Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/lowenergy/src/G4MicroElecCrossSectionDataSet.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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 /processes/electromagnetic/lowenergy/src/G4MicroElecCrossSectionDataSet.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4MicroElecCrossSectionDataSet.cc (Version 10.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //  MR - 04/04/2012                                26 //  MR - 04/04/2012
 27 //  Based on G4DNACrossSectionDataSet              27 //  Based on G4DNACrossSectionDataSet
 28 //                                                 28 // 
 29                                                    29 
 30                                                    30 
 31 #include "G4MicroElecCrossSectionDataSet.hh"       31 #include "G4MicroElecCrossSectionDataSet.hh"
 32 #include "G4VDataSetAlgorithm.hh"                  32 #include "G4VDataSetAlgorithm.hh"
 33 #include "G4EMDataSet.hh"                          33 #include "G4EMDataSet.hh"
 34 #include <vector>                                  34 #include <vector>
 35 #include <fstream>                                 35 #include <fstream>
 36 #include <sstream>                                 36 #include <sstream>
 37                                                    37 
 38                                                    38 
 39 G4MicroElecCrossSectionDataSet::G4MicroElecCro     39 G4MicroElecCrossSectionDataSet::G4MicroElecCrossSectionDataSet(G4VDataSetAlgorithm* argAlgorithm, 
 40                G4double argUnitEnergies,           40                G4double argUnitEnergies, 
 41                G4double argUnitData)               41                G4double argUnitData)
 42   :                                                42   :
 43    algorithm(argAlgorithm), unitEnergies(argUn     43    algorithm(argAlgorithm), unitEnergies(argUnitEnergies), unitData(argUnitData)
 44 {;}                                            <<  44 {
                                                   >>  45   z = 0;
                                                   >>  46 
                                                   >>  47 }
                                                   >>  48 
 45                                                    49 
 46 //....oooOO0OOooo........oooOO0OOooo........oo << 
 47 G4MicroElecCrossSectionDataSet::~G4MicroElecCr     50 G4MicroElecCrossSectionDataSet::~G4MicroElecCrossSectionDataSet()
 48 {                                                  51 {
 49   CleanUpComponents();                             52   CleanUpComponents();
 50                                                    53  
 51   if (algorithm)                                   54   if (algorithm)
 52     delete algorithm;                              55     delete algorithm;
 53 }                                                  56 }
 54                                                    57 
 55 //....oooOO0OOooo........oooOO0OOooo........oo << 
 56 G4bool G4MicroElecCrossSectionDataSet::LoadDat     58 G4bool G4MicroElecCrossSectionDataSet::LoadData(const G4String & argFileName)
 57 {                                                  59 {
 58   CleanUpComponents();                             60   CleanUpComponents();
 59                                                    61 
 60   G4String fullFileName(FullFileName(argFileNa     62   G4String fullFileName(FullFileName(argFileName));
 61   std::ifstream in(fullFileName, std::ifstream     63   std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
 62                                                    64 
 63   if (!in.is_open())                               65   if (!in.is_open())
 64     {                                              66     {
 65       G4String message("Data file \"");            67       G4String message("Data file \"");
 66       message+=fullFileName;                       68       message+=fullFileName;
 67       message+="\" not found";                     69       message+="\" not found";
 68       G4Exception("G4MicroElecCrossSectionData     70       G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0003",
 69                       FatalException,message);     71                       FatalException,message);
 70       return false;                                72       return false;
 71     }                                              73     }
 72                                                    74 
 73   std::vector<G4DataVector *> columns;             75   std::vector<G4DataVector *> columns;
 74   std::vector<G4DataVector *> log_columns;         76   std::vector<G4DataVector *> log_columns;
 75                                                    77 
 76   std::stringstream *stream(new std::stringstr     78   std::stringstream *stream(new std::stringstream);
 77   char c;                                          79   char c;
 78   G4bool comment(false);                           80   G4bool comment(false);
 79   G4bool space(true);                              81   G4bool space(true);
 80   G4bool first(true);                              82   G4bool first(true);
 81                                                    83 
 82   try                                              84   try
 83     {                                              85     {
 84       while (!in.eof())                            86       while (!in.eof())
 85   {                                                87   {
 86     in.get(c);                                     88     in.get(c);
 87                                                    89    
 88     switch (c)                                     90     switch (c)
 89       {                                            91       {
 90       case '\r':                                   92       case '\r':
 91       case '\n':                                   93       case '\n':
 92         if (!first)                                94         if (!first)
 93     {                                              95     {
 94       unsigned long i(0);                          96       unsigned long i(0);
 95       G4double value;                              97       G4double value;
 96                                                    98       
 97       while (!stream->eof())                       99       while (!stream->eof())
 98         {                                         100         {
 99           (*stream) >> value;                     101           (*stream) >> value;
100                                                   102        
101           while (i>=columns.size())               103           while (i>=columns.size())
102                         {                         104                         {
103        columns.push_back(new G4DataVector);       105        columns.push_back(new G4DataVector);
104                          log_columns.push_back    106                          log_columns.push_back(new G4DataVector);
105                         }                         107                         }
106                                                   108       
107           columns[i]->push_back(value);           109           columns[i]->push_back(value);
108           // N. A. Karakatsanis                << 110 
109           // A condition is applied to check i << 111 // N. A. Karakatsanis
110           // If yes, then a near-zero value is << 112 // A condition is applied to check if negative or zero values are present in the dataset.
111           // If a value is zero, this simplifi << 113 // If yes, then a near-zero value is applied to allow the computation of the logarithmic value
112           // If a value is negative, then it i << 114 // If a value is zero, this simplification is acceptable
113           // logarithmic values should not be  << 115 // If a value is negative, then it is not acceptable and the data of the particular column of
114           //                                   << 116 // logarithmic values should not be used by interpolation methods.
115           // Therefore, G4LogLogInterpolation  << 117 //
116           // Instead, G4LinInterpolation is sa << 118 // Therefore, G4LogLogInterpolation and G4LinLogLogInterpolation should not be used if negative values are present.
117           // SemiLogInterpolation is safe only << 119 // Instead, G4LinInterpolation is safe in every case
118           // G4LinLogInterpolation is safe onl << 120 // SemiLogInterpolation is safe only if the energy columns are non-negative
                                                   >> 121 // G4LinLogInterpolation is safe only if the cross section data columns are non-negative
119                                                   122 
120                       if (value <=0.) value =     123                       if (value <=0.) value = 1e-300;
121                       log_columns[i]->push_bac    124                       log_columns[i]->push_back(std::log10(value));
122                                                   125        
123           ++i;                                 << 126           i++;
124         }                                      << 127         }
                                                   >> 128       
125       delete stream;                              129       delete stream;
126       stream=new std::stringstream;               130       stream=new std::stringstream;
127     }                                             131     }
128       first=true;                              << 132      
129       comment=false;                           << 133         first=true;
130       space=true;                              << 134         comment=false;
131       break;                                   << 135         space=true;
132                                                << 136         break;
                                                   >> 137      
133       case '#':                                   138       case '#':
134         comment=true;                             139         comment=true;
135         break;                                 << 140         break;
                                                   >> 141      
136       case '\t':                                  142       case '\t':
                                                   >> 143         c=' ';
137       case ' ':                                   144       case ' ':
138         space = true;                          << 145         if (space)
139       break;                                   << 146     break;
140       default:                                    147       default:
141         if (comment) { break; }                << 148         if (comment)
142         if (space && (!first)) { (*stream) <<  << 149     break;
143         first=false;                           << 150      
144         (*stream) << c;                        << 151         if (c==' ')
145         space=false;                           << 152     space=true;
                                                   >> 153         else
                                                   >> 154     {
                                                   >> 155       if (space && (!first))
                                                   >> 156         (*stream) << ' ';
                                                   >> 157       
                                                   >> 158       first=false;
                                                   >> 159       (*stream) << c;
                                                   >> 160       space=false;
                                                   >> 161     }
146       }                                           162       }
147   }                                               163   }
148     }                                             164     }
149   catch(const std::ios::failure &e)               165   catch(const std::ios::failure &e)
150     {                                             166     {
151       // some implementations of STL could thr    167       // some implementations of STL could throw a "failture" exception
152       // when read wants read characters after    168       // when read wants read characters after end of file
153     }                                             169     }
154                                                   170  
155   delete stream;                                  171   delete stream;
156                                                   172  
157   std::size_t maxI(columns.size());            << 173   std::vector<G4DataVector *>::size_type maxI(columns.size());
158                                                   174  
159   if (maxI<2)                                     175   if (maxI<2)
160     {                                             176     {
161       G4String message("Data file \"");           177       G4String message("Data file \"");
162       message+=fullFileName;                      178       message+=fullFileName;
163       message+="\" should have at least two co    179       message+="\" should have at least two columns";
164       G4Exception("G4MicroElecCrossSectionData    180       G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
165                       FatalException,message);    181                       FatalException,message);
166       return false;                               182       return false;
167     }                                             183     }
168                                                   184  
169   std::size_t i(1);                            << 185   std::vector<G4DataVector*>::size_type i(1);
170   while (i<maxI)                                  186   while (i<maxI)
171     {                                             187     {
172       std::size_t maxJ(columns[i]->size());    << 188       G4DataVector::size_type maxJ(columns[i]->size());
173                                                   189 
174       if (maxJ!=columns[0]->size())               190       if (maxJ!=columns[0]->size())
175   {                                               191   {
176     G4String message("Data file \"");             192     G4String message("Data file \"");
177     message+=fullFileName;                        193     message+=fullFileName;
178     message+="\" has lines with a different nu    194     message+="\" has lines with a different number of columns";
179     G4Exception("G4MicroElecCrossSectionDataSe    195     G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
180                       FatalException,message);    196                       FatalException,message);
181     return false;                                 197     return false;
182   }                                               198   }
183                                                   199 
184       std::size_t j(0);                        << 200       G4DataVector::size_type j(0);
185                                                << 201 
186       G4DataVector *argEnergies=new G4DataVect    202       G4DataVector *argEnergies=new G4DataVector;
187       G4DataVector *argData=new G4DataVector;     203       G4DataVector *argData=new G4DataVector;
188       G4DataVector *argLogEnergies=new G4DataV    204       G4DataVector *argLogEnergies=new G4DataVector;
189       G4DataVector *argLogData=new G4DataVecto    205       G4DataVector *argLogData=new G4DataVector;
190                                                << 206 
191       while(j<maxJ)                               207       while(j<maxJ)
192   {                                               208   {
193     argEnergies->push_back(columns[0]->operato    209     argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
194     argData->push_back(columns[i]->operator[]     210     argData->push_back(columns[i]->operator[] (j)*GetUnitData());
195     argLogEnergies->push_back(log_columns[0]->    211     argLogEnergies->push_back(log_columns[0]->operator[] (j) + std::log10(GetUnitEnergies()));
196     argLogData->push_back(log_columns[i]->oper    212     argLogData->push_back(log_columns[i]->operator[] (j) + std::log10(GetUnitData()));
197     j++;                                          213     j++;
198   }                                               214   }
199                                                << 215 
200       AddComponent(new G4EMDataSet(G4int(i-1), << 216       AddComponent(new G4EMDataSet(i-1, argEnergies, argData, argLogEnergies, argLogData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
201            GetAlgorithm()->Clone(), GetUnitEne << 
202                                                   217   
203       ++i;                                     << 218       i++;
204     }                                             219     }
205                                                   220 
206   i=maxI;                                         221   i=maxI;
207   while (i>0)                                     222   while (i>0)
208     {                                             223     {
209       --i;                                     << 224       i--;
210       delete columns[i];                          225       delete columns[i];
211       delete log_columns[i];                      226       delete log_columns[i];
212     }                                             227     }
213                                                   228 
214   return true;                                    229   return true;
215 }                                                 230 }
216                                                   231 
217 //....oooOO0OOooo........oooOO0OOooo........oo << 
218                                                   232 
219 G4bool G4MicroElecCrossSectionDataSet::LoadNon    233 G4bool G4MicroElecCrossSectionDataSet::LoadNonLogData(const G4String & argFileName)
220 {                                                 234 {
221   CleanUpComponents();                            235   CleanUpComponents();
222                                                   236 
223   G4String fullFileName(FullFileName(argFileNa    237   G4String fullFileName(FullFileName(argFileName));
224   std::ifstream in(fullFileName, std::ifstream    238   std::ifstream in(fullFileName, std::ifstream::binary|std::ifstream::in);
225                                                   239 
226   if (!in.is_open())                              240   if (!in.is_open())
227     {                                             241     {
228       G4String message("Data file \"");           242       G4String message("Data file \"");
229       message+=fullFileName;                      243       message+=fullFileName;
230       message+="\" not found";                    244       message+="\" not found";
231       G4Exception("G4MicroElecCrossSectionData    245       G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0003",
232                       FatalException,message);    246                       FatalException,message);
233       return false;                               247       return false;
234     }                                             248     }
235                                                   249 
236   std::vector<G4DataVector *> columns;            250   std::vector<G4DataVector *> columns;
237                                                   251 
238   std::stringstream *stream(new std::stringstr    252   std::stringstream *stream(new std::stringstream);
239   char c;                                         253   char c;
240   G4bool comment(false);                          254   G4bool comment(false);
241   G4bool space(true);                             255   G4bool space(true);
242   G4bool first(true);                             256   G4bool first(true);
243                                                   257 
244   try                                             258   try
245     {                                             259     {
246       while (!in.eof())                           260       while (!in.eof())
247   {                                               261   {
248     in.get(c);                                    262     in.get(c);
249                                                   263    
250     switch (c)                                    264     switch (c)
251       {                                           265       {
252       case '\r':                                  266       case '\r':
253       case '\n':                                  267       case '\n':
254         if (!first)                               268         if (!first)
255     {                                             269     {
256       unsigned long i(0);                         270       unsigned long i(0);
257       G4double value;                             271       G4double value;
258                                                   272       
259       while (!stream->eof())                      273       while (!stream->eof())
260         {                                         274         {
261           (*stream) >> value;                     275           (*stream) >> value;
262                                                   276        
263           while (i>=columns.size())               277           while (i>=columns.size())
264                         {                         278                         {
265        columns.push_back(new G4DataVector);       279        columns.push_back(new G4DataVector);
266                         }                         280                         }
267                                                   281       
268           columns[i]->push_back(value);           282           columns[i]->push_back(value);
269                                                   283        
270           i++;                                    284           i++;
271         }                                         285         }
272                                                   286       
273       delete stream;                              287       delete stream;
274       stream=new std::stringstream;               288       stream=new std::stringstream;
275     }                                             289     }
276                                                   290      
277         first=true;                               291         first=true;
278         comment=false;                            292         comment=false;
279         space=true;                               293         space=true;
280         break;                                    294         break;
281                                                   295      
282       case '#':                                   296       case '#':
283         comment=true;                             297         comment=true;
284         break;                                    298         break;
285                                                   299      
286       case '\t':                                  300       case '\t':
                                                   >> 301         c=' ';
287       case ' ':                                   302       case ' ':
288         space = true;                          << 303         if (space)
289               break;                           << 304     break;
290                                                << 
291       default:                                    305       default:
292         if (comment) { break; }                << 306         if (comment)
293         if (space && (!first)) { (*stream) <<  << 307     break;
294                                                << 308      
295         first=false;                           << 309         if (c==' ')
296         (*stream) << c;                        << 310     space=true;
297         space=false;                           << 311         else
                                                   >> 312     {
                                                   >> 313       if (space && (!first))
                                                   >> 314         (*stream) << ' ';
                                                   >> 315       
                                                   >> 316       first=false;
                                                   >> 317       (*stream) << c;
                                                   >> 318       space=false;
                                                   >> 319     }
298       }                                           320       }
299   }                                               321   }
300     }                                             322     }
301   catch(const std::ios::failure &e)               323   catch(const std::ios::failure &e)
302     {                                             324     {
303       // some implementations of STL could thr    325       // some implementations of STL could throw a "failture" exception
304       // when read wants read characters after    326       // when read wants read characters after end of file
305     }                                             327     }
306                                                   328  
307   delete stream;                                  329   delete stream;
308                                                   330  
309   std::size_t maxI(columns.size());            << 331   std::vector<G4DataVector *>::size_type maxI(columns.size());
310                                                   332  
311   if (maxI<2)                                     333   if (maxI<2)
312     {                                             334     {
313       G4String message("Data file \"");           335       G4String message("Data file \"");
314       message+=fullFileName;                      336       message+=fullFileName;
315       message+="\" should have at least two co    337       message+="\" should have at least two columns";
316       G4Exception("G4MicroElecCrossSectionData    338       G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
317                       FatalException,message);    339                       FatalException,message);
318       return false;                               340       return false;
319     }                                             341     }
320                                                   342  
321   std::size_t i(1);                            << 343   std::vector<G4DataVector*>::size_type i(1);
322   while (i<maxI)                                  344   while (i<maxI)
323     {                                             345     {
324       std::size_t maxJ(columns[i]->size());    << 346       G4DataVector::size_type maxJ(columns[i]->size());
325                                                   347 
326       if (maxJ!=columns[0]->size())               348       if (maxJ!=columns[0]->size())
327   {                                               349   {
328     G4String message("Data file \"");             350     G4String message("Data file \"");
329     message+=fullFileName;                        351     message+=fullFileName;
330     message+="\" has lines with a different nu    352     message+="\" has lines with a different number of columns.";
331           G4Exception("G4MicroElecCrossSection    353           G4Exception("G4MicroElecCrossSectionDataSet::LoadData","em0005",
332                       FatalException,message);    354                       FatalException,message);
333     return false;                                 355     return false;
334   }                                               356   }
335                                                   357 
336       std::size_t j(0);                        << 358       G4DataVector::size_type j(0);
337                                                   359 
338       G4DataVector *argEnergies=new G4DataVect    360       G4DataVector *argEnergies=new G4DataVector;
339       G4DataVector *argData=new G4DataVector;     361       G4DataVector *argData=new G4DataVector;
340                                                   362 
341       while(j<maxJ)                               363       while(j<maxJ)
342   {                                               364   {
343     argEnergies->push_back(columns[0]->operato    365     argEnergies->push_back(columns[0]->operator[] (j)*GetUnitEnergies());
344     argData->push_back(columns[i]->operator[]     366     argData->push_back(columns[i]->operator[] (j)*GetUnitData());
345     j++;                                          367     j++;
346   }                                               368   }
347                                                   369 
348       AddComponent(new G4EMDataSet(G4int(i-1), << 370       AddComponent(new G4EMDataSet(i-1, argEnergies, argData, GetAlgorithm()->Clone(), GetUnitEnergies(), GetUnitData()));
349                                                   371   
350       i++;                                        372       i++;
351     }                                             373     }
352                                                   374 
353   i=maxI;                                         375   i=maxI;
354   while (i>0)                                     376   while (i>0)
355     {                                             377     {
356       i--;                                        378       i--;
357       delete columns[i];                          379       delete columns[i];
358     }                                             380     }
359                                                   381 
360   return true;                                    382   return true;
361 }                                                 383 }
362                                                   384 
363 //....oooOO0OOooo........oooOO0OOooo........oo << 
364                                                   385 
365 G4bool G4MicroElecCrossSectionDataSet::SaveDat    386 G4bool G4MicroElecCrossSectionDataSet::SaveData(const G4String & argFileName) const
366 {                                                 387 {
367   const std::size_t n(NumberOfComponents());   << 388   const size_t n(NumberOfComponents());
                                                   >> 389  
368   if (n==0)                                       390   if (n==0)
369     {                                             391     {
370       G4Exception("G4MicroElecCrossSectionData    392       G4Exception("G4MicroElecCrossSectionDataSet::SaveData","em0005",
371                       FatalException,"Expected    393                       FatalException,"Expected at least one component");
372                                                   394 
373       return false;                               395       return false;
374     }                                             396     }
375                                                   397  
376   G4String fullFileName(FullFileName(argFileNa    398   G4String fullFileName(FullFileName(argFileName));
377   std::ofstream out(fullFileName);                399   std::ofstream out(fullFileName);
378                                                   400 
379   if (!out.is_open())                             401   if (!out.is_open())
380     {                                             402     {
381       G4String message("Cannot open \"");         403       G4String message("Cannot open \"");
382       message+=fullFileName;                      404       message+=fullFileName;
383       message+="\"";                              405       message+="\"";
384       G4Exception("G4MicroElecCrossSectionData    406       G4Exception("G4MicroElecCrossSectionDataSet::SaveData","em0005",
385                       FatalException,message);    407                       FatalException,message);
386       return false;                               408       return false;
387     }                                             409     }
388                                                   410  
389   G4DataVector::const_iterator iEnergies(GetCo    411   G4DataVector::const_iterator iEnergies(GetComponent(0)->GetEnergies(0).begin());
390   G4DataVector::const_iterator iEnergiesEnd(Ge    412   G4DataVector::const_iterator iEnergiesEnd(GetComponent(0)->GetEnergies(0).end());
391   G4DataVector::const_iterator * iData(new G4D    413   G4DataVector::const_iterator * iData(new G4DataVector::const_iterator[n]);
392                                                   414  
393   std::size_t k(n);                            << 415   size_t k(n);
394                                                   416  
395   while (k>0)                                     417   while (k>0)
396     {                                             418     {
397       k--;                                        419       k--;
398       iData[k]=GetComponent((G4int)k)->GetData << 420       iData[k]=GetComponent(k)->GetData(0).begin();
399     }                                             421     }
400                                                   422  
401   while (iEnergies!=iEnergiesEnd)                 423   while (iEnergies!=iEnergiesEnd)
402     {                                             424     {
403       out.precision(10);                          425       out.precision(10);
404       out.width(15);                              426       out.width(15);
405       out.setf(std::ofstream::left);              427       out.setf(std::ofstream::left);
406       out << ((*iEnergies)/GetUnitEnergies());    428       out << ((*iEnergies)/GetUnitEnergies());
407                                                   429   
408       k=0;                                        430       k=0;
409                                                   431   
410       while (k<n)                                 432       while (k<n)
411   {                                               433   {
412     out << ' ';                                   434     out << ' ';
413     out.precision(10);                            435     out.precision(10);
414     out.width(15);                                436     out.width(15);
415     out.setf(std::ofstream::left);                437     out.setf(std::ofstream::left);
416     out << ((*(iData[k]))/GetUnitData());         438     out << ((*(iData[k]))/GetUnitData());
417                                                   439 
418     iData[k]++;                                   440     iData[k]++;
419     k++;                                          441     k++;
420   }                                               442   }
421       out << std::endl;                        << 443   
                                                   >> 444       out << std::endl;
                                                   >> 445   
422       iEnergies++;                                446       iEnergies++;
423     }                                             447     }
                                                   >> 448  
424   delete[] iData;                                 449   delete[] iData;
425                                                   450 
426   return true;                                    451   return true;
427 }                                                 452 }
428                                                   453 
429 //....oooOO0OOooo........oooOO0OOooo........oo << 
430                                                   454 
431 G4String G4MicroElecCrossSectionDataSet::FullF    455 G4String G4MicroElecCrossSectionDataSet::FullFileName(const G4String& argFileName) const
432 {                                                 456 {
433   const char* path = G4FindDataDir("G4LEDATA") << 457   char* path = getenv("G4LEDATA");
434   if (!path)                                      458   if (!path)
435   {                                               459   {
436       G4Exception("G4MicroElecCrossSectionData    460       G4Exception("G4MicroElecCrossSectionDataSet::FullFileName","em0006",
437                       FatalException,"G4LEDATA    461                       FatalException,"G4LEDATA environment variable not set.");
438                                                   462       
439       return "";                                  463       return "";
440   }                                               464   }
441                                                   465   
442   std::ostringstream fullFileName;                466   std::ostringstream fullFileName;
443                                                   467  
444   fullFileName << path << "/" << argFileName <    468   fullFileName << path << "/" << argFileName << ".dat";
445                                                   469                       
446   return G4String(fullFileName.str().c_str());    470   return G4String(fullFileName.str().c_str());
447 }                                                 471 }
448                                                   472 
449 //....oooOO0OOooo........oooOO0OOooo........oo << 
450                                                   473 
451 G4double G4MicroElecCrossSectionDataSet::FindV    474 G4double G4MicroElecCrossSectionDataSet::FindValue(G4double argEnergy, G4int /* argComponentId */) const
452 {                                                 475 {
453   // Returns the sum over the shells correspon    476   // Returns the sum over the shells corresponding to e
454   G4double value = 0.;                            477   G4double value = 0.;
455                                                   478 
456   std::vector<G4VEMDataSet *>::const_iterator     479   std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
457   std::vector<G4VEMDataSet *>::const_iterator     480   std::vector<G4VEMDataSet *>::const_iterator end(components.end());
458                                                   481 
459   while (i!=end)                                  482   while (i!=end)
460     {                                             483     {
461       value+=(*i)->FindValue(argEnergy);          484       value+=(*i)->FindValue(argEnergy);
462       i++;                                        485       i++;
463     }                                             486     }
464                                                   487 
465   return value;                                   488   return value;
466 }                                                 489 }
467                                                   490 
468 //....oooOO0OOooo........oooOO0OOooo........oo << 
469                                                   491 
470 void G4MicroElecCrossSectionDataSet::PrintData    492 void G4MicroElecCrossSectionDataSet::PrintData(void) const
471 {                                                 493 {
472   const std::size_t n(NumberOfComponents());   << 494   const size_t n(NumberOfComponents());
473                                                   495 
474   G4cout << "The data set has " << n << " comp    496   G4cout << "The data set has " << n << " components" << G4endl;
475   G4cout << G4endl;                               497   G4cout << G4endl;
476                                                   498  
477   G4int i(0);                                  << 499   size_t i(0);
478                                                   500  
479   while (i<(G4int)n)                           << 501   while (i<n)
480     {                                             502     {
481       G4cout << "--- Component " << i << " ---    503       G4cout << "--- Component " << i << " ---" << G4endl;
482       GetComponent(i)->PrintData();               504       GetComponent(i)->PrintData();
483       i++;                                        505       i++;
484     }                                             506     }
485 }                                                 507 }
486                                                   508 
487 //....oooOO0OOooo........oooOO0OOooo........oo << 
488                                                   509 
489 void G4MicroElecCrossSectionDataSet::SetEnergi    510 void G4MicroElecCrossSectionDataSet::SetEnergiesData(G4DataVector* argEnergies, 
490            G4DataVector* argData,                 511            G4DataVector* argData, 
491            G4int argComponentId)                  512            G4int argComponentId)
492 {                                                 513 {
493   G4VEMDataSet * component(components[argCompo    514   G4VEMDataSet * component(components[argComponentId]);
494                                                   515  
495   if (component)                                  516   if (component)
496     {                                             517     {
497       component->SetEnergiesData(argEnergies,     518       component->SetEnergiesData(argEnergies, argData, 0);
498       return;                                     519       return;
499     }                                             520     }
500                                                   521 
501   std::ostringstream message;                     522   std::ostringstream message;
502   message << "Component " << argComponentId <<    523   message << "Component " << argComponentId << " not found";
503                                                   524  
504   G4Exception("G4MicroElecCrossSectionDataSet:    525   G4Exception("G4MicroElecCrossSectionDataSet::SetEnergiesData","em0005",
505                  FatalException,message.str().    526                  FatalException,message.str().c_str());
506                                                   527   
507 }                                                 528 }
508                                                   529 
509 //....oooOO0OOooo........oooOO0OOooo........oo << 
510                                                   530 
511 void G4MicroElecCrossSectionDataSet::SetLogEne    531 void G4MicroElecCrossSectionDataSet::SetLogEnergiesData(G4DataVector* argEnergies, 
512            G4DataVector* argData,                 532            G4DataVector* argData,
513                                          G4Dat    533                                          G4DataVector* argLogEnergies,
514                                          G4Dat    534                                          G4DataVector* argLogData, 
515            G4int argComponentId)                  535            G4int argComponentId)
516 {                                                 536 {
517   G4VEMDataSet * component(components[argCompo    537   G4VEMDataSet * component(components[argComponentId]);
518                                                   538  
519   if (component)                                  539   if (component)
520     {                                             540     {
521       component->SetLogEnergiesData(argEnergie    541       component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
522       return;                                     542       return;
523     }                                             543     }
524                                                   544 
525   std::ostringstream message;                     545   std::ostringstream message;
526   message << "Component " << argComponentId <<    546   message << "Component " << argComponentId << " not found";
527                                                   547  
528   G4Exception("G4MicroElecCrossSectionDataSet:    548   G4Exception("G4MicroElecCrossSectionDataSet::SetLogEnergiesData","em0005",
529                  FatalException,message.str().    549                  FatalException,message.str().c_str());
530                                                   550 
531 }                                                 551 }
532                                                   552 
533 //....oooOO0OOooo........oooOO0OOooo........oo << 
534                                                   553 
535 void G4MicroElecCrossSectionDataSet::CleanUpCo    554 void G4MicroElecCrossSectionDataSet::CleanUpComponents()
536 {                                                 555 {
537   while (!components.empty())                     556   while (!components.empty())
538     {                                             557     {
539       if (components.back()) delete components    558       if (components.back()) delete components.back();
540       components.pop_back();                      559       components.pop_back();
541     }                                             560     }
542 }                                                 561 }
543                                                   562 
544                                                   563 
545                                                   564