Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 <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 {
53 G4bool fresh;
54 G4double currentMeanEnergy;
55 G4double remaining_energy;
56 G4double theTargetCode;
57 G4ReactionProduct* theTarget;
58 G4ReactionProduct* thePrimary;
59 toBeCached()
60 : fresh(true),currentMeanEnergy(-2.0),remaining_energy(0.0),
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);
72 theMinEner = DBL_MAX;
73 theMaxEner = -DBL_MAX;
74 theEnergy = -1;
75 nEnergies = -1;
76 nDiscreteEnergies = -1;
77 nAngularParameters = -1;
78 theProjectile = 0;
79 adjustResult = true;
80 }
81
83 {
84 theEnergy = val.theEnergy;
85 nEnergies = val.nEnergies;
86 nDiscreteEnergies = val.nDiscreteEnergies;
87 nAngularParameters= val.nAngularParameters;
88 theProjectile = val.theProjectile;
89 theManager = val.theManager;
90 theInt = val.theInt;
91 adjustResult = val.adjustResult;
92 theMinEner = val.theMinEner;
93 theMaxEner = val.theMaxEner;
94 theEnergiesTransformed = val.theEnergiesTransformed;
95 theDiscreteEnergies = val.theDiscreteEnergies;
96 theDiscreteEnergiesOwn = val.theDiscreteEnergiesOwn;
97 fCache.Put(0);
98 theAngular = new G4ParticleHPList[nEnergies];
99 for(G4int ie=0;ie<nEnergies;++ie) {
100 theAngular[ie].SetLabel(val.theAngular[ie].GetLabel());
101 for(G4int ip=0;ip<nAngularParameters;++ip) {
102 theAngular[ie].SetValue(ip,val.theAngular[ie].GetValue(ip));
103 }
104 }
105 }
106
108
110 {
111 if (theAngular !=0 ) delete [] theAngular;
112 if (fCache.Get() != 0) delete fCache.Get();
113 }
114
115 void Init(std::istream & aDataFile, G4ParticleDefinition* projectile);
116
117 G4ReactionProduct* Sample(G4double anEnergy, G4double massCode, G4double mass,
118 G4int angularRep, G4int interpol);
119
121 {
122 return theEnergy;
123 }
124
126 {
127 fCache.Get()->thePrimary = aPrimary;
128 }
129
131 {
132 fCache.Get()->theTarget = aTarget;
133 }
134
135 void SetTargetCode(G4double aTargetCode)
136 {
137 fCache.Get()->theTargetCode = aTargetCode;
138 }
139
140 void SetInterpolation(G4int theInterpolation)
141 {
142 theManager.Init(theInterpolation, nEnergies); // one range only
143 }
144
148 // NOTE: this interpolates legendre coefficients
149
151
153 {
154 G4double result;
155 if(fCache.Get()->currentMeanEnergy<-1)
156 {
157 return 0;
158 // throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPContAngularPar: Logical error in Product class");
159 }
160 else
161 {
162 result = fCache.Get()->currentMeanEnergy;
163 }
164 fCache.Get()->currentMeanEnergy = -2;
165 return result;
166 }
167
169 {
170 return nEnergies;
171 }
173 {
174 return nDiscreteEnergies;
175 }
176 std::set<G4double> GetEnergiesTransformed() const
177 {
178 return theEnergiesTransformed;
179 }
181 {
182 return (G4int)theEnergiesTransformed.size();
183 }
185 {
186 return theMinEner;
187 }
189 {
190 return theMaxEner;
191 }
192 std::map<G4double,G4int> GetDiscreteEnergiesOwn() const
193 {
194 return theDiscreteEnergiesOwn;
195 }
197 {
198 return theAngular;
199 }
200
202 {
203 if ( fCache.Get() == 0 ) cacheInit();
204 fCache.Get()->fresh = true;
205 }
206
207 void Dump() const;
208
209private:
210
211 // incoming particle
212 G4double theEnergy;
213 // number of exit channel energies
214 G4int nEnergies;
215 // number of discrete exit channels
216 G4int nDiscreteEnergies;
217 // number of angular paramerers per channel
218 G4int nAngularParameters;
219 // knows the interpolation between List labels
220 G4InterpolationManager theManager;
221 // on per exit-channel energy
222 G4ParticleHPList * theAngular;
223
225
226private:
227
229 void cacheInit()
230 {
231 toBeCached* val = new toBeCached;
232 val->currentMeanEnergy = -2;
233 val->remaining_energy = 0;
234 val->fresh=true;
235 fCache.Put( val );
236 };
237
238 G4ParticleDefinition* theProjectile;
239
240 G4bool adjustResult;
241 // if not set it will not force the conservation of energy in angularRep==1,
242 // but will sample the particle energy according to the database
243
244 G4double theMinEner;
245 G4double theMaxEner;
246 std::set<G4double> theEnergiesTransformed;
247 std::set<G4double> theDiscreteEnergies;
248 std::map<G4double,G4int> theDiscreteEnergiesOwn;
249};
250
251#endif
G4InterpolationScheme
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
value_type & Get() const
Definition: G4Cache.hh:315
void Put(const value_type &val) const
Definition: G4Cache.hh:321
void Init(G4int aScheme, G4int aRange)
G4ReactionProduct * Sample(G4double anEnergy, G4double massCode, G4double mass, G4int angularRep, G4int interpol)
G4ParticleHPList * GetAngDataList() const
void Init(std::istream &aDataFile, G4ParticleDefinition *projectile)
std::map< G4double, G4int > GetDiscreteEnergiesOwn() const
void SetPrimary(G4ReactionProduct *aPrimary)
void SetTarget(G4ReactionProduct *aTarget)
void SetInterpolation(G4int theInterpolation)
G4ParticleHPContAngularPar(G4ParticleHPContAngularPar &val)
std::set< G4double > GetEnergiesTransformed() const
void SetTargetCode(G4double aTargetCode)
void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme, G4ParticleHPContAngularPar &store1, G4ParticleHPContAngularPar &store2)
void SetLabel(G4double aLabel)
void SetValue(G4int i, G4double y)
G4double GetValue(G4int i)
#define DBL_MAX
Definition: templates.hh:62