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 G4INCLInteractionAvatar.hh 37 /* \file G4INCLInteractionAvatar.hh 39 * \brief Virtual class for interaction avatar 38 * \brief Virtual class for interaction avatars. 40 * 39 * 41 * This class is inherited by decay and collis 40 * This class is inherited by decay and collision avatars. The goal is to 42 * provide a uniform treatment of common physi 41 * provide a uniform treatment of common physics, such as Pauli blocking, 43 * enforcement of energy conservation, etc. 42 * enforcement of energy conservation, etc. 44 * 43 * 45 * \date Mar 1st, 2011 44 * \date Mar 1st, 2011 46 * \author Davide Mancusi 45 * \author Davide Mancusi 47 */ 46 */ 48 47 49 #ifndef G4INCLINTERACTIONAVATAR_HH_ 48 #ifndef G4INCLINTERACTIONAVATAR_HH_ 50 #define G4INCLINTERACTIONAVATAR_HH_ 49 #define G4INCLINTERACTIONAVATAR_HH_ 51 50 52 #include "G4INCLIAvatar.hh" 51 #include "G4INCLIAvatar.hh" 53 #include "G4INCLNucleus.hh" 52 #include "G4INCLNucleus.hh" 54 #include "G4INCLFinalState.hh" 53 #include "G4INCLFinalState.hh" 55 #include "G4INCLRootFinder.hh" 54 #include "G4INCLRootFinder.hh" 56 #include "G4INCLKinematicsUtils.hh" 55 #include "G4INCLKinematicsUtils.hh" 57 #include "G4INCLAllocationPool.hh" << 58 56 59 namespace G4INCL { 57 namespace G4INCL { 60 58 61 class InteractionAvatar : public G4INCL::IAv 59 class InteractionAvatar : public G4INCL::IAvatar { 62 public: 60 public: 63 InteractionAvatar(G4double, G4INCL::Nucl 61 InteractionAvatar(G4double, G4INCL::Nucleus*, G4INCL::Particle*); 64 InteractionAvatar(G4double, G4INCL::Nucl 62 InteractionAvatar(G4double, G4INCL::Nucleus*, G4INCL::Particle*, G4INCL::Particle*); 65 virtual ~InteractionAvatar(); 63 virtual ~InteractionAvatar(); 66 64 67 /// \brief Target accuracy in the determ 65 /// \brief Target accuracy in the determination of the local-energy Q-value 68 static const G4double locEAccuracy; 66 static const G4double locEAccuracy; 69 /// \brief Max number of iterations for 67 /// \brief Max number of iterations for the determination of the local-energy Q-value 70 static const G4int maxIterLocE; 68 static const G4int maxIterLocE; 71 69 72 /// \brief Release the memory allocated 70 /// \brief Release the memory allocated for the backup particles 73 static void deleteBackupParticles(); 71 static void deleteBackupParticles(); 74 72 75 protected: 73 protected: 76 virtual G4INCL::IChannel* getChannel() = 74 virtual G4INCL::IChannel* getChannel() = 0; 77 75 78 G4bool bringParticleInside(Particle * co 76 G4bool bringParticleInside(Particle * const p); 79 77 80 /** \brief Apply local-energy transforma 78 /** \brief Apply local-energy transformation, if appropriate 81 * 79 * 82 * \param p particle to apply the transf 80 * \param p particle to apply the transformation to 83 */ 81 */ 84 void preInteractionLocalEnergy(Particle 82 void preInteractionLocalEnergy(Particle * const p); 85 83 86 /** \brief Store the state of the partic 84 /** \brief Store the state of the particles before the interaction 87 * 85 * 88 * If the interaction cannot be realised 86 * If the interaction cannot be realised for any reason, we will need to 89 * restore the particle state as it was 87 * restore the particle state as it was before. This is done by calling 90 * the restoreParticles() method. 88 * the restoreParticles() method. 91 */ 89 */ 92 void preInteractionBlocking(); 90 void preInteractionBlocking(); 93 91 94 void preInteraction(); 92 void preInteraction(); 95 void postInteraction(FinalState *); << 93 FinalState *postInteraction(FinalState *); 96 94 97 /** \brief Restore the state of both par 95 /** \brief Restore the state of both particles. 98 * 96 * 99 * The state must first be stored by cal 97 * The state must first be stored by calling preInteractionBlocking(). 100 */ 98 */ 101 void restoreParticles() const; 99 void restoreParticles() const; 102 100 103 /// \brief true if the given avatar shou 101 /// \brief true if the given avatar should use local energy 104 G4bool shouldUseLocalEnergy() const; << 102 G4bool shouldUseLocalEnergy() const { >> 103 if(!theNucleus) return false; >> 104 LocalEnergyType theLocalEnergyType; >> 105 if(getType()==DecayAvatarType || isPiN) >> 106 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType(); >> 107 else >> 108 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType(); >> 109 >> 110 const G4bool firstAvatar = (theNucleus->getStore()->getBook().getAcceptedCollisions() == 0); >> 111 return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) || >> 112 theLocalEnergyType == AlwaysLocalEnergy); >> 113 } 105 114 106 Nucleus *theNucleus; 115 Nucleus *theNucleus; 107 Particle *particle1, *particle2; 116 Particle *particle1, *particle2; 108 static G4ThreadLocal Particle *backupPar 117 static G4ThreadLocal Particle *backupParticle1, *backupParticle2; 109 ThreeVector boostVector; 118 ThreeVector boostVector; 110 G4double oldTotalEnergy, oldXSec; 119 G4double oldTotalEnergy, oldXSec; 111 G4bool isPiN; 120 G4bool isPiN; 112 G4double weight; << 113 121 114 private: 122 private: 115 /// \brief RootFunctor-derived object fo 123 /// \brief RootFunctor-derived object for enforcing energy conservation in N-N. 116 class ViolationEMomentumFunctor : public 124 class ViolationEMomentumFunctor : public RootFunctor { 117 public: 125 public: 118 /** \brief Prepare for calling the ( 126 /** \brief Prepare for calling the () operator and scaleParticleMomenta 119 * 127 * 120 * The constructor sets the private 128 * The constructor sets the private class members. 121 */ 129 */ 122 ViolationEMomentumFunctor(Nucleus * << 130 ViolationEMomentumFunctor(Nucleus * const nucleus, FinalState const * const finalState, ThreeVector const * const boost, const G4bool localE); 123 virtual ~ViolationEMomentumFunctor() << 131 virtual ~ViolationEMomentumFunctor() { particleMomenta.clear(); } 124 132 125 /** \brief Compute the energy-conser 133 /** \brief Compute the energy-conservation violation. 126 * 134 * 127 * \param x scale factor for the par 135 * \param x scale factor for the particle momenta 128 * \return the energy-conservation v 136 * \return the energy-conservation violation 129 */ 137 */ 130 G4double operator()(const G4double x 138 G4double operator()(const G4double x) const; 131 139 132 /// \brief Clean up after root findi 140 /// \brief Clean up after root finding 133 void cleanUp(const G4bool success) c 141 void cleanUp(const G4bool success) const; 134 142 135 private: 143 private: 136 /// \brief List of final-state parti 144 /// \brief List of final-state particles. 137 ParticleList finalParticles; 145 ParticleList finalParticles; 138 /// \brief CM particle momenta, as d 146 /// \brief CM particle momenta, as determined by the channel. 139 std::vector<ThreeVector> particleMom << 147 std::list<ThreeVector> particleMomenta; 140 /// \brief Total energy before the i 148 /// \brief Total energy before the interaction. 141 G4double initialEnergy; 149 G4double initialEnergy; 142 /// \brief Pointer to the nucleus 150 /// \brief Pointer to the nucleus 143 Nucleus *theNucleus; 151 Nucleus *theNucleus; 144 /// \brief Pointer to the boost vect 152 /// \brief Pointer to the boost vector 145 ThreeVector const &boostVector; << 153 ThreeVector const *boostVector; 146 154 147 /// \brief True if we should use loc 155 /// \brief True if we should use local energy 148 const G4bool shouldUseLocalEnergy; 156 const G4bool shouldUseLocalEnergy; 149 157 150 /** \brief Scale the momenta of the 158 /** \brief Scale the momenta of the modified and created particles. 151 * 159 * 152 * Set the momenta of the modified a 160 * Set the momenta of the modified and created particles to alpha times 153 * their original momenta (stored in 161 * their original momenta (stored in particleMomenta). You must call 154 * init() before using this method. 162 * init() before using this method. 155 * 163 * 156 * \param alpha scale factor 164 * \param alpha scale factor 157 */ 165 */ 158 void scaleParticleMomenta(const G4do 166 void scaleParticleMomenta(const G4double alpha) const; 159 167 160 }; 168 }; 161 169 162 /// \brief RootFunctor-derived object fo << 170 /// \brief RootFunctor-derived object for enforcing energy conservation in pi-N. 163 class ViolationEEnergyFunctor : public R 171 class ViolationEEnergyFunctor : public RootFunctor { 164 public: 172 public: 165 /** \brief Prepare for calling the ( << 173 /** \brief Prepare for calling the () operator and scaleParticleMomenta 166 * 174 * 167 * The constructor sets the private 175 * The constructor sets the private class members. 168 */ 176 */ 169 ViolationEEnergyFunctor(Nucleus * co << 177 ViolationEEnergyFunctor(Nucleus * const nucleus, FinalState const * const finalState, const G4bool localE); 170 virtual ~ViolationEEnergyFunctor() { 178 virtual ~ViolationEEnergyFunctor() {} 171 179 172 /** \brief Compute the energy-conser 180 /** \brief Compute the energy-conservation violation. 173 * 181 * 174 * \param x scale factor for the par << 182 * \param x scale factor for the particle momenta 175 * \return the energy-conservation v 183 * \return the energy-conservation violation 176 */ 184 */ 177 G4double operator()(const G4double x 185 G4double operator()(const G4double x) const; 178 186 179 /// \brief Clean up after root findi 187 /// \brief Clean up after root finding 180 void cleanUp(const G4bool success) c 188 void cleanUp(const G4bool success) const; 181 189 182 /** \brief Set the energy of the par 190 /** \brief Set the energy of the particle. 183 * 191 * 184 * \param energy 192 * \param energy 185 */ 193 */ 186 void setParticleEnergy(const G4doubl 194 void setParticleEnergy(const G4double energy) const; 187 195 188 private: 196 private: 189 /// \brief Total energy before the i 197 /// \brief Total energy before the interaction. 190 G4double initialEnergy; 198 G4double initialEnergy; 191 /// \brief Pointer to the nucleus. 199 /// \brief Pointer to the nucleus. 192 Nucleus *theNucleus; 200 Nucleus *theNucleus; 193 /// \brief The final-state particle. 201 /// \brief The final-state particle. 194 Particle *theParticle; 202 Particle *theParticle; 195 /// \brief The initial energy of the 203 /// \brief The initial energy of the particle. 196 G4double theEnergy; 204 G4double theEnergy; 197 /// \brief The initial momentum of t 205 /// \brief The initial momentum of the particle. 198 ThreeVector theMomentum; 206 ThreeVector theMomentum; 199 /** \brief Threshold for the energy 207 /** \brief Threshold for the energy of the particle 200 * 208 * 201 * The particle (a delta) cannot hav 209 * The particle (a delta) cannot have less than this energy. 202 */ 210 */ 203 G4double energyThreshold; 211 G4double energyThreshold; 204 /// \brief Whether we should use loc 212 /// \brief Whether we should use local energy 205 const G4bool shouldUseLocalEnergy; 213 const G4bool shouldUseLocalEnergy; 206 }; 214 }; 207 215 208 RootFunctor *violationEFunctor; 216 RootFunctor *violationEFunctor; 209 217 210 protected: 218 protected: 211 /** \brief Enforce energy conservation. 219 /** \brief Enforce energy conservation. 212 * 220 * 213 * Final states generated by the channel 221 * Final states generated by the channels might violate energy conservation 214 * because of different reasons (energy- 222 * because of different reasons (energy-dependent potentials, local 215 * energy...). This conservation law mus 223 * energy...). This conservation law must therefore be enforced by hand. We 216 * do so by rescaling the momenta of the 224 * do so by rescaling the momenta of the final-state particles in the CM 217 * frame. If this turns out to be imposs 225 * frame. If this turns out to be impossible, this method returns false. 218 * 226 * 219 * \return true if the algorithm succeed 227 * \return true if the algorithm succeeded 220 */ 228 */ 221 G4bool enforceEnergyConservation(FinalSt 229 G4bool enforceEnergyConservation(FinalState * const fs); 222 230 223 ParticleList modified, created, modified << 224 << 225 INCL_DECLARE_ALLOCATION_POOL(Interaction << 226 }; 231 }; 227 232 228 } 233 } 229 234 230 #endif /* G4INCLINTERACTIONAVATAR_HH_ */ 235 #endif /* G4INCLINTERACTIONAVATAR_HH_ */ 231 236