Ignore:
Timestamp:
Nov 19, 2009, 2:53:25 PM (15 years ago)
Author:
garnier
Message:

update par rapport a CVS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/electromagnetic/lowenergy/src/G4ShellEMDataSet.cc

    r1007 r1192  
    2525//
    2626//
    27 // $Id: G4ShellEMDataSet.cc,v 1.16 2008/03/10 15:07:41 pia Exp $
    28 // GEANT4 tag $Name: geant4-09-02 $
     27// $Id: G4ShellEMDataSet.cc,v 1.18 2009/09/25 07:41:34 sincerti Exp $
     28// GEANT4 tag $Name: emlowen-V09-02-64 $
    2929//
    3030// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
     
    3232// History:
    3333// -----------
    34 //  1 Aug 2001   MGP        Created
    35 // 09.10.01   V.Ivanchenko Add case z=0
    36 //  9 Mar 2008   MGP        Cleaned up unreadable code modified by former developer
    37 //                          (Further clean-up needed)
     34//  1 Aug 2001   MGP         Created
     35//
     36//  09.10.01   V.Ivanchenko  Add case z=0
     37//
     38//  9 Mar 2008   MGP         Cleaned up unreadable code modified by former developer
     39//                           (Further clean-up needed)
     40//
     41//  15 Jul 2009   Nicolas A. Karakatsanis
     42//
     43//                           - LoadNonLogData method was created to load only the non-logarithmic data from G4EMLOW
     44//                             dataset. It is essentially performing the data loading operations as in the past.
     45//
     46//                           - LoadData method was revised in order to calculate the logarithmic values of the data
     47//                             It retrieves the data values from the G4EMLOW data files but, then, calculates the
     48//                             respective log values and loads them to seperate data structures.
     49//
     50//                           - SetLogEnergiesData method was cretaed to set logarithmic values to G4 data vectors.
     51//                             The EM data sets, initialized this way, contain both non-log and log values.
     52//                             These initialized data sets can enhance the computing performance of data interpolation
     53//                             operations
     54//
    3855//
    3956// -------------------------------------------------------------------
     
    121138
    122139
     140void G4ShellEMDataSet::SetLogEnergiesData(G4DataVector* energies,
     141                                          G4DataVector* data,
     142                                          G4DataVector* log_energies,
     143                                          G4DataVector* log_data,
     144                                          G4int componentId)
     145{
     146  G4VEMDataSet* component = components[componentId];
     147 
     148  if (component)
     149    {
     150      component->SetLogEnergiesData(energies, data, log_energies, log_data, 0);
     151      return;
     152    }
     153
     154  std::ostringstream message;
     155  message << "G4ShellEMDataSet::SetLogEnergiesData - component " << componentId << " not found";
     156 
     157  G4Exception(message.str().c_str());
     158}
     159
     160
     161
    123162G4bool G4ShellEMDataSet::LoadData(const G4String& file)
    124163{
     
    136175    }
    137176
    138   G4DataVector* energies = 0;
    139   G4DataVector* data = 0;
     177  G4DataVector* orig_shell_energies = 0;
     178  G4DataVector* orig_shell_data = 0;
     179  G4DataVector* log_shell_energies = 0;
     180  G4DataVector* log_shell_data = 0;
    140181
    141182  G4double a = 0.;
    142183  G4int shellIndex = 0;
    143   bool energyColumn = true;
     184  G4int k = 0;
     185  G4int nColumns = 2;
    144186
    145187  do
    146188    {
    147189      in >> a;
    148  
     190
     191      if (a==0.) a=1e-300;
     192
     193      // The file is organized into four columns:
     194      // 1st column contains the values of energy
     195      // 2nd column contains the corresponding data value
     196      // The file terminates with the pattern: -1   -1
     197      //                                       -2   -2
     198      //
    149199      if (a == -1)
    150200        {
    151           if (energyColumn && energies!=0)
     201          if ((k%nColumns == 0) && (orig_shell_energies != 0) )
    152202            {
    153               AddComponent(new G4EMDataSet(shellIndex, energies, data, algorithm->Clone(), unitEnergies, unitData));
    154               energies = 0;
    155               data = 0;
     203             AddComponent(new G4EMDataSet(shellIndex, orig_shell_energies, orig_shell_data, log_shell_energies, log_shell_data, algorithm->Clone(), unitEnergies, unitData));
     204              orig_shell_energies = 0;
     205              orig_shell_data = 0;
     206              log_shell_energies = 0;
     207              log_shell_data = 0;
    156208            }
    157    
    158           energyColumn = (!energyColumn);
    159209        }
    160210      else if (a != -2)
    161211        {
    162           if (energies == 0)
     212          if (orig_shell_energies == 0)
    163213            {
    164               energies = new G4DataVector;
    165               data = new G4DataVector;
     214             orig_shell_energies = new G4DataVector;
     215             orig_shell_data = new G4DataVector;
     216             log_shell_energies = new G4DataVector;
     217             log_shell_data = new G4DataVector;
    166218            }
    167  
    168           if (energyColumn)
    169             energies->push_back(a * unitEnergies);
    170           else
    171             data->push_back(a * unitData);
    172 
    173           energyColumn = (!energyColumn);
     219          if (k%nColumns == 0)
     220            {
     221             orig_shell_energies->push_back(a*unitEnergies);
     222             log_shell_energies->push_back(std::log10(a) + std::log10(unitEnergies));
     223            }
     224          else if (k%nColumns == 1)
     225            {
     226             orig_shell_data->push_back(a*unitData);
     227             log_shell_data->push_back(std::log10(a) + std::log10(unitData));
     228            }
     229          k++;
    174230        }
    175     }
    176   while (a != -2);
     231      else k = 1;
     232    }
     233  while (a != -2);  // End of file
    177234
    178235  return true;
    179236}
     237
     238
     239G4bool G4ShellEMDataSet::LoadNonLogData(const G4String& file)
     240{
     241  CleanUpComponents();
     242
     243  G4String fullFileName = FullFileName(file);
     244  std::ifstream in(fullFileName);
     245
     246  if (!in.is_open())
     247    {
     248      G4String message("G4ShellEMDataSet::LoadData - data file \"");
     249      message += fullFileName;
     250      message += "\" not found";
     251      G4Exception(message);
     252    }
     253
     254  G4DataVector* orig_shell_energies = 0;
     255  G4DataVector* orig_shell_data = 0;
     256
     257  G4double a = 0.;
     258  G4int shellIndex = 0;
     259  G4int k = 0;
     260  G4int nColumns = 2;
     261
     262  do
     263    {
     264      in >> a;
     265
     266      // The file is organized into four columns:
     267      // 1st column contains the values of energy
     268      // 2nd column contains the corresponding data value
     269      // The file terminates with the pattern: -1   -1
     270      //                                       -2   -2
     271      //
     272      if (a == -1)
     273        {
     274          if ((k%nColumns == 0) && (orig_shell_energies != 0) )
     275            {
     276             AddComponent(new G4EMDataSet(shellIndex, orig_shell_energies, orig_shell_data, algorithm->Clone(), unitEnergies, unitData));
     277              orig_shell_energies = 0;
     278              orig_shell_data = 0;
     279            }
     280        }
     281      else if (a != -2)
     282        {
     283          if (orig_shell_energies == 0)
     284            {
     285             orig_shell_energies = new G4DataVector;
     286             orig_shell_data = new G4DataVector;
     287            }
     288          if (k%nColumns == 0)
     289            {
     290             orig_shell_energies->push_back(a*unitEnergies);
     291            }
     292          else if (k%nColumns == 1)
     293            {
     294             orig_shell_data->push_back(a*unitData);
     295            }
     296          k++;
     297        }
     298      else k = 1;
     299    }
     300  while (a != -2);  // End of file
     301
     302  return true;
     303}
     304
    180305
    181306
Note: See TracChangeset for help on using the changeset viewer.