Geant4-11
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// Alain Boudard, CEA-Saclay, France
28// Joseph Cugnon, University of Liege, Belgium
29// Jean-Christophe David, CEA-Saclay, France
30// Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31// Sylvie Leray, CEA-Saclay, France
32// Davide Mancusi, CEA-Saclay, France
33//
34#define INCLXX_IN_GEANT4_MODE 1
35
36#include "globals.hh"
37
40
41namespace G4INCL {
42
43 namespace KinematicsUtils {
44
45 void transformToLocalEnergyFrame(Nucleus const * const n, Particle * const p) {
46// assert(!p->isMeson()); // No local energy for mesons
47 const G4double localEnergy = getLocalEnergy(n, p);
48 const G4double localTotalEnergy = p->getEnergy() - localEnergy;
49 p->setEnergy(localTotalEnergy);
51 }
52
53 G4double getLocalEnergy(Nucleus const * const n, Particle * const p) {
54// assert(!p->isMeson()); // No local energy for mesons
55
56 G4double vloc = 0.0;
57 const G4double r = p->getPosition().mag();
58 const G4double mass = p->getMass();
59
60 // Local energy is constant outside the surface
61 if(r > n->getUniverseRadius()) {
62 INCL_WARN("Tried to evaluate local energy for a particle outside the maximum radius."
63 << '\n' << p->print() << '\n'
64 << "Maximum radius = " << n->getDensity()->getMaximumRadius() << '\n'
65 << "Universe radius = " << n->getUniverseRadius() << '\n');
66 return 0.0;
67 }
68
69 G4double pfl0 = 0.0;
70 const ParticleType t = p->getType();
71 const G4double kinE = p->getKineticEnergy();
72 if(kinE <= n->getPotential()->getFermiEnergy(t)) {
73 pfl0 = n->getPotential()->getFermiMomentum(p);
74 } else {
75 const G4double tf0 = p->getPotentialEnergy() - n->getPotential()->getSeparationEnergy(p);
76 if(tf0<0.0) return 0.0;
77 pfl0 = std::sqrt(tf0*(tf0 + 2.0*mass));
78 }
79 const G4double pReflection = p->getReflectionMomentum()/pfl0;
80 const G4double reflectionRadius = n->getDensity()->getMaxRFromP(p->getType(), pReflection);
81 const G4double pNominal = p->getMomentum().mag()/pfl0;
82 const G4double nominalReflectionRadius = n->getDensity()->getMaxRFromP(p->getType(), pNominal);
83 const G4double pl = pfl0*n->getDensity()->getMinPFromR(t, r*nominalReflectionRadius/reflectionRadius);
84 vloc = std::sqrt(pl*pl + mass*mass) - mass;
85
86 return vloc;
87 }
88
89 ThreeVector makeBoostVector(Particle const * const p1, Particle const * const p2){
90 const G4double totalEnergy = p1->getEnergy() + p2->getEnergy();
91 return ((p1->getMomentum() + p2->getMomentum())/totalEnergy);
92 }
93
94 G4double totalEnergyInCM(Particle const * const p1, Particle const * const p2){
95 return std::sqrt(squareTotalEnergyInCM(p1,p2));
96 }
97
98 G4double squareTotalEnergyInCM(Particle const * const p1, Particle const * const p2) {
99 G4double beta2 = makeBoostVector(p1, p2).mag2();
100 if(beta2 > 1.0) {
101 INCL_ERROR("squareTotalEnergyInCM: beta2 == " << beta2 << " > 1.0" << '\n');
102 beta2 = 0.0;
103 }
104 return (1.0 - beta2)*std::pow(p1->getEnergy() + p2->getEnergy(), 2);
105 }
106
107 G4double momentumInCM(Particle const * const p1, Particle const * const p2) {
108 const G4double m1sq = std::pow(p1->getMass(),2);
109 const G4double m2sq = std::pow(p2->getMass(),2);
110 const G4double z = p1->getEnergy()*p2->getEnergy() - p1->getMomentum().dot(p2->getMomentum());
111 G4double pcm2 = (z*z-m1sq*m2sq)/(2*z+m1sq+m2sq);
112 if(pcm2 < 0.0) {
113 INCL_ERROR("momentumInCM: pcm2 == " << pcm2 << " < 0.0" << '\n');
114 pcm2 = 0.0;
115 }
116 return std::sqrt(pcm2);
117 }
118
119 G4double momentumInCM(const G4double E, const G4double M1, const G4double M2) {
120 return 0.5*std::sqrt((E*E - std::pow(M1 + M2, 2))
121 *(E*E - std::pow(M1 - M2, 2)))/E;
122 }
123
125 const G4double m1sq = m1*m1;
126 const G4double m2sq = m2*m2;
127 G4double plab2 = (s*s-2*s*(m1sq+m2sq)+(m1sq-m2sq)*(m1sq-m2sq))/(4*m2sq);
128 if(plab2 < 0.0) {
129 INCL_ERROR("momentumInLab: plab2 == " << plab2 << " < 0.0; m1sq == " << m1sq << "; m2sq == " << m2sq << "; s == " << s << '\n');
130 plab2 = 0.0;
131 }
132 return std::sqrt(plab2);
133 }
134
135 G4double momentumInLab(Particle const * const p1, Particle const * const p2) {
136 const G4double m1 = p1->getMass();
137 const G4double m2 = p2->getMass();
138 const G4double s = squareTotalEnergyInCM(p1, p2);
139 return momentumInLab(s, m1, m2);
140 }
141
143 G4double E = 0.0;
144 for(ParticleIter i=pl.begin(), e=pl.end(); i!=e; ++i) {
145 E += (*i)->getEnergy();
146 }
147 return E;
148 }
149
151 ThreeVector p(0.0, 0.0, 0.0);
152 for(ParticleIter i=pl.begin(), e=pl.end(); i!=e; ++i) {
153 p += (*i)->getMomentum();
154 }
155 return p;
156 }
157
159 return std::sqrt(p.mag2() + m*m);
160 }
161
163 return std::sqrt(squareInvariantMass(E, p));
164 }
165
167 return E*E - p.mag2();
168 }
169
171 G4double mass;
172 if(p.theType==Composite)
174 else
176 return (1.+EKin/mass);
177 }
178
179 }
180
181}
#define INCL_ERROR(x)
#define INCL_WARN(x)
static constexpr double m
Definition: G4SIunits.hh:109
static constexpr double s
Definition: G4SIunits.hh:154
static constexpr double m2
Definition: G4SIunits.hh:110
double G4double
Definition: G4Types.hh:83
G4double getEnergy() const
G4double getPotentialEnergy() const
Get the particle potential energy.
const G4INCL::ThreeVector & getPosition() const
G4double getKineticEnergy() const
Get the particle kinetic energy.
G4double getReflectionMomentum() const
Return the reflection momentum.
const ThreeVector & adjustMomentumFromEnergy()
Rescale the momentum to match the total energy.
const G4INCL::ThreeVector & getMomentum() const
G4INCL::ParticleType getType() const
void setEnergy(G4double energy)
std::string print() const
G4double getMass() const
Get the cached particle mass.
G4double mag() const
G4double dot(const ThreeVector &v) const
G4double mag2() const
G4double squareTotalEnergyInCM(Particle const *const p1, Particle const *const p2)
G4double invariantMass(const G4double E, const ThreeVector &p)
ThreeVector sumMomenta(const ParticleList &)
G4double gammaFromKineticEnergy(const ParticleSpecies &p, const G4double EKin)
G4double squareInvariantMass(const G4double E, const ThreeVector &p)
G4double sumTotalEnergies(const ParticleList &)
G4double energy(const ThreeVector &p, const G4double m)
ThreeVector makeBoostVector(Particle const *const p1, Particle const *const p2)
G4double totalEnergyInCM(Particle const *const p1, Particle const *const p2)
void transformToLocalEnergyFrame(Nucleus const *const n, Particle *const p)
G4double momentumInLab(Particle const *const p1, Particle const *const p2)
gives the momentum in the lab frame of two particles.
G4double momentumInCM(Particle const *const p1, Particle const *const p2)
gives the momentum in the CM frame of two particles.
G4double getLocalEnergy(Nucleus const *const n, Particle *const p)
G4ThreadLocal NuclearMassFn getTableMass
Static pointer to the mass function for nuclei.
G4ThreadLocal ParticleMassFn getTableParticleMass
Static pointer to the mass function for particles.
ParticleList::const_iterator ParticleIter