Geant4  10.00.p03
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 class G4ReactionProduct;
44 
45 // To support better memory management and reduced fragmentation
46 //
47 #if defined G4HADRONIC_ALLOC_EXPORT
49 #else
51 #endif
52 
54 {
56  const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
57 
59  const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
60 
62  const G4double aDouble, const G4ReactionProduct &p2 )
63  {
64  G4ReactionProduct result;
65  result.SetMomentum(aDouble*p2.GetMomentum());
66  result.SetMass(p2.GetMass());
67  result.SetTotalEnergy(std::sqrt(result.GetMass()*result.GetMass()+
68  result.GetMomentum()*result.GetMomentum()));
69  return result;
70  }
71 
72  public:
74 
75  G4ReactionProduct( G4ParticleDefinition *aParticleDefinition );
76 
78 
80 
81  // Override new and delete for use with G4Allocator
82  inline void* operator new(size_t) {
84  return (void *)aRPAllocator->MallocSingle();
85  }
86 #ifdef __IBMCPP__
87  inline void* operator new(size_t, void *p) {
88  return p;
89  }
90 #endif
91  inline void operator delete(void* aReactionProduct) {
92  aRPAllocator->FreeSingle((G4ReactionProduct*)aReactionProduct);
93  }
94 
96 
98 
100 
101  inline G4bool operator== ( const G4ReactionProduct &right ) const
102  { return ( this == (G4ReactionProduct*) &right ); }
103 
104  inline G4bool operator!= ( const G4ReactionProduct &right ) const
105  { return ( this != (G4ReactionProduct*) &right ); }
106 
108  { return theParticleDefinition; }
109 
110  void SetDefinition( G4ParticleDefinition *aParticleDefinition );
111 
112  void SetDefinitionAndUpdateE( G4ParticleDefinition *aParticleDefinition );
113 
114  void SetMomentum( const G4double x, const G4double y, const G4double z );
115 
116  void SetMomentum( const G4double x, const G4double y );
117 
118  void SetMomentum( const G4double z );
119 
120  inline void SetMomentum( const G4ThreeVector &mom )
121  { momentum = mom; }
122 
123  inline G4ThreeVector GetMomentum() const
124  { return momentum; }
125 
126  inline G4double GetTotalMomentum() const
127  { return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
128 
129  inline G4double GetTotalEnergy() const
130  { return totalEnergy; }
131 
132  inline void SetKineticEnergy( const G4double en )
133  {
134  kineticEnergy = en;
136  }
137 
138  inline G4double GetKineticEnergy() const
139  { return kineticEnergy; }
140 
141  inline void SetTotalEnergy( const G4double en )
142  {
143  totalEnergy = en;
145  }
146 
147  inline void SetMass( const G4double mas )
148  { mass = mas; }
149 
150  inline G4double GetMass() const
151  { return mass; }
152 
153  inline void SetTOF( const G4double t )
154  { timeOfFlight = t; }
155 
156  inline G4double GetTOF() const
157  { return timeOfFlight; }
158 
159  inline void SetSide( const G4int sid )
160  { side = sid; }
161 
162  inline G4int GetSide() const
163  { return side; }
164 
165  inline void SetNewlyAdded( const G4bool f )
166  { NewlyAdded = f; }
167 
168  inline G4bool GetNewlyAdded() const
169  { return NewlyAdded; }
170 
171  inline void SetMayBeKilled( const G4bool f )
172  { MayBeKilled = f; }
173 
174  inline G4bool GetMayBeKilled() const
175  { return MayBeKilled; }
176 
177  void SetZero();
178 
179  void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
180 
181  G4double Angle( const G4ReactionProduct &p ) const;
182 
184  {
185  positionInNucleus.setX(x);
186  positionInNucleus.setY(y);
187  positionInNucleus.setZ(z);
188  }
189 
190  inline void SetPositionInNucleus( G4ThreeVector & aPosition )
191  {
192  positionInNucleus = aPosition;
193  }
194 
196  inline G4double GetXPositionInNucleus() const { return positionInNucleus.x(); }
197  inline G4double GetYPositionInNucleus() const { return positionInNucleus.y(); }
198  inline G4double GetZPositionInNucleus() const { return positionInNucleus.z(); }
199 
200  inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
201 
202  inline G4double GetFormationTime() const { return formationTime; }
203 
204  inline void HasInitialStateParton(G4bool aFlag) { hasInitialStateParton = aFlag; }
205 
207 
208 #ifdef PRECOMPOUND_TEST
209  void SetCreatorModel(const G4String& aModel) { theCreatorModel = aModel; }
210  G4String GetCreatorModel() const { return theCreatorModel; }
211 #endif
212 
213  private:
214 
216 
217  // for use with string models and cascade.
221 
222  // mass is included here, since pseudo-particles are created with masses different
223  // than the standard particle masses, and we are not allowed to create particles
225 
227 
230 
232 
233  // side refers to how the particles are distributed in the
234  // forward (+) and backward (-) hemispheres in the center of mass system
236 
237  // NewlyAdded refers to particles added by "nuclear excitation", or as
238  // "black track" particles, or as deuterons, tritons, and alphas
241 
242 #ifdef PRECOMPOUND_TEST
243  G4String theCreatorModel;
244 #endif
245 };
246 
247 #endif
248 
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)
CLHEP::Hep3Vector G4ThreeVector
void SetMayBeKilled(const G4bool f)
G4int GetSide() const
#define G4DLLIMPORT
Definition: G4Types.hh:63
G4double z
Definition: TRTMaterials.hh:39
void SetKineticEnergy(const G4double en)
void SetMomentum(const G4double x, const G4double y, const G4double z)
G4bool GetMayBeKilled() const
void SetSide(const G4int sid)
G4double GetZPositionInNucleus() const
friend G4ReactionProduct operator-(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
G4double GetXPositionInNucleus() const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
void SetDefinitionAndUpdateE(G4ParticleDefinition *aParticleDefinition)
G4bool operator!=(const G4ReactionProduct &right) const
G4double Angle(const G4ReactionProduct &p) const
G4ParticleDefinition * GetDefinition() const
void SetNewlyAdded(const G4bool f)
G4ReactionProduct & operator=(const G4ReactionProduct &right)
G4bool operator==(const G4ReactionProduct &right) const
void SetMass(const G4double mas)
G4ParticleDefinition * theParticleDefinition
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector momentum
void SetTotalEnergy(const G4double en)
G4DLLIMPORT G4ThreadLocal G4Allocator< G4ReactionProduct > * aRPAllocator
friend G4ReactionProduct operator*(const G4double aDouble, const G4ReactionProduct &p2)
G4double GetKineticEnergy() const
G4double GetFormationTime() const
void SetMomentum(const G4ThreeVector &mom)
G4double GetTotalEnergy() const
G4double GetTOF() const
void SetDefinition(G4ParticleDefinition *aParticleDefinition)
friend G4ReactionProduct operator+(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
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
G4ThreeVector positionInNucleus
G4double GetMass() const
void SetPositionInNucleus(G4ThreeVector &aPosition)
G4double GetYPositionInNucleus() const