Geant4  10.00.p03
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 
66  static const G4double locEAccuracy;
68  static const G4int maxIterLocE;
69 
71  static void deleteBackupParticles();
72 
73  protected:
74  virtual G4INCL::IChannel* getChannel() = 0;
75 
77 
82  void preInteractionLocalEnergy(Particle * const p);
83 
91 
92  void preInteraction();
94 
99  void restoreParticles() const;
100 
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:
125  public:
130  ViolationEMomentumFunctor(Nucleus * const nucleus, FinalState const * const finalState, ThreeVector const * const boost, const G4bool localE);
132 
138  G4double operator()(const G4double x) const;
139 
141  void cleanUp(const G4bool success) const;
142 
143  private:
147  std::list<ThreeVector> particleMomenta;
154 
157 
166  void scaleParticleMomenta(const G4double alpha) const;
167 
168  };
169 
172  public:
177  ViolationEEnergyFunctor(Nucleus * const nucleus, FinalState const * const finalState, const G4bool localE);
179 
185  G4double operator()(const G4double x) const;
186 
188  void cleanUp(const G4bool success) const;
189 
194  void setParticleEnergy(const G4double energy) const;
195 
196  private:
214  };
215 
217 
218  protected:
230 
231  };
232 
233 }
234 
235 #endif /* G4INCLINTERACTIONAVATAR_HH_ */
G4double theEnergy
The initial energy of the particle.
static const G4double locEAccuracy
Target accuracy in the determination of the local-energy Q-value.
void cleanUp(const G4bool success) const
Clean up after root finding.
Channel generates a final state of an avatar.
G4int getAcceptedCollisions() const
Definition: G4INCLBook.hh:99
void preInteractionLocalEnergy(Particle *const p)
Apply local-energy transformation, if appropriate.
const G4bool shouldUseLocalEnergy
True if we should use local energy.
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.
ParticleList finalParticles
List of final-state particles.
G4double initialEnergy
Total energy before the interaction.
RootFunctor-derived object for enforcing energy conservation in pi-N.
Config const * getConfig()
Get the config object.
Definition: G4INCLStore.hh:251
Store * getStore() const
virtual G4INCL::IChannel * getChannel()=0
#define G4ThreadLocal
Definition: tls.hh:52
ViolationEEnergyFunctor(Nucleus *const nucleus, FinalState const *const finalState, const G4bool localE)
Prepare for calling the () operator and scaleParticleMomenta.
int G4int
Definition: G4Types.hh:78
static G4ThreadLocal Particle * backupParticle2
InteractionAvatar(G4double, G4INCL::Nucleus *, G4INCL::Particle *)
G4double operator()(const G4double x) const
Compute the energy-conservation violation.
Final state of an interaction.
static void deleteBackupParticles()
Release the memory allocated for the backup particles.
Book & getBook()
Return the pointer to the Book object which keeps track of various counters.
Definition: G4INCLStore.hh:237
G4double initialEnergy
Total energy before the interaction.
bool G4bool
Definition: G4Types.hh:79
void setParticleEnergy(const G4double energy) const
Set the energy of the particle.
FinalState * postInteraction(FinalState *)
void preInteractionBlocking()
Store the state of the particles before the interaction.
static G4ThreadLocal Particle * backupParticle1
ThreeVector theMomentum
The initial momentum of the particle.
RootFunctor-derived object for enforcing energy conservation in N-N.
const G4bool shouldUseLocalEnergy
Whether we should use local energy.
G4double energyThreshold
Threshold for the energy of the particle.
ViolationEMomentumFunctor(Nucleus *const nucleus, FinalState const *const finalState, ThreeVector const *const boost, const G4bool localE)
Prepare for calling the () operator and scaleParticleMomenta.
LocalEnergyType getLocalEnergyPiType() const
Get the type of local energy for pi-N and decay avatars.
G4double energy(const ThreeVector &p, const G4double m)
LocalEnergyType getLocalEnergyBBType() const
Get the type of local energy for N-N avatars.
std::list< ThreeVector > particleMomenta
CM particle momenta, as determined by the channel.
ThreeVector const * boostVector
Pointer to the boost vector.
G4bool enforceEnergyConservation(FinalState *const fs)
Enforce energy conservation.
void restoreParticles() const
Restore the state of both particles.
G4double operator()(const G4double x) const
Compute the energy-conservation violation.
double G4double
Definition: G4Types.hh:76
G4bool bringParticleInside(Particle *const p)
void scaleParticleMomenta(const G4double alpha) const
Scale the momenta of the modified and created particles.
static const G4double alpha
void cleanUp(const G4bool success) const
Clean up after root finding.
AvatarType getType() const
Static root-finder algorithm.