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
00031
00032 #ifndef G4PrimaryParticle_h
00033 #define G4PrimaryParticle_h 1
00034
00035 #include "globals.hh"
00036 #include "G4Allocator.hh"
00037 #include "G4ThreeVector.hh"
00038
00039 class G4ParticleDefinition;
00040 class G4VUserPrimaryParticleInformation;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 class G4PrimaryParticle
00067 {
00068 public:
00069 inline void *operator new(size_t);
00070 inline void operator delete(void *aStackedTrack);
00071
00072 public:
00073 G4PrimaryParticle();
00074 G4PrimaryParticle(G4int Pcode);
00075 G4PrimaryParticle(G4int Pcode,
00076 G4double px,G4double py,G4double pz);
00077 G4PrimaryParticle(G4int Pcode,
00078 G4double px,G4double py,G4double pz,G4double E);
00079 G4PrimaryParticle(const G4ParticleDefinition* Gcode);
00080 G4PrimaryParticle(const G4ParticleDefinition* Gcode,
00081 G4double px,G4double py,G4double pz);
00082 G4PrimaryParticle(const G4ParticleDefinition* Gcode,
00083 G4double px,G4double py,G4double pz,G4double E);
00084
00085 public:
00086 virtual ~G4PrimaryParticle();
00087
00088
00089
00090
00091 G4PrimaryParticle(const G4PrimaryParticle &right);
00092 G4PrimaryParticle & operator=(const G4PrimaryParticle &right);
00093
00094
00095 G4int operator==(const G4PrimaryParticle &right) const;
00096 G4int operator!=(const G4PrimaryParticle &right) const;
00097
00098 public:
00099 void Print() const;
00100
00101
00102
00103 public:
00104
00105
00106
00107
00108
00109
00110
00111
00112 G4int GetPDGcode() const;
00113 void SetPDGcode(G4int Pcode);
00114 G4ParticleDefinition * GetG4code() const;
00115 void SetG4code(const G4ParticleDefinition * Gcode);
00116 const G4ParticleDefinition * GetParticleDefinition() const;
00117 void SetParticleDefinition(const G4ParticleDefinition * pdef);
00118 G4double GetMass() const;
00119 void SetMass(G4double mas);
00120 G4double GetCharge() const;
00121 void SetCharge(G4double chg);
00122 G4double GetKineticEnergy() const;
00123 void SetKineticEnergy(G4double eKin);
00124 const G4ThreeVector& GetMomentumDirection() const;
00125 void SetMomentumDirection(const G4ThreeVector& p);
00126 G4double GetTotalMomentum() const;
00127 void Set4Momentum(G4double px, G4double py, G4double pz, G4double E);
00128 G4double GetTotalEnergy() const;
00129 void SetTotalEnergy(G4double eTot );
00130 G4ThreeVector GetMomentum() const;
00131 void SetMomentum(G4double px, G4double py, G4double pz);
00132 G4double GetPx() const;
00133 G4double GetPy() const;
00134 G4double GetPz() const;
00135 G4PrimaryParticle * GetNext() const;
00136 void SetNext(G4PrimaryParticle * np);
00137 G4PrimaryParticle * GetDaughter() const;
00138 void SetDaughter(G4PrimaryParticle * np);
00139 G4int GetTrackID() const;
00140 void SetTrackID(G4int id);
00141 G4ThreeVector GetPolarization() const;
00142 void SetPolarization(const G4ThreeVector& pol);
00143 void SetPolarization(G4double px,G4double py,G4double pz);
00144 G4double GetPolX() const;
00145 G4double GetPolY() const;
00146 G4double GetPolZ() const;
00147 G4double GetWeight() const;
00148 void SetWeight(G4double w);
00149 G4double GetProperTime() const;
00150 void SetProperTime(G4double t);
00151 G4VUserPrimaryParticleInformation* GetUserInformation() const;
00152 void SetUserInformation(G4VUserPrimaryParticleInformation* anInfo);
00153
00154 private:
00155 G4int PDGcode;
00156 const G4ParticleDefinition * G4code;
00157
00158 G4ThreeVector direction;
00159 G4double kinE;
00160
00161 G4PrimaryParticle * nextParticle;
00162 G4PrimaryParticle * daughterParticle;
00163
00164 G4int trackID;
00165
00166
00167
00168 G4double mass;
00169 G4double charge;
00170 G4double polX;
00171 G4double polY;
00172 G4double polZ;
00173 G4double Weight0;
00174 G4double properTime;
00175 G4VUserPrimaryParticleInformation* userInfo;
00176
00177 };
00178
00179 #if defined G4PARTICLES_ALLOC_EXPORT
00180 extern G4DLLEXPORT G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator;
00181 #else
00182 extern G4DLLIMPORT G4Allocator<G4PrimaryParticle> aPrimaryParticleAllocator;
00183 #endif
00184
00185 inline void * G4PrimaryParticle::operator new(size_t)
00186 {
00187 void * aPrimaryParticle;
00188 aPrimaryParticle = (void *) aPrimaryParticleAllocator.MallocSingle();
00189 return aPrimaryParticle;
00190 }
00191
00192 inline void G4PrimaryParticle::operator delete(void * aPrimaryParticle)
00193 {
00194 aPrimaryParticleAllocator.FreeSingle((G4PrimaryParticle *) aPrimaryParticle);
00195 }
00196
00197 inline G4double G4PrimaryParticle::GetMass() const
00198 { return mass; }
00199
00200 inline G4double G4PrimaryParticle::GetCharge() const
00201 { return charge; }
00202
00203 inline G4int G4PrimaryParticle::GetPDGcode() const
00204 { return PDGcode; }
00205
00206 inline G4ParticleDefinition * G4PrimaryParticle::GetG4code() const
00207 { return const_cast<G4ParticleDefinition*>(G4code); }
00208
00209 inline const G4ParticleDefinition * G4PrimaryParticle::GetParticleDefinition() const
00210 { return G4code; }
00211
00212 inline G4double G4PrimaryParticle::GetTotalMomentum() const
00213 {
00214 if (mass<0.) return kinE;
00215 else return std::sqrt(kinE*(kinE+2.*mass));
00216 }
00217
00218 inline G4ThreeVector G4PrimaryParticle::GetMomentum() const
00219 { return GetTotalMomentum()*direction;}
00220
00221 inline const G4ThreeVector& G4PrimaryParticle::GetMomentumDirection() const
00222 { return direction;}
00223
00224 inline void G4PrimaryParticle::SetMomentumDirection(const G4ThreeVector& p)
00225 { direction = p;}
00226
00227 inline G4double G4PrimaryParticle::GetPx() const
00228 { return GetTotalMomentum()*direction.x();}
00229
00230 inline G4double G4PrimaryParticle::GetPy() const
00231 { return GetTotalMomentum()*direction.y();}
00232
00233 inline G4double G4PrimaryParticle::GetPz() const
00234 { return GetTotalMomentum()*direction.z();}
00235
00236 inline G4double G4PrimaryParticle::GetTotalEnergy() const
00237 {
00238 if (mass<0.) return kinE;
00239 else return kinE+mass;
00240 }
00241
00242 inline void G4PrimaryParticle::SetTotalEnergy(G4double eTot )
00243 {
00244 if (mass<0.) kinE = eTot;
00245 else kinE = eTot - mass;
00246 }
00247
00248 inline G4double G4PrimaryParticle::GetKineticEnergy() const
00249 { return kinE; }
00250
00251 inline void G4PrimaryParticle::SetKineticEnergy(G4double eKin)
00252 { kinE = eKin; }
00253
00254 inline G4PrimaryParticle * G4PrimaryParticle::GetNext() const
00255 { return nextParticle; }
00256
00257 inline G4PrimaryParticle * G4PrimaryParticle::GetDaughter() const
00258 { return daughterParticle; }
00259
00260 inline G4int G4PrimaryParticle::GetTrackID() const
00261 { return trackID; }
00262
00263 inline G4ThreeVector G4PrimaryParticle::GetPolarization() const
00264 { return G4ThreeVector(polX,polY,polZ); }
00265
00266 inline G4double G4PrimaryParticle::GetPolX() const
00267 { return polX; }
00268
00269 inline G4double G4PrimaryParticle::GetPolY() const
00270 { return polY; }
00271
00272 inline G4double G4PrimaryParticle::GetPolZ() const
00273 { return polZ; }
00274
00275 inline G4double G4PrimaryParticle::GetWeight() const
00276 { return Weight0; }
00277
00278 inline void G4PrimaryParticle::SetWeight(G4double w)
00279 { Weight0 = w; }
00280
00281 inline void G4PrimaryParticle::SetProperTime(G4double t)
00282 { properTime = t; }
00283
00284 inline G4double G4PrimaryParticle::GetProperTime() const
00285 { return properTime; }
00286
00287 inline void G4PrimaryParticle::SetUserInformation(G4VUserPrimaryParticleInformation* anInfo)
00288 { userInfo = anInfo; }
00289
00290 inline G4VUserPrimaryParticleInformation* G4PrimaryParticle::GetUserInformation() const
00291 { return userInfo; }
00292
00293 inline void G4PrimaryParticle::SetG4code(const G4ParticleDefinition* Gcode)
00294 {
00295 SetParticleDefinition(Gcode);
00296 }
00297
00298 inline void G4PrimaryParticle::SetNext(G4PrimaryParticle * np)
00299 {
00300 if (nextParticle == 0) { nextParticle = np; }
00301 else { nextParticle->SetNext(np); }
00302 }
00303
00304 inline void G4PrimaryParticle::SetDaughter(G4PrimaryParticle * np)
00305 {
00306 if(daughterParticle == 0) { daughterParticle = np; }
00307 else { daughterParticle->SetNext(np); }
00308 }
00309
00310 inline void G4PrimaryParticle::SetTrackID(G4int id)
00311 { trackID = id; }
00312
00313 inline void G4PrimaryParticle::SetMass(G4double mas)
00314 { mass = mas; }
00315
00316 inline void G4PrimaryParticle::SetCharge(G4double chg)
00317 { charge = chg; }
00318
00319 inline void G4PrimaryParticle::SetPolarization(G4double px,G4double py,G4double pz)
00320 {
00321 polX = px;
00322 polY = py;
00323 polZ = pz;
00324 }
00325
00326 inline void G4PrimaryParticle::SetPolarization(const G4ThreeVector& pol)
00327 {
00328 polX = pol.x();
00329 polY = pol.y();
00330 polZ = pol.z();
00331 }
00332
00333 #endif
00334