Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
56  G4ReactionProduct* theProjectileRP;
58  G4int theCurrentMultiplicity;
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" ) {
72  theMultiplicityMethod = G4HPMultiPoisson;
73  } else if( G4String(method) == "BetweenInts" ) {
74  theMultiplicityMethod = G4HPMultiBetweenInts;
75  } else {
76  throw G4HadronicException(__FILE__, __LINE__, ("multiplicity method unknown to G4ParticleHPProduct" + G4String(method)).c_str());
77  }
78  } else {
79  theMultiplicityMethod = G4HPMultiPoisson;
80  }
81  theMassCode = 0.0;
82  theMass = 0.0;
83  theIsomerFlag = 0;
84  theGroundStateQValue = 0.0;
85  theActualStateQValue = 0.0;
86  theDistLaw = -1;
87  }
89  {
90  if(theDist != 0) delete theDist;
91  }
92 
93  inline void Init(std::istream & aDataFile, G4ParticleDefinition* projectile)
94  {
95  aDataFile >> theMassCode>>theMass>>theIsomerFlag>>theDistLaw
96  >> theGroundStateQValue>>theActualStateQValue;
97  if( getenv("G4PHPTEST") ) G4cout << " G4ParticleHPProduct :: Init MassCode " << theMassCode << " " << theMass << " theActualStateQValue " << theActualStateQValue << G4endl;// GDEB
98  if( getenv("G4PHPTEST") ) G4cout << " G4ParticleHPProduct :: Init theActualStateQValue " << theActualStateQValue << G4endl;// GDEB
99  theGroundStateQValue*= CLHEP::eV;
100  theActualStateQValue*= CLHEP::eV;
101  theYield.Init(aDataFile, CLHEP::eV);
102  theYield.Hash();
103  if(theDistLaw==0)
104  {
105  // distribution not known, use E-independent, isotropic angular distribution
106  theDist = new G4ParticleHPIsotropic;
107  }
108  else if(theDistLaw == 1)
109  {
110  // Continuum energy-angular distribution
111  theDist = new G4ParticleHPContEnergyAngular(projectile);
112  }
113  else if(theDistLaw == 2)
114  {
115  // Discrete 2-body scattering
116  theDist = new G4ParticleHPDiscreteTwoBody;
117  }
118  else if(theDistLaw == 3)
119  {
120  // Isotropic emission
121  theDist = new G4ParticleHPIsotropic;
122  }
123  else if(theDistLaw == 4)
124  {
125  // Discrete 2-body recoil modification
126  // not used for now. @@@@
127  theDist = new G4ParticleHPDiscreteTwoBody;
128  // the above is only temporary;
129  // recoils need to be addressed
130  // properly
131  delete theDist;
132  theDist = 0;
133  }
134  // else if(theDistLaw == 5)
135  // {
136  // charged particles only, to be used in a later stage. @@@@
137  // }
138  else if(theDistLaw == 6)
139  {
140  // N-Body phase space
141  theDist = new G4ParticleHPNBodyPhaseSpace;
142  }
143  else if(theDistLaw == 7)
144  {
145  // Laboratory angular energy paraetrisation
146  theDist = new G4ParticleHPLabAngularEnergy;
147  }
148  else
149  {
150  throw G4HadronicException(__FILE__, __LINE__, "distribution law unknown to G4ParticleHPProduct");
151  }
152  if(theDist!=0)
153  {
154  theDist->SetQValue(theActualStateQValue);
155  theDist->Init(aDataFile);
156  }
157  }
158 
159  G4int GetMultiplicity(G4double anEnergy);
160  G4ReactionProductVector * Sample(G4double anEnergy, G4int nParticles);
161 
163  {
164  return theYield.GetY(anEnergy);
165  }
166 
167  void SetProjectileRP(G4ReactionProduct * aIncidentPart)
168  {
169  fCache.Get().theProjectileRP = aIncidentPart;
170  }
171 
172  void SetTarget(G4ReactionProduct * aTarget)
173  {
174  fCache.Get().theTarget = aTarget;
175  }
176 
177  inline G4ReactionProduct * GetTarget() { return fCache.Get().theTarget; }
178 
179  inline G4ReactionProduct * GetProjectileRP() { return fCache.Get().theProjectileRP; }
180 
182  {
184  if(theDist == 0)
185  {
186  result = 0;
187  }
188  else
189  {
190  result=theDist->MeanEnergyOfThisInteraction();
191  result *= fCache.Get().theCurrentMultiplicity;
192  }
193  return result;
194  }
195 
196  inline G4double GetQValue() { return theActualStateQValue; }
197 
198  //TK120515 For migration of frameFlag (MF6 LCT) = 3 in
199  //G4ParticleHPEnAngCorrelation
200  G4double GetMassCode(){return theMassCode;};
201  G4double GetMass(){return theMass;};
202 
203  private:
204 
205  // data members
206 
207  G4double theMassCode;
208  G4double theMass;
209  G4int theIsomerFlag;
210  G4double theGroundStateQValue;
211  G4double theActualStateQValue;
212  G4int theDistLaw; // redundant
213  G4ParticleHPVector theYield;
214  G4VParticleHPEnergyAngular * theDist;
215 
216  // Utility quantities
217 
218  //G4ReactionProduct * theTarget;
219  //G4ReactionProduct * theProjectileRP;
220 
221  // cashed values
222 
223  //G4int theCurrentMultiplicity;
224  G4Cache<toBeCached> fCache;
225 
226  G4HPMultiMethod theMultiplicityMethod;
227 };
228 
229 #endif
G4double G4ParticleHPJENDLHEData::G4double result
void Init(std::istream &aDataFile, G4ParticleDefinition *projectile)
virtual void Init(std::istream &aDataFile)=0
G4ReactionProduct * GetTarget()
void SetProjectileRP(G4ReactionProduct *aIncidentPart)
value_type & Get() const
Definition: G4Cache.hh:282
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
G4ErrorTarget * theTarget
Definition: errprop.cc:59
G4double GetY(G4double x)
static constexpr double eV
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
void Put(const value_type &val) const
Definition: G4Cache.hh:286
void SetTarget(G4ReactionProduct *aTarget)
G4double GetMeanYield(G4double anEnergy)