00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "G4PrimaryVertex.hh"
00031 #include "G4SystemOfUnits.hh"
00032 #include "G4VUserPrimaryVertexInformation.hh"
00033 #include "G4ios.hh"
00034
00035 G4Allocator<G4PrimaryVertex> aPrimaryVertexAllocator;
00036
00037 G4PrimaryVertex::G4PrimaryVertex()
00038 :X0(0.),Y0(0.),Z0(0.),T0(0.),theParticle(0),theTail(0),
00039 nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
00040 {;}
00041
00042 G4PrimaryVertex::G4PrimaryVertex(
00043 G4double x0,G4double y0,G4double z0,G4double t0)
00044 :X0(x0),Y0(y0),Z0(z0),T0(t0),theParticle(0),theTail(0),
00045 nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
00046 {;}
00047
00048 G4PrimaryVertex::G4PrimaryVertex(G4ThreeVector xyz0,G4double t0)
00049 :T0(t0),theParticle(0),theTail(0),
00050 nextVertex(0),tailVertex(0),numberOfParticle(0),Weight0(1.0),userInfo(0)
00051 {
00052 X0=xyz0.x();
00053 Y0=xyz0.y();
00054 Z0=xyz0.z();
00055 }
00056
00057 G4PrimaryVertex::G4PrimaryVertex(const G4PrimaryVertex & right)
00058 :theParticle(0),theTail(0),
00059 nextVertex(0),tailVertex(0),userInfo(0)
00060 {
00061 numberOfParticle = right.numberOfParticle;
00062 *this = right;
00063 }
00064
00065 G4PrimaryVertex::~G4PrimaryVertex()
00066 {
00067 if(theParticle != 0) {
00068 delete theParticle;
00069 theParticle = 0;
00070 }
00071 if(nextVertex != 0) {
00072 delete nextVertex;
00073 nextVertex =0;
00074 }
00075 if(userInfo != 0) {
00076 delete userInfo;
00077 userInfo = 0;
00078 }
00079 }
00080
00081 G4PrimaryVertex & G4PrimaryVertex::operator=(const G4PrimaryVertex & right)
00082 {
00083 if (this != &right) {
00084 X0 = right.X0;
00085 Y0 = right.Y0;
00086 Z0 = right.Z0;
00087 T0 = right.T0;
00088 Weight0 = right.Weight0;
00089
00090 numberOfParticle = 0;
00091 if (theParticle !=0) delete theParticle;
00092 theParticle =0;
00093 theTail =0;
00094 if (right.theParticle !=0 ) {
00095 theParticle = new G4PrimaryParticle(*(right.theParticle));
00096 numberOfParticle += 1;
00097 theTail = theParticle;
00098 G4PrimaryParticle * np = theParticle->GetNext();
00099 while (np !=0) {
00100 numberOfParticle += 1;
00101 theTail = np;
00102 np = np->GetNext();
00103 }
00104 }
00105
00106 if (nextVertex !=0 ) delete nextVertex;
00107 nextVertex = 0;
00108 tailVertex =0;
00109 if (right.nextVertex !=0 ) {
00110 nextVertex = new G4PrimaryVertex(*(right.nextVertex));
00111 tailVertex = nextVertex;
00112 G4PrimaryVertex* nv = nextVertex->GetNext();
00113 while (nv !=0) {
00114 tailVertex = nv;
00115 nv = nv->GetNext();
00116 }
00117 }
00118
00119
00120 userInfo = 0;
00121 }
00122 return *this;
00123 }
00124
00125 G4int G4PrimaryVertex::operator==(const G4PrimaryVertex &right) const
00126 { return (this==&right); }
00127
00128 G4int G4PrimaryVertex::operator!=(const G4PrimaryVertex &right) const
00129 { return (this!=&right); }
00130
00131 G4PrimaryParticle* G4PrimaryVertex::GetPrimary(G4int i) const
00132 {
00133 if( i >= 0 && i < numberOfParticle ) {
00134 G4PrimaryParticle* particle = theParticle;
00135 for( G4int j=0; j<i; j++ ){
00136 if( particle == 0 ) return 0;
00137 particle = particle->GetNext();
00138 }
00139 return particle;
00140 } else {
00141 return 0; }
00142 }
00143
00144 void G4PrimaryVertex::Print() const
00145 {
00146 G4cout << "Vertex ( "
00147 << X0/mm << "[mm], "
00148 << Y0/mm << "[mm], "
00149 << Z0/mm << "[mm], "
00150 << T0/ns << "[ns] )"
00151 << " Weight " << Weight0 << G4endl;
00152 if(userInfo!=0) userInfo->Print();
00153 G4cout << " -- Primary particles :: "
00154 << " # of primaries =" << numberOfParticle << G4endl;
00155 if( theParticle != 0) theParticle->Print();
00156 if (nextVertex !=0 ) {
00157 G4cout << "Next Vertex " << G4endl;
00158 nextVertex->Print();
00159 }
00160 }