Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ReactionProduct.cc
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, 05-May-97
29 // M. Kelsey 29-Aug-2011 -- Use G4Allocator for better memory management
30 
31 #include "G4ReactionProduct.hh"
32 
34 
35 
37  theParticleDefinition(NULL),
38  formationTime(0.0),
39  hasInitialStateParton(false),
40  mass(0.0),
41  totalEnergy(0.0),
42  kineticEnergy(0.0),
43  timeOfFlight(0.0),
44  side(0),
45  theCreatorModel(-1),
46  NewlyAdded(false),
47  MayBeKilled(true)
48  {
49  SetMomentum( 0.0, 0.0, 0.0 );
50  SetPositionInNucleus( 0.0, 0.0, 0.0 );
51  }
52 
54  const G4ParticleDefinition *aParticleDefinition )
55  {
56  SetMomentum( 0.0, 0.0, 0.0 );
57  SetPositionInNucleus( 0.0, 0.0, 0.0 );
58  formationTime = 0.0;
59  hasInitialStateParton = false;
60  theParticleDefinition = aParticleDefinition;
61  mass = aParticleDefinition->GetPDGMass();
62  totalEnergy = mass;
63  kineticEnergy = 0.0;
64  (aParticleDefinition->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0;
65  side = 0;
66  theCreatorModel = -1;
67  NewlyAdded = false;
68  MayBeKilled = true;
69  }
70 
72  const G4ReactionProduct &right )
73  {
74  theParticleDefinition = right.theParticleDefinition;
75  positionInNucleus = right.positionInNucleus;
76  formationTime = right.formationTime;
77  hasInitialStateParton = right.hasInitialStateParton;
78  momentum = right.momentum;
79  mass = right.mass;
80  totalEnergy = right.totalEnergy;
81  kineticEnergy = right.kineticEnergy;
82  timeOfFlight = right.timeOfFlight;
83  side = right.side;
84  theCreatorModel = right.theCreatorModel;
85  NewlyAdded = right.NewlyAdded;
86  MayBeKilled = right.MayBeKilled;
87  }
88 
90  const G4ReactionProduct &right )
91  {
92  if( this != &right ) {
93  theParticleDefinition = right.theParticleDefinition;
94  positionInNucleus = right.positionInNucleus;
95  formationTime = right.formationTime;
96  hasInitialStateParton = right.hasInitialStateParton;
97  momentum = right.momentum;
98  mass = right.mass;
99  totalEnergy = right.totalEnergy;
100  kineticEnergy = right.kineticEnergy;
101  timeOfFlight = right.timeOfFlight;
102  side = right.side;
103  theCreatorModel = right.theCreatorModel;
104  NewlyAdded = right.NewlyAdded;
105  MayBeKilled = right.MayBeKilled;
106  }
107  return *this;
108  }
109 
111  const G4DynamicParticle &right )
112  {
113  theParticleDefinition = right.GetDefinition();
114  SetPositionInNucleus( 0.0, 0.0, 0.0 );
115  formationTime = 0.0;
116  hasInitialStateParton = false;
117  momentum = right.GetMomentum();
118  mass = right.GetDefinition()->GetPDGMass();
119  totalEnergy = right.GetTotalEnergy();
120  kineticEnergy = right.GetKineticEnergy();
121  (right.GetDefinition()->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0;
122  side = 0;
123  theCreatorModel = -1;
124  NewlyAdded = false;
125  MayBeKilled = true;
126  return *this;
127  }
128 
130  const G4HadProjectile &right )
131  {
132  theParticleDefinition = right.GetDefinition();
133  SetPositionInNucleus( 0.0, 0.0, 0.0 );
134  formationTime = 0.0;
135  hasInitialStateParton = false;
136  momentum = right.Get4Momentum().vect();
137  mass = right.GetDefinition()->GetPDGMass();
138  totalEnergy = right.Get4Momentum().e();
139  kineticEnergy = right.GetKineticEnergy();
140  (right.GetDefinition()->GetPDGEncoding()<0) ? timeOfFlight=-1.0 : timeOfFlight=1.0;
141  side = 0;
142  theCreatorModel = -1;
143  NewlyAdded = false;
144  MayBeKilled = true;
145  return *this;
146  }
147 
149  const G4ParticleDefinition *aParticleDefinition )
150  { G4double aKineticEnergy = GetKineticEnergy();
151  G4double pp = GetMomentum().mag();
152  G4ThreeVector aMomentum = GetMomentum();
153  SetDefinition( aParticleDefinition );
154  SetKineticEnergy( aKineticEnergy );
155  if( pp > DBL_MIN )
156  SetMomentum( aMomentum * (std::sqrt(aKineticEnergy*aKineticEnergy +
157  2*aKineticEnergy*GetMass())/pp) );
158  }
159 
161  const G4ParticleDefinition *aParticleDefinition )
162  {
163  theParticleDefinition = aParticleDefinition;
164  mass = aParticleDefinition->GetPDGMass();
165  totalEnergy = mass;
166  kineticEnergy = 0.0;
167  (aParticleDefinition->GetPDGEncoding()<0) ?
168  timeOfFlight=-1.0 : timeOfFlight=1.0;
169  }
170 
172  const G4double x, const G4double y, const G4double z )
173  {
174  momentum.setX( x );
175  momentum.setY( y );
176  momentum.setZ( z );
177  }
178 
180  const G4double x, const G4double y )
181  {
182  momentum.setX( x );
183  momentum.setY( y );
184  }
185 
187  {
188  momentum.setZ( z );
189  }
190 
192  {
193  SetMomentum( 0.0, 0.0, 0.0 );
194  totalEnergy = 0.0;
195  kineticEnergy = 0.0;
196  mass = 0.0;
197  timeOfFlight = 0.0;
198  side = 0;
199  theCreatorModel = -1;
200  NewlyAdded = false;
201  SetPositionInNucleus( 0.0, 0.0, 0.0 );
202  formationTime = 0.0;
203  hasInitialStateParton = false;
204  }
205 
207  const G4ReactionProduct &p1, const G4ReactionProduct &p2 )
208  {
209  G4ThreeVector p1M = p1.momentum;
210  G4ThreeVector p2M = p2.momentum;
211  G4double p1x = p1M.x(); G4double p1y = p1M.y(); G4double p1z = p1M.z();
212  G4double p2x = p2M.x(); G4double p2y = p2M.y(); G4double p2z = p2M.z();
213  G4double a = ( (p1x*p2x+p1y*p2y+p1z*p2z)/(p2.totalEnergy+p2.mass) -
214  p1.totalEnergy ) / p2.mass;
215  G4double x = p1x+a*p2x;
216  G4double y = p1y+a*p2y;
217  G4double z = p1z+a*p2z;
218  G4double p = std::sqrt(x*x+y*y+z*z);
219  SetMass( p1.mass );
220  SetTotalEnergy( std::sqrt( (p1.mass+p)*(p1.mass+p) - 2.*p1.mass*p ) );
221  //SetTotalEnergy( std::sqrt( p1.mass*p1.mass + x*x + y*y + z*z ) );
222  SetMomentum( x, y, z );
223  }
224 
226  const G4ReactionProduct& p ) const
227  {
228  G4ThreeVector tM = momentum;
229  G4ThreeVector pM = p.momentum;
230  G4double tx = tM.x(); G4double ty = tM.y(); G4double tz = tM.z();
231  G4double px = pM.x(); G4double py = pM.y(); G4double pz = pM.z();
232  G4double a = std::sqrt( ( px*px + py*py + pz*pz ) * ( tx*tx + ty*ty + tz*tz ) );
233  if( a == 0.0 ) {
234  return 0.0;
235  } else {
236  a = ( tx*px + ty*py + tz*pz ) / a;
237  if( std::fabs(a) > 1.0 ) { a<0.0 ? a=-1.0 : a=1.0; }
238  return std::acos( a );
239  }
240  }
241 
243  const G4ReactionProduct& p1, const G4ReactionProduct& p2 )
244  {
245  G4double totEnergy = p1.totalEnergy + p2.totalEnergy;
246  G4double x = p1.momentum.x() + p2.momentum.x();
247  G4double y = p1.momentum.y() + p2.momentum.y();
248  G4double z = p1.momentum.z() + p2.momentum.z();
249  G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z );
250  if( newMass < 0.0 )
251  newMass = -1. * std::sqrt( -newMass );
252  else
253  newMass = std::sqrt( newMass );
255  result.SetMass( newMass );
256  result.SetMomentum( x, y, z );
257  result.SetTotalEnergy( totEnergy );
258  result.SetPositionInNucleus( 0.0, 0.0, 0.0 );
259  result.SetFormationTime(0.0);
260  result.HasInitialStateParton(false);
261  return result;
262  }
263 
265  const G4ReactionProduct& p1, const G4ReactionProduct& p2 )
266  {
267  G4double totEnergy = p1.totalEnergy - p2.totalEnergy;
268  G4double x = p1.momentum.x() - p2.momentum.x();
269  G4double y = p1.momentum.y() - p2.momentum.y();
270  G4double z = p1.momentum.z() - p2.momentum.z();
271  G4double newMass = totEnergy*totEnergy - ( x*x + y*y + z*z );
272  if( newMass < 0.0 )
273  newMass = -1. * std::sqrt( -newMass );
274  else
275  newMass = std::sqrt( newMass );
277  result.SetMass( newMass );
278  result.SetMomentum( x, y, z );
279  result.SetTotalEnergy( totEnergy );
280  result.SetPositionInNucleus( 0.0, 0.0, 0.0 );
281  result.SetFormationTime(0.0);
282  result.HasInitialStateParton(false);
283  return result;
284  }
285  /* end of code */
286 
G4double G4ParticleHPJENDLHEData::G4double result
void SetPositionInNucleus(G4double x, G4double y, G4double z)
void HasInitialStateParton(G4bool aFlag)
void Lorentz(const G4ReactionProduct &p1, const G4ReactionProduct &p2)
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
double x() const
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
void SetKineticEnergy(const G4double en)
void SetMomentum(const G4double x, const G4double y, const G4double z)
const char * p
Definition: xmltok.h:285
BasicVector3D< float > operator-(const BasicVector3D< float > &v)
BasicVector3D< float > operator+(const BasicVector3D< float > &v)
G4ParticleDefinition * GetDefinition() const
tuple x
Definition: test.py:50
#define G4ThreadLocal
Definition: tls.hh:89
void setY(double)
double z() const
void setZ(double)
void setX(double)
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4double Angle(const G4ReactionProduct &p) const
G4ReactionProduct & operator=(const G4ReactionProduct &right)
void SetMass(const G4double mas)
Hep3Vector vect() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
void SetTotalEnergy(const G4double en)
G4DLLIMPORT G4ThreadLocal G4Allocator< G4ReactionProduct > * aRPAllocator
void SetDefinitionAndUpdateE(const G4ParticleDefinition *aParticleDefinition)
const G4LorentzVector & Get4Momentum() const
G4double GetKineticEnergy() const
G4double GetPDGMass() const
double y() const
#define DBL_MIN
Definition: templates.hh:75
tuple z
Definition: test.py:28
G4ThreeVector GetMomentum() const
void SetFormationTime(G4double aTime)
double G4double
Definition: G4Types.hh:76
double mag() const
G4double GetMass() const
G4ThreeVector GetMomentum() const