Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FluoData Class Reference

#include <G4FluoData.hh>

Public Member Functions

 G4FluoData ()
 
 ~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::G4FluoData ( )

Definition at line 44 of file G4FluoData.cc.

45{
46 numberOfVacancies=0;
47}

◆ ~G4FluoData()

G4FluoData::~G4FluoData ( )

Definition at line 49 of file G4FluoData.cc.

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

Member Function Documentation

◆ LoadData()

void G4FluoData::LoadData ( G4int  Z)

Definition at line 188 of file G4FluoData.cc.

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

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager().

◆ NumberOfTransitions()

size_t G4FluoData::NumberOfTransitions ( G4int  vacancyIndex) const

Definition at line 93 of file G4FluoData.cc.

94{
95 G4int n = 0;
96 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
97 {
98 G4Exception("G4FluoData::NumberOfTransitions()","de0002",JustWarning,"vacancyIndex outside boundaries, energy deposited locally");
99 return 0;
100 }
101 else
102 {
103 n = nInitShells[vacancyIndex]-1;
104 //-1 is necessary because the elements of the vector nInitShells
105 //include also the vacancy shell:
106 // -1 subtracts this last one
107 }
108 return n;
109}
@ JustWarning

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager(), and PrintData().

◆ NumberOfVacancies()

size_t G4FluoData::NumberOfVacancies ( ) const

Definition at line 70 of file G4FluoData.cc.

71{
72 return numberOfVacancies;
73}

◆ PrintData()

void G4FluoData::PrintData ( )

Definition at line 316 of file G4FluoData.cc.

317{
318
319 for (G4int i = 0; i <numberOfVacancies; i++)
320 {
321 G4cout << "---- TransitionData for the vacancy nb "
322 <<i
323 <<" ----- "
324 <<G4endl;
325
326 for (size_t k = 0; k<NumberOfTransitions(i); k++)
327 {
328 G4int id = StartShellId(k,i);
329 // let's start from 1 because the first (index = 0) element of the vector
330 // is the id of the intial vacancy
331 G4double e = StartShellEnergy(k,i) /MeV;
332 G4double p = StartShellProb(k,i);
333 G4cout << k <<") Shell id: " << id <<G4endl;
334 G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
335 G4cout << " - Transition probability = " << p <<G4endl;
336
337 }
338 G4cout << "-------------------------------------------------"
339 << G4endl;
340 }
341}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4double StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:137
size_t NumberOfTransitions(G4int vacancyIndex) const
Definition: G4FluoData.cc:93
G4int StartShellId(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:110
G4double StartShellProb(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:161

◆ StartShellEnergy()

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

Definition at line 137 of file G4FluoData.cc.

138{
139 G4double n = -1;
140
141 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
142 {G4Exception("G4FluoData::StartShellEnergy()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");}
143 else
144 {
145 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
146
147 pos = energyMap.find(vacancyIndex);
148
149 G4DataVector dataSet = *((*pos).second);
150
151 G4int nData = dataSet.size();
152 if (initIndex >= 0 && initIndex < nData)
153 {
154 n = dataSet[initIndex];
155
156 }
157 }
158 return n;
159}
@ FatalErrorInArgument

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager(), and PrintData().

◆ StartShellId()

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

Definition at line 110 of file G4FluoData.cc.

111{
112 G4int n = -1;
113
114 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
115 {G4Exception("G4FluoData::StartShellId()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");
116 }
117 else
118 {
119 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
120
121 pos = idMap.find(vacancyIndex);
122
123 G4DataVector dataSet = *((*pos).second);
124
125 G4int nData = dataSet.size();
126 //The first Element of idMap's dataSets is the original shell of the vacancy,
127 //so we must start from the first element of dataSet
128 if (initIndex >= 0 && initIndex < nData)
129 {
130 n = (G4int) dataSet[initIndex+1];
131
132 }
133 }
134 return n;
135}

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager(), and PrintData().

◆ StartShellProb()

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

Definition at line 161 of file G4FluoData.cc.

162{
163 G4double n = -1;
164
165 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
166 {
167 G4Exception("G4FluoData::StartShellEnergy()","de0002",JustWarning,"vacancyIndex outside boundaries, energy deposited locally");
168 return 0;
169}
170 else
171 {
172 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
173
174 pos = probabilityMap.find(vacancyIndex);
175
176 G4DataVector dataSet = *((*pos).second);
177
178 G4int nData = dataSet.size();
179 if (initIndex >= 0 && initIndex < nData)
180 {
181 n = dataSet[initIndex];
182
183 }
184 }
185 return n;
186}

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager(), and PrintData().

◆ VacancyId()

G4int G4FluoData::VacancyId ( G4int  vacancyIndex) const

Definition at line 75 of file G4FluoData.cc.

76{
77 G4int n = -1;
78 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
79 {G4Exception("G4FluoData::vacancyId()","de0002",FatalErrorInArgument,"vacancyIndex outside boundaries");}
80 else
81 {
82 std::map<G4int,G4DataVector*,std::less<G4int> >::const_iterator pos;
83 pos = idMap.find(vacancyIndex);
84 if (pos!= idMap.end())
85 { G4DataVector dataSet = (*(*pos).second);
86 n = (G4int) dataSet[0];
87
88 }
89 }
90 return n;
91}

Referenced by G4AtomicTransitionManager::G4AtomicTransitionManager().


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