Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4InuclParticle.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4InuclParticle.hh 66241 2012-12-13 18:34:42Z gunter $
27 //
28 // 20100112 M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
29 // 20100409 M. Kelsey -- Drop unused string argument from ctors.
30 // 20100519 M. Kelsey -- Add public access to G4DynamicParticle content
31 // 20100715 M. Kelsey -- Add setKineticEnergy() function
32 // 20100915 M. Kelsey -- Add constructor to copy G4DynamicParticle input
33 // 20110214 M. Kelsey -- Replace integer "model" with enum
34 // 20110225 M. Kelsey -- Add equality operator (NOT sorting!)
35 // 20110721 M. Kelsey -- Add model ID as optional ctor argument (so subclasses
36 // don't have to call SetModel()).
37 // 20110917 M. Kelsey -- Add coalesence to model ID list
38 // 20110919 M. Kelsey -- Move setDefinition code to .cc to allow null argument
39 // 20110922 M. Kelsey -- Add stream argument to printParticle() => print(),
40 // add operator<<().
41 // 20140310 M. Kelsey -- Fix constness in G4PD* passing
42 
43 #ifndef G4INUCL_PARTICLE_HH
44 #define G4INUCL_PARTICLE_HH
45 
46 #include <iosfwd>
48 
49 #include "globals.hh"
50 #include "G4LorentzVector.hh"
51 #include "G4DynamicParticle.hh"
52 
54 public:
55  // used to indicate model that created instance of G4InuclParticle
56  // 0 default
57  // 1 bullet
58  // 2 target
59  // 3 G4ElementaryParticleCollider
60  // 4 G4IntraNucleiCascader
61  // 5 G4NonEquilibriumEvaporator
62  // 6 G4EquilibriumEvaporator
63  // 7 G4Fissioner
64  // 8 G4BigBanger
65  // 9 G4PreCompound
66  // 10 G4CascadeCoalescence
70 
71 public:
72  G4InuclParticle() : modelId(DefaultModel) {}
73 
75  : pDP(dynPart), modelId(model) {}
76 
78  : modelId(model) { pDP.Set4Momentum(mom*CLHEP::GeV/CLHEP::MeV); } // Bertini to G4 units
79 
80  virtual ~G4InuclParticle() {}
81 
82  // Copy and assignment constructors for use with std::vector<>
84  : pDP(right.pDP), modelId(right.modelId) {}
85 
87 
88  // Equality (comparison) operator -- NOT SORTING
90  return ( (&right == this) || (pDP == right.pDP) ); // Ignore model code
91  }
92 
94  return !operator==(right);
95  }
96 
97  // This is no longer required, as setMomentum() handles mass adjustment
98  void setEnergy() { ; }
99 
100  // These are call-throughs to G4DynamicParticle
101  void setMomentum(const G4LorentzVector& mom);
102 
104 
105  void setMass(G4double mass) { pDP.SetMass(mass*CLHEP::GeV/CLHEP::MeV); }
106 
107  G4double getMass() const {
108  return pDP.GetMass()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
109  }
110 
111  G4double getCharge() const {
112  return pDP.GetCharge();
113  }
114 
116  return pDP.GetKineticEnergy()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
117  }
118 
119  G4double getEnergy() const {
120  return pDP.GetTotalEnergy()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
121  }
122 
124  return pDP.GetTotalMomentum()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
125  }
126 
128  return pDP.Get4Momentum()*CLHEP::MeV/CLHEP::GeV; // From G4 to Bertini units
129  }
130 
131  virtual void print(std::ostream& os) const;
132 
134  return pDP.GetDefinition();
135  }
136 
138  return pDP;
139  }
140 
141 public:
142  void setModel(Model model) { modelId = model; }
143  Model getModel() const { return modelId; }
144 
145 protected:
146  // Special constructors for subclasses to set particle type correctly
149  : modelId(model) { setDefinition(pd); }
150 
151  // FIXME: Bertini code doesn't pass valid 4-vectors, so force mass value
152  // from supplied PartDefn, with required unit conversions
155 
156  // NOTE: Momentum forced along Z direction
159  : pDP(pd,G4ThreeVector(0.,0.,1.),ekin*CLHEP::GeV/CLHEP::MeV), modelId(model) {}
160 
161  void setDefinition(const G4ParticleDefinition* pd);
162 
163 private:
164  G4DynamicParticle pDP; // Carries all the kinematics and info
165  Model modelId;
166 };
167 
168 // Proper stream output (just calls print())
169 
170 std::ostream& operator<<(std::ostream& os, const G4InuclParticle& part);
171 
172 #endif // G4INUCL_PARTICLE_HH
virtual ~G4InuclParticle()
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
G4InuclParticle(const G4ParticleDefinition *pd, G4double ekin, Model model=DefaultModel)
const G4DynamicParticle & getDynamicParticle() const
G4LorentzVector getMomentum() const
const G4ParticleDefinition * getDefinition() const
G4InuclParticle(const G4ParticleDefinition *pd, Model model=DefaultModel)
void setDefinition(const G4ParticleDefinition *pd)
G4double getEnergy() const
G4ParticleDefinition * GetDefinition() const
G4double getKineticEnergy() const
G4double GetTotalMomentum() const
G4InuclParticle(const G4DynamicParticle &dynPart, Model model=DefaultModel)
virtual void print(std::ostream &os) const
G4double GetMass() const
G4double GetCharge() const
static constexpr double MeV
Model getModel() const
void SetKineticEnergy(G4double aEnergy)
G4LorentzVector Get4Momentum() const
void Set4Momentum(const G4LorentzVector &momentum)
bool operator==(const G4InuclParticle &right)
static constexpr double GeV
G4InuclParticle(const G4LorentzVector &mom, Model model=DefaultModel)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static constexpr double GeV
Definition: G4SIunits.hh:217
G4InuclParticle(const G4InuclParticle &right)
G4double getCharge() const
G4InuclParticle & operator=(const G4InuclParticle &right)
void setMass(G4double mass)
void setModel(Model model)
static constexpr double MeV
Definition: G4SIunits.hh:214
void setKineticEnergy(G4double ekin)
void setMomentum(const G4LorentzVector &mom)
double G4double
Definition: G4Types.hh:76
const XML_Char XML_Content * model
Definition: expat.h:151
bool operator!=(const G4InuclParticle &right)
void SetMass(G4double mass)
G4double getMomModule() const
G4double getMass() const