Ignore:
Timestamp:
Apr 6, 2009, 12:21:12 PM (15 years ago)
Author:
garnier
Message:

update processes

File:
1 edited

Legend:

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

    r819 r961  
    2525//
    2626//
    27 // $Id: G4ShellEMDataSet.cc,v 1.15 2007/10/15 08:36:35 pia Exp $
    28 // GEANT4 tag $Name: geant4-09-01-patch-02 $
     27// $Id: G4ShellEMDataSet.cc,v 1.16 2008/03/10 15:07:41 pia Exp $
     28// GEANT4 tag $Name: geant4-09-02-ref-02 $
    2929//
    3030// Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
     
    3232// History:
    3333// -----------
    34 // 1 Aug 2001   MGP        Created
     34//  1 Aug 2001   MGP        Created
    3535// 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)
    3638//
    3739// -------------------------------------------------------------------
     
    4446
    4547
    46 G4ShellEMDataSet::G4ShellEMDataSet(G4int argZ, G4VDataSetAlgorithm* argAlgorithm,
    47                                    G4double argUnitEnergies,
    48                                    G4double argUnitData)
     48G4ShellEMDataSet::G4ShellEMDataSet(G4int zeta, G4VDataSetAlgorithm* algo,
     49                                   G4double eUnit,
     50                                   G4double dataUnit)
    4951  :
    50   z(argZ),
    51   algorithm(argAlgorithm),
    52   unitEnergies(argUnitEnergies),
    53   unitData(argUnitData)
    54 {
    55   if (algorithm == 0)
    56     G4Exception("G4ShellEMDataSet::G4ShellEMDataSet - interpolation == 0");
     52  z(zeta),
     53  algorithm(algo),
     54  unitEnergies(eUnit),
     55  unitData(dataUnit)
     56{
     57  if (algorithm == 0) G4Exception("G4ShellEMDataSet::G4ShellEMDataSet - interpolation == 0");
    5758}
    5859
     
    6162{
    6263  CleanUpComponents();
    63  
    64   if (algorithm)
    65     delete algorithm;
    66 }
    67 
    68 
    69 G4double G4ShellEMDataSet::FindValue(G4double argEnergy, G4int /* argComponentId */) const
     64  if (algorithm) delete algorithm;
     65}
     66
     67
     68G4double G4ShellEMDataSet::FindValue(G4double energy, G4int /* componentId */) const
    7069{
    7170  // Returns the sum over the shells corresponding to e
     
    7574  std::vector<G4VEMDataSet *>::const_iterator end(components.end());
    7675
    77   while (i!=end)
    78     {
    79       value+=(*i)->FindValue(argEnergy);
     76  while (i != end)
     77    {
     78      value += (*i)->FindValue(energy);
    8079      i++;
    8180    }
     
    8786void G4ShellEMDataSet::PrintData(void) const
    8887{
    89   const size_t n(NumberOfComponents());
     88  const size_t n = NumberOfComponents();
    9089
    9190  G4cout << "The data set has " << n << " components" << G4endl;
    9291  G4cout << G4endl;
    9392 
    94   size_t i(0);
    95  
    96   while (i<n)
     93  size_t i = 0;
     94 
     95  while (i < n)
    9796    {
    9897      G4cout << "--- Component " << i << " ---" << G4endl;
     
    103102
    104103
    105 void G4ShellEMDataSet :: SetEnergiesData(G4DataVector* argEnergies,
    106                                          G4DataVector* argData,
    107                                          G4int argComponentId)
    108 {
    109   G4VEMDataSet * component(components[argComponentId]);
     104void G4ShellEMDataSet::SetEnergiesData(G4DataVector* energies,
     105                                       G4DataVector* data,
     106                                       G4int componentId)
     107{
     108  G4VEMDataSet* component = components[componentId];
    110109 
    111110  if (component)
    112111    {
    113       component->SetEnergiesData(argEnergies, argData, 0);
     112      component->SetEnergiesData(energies, data, 0);
    114113      return;
    115114    }
    116115
    117116  std::ostringstream message;
    118   message << "G4ShellEMDataSet::SetEnergiesData - component " << argComponentId << " not found";
     117  message << "G4ShellEMDataSet::SetEnergiesData - component " << componentId << " not found";
    119118 
    120119  G4Exception(message.str().c_str());
     
    122121
    123122
    124 G4bool G4ShellEMDataSet::LoadData(const G4String& argFileName)
     123G4bool G4ShellEMDataSet::LoadData(const G4String& file)
    125124{
    126125  CleanUpComponents();
    127126
    128   G4String fullFileName(FullFileName(argFileName));
     127  G4String fullFileName = FullFileName(file);
    129128  std::ifstream in(fullFileName);
    130129
     
    132131    {
    133132      G4String message("G4ShellEMDataSet::LoadData - data file \"");
    134       message+=fullFileName;
    135       message+="\" not found";
     133      message += fullFileName;
     134      message += "\" not found";
    136135      G4Exception(message);
    137136    }
    138137
    139   G4DataVector* argEnergies(0);
    140   G4DataVector* argData(0);
    141 
    142   G4double a;
    143   G4int shellIndex(0);
    144   bool energyColumn(true);
     138  G4DataVector* energies = 0;
     139  G4DataVector* data = 0;
     140
     141  G4double a = 0.;
     142  G4int shellIndex = 0;
     143  bool energyColumn = true;
    145144
    146145  do
     
    150149      if (a == -1)
    151150        {
    152           if (energyColumn && argEnergies!=0)
     151          if (energyColumn && energies!=0)
    153152            {
    154               AddComponent(new G4EMDataSet(shellIndex, argEnergies, argData, algorithm->Clone(), unitEnergies, unitData));
    155               argEnergies=0;
    156               argData=0;
     153              AddComponent(new G4EMDataSet(shellIndex, energies, data, algorithm->Clone(), unitEnergies, unitData));
     154              energies = 0;
     155              data = 0;
    157156            }
    158157   
    159           energyColumn=(!energyColumn);
     158          energyColumn = (!energyColumn);
    160159        }
    161       else if (a!=-2)
     160      else if (a != -2)
    162161        {
    163           if (argEnergies==0)
     162          if (energies == 0)
    164163            {
    165               argEnergies=new G4DataVector;
    166               argData=new G4DataVector;
     164              energies = new G4DataVector;
     165              data = new G4DataVector;
    167166            }
    168167 
    169168          if (energyColumn)
    170             argEnergies->push_back(a*unitEnergies);
     169            energies->push_back(a * unitEnergies);
    171170          else
    172             argData->push_back(a*unitData);
    173 
    174           energyColumn=(!energyColumn);
     171            data->push_back(a * unitData);
     172
     173          energyColumn = (!energyColumn);
    175174        }
    176175    }
     
    181180
    182181
    183 G4bool G4ShellEMDataSet::SaveData(const G4String& argFileName) const
    184 {
    185   G4String fullFileName(FullFileName(argFileName));
     182G4bool G4ShellEMDataSet::SaveData(const G4String& file) const
     183{
     184  G4String fullFileName = FullFileName(file);
    186185  std::ofstream out(fullFileName);
    187186
     
    189188    {
    190189      G4String message("G4EMDataSet::SaveData - cannot open \"");
    191       message+=fullFileName;
    192       message+="\"";
     190      message += fullFileName;
     191      message += "\"";
    193192      G4Exception(message);
    194193    }
    195194 
    196   const size_t n(NumberOfComponents());
    197   size_t k(0);
    198  
    199   while (k<n)
    200     {
    201       const G4VEMDataSet * component=GetComponent(k);
     195  const size_t n = NumberOfComponents();
     196  size_t k = 0;
     197 
     198  while (k < n)
     199    {
     200      const G4VEMDataSet* component = GetComponent(k);
    202201 
    203202      if (component)
    204203        {
    205           const G4DataVector & energies(component->GetEnergies(0));
    206           const G4DataVector & data(component->GetData(0));
    207  
    208           G4DataVector::const_iterator i(energies.begin());
    209           G4DataVector::const_iterator endI(energies.end());
    210           G4DataVector::const_iterator j(data.begin());
    211  
    212           while (i!=endI)
     204          const G4DataVector& energies = component->GetEnergies(0);
     205          const G4DataVector& data = component->GetData(0);
     206 
     207          G4DataVector::const_iterator i = energies.begin();
     208          G4DataVector::const_iterator endI = energies.end();
     209          G4DataVector::const_iterator j = data.begin();
     210 
     211          while (i != endI)
    213212            {
    214213              out.precision(10);
     
    253252
    254253
    255 
    256 
    257 
    258254void G4ShellEMDataSet::CleanUpComponents(void)
    259255{
    260256  while (!components.empty())
    261257    {
    262       if (components.back())
    263         delete components.back();
    264 
     258      if (components.back()) delete components.back();
    265259      components.pop_back();
    266260    }
     
    268262
    269263
    270 
    271 
    272 
    273 G4String G4ShellEMDataSet::FullFileName(const G4String & argFileName) const
     264G4String G4ShellEMDataSet::FullFileName(const G4String& fileName) const
    274265{
    275266  char* path = getenv("G4LEDATA");
     
    279270  std::ostringstream fullFileName;
    280271 
    281   fullFileName << path << '/' << argFileName << z << ".dat";
     272  fullFileName << path << '/' << fileName << z << ".dat";
    282273                     
    283274  return G4String(fullFileName.str().c_str());
Note: See TracChangeset for help on using the changeset viewer.