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 10.5.p1)


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