Geant4 10.7.0
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
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
104 {
105 fCache.Get()->thePrimary = aPrimary;
106 }
107
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
126 // NOTE: this interpolates legendre coefficients
127
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
187private:
188
189 // incoming particle
190 G4double theEnergy;
191 // number of exit channel energies
192 G4int nEnergies;
193 // number of discrete exit channels
194 G4int nDiscreteEnergies;
195 // number of angular paramerers per channel
196 G4int nAngularParameters;
197 // knows the interpolation between List labels
198 G4InterpolationManager theManager;
199 // on per exit-channel energy
200 G4ParticleHPList * theAngular;
201
203
204private:
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
216 G4ParticleDefinition* theProjectile;
217
218 G4bool adjustResult;
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
222 G4double theMinEner;
223 G4double theMaxEner;
224 std::set<G4double> theEnergiesTransformed;
225 std::set<G4double> theDiscreteEnergies;
226 std::map<G4double,G4int> theDiscreteEnergiesOwn;
227};
228
229#endif
G4InterpolationScheme
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
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 PrepareTableInterpolation(const G4ParticleHPContAngularPar *angularPrev)
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)
std::set< G4double > GetEnergiesTransformed() const
void SetTargetCode(G4double aTargetCode)
void BuildByInterpolation(G4double anEnergy, G4InterpolationScheme aScheme, G4ParticleHPContAngularPar &store1, G4ParticleHPContAngularPar &store2)
#define DBL_MAX
Definition: templates.hh:62