G4PrimaryParticle.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
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 // class description:
00043 //
00044 //  This is a class which represents a primary particle.
00045 // This is completely deferent class from G4Track or G4DynamicParticle.
00046 // This class is designed with taking into account the possibility of
00047 // making this class persistent, i.e. kept with G4Event class object
00048 // to ODBMS. Thus this class is almost free from any other Geant4 classes.
00049 // The only exception is a pointer to G4ParticleDefinition but it can be
00050 // rebuilt by the PDGcode.
00051 //
00052 //  Primary particles are stored in G4PrimaryVertex object with a form
00053 // of linked list. Also, an object of this PrimaryParticle class can have
00054 // one or more objects of this class as its daughters with a form of 
00055 // linked list.
00056 //  A parimary particle represented by this class object needs not to be
00057 // a particle of type which Geant4 can simulate.
00058 //  case a) mother particle is not a particle Geant4 can simulate
00059 //   daughters associated to the mother will be examined.
00060 //  case b) mother particle is a perticle Geant4 can simulate
00061 //   daughters associated to the mother will be converted to G4Dynamic 
00062 //   particle and be set to the mother G4Track. For this case, dauthers
00063 //   are used as the "pre-fixed" decay channel.
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: // with description
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   // copy constructor and assignment operator 
00089   // nextParticle and daughterParticle is copied by object (i.e. deep copy)
00090   // userInfo will nt be copied
00091   G4PrimaryParticle(const G4PrimaryParticle &right);   
00092   G4PrimaryParticle & operator=(const G4PrimaryParticle &right);
00093   
00094   // equal operator  returns 'true' only if the same object (i.e comarison by pointer value)
00095   G4int operator==(const G4PrimaryParticle &right) const;
00096   G4int operator!=(const G4PrimaryParticle &right) const;
00097   
00098  public: // with description
00099   void Print() const;
00100   // Print the properties of the particle.
00101   
00102 
00103  public: // with description
00104   // followings are get/set methods available.
00105   //   "trackID" will be set if this particle is sent to G4EventManager 
00106   //    and converted to G4Track. Otherwise = -1.
00107   //    The mass and charge in G4ParticleDefinition will be used in default.
00108   //   "SetMass" and "SetCharge" methods are used to set dynamical mass and charge 
00109   //   G4DynamicParticle."GetMass" and "GetCharge" methods will return 
00110   //   those in G4ParticleDefinition if users do not set dynamical ones. 
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;  // This will be set if this particle is
00165   // sent to G4EventManager and converted to
00166   // G4Track. Otherwise = -1.
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 

Generated on Mon May 27 17:49:25 2013 for Geant4 by  doxygen 1.4.7