Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions
XrayFluoHPGeDetectorType Class Reference

#include <XrayFluoHPGeDetectorType.hh>

Inheritance diagram for XrayFluoHPGeDetectorType:
XrayFluoVDetectorType

Public Member Functions

 ~XrayFluoHPGeDetectorType ()
 
G4String GetDetectorMaterial ()
 
G4double ResponseFunction (G4double)
 
G4double GetInfData (G4double, G4double, G4int)
 
G4double GetSupData (G4double, G4double, G4int)
 
void LoadResponseData (G4String)
 
void LoadEfficiencyData (G4String)
 
- Public Member Functions inherited from XrayFluoVDetectorType
virtual ~XrayFluoVDetectorType ()
 

Static Public Member Functions

static XrayFluoHPGeDetectorTypeGetInstance ()
 

Additional Inherited Members

- Protected Member Functions inherited from XrayFluoVDetectorType
 XrayFluoVDetectorType ()
 

Detailed Description

Definition at line 50 of file XrayFluoHPGeDetectorType.hh.

Constructor & Destructor Documentation

XrayFluoHPGeDetectorType::~XrayFluoHPGeDetectorType ( )

Definition at line 60 of file XrayFluoHPGeDetectorType.cc.

61 {
62  std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
63 
64  for (pos = energyMap.begin(); pos != energyMap.end(); pos++)
65  {
66  G4DataVector* dataSet = (*pos).second;
67  delete dataSet;
68  dataSet = 0;
69  }
70  for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
71  {
72  G4DataVector* dataSet = (*pos).second;
73  delete dataSet;
74  dataSet = 0;
75  }
76 
77  delete interpolation4;
78 
79 }

Member Function Documentation

G4String XrayFluoHPGeDetectorType::GetDetectorMaterial ( )
virtual

Implements XrayFluoVDetectorType.

Definition at line 80 of file XrayFluoHPGeDetectorType.cc.

81 {
82  return detectorMaterial;
83 }
G4double XrayFluoHPGeDetectorType::GetInfData ( G4double  energy,
G4double  random,
G4int   
)
virtual

Implements XrayFluoVDetectorType.

Definition at line 165 of file XrayFluoHPGeDetectorType.cc.

References python.hepunit::keV.

Referenced by ResponseFunction().

166 {
167  G4double value = 0.;
168  G4int zMin = 1;
169  G4int zMax = 10;
170 
171  G4int Z = ((G4int)(energy/keV));
172 
173  if (Z<zMin) {Z=zMin;}
174  if (Z>zMax) {Z=zMax;}
175 
176  if (Z >= zMin && Z <= zMax)
177  {
178  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
179  pos = energyMap.find(Z);
180  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
181  posData = dataMap.find(Z);
182  if (pos!= energyMap.end())
183  {
184  G4DataVector energySet = *((*pos).second);
185  G4DataVector dataSet = *((*posData).second);
186  G4int nData = energySet.size();
187 
188  G4double partSum = 0;
189  G4int index = 0;
190 
191  while (random> partSum)
192  {
193  partSum += dataSet[index];
194  index++;
195  }
196 
197 
198  if (index >= 0 && index < nData)
199  {
200  value = energySet[index];
201 
202  }
203 
204  }
205  }
206  return value;
207 
208 }
int G4int
Definition: G4Types.hh:78
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
XrayFluoHPGeDetectorType * XrayFluoHPGeDetectorType::GetInstance ( void  )
static
G4double XrayFluoHPGeDetectorType::GetSupData ( G4double  energy,
G4double  random,
G4int   
)
virtual

Implements XrayFluoVDetectorType.

Definition at line 209 of file XrayFluoHPGeDetectorType.cc.

References python.hepunit::keV.

Referenced by ResponseFunction().

210 {
211  G4double value = 0.;
212  G4int zMin = 1;
213  G4int zMax = 10;
214  G4int Z = ((G4int)(energy/keV)+1);
215 
216  if (Z<zMin) {Z=zMin;}
217  if (Z>zMax) {Z=zMax;}
218  if (Z >= zMin && Z <= zMax)
219  {
220  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
221  pos = energyMap.find(Z);
222  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator posData;
223  posData = dataMap.find(Z);
224  if (pos!= energyMap.end())
225  {
226  G4DataVector energySet = *((*pos).second);
227  G4DataVector dataSet = *((*posData).second);
228  G4int nData = energySet.size();
229  G4double partSum = 0;
230  G4int index = 0;
231 
232  while (random> partSum)
233  {
234  partSum += dataSet[index];
235  index++;
236  }
237 
238 
239  if (index >= 0 && index < nData)
240  {
241  value = energySet[index];
242  }
243  }
244  }
245  return value;
246 
247 }
int G4int
Definition: G4Types.hh:78
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
void XrayFluoHPGeDetectorType::LoadEfficiencyData ( G4String  fileName)
virtual

Implements XrayFluoVDetectorType.

Definition at line 329 of file XrayFluoHPGeDetectorType.cc.

References python.hepunit::keV.

330 {
331  /*
332  char* path = getenv("XRAYDATA");
333  G4String dirFile;
334  if (path) {
335  G4String pathString(path);
336  dirFile = pathString + "/" + fileName;
337  }
338  else{
339  path = getenv("PWD");
340  G4String pathString(path);
341  dirFile = pathString + "/" + fileName;
342  }
343  */
344  interpolation4 = new G4LogLogInterpolation();
345  efficiencySet = new XrayFluoDataSet(1,fileName,interpolation4,keV,1);
346 }
void XrayFluoHPGeDetectorType::LoadResponseData ( G4String  fileName)
virtual

Implements XrayFluoVDetectorType.

Definition at line 248 of file XrayFluoHPGeDetectorType.cc.

References test::a, FatalException, G4Exception(), and python.hepunit::keV.

249 {
250  std::ostringstream ost;
251 
252  ost << fileName<<".dat";
253 
254  G4String name = ost.str();
255 
256  char* path = getenv("XRAYDATA");
257 
258  G4String pathString(path);
259  G4String dirFile = pathString + "/" + name;
260  std::ifstream file(dirFile);
261  std::filebuf* lsdp = file.rdbuf();
262 
263  if (! (lsdp->is_open()) )
264  {
266  execp << "XrayFluoHPGeDetectorType - data file: " + dirFile + " not found";
267  G4Exception("XrayFluoHPGeDetectorType::LoadResponseData()","example-xray_fluorescence02",
268  FatalException, execp);
269  }
270  G4double a = 0;
271  G4int k = 1;
272  G4int q = 0;
273 
274  G4int Z = 1;
275  G4DataVector* energies = new G4DataVector;
277 
278  do
279  {
280  file >> a;
281  G4int nColumns = 2;
282  if (a == -1)
283  {
284  if (q == 0)
285  {
286  // End of a data set
287  energyMap[Z] = energies;
288  dataMap[Z] = data;
289  // Start of new shell data set
290  energies = new G4DataVector;
291  data = new G4DataVector;
292  Z++;
293  }
294  q++;
295  if (q == nColumns)
296  {
297  q = 0;
298  }
299  }
300  else if (a == -2)
301  {
302  // End of file; delete the empty vectors
303  //created when encountering the last -1 -1 row
304  delete energies;
305  delete data;
306 
307  }
308  else
309  {
310  // 1st column is energy
311  if(k%nColumns != 0)
312  {
313  G4double e = a * keV;
314  energies->push_back(e);
315  k++;
316  }
317  else if (k%nColumns == 0)
318  {
319  // 2nd column is data
320 
321  data->push_back(a);
322  k = 1;
323  }
324  }
325  } while (a != -2); // end of file
326  file.close();
327 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const XML_Char * name
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
const XML_Char const XML_Char * data
G4double XrayFluoHPGeDetectorType::ResponseFunction ( G4double  energy)
virtual

Implements XrayFluoVDetectorType.

Definition at line 98 of file XrayFluoHPGeDetectorType.cc.

References energy(), XrayFluoDataSet::FindValue(), G4UniformRand, GetInfData(), GetSupData(), and python.hepunit::keV.

99 {
100 
101 
102  G4double eMin = 1* keV;
103  G4double eMax = 10*keV;
104  G4double value = 0.;
105  G4double efficiency = 1.;
106 
107  const XrayFluoDataSet* dataSet = efficiencySet;
108  G4int id = 0;
109 
110  G4double random = G4UniformRand();
111 
112  if (energy>=eMin && energy <=eMax)
113  {
114  G4double infEnergy = (G4int)(energy/keV)* keV;
115 
116  G4double supEnergy = ((G4int)(energy/keV) + 1)*keV;
117 
118  G4double infData = GetInfData(energy, random, 0);// 0 is not used
119 
120  G4double supData = GetSupData(energy,random, 0); // 0 is not used
121 
122  value = (std::log10(infData)*std::log10(supEnergy/energy) +
123  std::log10(supData)*std::log10(energy/infEnergy)) /
124  std::log10(supEnergy/infEnergy);
125  value = std::pow(10,value);
126  }
127  else if (energy<eMin)
128  {
129  G4double infEnergy = eMin;
130  G4double supEnergy = eMin/keV +1*keV;
131 
132  G4double infData = GetInfData(eMin, random, 0);
133  G4double supData = GetSupData(eMin,random, 0);
134  value = (std::log10(infData)*std::log10(supEnergy/eMin) +
135  std::log10(supData)*std::log10(eMin/infEnergy)) /
136  std::log10(supEnergy/infEnergy);
137  value = std::pow(10,value);
138  value = value-eMin+ energy;
139 
140 
141  }
142  else if (energy>eMax)
143  {
144  G4double infEnergy = eMax/keV - 1. *keV;
145  G4double supEnergy = eMax;
146 
147  G4double infData = GetInfData(eMax, random, 0);
148  G4double supData = GetSupData(eMax,random, 0);
149  value = (std::log10(infData)*std::log10(supEnergy/eMax) +
150  std::log10(supData)*std::log10(eMax/infEnergy)) /
151  std::log10(supEnergy/infEnergy);
152  value = std::pow(10,value);
153  value = value+energy- eMax;
154  }
155  G4double RandomNum = G4UniformRand();
156 
157  efficiency = dataSet->FindValue(value,id);
158  if ( RandomNum>efficiency )
159  {
160  value = 0.;
161  }
162 
163  return value;
164 }
G4double GetSupData(G4double, G4double, G4int)
int G4int
Definition: G4Types.hh:78
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
#define G4UniformRand()
Definition: Randomize.hh:87
G4double FindValue(G4double e, G4int) const
G4double GetInfData(G4double, G4double, G4int)
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76

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