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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 10.6)


  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 // Author: Maria Grazia Pia (Maria.Grazia.Pia@     28 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
 29 //                                                 29 //
 30 // History:                                        30 // History:
 31 // -----------                                     31 // -----------
 32 // 1 Aug 2001   MGP        Created                 32 // 1 Aug 2001   MGP        Created
 33 //                                                 33 //
 34 // 15 Jul 2009   Nicolas A. Karakatsanis           34 // 15 Jul 2009   Nicolas A. Karakatsanis
 35 //                                                 35 //
 36 //                           - LoadNonLogData      36 //                           - LoadNonLogData method was created to load only the non-logarithmic data from G4EMLOW
 37 //                             dataset. It is      37 //                             dataset. It is essentially performing the data loading operations as in the past.
 38 //                                                 38 //
 39 //                           - LoadData method     39 //                           - LoadData method was revised in order to calculate the logarithmic values of the data
 40 //                             It retrieves th     40 //                             It retrieves the data values from the G4EMLOW data files but, then, calculates the
 41 //                             respective log      41 //                             respective log values and loads them to seperate data structures. 
 42 //                                                 42 //
 43 //                           - SetLogEnergiesD     43 //                           - SetLogEnergiesData method was cretaed to set logarithmic values to G4 data vectors.
 44 //                             The EM data set     44 //                             The EM data sets, initialized this way, contain both non-log and log values.
 45 //                             These initializ     45 //                             These initialized data sets can enhance the computing performance of data interpolation
 46 //                             operations          46 //                             operations
 47 //                                                 47 //
 48 // -------------------------------------------     48 // -------------------------------------------------------------------
 49                                                    49 
 50 #include "G4CompositeEMDataSet.hh"                 50 #include "G4CompositeEMDataSet.hh"
 51 #include "G4EMDataSet.hh"                          51 #include "G4EMDataSet.hh"
 52 #include "G4VDataSetAlgorithm.hh"                  52 #include "G4VDataSetAlgorithm.hh"
 53 #include <fstream>                                 53 #include <fstream>
 54 #include <sstream>                                 54 #include <sstream>
 55                                                    55 
 56 //....oooOO0OOooo........oooOO0OOooo........oo << 
 57                                                << 
 58 G4CompositeEMDataSet::G4CompositeEMDataSet(G4V     56 G4CompositeEMDataSet::G4CompositeEMDataSet(G4VDataSetAlgorithm* argAlgorithm, 
 59              G4double argUnitEnergies,             57              G4double argUnitEnergies, 
 60              G4double argUnitData,                 58              G4double argUnitData, 
 61              G4int argMinZ,                        59              G4int argMinZ, 
 62              G4int argMaxZ)                        60              G4int argMaxZ)
 63   :                                                61   :
 64   algorithm(argAlgorithm),                         62   algorithm(argAlgorithm),
 65   unitEnergies(argUnitEnergies),                   63   unitEnergies(argUnitEnergies),
 66   unitData(argUnitData),                           64   unitData(argUnitData),
 67   minZ(argMinZ),                                   65   minZ(argMinZ),
 68   maxZ(argMaxZ)                                    66   maxZ(argMaxZ)
 69 {                                                  67 {
 70   if (algorithm == nullptr)                    <<  68   if (algorithm == 0) 
 71   G4Exception("G4CompositeEMDataSet::G4Composi     69   G4Exception("G4CompositeEMDataSet::G4CompositeEMDataSet",
 72         "em1003",FatalException,"interpolation     70         "em1003",FatalException,"interpolation == 0");
 73                                                    71 
 74 }                                                  72 }
 75                                                    73 
 76 //....oooOO0OOooo........oooOO0OOooo........oo <<  74 
 77                                                    75 
 78 G4CompositeEMDataSet::~G4CompositeEMDataSet()      76 G4CompositeEMDataSet::~G4CompositeEMDataSet()
 79 {                                                  77 {
 80   CleanUpComponents();                             78   CleanUpComponents();
 81   if (algorithm) delete algorithm;                 79   if (algorithm) delete algorithm;
 82 }                                                  80 }
 83 //....oooOO0OOooo........oooOO0OOooo........oo <<  81 
 84                                                    82 
 85 G4double G4CompositeEMDataSet::FindValue(G4dou     83 G4double G4CompositeEMDataSet::FindValue(G4double argEnergy, G4int argComponentId) const
 86 {                                                  84 {
 87   const G4VEMDataSet* component(GetComponent(a     85   const G4VEMDataSet* component(GetComponent(argComponentId));
 88                                                    86  
 89   if (component) return component->FindValue(a     87   if (component) return component->FindValue(argEnergy);
 90                                                    88 
 91   std::ostringstream message;                      89   std::ostringstream message;
 92   message << "G4CompositeEMDataSet::FindValue      90   message << "G4CompositeEMDataSet::FindValue - component " << argComponentId << " not found";
 93                                                    91  
 94   G4Exception("G4CompositeEMDataSet::FindValue     92   G4Exception("G4CompositeEMDataSet::FindValue",
 95         "em1004",FatalException,message.str().     93         "em1004",FatalException,message.str().c_str());
 96                                                    94  
 97   return 0.;                                       95   return 0.;
 98 }                                                  96 }
 99                                                    97 
100 //....oooOO0OOooo........oooOO0OOooo........oo << 
101                                                << 
102 void G4CompositeEMDataSet::PrintData(void) con     98 void G4CompositeEMDataSet::PrintData(void) const
103 {                                                  99 {
104   const G4int n = (G4int)NumberOfComponents(); << 100   const size_t n(NumberOfComponents());
105                                                   101 
106   G4cout << "The data set has " << n << " comp    102   G4cout << "The data set has " << n << " components" << G4endl;
107   G4cout << G4endl;                               103   G4cout << G4endl;
108                                                   104  
109   G4int i(0);                                  << 105   size_t i(0);
110                                                   106  
111   while (i<n)                                     107   while (i<n)
112     {                                             108     {
113       G4cout << "--- Component " << i << " ---    109       G4cout << "--- Component " << i << " ---" << G4endl;
114       GetComponent(i)->PrintData();               110       GetComponent(i)->PrintData();
115       ++i;                                     << 111       i++;
116     }                                             112     }
117 }                                                 113 }
118                                                   114 
119 //....oooOO0OOooo........oooOO0OOooo........oo << 
120                                                << 
121 void G4CompositeEMDataSet::SetEnergiesData(G4D    115 void G4CompositeEMDataSet::SetEnergiesData(G4DataVector* argEnergies, G4DataVector* argData, G4int argComponentId)
122 {                                                 116 {
123   G4VEMDataSet * component(components[argCompo    117   G4VEMDataSet * component(components[argComponentId]);
124                                                   118  
125   if (component)                                  119   if (component)
126     {                                             120     {
127       component->SetEnergiesData(argEnergies,     121       component->SetEnergiesData(argEnergies, argData, 0);
128       return;                                     122       return;
129     }                                             123     }
130                                                   124 
131   std::ostringstream message;                     125   std::ostringstream message;
132   message << "G4CompositeEMDataSet::SetEnergie    126   message << "G4CompositeEMDataSet::SetEnergiesData - component " << argComponentId << " not found";
133                                                   127  
134   G4Exception("G4CompositeEMDataSet::SetEnergi    128   G4Exception("G4CompositeEMDataSet::SetEnergiesData",
135         "em1004",FatalException,message.str().    129         "em1004",FatalException,message.str().c_str());
136 }                                                 130 }
137                                                   131 
138 //....oooOO0OOooo........oooOO0OOooo........oo << 
139                                                << 
140 void G4CompositeEMDataSet::SetLogEnergiesData(    132 void G4CompositeEMDataSet::SetLogEnergiesData(G4DataVector* argEnergies, 
141                                                   133                                               G4DataVector* argData,
142                                                   134                                               G4DataVector* argLogEnergies,
143                                                   135                                               G4DataVector* argLogData, 
144                                                   136                                               G4int argComponentId)
145 {                                                 137 {
146   G4VEMDataSet * component(components[argCompo    138   G4VEMDataSet * component(components[argComponentId]);
147                                                   139  
148   if (component)                                  140   if (component)
149     {                                             141     {
150       component->SetLogEnergiesData(argEnergie    142       component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
151       return;                                     143       return;
152     }                                             144     }
153                                                   145 
154   std::ostringstream message;                     146   std::ostringstream message;
155   message << "G4CompositeEMDataSet::SetEnergie    147   message << "G4CompositeEMDataSet::SetEnergiesData - component " << argComponentId << " not found";
156                                                   148  
157   G4Exception("G4CompositeEMDataSet::SetLogEne    149   G4Exception("G4CompositeEMDataSet::SetLogEnergiesData",
158         "em1004",FatalException,message.str().    150         "em1004",FatalException,message.str().c_str());
159 }                                                 151 }
160                                                   152 
161 //....oooOO0OOooo........oooOO0OOooo........oo << 
162                                                   153 
163 G4bool G4CompositeEMDataSet::LoadData(const G4    154 G4bool G4CompositeEMDataSet::LoadData(const G4String& argFileName)
164 {                                                 155 {
165   CleanUpComponents();                            156   CleanUpComponents(); 
166                                                   157 
167   for (G4int z(minZ); z<maxZ; ++z)             << 158   for (G4int z(minZ); z<maxZ; z++)
168     {                                             159     {
169       G4VEMDataSet* component = new G4EMDataSe    160       G4VEMDataSet* component = new G4EMDataSet(z, algorithm->Clone(), unitEnergies, unitData);
170       if (!component->LoadData(argFileName))      161       if (!component->LoadData(argFileName))
171   {                                               162   {
172     delete component;                             163     delete component;
173     return false;                                 164     return false;
174   }                                               165   }
175       AddComponent(component);                    166       AddComponent(component);
176     }                                             167     }
177   return true;                                    168   return true;
178 }                                                 169 }
179                                                   170 
180 //....oooOO0OOooo........oooOO0OOooo........oo << 
181                                                   171 
182 G4bool G4CompositeEMDataSet::LoadNonLogData(co    172 G4bool G4CompositeEMDataSet::LoadNonLogData(const G4String& argFileName)
183 {                                                 173 {
184   CleanUpComponents();                            174   CleanUpComponents(); 
185                                                   175 
186   for (G4int z(minZ); z<maxZ; ++z)             << 176   for (G4int z(minZ); z<maxZ; z++)
187     {                                             177     {
188       G4VEMDataSet* component = new G4EMDataSe    178       G4VEMDataSet* component = new G4EMDataSet(z, algorithm->Clone(), unitEnergies, unitData);
189       if (!component->LoadNonLogData(argFileNa    179       if (!component->LoadNonLogData(argFileName))
190   {                                               180   {
191     delete component;                             181     delete component;
192     return false;                                 182     return false;
193   }                                               183   }
194       AddComponent(component);                    184       AddComponent(component);
195     }                                             185     }
196   return true;                                    186   return true;
197 }                                                 187 }
198                                                   188 
199 //....oooOO0OOooo........oooOO0OOooo........oo << 
200                                                   189 
201 G4bool G4CompositeEMDataSet::SaveData(const G4    190 G4bool G4CompositeEMDataSet::SaveData(const G4String& argFileName) const
202 {                                                 191 {
203   for (G4int z=minZ; z<maxZ; ++z)              << 192   for (G4int z=minZ; z<maxZ; z++)
204     {                                             193     {
205       const G4VEMDataSet* component(GetCompone    194       const G4VEMDataSet* component(GetComponent(z-minZ));
206                                                   195   
207       if (!component)                             196       if (!component)
208   {                                               197   {
209     std::ostringstream message;                   198     std::ostringstream message;
210     message << "G4CompositeEMDataSet::SaveData    199     message << "G4CompositeEMDataSet::SaveData - component " << (z-minZ) << " not found";
211           G4Exception("G4CompositeEMDataSet::S    200           G4Exception("G4CompositeEMDataSet::SaveData",
212         "em1004",FatalException,message.str().    201         "em1004",FatalException,message.str().c_str());
213     return false;                                 202     return false;
214   }                                               203   }
215                                                   204 
216       if (!component->SaveData(argFileName))      205       if (!component->SaveData(argFileName))
217   return false;                                   206   return false;
218     }                                             207     }
219                                                   208  
220   return true;                                    209   return true;
221 }                                                 210 }
222                                                   211 
223 //....oooOO0OOooo........oooOO0OOooo........oo << 
224                                                << 
225 void G4CompositeEMDataSet::CleanUpComponents(v    212 void G4CompositeEMDataSet::CleanUpComponents(void)
226 {                                                 213 {
227   while (!components.empty())                     214   while (!components.empty())
228     {                                             215     {
229       if (components.back())                      216       if (components.back())
230   delete components.back();                       217   delete components.back();
231       components.pop_back();                      218       components.pop_back();
232     }                                             219     }
233 }                                                 220 }
234                                                   221 
235 //....oooOO0OOooo........oooOO0OOooo........oo << 
236                                                   222 
237 G4double G4CompositeEMDataSet::RandomSelect(G4    223 G4double G4CompositeEMDataSet::RandomSelect(G4int componentId) const
238 {                                                 224 {
239   G4double value = 0.;                            225   G4double value = 0.;
240   if (componentId >= 0 && componentId < (G4int    226   if (componentId >= 0 && componentId < (G4int)components.size())
241     {                                             227     {
242       const G4VEMDataSet* dataSet = GetCompone    228       const G4VEMDataSet* dataSet = GetComponent(componentId);
243       value = dataSet->RandomSelect();            229       value = dataSet->RandomSelect();
244     }                                             230     }
245   return value;                                   231   return value;
246 }                                                 232 }
247                                                   233