Geant4  10.02.p01
G4ParticleHPContAngularPar.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 //
28 // 080718 Add ClearHistories method and related class member
29 //
30 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
31 //
32 #ifndef G4ParticleHPContAngularPar_h
33 #define G4ParticleHPContAngularPar_h 1
34 
35 #include "G4ios.hh"
36 #include <fstream>
37 #include "globals.hh"
38 #include "G4ParticleHPList.hh"
39 #include "G4ReactionProduct.hh"
42 #include "G4Cache.hh"
43 #include <set>
45 
47 {
48 
49  struct toBeCached {
56  toBeCached():fresh(true),currentMeanEnergy(-2.0),remaining_energy(0.0),theTargetCode(-1.0),theTarget(NULL),thePrimary(NULL){};
57  };
58 
59  public:
60 
62  {
63  theAngular = 0;
64  //currentMeanEnergy = -2;
65  //fresh = true;
66  fCache.Put(NULL);
69  }
70 
72 
74  {
75  if(theAngular!=0) delete [] theAngular;
76  }
77 
78  void Init(std::istream & aDataFile, G4ParticleDefinition* projectile);
79 
80  G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass,
81  G4int angularRep, G4int interpol);
82 
84  if( getenv("G4PHPTEST") ) G4cout << this << " G4ParticleHPContAngularPar::GetEnergy " << theEnergy << " nE " << nEnergies << G4endl;
85  return theEnergy; }
86 
87  void SetPrimary(G4ReactionProduct * aPrimary)
88  {
89  fCache.Get()->thePrimary = aPrimary;
90  }
91 
92  void SetTarget(G4ReactionProduct * aTarget)
93  {
94  fCache.Get()->theTarget = aTarget;
95  }
96 
97  void SetTargetCode(G4double aTargetCode) { fCache.Get()->theTargetCode = aTargetCode; }
98 
99  void SetInterpolation(G4int theInterpolation)
100  {
101  theManager.Init(theInterpolation, nEnergies); // one range only
102  }
103 
104  void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
105  G4ParticleHPContAngularPar & store1,
106  G4ParticleHPContAngularPar & store2); // hmmmm, this interpolates legendre coefficients. Dangerous @@@
107 
108  void PrepareTableInterpolation(const G4ParticleHPContAngularPar* angularPrev);
109 
111  {
112  G4double result;
113  if(fCache.Get()->currentMeanEnergy<-1)
114  {
115  return 0;
116  // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
117  }
118  else
119  {
120  result = fCache.Get()->currentMeanEnergy;
121  }
122  fCache.Get()->currentMeanEnergy = -2;
123  return result;
124  }
125 
127  {
128  return nEnergies;
129  }
131  {
132  return nDiscreteEnergies;
133  }
134  std::set<G4double> GetEnergiesTransformed() const
135  {
136  return theEnergiesTransformed;
137  }
139  {
140  return theEnergiesTransformed.size();
141  }
143  {
144  return theMinEner;
145  }
147  {
148  return theMaxEner;
149  }
150  std::map<G4double,G4int> GetDiscreteEnergiesOwn() const
151  {
152  return theDiscreteEnergiesOwn;
153  }
155  return theAngular;
156  }
157 
158 private:
159 
160  // incoming particle
162 
163  // number of exit channel energies
165  // number of discrete exit channels
167  // number of angular paramerers per channel
169  // knows the interpolation between List labels
171  // on per exit-channel energy
173 
175 
176  //G4double theTargetCode;
177  //G4ReactionProduct * theTarget;
178  //G4ReactionProduct * thePrimary;
179 
180  //G4double currentMeanEnergy;
181 
182 //080718
183  public:
184  //void ClearHistories(){ fresh = true; };
185  void ClearHistories(){
186  if ( fCache.Get() == NULL ) cacheInit();
187  fCache.Get()->fresh = true; };
188 
189  void Dump();
190  private:
192  void cacheInit() {
193  toBeCached* val = new toBeCached;
194  val->currentMeanEnergy = -2;
195  val->remaining_energy = 0;
196  val->fresh=true;
197  fCache.Put( val );
198  };
199  /*G4bool fresh;*/
200  /*G4double remaining_energy;*/ // represent energy rest of cascade chain
201 
203 
204  G4bool adjustResult; // if not set it will not force the conservation of energy in angularRep==1, but will sample the particle energy according to the database
205 
208  std::set<G4double> theEnergiesTransformed;
209  std::set<G4double> theDiscreteEnergies;
210  std::map<G4double,G4int> theDiscreteEnergiesOwn;
211 
212 };
213 #endif
std::map< G4double, G4int > GetDiscreteEnergiesOwn() const
void SetTargetCode(G4double aTargetCode)
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme, G4ParticleHPContAngularPar &store1, G4ParticleHPContAngularPar &store2)
void Init(G4int aScheme, G4int aRange)
void SetInterpolation(G4int theInterpolation)
int G4int
Definition: G4Types.hh:78
std::map< G4double, G4int > theDiscreteEnergiesOwn
std::set< G4double > GetEnergiesTransformed() const
G4GLOB_DLL std::ostream G4cout
void Init(std::istream &aDataFile, G4ParticleDefinition *projectile)
bool G4bool
Definition: G4Types.hh:79
G4ParticleHPList * GetAngDataList() const
void SetPrimary(G4ReactionProduct *aPrimary)
G4InterpolationScheme
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void PrepareTableInterpolation(const G4ParticleHPContAngularPar *angularPrev)
#define DBL_MAX
Definition: templates.hh:83
void Put(const value_type &val) const
Definition: G4Cache.hh:286
void SetTarget(G4ReactionProduct *aTarget)