Geant4-11
Public Member Functions | Private Attributes
G4FluoData Class Reference

#include <G4FluoData.hh>

Public Member Functions

 G4FluoData (const G4FluoData &)=delete
 
 G4FluoData (const G4String &dir)
 
void LoadData (G4int Z)
 
size_t NumberOfTransitions (G4int vacancyIndex) const
 
size_t NumberOfVacancies () const
 
G4FluoDataoperator= (const G4FluoData &right)=delete
 
void PrintData ()
 
G4double StartShellEnergy (G4int initIndex, G4int vacancyIndex) const
 
G4int StartShellId (G4int initIndex, G4int vacancyIndex) const
 
G4double StartShellProb (G4int initIndex, G4int vacancyIndex) const
 
G4int VacancyId (G4int vacancyIndex) const
 Given the index of the vacancy returns its identity. More...
 
 ~G4FluoData ()
 

Private Attributes

std::map< G4int, G4DataVector *, std::less< G4int > > energyMap
 
G4String fluoDirectory
 
std::map< G4int, std::vector< G4FluoTransition * >, std::less< G4int > > fluoTransitionTable
 
std::map< G4int, G4DataVector *, std::less< G4int > > idMap
 
std::vector< G4intnInitShells
 
G4int numberOfVacancies = 0
 
std::map< G4int, G4DataVector *, std::less< G4int > > probabilityMap
 

Detailed Description

Definition at line 51 of file G4FluoData.hh.

Constructor & Destructor Documentation

◆ G4FluoData() [1/2]

G4FluoData::G4FluoData ( const G4String dir)
explicit

Definition at line 44 of file G4FluoData.cc.

45{
46 fluoDirectory = dir;
47}
G4String fluoDirectory
Definition: G4FluoData.hh:95

References fluoDirectory.

◆ ~G4FluoData()

G4FluoData::~G4FluoData ( )

Definition at line 51 of file G4FluoData.cc.

52{
53 for (auto& pos : idMap)
54 {
55 G4DataVector* dataSet = pos.second;
56 delete dataSet;
57 }
58
59 for (auto& pos : energyMap)
60 {
61 G4DataVector* dataSet = pos.second;
62 delete dataSet;
63 }
64
65 for (auto& pos: probabilityMap)
66 {
67 G4DataVector* dataSet = pos.second;
68 delete dataSet;
69 }
70}
static const G4double pos
std::map< G4int, G4DataVector *, std::less< G4int > > energyMap
Definition: G4FluoData.hh:91
std::map< G4int, G4DataVector *, std::less< G4int > > idMap
Definition: G4FluoData.hh:90
std::map< G4int, G4DataVector *, std::less< G4int > > probabilityMap
Definition: G4FluoData.hh:92

References energyMap, idMap, pos, and probabilityMap.

◆ G4FluoData() [2/2]

G4FluoData::G4FluoData ( const G4FluoData )
delete

Member Function Documentation

◆ LoadData()

void G4FluoData::LoadData ( G4int  Z)

Definition at line 204 of file G4FluoData.cc.

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

References energyMap, FatalException, geant4_check_module_cycles::file, fluoDirectory, G4Exception(), idMap, MeV, CLHEP::detail::n, G4InuclParticleNames::name(), nInitShells, numberOfVacancies, probabilityMap, and Z.

Referenced by G4AtomicTransitionManager::Initialise().

◆ NumberOfTransitions()

size_t G4FluoData::NumberOfTransitions ( G4int  vacancyIndex) const

Given the index of a vacancy returns the number of shells starting from wich an electrons can fill the vacancy

Definition at line 103 of file G4FluoData.cc.

104{
105 G4int n = 0;
106 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
107 {
108 G4Exception("G4FluoData::NumberOfTransitions()","de0002",JustWarning,
109 "vacancyIndex outside boundaries, energy deposited locally");
110 return 0;
111 }
112 else
113 {
114 n = nInitShells[vacancyIndex]-1;
115 //-1 is necessary because the elements of the vector nInitShells
116 //include also the vacancy shell:
117 // -1 subtracts this last one
118 }
119 return n;
120}
@ JustWarning

References G4Exception(), JustWarning, CLHEP::detail::n, nInitShells, and numberOfVacancies.

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

◆ NumberOfVacancies()

size_t G4FluoData::NumberOfVacancies ( ) const

The method returns the number of shells in wich a vacancy can be filled by a radiative transition

Definition at line 74 of file G4FluoData.cc.

75{
76 return numberOfVacancies;
77}

References numberOfVacancies.

◆ operator=()

G4FluoData & G4FluoData::operator= ( const G4FluoData right)
delete

◆ PrintData()

void G4FluoData::PrintData ( void  )

Definition at line 336 of file G4FluoData.cc.

337{
338 for (G4int i = 0; i <numberOfVacancies; i++)
339 {
340 G4cout << "---- TransitionData for the vacancy nb "
341 <<i
342 <<" ----- "
343 <<G4endl;
344
345 for (size_t k = 0; k<NumberOfTransitions(i); k++)
346 {
347 G4int id = StartShellId(k,i);
348 // let's start from 1 because the first (index = 0) element of the vector
349 // is the id of the initial vacancy
350 G4double e = StartShellEnergy(k,i) /MeV;
351 G4double p = StartShellProb(k,i);
352 G4cout << k <<") Shell id: " << id <<G4endl;
353 G4cout << " - Transition energy = " << e << " MeV "<<G4endl;
354 G4cout << " - Transition probability = " << p <<G4endl;
355
356 }
357 G4cout << "-------------------------------------------------"
358 << G4endl;
359 }
360}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4double StartShellEnergy(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:152
size_t NumberOfTransitions(G4int vacancyIndex) const
Definition: G4FluoData.cc:103
G4int StartShellId(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:124
G4double StartShellProb(G4int initIndex, G4int vacancyIndex) const
Definition: G4FluoData.cc:177

References G4cout, G4endl, MeV, NumberOfTransitions(), numberOfVacancies, StartShellEnergy(), StartShellId(), and StartShellProb().

◆ StartShellEnergy()

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

Given the indexes of the starting and final shells for the transition, returns the transition energy

Definition at line 152 of file G4FluoData.cc.

153{
154 G4double n = -1;
155
156 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
157 {
158 G4Exception("G4FluoData::StartShellEnergy()","de0002",FatalErrorInArgument,
159 "vacancyIndex outside boundaries");}
160 else
161 {
162 auto pos = energyMap.find(vacancyIndex);
163
164 G4DataVector dataSet = *((*pos).second);
165
166 G4int nData = dataSet.size();
167 if (initIndex >= 0 && initIndex < nData)
168 {
169 n = dataSet[initIndex];
170 }
171 }
172 return n;
173}
@ FatalErrorInArgument

References energyMap, FatalErrorInArgument, G4Exception(), CLHEP::detail::n, numberOfVacancies, and pos.

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

◆ StartShellId()

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

Given the indexes of the starting and final shells for the transition, returns the identity of the starting one

Definition at line 124 of file G4FluoData.cc.

125{
126 G4int n = -1;
127
128 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
129 {
130 G4Exception("G4FluoData::StartShellId()","de0002",FatalErrorInArgument,
131 "vacancyIndex outside boundaries");
132 }
133 else
134 {
135 auto pos = idMap.find(vacancyIndex);
136
137 G4DataVector dataSet = *((*pos).second);
138
139 G4int nData = dataSet.size();
140 // The first Element of idMap's dataSets is the original shell of
141 // the vacancy, so we must start from the first element of dataSet
142 if (initIndex >= 0 && initIndex < nData)
143 {
144 n = (G4int) dataSet[initIndex+1];
145 }
146 }
147 return n;
148}

References FatalErrorInArgument, G4Exception(), idMap, CLHEP::detail::n, numberOfVacancies, and pos.

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

◆ StartShellProb()

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

Given the indexes of the starting and final shells for the transition, returns the probability of this transition

Definition at line 177 of file G4FluoData.cc.

178{
179 G4double n = -1;
180
181 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
182 {
183 G4Exception("G4FluoData::StartShellEnergy()","de0002",JustWarning,
184 "vacancyIndex outside boundaries, energy deposited locally");
185 return 0;
186 }
187 else
188 {
189 auto pos = probabilityMap.find(vacancyIndex);
190
191 G4DataVector dataSet = *((*pos).second);
192
193 G4int nData = dataSet.size();
194 if (initIndex >= 0 && initIndex < nData)
195 {
196 n = dataSet[initIndex];
197 }
198 }
199 return n;
200}

References G4Exception(), JustWarning, CLHEP::detail::n, numberOfVacancies, pos, and probabilityMap.

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

◆ VacancyId()

G4int G4FluoData::VacancyId ( G4int  vacancyIndex) const

Given the index of the vacancy returns its identity.

Definition at line 81 of file G4FluoData.cc.

82{
83 G4int n = -1;
84 if (vacancyIndex<0 || vacancyIndex>=numberOfVacancies)
85 {
86 G4Exception("G4FluoData::vacancyId()","de0002",FatalErrorInArgument,
87 "vacancyIndex outside boundaries");
88 }
89 else
90 {
91 auto pos = idMap.find(vacancyIndex);
92 if (pos!= idMap.end())
93 { G4DataVector dataSet = (*(*pos).second);
94 n = (G4int) dataSet[0];
95
96 }
97 }
98 return n;
99}

References FatalErrorInArgument, G4Exception(), idMap, CLHEP::detail::n, numberOfVacancies, and pos.

Referenced by G4AtomicTransitionManager::Initialise().

Field Documentation

◆ energyMap

std::map<G4int,G4DataVector*,std::less<G4int> > G4FluoData::energyMap
private

Definition at line 91 of file G4FluoData.hh.

Referenced by LoadData(), StartShellEnergy(), and ~G4FluoData().

◆ fluoDirectory

G4String G4FluoData::fluoDirectory
private

Definition at line 95 of file G4FluoData.hh.

Referenced by G4FluoData(), and LoadData().

◆ fluoTransitionTable

std::map<G4int,std::vector<G4FluoTransition*>,std::less<G4int> > G4FluoData::fluoTransitionTable
private

Definition at line 94 of file G4FluoData.hh.

◆ idMap

std::map<G4int,G4DataVector*,std::less<G4int> > G4FluoData::idMap
private

Definition at line 90 of file G4FluoData.hh.

Referenced by LoadData(), StartShellId(), VacancyId(), and ~G4FluoData().

◆ nInitShells

std::vector<G4int> G4FluoData::nInitShells
private

Definition at line 93 of file G4FluoData.hh.

Referenced by LoadData(), and NumberOfTransitions().

◆ numberOfVacancies

G4int G4FluoData::numberOfVacancies = 0
private

◆ probabilityMap

std::map<G4int,G4DataVector*,std::less<G4int> > G4FluoData::probabilityMap
private

Definition at line 92 of file G4FluoData.hh.

Referenced by LoadData(), StartShellProb(), and ~G4FluoData().


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