Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4FluoData Class Reference

#include <G4FluoData.hh>

Public Member Functions

 G4FluoData (const G4String &dir)
 
 ~G4FluoData ()
 
size_t NumberOfVacancies () const
 
G4int VacancyId (G4int vacancyIndex) const
 
size_t NumberOfTransitions (G4int vacancyIndex) const
 
G4int StartShellId (G4int initIndex, G4int vacancyIndex) const
 
G4double StartShellEnergy (G4int initIndex, G4int vacancyIndex) const
 
G4double StartShellProb (G4int initIndex, G4int vacancyIndex) const
 
void LoadData (G4int Z)
 
void PrintData ()
 

Detailed Description

Definition at line 52 of file G4FluoData.hh.

Constructor & Destructor Documentation

G4FluoData::G4FluoData ( const G4String dir)

Definition at line 44 of file G4FluoData.cc.

45 {
46  numberOfVacancies=0;
47  fluoDirectory = dir;
48 }
G4FluoData::~G4FluoData ( )

Definition at line 50 of file G4FluoData.cc.

51 {
52  std::map<G4int,G4DataVector*,std::less<G4int> >::iterator pos;
53 
54  for (pos = idMap.begin(); pos != idMap.end(); ++pos)
55  {
56  G4DataVector* dataSet = (*pos).second;
57  delete dataSet;
58  }
59  for (pos = energyMap.begin(); pos != energyMap.end(); ++pos)
60  {
61  G4DataVector* dataSet = (*pos).second;
62  delete dataSet;
63  }
64  for (pos = probabilityMap.begin(); pos != probabilityMap.end(); ++pos)
65  {
66  G4DataVector* dataSet = (*pos).second;
67  delete dataSet;
68  }
69 }
static const G4double pos

Member Function Documentation

void G4FluoData::LoadData ( G4int  Z)

Definition at line 195 of file G4FluoData.cc.

196 {
197  // Build the complete string identifying the file with the data set
198  std::ostringstream ost;
199  if(Z != 0){
200  ost << "/fl-tr-pr-"<< Z << ".dat";
201  }
202  else{
203  ost << "/fl-tr-pr-"<<".dat";
204  }
205  G4String name(ost.str());
206 
207  char* path = getenv("G4LEDATA");
208  if (!path)
209  {
210  G4String excep("G4FluoData::LoadData()");
211  G4Exception(excep,"em0006",FatalException,"Please set G4LEDATA");
212  return;
213  }
214 
215  G4String pathString(path);
216  G4String dirFile = pathString + fluoDirectory + name;
217  std::ifstream file(dirFile);
218  std::filebuf* lsdp = file.rdbuf();
219 
220  if (! (lsdp->is_open()) )
221  {
222  G4String excep = "G4FluoData::LoadData()";
223  G4String msg = "data file: " + dirFile + " not found";
224  G4Exception(excep, "em0003",FatalException, msg );
225  return;
226  }
227 
228  G4double a = 0;
229  G4int k = 1;
230  G4int sLocal = 0;
231 
232  G4int vacIndex = 0;
233  G4DataVector* initIds = new G4DataVector;
234  G4DataVector* transEnergies = new G4DataVector;
235  G4DataVector* transProbabilities = new G4DataVector;
236 
237  do {
238  file >> a;
239  G4int nColumns = 3;
240  if (a == -1)
241  {
242  if (sLocal == 0)
243  {
244  // End of a shell data set
245  idMap[vacIndex] = initIds;
246  energyMap[vacIndex] = transEnergies;
247  probabilityMap[vacIndex] = transProbabilities;
248  // G4double size=transProbabilities->size();
249  G4int n = initIds->size();
250 
251  nInitShells.push_back(n);
252  numberOfVacancies++;
253  // Start of new shell data set
254  initIds = new G4DataVector;
255  transEnergies = new G4DataVector;
256  transProbabilities = new G4DataVector;
257  vacIndex++;
258  }
259  sLocal++;
260  if (sLocal == nColumns)
261  {
262  sLocal = 0;
263  }
264  }
265  // moved to the end in order to avoid possible leak
266  /* else if (a == -2)
267  {
268  // End of file; delete the empty vectors created
269  //when encountering the last -1 -1 row
270  delete initIds;
271  delete transEnergies;
272  delete transProbabilities;
273  }*/
274  else
275  {
276  if(k%nColumns == 2)
277  {
278  // 2nd column is transition probabilities
279 
280  if (a != -1) transProbabilities->push_back(a);
281 
282  k++;
283  }
284  else if (k%nColumns == 1)
285  {
286  // 1st column is shell id
287  // if this is the first data of the shell, all the colums are equal
288  // to the shell Id; so we skip the next colums ang go to the next row
289  if(initIds->size() == 0) {
290  if (a != -1) initIds->push_back((G4int)a);
291  file >> a;
292  file >> a;
293  k=k+2;
294  }
295  else{
296  if (a != -1) initIds->push_back(a);
297  }
298  k++;
299  }
300  else if (k%nColumns == 0)
301 
302  {//third column is transition energies
303 
304  if (a != -1)
305  {G4double e = a * MeV;
306  transEnergies->push_back(e);}
307 
308  k=1;
309  }
310  }
311  }
312  while (a != -2); // end of file
313  file.close();
314  delete initIds;
315  delete transEnergies;
316  delete transProbabilities;
317 }
const XML_Char * name
Definition: expat.h:151
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static constexpr double MeV
Definition: G4SIunits.hh:214
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

size_t G4FluoData::NumberOfTransitions ( G4int  vacancyIndex) const

Definition at line 97 of file G4FluoData.cc.

98 {
99  G4int n = 0;
100  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
101  {
102  G4Exception("G4FluoData::NumberOfTransitions()","de0002",JustWarning,
103  "vacancyIndex outside boundaries, energy deposited locally");
104  return 0;
105  }
106  else
107  {
108  n = nInitShells[vacancyIndex]-1;
109  //-1 is necessary because the elements of the vector nInitShells
110  //include also the vacancy shell:
111  // -1 subtracts this last one
112  }
113  return n;
114 }
int G4int
Definition: G4Types.hh:78
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:

size_t G4FluoData::NumberOfVacancies ( ) const

Definition at line 71 of file G4FluoData.cc.

72 {
73  return numberOfVacancies;
74 }
void G4FluoData::PrintData ( void  )

Definition at line 320 of file G4FluoData.cc.

321 {
322  for (G4int i = 0; i <numberOfVacancies; i++)
323  {
324  G4cout << "---- TransitionData for the vacancy nb "
325  <<i
326  <<" ----- "
327  <<G4endl;
328 
329  for (size_t k = 0; k<NumberOfTransitions(i); k++)
330  {
331  G4int id = StartShellId(k,i);
332  // let's start from 1 because the first (index = 0) element of the vector
333  // is the id of the intial vacancy
334  G4double e = StartShellEnergy(k,i) /MeV;
335  G4double p = StartShellProb(k,i);
336  G4cout << k <<") Shell id: " << id <<G4endl;
337  G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
338  G4cout << " - Transition probability = " << p <<G4endl;
339 
340  }
341  G4cout << "-------------------------------------------------"
342  << G4endl;
343  }
344 }
G4double StartShellProb(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:168
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4int StartShellId(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:115
G4double StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:143
size_t NumberOfTransitions(G4int vacancyIndex) const
Definition: G4FluoData.cc:97
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4double G4FluoData::StartShellEnergy ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 143 of file G4FluoData.cc.

144 {
145  G4double n = -1;
146 
147  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
148  {
149  G4Exception("G4FluoData::StartShellEnergy()","de0002",FatalErrorInArgument,
150  "vacancyIndex outside boundaries");}
151  else
152  {
153  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
154 
155  pos = energyMap.find(vacancyIndex);
156 
157  G4DataVector dataSet = *((*pos).second);
158 
159  G4int nData = dataSet.size();
160  if (initIndex >= 0 && initIndex < nData)
161  {
162  n = dataSet[initIndex];
163  }
164  }
165  return n;
166 }
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
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4FluoData::StartShellId ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 115 of file G4FluoData.cc.

116 {
117  G4int n = -1;
118 
119  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
120  {
121  G4Exception("G4FluoData::StartShellId()","de0002",FatalErrorInArgument,
122  "vacancyIndex outside boundaries");
123  }
124  else
125  {
126  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
127 
128  pos = idMap.find(vacancyIndex);
129 
130  G4DataVector dataSet = *((*pos).second);
131 
132  G4int nData = dataSet.size();
133  // The first Element of idMap's dataSets is the original shell of
134  // the vacancy, so we must start from the first element of dataSet
135  if (initIndex >= 0 && initIndex < nData)
136  {
137  n = (G4int) dataSet[initIndex+1];
138  }
139  }
140  return n;
141 }
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4FluoData::StartShellProb ( G4int  initIndex,
G4int  vacancyIndex 
) const

Definition at line 168 of file G4FluoData.cc.

169 {
170  G4double n = -1;
171 
172  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
173  {
174  G4Exception("G4FluoData::StartShellEnergy()","de0002",JustWarning,
175  "vacancyIndex outside boundaries, energy deposited locally");
176  return 0;
177  }
178  else
179  {
180  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
181 
182  pos = probabilityMap.find(vacancyIndex);
183 
184  G4DataVector dataSet = *((*pos).second);
185 
186  G4int nData = dataSet.size();
187  if (initIndex >= 0 && initIndex < nData)
188  {
189  n = dataSet[initIndex];
190  }
191  }
192  return n;
193 }
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
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4FluoData::VacancyId ( G4int  vacancyIndex) const

Definition at line 76 of file G4FluoData.cc.

77 {
78  G4int n = -1;
79  if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
80  {
81  G4Exception("G4FluoData::vacancyId()","de0002",FatalErrorInArgument,
82  "vacancyIndex outside boundaries");
83  }
84  else
85  {
86  std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
87  pos = idMap.find(vacancyIndex);
88  if (pos!= idMap.end())
89  { G4DataVector dataSet = (*(*pos).second);
90  n = (G4int) dataSet[0];
91 
92  }
93  }
94  return n;
95 }
int G4int
Definition: G4Types.hh:78
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static const G4double pos

Here is the call graph for this function:

Here is the caller graph for this function:


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