Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/utils/src/G4DNACrossSectionDataSet.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/dna/utils/src/G4DNACrossSectionDataSet.cc (Version 11.3.0) and /processes/electromagnetic/dna/utils/src/G4DNACrossSectionDataSet.cc (Version 10.0.p2)


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