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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/G4RDShellEMDataSet.cc (Version 11.3.0) and /examples/advanced/eRosita/physics/src/G4RDShellEMDataSet.cc (Version 9.4.p3)


  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: Maria Grazia Pia (Maria.Grazia.Pia@    
 29 //                                                
 30 // History:                                       
 31 // -----------                                    
 32 //  1 Aug 2001   MGP        Created               
 33 // 09.10.01   V.Ivanchenko Add case z=0           
 34 //  9 Mar 2008   MGP        Cleaned up unreada    
 35 //                          (Further clean-up     
 36 //                                                
 37 // -------------------------------------------    
 38                                                   
 39 #include "G4RDShellEMDataSet.hh"                  
 40 #include "G4RDEMDataSet.hh"                       
 41 #include "G4RDVDataSetAlgorithm.hh"               
 42 #include <fstream>                                
 43 #include <sstream>                                
 44                                                   
 45                                                   
 46 G4RDShellEMDataSet::G4RDShellEMDataSet(G4int z    
 47            G4double eUnit,                        
 48            G4double dataUnit)                     
 49   :                                               
 50   z(zeta),                                        
 51   algorithm(algo),                                
 52   unitEnergies(eUnit),                            
 53   unitData(dataUnit)                              
 54 {                                                 
 55   if (algorithm == 0)                             
 56     G4Exception("G4RDShellEMDataSet::G4RDShell    
 57                 FatalException, "Interpolation    
 58 }                                                 
 59                                                   
 60                                                   
 61 G4RDShellEMDataSet::~G4RDShellEMDataSet()         
 62 {                                                 
 63   CleanUpComponents();                            
 64   if (algorithm) delete algorithm;                
 65 }                                                 
 66                                                   
 67                                                   
 68 G4double G4RDShellEMDataSet::FindValue(G4doubl    
 69 {                                                 
 70   // Returns the sum over the shells correspon    
 71   G4double value = 0.;                            
 72                                                   
 73   std::vector<G4RDVEMDataSet *>::const_iterato    
 74   std::vector<G4RDVEMDataSet *>::const_iterato    
 75                                                   
 76   while (i != end)                                
 77     {                                             
 78       value += (*i)->FindValue(energy);           
 79       i++;                                        
 80     }                                             
 81                                                   
 82   return value;                                   
 83 }                                                 
 84                                                   
 85                                                   
 86 void G4RDShellEMDataSet::PrintData(void) const    
 87 {                                                 
 88   const size_t n = NumberOfComponents();          
 89                                                   
 90   G4cout << "The data set has " << n << " comp    
 91   G4cout << G4endl;                               
 92                                                   
 93   size_t i = 0;                                   
 94                                                   
 95   while (i < n)                                   
 96     {                                             
 97       G4cout << "--- Component " << i << " ---    
 98       GetComponent(i)->PrintData();               
 99       i++;                                        
100     }                                             
101 }                                                 
102                                                   
103                                                   
104 void G4RDShellEMDataSet::SetEnergiesData(G4Dat    
105                G4DataVector* data,                
106                G4int componentId)                 
107 {                                                 
108   G4RDVEMDataSet* component = components[compo    
109                                                   
110   if (component)                                  
111     {                                             
112       component->SetEnergiesData(energies, dat    
113       return;                                     
114     }                                             
115                                                   
116   std::ostringstream message;                     
117   message << "Component " << componentId << "     
118                                                   
119   G4Exception("G4RDShellEMDataSet::SetEnergies    
120               FatalException, message.str().c_    
121 }                                                 
122                                                   
123                                                   
124 G4bool G4RDShellEMDataSet::LoadData(const G4St    
125 {                                                 
126   CleanUpComponents();                            
127                                                   
128   G4String fullFileName = FullFileName(file);     
129   std::ifstream in(fullFileName);                 
130                                                   
131   if (!in.is_open())                              
132     {                                             
133       G4String message("Data file \"");           
134       message += fullFileName;                    
135       message += "\" not found";                  
136       G4Exception("G4RDShellEMDataSet::LoadDat    
137                   FatalException, message);       
138     }                                             
139                                                   
140   G4DataVector* energies = 0;                     
141   G4DataVector* data = 0;                         
142                                                   
143   G4double a = 0.;                                
144   G4int shellIndex = 0;                           
145   bool energyColumn = true;                       
146                                                   
147   do                                              
148     {                                             
149       in >> a;                                    
150                                                   
151       if (a == -1)                                
152   {                                               
153     if (energyColumn && energies!=0)              
154       {                                           
155         AddComponent(new G4RDEMDataSet(shellIn    
156         energies = 0;                             
157         data = 0;                                 
158       }                                           
159                                                   
160     energyColumn = (!energyColumn);               
161   }                                               
162       else if (a != -2)                           
163   {                                               
164     if (energies == 0)                            
165       {                                           
166         energies = new G4DataVector;              
167         data = new G4DataVector;                  
168       }                                           
169                                                   
170     if (energyColumn)                             
171       energies->push_back(a * unitEnergies);      
172     else                                          
173       data->push_back(a * unitData);              
174                                                   
175     energyColumn = (!energyColumn);               
176   }                                               
177     }                                             
178   while (a != -2);                                
179                                                   
180   return true;                                    
181 }                                                 
182                                                   
183                                                   
184 G4bool G4RDShellEMDataSet::SaveData(const G4St    
185 {                                                 
186   G4String fullFileName = FullFileName(file);     
187   std::ofstream out(fullFileName);                
188                                                   
189   if (!out.is_open())                             
190     {                                             
191       G4String message("Cannot open \"");         
192       message += fullFileName;                    
193       message += "\"";                            
194       G4Exception("G4RDEMDataSet::SaveData()",    
195                   FatalException, message);       
196     }                                             
197                                                   
198   const size_t n = NumberOfComponents();          
199   size_t k = 0;                                   
200                                                   
201   while (k < n)                                   
202     {                                             
203       const G4RDVEMDataSet* component = GetCom    
204                                                   
205       if (component)                              
206   {                                               
207     const G4DataVector& energies = component->    
208     const G4DataVector& data = component->GetD    
209                                                   
210     G4DataVector::const_iterator i = energies.    
211     G4DataVector::const_iterator endI = energi    
212     G4DataVector::const_iterator j = data.begi    
213                                                   
214     while (i != endI)                             
215       {                                           
216         out.precision(10);                        
217         out.width(15);                            
218         out.setf(std::ofstream::left);            
219         out << ((*i)/unitEnergies) << ' ';        
220                                                   
221         out.precision(10);                        
222         out.width(15);                            
223         out.setf(std::ofstream::left);            
224         out << ((*j)/unitData) << std::endl;      
225         i++;                                      
226         j++;                                      
227       }                                           
228   }                                               
229                                                   
230       out.precision(10);                          
231       out.width(15);                              
232       out.setf(std::ofstream::left);              
233       out << -1.f << ' ';                         
234                                                   
235       out.precision(10);                          
236       out.width(15);                              
237       out.setf(std::ofstream::left);              
238       out << -1.f << std::endl;                   
239                                                   
240       k++;                                        
241     }                                             
242                                                   
243   out.precision(10);                              
244   out.width(15);                                  
245   out.setf(std::ofstream::left);                  
246   out << -2.f << ' ';                             
247                                                   
248   out.precision(10);                              
249   out.width(15);                                  
250   out.setf(std::ofstream::left);                  
251   out << -2.f << std::endl;                       
252                                                   
253   return true;                                    
254 }                                                 
255                                                   
256                                                   
257 void G4RDShellEMDataSet::CleanUpComponents(voi    
258 {                                                 
259   while (!components.empty())                     
260     {                                             
261       if (components.back()) delete components    
262       components.pop_back();                      
263     }                                             
264 }                                                 
265                                                   
266                                                   
267 G4String G4RDShellEMDataSet::FullFileName(cons    
268 {                                                 
269   const char* path = G4FindDataDir("G4LEDATA")    
270   if (!path)                                      
271     G4Exception("G4RDShellEMDataSet::FullFileN    
272                 FatalException, "G4LEDATA envi    
273                                                   
274   std::ostringstream fullFileName;                
275                                                   
276   fullFileName << path << '/' << fileName << z    
277                                                   
278   return G4String(fullFileName.str().c_str());    
279 }                                                 
280