Geant4-11
G4INCLParticleSampler.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
48
49namespace G4INCL {
50
52 sampleOneProton(&ParticleSampler::sampleOneParticleWithoutRPCorrelation),
53 sampleOneNeutron(&ParticleSampler::sampleOneParticleWithoutRPCorrelation),
54 theA(A),
55 theZ(Z),
56 theS(S),
57 theDensity(NULL),
58 thePotential(NULL)
59 {
60 std::fill(theRCDFTable, theRCDFTable + UnknownParticle, static_cast<InterpolationTable *>(NULL));
61 std::fill(thePCDFTable, thePCDFTable + UnknownParticle, static_cast<InterpolationTable *>(NULL));
66 }
67
69 }
70
72 theDensity = d;
74 }
75
77 thePotential = p;
79 }
80
83 if(rpCorrelationCoefficient[Proton]>0.99999) {
85 } else {
87 }
90 } else {
92 }
93 } else {
96 }
97 }
98
100 ParticleList aList;
102 return aList;
103 }
104
106
108 // sampling without correlation, we need to initialize the CDF tables
115 }
116
117 theList.resize(theA);
118 if(theA > 2) {
119 ParticleType type = Proton;
120 ParticleSamplerMethod sampleOneParticle = sampleOneProton;
121 for(G4int i = 0; i < theA; ++i) {
122 if(i == theZ) { // Nucleons [Z..A-1] are neutrons
123 type = Lambda;
124 sampleOneParticle = sampleOneNeutron; // hypothesis: Lambdas follow the same rules than neutrons
125 }
126 if(i == theZ - theS) type = Neutron;
127 Particle *p = (this->*sampleOneParticle)(type);
129 theList[i] = p;
130 }
131 } else {
132 // For deuterons, only sample the proton position and momentum. The
133 // neutron position and momenta are determined by the conditions of
134 // vanishing CM position and total momentum.
135// assert(theZ==1);
136 Particle *aProton = (this->*(this->sampleOneProton))(Proton);
137 Particle *aNeutron = new Particle(Neutron, -aProton->getMomentum(), position - aProton->getPosition());
138 aProton->setPosition(position + aProton->getPosition());
139 theList[0] = aProton;
140 theList[1] = aNeutron;
141 }
142 }
143
145// assert(theDensity && thePotential);
146 const G4double theFermiMomentum = thePotential->getFermiMomentum(t);
147 const ThreeVector momentumVector = Random::sphereVector(theFermiMomentum);
148 const G4double momentumAbs = momentumVector.mag();
149 const G4double momentumRatio = momentumAbs/theFermiMomentum;
150 const G4double reflectionRadius = theDensity->getMaxRFromP(t, momentumRatio);
151 const ThreeVector positionVector = Random::sphereVector(reflectionRadius);
152 Particle *aParticle = new Particle(t, momentumVector, positionVector);
153 aParticle->setUncorrelatedMomentum(momentumAbs);
154 return aParticle;
155 }
156
158 const G4double position = (*(theRCDFTable[t]))(Random::shoot());
159 const G4double momentum = (*(thePCDFTable[t]))(Random::shoot());
160 ThreeVector positionVector = Random::normVector(position);
161 ThreeVector momentumVector = Random::normVector(momentum);
162 return new Particle(t, momentumVector, positionVector);
163 }
164
166// assert(theDensity && thePotential);
167 std::pair<G4double,G4double> ranNumbers = Random::correlatedUniform(rpCorrelationCoefficient[t]);
168 const G4double x = Math::pow13(ranNumbers.first);
169 const G4double y = Math::pow13(ranNumbers.second);
170 const G4double theFermiMomentum = thePotential->getFermiMomentum(t);
171 const ThreeVector momentumVector = Random::normVector(y*theFermiMomentum);
172 const G4double reflectionRadius = theDensity->getMaxRFromP(t, x);
173 const ThreeVector positionVector = Random::sphereVector(reflectionRadius);
174 Particle *aParticle = new Particle(t, momentumVector, positionVector);
175 aParticle->setUncorrelatedMomentum(x*theFermiMomentum);
176 return aParticle;
177 }
178
179}
180
G4double S(G4double temp)
Class for sampling particles in a nucleus.
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
const G4double A[17]
Class for interpolating the of a 1-dimensional function.
G4double getMaxRFromP(const ParticleType t, const G4double p) const
Get the maximum allowed radius for a given momentum.
G4double getFermiMomentum(const Particle *const p) const
Return the Fermi momentum for a particle.
void setPotential(NuclearPotential::INuclearPotential const *const p)
Setter for thePotential.
const G4int theA
Mass number.
ParticleSamplerMethod sampleOneNeutron
Sample a list of particles.
ParticleSamplerMethod sampleOneProton
Sample a list of particles.
G4double rpCorrelationCoefficient[UnknownParticle]
Correlation coefficients for the r-p correlation.
void sampleParticlesIntoList(ThreeVector const &position, ParticleList &theList)
Particle * sampleOneParticleWithFuzzyRPCorrelation(const ParticleType t) const
Sample one particle with a fuzzy rp-correlation.
Particle * sampleOneParticleWithoutRPCorrelation(const ParticleType t) const
Sample one particle not taking into account the rp-correlation.
ParticleSampler(const G4int A, const G4int Z, const G4int S)
Constructor.
void setDensity(NuclearDensity const *const d)
Setter for theDensity.
Particle * sampleOneParticleWithRPCorrelation(const ParticleType t) const
Sample one particle taking into account the rp-correlation.
NuclearDensity const * theDensity
Pointer to the Cluster's NuclearDensity.
InterpolationTable const * theRCDFTable[UnknownParticle]
Array of pointers to the r-space CDF table.
const G4int theS
Strangeness number.
InterpolationTable const * thePCDFTable[UnknownParticle]
Array of pointers to the p-space CDF table.
ParticleList sampleParticles(ThreeVector const &position)
NuclearPotential::INuclearPotential const * thePotential
Pointer to the Cluster's NuclearPotential.
const G4int theZ
Charge number.
Particle *(ParticleSampler::* ParticleSamplerMethod)(const ParticleType t) const
void setUncorrelatedMomentum(const G4double p)
Set the uncorrelated momentum.
const G4INCL::ThreeVector & getPosition() const
const G4INCL::ThreeVector & getMomentum() const
virtual void setPosition(const G4INCL::ThreeVector &position)
G4double mag() const
G4double pow13(G4double x)
InterpolationTable * createPCDFTable(const ParticleType t, const G4int A, const G4int Z)
InterpolationTable * createRCDFTable(const ParticleType t, const G4int A, const G4int Z)
G4double getRPCorrelationCoefficient(const ParticleType t)
Get the value of the r-p correlation coefficient.
ThreeVector normVector(G4double norm=1.)
ThreeVector sphereVector(G4double rmax=1.)
G4double shoot()
Definition: G4INCLRandom.cc:93
std::pair< G4double, G4double > correlatedUniform(const G4double corrCoeff)
Generate pairs of correlated uniform random numbers.