Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// 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// INCL++ revision: v5.1.8
34//
35#define INCLXX_IN_GEANT4_MODE 1
36
37#include "globals.hh"
38
39/** \file G4INCLParticleSampler.cc
40 * \brief Class for sampling particles in a nucleus
41 *
42 * \date 18 July 2012
43 * \author Davide Mancusi
44 */
45
47
48namespace G4INCL {
49
50 ParticleSampler::ParticleSampler(const G4int A, const G4int Z, InverseInterpolationTable const * const rCDFTable, InverseInterpolationTable const * const pCDFTable) :
51 sampleOneParticle(&ParticleSampler::sampleOneParticleWithoutRPCorrelation),
52 theA(A),
53 theZ(Z),
54 theRCDFTable(rCDFTable),
55 thePCDFTable(pCDFTable),
56 theDensity(NULL),
57 thePotential(NULL)
58 {}
59
61 }
62
64 theDensity = d;
65 updateSampleOneParticleMethod();
66 }
67
69 thePotential = p;
70 updateSampleOneParticleMethod();
71 }
72
73 void ParticleSampler::updateSampleOneParticleMethod() {
74 if(theDensity && thePotential)
75 sampleOneParticle = &ParticleSampler::sampleOneParticleWithRPCorrelation;
76 else
77 sampleOneParticle = &ParticleSampler::sampleOneParticleWithoutRPCorrelation;
78 }
79
81 ParticleList theList;
82 if(theA > 2) {
83 ParticleType type = Proton;
84 for(G4int i = 1; i <= theA; ++i) {
85 if(i == (theZ + 1)) // Nucleons [Z+1..A] are neutrons
86 type = Neutron;
87 Particle *p = (this->*(this->sampleOneParticle))(type);
89 theList.push_back(p);
90 }
91 } else {
92 // For deuterons, only sample the proton position and momentum. The
93 // neutron position and momenta are determined by the conditions of
94 // vanishing CM position and total momentum.
95// assert(theZ==1);
96 Particle *aProton = (this->*(this->sampleOneParticle))(Proton);
97 Particle *aNeutron = new Particle(Neutron, -aProton->getMomentum(), position - aProton->getPosition());
98 aProton->setPosition(position + aProton->getPosition());
99 theList.push_back(aProton);
100 theList.push_back(aNeutron);
101 }
102
103 return theList;
104 }
105
106 Particle *ParticleSampler::sampleOneParticleWithRPCorrelation(const ParticleType t) const {
107// assert(theDensity && thePotential);
108 const G4double theFermiMomentum = thePotential->getFermiMomentum(t);
109 const ThreeVector momentumVector = Random::sphereVector(theFermiMomentum);
110 const G4double momentumRatio = momentumVector.mag()/theFermiMomentum;
111 const ThreeVector positionVector = Random::sphereVector(theDensity->getMaxRFromP(momentumRatio));
112 return new Particle(t, momentumVector, positionVector);
113 }
114
115 Particle *ParticleSampler::sampleOneParticleWithoutRPCorrelation(const ParticleType t) const {
116 const G4double position = (*theRCDFTable)(Random::shoot());
117 const G4double momentum = (*thePCDFTable)(Random::shoot());
118 ThreeVector positionVector = Random::normVector(position);
119 ThreeVector momentumVector = Random::normVector(momentum);
120 return new Particle(t, momentumVector, positionVector);
121 }
122
123}
124
Class for sampling particles in a nucleus.
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
Class for interpolating the inverse of a 1-dimensional function.
G4double getMaxRFromP(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.
void setDensity(NuclearDensity const *const d)
Setter for theDensity.
ParticleSampler(const G4int A, const G4int Z, InverseInterpolationTable const *const rCDFTable, InverseInterpolationTable const *const pCDFTable)
Constructor.
ParticleList sampleParticles(ThreeVector const &position) const
const G4INCL::ThreeVector & getPosition() const
const G4INCL::ThreeVector & getMomentum() const
virtual void setPosition(const G4INCL::ThreeVector &position)
static ThreeVector normVector(G4double norm=1.)
Definition: G4INCLRandom.cc:73
static G4double shoot()
Definition: G4INCLRandom.hh:99
static ThreeVector sphereVector(G4double rmax=1.)
G4double mag() const
std::list< G4INCL::Particle * > ParticleList