Geant4  10.02.p01
G4ParticleHPProduct.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 //
27 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
28 //
29 #ifndef G4ParticleHPProduct_h
30 #define G4ParticleHPProduct_h 1
31 
32 #include "G4HadronicException.hh"
33 #include "globals.hh"
34 #include "G4ParticleHPVector.hh"
35 #include "Randomize.hh"
36 #include "G4ios.hh"
37 #include <fstream>
38 #include "globals.hh"
41 
44 #include "G4ParticleHPIsotropic.hh"
47 #include "G4Cache.hh"
49 
51 
53 {
54 
55  struct toBeCached {
59  toBeCached() : theProjectileRP(NULL),theTarget(NULL),theCurrentMultiplicity(-1) {};
60  };
61 
62  public:
64  {
65  theDist = 0;
66  toBeCached val;
67  fCache.Put( val );
68 
69  char * method = getenv( "G4PHP_MULTIPLICITY_METHOD" );
70  if( method ) {
71  if( G4String(method) == "Poisson" ) {
73  } else if( G4String(method) == "BetweenInts" ) {
75  } else {
76  throw G4HadronicException(__FILE__, __LINE__, ("multiplicity method unknown to G4ParticleHPProduct" + G4String(method)).c_str());
77  }
78  } else {
80  }
81  }
83  {
84  if(theDist != 0) delete theDist;
85  }
86 
87  inline void Init(std::istream & aDataFile, G4ParticleDefinition* projectile)
88  {
91  if( getenv("G4PHPTEST") ) G4cout << " G4ParticleHPProduct :: Init MassCode " << theMassCode << " " << theMass << " theActualStateQValue " << theActualStateQValue << G4endl;// GDEB
92  if( getenv("G4PHPTEST") ) G4cout << " G4ParticleHPProduct :: Init theActualStateQValue " << theActualStateQValue << G4endl;// GDEB
94  theActualStateQValue*= CLHEP::eV;
95  theYield.Init(aDataFile, CLHEP::eV);
96  theYield.Hash();
97  if(theDistLaw==0)
98  {
99  // distribution not known, use E-independent, isotropic angular distribution
101  }
102  else if(theDistLaw == 1)
103  {
104  // Continuum energy-angular distribution
105  theDist = new G4ParticleHPContEnergyAngular(projectile);
106  }
107  else if(theDistLaw == 2)
108  {
109  // Discrete 2-body scattering
111  }
112  else if(theDistLaw == 3)
113  {
114  // Isotropic emission
116  }
117  else if(theDistLaw == 4)
118  {
119  // Discrete 2-body recoil modification
120  // not used for now. @@@@
122  // the above is only temporary;
123  // recoils need to be addressed
124  // properly
125  delete theDist;
126  theDist = 0;
127  }
128  // else if(theDistLaw == 5)
129  // {
130  // charged particles only, to be used in a later stage. @@@@
131  // }
132  else if(theDistLaw == 6)
133  {
134  // N-Body phase space
136  }
137  else if(theDistLaw == 7)
138  {
139  // Laboratory angular energy paraetrisation
141  }
142  else
143  {
144  throw G4HadronicException(__FILE__, __LINE__, "distribution law unknown to G4ParticleHPProduct");
145  }
146  if(theDist!=0)
147  {
148  theDist->SetQValue(theActualStateQValue);
149  theDist->Init(aDataFile);
150  }
151  }
152 
153  G4int GetMultiplicity(G4double anEnergy);
154  G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles);
155 
157  {
158  return theYield.GetY(anEnergy);
159  }
160 
161  void SetProjectileRP(G4ReactionProduct * aIncidentPart)
162  {
163  fCache.Get().theProjectileRP = aIncidentPart;
164  }
165 
166  void SetTarget(G4ReactionProduct * aTarget)
167  {
168  fCache.Get().theTarget = aTarget;
169  }
170 
171  inline G4ReactionProduct * GetTarget() { return fCache.Get().theTarget; }
172 
173  inline G4ReactionProduct * GetProjectileRP() { return fCache.Get().theProjectileRP; }
174 
176  {
177  G4double result;
178  if(theDist == 0)
179  {
180  result = 0;
181  }
182  else
183  {
185  result *= fCache.Get().theCurrentMultiplicity;
186  }
187  return result;
188  }
189 
191 
192  //TK120515 For migration of frameFlag (MF6 LCT) = 3 in
193  //G4ParticleHPEnAngCorrelation
196 
197  private:
198 
199  // data members
200 
206  G4int theDistLaw; // redundant
209 
210  // Utility quantities
211 
212  //G4ReactionProduct * theTarget;
213  //G4ReactionProduct * theProjectileRP;
214 
215  // cashed values
216 
217  //G4int theCurrentMultiplicity;
219 
221 };
222 
223 #endif
void Init(std::istream &aDataFile, G4ParticleDefinition *projectile)
virtual void Init(std::istream &aDataFile)=0
G4ReactionProduct * GetTarget()
G4VParticleHPEnergyAngular * theDist
G4HPMultiMethod theMultiplicityMethod
void SetProjectileRP(G4ReactionProduct *aIncidentPart)
G4double MeanEnergyOfThisInteraction()
int G4int
Definition: G4Types.hh:78
std::vector< G4ReactionProduct * > G4ReactionProductVector
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4GLOB_DLL std::ostream G4cout
G4ParticleHPVector theYield
G4double GetY(G4double x)
static const double eV
Definition: G4SIunits.hh:212
G4int GetMultiplicity(G4double anEnergy)
virtual G4double MeanEnergyOfThisInteraction()=0
G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles)
G4ReactionProduct * GetProjectileRP()
G4HPMultiMethod
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4Cache< toBeCached > fCache
void SetTarget(G4ReactionProduct *aTarget)
G4double GetMeanYield(G4double anEnergy)