ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ReactionProduct.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ReactionProduct.hh
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(const 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 
107  inline const G4ParticleDefinition* GetDefinition() const
108  { return theParticleDefinition; }
109 
110  void SetDefinition(const G4ParticleDefinition* aParticleDefinition );
111 
112  void SetDefinitionAndUpdateE(const 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 SetCreatorModel( const G4int mod )
166  { theCreatorModel = mod; }
167 
168  inline G4int GetCreatorModel() const
169  { return theCreatorModel; }
170 
171  inline void SetNewlyAdded( const G4bool f )
172  { NewlyAdded = f; }
173 
174  inline G4bool GetNewlyAdded() const
175  { return NewlyAdded; }
176 
177  inline void SetMayBeKilled( const G4bool f )
178  { MayBeKilled = f; }
179 
180  inline G4bool GetMayBeKilled() const
181  { return MayBeKilled; }
182 
183  void SetZero();
184 
185  void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
186 
187  G4double Angle( const G4ReactionProduct &p ) const;
188 
190  {
194  }
195 
196  inline void SetPositionInNucleus( G4ThreeVector & aPosition )
197  {
198  positionInNucleus = aPosition;
199  }
200 
202  inline G4double GetXPositionInNucleus() const { return positionInNucleus.x(); }
203  inline G4double GetYPositionInNucleus() const { return positionInNucleus.y(); }
204  inline G4double GetZPositionInNucleus() const { return positionInNucleus.z(); }
205 
206  inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
207 
208  inline G4double GetFormationTime() const { return formationTime; }
209 
210  inline void HasInitialStateParton(G4bool aFlag) { hasInitialStateParton = aFlag; }
211 
213 
214 private:
215 
217 
218  // for use with string models and cascade.
222 
223  // mass is included here, since pseudo-particles are created with masses different
224  // than the standard particle masses, and we are not allowed to create particles
226 
228 
231 
233 
234  // side refers to how the particles are distributed in the
235  // forward (+) and backward (-) hemispheres in the center of mass system
237 
239 
240  // NewlyAdded refers to particles added by "nuclear excitation", or as
241  // "black track" particles, or as deuterons, tritons, and alphas
244 };
245 
246 #endif
247