Geant4_10
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:
124  class ViolationEMomentumFunctor : public RootFunctor {
125  public:
130  ViolationEMomentumFunctor(Nucleus * const nucleus, FinalState const * const finalState, ThreeVector const * const boost, const G4bool localE);
131  virtual ~ViolationEMomentumFunctor() { particleMomenta.clear(); }
132 
138  G4double operator()(const G4double x) const;
139 
141  void cleanUp(const G4bool success) const;
142 
143  private:
145  ParticleList finalParticles;
147  std::list<ThreeVector> particleMomenta;
149  G4double initialEnergy;
153  ThreeVector const *boostVector;
154 
157 
166  void scaleParticleMomenta(const G4double alpha) const;
167 
168  };
169 
171  class ViolationEEnergyFunctor : public RootFunctor {
172  public:
177  ViolationEEnergyFunctor(Nucleus * const nucleus, FinalState const * const finalState, const G4bool localE);
178  virtual ~ViolationEEnergyFunctor() {}
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:
198  G4double initialEnergy;
200  Nucleus *theNucleus;
202  Particle *theParticle;
204  G4double theEnergy;
206  ThreeVector theMomentum;
211  G4double energyThreshold;
214  };
215 
216  RootFunctor *violationEFunctor;
217 
218  protected:
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
tuple x
Definition: test.py:50
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
static G4ThreadLocal Particle * backupParticle2
InteractionAvatar(G4double, G4INCL::Nucleus *, G4INCL::Particle *)
double energy
Definition: plottest35.C:25
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.