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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 11.1)


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