Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:31

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // 20100112  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
0028 // 20100409  M. Kelsey -- Drop unused string argument from ctors.
0029 // 20100519  M. Kelsey -- Add public access to G4DynamicParticle content
0030 // 20100715  M. Kelsey -- Add setKineticEnergy() function
0031 // 20100915  M. Kelsey -- Add constructor to copy G4DynamicParticle input
0032 // 20110214  M. Kelsey -- Replace integer "model" with enum
0033 // 20110225  M. Kelsey -- Add equality operator (NOT sorting!)
0034 // 20110721  M. Kelsey -- Add model ID as optional ctor argument (so subclasses
0035 //      don't have to call SetModel()).
0036 // 20110917  M. Kelsey -- Add coalesence to model ID list
0037 // 20110919  M. Kelsey -- Move setDefinition code to .cc to allow null argument
0038 // 20110922  M. Kelsey -- Add stream argument to printParticle() => print(),
0039 //      add operator<<().
0040 // 20140310  M. Kelsey -- Fix constness in G4PD* passing
0041 
0042 #ifndef G4INUCL_PARTICLE_HH
0043 #define G4INUCL_PARTICLE_HH
0044 
0045 #include <iosfwd>
0046 #include <CLHEP/Units/SystemOfUnits.h>
0047 
0048 #include "globals.hh"
0049 #include "G4LorentzVector.hh"
0050 #include "G4DynamicParticle.hh"
0051 
0052 class G4InuclParticle {
0053 public:
0054   // used to indicate model that created instance of G4InuclParticle
0055   // 0 default
0056   // 1 bullet
0057   // 2 target
0058   // 3 G4ElementaryParticleCollider
0059   // 4 G4IntraNucleiCascader
0060   // 5 G4NonEquilibriumEvaporator
0061   // 6 G4EquilibriumEvaporator
0062   // 7 G4Fissioner
0063   // 8 G4BigBanger
0064   // 9 G4PreCompound
0065   // 10 G4CascadeCoalescence
0066   enum Model { DefaultModel, bullet, target, EPCollider, INCascader,
0067            NonEquilib, Equilib, Fissioner, BigBanger, PreCompound,
0068            Coalescence };
0069 
0070 public:
0071   G4InuclParticle() : modelId(DefaultModel) {}
0072 
0073   G4InuclParticle(const G4DynamicParticle& dynPart, Model model=DefaultModel)
0074     : pDP(dynPart), modelId(model) {}
0075 
0076   G4InuclParticle(const G4LorentzVector& mom, Model model=DefaultModel)
0077     : modelId(model) { pDP.Set4Momentum(mom*CLHEP::GeV/CLHEP::MeV); }   // Bertini to G4 units
0078 
0079   virtual ~G4InuclParticle() {}
0080 
0081   // Copy and assignment constructors for use with std::vector<>
0082   G4InuclParticle(const G4InuclParticle& right)
0083     : pDP(right.pDP), modelId(right.modelId) {}
0084 
0085   G4InuclParticle& operator=(const G4InuclParticle& right);
0086 
0087   // Equality (comparison) operator -- NOT SORTING
0088   G4bool operator==(const G4InuclParticle& right) {
0089     return ( (&right == this) || (pDP == right.pDP) );  // Ignore model code
0090   }
0091 
0092   G4bool operator!=(const G4InuclParticle& right) {
0093     return !operator==(right);
0094   }
0095 
0096   // This is no longer required, as setMomentum() handles mass adjustment
0097   void setEnergy() { ; }
0098 
0099   // These are call-throughs to G4DynamicParticle
0100   void setMomentum(const G4LorentzVector& mom);
0101 
0102   void setKineticEnergy(G4double ekin) { pDP.SetKineticEnergy(ekin*CLHEP::GeV/CLHEP::MeV); }
0103 
0104   void setMass(G4double mass) { pDP.SetMass(mass*CLHEP::GeV/CLHEP::MeV); }
0105 
0106   G4double getMass() const {
0107     return pDP.GetMass()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
0108   }
0109 
0110   G4double getCharge() const {
0111     return pDP.GetCharge();
0112   }
0113 
0114   G4double getKineticEnergy() const {
0115     return pDP.GetKineticEnergy()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
0116   }
0117 
0118   G4double getEnergy() const {
0119     return pDP.GetTotalEnergy()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
0120   }
0121 
0122   G4double getMomModule() const {
0123     return pDP.GetTotalMomentum()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
0124   }
0125 
0126   G4LorentzVector getMomentum() const {
0127     return pDP.Get4Momentum()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
0128   }
0129 
0130   virtual void print(std::ostream& os) const;
0131 
0132   const G4ParticleDefinition* getDefinition() const {
0133     return pDP.GetDefinition();
0134   }
0135 
0136   const G4DynamicParticle& getDynamicParticle() const {
0137     return pDP;
0138   }
0139 
0140 public:
0141   void setModel(Model model) { modelId = model; }
0142   Model getModel() const { return modelId; }
0143 
0144 protected: 
0145   //  Special constructors for subclasses to set particle type correctly
0146   explicit G4InuclParticle(const G4ParticleDefinition* pd,
0147                Model model=DefaultModel)
0148     : modelId(model) { setDefinition(pd); }
0149 
0150   // FIXME: Bertini code doesn't pass valid 4-vectors, so force mass value
0151   //        from supplied PartDefn, with required unit conversions
0152   G4InuclParticle(const G4ParticleDefinition* pd, const G4LorentzVector& mom,
0153           Model model=DefaultModel);
0154 
0155   // NOTE:  Momentum forced along Z direction
0156   G4InuclParticle(const G4ParticleDefinition* pd, G4double ekin,
0157           Model model=DefaultModel)
0158     : pDP(pd,G4ThreeVector(0.,0.,1.),ekin*CLHEP::GeV/CLHEP::MeV), modelId(model) {}
0159 
0160   void setDefinition(const G4ParticleDefinition* pd);
0161 
0162 private:
0163   G4DynamicParticle pDP;        // Carries all the kinematics and info
0164   Model modelId;
0165 };        
0166 
0167 // Proper stream output (just calls print())
0168 
0169 std::ostream& operator<<(std::ostream& os, const G4InuclParticle& part);
0170 
0171 #endif // G4INUCL_PARTICLE_HH