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" 45 #include "G4INCLParticleTable.hh" 47 #include "G4INCLNuclearDensityFactory.hh" 46 #include "G4INCLNuclearDensityFactory.hh" 48 47 49 namespace G4INCL { 48 namespace G4INCL { 50 49 51 ParticleSampler::ParticleSampler(const G4int << 50 ParticleSampler::ParticleSampler(const G4int A, const G4int Z) : 52 sampleOneProton(&ParticleSampler::sampleOn 51 sampleOneProton(&ParticleSampler::sampleOneParticleWithoutRPCorrelation), 53 sampleOneNeutron(&ParticleSampler::sampleO 52 sampleOneNeutron(&ParticleSampler::sampleOneParticleWithoutRPCorrelation), 54 theA(A), 53 theA(A), 55 theZ(Z), 54 theZ(Z), 56 theS(S), << 57 theDensity(NULL), 55 theDensity(NULL), 58 thePotential(NULL) 56 thePotential(NULL) 59 { 57 { 60 std::fill(theRCDFTable, theRCDFTable + Unk << 58 std::fill(theRCDFTable, theRCDFTable + UnknownParticle, static_cast<InverseInterpolationTable *>(NULL)); 61 std::fill(thePCDFTable, thePCDFTable + Unk << 59 std::fill(thePCDFTable, thePCDFTable + UnknownParticle, static_cast<InverseInterpolationTable *>(NULL)); 62 std::fill(rpCorrelationCoefficient, rpCorr 60 std::fill(rpCorrelationCoefficient, rpCorrelationCoefficient + UnknownParticle, 1.); 63 rpCorrelationCoefficient[Proton] = Particl 61 rpCorrelationCoefficient[Proton] = ParticleTable::getRPCorrelationCoefficient(Proton); 64 rpCorrelationCoefficient[Neutron] = Partic 62 rpCorrelationCoefficient[Neutron] = ParticleTable::getRPCorrelationCoefficient(Neutron); 65 rpCorrelationCoefficient[Lambda] = Particl << 66 } 63 } 67 64 68 ParticleSampler::~ParticleSampler() { 65 ParticleSampler::~ParticleSampler() { 69 } 66 } 70 67 71 void ParticleSampler::setDensity(NuclearDens 68 void ParticleSampler::setDensity(NuclearDensity const * const d) { 72 theDensity = d; 69 theDensity = d; 73 updateSampleOneParticleMethods(); 70 updateSampleOneParticleMethods(); 74 } 71 } 75 72 76 void ParticleSampler::setPotential(NuclearPo 73 void ParticleSampler::setPotential(NuclearPotential::INuclearPotential const * const p) { 77 thePotential = p; 74 thePotential = p; 78 updateSampleOneParticleMethods(); 75 updateSampleOneParticleMethods(); 79 } 76 } 80 77 81 void ParticleSampler::updateSampleOneParticl 78 void ParticleSampler::updateSampleOneParticleMethods() { 82 if(theDensity && thePotential) { 79 if(theDensity && thePotential) { 83 if(rpCorrelationCoefficient[Proton]>0.99 80 if(rpCorrelationCoefficient[Proton]>0.99999) { 84 sampleOneProton = &ParticleSampler::sa 81 sampleOneProton = &ParticleSampler::sampleOneParticleWithRPCorrelation; 85 } else { 82 } else { 86 sampleOneProton = &ParticleSampler::sa 83 sampleOneProton = &ParticleSampler::sampleOneParticleWithFuzzyRPCorrelation; 87 } 84 } 88 if(rpCorrelationCoefficient[Neutron]>0.9 85 if(rpCorrelationCoefficient[Neutron]>0.99999) { 89 sampleOneNeutron = &ParticleSampler::s 86 sampleOneNeutron = &ParticleSampler::sampleOneParticleWithRPCorrelation; 90 } else { 87 } else { 91 sampleOneNeutron = &ParticleSampler::s 88 sampleOneNeutron = &ParticleSampler::sampleOneParticleWithFuzzyRPCorrelation; 92 } 89 } 93 } else { 90 } else { 94 sampleOneProton = &ParticleSampler::samp 91 sampleOneProton = &ParticleSampler::sampleOneParticleWithoutRPCorrelation; 95 sampleOneNeutron = &ParticleSampler::sam 92 sampleOneNeutron = &ParticleSampler::sampleOneParticleWithoutRPCorrelation; 96 } 93 } 97 } 94 } 98 95 99 ParticleList ParticleSampler::sampleParticle 96 ParticleList ParticleSampler::sampleParticles(const ThreeVector &position) { 100 ParticleList aList; << 101 sampleParticlesIntoList(position, aList); << 102 return aList; << 103 } << 104 << 105 void ParticleSampler::sampleParticlesIntoLis << 106 97 107 if(sampleOneProton == &ParticleSampler::sa 98 if(sampleOneProton == &ParticleSampler::sampleOneParticleWithoutRPCorrelation) { 108 // sampling without correlation, we need 99 // sampling without correlation, we need to initialize the CDF tables 109 theRCDFTable[Proton] = NuclearDensityFac 100 theRCDFTable[Proton] = NuclearDensityFactory::createRCDFTable(Proton, theA, theZ); 110 thePCDFTable[Proton] = NuclearDensityFac 101 thePCDFTable[Proton] = NuclearDensityFactory::createPCDFTable(Proton, theA, theZ); 111 theRCDFTable[Neutron] = NuclearDensityFa 102 theRCDFTable[Neutron] = NuclearDensityFactory::createRCDFTable(Neutron, theA, theZ); 112 thePCDFTable[Neutron] = NuclearDensityFa 103 thePCDFTable[Neutron] = NuclearDensityFactory::createPCDFTable(Neutron, theA, theZ); 113 theRCDFTable[Lambda] = NuclearDensityFac << 114 thePCDFTable[Lambda] = NuclearDensityFac << 115 } 104 } 116 105 117 theList.resize(theA); << 106 ParticleList theList; 118 if(theA > 2) { 107 if(theA > 2) { 119 ParticleType type = Proton; 108 ParticleType type = Proton; 120 ParticleSamplerMethod sampleOneParticle 109 ParticleSamplerMethod sampleOneParticle = sampleOneProton; 121 for(G4int i = 0; i < theA; ++i) { << 110 for(G4int i = 1; i <= theA; ++i) { 122 if(i == theZ) { // Nucleons [Z..A-1] a << 111 if(i == (theZ + 1)) { // Nucleons [Z+1..A] are neutrons 123 type = Lambda; << 112 type = Neutron; 124 sampleOneParticle = sampleOneNeutron << 113 sampleOneParticle = sampleOneNeutron; 125 } 114 } 126 if(i == theZ - theS) type = Neutron; << 127 Particle *p = (this->*sampleOneParticl 115 Particle *p = (this->*sampleOneParticle)(type); 128 p->setPosition(position + p->getPositi 116 p->setPosition(position + p->getPosition()); 129 theList[i] = p; << 117 theList.push_back(p); 130 } 118 } 131 } else { 119 } else { 132 // For deuterons, only sample the proton 120 // For deuterons, only sample the proton position and momentum. The 133 // neutron position and momenta are dete 121 // neutron position and momenta are determined by the conditions of 134 // vanishing CM position and total momen 122 // vanishing CM position and total momentum. 135 // assert(theZ==1); 123 // assert(theZ==1); 136 Particle *aProton = (this->*(this->sampl 124 Particle *aProton = (this->*(this->sampleOneProton))(Proton); 137 Particle *aNeutron = new Particle(Neutro 125 Particle *aNeutron = new Particle(Neutron, -aProton->getMomentum(), position - aProton->getPosition()); 138 aProton->setPosition(position + aProton- 126 aProton->setPosition(position + aProton->getPosition()); 139 theList[0] = aProton; << 127 theList.push_back(aProton); 140 theList[1] = aNeutron; << 128 theList.push_back(aNeutron); 141 } 129 } >> 130 >> 131 return theList; 142 } 132 } 143 133 144 Particle *ParticleSampler::sampleOneParticle 134 Particle *ParticleSampler::sampleOneParticleWithRPCorrelation(const ParticleType t) const { 145 // assert(theDensity && thePotential); 135 // assert(theDensity && thePotential); 146 const G4double theFermiMomentum = thePoten 136 const G4double theFermiMomentum = thePotential->getFermiMomentum(t); 147 const ThreeVector momentumVector = Random: 137 const ThreeVector momentumVector = Random::sphereVector(theFermiMomentum); 148 const G4double momentumAbs = momentumVecto 138 const G4double momentumAbs = momentumVector.mag(); 149 const G4double momentumRatio = momentumAbs 139 const G4double momentumRatio = momentumAbs/theFermiMomentum; 150 const G4double reflectionRadius = theDensi 140 const G4double reflectionRadius = theDensity->getMaxRFromP(t, momentumRatio); 151 const ThreeVector positionVector = Random: 141 const ThreeVector positionVector = Random::sphereVector(reflectionRadius); 152 Particle *aParticle = new Particle(t, mome 142 Particle *aParticle = new Particle(t, momentumVector, positionVector); 153 aParticle->setUncorrelatedMomentum(momentu 143 aParticle->setUncorrelatedMomentum(momentumAbs); 154 return aParticle; 144 return aParticle; 155 } 145 } 156 146 157 Particle *ParticleSampler::sampleOneParticle 147 Particle *ParticleSampler::sampleOneParticleWithoutRPCorrelation(const ParticleType t) const { 158 const G4double position = (*(theRCDFTable[ 148 const G4double position = (*(theRCDFTable[t]))(Random::shoot()); 159 const G4double momentum = (*(thePCDFTable[ 149 const G4double momentum = (*(thePCDFTable[t]))(Random::shoot()); 160 ThreeVector positionVector = Random::normV 150 ThreeVector positionVector = Random::normVector(position); 161 ThreeVector momentumVector = Random::normV 151 ThreeVector momentumVector = Random::normVector(momentum); 162 return new Particle(t, momentumVector, pos 152 return new Particle(t, momentumVector, positionVector); 163 } 153 } 164 154 165 Particle *ParticleSampler::sampleOneParticle 155 Particle *ParticleSampler::sampleOneParticleWithFuzzyRPCorrelation(const ParticleType t) const { 166 // assert(theDensity && thePotential); 156 // assert(theDensity && thePotential); 167 std::pair<G4double,G4double> ranNumbers = 157 std::pair<G4double,G4double> ranNumbers = Random::correlatedUniform(rpCorrelationCoefficient[t]); 168 const G4double x = Math::pow13(ranNumbers. 158 const G4double x = Math::pow13(ranNumbers.first); 169 const G4double y = Math::pow13(ranNumbers. 159 const G4double y = Math::pow13(ranNumbers.second); 170 const G4double theFermiMomentum = thePoten 160 const G4double theFermiMomentum = thePotential->getFermiMomentum(t); 171 const ThreeVector momentumVector = Random: 161 const ThreeVector momentumVector = Random::normVector(y*theFermiMomentum); 172 const G4double reflectionRadius = theDensi 162 const G4double reflectionRadius = theDensity->getMaxRFromP(t, x); 173 const ThreeVector positionVector = Random: 163 const ThreeVector positionVector = Random::sphereVector(reflectionRadius); 174 Particle *aParticle = new Particle(t, mome 164 Particle *aParticle = new Particle(t, momentumVector, positionVector); 175 aParticle->setUncorrelatedMomentum(x*theFe 165 aParticle->setUncorrelatedMomentum(x*theFermiMomentum); 176 return aParticle; 166 return aParticle; 177 } 167 } 178 168 179 } 169 } 180 170 181 171