Geant4 11.4.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 /**
76 * static instance
77 */
79
80 void setSrcPartner(Particle *p /*, const ThreeVector m*/);
81
82 /** \brief Apply local-energy transformation, if appropriate
83 *
84 * \param p particle to apply the transformation to
85 */
86 void preInteractionLocalEnergy(Particle * const p);
87
89
91
92 protected:
94
96
98
99 /** \brief Store the state of the particles before the interaction
100 *
101 * If the interaction cannot be realised for any reason, we will need to
102 * restore the particle state as it was before. This is done by calling
103 * the restoreParticles() method.
104 */
106
107 void preInteraction();
109
110 /** \brief Restore the state of both particles.
111 *
112 * The state must first be stored by calling preInteractionBlocking().
113 */
114 void restoreParticles() const;
115
116 void restoreSrcPartner(FinalState * fs);
117
118 /// \brief true if the given avatar should use local energy
120
128
129 private:
130 static G4ThreadLocal InteractionAvatar* interactionAvatar;
131 static G4ThreadLocal Particle *backupPartner;
132 static ThreeVector mbackupPartner;
133
134 /// \brief RootFunctor-derived object for enforcing energy conservation in N-N.
135 class ViolationEMomentumFunctor : public RootFunctor {
136 public:
137 /** \brief Prepare for calling the () operator and scaleParticleMomenta
138 *
139 * The constructor sets the private class members.
140 */
141 ViolationEMomentumFunctor(Nucleus * const nucleus, ParticleList const &modAndCre, const G4double totalEnergyBeforeInteraction, ThreeVector const &boost, const G4bool localE);
142 virtual ~ViolationEMomentumFunctor();
143
144 /** \brief Compute the energy-conservation violation.
145 *
146 * \param x scale factor for the particle momenta
147 * \return the energy-conservation violation
148 */
149 G4double operator()(const G4double x) const;
150
151 /// \brief Clean up after root finding
152 void cleanUp(const G4bool success) const;
153
154 private:
155 /// \brief List of final-state particles.
156 ParticleList finalParticles;
157 /// \brief CM particle momenta, as determined by the channel.
158 std::vector<ThreeVector> particleMomenta;
159 /// \brief Total energy before the interaction.
160 G4double initialEnergy;
161 /// \brief Pointer to the nucleus
163 /// \brief Pointer to the boost vector
165
166 /// \brief True if we should use local energy
168
169 /** \brief Scale the momenta of the modified and created particles.
170 *
171 * Set the momenta of the modified and created particles to alpha times
172 * their original momenta (stored in particleMomenta). You must call
173 * init() before using this method.
174 *
175 * \param alpha scale factor
176 */
177 void scaleParticleMomenta(const G4double alpha) const;
178
179 };
180
181 /// \brief RootFunctor-derived object for enforcing energy conservation in delta production
182 class ViolationEEnergyFunctor : public RootFunctor {
183 public:
184 /** \brief Prepare for calling the () operator and setParticleEnergy
185 *
186 * The constructor sets the private class members.
187 */
188 ViolationEEnergyFunctor(Nucleus * const nucleus, Particle * const aParticle, const G4double totalEnergyBeforeInteraction, const G4bool localE);
189 virtual ~ViolationEEnergyFunctor() {}
190
191 /** \brief Compute the energy-conservation violation.
192 *
193 * \param x scale factor for the particle energy
194 * \return the energy-conservation violation
195 */
196 G4double operator()(const G4double x) const;
197
198 /// \brief Clean up after root finding
199 void cleanUp(const G4bool success) const;
200
201 /** \brief Set the energy of the particle.
202 *
203 * \param energy
204 */
205 void setParticleEnergy(const G4double energy) const;
206
207 private:
208 /// \brief Total energy before the interaction.
209 G4double initialEnergy;
210 /// \brief Pointer to the nucleus.
211 Nucleus *theNucleus;
212 /// \brief The final-state particle.
213 Particle *theParticle;
214 /// \brief The initial energy of the particle.
215 G4double theEnergy;
216 /// \brief The initial momentum of the particle.
217 ThreeVector theMomentum;
218 /** \brief Threshold for the energy of the particle
219 *
220 * The particle (a delta) cannot have less than this energy.
221 */
222 G4double energyThreshold;
223 /// \brief Whether we should use local energy
225 };
226
227 RootFunctor *violationEFunctor;
228
229 protected:
230 /** \brief Enforce energy conservation.
231 *
232 * Final states generated by the channels might violate energy conservation
233 * because of different reasons (energy-dependent potentials, local
234 * energy...). This conservation law must therefore be enforced by hand. We
235 * do so by rescaling the momenta of the final-state particles in the CM
236 * frame. If this turns out to be impossible, this method returns false.
237 *
238 * \return true if the algorithm succeeded
239 */
240 G4bool enforceEnergyConservation(FinalState * const fs);
241
243
245 };
246
247}
248
249#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.
static InteractionAvatar * Instance()
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
InteractionAvatar(G4double, G4INCL::Nucleus *, G4INCL::Particle *)
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