Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 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 H 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 38 /** \file G4INCLParticleSampler.cc 39 * \brief Class for sampling particles in a nu 40 * 41 * \date 18 July 2012 42 * \author Davide Mancusi 43 */ 44 45 #include "G4INCLParticleSampler.hh" 46 #include "G4INCLParticleTable.hh" 47 #include "G4INCLNuclearDensityFactory.hh" 48 49 namespace G4INCL { 50 51 ParticleSampler::ParticleSampler(const G4int 52 sampleOneProton(&ParticleSampler::sampleOn 53 sampleOneNeutron(&ParticleSampler::sampleO 54 theA(A), 55 theZ(Z), 56 theS(S), 57 theDensity(NULL), 58 thePotential(NULL) 59 { 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 68 ParticleSampler::~ParticleSampler() { 69 } 70 71 void ParticleSampler::setDensity(NuclearDens 72 theDensity = d; 73 updateSampleOneParticleMethods(); 74 } 75 76 void ParticleSampler::setPotential(NuclearPo 77 thePotential = p; 78 updateSampleOneParticleMethods(); 79 } 80 81 void ParticleSampler::updateSampleOneParticl 82 if(theDensity && thePotential) { 83 if(rpCorrelationCoefficient[Proton]>0.99 84 sampleOneProton = &ParticleSampler::sa 85 } else { 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 } 98 99 ParticleList ParticleSampler::sampleParticle 100 ParticleList aList; 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) { 119 ParticleType type = Proton; 120 ParticleSamplerMethod sampleOneParticle 121 for(G4int i = 0; i < theA; ++i) { 122 if(i == theZ) { // Nucleons [Z..A-1] a 123 type = Lambda; 124 sampleOneParticle = sampleOneNeutron 125 } 126 if(i == theZ - theS) type = Neutron; 127 Particle *p = (this->*sampleOneParticl 128 p->setPosition(position + p->getPositi 129 theList[i] = p; 130 } 131 } else { 132 // For deuterons, only sample the proton 133 // neutron position and momenta are dete 134 // vanishing CM position and total momen 135 // assert(theZ==1); 136 Particle *aProton = (this->*(this->sampl 137 Particle *aNeutron = new Particle(Neutro 138 aProton->setPosition(position + aProton- 139 theList[0] = aProton; 140 theList[1] = aNeutron; 141 } 142 } 143 144 Particle *ParticleSampler::sampleOneParticle 145 // assert(theDensity && thePotential); 146 const G4double theFermiMomentum = thePoten 147 const ThreeVector momentumVector = Random: 148 const G4double momentumAbs = momentumVecto 149 const G4double momentumRatio = momentumAbs 150 const G4double reflectionRadius = theDensi 151 const ThreeVector positionVector = Random: 152 Particle *aParticle = new Particle(t, mome 153 aParticle->setUncorrelatedMomentum(momentu 154 return aParticle; 155 } 156 157 Particle *ParticleSampler::sampleOneParticle 158 const G4double position = (*(theRCDFTable[ 159 const G4double momentum = (*(thePCDFTable[ 160 ThreeVector positionVector = Random::normV 161 ThreeVector momentumVector = Random::normV 162 return new Particle(t, momentumVector, pos 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 } 178 179 } 180 181