Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4INCLKinematicsUtils.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 // INCL++ intra-nuclear cascade model
27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28 // Davide Mancusi, CEA
29 // Alain Boudard, CEA
30 // Sylvie Leray, CEA
31 // Joseph Cugnon, University of Liege
32 //
33 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 #include "G4INCLKinematicsUtils.hh"
38 #include "G4INCLParticleTable.hh"
39 
40 namespace G4INCL {
41 
43  const G4double localEnergy = KinematicsUtils::getLocalEnergy(n, p);
44  const G4double localTotalEnergy = p->getEnergy() - localEnergy;
45  p->setEnergy(localTotalEnergy);
47  }
48 
50 // assert(!p->isPion()); // No local energy for pions
51 
52  G4double vloc = 0.0;
53  const G4double r = p->getPosition().mag();
54  const G4double mass = p->getMass();
55 
56  // Local energy is constant outside the surface
57  if(r > n->getUniverseRadius()) {
58  WARN("Tried to evaluate local energy for a particle outside the maximum radius."
59  << std::endl << p->print() << std::endl
60  << "Maximum radius = " << n->getDensity()->getMaximumRadius() << std::endl
61  << "Universe radius = " << n->getUniverseRadius() << std::endl);
62  return 0.0;
63  }
64 
65  G4double pfl0 = 0.0;
66  const G4double kinE = p->getKineticEnergy();
67  if(kinE <= n->getPotential()->getFermiEnergy(p->getType())) {
68  pfl0 = n->getPotential()->getFermiMomentum(p);
69  } else {
70  const G4double tf0 = p->getPotentialEnergy() - n->getPotential()->getSeparationEnergy(p);
71  if(tf0<0.0) return 0.0;
72  pfl0 = std::sqrt(tf0*(tf0 + 2.0*mass));
73  }
74  const G4double pl = pfl0*n->getDensity()->getMaxTFromR(r);
75  vloc = std::sqrt(pl*pl + mass*mass) - mass;
76 
77  return vloc;
78  }
79 
80  ThreeVector KinematicsUtils::makeBoostVector(Particle const * const p1, Particle const * const p2){
81  const G4double totalEnergy = p1->getEnergy() + p2->getEnergy();
82  return ((p1->getMomentum() + p2->getMomentum())/totalEnergy);
83  }
84 
85  G4double KinematicsUtils::totalEnergyInCM(Particle const * const p1, Particle const * const p2){
86  return std::sqrt(squareTotalEnergyInCM(p1,p2));
87  }
88 
89  G4double KinematicsUtils::squareTotalEnergyInCM(Particle const * const p1, Particle const * const p2) {
91  if(beta2 > 1.0) {
92  ERROR("KinematicsUtils::squareTotalEnergyInCM: beta2 == " << beta2 << " > 1.0" << std::endl);
93  beta2 = 0.0;
94  }
95  return (1.0 - beta2)*std::pow(p1->getEnergy() + p2->getEnergy(), 2);
96  }
97 
98  G4double KinematicsUtils::momentumInCM(Particle const * const p1, Particle const * const p2) {
99  const G4double m1sq = std::pow(p1->getMass(),2);
100  const G4double m2sq = std::pow(p2->getMass(),2);
101  const G4double z = p1->getEnergy()*p2->getEnergy() - p1->getMomentum().dot(p2->getMomentum());
102  G4double pcm2 = (z*z-m1sq*m2sq)/(2*z+m1sq+m2sq);
103  if(pcm2 < 0.0) {
104  ERROR("KinematicsUtils::momentumInCM: pcm2 == " << pcm2 << " < 0.0" << std::endl);
105  pcm2 = 0.0;
106  }
107  return std::sqrt(pcm2);
108  }
109 
111  return 0.5*std::sqrt((E*E - std::pow(M1 + M2, 2))
112  *(E*E - std::pow(M1 - M2, 2)))/E;
113  }
114 
116  const G4double m1sq = m1*m1;
117  const G4double m2sq = m2*m2;
118  G4double plab2 = (s*s-2*s*(m1sq+m2sq)+(m1sq-m2sq)*(m1sq-m2sq))/(4*m2sq);
119  if(plab2 < 0.0) {
120  ERROR("KinematicsUtils::momentumInLab: plab2 == " << plab2 << " < 0.0; m1sq == " << m1sq << "; m2sq == " << m2sq << "; s == " << s << std::endl);
121  plab2 = 0.0;
122  }
123  return std::sqrt(plab2);
124  }
125 
126  G4double KinematicsUtils::momentumInLab(Particle const * const p1, Particle const * const p2) {
127  const G4double m1 = p1->getMass();
128  const G4double m2 = p2->getMass();
129  const G4double s = squareTotalEnergyInCM(p1, p2);
130  return KinematicsUtils::momentumInLab(s, m1, m2);
131  }
132 
134  G4double E = 0.0;
135  for(ParticleIter i = pl.begin(); i != pl.end(); ++i) {
136  E += (*i)->getEnergy();
137  }
138  return E;
139  }
140 
142  ThreeVector p(0.0, 0.0, 0.0);
143  for(ParticleIter i = pl.begin(); i != pl.end(); ++i) {
144  p += (*i)->getMomentum();
145  }
146  return p;
147  }
148 
150  return std::sqrt(p.mag2() + m*m);
151  }
152 
154  return std::sqrt(E*E - p.mag2());
155  }
156 
158  G4double mass;
159  if(p.theType==Composite)
161  else
163  return (1.+EKin/mass);
164  }
165 
166 }