Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 )
61  {
62  G4ReactionProduct result;
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
80  inline void* operator new(size_t) {
81  return (void *)aRPAllocator.MallocSingle();
82  }
83 #ifdef __IBMCPP__
84  inline void* operator new(size_t, void *p) {
85  return p;
86  }
87 #endif
88  inline void operator delete(void* aReactionProduct) {
89  aRPAllocator.FreeSingle((G4ReactionProduct*)aReactionProduct);
90  }
91 
93 
95 
97 
98  inline G4bool operator== ( const G4ReactionProduct &right ) const
99  { return ( this == (G4ReactionProduct*) &right ); }
100 
101  inline G4bool operator!= ( const G4ReactionProduct &right ) const
102  { return ( this != (G4ReactionProduct*) &right ); }
103 
105  { 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 )
118  { momentum = mom; }
119 
120  inline G4ThreeVector GetMomentum() const
121  { return momentum; }
122 
123  inline G4double GetTotalMomentum() const
124  { return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
125 
126  inline G4double GetTotalEnergy() const
127  { return totalEnergy; }
128 
129  inline void SetKineticEnergy( const G4double en )
130  {
131  kineticEnergy = en;
132  totalEnergy = kineticEnergy + mass;
133  }
134 
135  inline G4double GetKineticEnergy() const
136  { return kineticEnergy; }
137 
138  inline void SetTotalEnergy( const G4double en )
139  {
140  totalEnergy = en;
141  kineticEnergy = totalEnergy - mass;
142  }
143 
144  inline void SetMass( const G4double mas )
145  { mass = mas; }
146 
147  inline G4double GetMass() const
148  { return mass; }
149 
150  inline void SetTOF( const G4double t )
151  { timeOfFlight = t; }
152 
153  inline G4double GetTOF() const
154  { return timeOfFlight; }
155 
156  inline void SetSide( const G4int sid )
157  { side = sid; }
158 
159  inline G4int GetSide() const
160  { return side; }
161 
162  inline void SetNewlyAdded( const G4bool f )
163  { NewlyAdded = f; }
164 
165  inline G4bool GetNewlyAdded() const
166  { return NewlyAdded; }
167 
168  inline void SetMayBeKilled( const G4bool f )
169  { MayBeKilled = f; }
170 
171  inline G4bool GetMayBeKilled() const
172  { return MayBeKilled; }
173 
174  void SetZero();
175 
176  void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
177 
178  G4double Angle( const G4ReactionProduct &p ) const;
179 
181  {
182  positionInNucleus.setX(x);
183  positionInNucleus.setY(y);
184  positionInNucleus.setZ(z);
185  }
186 
187  inline void SetPositionInNucleus( G4ThreeVector & aPosition )
188  {
189  positionInNucleus = aPosition;
190  }
191 
192  inline G4ThreeVector GetPositionInNucleus() const {return positionInNucleus; }
193  inline G4double GetXPositionInNucleus() const { return positionInNucleus.x(); }
194  inline G4double GetYPositionInNucleus() const { return positionInNucleus.y(); }
195  inline G4double GetZPositionInNucleus() const { return positionInNucleus.z(); }
196 
197  inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
198 
199  inline G4double GetFormationTime() const { return formationTime; }
200 
201  inline void HasInitialStateParton(G4bool aFlag) { hasInitialStateParton = aFlag; }
202 
203  inline G4bool HasInitialStateParton() const { return hasInitialStateParton; }
204 
205 #ifdef PRECOMPOUND_TEST
206  void SetCreatorModel(const G4String& aModel) { theCreatorModel = aModel; }
207  G4String GetCreatorModel() const { 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