ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleHPContAngularPar.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ParticleHPContAngularPar.hh
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 <fstream>
36 #include <set>
37 
38 #include "G4ios.hh"
39 #include "globals.hh"
40 #include "G4ParticleHPList.hh"
41 #include "G4ReactionProduct.hh"
44 #include "G4Cache.hh"
45 
47 
49 {
50 
51  struct toBeCached
52  {
61  theTargetCode(-1.0),theTarget(0),thePrimary(0) {}
62  };
63 
64  public:
65 
67  {
68  theAngular = 0;
69  //currentMeanEnergy = -2;
70  //fresh = true;
71  fCache.Put(0);
74  theEnergy = -1;
75  nEnergies = -1;
76  nDiscreteEnergies = -1;
77  nAngularParameters = -1;
78  theProjectile = 0;
79  adjustResult = true;
80  }
81 
83 
85  {
86  if (theAngular !=0 ) delete [] theAngular;
87  if (fCache.Get() != 0) delete fCache.Get();
88  }
89 
90  void Init(std::istream & aDataFile, G4ParticleDefinition* projectile);
91 
92  G4ReactionProduct* Sample(G4double anEnergy, G4double massCode, G4double mass,
93  G4int angularRep, G4int interpol);
94 
96  {
97  if( std::getenv("G4PHPTEST") )
98  G4cout << this << " G4ParticleHPContAngularPar::GetEnergy "
99  << theEnergy << " nE " << nEnergies << G4endl;
100  return theEnergy;
101  }
102 
103  void SetPrimary(G4ReactionProduct * aPrimary)
104  {
105  fCache.Get()->thePrimary = aPrimary;
106  }
107 
108  void SetTarget(G4ReactionProduct * aTarget)
109  {
110  fCache.Get()->theTarget = aTarget;
111  }
112 
113  void SetTargetCode(G4double aTargetCode)
114  {
115  fCache.Get()->theTargetCode = aTargetCode;
116  }
117 
118  void SetInterpolation(G4int theInterpolation)
119  {
120  theManager.Init(theInterpolation, nEnergies); // one range only
121  }
122 
123  void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme,
124  G4ParticleHPContAngularPar & store1,
125  G4ParticleHPContAngularPar & store2);
126  // NOTE: this interpolates legendre coefficients
127 
128  void PrepareTableInterpolation(const G4ParticleHPContAngularPar* angularPrev);
129 
131  {
132  G4double result;
133  if(fCache.Get()->currentMeanEnergy<-1)
134  {
135  return 0;
136  // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
137  }
138  else
139  {
140  result = fCache.Get()->currentMeanEnergy;
141  }
142  fCache.Get()->currentMeanEnergy = -2;
143  return result;
144  }
145 
147  {
148  return nEnergies;
149  }
151  {
152  return nDiscreteEnergies;
153  }
154  std::set<G4double> GetEnergiesTransformed() const
155  {
156  return theEnergiesTransformed;
157  }
159  {
160  return theEnergiesTransformed.size();
161  }
163  {
164  return theMinEner;
165  }
167  {
168  return theMaxEner;
169  }
170  std::map<G4double,G4int> GetDiscreteEnergiesOwn() const
171  {
172  return theDiscreteEnergiesOwn;
173  }
175  {
176  return theAngular;
177  }
178 
180  {
181  if ( fCache.Get() == 0 ) cacheInit();
182  fCache.Get()->fresh = true;
183  }
184 
185  void Dump();
186 
187 private:
188 
189  // incoming particle
191  // number of exit channel energies
193  // number of discrete exit channels
195  // number of angular paramerers per channel
197  // knows the interpolation between List labels
199  // on per exit-channel energy
201 
203 
204 private:
205 
207  void cacheInit()
208  {
209  toBeCached* val = new toBeCached;
210  val->currentMeanEnergy = -2;
211  val->remaining_energy = 0;
212  val->fresh=true;
213  fCache.Put( val );
214  };
215 
217 
219  // if not set it will not force the conservation of energy in angularRep==1,
220  // but will sample the particle energy according to the database
221 
224  std::set<G4double> theEnergiesTransformed;
225  std::set<G4double> theDiscreteEnergies;
226  std::map<G4double,G4int> theDiscreteEnergiesOwn;
227 };
228 
229 #endif