Geant4_10
G4ReactionProduct.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 // J.L. Chuma, TRIUMF, 31-Oct-1996
27 // last modified: 19-Dec-1996
28 // modified by J.L.Chuma, 24-Jul-1997 to include total momentum
29 // inluded operator *, and some minor modifications.
30 // modified by H.P.Wellisch to add functionality needed by string models,
31 // cascade and Nucleus. (Mon Mar 16 1998)
32 // M. Kelsey 29-Aug-2011 -- Use G4Allocator model to avoid memory churn.
33 
34 #ifndef G4ReactionProduct_h
35 #define G4ReactionProduct_h 1
36 
37 #include "globals.hh"
38 #include "G4Allocator.hh"
39 #include "G4DynamicParticle.hh"
40 #include "G4HadProjectile.hh"
41 #include "G4HadronicException.hh"
42 
43 // To support better memory management and reduced fragmentation
44 class G4ReactionProduct;
45 #if defined G4HADRONIC_ALLOC_EXPORT
47 #else
49 #endif
50 
52 {
54  const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
55 
57  const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
58 
60  const G4double aDouble, const G4ReactionProduct &p2 )
63  result.SetMomentum(aDouble*p2.GetMomentum());
64  result.SetMass(p2.GetMass());
65  result.SetTotalEnergy(std::sqrt(result.GetMass()*result.GetMass()+
66  result.GetMomentum()*result.GetMomentum()));
67  return result;
68  }
69 
70  public:
72 
73  G4ReactionProduct( G4ParticleDefinition *aParticleDefinition );
74 
76 
78 
79  // Override new and delete for use with G4Allocator
81  return (void *)aRPAllocator.MallocSingle();
82  }
83 #ifdef __IBMCPP__
84  inline void* operator new(size_t, void *p) { ;;; if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; G4Allocator<G4ReactionProduct> &aRPAllocator = *aRPAllocator_G4MT_TLS_; ;;;
85  return p;
86  }
87 #endif
88  inline void operator delete(void* aReactionProduct) { ;;; if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; G4Allocator<G4ReactionProduct> &aRPAllocator = *aRPAllocator_G4MT_TLS_; ;;;
89  aRPAllocator.FreeSingle((G4ReactionProduct*)aReactionProduct);
90  }
91 
93 
95 
97 
98  inline G4bool operator== ( const G4ReactionProduct &right ) const
100 
101  inline G4bool operator!= ( const G4ReactionProduct &right ) const
103 
105  { if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; return theParticleDefinition; }
106 
107  void SetDefinition( G4ParticleDefinition *aParticleDefinition );
108 
109  void SetDefinitionAndUpdateE( G4ParticleDefinition *aParticleDefinition );
110 
111  void SetMomentum( const G4double x, const G4double y, const G4double z );
112 
113  void SetMomentum( const G4double x, const G4double y );
114 
115  void SetMomentum( const G4double z );
116 
117  inline void SetMomentum( const G4ThreeVector &mom )
119 
120  inline G4ThreeVector GetMomentum() const
122 
123  inline G4double GetTotalMomentum() const
124  { if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
125 
126  inline G4double GetTotalEnergy() const
128 
129  inline void SetKineticEnergy( const G4double en )
131  kineticEnergy = en;
132  totalEnergy = kineticEnergy + mass;
133  }
134 
135  inline G4double GetKineticEnergy() const
137 
138  inline void SetTotalEnergy( const G4double en )
140  totalEnergy = en;
141  kineticEnergy = totalEnergy - mass;
142  }
143 
144  inline void SetMass( const G4double mas )
146 
147  inline G4double GetMass() const
149 
150  inline void SetTOF( const G4double t )
152 
153  inline G4double GetTOF() const
155 
156  inline void SetSide( const G4int sid )
158 
159  inline G4int GetSide() const
161 
162  inline void SetNewlyAdded( const G4bool f )
164 
165  inline G4bool GetNewlyAdded() const
167 
168  inline void SetMayBeKilled( const G4bool f )
170 
171  inline G4bool GetMayBeKilled() const
173 
174  void SetZero();
175 
176  void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
177 
178  G4double Angle( const G4ReactionProduct &p ) const;
179 
182  positionInNucleus.setX(x);
183  positionInNucleus.setY(y);
184  positionInNucleus.setZ(z);
185  }
186 
187  inline void SetPositionInNucleus( G4ThreeVector & aPosition )
189  positionInNucleus = aPosition;
190  }
191 
196 
198 
200 
201  inline void HasInitialStateParton(G4bool aFlag) { if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; hasInitialStateParton = aFlag; }
202 
203  inline G4bool HasInitialStateParton() const { if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; return hasInitialStateParton; }
204 
205 #ifdef PRECOMPOUND_TEST
206  void SetCreatorModel(const G4String& aModel) { ;;; if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; G4Allocator<G4ReactionProduct> &aRPAllocator = *aRPAllocator_G4MT_TLS_; ;;; theCreatorModel = aModel; }
207  G4String GetCreatorModel() const { ;;; if (!aRPAllocator_G4MT_TLS_) aRPAllocator_G4MT_TLS_ = new G4Allocator<G4ReactionProduct> ; G4Allocator<G4ReactionProduct> &aRPAllocator = *aRPAllocator_G4MT_TLS_; ;;; return theCreatorModel; }
208 #endif
209 
210  private:
211 
212  G4ParticleDefinition *theParticleDefinition;
213 
214  // for use with string models and cascade.
215  G4ThreeVector positionInNucleus;
216  G4double formationTime;
217  G4bool hasInitialStateParton;
218 
219  // mass is included here, since pseudo-particles are created with masses different
220  // than the standard particle masses, and we are not allowed to create particles
221  G4double mass;
222 
223  G4ThreeVector momentum;
224 
225  G4double totalEnergy;
226  G4double kineticEnergy;
227 
228  G4double timeOfFlight;
229 
230  // side refers to how the particles are distributed in the
231  // forward (+) and backward (-) hemispheres in the center of mass system
232  G4int side;
233 
234  // NewlyAdded refers to particles added by "nuclear excitation", or as
235  // "black track" particles, or as deuterons, tritons, and alphas
236  G4bool NewlyAdded;
237  G4bool MayBeKilled;
238 
239 #ifdef PRECOMPOUND_TEST
240  G4String theCreatorModel;
241 #endif
242 };
243 
244 #endif
245 
Type * MallocSingle()
Definition: G4Allocator.hh:191
void SetPositionInNucleus(G4double x, G4double y, G4double z)
void HasInitialStateParton(G4bool aFlag)
G4double GetTotalMomentum() const
#define G4DLLEXPORT
Definition: G4Types.hh:62
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
void SetMayBeKilled(const G4bool f)
double x() const
G4int GetSide() const
#define G4DLLIMPORT
Definition: G4Types.hh:63
void SetKineticEnergy(const G4double en)
void SetMomentum(const G4double x, const G4double y, const G4double z)
const char * p
Definition: xmltok.h:285
void FreeSingle(Type *anElement)
Definition: G4Allocator.hh:201
G4bool GetMayBeKilled() const
void SetSide(const G4int sid)
G4double G4NeutronHPJENDLHEData::G4double result
G4double GetZPositionInNucleus() const
friend G4ReactionProduct operator-(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
G4double GetXPositionInNucleus() const
tuple x
Definition: test.py:50
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
void setY(double)
void SetDefinitionAndUpdateE(G4ParticleDefinition *aParticleDefinition)
G4bool operator!=(const G4ReactionProduct &right) const
TFile f
Definition: plotHisto.C:6
double z() const
void setZ(double)
void setX(double)
G4double Angle(const G4ReactionProduct &p) const
G4ParticleDefinition * GetDefinition() const
void SetNewlyAdded(const G4bool f)
G4ReactionProduct & operator=(const G4ReactionProduct &right)
Double_t y
Definition: plot.C:279
G4bool operator==(const G4ReactionProduct &right) const
void SetMass(const G4double mas)
bool G4bool
Definition: G4Types.hh:79
void SetTotalEnergy(const G4double en)
friend G4ReactionProduct operator*(const G4double aDouble, const G4ReactionProduct &p2)
G4double GetKineticEnergy() const
G4double GetFormationTime() const
void SetMomentum(const G4ThreeVector &mom)
G4double GetTotalEnergy() const
G4DLLIMPORT G4ThreadLocal G4Allocator< G4ReactionProduct > * aRPAllocator_G4MT_TLS_
double y() const
G4double GetTOF() const
void SetDefinition(G4ParticleDefinition *aParticleDefinition)
friend G4ReactionProduct operator+(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
tuple z
Definition: test.py:28
G4ThreeVector GetPositionInNucleus() const
G4ThreeVector GetMomentum() const
G4bool GetNewlyAdded() const
void SetTOF(const G4double t)
G4bool HasInitialStateParton() const
void SetFormationTime(G4double aTime)
double G4double
Definition: G4Types.hh:76
G4double GetMass() const
void SetPositionInNucleus(G4ThreeVector &aPosition)
G4double GetYPositionInNucleus() const