Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // INCL++ intra-nuclear cascade model 26 // INCL++ intra-nuclear cascade model 27 // Alain Boudard, CEA-Saclay, France << 27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics 28 // Joseph Cugnon, University of Liege, Belgium << 28 // Davide Mancusi, CEA 29 // Jean-Christophe David, CEA-Saclay, France << 29 // Alain Boudard, CEA 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H << 30 // Sylvie Leray, CEA 31 // Sylvie Leray, CEA-Saclay, France << 31 // Joseph Cugnon, University of Liege 32 // Davide Mancusi, CEA-Saclay, France << 33 // 32 // 34 #define INCLXX_IN_GEANT4_MODE 1 33 #define INCLXX_IN_GEANT4_MODE 1 35 34 36 #include "globals.hh" 35 #include "globals.hh" 37 36 38 /** \file G4INCLParticleSampler.cc 37 /** \file G4INCLParticleSampler.cc 39 * \brief Class for sampling particles in a nu 38 * \brief Class for sampling particles in a nucleus 40 * 39 * 41 * \date 18 July 2012 40 * \date 18 July 2012 42 * \author Davide Mancusi 41 * \author Davide Mancusi 43 */ 42 */ 44 43 45 #include "G4INCLParticleSampler.hh" 44 #include "G4INCLParticleSampler.hh" 46 #include "G4INCLParticleTable.hh" << 47 #include "G4INCLNuclearDensityFactory.hh" << 48 45 49 namespace G4INCL { 46 namespace G4INCL { 50 47 51 ParticleSampler::ParticleSampler(const G4int << 48 ParticleSampler::ParticleSampler(const G4int A, const G4int Z, InverseInterpolationTable const * const rCDFTable, InverseInterpolationTable const * const pCDFTable) : 52 sampleOneProton(&ParticleSampler::sampleOn << 49 sampleOneParticle(&ParticleSampler::sampleOneParticleWithoutRPCorrelation), 53 sampleOneNeutron(&ParticleSampler::sampleO << 54 theA(A), 50 theA(A), 55 theZ(Z), 51 theZ(Z), 56 theS(S), << 52 theRCDFTable(rCDFTable), >> 53 thePCDFTable(pCDFTable), 57 theDensity(NULL), 54 theDensity(NULL), 58 thePotential(NULL) 55 thePotential(NULL) 59 { << 56 {} 60 std::fill(theRCDFTable, theRCDFTable + Unk << 61 std::fill(thePCDFTable, thePCDFTable + Unk << 62 std::fill(rpCorrelationCoefficient, rpCorr << 63 rpCorrelationCoefficient[Proton] = Particl << 64 rpCorrelationCoefficient[Neutron] = Partic << 65 rpCorrelationCoefficient[Lambda] = Particl << 66 } << 67 57 68 ParticleSampler::~ParticleSampler() { 58 ParticleSampler::~ParticleSampler() { 69 } 59 } 70 60 71 void ParticleSampler::setDensity(NuclearDens 61 void ParticleSampler::setDensity(NuclearDensity const * const d) { 72 theDensity = d; 62 theDensity = d; 73 updateSampleOneParticleMethods(); << 63 updateSampleOneParticleMethod(); 74 } 64 } 75 65 76 void ParticleSampler::setPotential(NuclearPo 66 void ParticleSampler::setPotential(NuclearPotential::INuclearPotential const * const p) { 77 thePotential = p; 67 thePotential = p; 78 updateSampleOneParticleMethods(); << 68 updateSampleOneParticleMethod(); 79 } 69 } 80 70 81 void ParticleSampler::updateSampleOneParticl << 71 void ParticleSampler::updateSampleOneParticleMethod() { 82 if(theDensity && thePotential) { << 72 if(theDensity && thePotential) 83 if(rpCorrelationCoefficient[Proton]>0.99 << 73 sampleOneParticle = &ParticleSampler::sampleOneParticleWithRPCorrelation; 84 sampleOneProton = &ParticleSampler::sa << 74 else 85 } else { << 75 sampleOneParticle = &ParticleSampler::sampleOneParticleWithoutRPCorrelation; 86 sampleOneProton = &ParticleSampler::sa << 87 } << 88 if(rpCorrelationCoefficient[Neutron]>0.9 << 89 sampleOneNeutron = &ParticleSampler::s << 90 } else { << 91 sampleOneNeutron = &ParticleSampler::s << 92 } << 93 } else { << 94 sampleOneProton = &ParticleSampler::samp << 95 sampleOneNeutron = &ParticleSampler::sam << 96 } << 97 } 76 } 98 77 99 ParticleList ParticleSampler::sampleParticle << 78 ParticleList ParticleSampler::sampleParticles(const ThreeVector &position) const { 100 ParticleList aList; << 79 ParticleList theList; 101 sampleParticlesIntoList(position, aList); << 102 return aList; << 103 } << 104 << 105 void ParticleSampler::sampleParticlesIntoLis << 106 << 107 if(sampleOneProton == &ParticleSampler::sa << 108 // sampling without correlation, we need << 109 theRCDFTable[Proton] = NuclearDensityFac << 110 thePCDFTable[Proton] = NuclearDensityFac << 111 theRCDFTable[Neutron] = NuclearDensityFa << 112 thePCDFTable[Neutron] = NuclearDensityFa << 113 theRCDFTable[Lambda] = NuclearDensityFac << 114 thePCDFTable[Lambda] = NuclearDensityFac << 115 } << 116 << 117 theList.resize(theA); << 118 if(theA > 2) { 80 if(theA > 2) { 119 ParticleType type = Proton; 81 ParticleType type = Proton; 120 ParticleSamplerMethod sampleOneParticle << 82 for(G4int i = 1; i <= theA; ++i) { 121 for(G4int i = 0; i < theA; ++i) { << 83 if(i == (theZ + 1)) // Nucleons [Z+1..A] are neutrons 122 if(i == theZ) { // Nucleons [Z..A-1] a << 84 type = Neutron; 123 type = Lambda; << 85 Particle *p = (this->*(this->sampleOneParticle))(type); 124 sampleOneParticle = sampleOneNeutron << 125 } << 126 if(i == theZ - theS) type = Neutron; << 127 Particle *p = (this->*sampleOneParticl << 128 p->setPosition(position + p->getPositi 86 p->setPosition(position + p->getPosition()); 129 theList[i] = p; << 87 theList.push_back(p); 130 } 88 } 131 } else { 89 } else { 132 // For deuterons, only sample the proton 90 // For deuterons, only sample the proton position and momentum. The 133 // neutron position and momenta are dete 91 // neutron position and momenta are determined by the conditions of 134 // vanishing CM position and total momen 92 // vanishing CM position and total momentum. 135 // assert(theZ==1); 93 // assert(theZ==1); 136 Particle *aProton = (this->*(this->sampl << 94 Particle *aProton = (this->*(this->sampleOneParticle))(Proton); 137 Particle *aNeutron = new Particle(Neutro 95 Particle *aNeutron = new Particle(Neutron, -aProton->getMomentum(), position - aProton->getPosition()); 138 aProton->setPosition(position + aProton- 96 aProton->setPosition(position + aProton->getPosition()); 139 theList[0] = aProton; << 97 theList.push_back(aProton); 140 theList[1] = aNeutron; << 98 theList.push_back(aNeutron); 141 } 99 } >> 100 >> 101 return theList; 142 } 102 } 143 103 144 Particle *ParticleSampler::sampleOneParticle 104 Particle *ParticleSampler::sampleOneParticleWithRPCorrelation(const ParticleType t) const { 145 // assert(theDensity && thePotential); 105 // assert(theDensity && thePotential); 146 const G4double theFermiMomentum = thePoten 106 const G4double theFermiMomentum = thePotential->getFermiMomentum(t); 147 const ThreeVector momentumVector = Random: 107 const ThreeVector momentumVector = Random::sphereVector(theFermiMomentum); 148 const G4double momentumAbs = momentumVecto << 108 const G4double momentumRatio = momentumVector.mag()/theFermiMomentum; 149 const G4double momentumRatio = momentumAbs << 109 const ThreeVector positionVector = Random::sphereVector(theDensity->getMaxRFromP(momentumRatio)); 150 const G4double reflectionRadius = theDensi << 110 return new Particle(t, momentumVector, positionVector); 151 const ThreeVector positionVector = Random: << 152 Particle *aParticle = new Particle(t, mome << 153 aParticle->setUncorrelatedMomentum(momentu << 154 return aParticle; << 155 } 111 } 156 112 157 Particle *ParticleSampler::sampleOneParticle 113 Particle *ParticleSampler::sampleOneParticleWithoutRPCorrelation(const ParticleType t) const { 158 const G4double position = (*(theRCDFTable[ << 114 const G4double position = (*theRCDFTable)(Random::shoot()); 159 const G4double momentum = (*(thePCDFTable[ << 115 const G4double momentum = (*thePCDFTable)(Random::shoot()); 160 ThreeVector positionVector = Random::normV 116 ThreeVector positionVector = Random::normVector(position); 161 ThreeVector momentumVector = Random::normV 117 ThreeVector momentumVector = Random::normVector(momentum); 162 return new Particle(t, momentumVector, pos 118 return new Particle(t, momentumVector, positionVector); 163 } << 164 << 165 Particle *ParticleSampler::sampleOneParticle << 166 // assert(theDensity && thePotential); << 167 std::pair<G4double,G4double> ranNumbers = << 168 const G4double x = Math::pow13(ranNumbers. << 169 const G4double y = Math::pow13(ranNumbers. << 170 const G4double theFermiMomentum = thePoten << 171 const ThreeVector momentumVector = Random: << 172 const G4double reflectionRadius = theDensi << 173 const ThreeVector positionVector = Random: << 174 Particle *aParticle = new Particle(t, mome << 175 aParticle->setUncorrelatedMomentum(x*theFe << 176 return aParticle; << 177 } 119 } 178 120 179 } 121 } 180 122 181 123