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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/eRosita/physics/src/G4RDFluoData.cc (Version 11.3.0) and /examples/advanced/eRosita/physics/src/G4RDFluoData.cc (Version 5.2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 // Author: Elena Guardincerri (Elena.Guardince    
 29 //                                                
 30 // History:                                       
 31 // -----------                                    
 32 // 16 Sept 2001  First committed to cvs           
 33 //                                                
 34 // -------------------------------------------    
 35                                                   
 36 #include <fstream>                                
 37 #include <sstream>                                
 38                                                   
 39 #include "G4RDFluoData.hh"                        
 40 #include "G4SystemOfUnits.hh"                     
 41 #include "G4DataVector.hh"                        
 42 #include "G4RDFluoTransition.hh"                  
 43                                                   
 44 G4RDFluoData::G4RDFluoData()                      
 45 {                                                 
 46   numberOfVacancies=0;                            
 47 }                                                 
 48                                                   
 49 G4RDFluoData::~G4RDFluoData()                     
 50 {                                                 
 51  std::map<G4int,G4DataVector*,std::less<G4int>    
 52                                                   
 53   for (pos = idMap.begin(); pos != idMap.end()    
 54     {                                             
 55       G4DataVector* dataSet = (*pos).second;      
 56       delete dataSet;                             
 57     }                                             
 58   for (pos = energyMap.begin(); pos != energyM    
 59     {                                             
 60       G4DataVector* dataSet = (*pos).second;      
 61       delete dataSet;                             
 62     }                                             
 63  for (pos = probabilityMap.begin(); pos != pro    
 64     {                                             
 65       G4DataVector* dataSet = (*pos).second;      
 66       delete dataSet;                             
 67     }                                             
 68 }                                                 
 69                                                   
 70 size_t G4RDFluoData::NumberOfVacancies() const    
 71 {                                                 
 72   return numberOfVacancies;                       
 73 }                                                 
 74                                                   
 75 G4int G4RDFluoData::VacancyId(G4int vacancyInd    
 76 {                                                 
 77   G4int n = -1;                                   
 78   if (vacancyIndex<0 || vacancyIndex>=numberOf    
 79     {G4Exception("G4RDFluoData::VacancyId()",     
 80                  FatalException, "VacancyIndex    
 81   else                                            
 82     {                                             
 83       std::map<G4int,G4DataVector*,std::less<G    
 84       pos = idMap.find(vacancyIndex);             
 85       if (pos!= idMap.end())                      
 86   { G4DataVector dataSet = (*(*pos).second);      
 87   n = (G4int) dataSet[0];                         
 88                                                   
 89   }                                               
 90     }                                             
 91   return n;                                       
 92 }                                                 
 93                                                   
 94 size_t G4RDFluoData::NumberOfTransitions(G4int    
 95 {                                                 
 96   G4int n = 0;                                    
 97   if (vacancyIndex<0 || vacancyIndex>=numberOf    
 98     {G4Exception("G4RDFluoData::NumberOfTransi    
 99                  FatalException, "VacancyIndex    
100   else                                            
101     {                                             
102       n = nInitShells[vacancyIndex]-1;            
103       //-1 is necessary because the elements o    
104       //include also the vacancy shell:           
105       // -1 subtracts this last one               
106   }                                               
107  return n;                                        
108 }                                                 
109 G4int G4RDFluoData::StartShellId(G4int initInd    
110 {                                                 
111  G4int n = -1;                                    
112                                                   
113  if (vacancyIndex<0 || vacancyIndex>=numberOfV    
114     {G4Exception("G4RDFluoData::StartShellId()    
115                  FatalException, "VacancyIndex    
116  else                                             
117    {                                              
118      std::map<G4int,G4DataVector*,std::less<G4    
119                                                   
120      pos = idMap.find(vacancyIndex);              
121                                                   
122      G4DataVector dataSet = *((*pos).second);     
123                                                   
124      G4int nData = dataSet.size();                
125      //The first Element of idMap's dataSets i    
126      //so we must start from the first element    
127  if (initIndex >= 0 && initIndex < nData)         
128       {                                           
129         n =  (G4int) dataSet[initIndex+1];        
130                                                   
131       }                                           
132    }                                              
133  return n;                                        
134 }                                                 
135                                                   
136 G4double G4RDFluoData::StartShellEnergy(G4int     
137 {                                                 
138   G4double n = -1;                                
139                                                   
140   if (vacancyIndex<0 || vacancyIndex>=numberOf    
141     {G4Exception("G4RDFluoData::StartShellEner    
142                  FatalException, "VacancyIndex    
143  else                                             
144    {                                              
145      std::map<G4int,G4DataVector*,std::less<G4    
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 }                                                 
160                                                   
161 G4double G4RDFluoData::StartShellProb(G4int in    
162 {                                                 
163   G4double n = -1;                                
164                                                   
165   if (vacancyIndex<0 || vacancyIndex>=numberOf    
166     {G4Exception("G4RDFluoData::StartShellProb    
167                  FatalException, "VacancyIndex    
168   else                                            
169     {                                             
170      std::map<G4int,G4DataVector*,std::less<G4    
171                                                   
172      pos = probabilityMap.find(vacancyIndex);     
173                                                   
174      G4DataVector dataSet = *((*pos).second);     
175                                                   
176      G4int nData = dataSet.size();                
177      if (initIndex >= 0 && initIndex < nData)     
178        {                                          
179    n =  dataSet[initIndex];                       
180                                                   
181        }                                          
182     }                                             
183   return n;                                       
184 }                                                 
185                                                   
186 void G4RDFluoData::LoadData(G4int Z)              
187 {                                                 
188   // Build the complete string identifying the    
189                                                   
190   std::ostringstream ost;                         
191   if(Z != 0){                                     
192     ost << "fl-tr-pr-"<< Z << ".dat";             
193   }                                               
194   else{                                           
195     ost << "fl-tr-pr-"<<".dat";                   
196   }                                               
197   G4String name(ost.str());                       
198                                                   
199   const char* path = G4FindDataDir("G4LEDATA")    
200   if (!path)                                      
201     {                                             
202       G4String excep("G4LEDATA environment var    
203       G4Exception("G4RDEMDataSet::LoadData()",    
204                   FatalException, excep);         
205     }                                             
206                                                   
207   G4String pathString(path);                      
208   G4String fluor("/fluor/");                      
209   G4String dirFile = pathString + fluor + name    
210   std::ifstream file(dirFile);                    
211   std::filebuf* lsdp = file.rdbuf();              
212                                                   
213   if (! (lsdp->is_open()) )                       
214     {                                             
215       G4String excep = "Data file: " + dirFile    
216       G4Exception("G4RDEMDataSet::LoadData()",    
217                   FatalException, excep);         
218     }                                             
219                                                   
220   G4double a = 0;                                 
221   G4int k = 1;                                    
222   G4int s = 0;                                    
223                                                   
224   G4int vacIndex = 0;                             
225   G4DataVector* initIds = new G4DataVector;       
226   G4DataVector* transEnergies = new G4DataVect    
227   G4DataVector* transProbabilities = new G4Dat    
228                                                   
229   do {                                            
230     file >> a;                                    
231     G4int nColumns = 3;                           
232     if (a == -1)                                  
233       {                                           
234   if (s == 0)                                     
235     {                                             
236       // End of a shell data set                  
237       idMap[vacIndex] = initIds;                  
238             energyMap[vacIndex] = transEnergie    
239       probabilityMap[vacIndex] = transProbabil    
240       //      G4double size=transProbabilities    
241             G4int n = initIds->size();            
242                                                   
243       nInitShells.push_back(n);                   
244       numberOfVacancies++;                        
245       // Start of new shell data set              
246       initIds = new G4DataVector;                 
247             transEnergies = new G4DataVector;     
248       transProbabilities = new G4DataVector;      
249             vacIndex++;                           
250     }                                             
251   s++;                                            
252   if (s == nColumns)                              
253     {                                             
254       s = 0;                                      
255     }                                             
256       }                                           
257     else if (a == -2)                             
258       {                                           
259   // End of file; delete the empty vectors cre    
260   //when encountering the last -1 -1 row          
261   delete initIds;                                 
262   delete transEnergies;                           
263   delete transProbabilities;                      
264       }                                           
265     else                                          
266       {                                           
267                                                   
268   if(k%nColumns == 2)                             
269     {                                             
270       // 2nd column is transition  probabiliti    
271                                                   
272      if (a != -1) transProbabilities->push_bac    
273                                                   
274       k++;                                        
275     }                                             
276   else if (k%nColumns == 1)                       
277     {                                             
278       // 1st column is shell id                   
279       // if this is the first data of the shel    
280       // to the shell Id; so we skip the next     
281       if(initIds->size() == 0) {                  
282         if (a != -1) initIds->push_back((G4int    
283         file >> a;                                
284         file >> a;                                
285         k=k+2;                                    
286       }                                           
287       else{                                       
288         if (a != -1) initIds->push_back(a);       
289       }                                           
290       k++;                                        
291     }                                             
292   else if (k%nColumns == 0)                       
293                                                   
294     {//third column is transition energies        
295                                                   
296       if (a != -1)                                
297         {G4double e = a * MeV;                    
298         transEnergies->push_back(e);}             
299                                                   
300       k=1;                                        
301     }                                             
302       }                                           
303   }                                               
304   while (a != -2); // end of file                 
305   file.close();                                   
306 }                                                 
307                                                   
308 void G4RDFluoData::PrintData()                    
309 {                                                 
310                                                   
311   for (G4int i = 0; i <numberOfVacancies; i++)    
312     {                                             
313       G4cout << "---- TransitionData for the v    
314        <<i                                        
315        <<" ----- "                                
316        <<G4endl;                                  
317                                                   
318       for (size_t k = 0; k<NumberOfTransitions    
319   {                                               
320     G4int id = StartShellId(k,i);                 
321   // let's start from 1 because the first (ind    
322   // is the id of the intial vacancy              
323     G4double e = StartShellEnergy(k,i) /MeV;      
324     G4double p = StartShellProb(k,i);             
325     G4cout << k <<") Shell id: " << id <<G4end    
326     G4cout << " - Transition energy = " << e <    
327     G4cout   << " - Transition probability = "    
328                                                   
329   }                                               
330       G4cout << "-----------------------------    
331        << G4endl;                                 
332     }                                             
333 }                                                 
334