Geant4  10.02
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 {
53  toBeCached():fresh(true),currentMeanEnergy(-2.0),remaining_energy(0.0){};
54  };
55 
56  public:
57 
59  {
60  theAngular = 0;
61  //currentMeanEnergy = -2;
62  //fresh = true;
63  fCache.Put(NULL);
66  }
67 
69 
71  {
72  if(theAngular!=0) delete [] theAngular;
73  }
74 
75  void Init(std::istream & aDataFile, G4ParticleDefinition* projectile);
76 
77  G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass,
78  G4int angularRep, G4int interpol);
79 
81  if( getenv("G4PHPTEST") ) G4cout << this << " G4ParticleHPContAngularPar::GetEnergy " << theEnergy << " nE " << nEnergies << G4endl;
82  return theEnergy; }
83 
84  void SetPrimary(G4ReactionProduct * aPrimary)
85  {
86  thePrimary = aPrimary;
87  }
88 
89  void SetTarget(G4ReactionProduct * aTarget)
90  {
91  theTarget = aTarget;
92  }
93 
94  void SetTargetCode(G4double aTargetCode) { theTargetCode = aTargetCode; }
95 
96  void SetInterpolation(G4int theInterpolation)
97  {
98  theManager.Init(theInterpolation, nEnergies); // one range only
99  }
100 
101  void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
102  G4ParticleHPContAngularPar & store1,
103  G4ParticleHPContAngularPar & store2); // hmmmm, this interpolates legendre coefficients. Dangerous @@@
104 
105  void PrepareTableInterpolation(const G4ParticleHPContAngularPar* angularPrev);
106 
108  {
109  G4double result;
110  if(fCache.Get()->currentMeanEnergy<-1)
111  {
112  return 0;
113  // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
114  }
115  else
116  {
117  result = fCache.Get()->currentMeanEnergy;
118  }
119  fCache.Get()->currentMeanEnergy = -2;
120  return result;
121  }
122 
124  {
125  return nEnergies;
126  }
128  {
129  return nDiscreteEnergies;
130  }
131  std::set<G4double> GetEnergiesTransformed() const
132  {
133  return theEnergiesTransformed;
134  }
136  {
137  return theEnergiesTransformed.size();
138  }
140  {
141  return theMinEner;
142  }
144  {
145  return theMaxEner;
146  }
147  std::map<G4double,G4int> GetDiscreteEnergiesOwn() const
148  {
149  return theDiscreteEnergiesOwn;
150  }
152  return theAngular;
153  }
154 
155 private:
156 
157  // incoming particle
159 
160  // number of exit channel energies
162  // number of discrete exit channels
164  // number of angular paramerers per channel
166  // knows the interpolation between List labels
168  // on per exit-channel energy
170 
172 
176 
177  //G4double currentMeanEnergy;
178 
179 //080718
180  public:
181  //void ClearHistories(){ fresh = true; };
182  void ClearHistories(){
183  if ( fCache.Get() == NULL ) cacheInit();
184  fCache.Get()->fresh = true; };
185 
186  void Dump();
187  private:
189  void cacheInit() {
190  toBeCached* val = new toBeCached;
191  val->currentMeanEnergy = -2;
192  val->remaining_energy = 0;
193  val->fresh=true;
194  fCache.Put( val );
195  };
196  /*G4bool fresh;*/
197  /*G4double remaining_energy;*/ // represent energy rest of cascade chain
198 
200 
201  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
202 
205  std::set<G4double> theEnergiesTransformed;
206  std::set<G4double> theDiscreteEnergies;
207  std::map<G4double,G4int> theDiscreteEnergiesOwn;
208 
209 };
210 #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)