Geant4  10.01.p02
G4NeutronHPContAngularPar.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 #ifndef G4NeutronHPContAngularPar_h
31 #define G4NeutronHPContAngularPar_h 1
32 
33 #include "G4ios.hh"
34 #include <fstream>
35 #include "globals.hh"
36 #include "G4NeutronHPList.hh"
37 #include "G4ReactionProduct.hh"
40 
41 #include "G4Cache.hh"
42 
44 {
45 
46  struct toBeCached {
50  toBeCached():fresh(true),currentMeanEnergy(-2),remaining_energy(0){};
51  };
52 
53  public:
54 
56  {
57  theAngular = 0;
58  fCache.Put(NULL);
59  //currentMeanEnergy = -2;
60  //fresh = true;
61  }
63  {
64  if(theAngular!=0) delete [] theAngular;
65  }
66 
67  void Init(std::istream & aDataFile);
68 
69  G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass,
70  G4int angularRep, G4int interpol);
71 
73 
74  void SetPrimary(G4ReactionProduct * aPrimary)
75  {
76  thePrimary = aPrimary;
77  }
78 
79  void SetTarget(G4ReactionProduct * aTarget)
80  {
81  theTarget = aTarget;
82  }
83 
84  void SetTargetCode(G4double aTargetCode) { theTargetCode = aTargetCode; }
85 
86  void SetInterpolation(G4int theInterpolation)
87  {
88  theManager.Init(theInterpolation, nEnergies); // one range only
89  }
90 
91  void Merge(G4double anEnergy, G4InterpolationScheme & aScheme,
92  G4NeutronHPContAngularPar & store1,
93  G4NeutronHPContAngularPar & store2) // hmmmm, this interpolates legendre coefficients. Dangerous @@@
94  {
97  nEnergies = store1.nEnergies;
98  theManager = store1.theManager;
99  theEnergy = anEnergy;
100  if(theAngular != 0) delete [] theAngular;
102  G4int i, ii;
103  G4double value;
104  for(i=0; i<nEnergies; i++)
105  {
106  theAngular[i].SetLabel(store1.theAngular[i].GetLabel());
107  for(ii=0; ii<nAngularParameters; ii++)
108  {
109 // G4cout <<"test "<<i<<" "<<store1.theEnergy<<" "<<store2.theEnergy<<" "
110 // << store1.theAngular[i].GetValue(ii)<<" "<<
111 // store2.theAngular[i].GetValue(ii)<<G4endl;
112  value = theInt.Interpolate(aScheme, anEnergy,
113  store1.theEnergy, store2.theEnergy,
114  store1.theAngular[i].GetValue(ii),
115  store2.theAngular[i].GetValue(ii));
116  theAngular[i].SetValue(ii, value);
117  }
118  }
119  };
120 
122  {
123  G4double result;
124  if( fCache.Get()->currentMeanEnergy<-1)
125  {
126  return 0;
127  // throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPContAngularPar: Logical error in Product class");
128  }
129  else
130  {
131  result = fCache.Get()->currentMeanEnergy;
132  }
133  fCache.Get()->currentMeanEnergy = -2;
134  return result;
135  }
136 
137  private:
138 
139  // incoming particle
141 
142  // number of exit channel energies
144  // number of discrete exit channels
146  // number of angular paramerers per channel
148  // knows the interpolation between List labels
150  // on per exit-channel energy
152 
153  private:
154 
156 
160 
161  //G4double currentMeanEnergy;
162 
163 //080718
164  private:
165  //G4bool fresh;
166  //G4double remaining_energy; // represent energy rest of cascade chain
167 
168  private:
170  void cacheInit() {
171  toBeCached* val = new toBeCached;
172  val->currentMeanEnergy = -2;
173  val->remaining_energy = 0;
174  val->fresh=true;
175  fCache.Put( val );
176  };
177  public:
178  void ClearHistories(){
179  if ( fCache.Get() == NULL ) cacheInit();
180  fCache.Get()->fresh = true; };
181 };
182 #endif
void SetValue(G4int i, G4double y)
void SetInterpolation(G4int theInterpolation)
G4double GetLabel()
void SetLabel(G4double aLabel)
void Init(G4int aScheme, G4int aRange)
value_type & Get() const
Definition: G4Cache.hh:282
void SetTarget(G4ReactionProduct *aTarget)
int G4int
Definition: G4Types.hh:78
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
bool G4bool
Definition: G4Types.hh:79
void SetPrimary(G4ReactionProduct *aPrimary)
void SetTargetCode(G4double aTargetCode)
G4InterpolationScheme
void Init(std::istream &aDataFile)
G4double GetValue(G4int i)
double G4double
Definition: G4Types.hh:76
void Put(const value_type &val) const
Definition: G4Cache.hh:286
void Merge(G4double anEnergy, G4InterpolationScheme &aScheme, G4NeutronHPContAngularPar &store1, G4NeutronHPContAngularPar &store2)