Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
50  G4bool fresh;
51  G4double currentMeanEnergy;
52  G4double remaining_energy;
53  G4double theTargetCode;
55  G4ReactionProduct* thePrimary;
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);
67  theMinEner = DBL_MAX;
68  theMaxEner = -DBL_MAX;
69  theEnergy = -1;
70  nEnergies = -1;
71  nDiscreteEnergies = -1;
72  nAngularParameters = -1;
73  theProjectile = NULL;
74  adjustResult = true;
75  }
76 
78 
80  {
81  if(theAngular!=0) delete [] theAngular;
82  }
83 
84  void Init(std::istream & aDataFile, G4ParticleDefinition* projectile);
85 
86  G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass,
87  G4int angularRep, G4int interpol);
88 
90  if( getenv("G4PHPTEST") ) G4cout << this << " G4ParticleHPContAngularPar::GetEnergy " << theEnergy << " nE " << nEnergies << G4endl;
91  return theEnergy; }
92 
93  void SetPrimary(G4ReactionProduct * aPrimary)
94  {
95  fCache.Get()->thePrimary = aPrimary;
96  }
97 
98  void SetTarget(G4ReactionProduct * aTarget)
99  {
100  fCache.Get()->theTarget = aTarget;
101  }
102 
103  void SetTargetCode(G4double aTargetCode) { fCache.Get()->theTargetCode = aTargetCode; }
104 
105  void SetInterpolation(G4int theInterpolation)
106  {
107  theManager.Init(theInterpolation, nEnergies); // one range only
108  }
109 
110  void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
111  G4ParticleHPContAngularPar & store1,
112  G4ParticleHPContAngularPar & store2); // hmmmm, this interpolates legendre coefficients. Dangerous @@@
113 
114  void PrepareTableInterpolation(const G4ParticleHPContAngularPar* angularPrev);
115 
117  {
119  if(fCache.Get()->currentMeanEnergy<-1)
120  {
121  return 0;
122  // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
123  }
124  else
125  {
126  result = fCache.Get()->currentMeanEnergy;
127  }
128  fCache.Get()->currentMeanEnergy = -2;
129  return result;
130  }
131 
133  {
134  return nEnergies;
135  }
137  {
138  return nDiscreteEnergies;
139  }
140  std::set<G4double> GetEnergiesTransformed() const
141  {
142  return theEnergiesTransformed;
143  }
145  {
146  return theEnergiesTransformed.size();
147  }
149  {
150  return theMinEner;
151  }
153  {
154  return theMaxEner;
155  }
156  std::map<G4double,G4int> GetDiscreteEnergiesOwn() const
157  {
158  return theDiscreteEnergiesOwn;
159  }
161  return theAngular;
162  }
163 
164 private:
165 
166  // incoming particle
167  G4double theEnergy;
168 
169  // number of exit channel energies
170  G4int nEnergies;
171  // number of discrete exit channels
172  G4int nDiscreteEnergies;
173  // number of angular paramerers per channel
174  G4int nAngularParameters;
175  // knows the interpolation between List labels
176  G4InterpolationManager theManager;
177  // on per exit-channel energy
178  G4ParticleHPList * theAngular;
179 
181 
182  //G4double theTargetCode;
183  //G4ReactionProduct * theTarget;
184  //G4ReactionProduct * thePrimary;
185 
186  //G4double currentMeanEnergy;
187 
188 //080718
189  public:
190  //void ClearHistories(){ fresh = true; };
191  void ClearHistories(){
192  if ( fCache.Get() == NULL ) cacheInit();
193  fCache.Get()->fresh = true; };
194 
195  void Dump();
196  private:
197  G4Cache< toBeCached* > fCache;
198  void cacheInit() {
199  toBeCached* val = new toBeCached;
200  val->currentMeanEnergy = -2;
201  val->remaining_energy = 0;
202  val->fresh=true;
203  fCache.Put( val );
204  };
205  /*G4bool fresh;*/
206  /*G4double remaining_energy;*/ // represent energy rest of cascade chain
207 
208  G4ParticleDefinition* theProjectile;
209 
210  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
211 
212  G4double theMinEner;
213  G4double theMaxEner;
214  std::set<G4double> theEnergiesTransformed;
215  std::set<G4double> theDiscreteEnergies;
216  std::map<G4double,G4int> theDiscreteEnergiesOwn;
217 
218 };
219 #endif
G4double G4ParticleHPJENDLHEData::G4double result
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)
value_type & Get() const
Definition: G4Cache.hh:282
void SetInterpolation(G4int theInterpolation)
int G4int
Definition: G4Types.hh:78
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
G4ErrorTarget * theTarget
Definition: errprop.cc:59
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)