Geant4.10
 All Data Structures 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 
42  namespace KinematicsUtils {
43 
44  void transformToLocalEnergyFrame(Nucleus const * const n, Particle * const p) {
45  const G4double localEnergy = getLocalEnergy(n, p);
46  const G4double localTotalEnergy = p->getEnergy() - localEnergy;
47  p->setEnergy(localTotalEnergy);
49  }
50 
51  G4double getLocalEnergy(Nucleus const * const n, Particle * const p) {
52 // assert(!p->isPion()); // No local energy for pions
53 
54  G4double vloc = 0.0;
55  const G4double r = p->getPosition().mag();
56  const G4double mass = p->getMass();
57 
58  // Local energy is constant outside the surface
59  if(r > n->getUniverseRadius()) {
60  INCL_WARN("Tried to evaluate local energy for a particle outside the maximum radius."
61  << std::endl << p->print() << std::endl
62  << "Maximum radius = " << n->getDensity()->getMaximumRadius() << std::endl
63  << "Universe radius = " << n->getUniverseRadius() << std::endl);
64  return 0.0;
65  }
66 
67  G4double pfl0 = 0.0;
68  const ParticleType t = p->getType();
69  const G4double kinE = p->getKineticEnergy();
70  if(kinE <= n->getPotential()->getFermiEnergy(t)) {
71  pfl0 = n->getPotential()->getFermiMomentum(p);
72  } else {
73  const G4double tf0 = p->getPotentialEnergy() - n->getPotential()->getSeparationEnergy(p);
74  if(tf0<0.0) return 0.0;
75  pfl0 = std::sqrt(tf0*(tf0 + 2.0*mass));
76  }
77  const G4double pReflection = p->getReflectionMomentum()/pfl0;
78  const G4double reflectionRadius = n->getDensity()->getMaxRFromP(p->getType(), pReflection);
79  const G4double pNominal = p->getMomentum().mag()/pfl0;
80  const G4double nominalReflectionRadius = n->getDensity()->getMaxRFromP(p->getType(), pNominal);
81  const G4double pl = pfl0*n->getDensity()->getMinPFromR(t, r*nominalReflectionRadius/reflectionRadius);
82  vloc = std::sqrt(pl*pl + mass*mass) - mass;
83 
84  return vloc;
85  }
86 
87  ThreeVector makeBoostVector(Particle const * const p1, Particle const * const p2){
88  const G4double totalEnergy = p1->getEnergy() + p2->getEnergy();
89  return ((p1->getMomentum() + p2->getMomentum())/totalEnergy);
90  }
91 
92  G4double totalEnergyInCM(Particle const * const p1, Particle const * const p2){
93  return std::sqrt(squareTotalEnergyInCM(p1,p2));
94  }
95 
96  G4double squareTotalEnergyInCM(Particle const * const p1, Particle const * const p2) {
97  G4double beta2 = makeBoostVector(p1, p2).mag2();
98  if(beta2 > 1.0) {
99  INCL_ERROR("squareTotalEnergyInCM: beta2 == " << beta2 << " > 1.0" << std::endl);
100  beta2 = 0.0;
101  }
102  return (1.0 - beta2)*std::pow(p1->getEnergy() + p2->getEnergy(), 2);
103  }
104 
105  G4double momentumInCM(Particle const * const p1, Particle const * const p2) {
106  const G4double m1sq = std::pow(p1->getMass(),2);
107  const G4double m2sq = std::pow(p2->getMass(),2);
108  const G4double z = p1->getEnergy()*p2->getEnergy() - p1->getMomentum().dot(p2->getMomentum());
109  G4double pcm2 = (z*z-m1sq*m2sq)/(2*z+m1sq+m2sq);
110  if(pcm2 < 0.0) {
111  INCL_ERROR("momentumInCM: pcm2 == " << pcm2 << " < 0.0" << std::endl);
112  pcm2 = 0.0;
113  }
114  return std::sqrt(pcm2);
115  }
116 
117  G4double momentumInCM(const G4double E, const G4double M1, const G4double M2) {
118  return 0.5*std::sqrt((E*E - std::pow(M1 + M2, 2))
119  *(E*E - std::pow(M1 - M2, 2)))/E;
120  }
121 
122  G4double momentumInLab(const G4double s, const G4double m1, const G4double m2) {
123  const G4double m1sq = m1*m1;
124  const G4double m2sq = m2*m2;
125  G4double plab2 = (s*s-2*s*(m1sq+m2sq)+(m1sq-m2sq)*(m1sq-m2sq))/(4*m2sq);
126  if(plab2 < 0.0) {
127  INCL_ERROR("momentumInLab: plab2 == " << plab2 << " < 0.0; m1sq == " << m1sq << "; m2sq == " << m2sq << "; s == " << s << std::endl);
128  plab2 = 0.0;
129  }
130  return std::sqrt(plab2);
131  }
132 
133  G4double momentumInLab(Particle const * const p1, Particle const * const p2) {
134  const G4double m1 = p1->getMass();
135  const G4double m2 = p2->getMass();
136  const G4double s = squareTotalEnergyInCM(p1, p2);
137  return momentumInLab(s, m1, m2);
138  }
139 
141  G4double E = 0.0;
142  for(ParticleIter i=pl.begin(), e=pl.end(); i!=e; ++i) {
143  E += (*i)->getEnergy();
144  }
145  return E;
146  }
147 
149  ThreeVector p(0.0, 0.0, 0.0);
150  for(ParticleIter i=pl.begin(), e=pl.end(); i!=e; ++i) {
151  p += (*i)->getMomentum();
152  }
153  return p;
154  }
155 
157  return std::sqrt(p.mag2() + m*m);
158  }
159 
161  return std::sqrt(squareInvariantMass(E, p));
162  }
163 
165  return E*E - p.mag2();
166  }
167 
169  G4double mass;
170  if(p.theType==Composite)
172  else
174  return (1.+EKin/mass);
175  }
176 
177  }
178 
179 }
G4double getReflectionMomentum() const
Return the reflection momentum.
G4double getMass() const
Get the cached particle mass.
G4double getMinPFromR(const ParticleType t, const G4double r) const
G4ThreadLocal ParticleMassFn getTableParticleMass
Static pointer to the mass function for particles.
G4double dot(const ThreeVector &v) const
void transformToLocalEnergyFrame(Nucleus const *const n, Particle *const p)
G4double getFermiMomentum(const Particle *const p) const
Return the Fermi momentum for a particle.
const XML_Char * s
G4double z
Definition: TRTMaterials.hh:39
G4double squareTotalEnergyInCM(Particle const *const p1, Particle const *const p2)
ThreeVector sumMomenta(const ParticleList &)
const char * p
Definition: xmltok.h:285
#define INCL_ERROR(x)
const G4INCL::ThreeVector & getMomentum() const
std::string print() const
G4double getEnergy() const
#define INCL_WARN(x)
G4double momentumInCM(Particle const *const p1, Particle const *const p2)
gives the momentum in the CM frame of two particles.
ThreeVector makeBoostVector(Particle const *const p1, Particle const *const p2)
G4double mag2() const
G4double getPotentialEnergy() const
Get the particle potential energy.
void setEnergy(G4double energy)
G4double gammaFromKineticEnergy(const ParticleSpecies &p, const G4double EKin)
tuple pl
Definition: readPY.py:5
G4double getSeparationEnergy(const Particle *const p) const
Return the separation energy for a particle.
const G4int n
G4double invariantMass(const G4double E, const ThreeVector &p)
NuclearPotential::INuclearPotential const * getPotential() const
Getter for thePotential.
G4INCL::ParticleType getType() const
NuclearDensity const * getDensity() const
Getter for theDensity.
G4double energy(const ThreeVector &p, const G4double m)
G4ThreadLocal NuclearMassFn getTableMass
Static pointer to the mass function for nuclei.
const G4INCL::ThreeVector & getPosition() const
G4double squareInvariantMass(const G4double E, const ThreeVector &p)
G4double getMaximumRadius() const
G4double getKineticEnergy() const
Get the particle kinetic energy.
G4double getUniverseRadius() const
Getter for theUniverseRadius.
G4double momentumInLab(Particle const *const p1, Particle const *const p2)
gives the momentum in the lab frame of two particles.
G4double mag() const
double G4double
Definition: G4Types.hh:76
G4double totalEnergyInCM(Particle const *const p1, Particle const *const p2)
const ThreeVector & adjustMomentumFromEnergy()
Rescale the momentum to match the total energy.
G4double getMaxRFromP(const ParticleType t, const G4double p) const
Get the maximum allowed radius for a given momentum.
ParticleList::const_iterator ParticleIter
G4double sumTotalEnergies(const ParticleList &)
G4double getLocalEnergy(Nucleus const *const n, Particle *const p)