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3 ] [ 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/G4CompositeEMDataSet.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4CompositeEMDataSet.cc (Version 9.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4CompositeEMDataSet.cc,v 1.9 2006/06/29 19:38:46 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-08-03-patch-01 $
 27 //                                                 29 //
 28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@     30 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
 29 //                                                 31 //
 30 // History:                                        32 // History:
 31 // -----------                                     33 // -----------
 32 // 1 Aug 2001   MGP        Created                 34 // 1 Aug 2001   MGP        Created
 33 //                                                 35 //
 34 // 15 Jul 2009   Nicolas A. Karakatsanis       << 
 35 //                                             << 
 36 //                           - LoadNonLogData  << 
 37 //                             dataset. It is  << 
 38 //                                             << 
 39 //                           - LoadData method << 
 40 //                             It retrieves th << 
 41 //                             respective log  << 
 42 //                                             << 
 43 //                           - SetLogEnergiesD << 
 44 //                             The EM data set << 
 45 //                             These initializ << 
 46 //                             operations      << 
 47 //                                             << 
 48 // -------------------------------------------     36 // -------------------------------------------------------------------
 49                                                    37 
 50 #include "G4CompositeEMDataSet.hh"                 38 #include "G4CompositeEMDataSet.hh"
 51 #include "G4EMDataSet.hh"                          39 #include "G4EMDataSet.hh"
 52 #include "G4VDataSetAlgorithm.hh"                  40 #include "G4VDataSetAlgorithm.hh"
 53 #include <fstream>                                 41 #include <fstream>
 54 #include <sstream>                                 42 #include <sstream>
 55                                                    43 
 56 //....oooOO0OOooo........oooOO0OOooo........oo <<  44                                                 G4CompositeEMDataSet :: G4CompositeEMDataSet(G4VDataSetAlgorithm* argAlgorithm, G4double argUnitEnergies, G4double argUnitData, G4int argMinZ, G4int argMaxZ)
 57                                                <<  45 :
 58 G4CompositeEMDataSet::G4CompositeEMDataSet(G4V <<  46  algorithm(argAlgorithm),
 59              G4double argUnitEnergies,         <<  47  unitEnergies(argUnitEnergies),
 60              G4double argUnitData,             <<  48  unitData(argUnitData),
 61              G4int argMinZ,                    <<  49  minZ(argMinZ),
 62              G4int argMaxZ)                    <<  50  maxZ(argMaxZ)
 63   :                                            << 
 64   algorithm(argAlgorithm),                     << 
 65   unitEnergies(argUnitEnergies),               << 
 66   unitData(argUnitData),                       << 
 67   minZ(argMinZ),                               << 
 68   maxZ(argMaxZ)                                << 
 69 {                                                  51 {
 70   if (algorithm == nullptr)                    <<  52  if (algorithm == 0) 
 71   G4Exception("G4CompositeEMDataSet::G4Composi <<  53   G4Exception("G4CompositeEMDataSet::G4CompositeEMDataSet - interpolation == 0");
 72         "em1003",FatalException,"interpolation << 
 73                                                << 
 74 }                                                  54 }
 75                                                    55 
 76 //....oooOO0OOooo........oooOO0OOooo........oo << 
 77                                                    56 
 78 G4CompositeEMDataSet::~G4CompositeEMDataSet()  <<  57 
                                                   >>  58                                                 G4CompositeEMDataSet :: ~G4CompositeEMDataSet()
 79 {                                                  59 {
 80   CleanUpComponents();                         <<  60  CleanUpComponents();
 81   if (algorithm) delete algorithm;             <<  61 
                                                   >>  62  if (algorithm)
                                                   >>  63   delete algorithm;
 82 }                                                  64 }
 83 //....oooOO0OOooo........oooOO0OOooo........oo << 
 84                                                    65 
 85 G4double G4CompositeEMDataSet::FindValue(G4dou <<  66 
                                                   >>  67 
                                                   >>  68 
                                                   >>  69 
                                                   >>  70 
                                                   >>  71 G4double                                        G4CompositeEMDataSet :: FindValue(G4double argEnergy, G4int argComponentId) const
 86 {                                                  72 {
 87   const G4VEMDataSet* component(GetComponent(a <<  73  const G4VEMDataSet * component(GetComponent(argComponentId));
 88                                                    74  
 89   if (component) return component->FindValue(a <<  75  if (component)
                                                   >>  76   return component->FindValue(argEnergy);
 90                                                    77 
 91   std::ostringstream message;                  <<  78  std::ostringstream message;
 92   message << "G4CompositeEMDataSet::FindValue  <<  79  message << "G4CompositeEMDataSet::FindValue - component " << argComponentId << " not found";
 93                                                    80  
 94   G4Exception("G4CompositeEMDataSet::FindValue <<  81  G4Exception(message.str().c_str());
 95         "em1004",FatalException,message.str(). << 
 96                                                    82  
 97   return 0.;                                   <<  83  return 0.;
 98 }                                                  84 }
 99                                                    85 
100 //....oooOO0OOooo........oooOO0OOooo........oo << 
101                                                    86 
102 void G4CompositeEMDataSet::PrintData(void) con <<  87 
                                                   >>  88 
                                                   >>  89 
                                                   >>  90 void                                            G4CompositeEMDataSet :: PrintData(void) const
103 {                                                  91 {
104   const G4int n = (G4int)NumberOfComponents(); <<  92  const size_t n(NumberOfComponents());
105                                                    93 
106   G4cout << "The data set has " << n << " comp <<  94  G4cout << "The data set has " << n << " components" << G4endl;
107   G4cout << G4endl;                            <<  95  G4cout << G4endl;
108                                                    96  
109   G4int i(0);                                  <<  97  size_t i(0);
110                                                    98  
111   while (i<n)                                  <<  99  while (i<n)
112     {                                          << 100  {
113       G4cout << "--- Component " << i << " --- << 101   G4cout << "--- Component " << i << " ---" << G4endl;
114       GetComponent(i)->PrintData();            << 102   GetComponent(i)->PrintData();
115       ++i;                                     << 103   i++;
116     }                                          << 104  }
117 }                                                 105 }
118                                                   106 
119 //....oooOO0OOooo........oooOO0OOooo........oo << 
120                                                   107 
121 void G4CompositeEMDataSet::SetEnergiesData(G4D << 
122 {                                              << 
123   G4VEMDataSet * component(components[argCompo << 
124                                                << 
125   if (component)                               << 
126     {                                          << 
127       component->SetEnergiesData(argEnergies,  << 
128       return;                                  << 
129     }                                          << 
130                                                   108 
131   std::ostringstream message;                  << 
132   message << "G4CompositeEMDataSet::SetEnergie << 
133                                                << 
134   G4Exception("G4CompositeEMDataSet::SetEnergi << 
135         "em1004",FatalException,message.str(). << 
136 }                                              << 
137                                                   109 
138 //....oooOO0OOooo........oooOO0OOooo........oo << 
139                                                   110 
140 void G4CompositeEMDataSet::SetLogEnergiesData( << 111 void                                            G4CompositeEMDataSet :: SetEnergiesData(G4DataVector * argEnergies, G4DataVector * argData, G4int argComponentId)
141                                                << 
142                                                << 
143                                                << 
144                                                << 
145 {                                                 112 {
146   G4VEMDataSet * component(components[argCompo << 113  G4VEMDataSet * component(components[argComponentId]);
147                                                   114  
148   if (component)                               << 115  if (component)
149     {                                          << 116  {
150       component->SetLogEnergiesData(argEnergie << 117   component->SetEnergiesData(argEnergies, argData, 0);
151       return;                                  << 118   return;
152     }                                          << 119  }
153                                                   120 
154   std::ostringstream message;                  << 121  std::ostringstream message;
155   message << "G4CompositeEMDataSet::SetEnergie << 122  message << "G4CompositeEMDataSet::SetEnergiesData - component " << argComponentId << " not found";
156                                                   123  
157   G4Exception("G4CompositeEMDataSet::SetLogEne << 124  G4Exception(message.str().c_str());
158         "em1004",FatalException,message.str(). << 
159 }                                                 125 }
160                                                   126 
161 //....oooOO0OOooo........oooOO0OOooo........oo << 
162                                                   127 
163 G4bool G4CompositeEMDataSet::LoadData(const G4 << 
164 {                                              << 
165   CleanUpComponents();                         << 
166                                                   128 
167   for (G4int z(minZ); z<maxZ; ++z)             << 
168     {                                          << 
169       G4VEMDataSet* component = new G4EMDataSe << 
170       if (!component->LoadData(argFileName))   << 
171   {                                            << 
172     delete component;                          << 
173     return false;                              << 
174   }                                            << 
175       AddComponent(component);                 << 
176     }                                          << 
177   return true;                                 << 
178 }                                              << 
179                                                   129 
180 //....oooOO0OOooo........oooOO0OOooo........oo << 
181                                                   130 
182 G4bool G4CompositeEMDataSet::LoadNonLogData(co << 131 G4bool                                          G4CompositeEMDataSet :: LoadData(const G4String & argFileName)
183 {                                                 132 {
184   CleanUpComponents();                         << 133  CleanUpComponents(); 
185                                                   134 
186   for (G4int z(minZ); z<maxZ; ++z)             << 135  for (G4int z(minZ); z<maxZ; z++)
187     {                                          << 136  {
188       G4VEMDataSet* component = new G4EMDataSe << 137   G4VEMDataSet * component=new G4EMDataSet(z, algorithm->Clone(), unitEnergies, unitData);
189       if (!component->LoadNonLogData(argFileNa << 138   if (!component->LoadData(argFileName))
190   {                                            << 139   {
191     delete component;                          << 140    delete component;
192     return false;                              << 141    return false;
193   }                                            << 142   }
194       AddComponent(component);                 << 143   
195     }                                          << 144   AddComponent(component);
196   return true;                                 << 145  }
                                                   >> 146  
                                                   >> 147  return true;
197 }                                                 148 }
198                                                   149 
199 //....oooOO0OOooo........oooOO0OOooo........oo << 
200                                                   150 
201 G4bool G4CompositeEMDataSet::SaveData(const G4 << 151 
                                                   >> 152 G4bool                                          G4CompositeEMDataSet :: SaveData(const G4String & argFileName) const
202 {                                                 153 {
203   for (G4int z=minZ; z<maxZ; ++z)              << 154  for (G4int z(minZ); z<maxZ; z++)
204     {                                          << 155  {
205       const G4VEMDataSet* component(GetCompone << 156   const G4VEMDataSet * component(GetComponent(z-minZ));
206                                                   157   
207       if (!component)                          << 158   if (!component)
208   {                                            << 159   {
209     std::ostringstream message;                << 160    std::ostringstream message;
210     message << "G4CompositeEMDataSet::SaveData << 161    message << "G4CompositeEMDataSet::SaveData - component " << (z-minZ) << " not found";
211           G4Exception("G4CompositeEMDataSet::S << 162  
212         "em1004",FatalException,message.str(). << 163    G4Exception(message.str().c_str());
213     return false;                              << 164   }
214   }                                            << 
215                                                   165 
216       if (!component->SaveData(argFileName))   << 166   if (!component->SaveData(argFileName))
217   return false;                                << 167    return false;
218     }                                          << 168  }
219                                                   169  
220   return true;                                 << 170  return true;
221 }                                                 171 }
222                                                   172 
223 //....oooOO0OOooo........oooOO0OOooo........oo << 
224                                                   173 
225 void G4CompositeEMDataSet::CleanUpComponents(v << 
226 {                                              << 
227   while (!components.empty())                  << 
228     {                                          << 
229       if (components.back())                   << 
230   delete components.back();                    << 
231       components.pop_back();                   << 
232     }                                          << 
233 }                                              << 
234                                                   174 
235 //....oooOO0OOooo........oooOO0OOooo........oo << 
236                                                   175 
237 G4double G4CompositeEMDataSet::RandomSelect(G4 << 176 
                                                   >> 177 void                                            G4CompositeEMDataSet :: CleanUpComponents(void)
238 {                                                 178 {
239   G4double value = 0.;                         << 179  while (!components.empty())
240   if (componentId >= 0 && componentId < (G4int << 180  {
241     {                                          << 181   if (components.back())
242       const G4VEMDataSet* dataSet = GetCompone << 182    delete components.back();
243       value = dataSet->RandomSelect();         << 183 
244     }                                          << 184   components.pop_back();
245   return value;                                << 185  }
246 }                                                 186 }
                                                   >> 187 
247                                                   188