Geant4  10.02.p03
G4BremsstrahlungParameters Class Reference

#include <G4BremsstrahlungParameters.hh>

Collaboration diagram for G4BremsstrahlungParameters:

Public Member Functions

 G4BremsstrahlungParameters (const G4String &name, size_t num, G4int minZ=1, G4int maxZ=99)
 
 ~G4BremsstrahlungParameters ()
 
G4double Parameter (G4int parameterIndex, G4int Z, G4double energy) const
 
G4double ParameterC (G4int index) const
 
void PrintData () const
 

Private Member Functions

 G4BremsstrahlungParameters (const G4BremsstrahlungParameters &)
 
G4BremsstrahlungParametersoperator= (const G4BremsstrahlungParameters &right)
 
void LoadData (const G4String &name)
 

Private Attributes

std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
 
G4DataVector paramC
 
G4DataVector activeZ
 
G4int zMin
 
G4int zMax
 
size_t length
 

Detailed Description

Definition at line 62 of file G4BremsstrahlungParameters.hh.

Constructor & Destructor Documentation

◆ G4BremsstrahlungParameters() [1/2]

G4BremsstrahlungParameters::G4BremsstrahlungParameters ( const G4String name,
size_t  num,
G4int  minZ = 1,
G4int  maxZ = 99 
)

Definition at line 54 of file G4BremsstrahlungParameters.cc.

Here is the call graph for this function:

◆ ~G4BremsstrahlungParameters()

G4BremsstrahlungParameters::~G4BremsstrahlungParameters ( )

Definition at line 64 of file G4BremsstrahlungParameters.cc.

65 {
66  // Reset the map of data sets: remove the data sets from the map
67  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::iterator pos;
68 
69  for (pos = param.begin(); pos != param.end(); ++pos)
70  {
71  G4VEMDataSet* dataSet = (*pos).second;
72  delete dataSet;
73  }
74 
75  activeZ.clear();
76  paramC.clear();
77 }
static const G4double pos
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param

◆ G4BremsstrahlungParameters() [2/2]

G4BremsstrahlungParameters::G4BremsstrahlungParameters ( const G4BremsstrahlungParameters )
private

Member Function Documentation

◆ LoadData()

void G4BremsstrahlungParameters::LoadData ( const G4String name)
private

Definition at line 105 of file G4BremsstrahlungParameters.cc.

106 {
107  const G4double mConst =
109 
110  // Build the complete string identifying the file with the data set
111  // define active elements
112 
113  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
114  if (materialTable == 0)
115  G4Exception("G4BremsstrahlungParameters::LoadData",
116  "em1001",FatalException,"Unable to find MaterialTable");
117 
119 
120  G4double x = 1.e-9;
121  for (G4int mmLocal=0; mmLocal<100; mmLocal++) {
122  paramC.push_back(x);
123  }
124 
125  for (G4int mLocal=0; mLocal<nMaterials; mLocal++) {
126 
127  const G4Material* material= (*materialTable)[mLocal];
128  const G4ElementVector* elementVector = material->GetElementVector();
129  const G4int nElements = material->GetNumberOfElements();
130 
131  for (G4int iEl=0; iEl<nElements; iEl++) {
132  G4Element* element = (*elementVector)[iEl];
133  G4double Z = element->GetZ();
134  G4int iz = (G4int)Z;
135  if(iz < 100) {
136  paramC[iz] = mConst*material->GetTotNbOfElectPerVolume();
137  //paramC[iz] = 0.217635e-33*(material->GetTotNbOfElectPerVolume());
138  }
139  if (!(activeZ.contains(Z))) {
140  activeZ.push_back(Z);
141  }
142  }
143  }
144 
145  // Read parameters
146 
147  char* path = getenv("G4LEDATA");
148  if (path == 0)
149  {
150  G4Exception("G4BremsstrahlungParameters::LoadData",
151  "em0006",FatalException,"G4LEDATA environment variable not set");
152  return;
153  }
154 
155  G4String pathString_a(path);
156  G4String name_a = pathString_a + name;
157  std::ifstream file_a(name_a);
158  std::filebuf* lsdp_a = file_a.rdbuf();
159 
160  if (! (lsdp_a->is_open()) )
161  {
162  G4String stringConversion2("G4BremsstrahlungParameters::LoadData");
163  G4String excep = stringConversion2 + name_a;
164  G4Exception("G4BremsstrahlungParameters::LoadData",
165  "em0003",FatalException,excep);
166  }
167 
168  // The file is organized into two columns:
169  // 1st column is the energy
170  // 2nd column is the corresponding value
171  // The file terminates with the pattern: -1 -1
172  // -2 -2
173 
174  G4double ener = 0.0;
175  G4double sum = 0.0;
176  G4int z = 0;
177 
178  std::vector<G4DataVector*> a;
179  a.resize(length);
180 
181  G4DataVector e;
182  e.clear();
183 
184  G4bool isReady = false;
185 
186  do {
187  file_a >> ener >> sum;
188 
189  // End of file
190  if (ener == (G4double)(-2)) {
191  break;
192 
193  // End of next element
194  } else if (ener == (G4double)(-1)) {
195 
196  ++z;
197  G4double Z = (G4double)z;
198 
199  // fill map if Z is used
200  if (activeZ.contains(Z)) {
201 
202  for (size_t k=0; k<length; ++k) {
203 
204  G4int id = z*length + k;
206  G4DataVector* eVector = new G4DataVector;
207  size_t eSize = e.size();
208  for (size_t sLocal=0; sLocal<eSize; sLocal++) {
209  eVector->push_back(e[sLocal]);
210  }
211  G4VEMDataSet* set = new G4EMDataSet(id,eVector,a[k],inter,1.,1.);
212  param[id] = set;
213  }
214  } else {
215  for (size_t j=0; j<length; j++) {
216  delete a[j];
217  }
218  }
219  isReady = false;
220 
221  } else {
222 
223  if(!isReady) {
224  isReady = true;
225  e.clear();
226  for (size_t j=0; j<length; ++j) {
227  a[j] = new G4DataVector();
228  }
229  }
230 
231  if(ener > 1000.) ener = 1000.;
232  e.push_back(ener);
233  a[length-1]->push_back(sum);
234 
235  for (size_t j=0; j<length-1; j++) {
236  G4double qRead;
237  file_a >> qRead;
238  a[j]->push_back(qRead);
239  }
240 
241  }
242  } while (ener != (G4double)(-2));
243 
244  file_a.close();
245 
246 }
std::vector< G4Element * > G4ElementVector
G4String name
Definition: TRTMaterials.hh:40
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
std::vector< G4Material * > G4MaterialTable
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
float electron_Compton_length
Definition: hepunit.py:289
Float_t Z
bool G4bool
Definition: G4Types.hh:79
G4double iz
Definition: TRTMaterials.hh:39
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:596
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
int classic_electr_radius
Definition: hepunit.py:288
static const double pi
Definition: G4SIunits.hh:74
G4bool contains(const G4double &) const
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
G4double GetTotNbOfElectPerVolume() const
Definition: G4Material.hh:212
G4double GetZ() const
Definition: G4Element.hh:131
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

G4BremsstrahlungParameters& G4BremsstrahlungParameters::operator= ( const G4BremsstrahlungParameters right)
private

◆ Parameter()

G4double G4BremsstrahlungParameters::Parameter ( G4int  parameterIndex,
G4int  Z,
G4double  energy 
) const

Definition at line 80 of file G4BremsstrahlungParameters.cc.

83 {
84  G4double value = 0.;
85  G4int id = Z*length + parameterIndex;
86  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
87 
88  pos = param.find(id);
89  if (pos!= param.end()) {
90 
91  G4VEMDataSet* dataSet = (*pos).second;
92  const G4DataVector ener = dataSet->GetEnergies(0);
93  G4double ee = std::max(ener.front(),std::min(ener.back(),energy));
94  value = dataSet->FindValue(ee);
95 
96  } else {
97  G4cout << "WARNING: G4BremsstrahlungParameters::FindValue "
98  << "did not find ID = "
99  << id << G4endl;
100  }
101 
102  return value;
103 }
virtual const G4DataVector & GetEnergies(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
double energy
Definition: plottest35.C:25
Float_t Z
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const G4double pos
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParameterC()

G4double G4BremsstrahlungParameters::ParameterC ( G4int  index) const

Definition at line 249 of file G4BremsstrahlungParameters.cc.

250 {
251  G4int n = paramC.size();
252  if (id < 0 || id >= n)
253  {
254  G4String stringConversion2(id);
255  G4String ex = "Wrong id " + stringConversion2;
256  G4Exception("G4BremsstrahlungParameters::ParameterC",
257  "em1002",FatalException,ex);
258 
259  }
260 
261  return paramC[id];
262 }
int G4int
Definition: G4Types.hh:78
Char_t n[5]
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintData()

void G4BremsstrahlungParameters::PrintData ( void  ) const

Definition at line 265 of file G4BremsstrahlungParameters.cc.

266 {
267 
268  G4cout << G4endl;
269  G4cout << "===== G4BremsstrahlungParameters =====" << G4endl;
270  G4cout << G4endl;
271  G4cout << "===== Parameters =====" << G4endl;
272  G4cout << G4endl;
273 
274  size_t nZ = activeZ.size();
275  std::map<G4int,G4VEMDataSet*,std::less<G4int> >::const_iterator pos;
276 
277  for (size_t j=0; j<nZ; j++) {
278  G4int Z = (G4int)activeZ[j];
279 
280  for (size_t i=0; i<length; i++) {
281 
282  pos = param.find(Z*length + i);
283  if (pos!= param.end()) {
284 
285  G4cout << "===== Z= " << Z
286  << " parameter[" << i << "] ====="
287  << G4endl;
288  G4VEMDataSet* dataSet = (*pos).second;
289  dataSet->PrintData();
290  }
291  }
292  }
293 
294  G4cout << "==========================================" << G4endl;
295 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
Float_t Z
virtual void PrintData(void) const =0
#define G4endl
Definition: G4ios.hh:61
static const G4double pos
std::map< G4int, G4VEMDataSet *, std::less< G4int > > param
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ activeZ

G4DataVector G4BremsstrahlungParameters::activeZ
private

Definition at line 87 of file G4BremsstrahlungParameters.hh.

◆ length

size_t G4BremsstrahlungParameters::length
private

Definition at line 92 of file G4BremsstrahlungParameters.hh.

◆ param

std::map<G4int,G4VEMDataSet*,std::less<G4int> > G4BremsstrahlungParameters::param
private

Definition at line 84 of file G4BremsstrahlungParameters.hh.

◆ paramC

G4DataVector G4BremsstrahlungParameters::paramC
private

Definition at line 86 of file G4BremsstrahlungParameters.hh.

◆ zMax

G4int G4BremsstrahlungParameters::zMax
private

Definition at line 90 of file G4BremsstrahlungParameters.hh.

◆ zMin

G4int G4BremsstrahlungParameters::zMin
private

Definition at line 89 of file G4BremsstrahlungParameters.hh.


The documentation for this class was generated from the following files: