Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28// Davide Mancusi, CEA
29// Alain Boudard, CEA
30// Sylvie Leray, CEA
31// Joseph Cugnon, University of Liege
32//
33// INCL++ revision: v5.1.8
34//
35#define INCLXX_IN_GEANT4_MODE 1
36
37#include "globals.hh"
38
39/* \file G4INCLInteractionAvatar.hh
40 * \brief Virtual class for interaction avatars.
41 *
42 * This class is inherited by decay and collision avatars. The goal is to
43 * provide a uniform treatment of common physics, such as Pauli blocking,
44 * enforcement of energy conservation, etc.
45 *
46 * \date Mar 1st, 2011
47 * \author Davide Mancusi
48 */
49
50#ifndef G4INCLINTERACTIONAVATAR_HH_
51#define G4INCLINTERACTIONAVATAR_HH_
52
53#include "G4INCLIAvatar.hh"
54#include "G4INCLNucleus.hh"
55#include "G4INCLFinalState.hh"
56#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 protected:
73 virtual G4INCL::IChannel* getChannel() const = 0;
74
76
77 /** \brief Apply local-energy transformation, if appropriate
78 *
79 * \param p particle to apply the transformation to
80 */
81 void preInteractionLocalEnergy(Particle * const p);
82
83 /** \brief Store the state of the particles before the interaction
84 *
85 * If the interaction cannot be realised for any reason, we will need to
86 * restore the particle state as it was before. This is done by calling
87 * the restoreParticles() method.
88 */
90
91 void preInteraction();
93
94 /** \brief Restore the state of both particles.
95 *
96 * The state must first be stored by calling preInteractionBlocking().
97 */
98 void restoreParticles() const;
99
100 /// \brief true if the given avatar should use local energy
102 if(!theNucleus) return false;
103 LocalEnergyType theLocalEnergyType;
105 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyPiType();
106 else
107 theLocalEnergyType = theNucleus->getStore()->getConfig()->getLocalEnergyBBType();
108
109 const G4bool firstAvatar = (theNucleus->getStore()->getBook()->getAcceptedCollisions() == 0);
110 return ((theLocalEnergyType == FirstCollisionLocalEnergy && firstAvatar) ||
111 theLocalEnergyType == AlwaysLocalEnergy);
112 }
113
125
126 private:
127 /// \brief RootFunctor-derived object for enforcing energy conservation in N-N.
128 class ViolationEMomentumFunctor : public RootFunctor {
129 public:
130 /** \brief Prepare for calling the () operator and scaleParticleMomenta
131 *
132 * The constructor sets the private class members.
133 */
134 ViolationEMomentumFunctor(Nucleus * const nucleus, FinalState const * const finalState, ThreeVector const * const boost, const G4bool localE);
135 virtual ~ViolationEMomentumFunctor() { particleMomenta.clear(); }
136
137 /** \brief Compute the energy-conservation violation.
138 *
139 * \param x scale factor for the particle momenta
140 * \return the energy-conservation violation
141 */
142 G4double operator()(const G4double x) const;
143
144 /// \brief Clean up after root finding
145 void cleanUp(const G4bool success) const;
146
147 private:
148 /// \brief List of final-state particles.
149 ParticleList finalParticles;
150 /// \brief CM particle momenta, as determined by the channel.
151 std::list<ThreeVector> particleMomenta;
152 /// \brief Total energy before the interaction.
153 G4double initialEnergy;
154 /// \brief Pointer to the nucleus
155 Nucleus *theNucleus;
156 /// \brief Pointer to the boost vector
157 ThreeVector const *boostVector;
158 /// \brief true if we must apply local energy to nucleons
159 G4bool hasLocalEnergy;
160 /// \brief true if we must apply local energy to deltas
161 G4bool hasLocalEnergyDelta;
162
163 /// \brief True if we should use local energy
164 const G4bool shouldUseLocalEnergy;
165
166 /** \brief Scale the momenta of the modified and created particles.
167 *
168 * Set the momenta of the modified and created particles to alpha times
169 * their original momenta (stored in particleMomenta). You must call
170 * init() before using this method.
171 *
172 * \param alpha scale factor
173 */
174 void scaleParticleMomenta(const G4double alpha) const;
175
176 };
177
178 /// \brief RootFunctor-derived object for enforcing energy conservation in pi-N.
179 class ViolationEEnergyFunctor : public RootFunctor {
180 public:
181 /** \brief Prepare for calling the () operator and scaleParticleMomenta
182 *
183 * The constructor sets the private class members.
184 */
185 ViolationEEnergyFunctor(Nucleus * const nucleus, FinalState const * const finalState);
186 virtual ~ViolationEEnergyFunctor() {}
187
188 /** \brief Compute the energy-conservation violation.
189 *
190 * \param x scale factor for the particle momenta
191 * \return the energy-conservation violation
192 */
193 G4double operator()(const G4double x) const;
194
195 /// \brief Clean up after root finding
196 void cleanUp(const G4bool success) const;
197
198 /** \brief Set the energy of the particle.
199 *
200 * \param energy
201 */
202 void setParticleEnergy(const G4double energy) const;
203
204 private:
205 /// \brief Total energy before the interaction.
206 G4double initialEnergy;
207 /// \brief Pointer to the nucleus.
208 Nucleus *theNucleus;
209 /// \brief The final-state particle.
210 Particle *theParticle;
211 /// \brief The initial energy of the particle.
212 G4double theEnergy;
213 /// \brief The initial momentum of the particle.
214 ThreeVector theMomentum;
215 /** \brief Threshold for the energy of the particle
216 *
217 * The particle (a delta) cannot have less than this energy.
218 */
219 G4double energyThreshold;
220 };
221
222 RootFunctor *violationEFunctor;
223
224 protected:
225 /** \brief Enforce energy conservation.
226 *
227 * Final states generated by the channels might violate energy conservation
228 * because of different reasons (energy-dependent potentials, local
229 * energy...). This conservation law must therefore be enforced by hand. We
230 * do so by rescaling the momenta of the final-state particles in the CM
231 * frame. If this turns out to be impossible, this method returns false.
232 *
233 * \return true if the algorithm succeeded
234 */
235 G4bool enforceEnergyConservation(FinalState * const fs);
236
237 };
238
239}
240
241#endif /* G4INCLINTERACTIONAVATAR_HH_ */
Static root-finder algorithm.
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:85
LocalEnergyType getLocalEnergyPiType() const
Get the type of local energy for pi-N and decay avatars.
LocalEnergyType getLocalEnergyBBType() const
Get the type of local energy for N-N avatars.
AvatarType getType() const
static const G4int maxIterLocE
Max number of iterations for the determination of the local-energy Q-value.
FinalState * postInteraction(FinalState *)
void restoreParticles() const
Restore the state of both particles.
virtual G4INCL::IChannel * getChannel() const =0
G4bool enforceEnergyConservation(FinalState *const fs)
Enforce energy conservation.
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.
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
G4bool bringParticleInside(Particle *const p)
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
Store * getStore() const
Book * getBook()
Definition: G4INCLStore.hh:243
Config const * getConfig()
Definition: G4INCLStore.hh:257
@ DecayAvatarType
@ FirstCollisionLocalEnergy
std::list< G4INCL::Particle * > ParticleList