Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 /* \file G4INCLInteractionAvatar.hh
38  * \brief Virtual class for interaction avatars.
39  *
40  * This class is inherited by decay and collision avatars. The goal is to
41  * provide a uniform treatment of common physics, such as Pauli blocking,
42  * enforcement of energy conservation, etc.
43  *
44  * \date Mar 1st, 2011
45  * \author Davide Mancusi
46  */
47 
48 #ifndef G4INCLINTERACTIONAVATAR_HH_
49 #define G4INCLINTERACTIONAVATAR_HH_
50 
51 #include "G4INCLIAvatar.hh"
52 #include "G4INCLNucleus.hh"
53 #include "G4INCLFinalState.hh"
54 #include "G4INCLRootFinder.hh"
55 #include "G4INCLKinematicsUtils.hh"
56 
57 namespace G4INCL {
58 
60  public:
63  virtual ~InteractionAvatar();
64 
65  /// \brief Target accuracy in the determination of the local-energy Q-value
66  static const G4double locEAccuracy;
67  /// \brief Max number of iterations for the determination of the local-energy Q-value
68  static const G4int maxIterLocE;
69 
70  /// \brief Release the memory allocated for the backup particles
71  static void deleteBackupParticles();
72 
73  protected:
74  virtual G4INCL::IChannel* getChannel() = 0;
75 
77 
78  /** \brief Apply local-energy transformation, if appropriate
79  *
80  * \param p particle to apply the transformation to
81  */
82  void preInteractionLocalEnergy(Particle * const p);
83 
84  /** \brief Store the state of the particles before the interaction
85  *
86  * If the interaction cannot be realised for any reason, we will need to
87  * restore the particle state as it was before. This is done by calling
88  * the restoreParticles() method.
89  */
91 
92  void preInteraction();
94 
95  /** \brief Restore the state of both particles.
96  *
97  * The state must first be stored by calling preInteractionBlocking().
98  */
99  void restoreParticles() const;
100 
101  /// \brief true if the given avatar should use local energy
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  }
114 
121 
122  private:
123  /// \brief RootFunctor-derived object for enforcing energy conservation in N-N.
124  class ViolationEMomentumFunctor : public RootFunctor {
125  public:
126  /** \brief Prepare for calling the () operator and scaleParticleMomenta
127  *
128  * The constructor sets the private class members.
129  */
130  ViolationEMomentumFunctor(Nucleus * const nucleus, FinalState const * const finalState, ThreeVector const * const boost, const G4bool localE);
131  virtual ~ViolationEMomentumFunctor() { particleMomenta.clear(); }
132 
133  /** \brief Compute the energy-conservation violation.
134  *
135  * \param x scale factor for the particle momenta
136  * \return the energy-conservation violation
137  */
138  G4double operator()(const G4double x) const;
139 
140  /// \brief Clean up after root finding
141  void cleanUp(const G4bool success) const;
142 
143  private:
144  /// \brief List of final-state particles.
145  ParticleList finalParticles;
146  /// \brief CM particle momenta, as determined by the channel.
147  std::list<ThreeVector> particleMomenta;
148  /// \brief Total energy before the interaction.
149  G4double initialEnergy;
150  /// \brief Pointer to the nucleus
152  /// \brief Pointer to the boost vector
153  ThreeVector const *boostVector;
154 
155  /// \brief True if we should use local energy
157 
158  /** \brief Scale the momenta of the modified and created particles.
159  *
160  * Set the momenta of the modified and created particles to alpha times
161  * their original momenta (stored in particleMomenta). You must call
162  * init() before using this method.
163  *
164  * \param alpha scale factor
165  */
166  void scaleParticleMomenta(const G4double alpha) const;
167 
168  };
169 
170  /// \brief RootFunctor-derived object for enforcing energy conservation in pi-N.
171  class ViolationEEnergyFunctor : public RootFunctor {
172  public:
173  /** \brief Prepare for calling the () operator and scaleParticleMomenta
174  *
175  * The constructor sets the private class members.
176  */
177  ViolationEEnergyFunctor(Nucleus * const nucleus, FinalState const * const finalState, const G4bool localE);
178  virtual ~ViolationEEnergyFunctor() {}
179 
180  /** \brief Compute the energy-conservation violation.
181  *
182  * \param x scale factor for the particle momenta
183  * \return the energy-conservation violation
184  */
185  G4double operator()(const G4double x) const;
186 
187  /// \brief Clean up after root finding
188  void cleanUp(const G4bool success) const;
189 
190  /** \brief Set the energy of the particle.
191  *
192  * \param energy
193  */
194  void setParticleEnergy(const G4double energy) const;
195 
196  private:
197  /// \brief Total energy before the interaction.
198  G4double initialEnergy;
199  /// \brief Pointer to the nucleus.
200  Nucleus *theNucleus;
201  /// \brief The final-state particle.
202  Particle *theParticle;
203  /// \brief The initial energy of the particle.
204  G4double theEnergy;
205  /// \brief The initial momentum of the particle.
206  ThreeVector theMomentum;
207  /** \brief Threshold for the energy of the particle
208  *
209  * The particle (a delta) cannot have less than this energy.
210  */
211  G4double energyThreshold;
212  /// \brief Whether we should use local energy
214  };
215 
216  RootFunctor *violationEFunctor;
217 
218  protected:
219  /** \brief Enforce energy conservation.
220  *
221  * Final states generated by the channels might violate energy conservation
222  * because of different reasons (energy-dependent potentials, local
223  * energy...). This conservation law must therefore be enforced by hand. We
224  * do so by rescaling the momenta of the final-state particles in the CM
225  * frame. If this turns out to be impossible, this method returns false.
226  *
227  * \return true if the algorithm succeeded
228  */
229  G4bool enforceEnergyConservation(FinalState * const fs);
230 
231  };
232 
233 }
234 
235 #endif /* G4INCLINTERACTIONAVATAR_HH_ */
static const G4double locEAccuracy
Target accuracy in the determination of the local-energy Q-value.
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:99
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
G4bool shouldUseLocalEnergy() const
true if the given avatar should use local energy
static const G4int maxIterLocE
Max number of iterations for the determination of the local-energy Q-value.
const char * p
Definition: xmltok.h:285
Config const * getConfig()
Definition: G4INCLStore.hh:251
Store * getStore() const
virtual G4INCL::IChannel * getChannel()=0
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
static G4ThreadLocal Particle * backupParticle2
InteractionAvatar(G4double, G4INCL::Nucleus *, G4INCL::Particle *)
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
static void deleteBackupParticles()
Release the memory allocated for the backup particles.
Book & getBook()
Definition: G4INCLStore.hh:237
bool G4bool
Definition: G4Types.hh:79
FinalState * postInteraction(FinalState *)
void preInteractionBlocking()
Store the state of the particles before the interaction.
static G4ThreadLocal Particle * backupParticle1
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.
G4bool enforceEnergyConservation(FinalState *const fs)
Enforce energy conservation.
void restoreParticles() const
Restore the state of both particles.
double G4double
Definition: G4Types.hh:76
G4bool bringParticleInside(Particle *const p)
AvatarType getType() const
Static root-finder algorithm.