Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCLInteractionAvatar.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
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 Helsinki Institute of Physics, Finland
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 G4INCLInteractionAvatar.hh
39 * \brief Virtual class for interaction avatars.
40 *
41 * This class is inherited by decay and collision avatars. The goal is to
42 * provide a uniform treatment of common physics, such as Pauli blocking,
43 * enforcement of energy conservation, etc.
44 *
45 * \date Mar 1st, 2011
46 * \author Davide Mancusi
47 */
48
49#ifndef G4INCLINTERACTIONAVATAR_HH_
50#define G4INCLINTERACTIONAVATAR_HH_
51
52#include "G4INCLIAvatar.hh"
53#include "G4INCLNucleus.hh"
54#include "G4INCLFinalState.hh"
55#include "G4INCLRootFinder.hh"
58
59namespace G4INCL {
60
62 public:
65 virtual ~InteractionAvatar();
66
67 /// \brief Target accuracy in the determination of the local-energy Q-value
68 static const G4double locEAccuracy;
69 /// \brief Max number of iterations for the determination of the local-energy Q-value
70 static const G4int maxIterLocE;
71
72 /// \brief Release the memory allocated for the backup particles
73 static void deleteBackupParticles();
74
75 protected:
77
79
80 /** \brief Apply local-energy transformation, if appropriate
81 *
82 * \param p particle to apply the transformation to
83 */
84 void preInteractionLocalEnergy(Particle * const p);
85
86 /** \brief Store the state of the particles before the interaction
87 *
88 * If the interaction cannot be realised for any reason, we will need to
89 * restore the particle state as it was before. This is done by calling
90 * the restoreParticles() method.
91 */
93
94 void preInteraction();
96
97 /** \brief Restore the state of both particles.
98 *
99 * The state must first be stored by calling preInteractionBlocking().
100 */
101 void restoreParticles() const;
102
103 /// \brief true if the given avatar should use local energy
105
113
114 private:
115 /// \brief RootFunctor-derived object for enforcing energy conservation in N-N.
116 class ViolationEMomentumFunctor : public RootFunctor {
117 public:
118 /** \brief Prepare for calling the () operator and scaleParticleMomenta
119 *
120 * The constructor sets the private class members.
121 */
122 ViolationEMomentumFunctor(Nucleus * const nucleus, ParticleList const &modAndCre, const G4double totalEnergyBeforeInteraction, ThreeVector const &boost, const G4bool localE);
123 virtual ~ViolationEMomentumFunctor();
124
125 /** \brief Compute the energy-conservation violation.
126 *
127 * \param x scale factor for the particle momenta
128 * \return the energy-conservation violation
129 */
130 G4double operator()(const G4double x) const;
131
132 /// \brief Clean up after root finding
133 void cleanUp(const G4bool success) const;
134
135 private:
136 /// \brief List of final-state particles.
137 ParticleList finalParticles;
138 /// \brief CM particle momenta, as determined by the channel.
139 std::vector<ThreeVector> particleMomenta;
140 /// \brief Total energy before the interaction.
141 G4double initialEnergy;
142 /// \brief Pointer to the nucleus
143 Nucleus *theNucleus;
144 /// \brief Pointer to the boost vector
145 ThreeVector const &boostVector;
146
147 /// \brief True if we should use local energy
148 const G4bool shouldUseLocalEnergy;
149
150 /** \brief Scale the momenta of the modified and created particles.
151 *
152 * Set the momenta of the modified and created particles to alpha times
153 * their original momenta (stored in particleMomenta). You must call
154 * init() before using this method.
155 *
156 * \param alpha scale factor
157 */
158 void scaleParticleMomenta(const G4double alpha) const;
159
160 };
161
162 /// \brief RootFunctor-derived object for enforcing energy conservation in delta production
163 class ViolationEEnergyFunctor : public RootFunctor {
164 public:
165 /** \brief Prepare for calling the () operator and setParticleEnergy
166 *
167 * The constructor sets the private class members.
168 */
169 ViolationEEnergyFunctor(Nucleus * const nucleus, Particle * const aParticle, const G4double totalEnergyBeforeInteraction, const G4bool localE);
170 virtual ~ViolationEEnergyFunctor() {}
171
172 /** \brief Compute the energy-conservation violation.
173 *
174 * \param x scale factor for the particle energy
175 * \return the energy-conservation violation
176 */
177 G4double operator()(const G4double x) const;
178
179 /// \brief Clean up after root finding
180 void cleanUp(const G4bool success) const;
181
182 /** \brief Set the energy of the particle.
183 *
184 * \param energy
185 */
186 void setParticleEnergy(const G4double energy) const;
187
188 private:
189 /// \brief Total energy before the interaction.
190 G4double initialEnergy;
191 /// \brief Pointer to the nucleus.
192 Nucleus *theNucleus;
193 /// \brief The final-state particle.
194 Particle *theParticle;
195 /// \brief The initial energy of the particle.
196 G4double theEnergy;
197 /// \brief The initial momentum of the particle.
198 ThreeVector theMomentum;
199 /** \brief Threshold for the energy of the particle
200 *
201 * The particle (a delta) cannot have less than this energy.
202 */
203 G4double energyThreshold;
204 /// \brief Whether we should use local energy
205 const G4bool shouldUseLocalEnergy;
206 };
207
208 RootFunctor *violationEFunctor;
209
210 protected:
211 /** \brief Enforce energy conservation.
212 *
213 * Final states generated by the channels might violate energy conservation
214 * because of different reasons (energy-dependent potentials, local
215 * energy...). This conservation law must therefore be enforced by hand. We
216 * do so by rescaling the momenta of the final-state particles in the CM
217 * frame. If this turns out to be impossible, this method returns false.
218 *
219 * \return true if the algorithm succeeded
220 */
221 G4bool enforceEnergyConservation(FinalState * const fs);
222
224
226 };
227
228}
229
230#endif /* G4INCLINTERACTIONAVATAR_HH_ */
Singleton for recycling allocation of instances of a given class.
#define INCL_DECLARE_ALLOCATION_POOL(T)
Static root-finder algorithm.
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
static const G4int maxIterLocE
Max number of iterations for the determination of the local-energy Q-value.
void restoreParticles() const
Restore the state of both particles.
G4bool enforceEnergyConservation(FinalState *const fs)
Enforce energy conservation.
static void deleteBackupParticles()
Release the memory allocated for the backup particles.
void preInteractionBlocking()
Store the state of the particles before the interaction.
static const G4double locEAccuracy
Target accuracy in the determination of the local-energy Q-value.
virtual G4INCL::IChannel * getChannel()=0
static G4ThreadLocal Particle * backupParticle2
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
static G4ThreadLocal Particle * backupParticle1
G4bool bringParticleInside(Particle *const p)
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
#define G4ThreadLocal
Definition: tls.hh:77