Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/materials/src/G4SandiaTable.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 /materials/src/G4SandiaTable.cc (Version 11.3.0) and /materials/src/G4SandiaTable.cc (Version 3.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
                                                   >>   3 //
                                                   >>   4 // By copying, distributing or modifying the Program (or any work
                                                   >>   5 // based on the Program) you indicate your acceptance of this statement,
                                                   >>   6 // and all its terms.
                                                   >>   7 //
                                                   >>   8 // $Id: G4SandiaTable.cc,v 1.6 2000/08/03 14:28:31 grichine Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-03-00 $
                                                   >>  10 //
                                                   >>  11 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
  1 //                                                 12 //
  2 // ******************************************* << 
  3 // * License and Disclaimer                    << 
  4 // *                                           << 
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25                                                << 
 26 // 10.06.97 created. V. Grichine               << 
 27 // 18.11.98 simplified public interface; new m     13 // 18.11.98 simplified public interface; new methods for materials.  mma
 28 // 31.01.01 redesign of ComputeMatSandiaMatrix <<  14 // 10.06.97 created. V. Grichine
 29 // 16.02.01 adapted for STL.  mma              <<  15 //
 30 // 22.02.01 GetsandiaCofForMaterial(energy) re <<  16 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
 31 // 03.04.01 fnulcof returned if energy < emin  << 
 32 // 10.07.01 Migration to STL. M. Verderi.      << 
 33 // 03.02.04 Update distructor V.Ivanchenko     << 
 34 // 05.03.04 New methods for old sorting algori << 
 35 // 26.10.11 new scheme for G4Exception  (mma)  << 
 36 // 22.05.13 preparation of material table with << 
 37 // 09.07.14 modify low limit in GetSandiaCofPe << 
 38 // 10.07.14 modify low limit for water. VI     << 
 39                                                    17 
 40 #include "G4SandiaTable.hh"                    << 
 41                                                    18 
 42 #include "G4Material.hh"                       <<  19 #include "G4SandiaTable.hh"
 43 #include "G4MaterialTable.hh"                  << 
 44 #include "G4PhysicalConstants.hh"              << 
 45 #include "G4StaticSandiaData.hh"                   20 #include "G4StaticSandiaData.hh"
 46 #include "G4SystemOfUnits.hh"                  <<  21 #include "G4Material.hh"
 47                                                << 
 48 const G4double G4SandiaTable::funitc[5] = {CLH << 
 49   CLHEP::cm2* CLHEP::keV* CLHEP::keV / CLHEP:: << 
 50   CLHEP::cm2* CLHEP::keV* CLHEP::keV* CLHEP::k << 
 51   CLHEP::cm2* CLHEP::keV* CLHEP::keV* CLHEP::k << 
 52                                                << 
 53 G4int G4SandiaTable::fCumulInterval[] = {0};   << 
 54                                                    22 
                                                   >>  23 G4int    G4SandiaTable::fCumulInterval[101];
                                                   >>  24 G4double G4SandiaTable::fSandiaCofPerAtom[4];
                                                   >>  25  
 55 //....oooOO0OOooo........oooOO0OOooo........oo     26 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
 56                                                    27 
 57 G4SandiaTable::G4SandiaTable(const G4Material* <<  28 G4SandiaTable::G4SandiaTable(G4int matIndex)
 58 {                                              <<  29 { 
 59   fMatSandiaMatrix = nullptr;                  <<  30   fMatSandiaMatrix = 0 ; 
 60   fMatSandiaMatrixPAI = nullptr;               <<  31   fPhotoAbsorptionCof = 0 ;
 61   fPhotoAbsorptionCof = nullptr;               <<  32 }
 62                                                <<  33 
 63   fMatNbOfIntervals = 0;                       <<  34 G4SandiaTable::G4SandiaTable(G4Material* material)
 64                                                <<  35 :fMaterial(material)
 65   fMaxInterval = 0;                            <<  36 {
 66   fVerbose = 0;                                <<  37   fPhotoAbsorptionCof = 0 ;
 67                                                <<  38   //build the CumulInterval array
 68   // build the CumulInterval array             <<  39   fCumulInterval[0] = 1;
 69   if (0 == fCumulInterval[0]) {                <<  40   for (G4int Z=1; Z<101; Z++)
 70     fCumulInterval[0] = 1;                     <<  41       fCumulInterval[Z] = fCumulInterval[Z-1] + fNbOfIntervals[Z];
 71                                                <<  42   
 72     for (G4int Z = 1; Z < 101; ++Z) {          <<  43   //compute macroscopic Sandia coefs for a material   
 73       fCumulInterval[Z] = fCumulInterval[Z - 1 <<  44   ComputeMatSandiaMatrix();    
 74     }                                          << 
 75   }                                            << 
 76                                                << 
 77   fMaxInterval = 0;                            << 
 78   fSandiaCofPerAtom.resize(4, 0.0);            << 
 79   fLowerI1 = false;                            << 
 80   // compute macroscopic Sandia coefs for a ma << 
 81   ComputeMatSandiaMatrix();  // mma            << 
 82 }                                                  45 }
 83                                                <<  46               
 84 //....oooOO0OOooo........oooOO0OOooo........oo     47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
 85                                                    48 
 86 G4SandiaTable::~G4SandiaTable()                    49 G4SandiaTable::~G4SandiaTable()
 87 {                                              <<  50 { 
 88   if (fMatSandiaMatrix != nullptr) {           <<  51   if(fMatSandiaMatrix) delete fMatSandiaMatrix ;
 89     fMatSandiaMatrix->clearAndDestroy();       <<  52   if(fPhotoAbsorptionCof)
 90     delete fMatSandiaMatrix;                   <<  53   {
 91   }                                            <<  54     for(G4int i = 0 ; i < fMaxInterval ; i++)  delete[] fPhotoAbsorptionCof[i] ;
 92   if (fMatSandiaMatrixPAI != nullptr) {        <<  55     delete fPhotoAbsorptionCof ;
 93     fMatSandiaMatrixPAI->clearAndDestroy();    << 
 94     delete fMatSandiaMatrixPAI;                << 
 95   }                                            << 
 96                                                << 
 97   delete[] fPhotoAbsorptionCof;                << 
 98 }                                              << 
 99                                                << 
100 //....oooOO0OOooo........oooOO0OOooo........oo << 
101                                                << 
102 void G4SandiaTable::GetSandiaCofPerAtom(       << 
103   G4int Z, G4double energy, std::vector<G4doub << 
104 {                                              << 
105 #ifdef G4VERBOSE                               << 
106   if (Z < 1 || Z > 100) {                      << 
107     Z = PrintErrorZ(Z, "GetSandiaCofPerAtom"); << 
108   }                                            << 
109   if (4 > coeff.size()) {                      << 
110     PrintErrorV("GetSandiaCofPerAtom(): input  << 
111     coeff.resize(4);                           << 
112   }                                            << 
113 #endif                                         << 
114   G4double Emin = fSandiaTable[fCumulInterval[ << 
115   // G4double Iopot = fIonizationPotentials[Z] << 
116   // if (Emin  < Iopot) Emin = Iopot;          << 
117                                                << 
118   G4int row = 0;                               << 
119   if (energy <= Emin) {                        << 
120     energy = Emin;                             << 
121   }                                            << 
122   else {                                       << 
123     G4int interval = fNbOfIntervals[Z] - 1;    << 
124     row = fCumulInterval[Z - 1] + interval;    << 
125     // Loop checking, 07-Aug-2015, Vladimir Iv << 
126     while ((interval > 0) && (energy < fSandia << 
127       --interval;                              << 
128       row = fCumulInterval[Z - 1] + interval;  << 
129     }                                          << 
130   }                                            << 
131                                                << 
132   G4double AoverAvo = Z * amu / fZtoAratio[Z]; << 
133                                                << 
134   coeff[0] = AoverAvo * funitc[1] * fSandiaTab << 
135   coeff[1] = AoverAvo * funitc[2] * fSandiaTab << 
136   coeff[2] = AoverAvo * funitc[3] * fSandiaTab << 
137   coeff[3] = AoverAvo * funitc[4] * fSandiaTab << 
138 }                                              << 
139                                                << 
140 //....oooOO0OOooo........oooOO0OOooo........oo << 
141                                                << 
142 void G4SandiaTable::GetSandiaCofWater(G4double << 
143 {                                              << 
144 #ifdef G4VERBOSE                               << 
145   if (4 > coeff.size()) {                      << 
146     PrintErrorV("GetSandiaCofWater: input vect << 
147     coeff.resize(4);                           << 
148   }                                            << 
149 #endif                                         << 
150   G4int i = 0;                                 << 
151   if (energy > fH2OlowerI1[0][0] * CLHEP::keV) << 
152     i = fH2OlowerInt - 1;                      << 
153     for (; i > 0; --i) {                       << 
154       if (energy >= fH2OlowerI1[i][0] * CLHEP: << 
155         break;                                 << 
156       }                                        << 
157     }                                          << 
158   }                                            << 
159   coeff[0] = funitc[1] * fH2OlowerI1[i][1];    << 
160   coeff[1] = funitc[2] * fH2OlowerI1[i][2];    << 
161   coeff[2] = funitc[3] * fH2OlowerI1[i][3];    << 
162   coeff[3] = funitc[4] * fH2OlowerI1[i][4];    << 
163 }                                              << 
164                                                << 
165 //....oooOO0OOooo........oooOO0OOooo........oo << 
166                                                << 
167 G4double G4SandiaTable::GetWaterEnergyLimit()  << 
168 {                                              << 
169   return fH2OlowerI1[fH2OlowerInt - 1][0] * CL << 
170 }                                              << 
171                                                << 
172 //....oooOO0OOooo........oooOO0OOooo........oo << 
173                                                << 
174 G4double G4SandiaTable::GetWaterCofForMaterial << 
175 {                                              << 
176   return fH2OlowerI1[i][j] * funitc[j];        << 
177 }                                              << 
178                                                << 
179 //....oooOO0OOooo........oooOO0OOooo........oo << 
180                                                << 
181 G4double G4SandiaTable::GetZtoA(G4int Z)       << 
182 {                                              << 
183 #ifdef G4VERBOSE                               << 
184   if (Z < 1 || Z > 100) {                      << 
185     Z = PrintErrorZ(Z, "GetSandiaCofPerAtom"); << 
186   }                                                56   }
187 #endif                                         << 
188   return fZtoAratio[Z];                        << 
189 }                                              << 
190                                                << 
191 //....oooOO0OOooo........oooOO0OOooo........oo << 
192                                                << 
193 #ifdef G4VERBOSE                               << 
194                                                << 
195 G4int G4SandiaTable::PrintErrorZ(G4int Z, cons << 
196 {                                              << 
197   G4String sss = "G4SandiaTable::" + ss + "()" << 
198   G4ExceptionDescription ed;                   << 
199   ed << "Atomic number out of range Z= " << Z  << 
200   G4Exception(sss, "mat060", JustWarning, ed,  << 
201   return (Z > 100) ? 100 : 1;                  << 
202 }                                              << 
203                                                << 
204 //....oooOO0OOooo........oooOO0OOooo........oo << 
205                                                << 
206 void G4SandiaTable::PrintErrorV(const G4String << 
207 {                                              << 
208   G4String sss = "G4SandiaTable::" + ss;       << 
209   G4ExceptionDescription ed;                   << 
210   G4Exception(sss, "mat061", JustWarning, "Wro << 
211 }                                                  57 }
212 #endif                                         <<  58               
213                                                << 
214 //....oooOO0OOooo........oooOO0OOooo........oo     59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
215                                                    60 
216 void G4SandiaTable::ComputeMatSandiaMatrix()       61 void G4SandiaTable::ComputeMatSandiaMatrix()
217 {                                              <<  62 {  
218   // get list of elements                      <<  63   //get list of elements
219   const auto NbElm = (G4int)fMaterial->GetNumb <<  64   const G4int NbElm = fMaterial->GetNumberOfElements();
220   const G4ElementVector* ElementVector = fMate     65   const G4ElementVector* ElementVector = fMaterial->GetElementVector();
221                                                <<  66   
222   auto Z = new G4int[NbElm];  // Atomic number <<  67   G4int* Z = new G4int[NbElm];               //Atomic number
223                                                <<  68      
224   // determine the maximum number of energy-in <<  69   //determine the total number of energy-intervals for this material
225   G4int MaxIntervals = 0;                      << 
226   G4int elm, z;                                << 
227                                                << 
228   // here we compute only for a mixture, so no << 
229   // if z is out of validity interval          << 
230   for (elm = 0; elm < NbElm; ++elm) {          << 
231     z = G4lrint((*ElementVector)[elm]->GetZ()) << 
232     if (z < 1) {                               << 
233       z = 1;                                   << 
234     }                                          << 
235     else if (z > 100) {                        << 
236       z = 100;                                 << 
237     }                                          << 
238     Z[elm] = z;                                << 
239     MaxIntervals += fNbOfIntervals[z];         << 
240   }                                            << 
241                                                << 
242   // copy the Energy bins in a tmp1 array      << 
243   //(take care of the Ionization Potential of  << 
244   auto tmp1 = new G4double[MaxIntervals];      << 
245   G4double IonizationPot;                      << 
246   G4int interval1 = 0;                         << 
247                                                << 
248   for (elm = 0; elm < NbElm; ++elm) {          << 
249     z = Z[elm];                                << 
250     IonizationPot = fIonizationPotentials[z] * << 
251     for (G4int row = fCumulInterval[z - 1]; ro << 
252       tmp1[interval1] = std::max(fSandiaTable[ << 
253       ++interval1;                             << 
254     }                                          << 
255   }                                            << 
256   // sort the energies in strickly increasing  << 
257   //(eliminate redondances)                    << 
258                                                << 
259   auto tmp2 = new G4double[MaxIntervals];      << 
260   G4double Emin;                               << 
261   G4int interval2 = 0;                         << 
262                                                << 
263   do {                                         << 
264     Emin = DBL_MAX;                            << 
265                                                << 
266     for (G4int i1 = 0; i1 < MaxIntervals; ++i1 << 
267       Emin = std::min(Emin, tmp1[i1]);  // fin << 
268     }                                          << 
269     if (Emin < DBL_MAX) {                      << 
270       tmp2[interval2] = Emin;                  << 
271       ++interval2;                             << 
272     }                                          << 
273     // copy Emin in tmp2                       << 
274     for (G4int j1 = 0; j1 < MaxIntervals; ++j1 << 
275       if (tmp1[j1] <= Emin) {                  << 
276         tmp1[j1] = DBL_MAX;                    << 
277       }  // eliminate from tmp1                << 
278     }                                          << 
279     // Loop checking, 07-Aug-2015, Vladimir Iv << 
280   } while (Emin < DBL_MAX);                    << 
281                                                << 
282   // create the sandia matrix for this materia << 
283                                                << 
284   fMatSandiaMatrix = new G4OrderedTable();     << 
285   G4int interval;                              << 
286                                                << 
287   for (interval = 0; interval < interval2; ++i << 
288     fMatSandiaMatrix->push_back(new G4DataVect << 
289   }                                            << 
290                                                << 
291   // ready to compute the Sandia coefs for the << 
292                                                << 
293   const G4double* NbOfAtomsPerVolume = fMateri << 
294                                                << 
295   static const G4double prec = 1.e-03 * CLHEP: << 
296   G4double coef, oldsum(0.), newsum(0.);       << 
297   fMatNbOfIntervals = 0;                           70   fMatNbOfIntervals = 0;
298                                                <<  71   G4int elm;    
299   for (interval = 0; interval < interval2; ++i <<  72   for (elm=0; elm<NbElm; elm++)
300     Emin = (*(*fMatSandiaMatrix)[fMatNbOfInter <<  73      { Z[elm] = (int)(*ElementVector)(elm)->GetZ();
301                                                <<  74        fMatNbOfIntervals += fNbOfIntervals[Z[elm]];
302     for (G4int k = 1; k < 5; ++k) {            <<  75      }  
303       (*(*fMatSandiaMatrix)[fMatNbOfIntervals] <<  76      
304     }                                          <<  77   //create the sandia matrix for this material  
305     newsum = 0.;                               <<  78   fMatSandiaMatrix = new G4OrderedTable(fMatNbOfIntervals);
306                                                <<  79   G4int interval;
307     for (elm = 0; elm < NbElm; elm++) {        <<  80   for (interval=0; interval<fMatNbOfIntervals; interval++)
308       GetSandiaCofPerAtom(Z[elm], Emin + prec, <<  81      (*fMatSandiaMatrix)(interval) = new G4ValVector(5);
309                                                <<  82   
310       for (G4int j = 1; j < 5; ++j) {          <<  83   //copy the Energy bins (take care of the Ionization Potential)
311         coef = NbOfAtomsPerVolume[elm] * fSand <<  84   G4double Ebin;
312         (*(*fMatSandiaMatrix)[fMatNbOfInterval <<  85   interval=0;
313         newsum += std::abs(coef);              <<  86   for (elm=0; elm<NbElm; elm++)
314       }                                        <<  87      for (G4int row=fCumulInterval[Z[elm]-1];row<fCumulInterval[Z[elm]];row++)
315     }                                          <<  88         { Ebin = fSandiaTable[row][0]*keV;
316     // check for null or redondant intervals   <<  89           if ((row==fCumulInterval[Z[elm]-1])&&(GetIonizationPot(Z[elm])<Ebin))
317                                                <<  90               Ebin = GetIonizationPot(Z[elm]);
318     if (newsum != oldsum) {                    <<  91           (*(*fMatSandiaMatrix)(interval++))(0) = Ebin;
319       oldsum = newsum;                         <<  92         }  
320       ++fMatNbOfIntervals;                     <<  93          
321     }                                          <<  94   //sort the energies in increasing values
322   }                                            <<  95   G4double tmp;
323   delete[] Z;                                  <<  96   for (G4int i1=0; i1<fMatNbOfIntervals; i1++)
324   delete[] tmp1;                               <<  97      for (G4int i2=i1+1; i2<fMatNbOfIntervals; i2++)
325   delete[] tmp2;                               <<  98         {if ((*(*fMatSandiaMatrix)(i1))(0) > (*(*fMatSandiaMatrix)(i2))(0))        
326                                                <<  99            {
327   if (fVerbose > 0) {                          << 100             tmp = (*(*fMatSandiaMatrix)(i1))(0);
328     G4cout << "G4SandiaTable::ComputeMatSandia << 101             (*(*fMatSandiaMatrix)(i1))(0) = (*(*fMatSandiaMatrix)(i2))(0);
329                                                << 102             (*(*fMatSandiaMatrix)(i2))(0) = tmp;
330     for (G4int i = 0; i < fMatNbOfIntervals; + << 103            }
331       G4cout << i << "\t" << GetSandiaCofForMa << 
332              << GetSandiaCofForMaterial(i, 1)  << 
333              << GetSandiaCofForMaterial(i, 3)  << 
334     }                                          << 
335   }                                            << 
336 }                                              << 
337                                                << 
338 ////////////////////////////////////////////// << 
339 //                                             << 
340 // Sandia matrix for PAI models based on vecto << 
341                                                << 
342 void G4SandiaTable::ComputeMatSandiaMatrixPAI( << 
343 {                                              << 
344   G4int MaxIntervals = 0;                      << 
345   G4int elm, c, i, j, jj, k, k1, k2, c1, n1, z << 
346                                                << 
347   const auto noElm = (G4int)fMaterial->GetNumb << 
348   const G4ElementVector* ElementVector = fMate << 
349                                                << 
350   std::vector<G4int> Z(noElm);  // Atomic numb << 
351                                                << 
352   for (elm = 0; elm < noElm; ++elm) {          << 
353     z = G4lrint((*ElementVector)[elm]->GetZ()) << 
354     if (z < 1) {                               << 
355       z = 1;                                   << 
356     }                                          << 
357     else if (z > 100) {                        << 
358       z = 100;                                 << 
359     }                                          << 
360     Z[elm] = z;                                << 
361     MaxIntervals += fNbOfIntervals[Z[elm]];    << 
362   }                                            << 
363   fMaxInterval = MaxIntervals + 2;             << 
364                                                << 
365   if (fVerbose > 0) {                          << 
366     G4cout << "G4SandiaTable::ComputeMatSandia << 
367   }                                            << 
368                                                << 
369   G4DataVector fPhotoAbsorptionCof0(fMaxInterv << 
370   G4DataVector fPhotoAbsorptionCof1(fMaxInterv << 
371   G4DataVector fPhotoAbsorptionCof2(fMaxInterv << 
372   G4DataVector fPhotoAbsorptionCof3(fMaxInterv << 
373   G4DataVector fPhotoAbsorptionCof4(fMaxInterv << 
374                                                << 
375   for (c = 0; c < fMaxInterval; ++c)  // just  << 
376   {                                            << 
377     fPhotoAbsorptionCof0[c] = 0.;              << 
378     fPhotoAbsorptionCof1[c] = 0.;              << 
379     fPhotoAbsorptionCof2[c] = 0.;              << 
380     fPhotoAbsorptionCof3[c] = 0.;              << 
381     fPhotoAbsorptionCof4[c] = 0.;              << 
382   }                                            << 
383   c = 1;                                       << 
384                                                << 
385   for (i = 0; i < noElm; ++i) {                << 
386     G4double I1 = fIonizationPotentials[Z[i]]  << 
387     n1 = 1;                                    << 
388                                                << 
389     for (j = 1; j < Z[i]; ++j) {               << 
390       n1 += fNbOfIntervals[j];                 << 
391     }                                          << 
392                                                << 
393     G4int n2 = n1 + fNbOfIntervals[Z[i]];      << 
394                                                << 
395     for (k1 = n1; k1 < n2; ++k1) {             << 
396       if (I1 > fSandiaTable[k1][0]) {          << 
397         continue;  // no ionization for energi << 
398       }  // ionisation potential)              << 
399       break;                                   << 
400     }                                          << 
401     G4int flag = 0;                            << 
402                                                << 
403     for (c1 = 1; c1 < c; ++c1) {               << 
404       if (fPhotoAbsorptionCof0[c1] == I1)  //  << 
405       {                                        << 
406         flag = 1;                              << 
407         break;                                 << 
408       }                                        << 
409     }                                          << 
410     if (flag == 0) {                           << 
411       fPhotoAbsorptionCof0[c] = I1;            << 
412       ++c;                                     << 
413     }                                          << 
414     for (k2 = k1; k2 < n2; ++k2) {             << 
415       flag = 0;                                << 
416                                                << 
417       for (c1 = 1; c1 < c; ++c1) {             << 
418         if (fPhotoAbsorptionCof0[c1] == fSandi << 
419           flag = 1;                            << 
420           break;                               << 
421         }                                      << 
422       }                                        << 
423       if (flag == 0) {                         << 
424         fPhotoAbsorptionCof0[c] = fSandiaTable << 
425         ++c;                                   << 
426       }                                        << 
427     }                                          << 
428   }  // end for(i)                             << 
429   // sort out                                  << 
430                                                << 
431   for (i = 1; i < c; ++i) {                    << 
432     for (j = i + 1; j < c; ++j) {              << 
433       if (fPhotoAbsorptionCof0[i] > fPhotoAbso << 
434         G4double tmp = fPhotoAbsorptionCof0[i] << 
435         fPhotoAbsorptionCof0[i] = fPhotoAbsorp << 
436         fPhotoAbsorptionCof0[j] = tmp;         << 
437       }                                        << 
438     }                                          << 
439     if (fVerbose > 0) {                        << 
440       G4cout << i << "\t energy = " << fPhotoA << 
441     }                                          << 
442   }                                            << 
443   fMaxInterval = c;                            << 
444                                                << 
445   const G4double* fractionW = fMaterial->GetFr << 
446                                                << 
447   if (fVerbose > 0) {                          << 
448     for (i = 0; i < noElm; ++i) {              << 
449       G4cout << i << " = elN, fraction = " <<  << 
450     }                                          << 
451   }                                            << 
452                                                << 
453   for (i = 0; i < noElm; ++i) {                << 
454     n1 = 1;                                    << 
455     G4double I1 = fIonizationPotentials[Z[i]]  << 
456                                                << 
457     for (j = 1; j < Z[i]; ++j) {               << 
458       n1 += fNbOfIntervals[j];                 << 
459     }                                          << 
460                                                << 
461     G4int n2 = n1 + fNbOfIntervals[Z[i]] - 1;  << 
462                                                << 
463     for (k = n1; k < n2; ++k) {                << 
464       G4double B1 = fSandiaTable[k][0];        << 
465       G4double B2 = fSandiaTable[k + 1][0];    << 
466                                                << 
467       for (G4int q = 1; q < fMaxInterval - 1;  << 
468         G4double E1 = fPhotoAbsorptionCof0[q]; << 
469         G4double E2 = fPhotoAbsorptionCof0[q + << 
470                                                << 
471         if (fVerbose > 0) {                    << 
472           G4cout << "k = " << k << ", q = " << << 
473                  << ", E1 = " << E1 << ", E2 = << 
474         }                                      << 
475         if (B1 > E1 || B2 < E2 || E1 < I1) {   << 
476           if (fVerbose > 0) {                  << 
477             G4cout << "continue for: B1 = " << << 
478                    << ", E2 = " << E2 << G4end << 
479           }                                    << 
480           continue;                            << 
481         }                                         104         }
482         fPhotoAbsorptionCof1[q] += fSandiaTabl << 105         
483         fPhotoAbsorptionCof2[q] += fSandiaTabl << 106   //ready to compute the Sandia coefs for the material
484         fPhotoAbsorptionCof3[q] += fSandiaTabl << 107   const G4double* NbOfAtomsPerVolume = fMaterial->GetVecNbOfAtomsPerVolume();
485         fPhotoAbsorptionCof4[q] += fSandiaTabl << 108   for (interval=0; interval<fMatNbOfIntervals; interval++)
486       }                                        << 109      {
487     }                                          << 110       Ebin = (*(*fMatSandiaMatrix)(interval))(0);        
488     // Last interval                           << 111       for (elm=0; elm<NbElm; elm++)
489                                                << 112          {
490     fPhotoAbsorptionCof1[fMaxInterval - 1] +=  << 113            GetSandiaCofPerAtom(Z[elm], Ebin);
491     fPhotoAbsorptionCof2[fMaxInterval - 1] +=  << 114            for (G4int j=1; j<5; j++)
492     fPhotoAbsorptionCof3[fMaxInterval - 1] +=  << 115               (*(*fMatSandiaMatrix)(interval))(j) += NbOfAtomsPerVolume[elm]*
493     fPhotoAbsorptionCof4[fMaxInterval - 1] +=  << 116                                                      fSandiaCofPerAtom[j-1];
494   }  // for(i)                                 << 117          }
495   c = 0;  // Deleting of first intervals where << 118      }
496                                                << 119   delete [] Z;              
497   do {                                         << 
498     ++c;                                       << 
499                                                << 
500     if (fPhotoAbsorptionCof1[c] != 0.0 || fPho << 
501         fPhotoAbsorptionCof3[c] != 0.0 || fPho << 
502     {                                          << 
503       continue;                                << 
504     }                                          << 
505                                                << 
506     if (fVerbose > 0) {                        << 
507       G4cout << c << " = number with zero cofs << 
508     }                                          << 
509     for (jj = 2; jj < fMaxInterval; ++jj) {    << 
510       fPhotoAbsorptionCof0[jj - 1] = fPhotoAbs << 
511       fPhotoAbsorptionCof1[jj - 1] = fPhotoAbs << 
512       fPhotoAbsorptionCof2[jj - 1] = fPhotoAbs << 
513       fPhotoAbsorptionCof3[jj - 1] = fPhotoAbs << 
514       fPhotoAbsorptionCof4[jj - 1] = fPhotoAbs << 
515     }                                          << 
516     --fMaxInterval;                            << 
517     --c;                                       << 
518   }                                            << 
519   // Loop checking, 07-Aug-2015, Vladimir Ivan << 
520   while (c < fMaxInterval - 1);                << 
521                                                << 
522   if (fPhotoAbsorptionCof0[fMaxInterval - 1] = << 
523     fMaxInterval--;                            << 
524   }                                            << 
525                                                << 
526   // create the sandia matrix for this materia << 
527                                                << 
528   fMatSandiaMatrixPAI = new G4OrderedTable();  << 
529                                                << 
530   G4double density = fMaterial->GetDensity();  << 
531                                                << 
532   for (i = 0; i < fMaxInterval; ++i)  // -> G4 << 
533   {                                            << 
534     fPhotoAbsorptionCof0[i + 1] *= funitc[0];  << 
535     fPhotoAbsorptionCof1[i + 1] *= funitc[1] * << 
536     fPhotoAbsorptionCof2[i + 1] *= funitc[2] * << 
537     fPhotoAbsorptionCof3[i + 1] *= funitc[3] * << 
538     fPhotoAbsorptionCof4[i + 1] *= funitc[4] * << 
539   }                                            << 
540   if (fLowerI1) {                              << 
541     if (fMaterial->GetName() == "G4_WATER") {  << 
542       fMaxInterval += fH2OlowerInt;            << 
543                                                << 
544       for (i = 0; i < fMaxInterval; ++i)  // i << 
545       {                                        << 
546         fMatSandiaMatrixPAI->push_back(new G4D << 
547       }                                        << 
548       for (i = 0; i < fH2OlowerInt; ++i) {     << 
549         (*(*fMatSandiaMatrixPAI)[i])[0] = fH2O << 
550         (*(*fMatSandiaMatrixPAI)[i])[1] = fH2O << 
551         (*(*fMatSandiaMatrixPAI)[i])[2] = fH2O << 
552         (*(*fMatSandiaMatrixPAI)[i])[3] = fH2O << 
553         (*(*fMatSandiaMatrixPAI)[i])[4] = fH2O << 
554       }                                        << 
555       for (i = fH2OlowerInt; i < fMaxInterval; << 
556         (*(*fMatSandiaMatrixPAI)[i])[0] = fPho << 
557         (*(*fMatSandiaMatrixPAI)[i])[1] = fPho << 
558         (*(*fMatSandiaMatrixPAI)[i])[2] = fPho << 
559         (*(*fMatSandiaMatrixPAI)[i])[3] = fPho << 
560         (*(*fMatSandiaMatrixPAI)[i])[4] = fPho << 
561       }                                        << 
562     }                                          << 
563   }                                            << 
564   else {                                       << 
565     for (i = 0; i < fMaxInterval; ++i)  // ini << 
566     {                                          << 
567       fMatSandiaMatrixPAI->push_back(new G4Dat << 
568     }                                          << 
569     for (i = 0; i < fMaxInterval; ++i) {       << 
570       (*(*fMatSandiaMatrixPAI)[i])[0] = fPhoto << 
571       (*(*fMatSandiaMatrixPAI)[i])[1] = fPhoto << 
572       (*(*fMatSandiaMatrixPAI)[i])[2] = fPhoto << 
573       (*(*fMatSandiaMatrixPAI)[i])[3] = fPhoto << 
574       (*(*fMatSandiaMatrixPAI)[i])[4] = fPhoto << 
575     }                                          << 
576   }                                            << 
577   // --fMaxInterval;                           << 
578   // to avoid duplicate at 500 keV or extra ze << 
579                                                << 
580   if (fVerbose > 0) {                          << 
581     G4cout << "G4SandiaTable::ComputeMatSandia << 
582            << G4endl;                          << 
583                                                << 
584     for (i = 0; i < fMaxInterval; ++i) {       << 
585       G4cout << i << "\t" << GetSandiaMatTable << 
586              << GetSandiaMatTablePAI(i, 1) <<  << 
587              << GetSandiaMatTablePAI(i, 3) <<  << 
588     }                                          << 
589   }                                            << 
590   return;                                      << 
591 }                                              << 
592                                                << 
593 ////////////////////////////////////////////// << 
594 // Methods for PAI model only                  << 
595 //                                             << 
596                                                << 
597 G4SandiaTable::G4SandiaTable(G4int matIndex)   << 
598 {                                              << 
599   fMaterial = nullptr;                         << 
600   fMatNbOfIntervals = 0;                       << 
601   fMatSandiaMatrix = nullptr;                  << 
602   fMatSandiaMatrixPAI = nullptr;               << 
603   fPhotoAbsorptionCof = nullptr;               << 
604                                                << 
605   fMaxInterval = 0;                            << 
606   fVerbose = 0;                                << 
607   fLowerI1 = false;                            << 
608                                                << 
609   fSandiaCofPerAtom.resize(4, 0.0);            << 
610                                                << 
611   const G4MaterialTable* theMaterialTable = G4 << 
612   auto numberOfMat = (G4int)G4Material::GetNum << 
613                                                << 
614   if (matIndex >= 0 && matIndex < numberOfMat) << 
615     fMaterial = (*theMaterialTable)[matIndex]; << 
616   }                                            << 
617   else {                                       << 
618     G4Exception(                               << 
619       "G4SandiaTable::G4SandiaTable(G4int matI << 
620   }                                            << 
621 }                                              << 
622                                                << 
623 ////////////////////////////////////////////// << 
624                                                << 
625 G4SandiaTable::G4SandiaTable()                 << 
626 {                                              << 
627   fMaterial = nullptr;                         << 
628   fMatNbOfIntervals = 0;                       << 
629   fMatSandiaMatrix = nullptr;                  << 
630   fMatSandiaMatrixPAI = nullptr;               << 
631   fPhotoAbsorptionCof = nullptr;               << 
632                                                << 
633   fMaxInterval = 0;                            << 
634   fVerbose = 0;                                << 
635   fLowerI1 = false;                            << 
636                                                << 
637   fSandiaCofPerAtom.resize(4, 0.0);            << 
638 }                                                 120 }
639                                                   121 
640 ////////////////////////////////////////////// << 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
641                                                   123 
642 void G4SandiaTable::Initialize(const G4Materia << 124 G4double  G4SandiaTable::GetSandiaCofForMaterial(G4int interval, G4int j)                                                 
643 {                                                 125 {
644   fMaterial = mat;                             << 126    assert (interval>=0 && interval<fMatNbOfIntervals && j>=0 && j<5);                      
645   ComputeMatSandiaMatrixPAI();                 << 127    return ((*(*fMatSandiaMatrix)(interval))(j)); 
646 }                                                 128 }
647                                                   129 
648 ////////////////////////////////////////////// << 130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
649                                                << 
650 G4int G4SandiaTable::GetMaxInterval() const {  << 
651                                                << 
652 ////////////////////////////////////////////// << 
653                                                   131 
654 G4double** G4SandiaTable::GetPointerToCof()    << 132 G4double* G4SandiaTable::GetSandiaCofForMaterial(G4double energy)
655 {                                                 133 {
656   if (fPhotoAbsorptionCof == nullptr) {        << 134    G4int interval = fMatNbOfIntervals - 1;
657     ComputeMatTable();                         << 135    while ((interval>0)&&(energy<(*(*fMatSandiaMatrix)(interval))(0))) interval--; 
658   }                                            << 136    return &((*(*fMatSandiaMatrix)(interval))(1));
659   return fPhotoAbsorptionCof;                  << 
660 }                                                 137 }
661                                                   138 
662 ////////////////////////////////////////////// << 139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
663                                                << 
664 void G4SandiaTable::SandiaSwap(G4double** da,  << 
665 {                                              << 
666   G4double tmp = da[i][0];                     << 
667   da[i][0] = da[j][0];                         << 
668   da[j][0] = tmp;                              << 
669 }                                              << 
670                                                   140 
671 ////////////////////////////////////////////// << 141 ////////////////////////////////////////////////////////////////////////
                                                   >> 142 ////////////////////////////////////////////////////////////////////////
                                                   >> 143 //
                                                   >> 144 // Methods for PAI model
672                                                   145 
673 G4double G4SandiaTable::GetPhotoAbsorpCof(G4in << 
674 {                                              << 
675   return fPhotoAbsorptionCof[i][j] * funitc[j] << 
676 }                                              << 
677                                                   146 
678 ////////////////////////////////////////////// << 147 ///////////////////////////////////////////////////////////////////////
679 //                                                148 //
680 // Bubble sorting of left energy interval in S    149 // Bubble sorting of left energy interval in SandiaTable in ascening order
681 //                                                150 //
682                                                   151 
683 void G4SandiaTable::SandiaSort(G4double** da,  << 152 void
                                                   >> 153 G4SandiaTable::SandiaSort(G4double** da ,
                                                   >> 154         G4int sz )
684 {                                                 155 {
685   for (G4int i = 1; i < sz; ++i) {             << 156    for(G4int i = 1 ;i < sz ; i++ ) 
686     for (G4int j = i + 1; j < sz; ++j) {       << 157    {
687       if (da[i][0] > da[j][0]) {               << 158      for(G4int j = i + 1 ;j < sz ; j++ )
688         SandiaSwap(da, i, j);                  << 159      {
689       }                                        << 160        if(da[i][0] > da[j][0]) 
690     }                                          << 161        {
691   }                                            << 162     SandiaSwap(da,i,j) ;
                                                   >> 163        }
                                                   >> 164      }
                                                   >> 165    }
692 }                                                 166 }
693                                                   167 
694 ////////////////////////////////////////////// << 168 ////////////////////////////////////////////////////////////////////////////
695 //                                                169 //
696 //  SandiaIntervals                            << 170 //  SandiaIntervals 
697 //                                                171 //
698                                                   172 
699 G4int G4SandiaTable::SandiaIntervals(G4int Z[] << 173 G4int
                                                   >> 174 G4SandiaTable::SandiaIntervals(G4int Z[],
                                                   >> 175              G4int el )
700 {                                                 176 {
701   G4int c, i, flag = 0, n1 = 1;                << 177   G4int c,i ;
702   G4int j, c1, k1, k2;                         << 
703   G4double I1;                                 << 
704   fMaxInterval = 0;                            << 
705                                                << 
706   for (i = 0; i < el; ++i) {                   << 
707     fMaxInterval += fNbOfIntervals[Z[i]];      << 
708   }                                            << 
709                                                   178 
710   fMaxInterval += 2;                           << 179   fMaxInterval = 0 ;
711                                                   180 
712   if (fVerbose > 0) {                          << 181   for(i=0;i<el;i++)
713     G4cout << "begin sanInt, fMaxInterval = "  << 182   {
                                                   >> 183     fMaxInterval += fNbOfIntervals[Z[i]] ; 
714   }                                               184   }
                                                   >> 185   fMaxInterval += 2 ;
715                                                   186 
716   fPhotoAbsorptionCof = new G4double*[fMaxInte << 187 //  G4cout<<"fMaxInterval = "<<fMaxInterval<<G4endl ;
717                                                   188 
718   for (i = 0; i < fMaxInterval; ++i) {         << 189   fPhotoAbsorptionCof = new G4double* [fMaxInterval] ;
719     fPhotoAbsorptionCof[i] = new G4double[5];  << 
720   }                                            << 
721   //  for(c = 0; c < fIntervalLimit; ++c)   // << 
722                                                   190 
723   for (c = 0; c < fMaxInterval; ++c) {         << 191   for(i = 0 ; i < fMaxInterval ; i++)  
724     fPhotoAbsorptionCof[c][0] = 0.;            << 192   {
                                                   >> 193      fPhotoAbsorptionCof[i] = new G4double[5] ;
725   }                                               194   }
726                                                   195 
727   c = 1;                                       << 
728                                                << 
729   for (i = 0; i < el; ++i) {                   << 
730     I1 = fIonizationPotentials[Z[i]] * keV;  / << 
731     n1 = 1;  // potential in keV               << 
732                                                << 
733     for (j = 1; j < Z[i]; ++j) {               << 
734       n1 += fNbOfIntervals[j];                 << 
735     }                                          << 
736                                                   196 
737     G4int n2 = n1 + fNbOfIntervals[Z[i]];      << 197   //  for(c = 0 ; c < fIntervalLimit ; c++)   // just in case
738                                                   198 
739     for (k1 = n1; k1 < n2; k1++) {             << 199   for(c = 0 ; c < fMaxInterval ; c++)   // just in case
740       if (I1 > fSandiaTable[k1][0]) {          << 200   {
741         continue;  // no ionization for energi << 201      fPhotoAbsorptionCof[c][0] = 0. ;
742       }  // ionisation potential)              << 202   }
743       break;                                   << 203   c = 1 ;
                                                   >> 204   for(i = 0 ; i < el ; i++)
                                                   >> 205   {
                                                   >> 206     G4double I1 = fIonizationPotentials[Z[i]]*keV ;  // First ionization
                                                   >> 207     G4int n1 = 1 ;                                     // potential in keV
                                                   >> 208     G4int j, c1, k1, k2 ;
                                                   >> 209     for(j = 1 ; j < Z[i] ; j++)
                                                   >> 210     {
                                                   >> 211       n1 += fNbOfIntervals[j] ;
744     }                                             212     }
745     flag = 0;                                  << 213     G4int n2 = n1 + fNbOfIntervals[Z[i]] ;
746                                                << 214     
747     for (c1 = 1; c1 < c; c1++) {               << 215     for(k1 = n1 ; k1 < n2 ; k1++)
748       if (fPhotoAbsorptionCof[c1][0] == I1)  / << 216     {
                                                   >> 217       if(I1  > fSandiaTable[k1][0])
                                                   >> 218       {
                                                   >> 219    continue ;    // no ionization for energies smaller than I1 (first
                                                   >> 220       }          // ionisation potential)        
                                                   >> 221       break ;
                                                   >> 222     }
                                                   >> 223     G4int flag = 0 ;
                                                   >> 224     
                                                   >> 225     for(c1 = 1 ; c1 < c ; c1++)
                                                   >> 226     {
                                                   >> 227       if(fPhotoAbsorptionCof[c1][0] == I1) // this value already has existed
749       {                                           228       {
750         flag = 1;                              << 229   flag = 1 ;                      
751         break;                                 << 230   break ;                         
752       }                                           231       }
753     }                                             232     }
754     if (flag == 0) {                           << 233     if(flag == 0)
755       fPhotoAbsorptionCof[c][0] = I1;          << 234     {
756       ++c;                                     << 235       fPhotoAbsorptionCof[c][0] = I1 ;
                                                   >> 236       c++ ;
757     }                                             237     }
758     for (k2 = k1; k2 < n2; k2++) {             << 238     for(k2 = k1 ; k2 < n2 ; k2++)
759       flag = 0;                                << 239     {
760                                                << 240       flag = 0 ;
761       for (c1 = 1; c1 < c; c1++) {             << 241       for(c1 = 1 ; c1 < c ; c1++)
762         if (fPhotoAbsorptionCof[c1][0] == fSan << 242       {
763           flag = 1;                            << 243         if(fPhotoAbsorptionCof[c1][0] == fSandiaTable[k2][0])
764           break;                               << 244         {
                                                   >> 245     flag = 1 ;
                                                   >> 246     break ;
765         }                                         247         }
766       }                                           248       }
767       if (flag == 0) {                         << 249       if(flag == 0)
768         fPhotoAbsorptionCof[c][0] = fSandiaTab << 250       {
769         if (fVerbose > 0) {                    << 251         fPhotoAbsorptionCof[c][0] = fSandiaTable[k2][0] ;
770           G4cout << "sanInt, c = " << c << ",  << 252   c++ ;
771         }                                      << 
772         ++c;                                   << 
773       }                                           253       }
774     }                                          << 254     }       
775   }  // end for(i)                             << 255   }   // end for(i)
776                                                << 256   
777   SandiaSort(fPhotoAbsorptionCof, c);          << 257   SandiaSort(fPhotoAbsorptionCof,c) ;
778   fMaxInterval = c;                            << 258   fMaxInterval = c ;
779   if (fVerbose > 0) {                          << 259   return c ;
780     G4cout << "end SanInt, fMaxInterval = " << << 260 }   
781   }                                            << 
782   return c;                                    << 
783 }                                              << 
784                                                   261 
785 ////////////////////////////////////////////// << 262 ///////////////////////////////////////////////////////////////////////
786 //                                                263 //
787 //  SandiaMixing                                  264 //  SandiaMixing
788 //                                                265 //
789                                                   266 
790 G4int G4SandiaTable::SandiaMixing(G4int Z[], c << 267 G4int
791 {                                              << 268 G4SandiaTable::SandiaMixing(         G4int Z[],
792   G4int i, j, n1, k, c = 1, jj, kk;            << 269              const G4double fractionW[],
793   G4double I1, B1, B2, E1, E2;                 << 270                    G4int el,
794                                                << 271                    G4int mi     )
795   for (i = 0; i < mi; ++i) {                   << 272 {
796     for (j = 1; j < 5; ++j) {                  << 273    G4int i;
797       fPhotoAbsorptionCof[i][j] = 0.;          << 274    
798     }                                          << 275    for(i = 0 ; i < mi ; i++)
799   }                                            << 276    {
800   for (i = 0; i < el; ++i) {                   << 277       for(G4int j = 1 ; j < 5 ; j++) fPhotoAbsorptionCof[i][j] = 0. ;
801     n1 = 1;                                    << 278    }
802     I1 = fIonizationPotentials[Z[i]] * keV;    << 279    for(i = 0 ; i < el ; i++)
803                                                << 280    {
804     for (j = 1; j < Z[i]; ++j) {               << 281       G4int n1 = 1 ;
805       n1 += fNbOfIntervals[j];                 << 282       G4int j, k ;
806     }                                          << 283       G4double I1 = fIonizationPotentials[Z[i]]*keV ;
807                                                << 284       for(j = 1 ; j < Z[i] ; j++)
808     G4int n2 = n1 + fNbOfIntervals[Z[i]] - 1;  << 
809                                                << 
810     for (k = n1; k < n2; ++k) {                << 
811       B1 = fSandiaTable[k][0];                 << 
812       B2 = fSandiaTable[k + 1][0];             << 
813                                                << 
814       for (c = 1; c < mi - 1; ++c) {           << 
815         E1 = fPhotoAbsorptionCof[c][0];        << 
816         E2 = fPhotoAbsorptionCof[c + 1][0];    << 
817                                                << 
818         if (B1 > E1 || B2 < E2 || E1 < I1) {   << 
819           continue;                            << 
820         }                                      << 
821                                                << 
822         for (j = 1; j < 5; ++j) {              << 
823           fPhotoAbsorptionCof[c][j] += fSandia << 
824           if (fVerbose > 0) {                  << 
825             G4cout << "c=" << c << "; j=" << j << 
826                    << "; frW=" << fractionW[i] << 
827           }                                    << 
828         }                                      << 
829       }                                        << 
830     }                                          << 
831     for (j = 1; j < 5; ++j)  // Last interval  << 
832     {                                          << 
833       fPhotoAbsorptionCof[mi - 1][j] += fSandi << 
834       if (fVerbose > 0) {                      << 
835         G4cout << "mi-1=" << mi - 1 << "; j="  << 
836                << "; frW=" << fractionW[i] <<  << 
837       }                                        << 
838     }                                          << 
839   }  // for(i)                                 << 
840   c = 0;  // Deleting of first intervals where << 
841                                                << 
842   do {                                         << 
843     ++c;                                       << 
844                                                << 
845     if (fPhotoAbsorptionCof[c][1] != 0.0 || fP << 
846         fPhotoAbsorptionCof[c][3] != 0.0 || fP << 
847     {                                          << 
848       continue;                                << 
849     }                                          << 
850                                                << 
851     for (jj = 2; jj < mi; ++jj) {              << 
852       for (kk = 0; kk < 5; ++kk) {             << 
853         fPhotoAbsorptionCof[jj - 1][kk] = fPho << 
854       }                                        << 
855     }                                          << 
856     mi--;                                      << 
857     c--;                                       << 
858   }                                            << 
859   // Loop checking, 07-Aug-2015, Vladimir Ivan << 
860   while (c < mi - 1);                          << 
861                                                << 
862   if (fVerbose > 0) {                          << 
863     G4cout << "end SanMix, mi = " << mi << G4e << 
864   }                                            << 
865                                                << 
866   return mi;                                   << 
867 }                                              << 
868                                                << 
869 ////////////////////////////////////////////// << 
870                                                << 
871 G4int G4SandiaTable::GetMatNbOfIntervals() con << 
872                                                << 
873 ////////////////////////////////////////////// << 
874                                                << 
875 G4double G4SandiaTable::GetSandiaPerAtom(G4int << 
876 {                                              << 
877 #ifdef G4VERBOSE                               << 
878   if (Z < 1 || Z > 100) {                      << 
879     Z = PrintErrorZ(Z, "GetSandiaPerAtom");    << 
880   }                                            << 
881   if (interval < 0 || interval >= fNbOfInterva << 
882     PrintErrorV("GetSandiaPerAtom");           << 
883     interval = (interval < 0) ? 0 : fNbOfInter << 
884   }                                            << 
885   if (j < 0 || j > 4) {                        << 
886     PrintErrorV("GetSandiaPerAtom");           << 
887     j = (j < 0) ? 0 : 4;                       << 
888   }                                            << 
889 #endif                                         << 
890   G4int row = fCumulInterval[Z - 1] + interval << 
891   G4double x = fSandiaTable[row][0] * CLHEP::k << 
892   if (j > 0) {                                 << 
893     x = Z * CLHEP::amu / fZtoAratio[Z] * fSand << 
894   }                                            << 
895   return x;                                    << 
896 }                                              << 
897                                                << 
898 ////////////////////////////////////////////// << 
899                                                << 
900 G4double G4SandiaTable::GetSandiaCofForMateria << 
901 {                                              << 
902 #ifdef G4VERBOSE                               << 
903   if (interval < 0 || interval >= fMatNbOfInte << 
904     PrintErrorV("GetSandiaCofForMaterial");    << 
905     interval = (interval < 0) ? 0 : fMatNbOfIn << 
906   }                                            << 
907   if (j < 0 || j > 4) {                        << 
908     PrintErrorV("GetSandiaCofForMaterial");    << 
909     j = (j < 0) ? 0 : 4;                       << 
910   }                                            << 
911 #endif                                         << 
912   return ((*(*fMatSandiaMatrix)[interval])[j]) << 
913 }                                              << 
914                                                << 
915 ////////////////////////////////////////////// << 
916                                                << 
917 const G4double* G4SandiaTable::GetSandiaCofFor << 
918 {                                              << 
919   G4int interval = 0;                          << 
920   if (energy > (*(*fMatSandiaMatrix)[0])[0]) { << 
921     interval = fMatNbOfIntervals - 1;          << 
922     // Loop checking, 07-Aug-2015, Vladimir Iv << 
923     while ((interval > 0) && (energy < (*(*fMa << 
924       --interval;                              << 
925     }                                          << 
926   }                                            << 
927   return &((*(*fMatSandiaMatrix)[interval])[1] << 
928 }                                              << 
929                                                << 
930 ////////////////////////////////////////////// << 
931                                                << 
932 G4double G4SandiaTable::GetSandiaMatTable(G4in << 
933 {                                              << 
934 #ifdef G4VERBOSE                               << 
935   if (interval < 0 || interval >= fMatNbOfInte << 
936     PrintErrorV("GetSandiaCofForMaterial");    << 
937     interval = (interval < 0) ? 0 : fMatNbOfIn << 
938   }                                            << 
939   if (j < 0 || j > 4) {                        << 
940     PrintErrorV("GetSandiaCofForMaterial");    << 
941     j = (j < 0) ? 0 : 4;                       << 
942   }                                            << 
943 #endif                                         << 
944   return ((*(*fMatSandiaMatrix)[interval])[j]) << 
945 }                                              << 
946                                                << 
947 ////////////////////////////////////////////// << 
948                                                << 
949 G4double G4SandiaTable::GetSandiaMatTablePAI(G << 
950 {                                              << 
951 #ifdef G4VERBOSE                               << 
952   if (interval < 0 || interval >= fMaxInterval << 
953     PrintErrorV("GetSandiaCofForMaterialPAI"); << 
954     interval = (interval < 0) ? 0 : fMaxInterv << 
955   }                                            << 
956   if (j < 0 || j > 4) {                        << 
957     PrintErrorV("GetSandiaCofForMaterialPAI"); << 
958     j = (j < 0) ? 0 : 4;                       << 
959   }                                            << 
960 #endif                                         << 
961   return ((*(*fMatSandiaMatrixPAI)[interval])[ << 
962 }                                              << 
963                                                << 
964 ////////////////////////////////////////////// << 
965 //                                             << 
966 //  Sandia interval and mixing calculations fo << 
967 //                                             << 
968                                                << 
969 void G4SandiaTable::ComputeMatTable()          << 
970 {                                              << 
971   G4int elm, c, i, j, jj, k, kk, k1, k2, c1, n << 
972                                                << 
973   const auto noElm = (G4int)fMaterial->GetNumb << 
974   const G4ElementVector* ElementVector = fMate << 
975   auto Z = new G4int[noElm];  // Atomic number << 
976                                                << 
977   fMaxInterval = 0;                            << 
978   for (elm = 0; elm < noElm; ++elm) {          << 
979     Z[elm] = (*ElementVector)[elm]->GetZasInt( << 
980     fMaxInterval += fNbOfIntervals[Z[elm]];    << 
981   }                                            << 
982   fMaxInterval += 2;                           << 
983                                                << 
984   //  G4cout<<"fMaxInterval = "<<fMaxInterval< << 
985                                                << 
986   fPhotoAbsorptionCof = new G4double*[fMaxInte << 
987                                                << 
988   for (i = 0; i < fMaxInterval; ++i) {         << 
989     fPhotoAbsorptionCof[i] = new G4double[5];  << 
990   }                                            << 
991                                                << 
992   //  for(c = 0; c < fIntervalLimit; ++c)   // << 
993                                                << 
994   for (c = 0; c < fMaxInterval; ++c)  // just  << 
995   {                                            << 
996     fPhotoAbsorptionCof[c][0] = 0.;            << 
997   }                                            << 
998   c = 1;                                       << 
999                                                << 
1000   for (i = 0; i < noElm; ++i) {               << 
1001     G4double I1 = fIonizationPotentials[Z[i]] << 
1002     n1 = 1;  // potential in keV              << 
1003                                               << 
1004     for (j = 1; j < Z[i]; ++j) {              << 
1005       n1 += fNbOfIntervals[j];                << 
1006     }                                         << 
1007     G4int n2 = n1 + fNbOfIntervals[Z[i]];     << 
1008                                               << 
1009     for (k1 = n1; k1 < n2; ++k1) {            << 
1010       if (I1 > fSandiaTable[k1][0]) {         << 
1011         continue;  // no ionization for energ << 
1012       }  // ionisation potential)             << 
1013       break;                                  << 
1014     }                                         << 
1015     G4int flag = 0;                           << 
1016                                               << 
1017     for (c1 = 1; c1 < c; ++c1) {              << 
1018       if (fPhotoAbsorptionCof[c1][0] == I1)   << 
1019       {                                          285       {
1020         flag = 1;                             << 286          n1 += fNbOfIntervals[j] ;
1021         break;                                << 
1022       }                                       << 
1023     }                                         << 
1024     if (flag == 0) {                          << 
1025       fPhotoAbsorptionCof[c][0] = I1;         << 
1026       ++c;                                    << 
1027     }                                         << 
1028     for (k2 = k1; k2 < n2; ++k2) {            << 
1029       flag = 0;                               << 
1030                                               << 
1031       for (c1 = 1; c1 < c; ++c1) {            << 
1032         if (fPhotoAbsorptionCof[c1][0] == fSa << 
1033           flag = 1;                           << 
1034           break;                              << 
1035         }                                     << 
1036       }                                       << 
1037       if (flag == 0) {                        << 
1038         fPhotoAbsorptionCof[c][0] = fSandiaTa << 
1039         ++c;                                  << 
1040       }                                       << 
1041     }                                         << 
1042   }  // end for(i)                            << 
1043                                               << 
1044   SandiaSort(fPhotoAbsorptionCof, c);         << 
1045   fMaxInterval = c;                           << 
1046                                               << 
1047   const G4double* fractionW = fMaterial->GetF << 
1048                                               << 
1049   for (i = 0; i < fMaxInterval; ++i) {        << 
1050     for (j = 1; j < 5; ++j) {                 << 
1051       fPhotoAbsorptionCof[i][j] = 0.;         << 
1052     }                                         << 
1053   }                                           << 
1054   for (i = 0; i < noElm; ++i) {               << 
1055     n1 = 1;                                   << 
1056     G4double I1 = fIonizationPotentials[Z[i]] << 
1057                                               << 
1058     for (j = 1; j < Z[i]; ++j) {              << 
1059       n1 += fNbOfIntervals[j];                << 
1060     }                                         << 
1061     G4int n2 = n1 + fNbOfIntervals[Z[i]] - 1; << 
1062                                               << 
1063     for (k = n1; k < n2; ++k) {               << 
1064       G4double B1 = fSandiaTable[k][0];       << 
1065       G4double B2 = fSandiaTable[k + 1][0];   << 
1066       for (G4int q = 1; q < fMaxInterval - 1; << 
1067         G4double E1 = fPhotoAbsorptionCof[q][ << 
1068         G4double E2 = fPhotoAbsorptionCof[q + << 
1069         if (B1 > E1 || B2 < E2 || E1 < I1) {  << 
1070           continue;                           << 
1071         }                                     << 
1072         for (j = 1; j < 5; ++j) {             << 
1073           fPhotoAbsorptionCof[q][j] += fSandi << 
1074         }                                     << 
1075       }                                          287       }
1076     }                                         << 288       G4int n2 = n1 + fNbOfIntervals[Z[i]] - 1 ;
1077     for (j = 1; j < 5; ++j)  // Last interval << 
1078     {                                         << 
1079       fPhotoAbsorptionCof[fMaxInterval - 1][j << 
1080     }                                         << 
1081   }  // for(i)                                << 
1082                                                  289 
1083   c = 0;  // Deleting of first intervals wher << 290       for(k = n1 ; k < n2 ; k++)
1084                                               << 291       {
1085   do {                                        << 292          G4double B1 = fSandiaTable[k][0] ;
1086     ++c;                                      << 293          G4double B2 = fSandiaTable[k+1][0] ;
1087                                               << 294          for(G4int c = 1 ; c < mi-1 ; c++)
1088     if (fPhotoAbsorptionCof[c][1] != 0.0 || f << 295          {
1089         fPhotoAbsorptionCof[c][3] != 0.0 || f << 296             G4double E1 = fPhotoAbsorptionCof[c][0] ;
                                                   >> 297             G4double E2 = fPhotoAbsorptionCof[c+1][0] ;
                                                   >> 298             if(B1 > E1 || B2 < E2 || E1 < I1)
                                                   >> 299       {
                                                   >> 300          continue ;
                                                   >> 301       }
                                                   >> 302       for(j = 1 ; j < 5 ; j++)
                                                   >> 303         {
                                                   >> 304                fPhotoAbsorptionCof[c][j] += fSandiaTable[k][j]*fractionW[i] ;
                                                   >> 305       }
                                                   >> 306     }  
                                                   >> 307        }   
                                                   >> 308        for(j = 1 ; j < 5 ; j++)   // Last interval
                                                   >> 309        {
                                                   >> 310           fPhotoAbsorptionCof[mi-1][j] += fSandiaTable[k][j]*fractionW[i] ;
                                                   >> 311        }
                                                   >> 312     }     // for(i)
                                                   >> 313     G4int c = 0 ;     // Deleting of first intervals where all coefficients = 0
                                                   >> 314     do                        
1090     {                                            315     {
1091       continue;                               << 316        c++ ;
1092     }                                         << 317        if( fPhotoAbsorptionCof[c][1] != 0.0 ||
1093                                               << 318      fPhotoAbsorptionCof[c][2] != 0.0 ||
1094     for (jj = 2; jj < fMaxInterval; ++jj) {   << 319      fPhotoAbsorptionCof[c][3] != 0.0 || 
1095       for (kk = 0; kk < 5; ++kk) {            << 320      fPhotoAbsorptionCof[c][4] != 0.0     )
1096         fPhotoAbsorptionCof[jj - 1][kk] = fPh << 321        {
1097       }                                       << 322     continue ;
1098     }                                         << 323        }
1099     --fMaxInterval;                           << 324        for(G4int jj = 2 ; jj < mi ; jj++)
1100     --c;                                      << 325        {
1101   }                                           << 326     for(G4int kk = 0 ; kk < 5 ; kk++)
1102   // Loop checking, 07-Aug-2015, Vladimir Iva << 327     {
1103   while (c < fMaxInterval - 1);               << 328        fPhotoAbsorptionCof[jj-1][kk]= fPhotoAbsorptionCof[jj][kk] ;
1104                                               << 329     }
1105   // create the sandia matrix for this materi << 330        }
                                                   >> 331        mi-- ;
                                                   >> 332        c-- ;
                                                   >> 333     }
                                                   >> 334     while(c < mi - 1) ;
                                                   >> 335     
                                                   >> 336     return mi ;
                                                   >> 337 }  
1106                                                  338 
1107   --fMaxInterval;  // vmg 20.11.10            << 339 //     G4SandiaTable class -- end of implementation file
1108                                               << 340 //
1109   fMatSandiaMatrix = new G4OrderedTable();    << 341 ////////////////////////////////////////////////////////////////////////////
1110                                               << 
1111   for (i = 0; i < fMaxInterval; ++i) {        << 
1112     fMatSandiaMatrix->push_back(new G4DataVec << 
1113   }                                           << 
1114   for (i = 0; i < fMaxInterval; ++i) {        << 
1115     for (j = 0; j < 5; ++j) {                 << 
1116       (*(*fMatSandiaMatrix)[i])[j] = fPhotoAb << 
1117     }                                         << 
1118   }                                           << 
1119   fMatNbOfIntervals = fMaxInterval;           << 
1120                                                  342 
1121   if (fVerbose > 0) {                         << 
1122     G4cout << "vmg, G4SandiaTable::ComputeMat << 
1123                                                  343 
1124     for (i = 0; i < fMaxInterval; ++i) {      << 
1125       G4cout << i << "\t" << GetSandiaCofForM << 
1126              << this->GetSandiaCofForMaterial << 
1127              << "\t" << this->GetSandiaCofFor << 
1128              << this->GetSandiaCofForMaterial << 
1129     }                                         << 
1130   }                                           << 
1131   delete[] Z;                                 << 
1132   return;                                     << 
1133 }                                             << 
1134                                                  344