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.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/inclxx/incl_physics/src/G4INCLParticleSampler.cc (Version 11.3.0) and /processes/hadronic/models/inclxx/incl_physics/src/G4INCLParticleSampler.cc (Version 10.6.p3)


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