G4InuclElementaryParticle.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 // $Id$
00027 //
00028 // 20100114  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
00029 // 20100409  M. Kelsey -- Drop unused string argument from ctors.
00030 // 20100429  M. Kelsey -- Change "photon()" to "isPhoton()", use enum names
00031 // 20100914  M. Kelsey -- Move printout to .cc file
00032 // 20100915  M. Kelsey -- Add hyperon() identification function, ctor for
00033 //              G4DynamicParticle
00034 // 20110117  M. Kelsey -- Add antinucleon() and antibaryon() flag
00035 // 20110127  M. Kelsey -- Drop generation.
00036 // 20110214  M. Kelsey -- Replace integer "model" with enum
00037 // 20110321  M. Kelsey -- Fix getStrangeness() to return int
00038 // 20110721  M. Kelsey -- Add constructors to take G4ParticleDefinition as
00039 //              input instead of type code, to allow pass-through of unusable
00040 //              particles during rescattering.  Modify ctors to pass model to
00041 //              base ctor.
00042 // 20110801  M. Kelsey -- Add fill() functions to replicate ctors, allowing
00043 //              reuse of objects as buffers; c.f. G4InuclNuclei.
00044 // 20110922  M. Kelsey -- Add stream argument to printParticle() => print()
00045 // 20120608  M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
00046 
00047 #ifndef G4INUCL_ELEMENTARY_PARTICLE_HH
00048 #define G4INUCL_ELEMENTARY_PARTICLE_HH
00049 
00050 #include "G4InuclParticle.hh"
00051 #include "G4InuclParticleNames.hh"
00052 #include "globals.hh"
00053 
00054 class G4ParticleDefinition;
00055 
00056 
00057 class G4InuclElementaryParticle : public G4InuclParticle {
00058 public:
00059   G4InuclElementaryParticle() 
00060     : G4InuclParticle() {}
00061 
00062   G4InuclElementaryParticle(G4int ityp, Model model=DefaultModel) 
00063     : G4InuclParticle(makeDefinition(ityp), model) {}
00064 
00065   G4InuclElementaryParticle(const G4DynamicParticle& dynPart,
00066                             Model model=DefaultModel)
00067     : G4InuclParticle(dynPart, model) {}
00068 
00069   G4InuclElementaryParticle(const G4LorentzVector& mom,
00070                             G4int ityp, Model model=DefaultModel)
00071     : G4InuclParticle(makeDefinition(ityp), mom, model) {}
00072 
00073   G4InuclElementaryParticle(G4double ekin, G4int ityp,
00074                             Model model=DefaultModel) 
00075     : G4InuclParticle(makeDefinition(ityp), ekin, model) {}
00076 
00077   // WARNING:  This may create a particle without a valid type code!
00078   G4InuclElementaryParticle(const G4LorentzVector& mom,
00079                             G4ParticleDefinition* pd, Model model=DefaultModel)
00080     : G4InuclParticle(pd, mom, model) {}
00081 
00082   // Copy and assignment constructors for use with std::vector<>
00083   G4InuclElementaryParticle(const G4InuclElementaryParticle& right)
00084     : G4InuclParticle(right) {}
00085 
00086   G4InuclElementaryParticle& operator=(const G4InuclElementaryParticle& right);
00087 
00088   // Overwrite data structure (avoids creating/copying temporaries)
00089   void fill(G4int ityp, Model model=DefaultModel) { fill(0., ityp, model); }
00090 
00091   void fill(const G4LorentzVector& mom, G4int ityp, Model model=DefaultModel);
00092 
00093   void fill(G4double ekin, G4int ityp, Model model=DefaultModel);
00094 
00095   // WARNING:  This may create a particle without a valid type code!
00096   void fill(const G4LorentzVector& mom, G4ParticleDefinition* pd,
00097             Model model=DefaultModel);
00098 
00099   // Assignment and accessor functions
00100   void setType(G4int ityp);
00101   G4int type() const { return type(getDefinition()); }
00102 
00103   static G4int type(const G4ParticleDefinition* pd);
00104 
00105   G4bool isPhoton() const { return (type() == G4InuclParticleNames::photon); }
00106 
00107   G4bool pion() const { return (type()==G4InuclParticleNames::pionPlus ||
00108                                 type()==G4InuclParticleNames::pionMinus ||
00109                                 type()==G4InuclParticleNames::pionZero); }
00110 
00111   G4bool nucleon() const { return (type()==G4InuclParticleNames::proton ||
00112                                    type()==G4InuclParticleNames::neutron); }
00113 
00114   G4bool antinucleon() const {
00115     return (type()==G4InuclParticleNames::antiProton ||
00116             type()==G4InuclParticleNames::antiNeutron); }
00117 
00118   G4int baryon() const {                // Can use as a bool (!=0 ==> true)
00119     return getDefinition()->GetBaryonNumber();
00120   }
00121 
00122   G4bool antibaryon() const { return baryon() < 0; }
00123 
00124   G4bool hyperon() const { return (baryon() && getStrangeness()); }
00125 
00126   G4bool quasi_deutron() const { return (type() > 100); }
00127 
00128   G4int getStrangeness() const { return getStrangeness(type()); }
00129 
00130   G4bool valid() const { return type()>0; }
00131 
00132   virtual void print(std::ostream& os) const;
00133 
00134   static G4int getStrangeness(G4int type);
00135   static G4double getParticleMass(G4int type);
00136 
00137 protected:
00138   // Convert internal type code to standard GEANT4 pointer
00139   static G4ParticleDefinition* makeDefinition(G4int ityp);
00140 };        
00141 
00142 #endif // G4INUCL_ELEMENTARY_PARTICLE_HH 

Generated on Mon May 27 17:48:38 2013 for Geant4 by  doxygen 1.4.7