Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/lowenergy/src/G4MicroElecCrossSectionDataSet_new.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_new.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4MicroElecCrossSectionDataSet_new.cc (Version 10.7.p3)


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