Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/standard/src/G4PAIxSection.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 /processes/electromagnetic/standard/src/G4PAIxSection.cc (Version 11.3.0) and /processes/electromagnetic/standard/src/G4PAIxSection.cc (Version 10.0.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G4PAIxSection.cc 84489 2014-10-16 09:51:31Z gcosmo $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-03-ref-06 $
 27 //                                                 29 //
 28 //                                                 30 // 
 29 // G4PAIxSection.cc -- class implementation fi     31 // G4PAIxSection.cc -- class implementation file
 30 //                                                 32 //
 31 // GEANT 4 class implementation file               33 // GEANT 4 class implementation file
 32 //                                                 34 //
 33 // For information related to this code, pleas     35 // For information related to this code, please, contact
 34 // the Geant4 Collaboration.                       36 // the Geant4 Collaboration.
 35 //                                                 37 //
 36 // R&D: Vladimir.Grichine@cern.ch                  38 // R&D: Vladimir.Grichine@cern.ch
 37 //                                                 39 //
 38 // History:                                        40 // History:
 39 //                                                 41 //
 40 // 13.05.03 V. Grichine, bug fixed for maxEner     42 // 13.05.03 V. Grichine, bug fixed for maxEnergyTransfer > max interval energy
 41 // 28.05.01 V.Ivanchenko minor changes to prov     43 // 28.05.01 V.Ivanchenko minor changes to provide ANSI -wall compilation 
 42 // 17.05.01 V. Grichine, low energy extension      44 // 17.05.01 V. Grichine, low energy extension down to 10*keV of proton
 43 // 20.11.98 adapted to a new Material/SandiaTa     45 // 20.11.98 adapted to a new Material/SandiaTable interface, mma 
 44 // 11.06.97 V. Grichine, 1st version               46 // 11.06.97 V. Grichine, 1st version 
 45 //                                                 47 //
 46                                                    48 
                                                   >>  49 
                                                   >>  50 
 47 #include "G4PAIxSection.hh"                        51 #include "G4PAIxSection.hh"
 48                                                    52 
 49 #include "globals.hh"                              53 #include "globals.hh"
 50 #include "G4PhysicalConstants.hh"                  54 #include "G4PhysicalConstants.hh"
 51 #include "G4SystemOfUnits.hh"                      55 #include "G4SystemOfUnits.hh"
 52 #include "G4ios.hh"                                56 #include "G4ios.hh"
 53 #include "G4Poisson.hh"                            57 #include "G4Poisson.hh"
 54 #include "G4Material.hh"                           58 #include "G4Material.hh"
 55 #include "G4MaterialCutsCouple.hh"                 59 #include "G4MaterialCutsCouple.hh"
 56 #include "G4SandiaTable.hh"                        60 #include "G4SandiaTable.hh"
 57                                                    61 
 58 using namespace std;                               62 using namespace std;
 59                                                    63 
 60 /* *******************************************     64 /* ******************************************************************
 61                                                    65 
 62 // Init  array of Lorentz factors                  66 // Init  array of Lorentz factors
 63                                                    67 
 64 const G4double G4PAIxSection::fLorentzFactor[2     68 const G4double G4PAIxSection::fLorentzFactor[22] =
 65 {                                                  69 {
 66           0.0 ,     1.1 ,   1.2 ,   1.3 ,    1     70           0.0 ,     1.1 ,   1.2 ,   1.3 ,    1.5 ,    1.8 ,  2.0 ,
 67           2.5 ,     3.0 ,   4.0 ,   7.0 ,   10     71           2.5 ,     3.0 ,   4.0 ,   7.0 ,   10.0 ,   20.0 , 40.0 ,
 68          70.0 ,   100.0 , 300.0 , 600.0 , 1000     72          70.0 ,   100.0 , 300.0 , 600.0 , 1000.0 , 3000.0 ,
 69       10000.0 , 50000.0                            73       10000.0 , 50000.0
 70 };                                                 74 };
 71                                                    75 
 72 const G4int G4PAIxSection::                        76 const G4int G4PAIxSection::
 73 fRefGammaNumber = 29;         // The number of     77 fRefGammaNumber = 29;         // The number of gamma for creation of 
 74                                // spline (9)       78                                // spline (9)
 75                                                    79 
 76 **********************************************     80 ***************************************************************** */ 
 77                                                    81 
 78 // Local class constants                           82 // Local class constants
 79                                                    83 
 80 const G4double G4PAIxSection::fDelta = 0.005;      84 const G4double G4PAIxSection::fDelta = 0.005; // 0.005 energy shift from interval border
 81 const G4double G4PAIxSection::fError = 0.005;      85 const G4double G4PAIxSection::fError = 0.005; // 0.005 error in lin-log approximation
 82                                                    86 
 83 const G4int G4PAIxSection::fMaxSplineSize = 10     87 const G4int G4PAIxSection::fMaxSplineSize = 1000;  // Max size of output spline
 84                                                    88                                                     // arrays
 85 //////////////////////////////////////////////     89 //////////////////////////////////////////////////////////////////
 86 //                                                 90 //
 87 // Constructor                                     91 // Constructor
 88 //                                                 92 //
 89                                                    93 
 90 G4PAIxSection::G4PAIxSection()                     94 G4PAIxSection::G4PAIxSection()
 91 {                                                  95 {
 92   fSandia = nullptr;                           <<  96   fSandia = 0;
 93   fMatSandiaMatrix = nullptr;                  <<  97   fMatSandiaMatrix = 0;
 94   fDensity = fElectronDensity = fNormalization     98   fDensity = fElectronDensity = fNormalizationCof = fLowEnergyCof = 0.0;
 95   fIntervalNumber = fSplineNumber = 0;             99   fIntervalNumber = fSplineNumber = 0;
 96   fVerbose = 0;                                   100   fVerbose = 0;
 97                                                   101     
 98   fSplineEnergy          = G4DataVector(fMaxSp    102   fSplineEnergy          = G4DataVector(fMaxSplineSize,0.0);
 99   fRePartDielectricConst = G4DataVector(fMaxSp    103   fRePartDielectricConst = G4DataVector(fMaxSplineSize,0.0);
100   fImPartDielectricConst = G4DataVector(fMaxSp    104   fImPartDielectricConst = G4DataVector(fMaxSplineSize,0.0);
101   fIntegralTerm          = G4DataVector(fMaxSp    105   fIntegralTerm          = G4DataVector(fMaxSplineSize,0.0);
102   fDifPAIxSection        = G4DataVector(fMaxSp    106   fDifPAIxSection        = G4DataVector(fMaxSplineSize,0.0);
103   fdNdxCerenkov          = G4DataVector(fMaxSp    107   fdNdxCerenkov          = G4DataVector(fMaxSplineSize,0.0);
104   fdNdxPlasmon           = G4DataVector(fMaxSp    108   fdNdxPlasmon           = G4DataVector(fMaxSplineSize,0.0);
105   fdNdxMM                = G4DataVector(fMaxSp    109   fdNdxMM                = G4DataVector(fMaxSplineSize,0.0);
106   fdNdxResonance         = G4DataVector(fMaxSp    110   fdNdxResonance         = G4DataVector(fMaxSplineSize,0.0);
107   fIntegralPAIxSection   = G4DataVector(fMaxSp    111   fIntegralPAIxSection   = G4DataVector(fMaxSplineSize,0.0);
108   fIntegralPAIdEdx       = G4DataVector(fMaxSp    112   fIntegralPAIdEdx       = G4DataVector(fMaxSplineSize,0.0);
109   fIntegralCerenkov      = G4DataVector(fMaxSp    113   fIntegralCerenkov      = G4DataVector(fMaxSplineSize,0.0);
110   fIntegralPlasmon       = G4DataVector(fMaxSp    114   fIntegralPlasmon       = G4DataVector(fMaxSplineSize,0.0);
111   fIntegralMM            = G4DataVector(fMaxSp    115   fIntegralMM            = G4DataVector(fMaxSplineSize,0.0);
112   fIntegralResonance     = G4DataVector(fMaxSp    116   fIntegralResonance     = G4DataVector(fMaxSplineSize,0.0);
113                                                   117 
114   fMaterialIndex = 0;                             118   fMaterialIndex = 0;   
115                                                   119 
116   for( G4int i = 0; i < 500; ++i )                120   for( G4int i = 0; i < 500; ++i ) 
117   {                                               121   {
118     for( G4int j = 0; j < 112; ++j )  fPAItabl    122     for( G4int j = 0; j < 112; ++j )  fPAItable[i][j] = 0.0; 
119   }                                               123   }
120 }                                                 124 }
121                                                   125 
122 //////////////////////////////////////////////    126 //////////////////////////////////////////////////////////////////
123 //                                                127 //
124 // Constructor                                    128 // Constructor
125 //                                                129 //
126                                                   130 
127 G4PAIxSection::G4PAIxSection(G4MaterialCutsCou    131 G4PAIxSection::G4PAIxSection(G4MaterialCutsCouple* matCC)
128 {                                                 132 {
129   fDensity       = matCC->GetMaterial()->GetDe    133   fDensity       = matCC->GetMaterial()->GetDensity();
130   G4int matIndex = (G4int)matCC->GetMaterial() << 134   G4int matIndex = matCC->GetMaterial()->GetIndex();
131   fMaterialIndex = matIndex;                      135   fMaterialIndex = matIndex;   
132                                                << 136   fSandia        = new G4SandiaTable(matIndex);
133   const G4MaterialTable* theMaterialTable = G4 << 
134   fSandia = (*theMaterialTable)[matIndex]->Get << 
135                                                << 
136   fVerbose = 0;                                   137   fVerbose = 0;
137                                                   138 
138   G4int i, j;                                     139   G4int i, j; 
139   fMatSandiaMatrix = new G4OrderedTable();        140   fMatSandiaMatrix = new G4OrderedTable();
140                                                   141  
141   for (i = 0; i < fSandia->GetMaxInterval()-1; << 142   for (i = 0; i < fSandia->GetMaxInterval()-1; i++)
142   {                                               143   {
143      fMatSandiaMatrix->push_back(new G4DataVec    144      fMatSandiaMatrix->push_back(new G4DataVector(5,0.));
144   }                                            << 145   }           
145   for (i = 0; i < fSandia->GetMaxInterval()-1; << 146   for (i = 0; i < fSandia->GetMaxInterval()-1; i++)
146   {                                               147   {
147     (*(*fMatSandiaMatrix)[i])[0] = fSandia->Ge    148     (*(*fMatSandiaMatrix)[i])[0] = fSandia->GetSandiaMatTable(i,0);
148                                                   149 
149     for(j = 1; j < 5; ++j)                     << 150     for(j = 1; j < 5; j++)
150     {                                             151     {
151       (*(*fMatSandiaMatrix)[i])[j] = fSandia->    152       (*(*fMatSandiaMatrix)[i])[j] = fSandia->GetSandiaMatTable(i,j)*fDensity;
152     }                                             153     }     
153   }                                               154   }
154   ComputeLowEnergyCof();                       << 155   ComputeLowEnergyCof();                  
155   //  fEnergyInterval = fA1 = fA2 = fA3 = fA4     156   //  fEnergyInterval = fA1 = fA2 = fA3 = fA4 = 0;
156 }                                                 157 }
157                                                   158 
158 //////////////////////////////////////////////    159 ////////////////////////////////////////////////////////////////
159                                                   160 
160 G4PAIxSection::G4PAIxSection(G4int materialInd    161 G4PAIxSection::G4PAIxSection(G4int materialIndex,
161                              G4double maxEnerg << 162            G4double maxEnergyTransfer)
162 {                                                 163 {
163   fSandia = nullptr;                           << 164   fSandia = 0;
164   fMatSandiaMatrix = nullptr;                  << 165   fMatSandiaMatrix = 0;
165   fVerbose = 0;                                   166   fVerbose = 0;
166   const G4MaterialTable* theMaterialTable = G4    167   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
167   G4int i, j;                                     168   G4int i, j;   
168                                                   169 
169   fMaterialIndex   = materialIndex;               170   fMaterialIndex   = materialIndex;   
170   fDensity                = (*theMaterialTable    171   fDensity                = (*theMaterialTable)[materialIndex]->GetDensity();
171   fElectronDensity        = (*theMaterialTable    172   fElectronDensity        = (*theMaterialTable)[materialIndex]->
172                              GetElectronDensit    173                              GetElectronDensity();
173   fIntervalNumber         = (*theMaterialTable    174   fIntervalNumber         = (*theMaterialTable)[materialIndex]->
174                              GetSandiaTable()-    175                              GetSandiaTable()->GetMatNbOfIntervals();
175   fIntervalNumber--;                              176   fIntervalNumber--;      
176   // G4cout<<fDensity<<"\t"<<fElectronDensity<    177   // G4cout<<fDensity<<"\t"<<fElectronDensity<<"\t"<<fIntervalNumber<<G4endl;
177                                                   178 
178   fEnergyInterval = G4DataVector(fIntervalNumb    179   fEnergyInterval = G4DataVector(fIntervalNumber+2,0.0);
179   fA1             = G4DataVector(fIntervalNumb    180   fA1             = G4DataVector(fIntervalNumber+2,0.0);
180   fA2             = G4DataVector(fIntervalNumb    181   fA2             = G4DataVector(fIntervalNumber+2,0.0);
181   fA3             = G4DataVector(fIntervalNumb    182   fA3             = G4DataVector(fIntervalNumber+2,0.0);
182   fA4             = G4DataVector(fIntervalNumb    183   fA4             = G4DataVector(fIntervalNumber+2,0.0);
183                                                   184 
184   for(i = 1; i <= fIntervalNumber; i++ )          185   for(i = 1; i <= fIntervalNumber; i++ )
185     {                                             186     {
186       if(((*theMaterialTable)[materialIndex]->    187       if(((*theMaterialTable)[materialIndex]->
187     GetSandiaTable()->GetSandiaCofForMaterial(    188     GetSandiaTable()->GetSandiaCofForMaterial(i-1,0) >= maxEnergyTransfer) ||
188               i > fIntervalNumber                 189               i > fIntervalNumber               )
189         {                                      << 190   {
190           fEnergyInterval[i] = maxEnergyTransf << 191     fEnergyInterval[i] = maxEnergyTransfer;
191           fIntervalNumber = i;                 << 192     fIntervalNumber = i;
192           break;                               << 193     break;
193         }                                      << 194   }
194          fEnergyInterval[i] = (*theMaterialTab    195          fEnergyInterval[i] = (*theMaterialTable)[materialIndex]->
195                               GetSandiaTable() << 196                         GetSandiaTable()->GetSandiaCofForMaterial(i-1,0);
196          fA1[i]             = (*theMaterialTab    197          fA1[i]             = (*theMaterialTable)[materialIndex]->
197                               GetSandiaTable() << 198                         GetSandiaTable()->GetSandiaCofForMaterial(i-1,1);
198          fA2[i]             = (*theMaterialTab    199          fA2[i]             = (*theMaterialTable)[materialIndex]->
199                               GetSandiaTable() << 200                         GetSandiaTable()->GetSandiaCofForMaterial(i-1,2);
200          fA3[i]             = (*theMaterialTab    201          fA3[i]             = (*theMaterialTable)[materialIndex]->
201                               GetSandiaTable() << 202                         GetSandiaTable()->GetSandiaCofForMaterial(i-1,3);
202          fA4[i]             = (*theMaterialTab    203          fA4[i]             = (*theMaterialTable)[materialIndex]->
203                               GetSandiaTable() << 204                         GetSandiaTable()->GetSandiaCofForMaterial(i-1,4);
204          // G4cout<<i<<"\t"<<fEnergyInterval[i << 205    // G4cout<<i<<"\t"<<fEnergyInterval[i]<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
205          //                               <<fA << 206    //                               <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
206     }                                             207     }   
207   if(fEnergyInterval[fIntervalNumber] != maxEn    208   if(fEnergyInterval[fIntervalNumber] != maxEnergyTransfer)
208     {                                             209     {
209          fIntervalNumber++;                       210          fIntervalNumber++;
210          fEnergyInterval[fIntervalNumber] = ma    211          fEnergyInterval[fIntervalNumber] = maxEnergyTransfer;
211     }                                             212     }
212                                                   213 
213   // Now checking, if two borders are too clos    214   // Now checking, if two borders are too close together
214                                                   215 
215   for(i=1;i<fIntervalNumber;i++)                  216   for(i=1;i<fIntervalNumber;i++)
216     {                                             217     {
217         if(fEnergyInterval[i+1]-fEnergyInterva    218         if(fEnergyInterval[i+1]-fEnergyInterval[i] >
218            1.5*fDelta*(fEnergyInterval[i+1]+fE    219            1.5*fDelta*(fEnergyInterval[i+1]+fEnergyInterval[i]))
219         {                                      << 220   {
220           continue;                               221           continue;
221         }                                      << 222   }
222         else                                      223         else
223         {                                      << 224   {
224           for(j=i;j<fIntervalNumber;j++)          225           for(j=i;j<fIntervalNumber;j++)
225           {                                    << 226     {
226             fEnergyInterval[j] = fEnergyInterv    227             fEnergyInterval[j] = fEnergyInterval[j+1];
227                         fA1[j] = fA1[j+1];        228                         fA1[j] = fA1[j+1];
228                         fA2[j] = fA2[j+1];        229                         fA2[j] = fA2[j+1];
229                         fA3[j] = fA3[j+1];        230                         fA3[j] = fA3[j+1];
230                         fA4[j] = fA4[j+1];        231                         fA4[j] = fA4[j+1];
231           }                                    << 232     }
232           fIntervalNumber--;                      233           fIntervalNumber--;
233           i--;                                    234           i--;
234         }                                      << 235   }
235     }                                             236     }
236                                                   237 
237                                                   238 
238       /* *********************************        239       /* *********************************
239                                                   240 
240       fSplineEnergy          = new G4double[fM    241       fSplineEnergy          = new G4double[fMaxSplineSize];   
241       fRePartDielectricConst = new G4double[fM    242       fRePartDielectricConst = new G4double[fMaxSplineSize];   
242       fImPartDielectricConst = new G4double[fM    243       fImPartDielectricConst = new G4double[fMaxSplineSize];   
243       fIntegralTerm          = new G4double[fM    244       fIntegralTerm          = new G4double[fMaxSplineSize];   
244       fDifPAIxSection        = new G4double[fM    245       fDifPAIxSection        = new G4double[fMaxSplineSize];   
245       fIntegralPAIxSection   = new G4double[fM    246       fIntegralPAIxSection   = new G4double[fMaxSplineSize];   
246                                                   247       
247       for(i=0;i<fMaxSplineSize;i++)               248       for(i=0;i<fMaxSplineSize;i++)
248       {                                           249       {
249          fSplineEnergy[i]          = 0.0;         250          fSplineEnergy[i]          = 0.0;   
250          fRePartDielectricConst[i] = 0.0;         251          fRePartDielectricConst[i] = 0.0;   
251          fImPartDielectricConst[i] = 0.0;         252          fImPartDielectricConst[i] = 0.0;   
252          fIntegralTerm[i]          = 0.0;         253          fIntegralTerm[i]          = 0.0;   
253          fDifPAIxSection[i]        = 0.0;         254          fDifPAIxSection[i]        = 0.0;   
254          fIntegralPAIxSection[i]   = 0.0;         255          fIntegralPAIxSection[i]   = 0.0;   
255       }                                           256       }
256       ****************************************    257       **************************************************  */   
257       ComputeLowEnergyCof();                      258       ComputeLowEnergyCof();      
258       InitPAI();  // create arrays allocated a    259       InitPAI();  // create arrays allocated above
259       /*                                          260       /*     
260       delete[] fEnergyInterval;                   261       delete[] fEnergyInterval;
261       delete[] fA1;                               262       delete[] fA1;
262       delete[] fA2;                               263       delete[] fA2;
263       delete[] fA3;                               264       delete[] fA3;
264       delete[] fA4;                               265       delete[] fA4; 
265       */                                          266       */   
266 }                                                 267 }
267                                                   268 
268 //////////////////////////////////////////////    269 ////////////////////////////////////////////////////////////////////////
269 //                                                270 //
270 // Constructor called from G4PAIPhotonModel !!    271 // Constructor called from G4PAIPhotonModel !!!
271                                                   272 
272 G4PAIxSection::G4PAIxSection( G4int materialIn    273 G4PAIxSection::G4PAIxSection( G4int materialIndex,
273                               G4double maxEner << 274             G4double maxEnergyTransfer,
274                               G4double betaGam << 275             G4double betaGammaSq,
275                               G4double** photo    276                               G4double** photoAbsCof, 
276                               G4int intNumber     277                               G4int intNumber                   )
277 {                                                 278 {
278   fSandia = nullptr;                           << 279   fSandia = 0;
279   fDensity = fElectronDensity = fNormalization    280   fDensity = fElectronDensity = fNormalizationCof = fLowEnergyCof = 0.0;
280   fIntervalNumber = fSplineNumber = 0;            281   fIntervalNumber = fSplineNumber = 0;
281   fVerbose = 0;                                   282   fVerbose = 0;
282                                                   283     
283   fSplineEnergy          = G4DataVector(500,0.    284   fSplineEnergy          = G4DataVector(500,0.0);
284   fRePartDielectricConst = G4DataVector(500,0.    285   fRePartDielectricConst = G4DataVector(500,0.0);
285   fImPartDielectricConst = G4DataVector(500,0.    286   fImPartDielectricConst = G4DataVector(500,0.0);
286   fIntegralTerm          = G4DataVector(500,0.    287   fIntegralTerm          = G4DataVector(500,0.0);
287   fDifPAIxSection        = G4DataVector(500,0.    288   fDifPAIxSection        = G4DataVector(500,0.0);
288   fdNdxCerenkov          = G4DataVector(500,0.    289   fdNdxCerenkov          = G4DataVector(500,0.0);
289   fdNdxPlasmon           = G4DataVector(500,0.    290   fdNdxPlasmon           = G4DataVector(500,0.0);
290   fdNdxMM                = G4DataVector(500,0.    291   fdNdxMM                = G4DataVector(500,0.0);
291   fdNdxResonance         = G4DataVector(500,0.    292   fdNdxResonance         = G4DataVector(500,0.0);
292   fIntegralPAIxSection   = G4DataVector(500,0.    293   fIntegralPAIxSection   = G4DataVector(500,0.0);
293   fIntegralPAIdEdx       = G4DataVector(500,0.    294   fIntegralPAIdEdx       = G4DataVector(500,0.0);
294   fIntegralCerenkov      = G4DataVector(500,0.    295   fIntegralCerenkov      = G4DataVector(500,0.0);
295   fIntegralPlasmon       = G4DataVector(500,0.    296   fIntegralPlasmon       = G4DataVector(500,0.0);
296   fIntegralMM            = G4DataVector(500,0.    297   fIntegralMM            = G4DataVector(500,0.0);
297   fIntegralResonance     = G4DataVector(500,0.    298   fIntegralResonance     = G4DataVector(500,0.0);
298                                                   299 
299   for( G4int i = 0; i < 500; ++i )                300   for( G4int i = 0; i < 500; ++i ) 
300   {                                               301   {
301     for( G4int j = 0; j < 112; ++j )  fPAItabl    302     for( G4int j = 0; j < 112; ++j )  fPAItable[i][j] = 0.0; 
302   }                                               303   }
303                                                   304 
304   fSandia = nullptr;                           << 305   fSandia = 0;
305   fMatSandiaMatrix = nullptr;                  << 306   fMatSandiaMatrix = 0;
306   const G4MaterialTable* theMaterialTable = G4    307   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
307   G4int i, j;                                     308   G4int i, j; 
308                                                   309   
309   fMaterialIndex   = materialIndex;               310   fMaterialIndex   = materialIndex;      
310   fDensity         = (*theMaterialTable)[mater    311   fDensity         = (*theMaterialTable)[materialIndex]->GetDensity();
311   fElectronDensity = (*theMaterialTable)[mater    312   fElectronDensity = (*theMaterialTable)[materialIndex]->GetElectronDensity();
312                                                   313 
313   fIntervalNumber         = intNumber;            314   fIntervalNumber         = intNumber;
314   fIntervalNumber--;                              315   fIntervalNumber--;
315   //   G4cout<<fDensity<<"\t"<<fElectronDensit    316   //   G4cout<<fDensity<<"\t"<<fElectronDensity<<"\t"<<fIntervalNumber<<G4endl;
316                                                   317   
317   fEnergyInterval = G4DataVector(fIntervalNumb    318   fEnergyInterval = G4DataVector(fIntervalNumber+2,0.0);
318   fA1             = G4DataVector(fIntervalNumb    319   fA1             = G4DataVector(fIntervalNumber+2,0.0);
319   fA2             = G4DataVector(fIntervalNumb    320   fA2             = G4DataVector(fIntervalNumber+2,0.0);
320   fA3             = G4DataVector(fIntervalNumb    321   fA3             = G4DataVector(fIntervalNumber+2,0.0);
321   fA4             = G4DataVector(fIntervalNumb    322   fA4             = G4DataVector(fIntervalNumber+2,0.0);
322                                                   323 
323                                                   324 
324   /*                                              325   /*
325       fEnergyInterval = new G4double[fInterval    326       fEnergyInterval = new G4double[fIntervalNumber+2];
326       fA1             = new G4double[fInterval    327       fA1             = new G4double[fIntervalNumber+2];
327       fA2             = new G4double[fInterval    328       fA2             = new G4double[fIntervalNumber+2];
328       fA3             = new G4double[fInterval    329       fA3             = new G4double[fIntervalNumber+2];
329       fA4             = new G4double[fInterval    330       fA4             = new G4double[fIntervalNumber+2];
330   */                                              331   */
331   for( i = 1; i <= fIntervalNumber; i++ )         332   for( i = 1; i <= fIntervalNumber; i++ )
332     {                                             333     {
333          if( ( photoAbsCof[i-1][0] >= maxEnerg    334          if( ( photoAbsCof[i-1][0] >= maxEnergyTransfer ) ||
334              i > fIntervalNumber )                335              i > fIntervalNumber )
335          {                                        336          {
336             fEnergyInterval[i] = maxEnergyTran    337             fEnergyInterval[i] = maxEnergyTransfer;
337             fIntervalNumber = i;               << 338       fIntervalNumber = i;
338             break;                             << 339       break;
339          }                                        340          }
340          fEnergyInterval[i] = photoAbsCof[i-1]    341          fEnergyInterval[i] = photoAbsCof[i-1][0];
341          fA1[i]             = photoAbsCof[i-1]    342          fA1[i]             = photoAbsCof[i-1][1];
342          fA2[i]             = photoAbsCof[i-1]    343          fA2[i]             = photoAbsCof[i-1][2];
343          fA3[i]             = photoAbsCof[i-1]    344          fA3[i]             = photoAbsCof[i-1][3];
344          fA4[i]             = photoAbsCof[i-1]    345          fA4[i]             = photoAbsCof[i-1][4];
345          // G4cout<<i<<"\t"<<fEnergyInterval[i << 346    // G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
346          //      <<fA3[i]<<"\t"<<fA4[i]<<"\t"< << 347    //      <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
347     }                                             348     }
348       // G4cout<<"i last = "<<i<<"; "<<"fInter    349       // G4cout<<"i last = "<<i<<"; "<<"fIntervalNumber = "<<fIntervalNumber<<G4endl; 
349                                                   350   
350   if(fEnergyInterval[fIntervalNumber] != maxEn    351   if(fEnergyInterval[fIntervalNumber] != maxEnergyTransfer)
351     {                                             352     {
352          fIntervalNumber++;                       353          fIntervalNumber++;
353          fEnergyInterval[fIntervalNumber] = ma    354          fEnergyInterval[fIntervalNumber] = maxEnergyTransfer;
354     }                                             355     }
355       // G4cout<<"after check of max energy tr    356       // G4cout<<"after check of max energy transfer"<<G4endl;
356                                                   357 
357   for( i = 1; i <= fIntervalNumber; i++ )         358   for( i = 1; i <= fIntervalNumber; i++ )
358     {                                             359     {
359         // G4cout<<i<<"\t"<<fEnergyInterval[i] << 360   // G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
360         //   <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4e << 361   //   <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
361     }                                             362     }
362       // Now checking, if two borders are too     363       // Now checking, if two borders are too close together
363                                                   364 
364   for( i = 1; i < fIntervalNumber; i++ )          365   for( i = 1; i < fIntervalNumber; i++ )
365     {                                             366     {
366         if(fEnergyInterval[i+1]-fEnergyInterva    367         if(fEnergyInterval[i+1]-fEnergyInterval[i] >
367            1.5*fDelta*(fEnergyInterval[i+1]+fE    368            1.5*fDelta*(fEnergyInterval[i+1]+fEnergyInterval[i]))
368         {                                      << 369   {
369           continue;                               370           continue;
370         }                                      << 371   }
371         else                                      372         else
372         {                                      << 373   {
373           for(j=i;j<fIntervalNumber;j++)          374           for(j=i;j<fIntervalNumber;j++)
374           {                                    << 375     {
375             fEnergyInterval[j] = fEnergyInterv    376             fEnergyInterval[j] = fEnergyInterval[j+1];
376                         fA1[j] = fA1[j+1];        377                         fA1[j] = fA1[j+1];
377                         fA2[j] = fA2[j+1];        378                         fA2[j] = fA2[j+1];
378                         fA3[j] = fA3[j+1];        379                         fA3[j] = fA3[j+1];
379                         fA4[j] = fA4[j+1];        380                         fA4[j] = fA4[j+1];
380           }                                    << 381     }
381           fIntervalNumber--;                      382           fIntervalNumber--;
382           i--;                                    383           i--;
383         }                                      << 384   }
384     }                                             385     }
385   // G4cout<<"after check of close borders"<<G    386   // G4cout<<"after check of close borders"<<G4endl;
386                                                   387 
387   for( i = 1; i <= fIntervalNumber; i++ )         388   for( i = 1; i <= fIntervalNumber; i++ )
388     {                                             389     {
389         // G4cout<<i<<"\t"<<fEnergyInterval[i] << 390   // G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
390         //  <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4en << 391   //  <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
391     }                                             392     }
392                                                   393 
393   // Preparation of fSplineEnergy array corres    394   // Preparation of fSplineEnergy array corresponding to min ionisation, G~4
394                                                   395 
395   ComputeLowEnergyCof();                          396   ComputeLowEnergyCof();            
396   G4double   betaGammaSqRef =                     397   G4double   betaGammaSqRef = 
397     fLorentzFactor[fRefGammaNumber]*fLorentzFa    398     fLorentzFactor[fRefGammaNumber]*fLorentzFactor[fRefGammaNumber] - 1;
398                                                   399 
399   NormShift(betaGammaSqRef);                      400   NormShift(betaGammaSqRef);             
400   SplainPAI(betaGammaSqRef);                      401   SplainPAI(betaGammaSqRef);
401                                                   402       
402   // Preparation of integral PAI cross section    403   // Preparation of integral PAI cross section for input betaGammaSq
403                                                   404    
404   for(i = 1; i <= fSplineNumber; i++)             405   for(i = 1; i <= fSplineNumber; i++)
405     {                                             406     {
406          fdNdxCerenkov[i]   = PAIdNdxCerenkov(    407          fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,betaGammaSq);
407          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaS    408          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);
408          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i    409          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,betaGammaSq);
409          fdNdxResonance[i]  = PAIdNdxResonance    410          fdNdxResonance[i]  = PAIdNdxResonance(i,betaGammaSq);
410          fDifPAIxSection[i] = DifPAIxSection(i    411          fDifPAIxSection[i] = DifPAIxSection(i,betaGammaSq);
411                                                   412 
412          // G4cout<<i<<"; dNdxC = "<<fdNdxCere << 413    // G4cout<<i<<"; dNdxC = "<<fdNdxCerenkov[i]<<"; dNdxP = "<<fdNdxPlasmon[i]
413          //    <<"; dNdxPAI = "<<fDifPAIxSecti << 414    //    <<"; dNdxPAI = "<<fDifPAIxSection[i]<<G4endl;
414     }                                             415     }
415   IntegralCerenkov();                             416   IntegralCerenkov();
416   IntegralMM();                                   417   IntegralMM();
417   IntegralPlasmon();                              418   IntegralPlasmon();
418   IntegralResonance();                            419   IntegralResonance();
419   IntegralPAIxSection();                          420   IntegralPAIxSection();
420   /*                                              421   /*      
421       delete[] fEnergyInterval;                   422       delete[] fEnergyInterval;
422       delete[] fA1;                               423       delete[] fA1;
423       delete[] fA2;                               424       delete[] fA2;
424       delete[] fA3;                               425       delete[] fA3;
425       delete[] fA4;                               426       delete[] fA4;
426   */                                              427   */    
427 }                                                 428 }
428                                                   429 
429 //////////////////////////////////////////////    430 ////////////////////////////////////////////////////////////////////////
430 //                                                431 //
431 // Test Constructor with beta*gamma square val    432 // Test Constructor with beta*gamma square value
432                                                   433 
433 G4PAIxSection::G4PAIxSection( G4int materialIn    434 G4PAIxSection::G4PAIxSection( G4int materialIndex,
434                               G4double maxEner << 435             G4double maxEnergyTransfer,
435                               G4double betaGam << 436             G4double betaGammaSq          )
436 {                                                 437 {
437   fSandia = nullptr;                           << 438   fSandia = 0;
438   fMatSandiaMatrix = nullptr;                  << 439   fMatSandiaMatrix = 0;
439   fVerbose = 0;                                   440   fVerbose = 0;
440   const G4MaterialTable* theMaterialTable = G4    441   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
441                                                   442 
442   G4int i, j, numberOfElements;                   443   G4int i, j, numberOfElements;   
443                                                   444 
444   fMaterialIndex   = materialIndex;               445   fMaterialIndex   = materialIndex;   
445   fDensity         = (*theMaterialTable)[mater    446   fDensity         = (*theMaterialTable)[materialIndex]->GetDensity();
446   fElectronDensity = (*theMaterialTable)[mater    447   fElectronDensity = (*theMaterialTable)[materialIndex]->GetElectronDensity();
447   numberOfElements = (G4int)(*theMaterialTable << 448   numberOfElements = (*theMaterialTable)[materialIndex]->GetNumberOfElements();
448                                                   449 
449   G4int* thisMaterialZ = new G4int[numberOfEle    450   G4int* thisMaterialZ = new G4int[numberOfElements];
450                                                   451    
451   for( i = 0; i < numberOfElements; ++i )      << 452   for( i = 0; i < numberOfElements; i++ )
452    {                                              453    {
453          thisMaterialZ[i] = (G4int)(*theMateri    454          thisMaterialZ[i] = (G4int)(*theMaterialTable)[materialIndex]->
454                                       GetEleme    455                                       GetElement(i)->GetZ();
455    }                                              456    }
456   // fSandia = new G4SandiaTable(materialIndex    457   // fSandia = new G4SandiaTable(materialIndex);
457   fSandia = (*theMaterialTable)[materialIndex]    458   fSandia = (*theMaterialTable)[materialIndex]->GetSandiaTable();
458   G4SandiaTable     thisMaterialSandiaTable(ma    459   G4SandiaTable     thisMaterialSandiaTable(materialIndex);
459   fIntervalNumber = thisMaterialSandiaTable.Sa    460   fIntervalNumber = thisMaterialSandiaTable.SandiaIntervals(thisMaterialZ,
460                                                << 461                   numberOfElements);
461   fIntervalNumber = thisMaterialSandiaTable.Sa    462   fIntervalNumber = thisMaterialSandiaTable.SandiaMixing
462                            ( thisMaterialZ ,      463                            ( thisMaterialZ ,
463                       (*theMaterialTable)[mate    464                       (*theMaterialTable)[materialIndex]->GetFractionVector() ,
464                              numberOfElements, << 465                  numberOfElements,fIntervalNumber);
465                                                   466 
466   fIntervalNumber--;                              467   fIntervalNumber--;
467                                                   468 
468   fEnergyInterval = G4DataVector(fIntervalNumb    469   fEnergyInterval = G4DataVector(fIntervalNumber+2,0.0);
469   fA1             = G4DataVector(fIntervalNumb    470   fA1             = G4DataVector(fIntervalNumber+2,0.0);
470   fA2             = G4DataVector(fIntervalNumb    471   fA2             = G4DataVector(fIntervalNumber+2,0.0);
471   fA3             = G4DataVector(fIntervalNumb    472   fA3             = G4DataVector(fIntervalNumber+2,0.0);
472   fA4             = G4DataVector(fIntervalNumb    473   fA4             = G4DataVector(fIntervalNumber+2,0.0);
473                                                   474 
474   /*                                              475   /*
475       fEnergyInterval = new G4double[fInterval    476       fEnergyInterval = new G4double[fIntervalNumber+2];
476       fA1             = new G4double[fInterval    477       fA1             = new G4double[fIntervalNumber+2];
477       fA2             = new G4double[fInterval    478       fA2             = new G4double[fIntervalNumber+2];
478       fA3             = new G4double[fInterval    479       fA3             = new G4double[fIntervalNumber+2];
479       fA4             = new G4double[fInterval    480       fA4             = new G4double[fIntervalNumber+2];
480   */                                              481   */
481   for( i = 1; i <= fIntervalNumber; i++ )         482   for( i = 1; i <= fIntervalNumber; i++ )
482     {                                             483     {
483   if((thisMaterialSandiaTable.GetPhotoAbsorpCo    484   if((thisMaterialSandiaTable.GetPhotoAbsorpCof(i,0) >= maxEnergyTransfer) ||
484           i > fIntervalNumber)                    485           i > fIntervalNumber)
485          {                                        486          {
486             fEnergyInterval[i] = maxEnergyTran    487             fEnergyInterval[i] = maxEnergyTransfer;
487             fIntervalNumber = i;               << 488       fIntervalNumber = i;
488             break;                             << 489       break;
489          }                                        490          }
490    fEnergyInterval[i] = thisMaterialSandiaTabl    491    fEnergyInterval[i] = thisMaterialSandiaTable.GetPhotoAbsorpCof(i,0);
491    fA1[i]             = thisMaterialSandiaTabl    492    fA1[i]             = thisMaterialSandiaTable.GetPhotoAbsorpCof(i,1)*fDensity;
492    fA2[i]             = thisMaterialSandiaTabl    493    fA2[i]             = thisMaterialSandiaTable.GetPhotoAbsorpCof(i,2)*fDensity;
493    fA3[i]             = thisMaterialSandiaTabl    494    fA3[i]             = thisMaterialSandiaTable.GetPhotoAbsorpCof(i,3)*fDensity;
494    fA4[i]             = thisMaterialSandiaTabl    495    fA4[i]             = thisMaterialSandiaTable.GetPhotoAbsorpCof(i,4)*fDensity;
495                                                   496 
496     }                                             497     }   
497   if(fEnergyInterval[fIntervalNumber] != maxEn    498   if(fEnergyInterval[fIntervalNumber] != maxEnergyTransfer)
498     {                                             499     {
499          fIntervalNumber++;                       500          fIntervalNumber++;
500          fEnergyInterval[fIntervalNumber] = ma    501          fEnergyInterval[fIntervalNumber] = maxEnergyTransfer;
501          fA1[fIntervalNumber] = fA1[fIntervalN    502          fA1[fIntervalNumber] = fA1[fIntervalNumber-1];
502          fA2[fIntervalNumber] = fA2[fIntervalN    503          fA2[fIntervalNumber] = fA2[fIntervalNumber-1];
503          fA3[fIntervalNumber] = fA3[fIntervalN    504          fA3[fIntervalNumber] = fA3[fIntervalNumber-1];
504          fA4[fIntervalNumber] = fA4[fIntervalN    505          fA4[fIntervalNumber] = fA4[fIntervalNumber-1];
505     }                                             506     }
506   for(i=1;i<=fIntervalNumber;i++)                 507   for(i=1;i<=fIntervalNumber;i++)
507     {                                             508     {
508         // G4cout<<fEnergyInterval[i]<<"\t"<<f << 509   // G4cout<<fEnergyInterval[i]<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
509         //   <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4e << 510   //   <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
510     }                                             511     }
511   // Now checking, if two borders are too clos    512   // Now checking, if two borders are too close together
512                                                   513 
513   for( i = 1; i < fIntervalNumber; i++ )          514   for( i = 1; i < fIntervalNumber; i++ )
514     {                                             515     {
515         if(fEnergyInterval[i+1]-fEnergyInterva    516         if(fEnergyInterval[i+1]-fEnergyInterval[i] >
516            1.5*fDelta*(fEnergyInterval[i+1]+fE    517            1.5*fDelta*(fEnergyInterval[i+1]+fEnergyInterval[i]))
517         {                                      << 518   {
518           continue;                               519           continue;
519         }                                      << 520   }
520         else                                      521         else
521         {                                      << 522   {
522           for( j = i; j < fIntervalNumber; j++    523           for( j = i; j < fIntervalNumber; j++ )
523           {                                    << 524     {
524             fEnergyInterval[j] = fEnergyInterv    525             fEnergyInterval[j] = fEnergyInterval[j+1];
525                         fA1[j] = fA1[j+1];        526                         fA1[j] = fA1[j+1];
526                         fA2[j] = fA2[j+1];        527                         fA2[j] = fA2[j+1];
527                         fA3[j] = fA3[j+1];        528                         fA3[j] = fA3[j+1];
528                         fA4[j] = fA4[j+1];        529                         fA4[j] = fA4[j+1];
529           }                                    << 530     }
530           fIntervalNumber--;                      531           fIntervalNumber--;
531           i--;                                    532           i--;
532         }                                      << 533   }
533     }                                             534     }
534                                                   535 
535       /* *********************************        536       /* *********************************
536       fSplineEnergy          = new G4double[fM    537       fSplineEnergy          = new G4double[fMaxSplineSize];   
537       fRePartDielectricConst = new G4double[fM    538       fRePartDielectricConst = new G4double[fMaxSplineSize];   
538       fImPartDielectricConst = new G4double[fM    539       fImPartDielectricConst = new G4double[fMaxSplineSize];   
539       fIntegralTerm          = new G4double[fM    540       fIntegralTerm          = new G4double[fMaxSplineSize];   
540       fDifPAIxSection        = new G4double[fM    541       fDifPAIxSection        = new G4double[fMaxSplineSize];   
541       fIntegralPAIxSection   = new G4double[fM    542       fIntegralPAIxSection   = new G4double[fMaxSplineSize];   
542                                                   543       
543       for(i=0;i<fMaxSplineSize;i++)               544       for(i=0;i<fMaxSplineSize;i++)
544       {                                           545       {
545          fSplineEnergy[i]          = 0.0;         546          fSplineEnergy[i]          = 0.0;   
546          fRePartDielectricConst[i] = 0.0;         547          fRePartDielectricConst[i] = 0.0;   
547          fImPartDielectricConst[i] = 0.0;         548          fImPartDielectricConst[i] = 0.0;   
548          fIntegralTerm[i]          = 0.0;         549          fIntegralTerm[i]          = 0.0;   
549          fDifPAIxSection[i]        = 0.0;         550          fDifPAIxSection[i]        = 0.0;   
550          fIntegralPAIxSection[i]   = 0.0;         551          fIntegralPAIxSection[i]   = 0.0;   
551       }                                           552       }
552       */ ////////////////////////                 553       */ ////////////////////////
553                                                   554 
554       // Preparation of fSplineEnergy array co    555       // Preparation of fSplineEnergy array corresponding to min ionisation, G~4
555                                                   556 
556   ComputeLowEnergyCof();                          557   ComputeLowEnergyCof();      
557   G4double   betaGammaSqRef =                     558   G4double   betaGammaSqRef = 
558     fLorentzFactor[fRefGammaNumber]*fLorentzFa    559     fLorentzFactor[fRefGammaNumber]*fLorentzFactor[fRefGammaNumber] - 1;
559                                                   560 
560   NormShift(betaGammaSqRef);                      561   NormShift(betaGammaSqRef);             
561   SplainPAI(betaGammaSqRef);                      562   SplainPAI(betaGammaSqRef);
562                                                   563       
563   // Preparation of integral PAI cross section    564   // Preparation of integral PAI cross section for input betaGammaSq
564                                                   565    
565   for(i = 1; i <= fSplineNumber; i++)             566   for(i = 1; i <= fSplineNumber; i++)
566     {                                             567     {
567          fDifPAIxSection[i] = DifPAIxSection(i    568          fDifPAIxSection[i] = DifPAIxSection(i,betaGammaSq);
568          fdNdxCerenkov[i]   = PAIdNdxCerenkov(    569          fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,betaGammaSq);
569          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaS    570          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);
570          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i    571          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,betaGammaSq);
571          fdNdxResonance[i]  = PAIdNdxResonance    572          fdNdxResonance[i]  = PAIdNdxResonance(i,betaGammaSq);
572     }                                             573     }
573   IntegralPAIxSection();                          574   IntegralPAIxSection();
574   IntegralCerenkov();                             575   IntegralCerenkov();
575   IntegralMM();                                   576   IntegralMM();
576   IntegralPlasmon();                              577   IntegralPlasmon();
577   IntegralResonance();                            578   IntegralResonance();    
578 }                                                 579 }
579                                                   580 
580 //////////////////////////////////////////////    581 ////////////////////////////////////////////////////////////////////////////
581 //                                                582 //
582 // Destructor                                     583 // Destructor
583                                                   584 
584 G4PAIxSection::~G4PAIxSection()                   585 G4PAIxSection::~G4PAIxSection()
585 {                                                 586 {
586    /* ************************                    587    /* ************************
587    delete[] fSplineEnergy         ;               588    delete[] fSplineEnergy         ;   
588    delete[] fRePartDielectricConst;               589    delete[] fRePartDielectricConst;   
589    delete[] fImPartDielectricConst;               590    delete[] fImPartDielectricConst;   
590    delete[] fIntegralTerm         ;               591    delete[] fIntegralTerm         ;   
591    delete[] fDifPAIxSection       ;               592    delete[] fDifPAIxSection       ;   
592    delete[] fIntegralPAIxSection  ;               593    delete[] fIntegralPAIxSection  ;
593    */ ////////////////////////                    594    */ ////////////////////////
594   delete fMatSandiaMatrix;                        595   delete fMatSandiaMatrix;
595 }                                                 596 }
596                                                   597 
597 G4double G4PAIxSection::GetLorentzFactor(G4int << 598 
598 {                                              << 599 
599    return fLorentzFactor[j];                   << 
600 }                                              << 
601                                                   600 
602 //////////////////////////////////////////////    601 ////////////////////////////////////////////////////////////////////////
603 //                                                602 //
604 // Constructor with beta*gamma square value ca    603 // Constructor with beta*gamma square value called from G4PAIPhotModel/Data
605                                                   604 
606 void G4PAIxSection::Initialize( const G4Materi    605 void G4PAIxSection::Initialize( const G4Material* material,
607                                 G4double maxEn << 606         G4double maxEnergyTransfer,
608                                 G4double betaG << 607         G4double betaGammaSq, 
609                                 G4SandiaTable* << 608         G4SandiaTable* sandia)
610 {                                                 609 {
611   if(fVerbose > 0)                                610   if(fVerbose > 0)
612   {                                               611   {
613     G4cout<<G4endl;                               612     G4cout<<G4endl;
614     G4cout<<"G4PAIxSection::Initialize(...,G4S    613     G4cout<<"G4PAIxSection::Initialize(...,G4SandiaTable* sandia)"<<G4endl;
615     G4cout<<G4endl;                               614     G4cout<<G4endl;
616   }                                               615   }
617   G4int i, j;                                     616   G4int i, j;
618                                                   617 
619   fSandia          = sandia;                      618   fSandia          = sandia;
620   fIntervalNumber  = sandia->GetMaxInterval();    619   fIntervalNumber  = sandia->GetMaxInterval();
621   fDensity         = material->GetDensity();      620   fDensity         = material->GetDensity();
622   fElectronDensity = material->GetElectronDens    621   fElectronDensity = material->GetElectronDensity();
623                                                   622 
624   // fIntervalNumber--;                           623   // fIntervalNumber--;
625                                                   624 
626   if( fVerbose > 0 )                              625   if( fVerbose > 0 )
627   {                                               626   {
628     G4cout<<"fDensity = "<<fDensity<<"\t"<<fEl    627     G4cout<<"fDensity = "<<fDensity<<"\t"<<fElectronDensity<<"\t fIntervalNumber = "<<fIntervalNumber<<G4endl;
629   }                                               628   }  
630   fEnergyInterval = G4DataVector(fIntervalNumb    629   fEnergyInterval = G4DataVector(fIntervalNumber+2,0.0);
631   fA1             = G4DataVector(fIntervalNumb    630   fA1             = G4DataVector(fIntervalNumber+2,0.0);
632   fA2             = G4DataVector(fIntervalNumb    631   fA2             = G4DataVector(fIntervalNumber+2,0.0);
633   fA3             = G4DataVector(fIntervalNumb    632   fA3             = G4DataVector(fIntervalNumber+2,0.0);
634   fA4             = G4DataVector(fIntervalNumb    633   fA4             = G4DataVector(fIntervalNumber+2,0.0);
635                                                   634 
636   for( i = 1; i <= fIntervalNumber; i++ )         635   for( i = 1; i <= fIntervalNumber; i++ ) 
637   {                                               636   {
638     if ( sandia->GetSandiaMatTablePAI(i-1,0) <    637     if ( sandia->GetSandiaMatTablePAI(i-1,0) < 1.*eV && sandia->GetLowerI1() == false) 
639     {                                             638     { 
640       fIntervalNumber--;                          639       fIntervalNumber--;
641       continue;                                   640       continue;
642     }                                             641     }
643     if( ( sandia->GetSandiaMatTablePAI(i-1,0)     642     if( ( sandia->GetSandiaMatTablePAI(i-1,0) >= maxEnergyTransfer ) || i >= fIntervalNumber ) 
644     {                                             643     {
645       fEnergyInterval[i] = maxEnergyTransfer;     644       fEnergyInterval[i] = maxEnergyTransfer;
646       fIntervalNumber = i;                        645       fIntervalNumber = i;
647       break;                                      646       break;
648     }                                             647     }
649     fEnergyInterval[i] = sandia->GetSandiaMatT    648     fEnergyInterval[i] = sandia->GetSandiaMatTablePAI(i-1,0);
650     fA1[i]             = sandia->GetSandiaMatT    649     fA1[i]             = sandia->GetSandiaMatTablePAI(i-1,1);
651     fA2[i]             = sandia->GetSandiaMatT    650     fA2[i]             = sandia->GetSandiaMatTablePAI(i-1,2);
652     fA3[i]             = sandia->GetSandiaMatT    651     fA3[i]             = sandia->GetSandiaMatTablePAI(i-1,3);
653     fA4[i]             = sandia->GetSandiaMatT    652     fA4[i]             = sandia->GetSandiaMatTablePAI(i-1,4);
654                                                   653 
655       if( fVerbose > 0 )                          654       if( fVerbose > 0 ) 
656       {                                           655       {
657         G4cout<<i<<"\t"<<fEnergyInterval[i]/ke    656         G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
658              <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4e    657              <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
659       }                                           658       }
660   }                                               659   }
661   if( fVerbose > 0 ) G4cout<<"last i = "<<i<<"    660   if( fVerbose > 0 ) G4cout<<"last i = "<<i<<"; "<<"fIntervalNumber = "<<fIntervalNumber<<G4endl;   
662                                                   661 
663   if( fEnergyInterval[fIntervalNumber] != maxE    662   if( fEnergyInterval[fIntervalNumber] != maxEnergyTransfer )
664   {                                               663   {
665       fIntervalNumber++;                          664       fIntervalNumber++;
666       fEnergyInterval[fIntervalNumber] = maxEn    665       fEnergyInterval[fIntervalNumber] = maxEnergyTransfer;
667   }                                               666   }
668   if( fVerbose > 0 )                              667   if( fVerbose > 0 )
669   {                                               668   {  
670     for( i = 1; i <= fIntervalNumber; i++ )       669     for( i = 1; i <= fIntervalNumber; i++ )
671     {                                             670     {
672       G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<    671       G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
673         <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;     672         <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
674     }                                             673     }
675   }                                               674   }  
676   if( fVerbose > 0 )    G4cout<<"Now checking,    675   if( fVerbose > 0 )    G4cout<<"Now checking, if two borders are too close together"<<G4endl;
677                                                   676 
678   for( i = 1; i < fIntervalNumber; i++ )          677   for( i = 1; i < fIntervalNumber; i++ )
679   {                                               678   {
680     if( fEnergyInterval[i+1]-fEnergyInterval[i    679     if( fEnergyInterval[i+1]-fEnergyInterval[i] >
681          1.5*fDelta*(fEnergyInterval[i+1]+fEne << 680    1.5*fDelta*(fEnergyInterval[i+1]+fEnergyInterval[i]) && fEnergyInterval[i] > 0.) continue;
682     else                                          681     else
683     {                                             682     {
684       if( fVerbose > 0 )  G4cout<<i<<"\t"<<fEn    683       if( fVerbose > 0 )  G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fEnergyInterval[i+1]/keV;
685                                                   684 
686       for( j = i; j < fIntervalNumber; j++ )      685       for( j = i; j < fIntervalNumber; j++ )
687       {                                           686       {
688               fEnergyInterval[j] = fEnergyInte << 687         fEnergyInterval[j] = fEnergyInterval[j+1];
689               fA1[j]             = fA1[j+1];   << 688         fA1[j]             = fA1[j+1];
690               fA2[j]             = fA2[j+1];   << 689         fA2[j]             = fA2[j+1];
691               fA3[j]             = fA3[j+1];   << 690         fA3[j]             = fA3[j+1];
692               fA4[j]             = fA4[j+1];   << 691         fA4[j]             = fA4[j+1];
693       }                                           692       }
694       fIntervalNumber--;                          693       fIntervalNumber--;
695       i--;                                        694       i--;
696     }                                             695     }
697   }                                               696   }
698   if( fVerbose > 0 )                              697   if( fVerbose > 0 )
699   {                                               698   {
700     for( i = 1; i <= fIntervalNumber; i++ )       699     for( i = 1; i <= fIntervalNumber; i++ )
701     {                                             700     {
702       G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<    701       G4cout<<i<<"\t"<<fEnergyInterval[i]/keV<<"\t"<<fA1[i]<<"\t"<<fA2[i]<<"\t"
703         <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;     702         <<fA3[i]<<"\t"<<fA4[i]<<"\t"<<G4endl;
704     }                                             703     }
705   }                                               704   }
706   // Preparation of fSplineEnergy array corres    705   // Preparation of fSplineEnergy array corresponding to min ionisation, G~4
707                                                   706 
708   ComputeLowEnergyCof(material);                  707   ComputeLowEnergyCof(material);
709                                                   708             
710   G4double   betaGammaSqRef =                     709   G4double   betaGammaSqRef = 
711     fLorentzFactor[fRefGammaNumber]*fLorentzFa    710     fLorentzFactor[fRefGammaNumber]*fLorentzFactor[fRefGammaNumber] - 1;
712                                                   711 
713   NormShift(betaGammaSqRef);                      712   NormShift(betaGammaSqRef);             
714   SplainPAI(betaGammaSqRef);                      713   SplainPAI(betaGammaSqRef);
715                                                   714       
716   // Preparation of integral PAI cross section    715   // Preparation of integral PAI cross section for input betaGammaSq
717                                                   716    
718   for( i = 1; i <= fSplineNumber; i++ )           717   for( i = 1; i <= fSplineNumber; i++ )
719   {                                               718   {
720      fDifPAIxSection[i] = DifPAIxSection(i,bet    719      fDifPAIxSection[i] = DifPAIxSection(i,betaGammaSq);
721                                                   720 
722                                                   721 
723      fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,be    722      fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,betaGammaSq);
724      fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);     723      fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);
725      fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,bet    724      fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,betaGammaSq);
726      fdNdxResonance[i]  = PAIdNdxResonance(i,b    725      fdNdxResonance[i]  = PAIdNdxResonance(i,betaGammaSq);
727   }                                               726   }
728   IntegralPAIxSection();                          727   IntegralPAIxSection();   
729   IntegralCerenkov();                             728   IntegralCerenkov();
730   IntegralMM();                                   729   IntegralMM();
731   IntegralPlasmon();                              730   IntegralPlasmon();
732   IntegralResonance();                            731   IntegralResonance();
733                                                   732    
734   for( i = 1; i <= fSplineNumber; i++ )           733   for( i = 1; i <= fSplineNumber; i++ )
735   {                                               734   {
736     if(fVerbose>0) G4cout<<i<<"; w = "<<fSplin    735     if(fVerbose>0) G4cout<<i<<"; w = "<<fSplineEnergy[i]/keV<<" keV; dN/dx_>w = "<<fIntegralPAIxSection[i]<<" 1/mm"<<G4endl;
737   }                                               736   }
738 }                                                 737 }
739                                                   738 
740                                                   739 
741 //////////////////////////////////////////////    740 /////////////////////////////////////////////////////////////////////////
742 //                                                741 //
743 // Compute low energy cof. It reduces PAI xsc     742 // Compute low energy cof. It reduces PAI xsc for Lorentz factors less than 4.
744 //                                                743 //
745                                                   744 
746 void G4PAIxSection::ComputeLowEnergyCof(const     745 void G4PAIxSection::ComputeLowEnergyCof(const G4Material* material)
747 {                                                 746 {    
748   G4int i, numberOfElements = (G4int)material- << 747   G4int i, numberOfElements = material->GetNumberOfElements();
749   G4double sumZ = 0., sumCof = 0.;                748   G4double sumZ = 0., sumCof = 0.; 
750                                                   749 
751   static const G4double p0 =  1.20923e+00;        750   static const G4double p0 =  1.20923e+00; 
752   static const G4double p1 =  3.53256e-01;        751   static const G4double p1 =  3.53256e-01; 
753   static const G4double p2 = -1.45052e-03;        752   static const G4double p2 = -1.45052e-03; 
754                                                   753   
755   G4double* thisMaterialZ   = new G4double[num    754   G4double* thisMaterialZ   = new G4double[numberOfElements];
756   G4double* thisMaterialCof = new G4double[num    755   G4double* thisMaterialCof = new G4double[numberOfElements];
757                                                   756    
758   for( i = 0; i < numberOfElements; ++i )      << 757   for( i = 0; i < numberOfElements; i++ )
759   {                                               758   {
760     thisMaterialZ[i] = material->GetElement(i)    759     thisMaterialZ[i] = material->GetElement(i)->GetZ();
761     sumZ += thisMaterialZ[i];                     760     sumZ += thisMaterialZ[i];
762     thisMaterialCof[i] = p0+p1*thisMaterialZ[i    761     thisMaterialCof[i] = p0+p1*thisMaterialZ[i]+p2*thisMaterialZ[i]*thisMaterialZ[i];   
763   }                                               762   }
764   for( i = 0; i < numberOfElements; ++i )      << 763   for( i = 0; i < numberOfElements; i++ )
765   {                                               764   {
766     sumCof += thisMaterialCof[i]*thisMaterialZ    765     sumCof += thisMaterialCof[i]*thisMaterialZ[i]/sumZ;
767   }                                               766   }
768   fLowEnergyCof = sumCof;                         767   fLowEnergyCof = sumCof;
769   delete [] thisMaterialZ;                        768   delete [] thisMaterialZ;
770   delete [] thisMaterialCof;                      769   delete [] thisMaterialCof;
771   // G4cout<<"fLowEnergyCof = "<<fLowEnergyCof    770   // G4cout<<"fLowEnergyCof = "<<fLowEnergyCof<<G4endl;
772 }                                                 771 }
773                                                   772 
774 //////////////////////////////////////////////    773 /////////////////////////////////////////////////////////////////////////
775 //                                                774 //
776 // Compute low energy cof. It reduces PAI xsc     775 // Compute low energy cof. It reduces PAI xsc for Lorentz factors less than 4.
777 //                                                776 //
778                                                   777 
779 void G4PAIxSection::ComputeLowEnergyCof()         778 void G4PAIxSection::ComputeLowEnergyCof()
780 {                                                 779 {    
781   const G4MaterialTable* theMaterialTable = G4    780   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
782   G4int i, numberOfElements = (G4int)(*theMate << 781   G4int i, numberOfElements = (*theMaterialTable)[fMaterialIndex]->GetNumberOfElements();
783   G4double sumZ = 0., sumCof = 0.;                782   G4double sumZ = 0., sumCof = 0.; 
784                                                   783 
785   const G4double p0 =  1.20923e+00;               784   const G4double p0 =  1.20923e+00; 
786   const G4double p1 =  3.53256e-01;               785   const G4double p1 =  3.53256e-01; 
787   const G4double p2 = -1.45052e-03;               786   const G4double p2 = -1.45052e-03; 
788                                                   787   
789   G4double* thisMaterialZ   = new G4double[num    788   G4double* thisMaterialZ   = new G4double[numberOfElements];
790   G4double* thisMaterialCof = new G4double[num    789   G4double* thisMaterialCof = new G4double[numberOfElements];
791                                                   790    
792   for( i = 0; i < numberOfElements; ++i )      << 791   for( i = 0; i < numberOfElements; i++ )
793   {                                               792   {
794     thisMaterialZ[i] = (*theMaterialTable)[fMa    793     thisMaterialZ[i] = (*theMaterialTable)[fMaterialIndex]->GetElement(i)->GetZ();
795     sumZ += thisMaterialZ[i];                     794     sumZ += thisMaterialZ[i];
796     thisMaterialCof[i] = p0+p1*thisMaterialZ[i    795     thisMaterialCof[i] = p0+p1*thisMaterialZ[i]+p2*thisMaterialZ[i]*thisMaterialZ[i];   
797   }                                               796   }
798   for( i = 0; i < numberOfElements; ++i )      << 797   for( i = 0; i < numberOfElements; i++ )
799   {                                               798   {
800     sumCof += thisMaterialCof[i]*thisMaterialZ    799     sumCof += thisMaterialCof[i]*thisMaterialZ[i]/sumZ;
801   }                                               800   }
802   fLowEnergyCof = sumCof;                         801   fLowEnergyCof = sumCof;
803   // G4cout<<"fLowEnergyCof = "<<fLowEnergyCof    802   // G4cout<<"fLowEnergyCof = "<<fLowEnergyCof<<G4endl;
804   delete [] thisMaterialZ;                        803   delete [] thisMaterialZ;
805   delete [] thisMaterialCof;                      804   delete [] thisMaterialCof;
806 }                                                 805 }
807                                                   806 
808 //////////////////////////////////////////////    807 /////////////////////////////////////////////////////////////////////////
809 //                                                808 //
810 // General control function for class G4PAIxSe    809 // General control function for class G4PAIxSection
811 //                                                810 //
812                                                   811 
813 void G4PAIxSection::InitPAI()                     812 void G4PAIxSection::InitPAI()
814 {                                                 813 {    
815    G4int i;                                       814    G4int i;
816    G4double betaGammaSq = fLorentzFactor[fRefG    815    G4double betaGammaSq = fLorentzFactor[fRefGammaNumber]*
817                           fLorentzFactor[fRefG    816                           fLorentzFactor[fRefGammaNumber] - 1;
818                                                   817 
819    // Preparation of integral PAI cross sectio    818    // Preparation of integral PAI cross section for reference gamma
820                                                   819    
821    NormShift(betaGammaSq);                        820    NormShift(betaGammaSq);             
822    SplainPAI(betaGammaSq);                        821    SplainPAI(betaGammaSq);
823                                                   822 
824    IntegralPAIxSection();                         823    IntegralPAIxSection();
825    IntegralCerenkov();                            824    IntegralCerenkov();
826    IntegralMM();                                  825    IntegralMM();
827    IntegralPlasmon();                             826    IntegralPlasmon();
828    IntegralResonance();                           827    IntegralResonance();
829                                                   828 
830    for(i = 0; i<= fSplineNumber; i++)             829    for(i = 0; i<= fSplineNumber; i++)
831    {                                              830    {
832       fPAItable[i][fRefGammaNumber] = fIntegra    831       fPAItable[i][fRefGammaNumber] = fIntegralPAIxSection[i];
833       if(i != 0)                                  832       if(i != 0) 
834       {                                           833       {
835          fPAItable[i][0] = fSplineEnergy[i];   << 834    fPAItable[i][0] = fSplineEnergy[i];
836       }                                           835       }
837    }                                              836    }
838    fPAItable[0][0] = fSplineNumber;               837    fPAItable[0][0] = fSplineNumber;
839                                                   838    
840    for(G4int j = 1; j < 112; j++)       // for    839    for(G4int j = 1; j < 112; j++)       // for other gammas
841    {                                              840    {
842       if( j == fRefGammaNumber ) continue;        841       if( j == fRefGammaNumber ) continue;
843                                                   842       
844       betaGammaSq = fLorentzFactor[j]*fLorentz    843       betaGammaSq = fLorentzFactor[j]*fLorentzFactor[j] - 1;
845                                                   844       
846       for(i = 1; i <= fSplineNumber; i++)         845       for(i = 1; i <= fSplineNumber; i++)
847       {                                           846       {
848          fDifPAIxSection[i] = DifPAIxSection(i    847          fDifPAIxSection[i] = DifPAIxSection(i,betaGammaSq);
849          fdNdxCerenkov[i]   = PAIdNdxCerenkov(    848          fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,betaGammaSq);
850          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaS    849          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);
851          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i    850          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,betaGammaSq);
852          fdNdxResonance[i]  = PAIdNdxResonance    851          fdNdxResonance[i]  = PAIdNdxResonance(i,betaGammaSq);
853       }                                           852       }
854       IntegralPAIxSection();                      853       IntegralPAIxSection();
855       IntegralCerenkov();                         854       IntegralCerenkov();
856       IntegralMM();                               855       IntegralMM();
857       IntegralPlasmon();                          856       IntegralPlasmon();
858       IntegralResonance();                        857       IntegralResonance();
859                                                   858       
860       for(i = 0; i <= fSplineNumber; i++)         859       for(i = 0; i <= fSplineNumber; i++)
861       {                                           860       {
862          fPAItable[i][j] = fIntegralPAIxSectio    861          fPAItable[i][j] = fIntegralPAIxSection[i];
863       }                                           862       }
864    }                                              863    } 
865                                                   864 
866 }                                                 865 }  
867                                                   866 
868 //////////////////////////////////////////////    867 ///////////////////////////////////////////////////////////////////////
869 //                                                868 //
870 // Shifting from borders to intervals Creation    869 // Shifting from borders to intervals Creation of first energy points
871 //                                                870 //
872                                                   871 
873 void G4PAIxSection::NormShift(G4double betaGam    872 void G4PAIxSection::NormShift(G4double betaGammaSq)
874 {                                                 873 {
875   G4int i, j;                                     874   G4int i, j;
876                                                   875 
877   if(fVerbose>0) G4cout<<"      G4PAIxSection:    876   if(fVerbose>0) G4cout<<"      G4PAIxSection::NormShift call "<<G4endl;
878                                                   877 
879                                                   878 
880   for( i = 1; i <= fIntervalNumber-1; i++ )       879   for( i = 1; i <= fIntervalNumber-1; i++ )
881   {                                               880   {
882     for( j = 1; j <= 2; j++ )                     881     for( j = 1; j <= 2; j++ )
883     {                                             882     {
884       fSplineNumber = (i-1)*2 + j;                883       fSplineNumber = (i-1)*2 + j;
885                                                   884 
886       if( j == 1 ) fSplineEnergy[fSplineNumber    885       if( j == 1 ) fSplineEnergy[fSplineNumber] = fEnergyInterval[i  ]*(1+fDelta);
887       else         fSplineEnergy[fSplineNumber    886       else         fSplineEnergy[fSplineNumber] = fEnergyInterval[i+1]*(1-fDelta); 
888       if(fVerbose>0) G4cout<<"cn = "<<fSplineN    887       if(fVerbose>0) G4cout<<"cn = "<<fSplineNumber<<"; "<<"w = "<<fSplineEnergy[fSplineNumber]/keV<<" keV"<<G4endl;
889     }                                             888     }
890   }                                               889   }
891   fIntegralTerm[1]=RutherfordIntegral(1,fEnerg    890   fIntegralTerm[1]=RutherfordIntegral(1,fEnergyInterval[1],fSplineEnergy[1]);
892                                                   891 
893   j = 1;                                          892   j = 1;
894                                                   893 
895   for( i = 2; i <= fSplineNumber; i++ )           894   for( i = 2; i <= fSplineNumber; i++ )
896   {                                               895   {
897     if( fSplineEnergy[i]<fEnergyInterval[j+1]     896     if( fSplineEnergy[i]<fEnergyInterval[j+1] )
898     {                                             897     {
899          fIntegralTerm[i] = fIntegralTerm[i-1]    898          fIntegralTerm[i] = fIntegralTerm[i-1] + 
900                             RutherfordIntegral << 899                       RutherfordIntegral(j,fSplineEnergy[i-1],
901                                                   900                                                  fSplineEnergy[i]   );
902     }                                             901     }
903     else                                          902     else
904     {                                             903     {
905        G4double x = RutherfordIntegral(j,fSpli    904        G4double x = RutherfordIntegral(j,fSplineEnergy[i-1],
906                                            fEn    905                                            fEnergyInterval[j+1]   );
907          j++;                                     906          j++;
908          fIntegralTerm[i] = fIntegralTerm[i-1]    907          fIntegralTerm[i] = fIntegralTerm[i-1] + x + 
909                             RutherfordIntegral << 908                       RutherfordIntegral(j,fEnergyInterval[j],
910                                                   909                                                  fSplineEnergy[i]    );
911     }                                             910     }
912    if(fVerbose>0)  G4cout<<i<<"  Shift: w = "<    911    if(fVerbose>0)  G4cout<<i<<"  Shift: w = "<<fSplineEnergy[i]/keV<<" keV \t"<<fIntegralTerm[i]<<"\n"<<G4endl;
913   }                                               912   } 
914   fNormalizationCof = 2*pi*pi*hbarc*hbarc*fine    913   fNormalizationCof = 2*pi*pi*hbarc*hbarc*fine_structure_const/electron_mass_c2;
915   fNormalizationCof *= fElectronDensity/fInteg    914   fNormalizationCof *= fElectronDensity/fIntegralTerm[fSplineNumber];
916                                                   915 
917   // G4cout<<"fNormalizationCof = "<<fNormaliz    916   // G4cout<<"fNormalizationCof = "<<fNormalizationCof<<G4endl;
918                                                   917 
919           // Calculation of PAI differrential  << 918     // Calculation of PAI differrential cross-section (1/(keV*cm))
920           // in the energy points near borders << 919     // in the energy points near borders of energy intervals
921                                                   920 
922    for(G4int k = 1; k <= fIntervalNumber-1; k+    921    for(G4int k = 1; k <= fIntervalNumber-1; k++ )
923    {                                              922    {
924       for( j = 1; j <= 2; j++ )                   923       for( j = 1; j <= 2; j++ )
925       {                                           924       {
926          i = (k-1)*2 + j;                         925          i = (k-1)*2 + j;
927          fImPartDielectricConst[i] = fNormaliz    926          fImPartDielectricConst[i] = fNormalizationCof*
928                                      ImPartDie << 927                                ImPartDielectricConst(k,fSplineEnergy[i]);
929          fRePartDielectricConst[i] = fNormaliz    928          fRePartDielectricConst[i] = fNormalizationCof*
930                                      RePartDie << 929                                RePartDielectricConst(fSplineEnergy[i]);
931          fIntegralTerm[i] *= fNormalizationCof    930          fIntegralTerm[i] *= fNormalizationCof;
932                                                   931 
933          fDifPAIxSection[i] = DifPAIxSection(i    932          fDifPAIxSection[i] = DifPAIxSection(i,betaGammaSq);
934          fdNdxCerenkov[i]   = PAIdNdxCerenkov(    933          fdNdxCerenkov[i]   = PAIdNdxCerenkov(i,betaGammaSq);
935          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaS    934          fdNdxMM[i]   = PAIdNdxMM(i,betaGammaSq);
936          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i    935          fdNdxPlasmon[i]    = PAIdNdxPlasmon(i,betaGammaSq);
937          fdNdxResonance[i]    = PAIdNdxResonan    936          fdNdxResonance[i]    = PAIdNdxResonance(i,betaGammaSq);
938    if(fVerbose>0)  G4cout<<i<<"  Shift: w = "<    937    if(fVerbose>0)  G4cout<<i<<"  Shift: w = "<<fSplineEnergy[i]/keV<<" keV, xsc = "<<fDifPAIxSection[i]<<"\n"<<G4endl;
939       }                                           938       }
940    }                                              939    }
941                                                   940 
942 }  // end of NormShift                            941 }  // end of NormShift 
943                                                   942 
944 //////////////////////////////////////////////    943 /////////////////////////////////////////////////////////////////////////
945 //                                                944 //
946 // Creation of new energy points as geometrica    945 // Creation of new energy points as geometrical mean of existing
947 // one, calculation PAI_cs for them, while the    946 // one, calculation PAI_cs for them, while the error of logarithmic
948 // linear approximation would be smaller than     947 // linear approximation would be smaller than 'fError'
949                                                   948 
950 void G4PAIxSection::SplainPAI(G4double betaGam    949 void G4PAIxSection::SplainPAI(G4double betaGammaSq)
951 {                                                 950 {
952   G4int j, k = 1, i = 1;                          951   G4int j, k = 1, i = 1;
953                                                   952 
954   if(fVerbose>0) G4cout<<"                   G    953   if(fVerbose>0) G4cout<<"                   G4PAIxSection::SplainPAI call "<<G4endl;
955                                                   954 
956   while ( (i < fSplineNumber) && (fSplineNumbe    955   while ( (i < fSplineNumber) && (fSplineNumber < fMaxSplineSize-1) )
957   {                                               956   {
958      // if( std::abs(fSplineEnergy[i+1]-fEnerg    957      // if( std::abs(fSplineEnergy[i+1]-fEnergyInterval[k+1]) > (fSplineEnergy[i+1]+fEnergyInterval[k+1])*5.e-7 )
959      if( fSplineEnergy[i+1] > fEnergyInterval[    958      if( fSplineEnergy[i+1] > fEnergyInterval[k+1] )
960      {                                            959      {
961           k++;   // Here next energy point is     960           k++;   // Here next energy point is in next energy interval
962           i++;                                 << 961     i++;
963           if(fVerbose>0) G4cout<<"             << 962     if(fVerbose>0) G4cout<<"                     in if: i = "<<i<<"; k = "<<k<<G4endl;
964           continue;                               963           continue;
965      }                                            964      }
966      if(fVerbose>0) G4cout<<"       out if: i     965      if(fVerbose>0) G4cout<<"       out if: i = "<<i<<"; k = "<<k<<G4endl;
967                                                   966 
968                         // Shifting of arrayes << 967                  // Shifting of arrayes for inserting the geometrical 
969                        // average of 'i' and ' << 968            // average of 'i' and 'i+1' energy points to 'i+1' place
970      fSplineNumber++;                             969      fSplineNumber++;
971                                                   970 
972      for( j = fSplineNumber; j >= i+2; j-- )      971      for( j = fSplineNumber; j >= i+2; j-- )
973      {                                            972      {
974          fSplineEnergy[j]          = fSplineEn    973          fSplineEnergy[j]          = fSplineEnergy[j-1];
975          fImPartDielectricConst[j] = fImPartDi    974          fImPartDielectricConst[j] = fImPartDielectricConst[j-1];
976          fRePartDielectricConst[j] = fRePartDi << 975    fRePartDielectricConst[j] = fRePartDielectricConst[j-1];
977          fIntegralTerm[j]          = fIntegral << 976    fIntegralTerm[j]          = fIntegralTerm[j-1];
978                                                   977 
979          fDifPAIxSection[j] = fDifPAIxSection[ << 978    fDifPAIxSection[j] = fDifPAIxSection[j-1];
980          fdNdxCerenkov[j]   = fdNdxCerenkov[j-    979          fdNdxCerenkov[j]   = fdNdxCerenkov[j-1];
981          fdNdxMM[j]         = fdNdxMM[j-1];       980          fdNdxMM[j]         = fdNdxMM[j-1];
982          fdNdxPlasmon[j]    = fdNdxPlasmon[j-1    981          fdNdxPlasmon[j]    = fdNdxPlasmon[j-1];
983          fdNdxResonance[j]  = fdNdxResonance[j    982          fdNdxResonance[j]  = fdNdxResonance[j-1];
984      }                                            983      }
985       G4double x1  = fSplineEnergy[i];            984       G4double x1  = fSplineEnergy[i];
986       G4double x2  = fSplineEnergy[i+1];          985       G4double x2  = fSplineEnergy[i+1];
987       G4double yy1 = fDifPAIxSection[i];          986       G4double yy1 = fDifPAIxSection[i];
988       G4double y2  = fDifPAIxSection[i+1];        987       G4double y2  = fDifPAIxSection[i+1];
989                                                   988 
990       if(fVerbose>0) G4cout<<"Spline: x1 = "<<    989       if(fVerbose>0) G4cout<<"Spline: x1 = "<<x1<<"; x2 = "<<x2<<", yy1 = "<<yy1<<"; y2 = "<<y2<<G4endl;
991                                                   990 
992                                                   991 
993       G4double en1 = sqrt(x1*x2);                 992       G4double en1 = sqrt(x1*x2);
994       // G4double    en1 = 0.5*(x1 + x2);         993       // G4double    en1 = 0.5*(x1 + x2);
995                                                   994 
996                                                   995 
997       fSplineEnergy[i+1] = en1;                   996       fSplineEnergy[i+1] = en1;
998                                                   997 
999                  // Calculation of logarithmic << 998      // Calculation of logarithmic linear approximation
1000                  // in this (enr) energy poin << 999      // in this (enr) energy point, which number is 'i+1' now
1001                                                  1000 
1002       G4double a = log10(y2/yy1)/log10(x2/x1)    1001       G4double a = log10(y2/yy1)/log10(x2/x1);
1003       G4double b = log10(yy1) - a*log10(x1);     1002       G4double b = log10(yy1) - a*log10(x1);
1004       G4double y = a*log10(en1) + b;             1003       G4double y = a*log10(en1) + b;
1005                                                  1004 
1006       y = pow(10.,y);                            1005       y = pow(10.,y);
1007                                                  1006 
1008                  // Calculation of the PAI di << 1007      // Calculation of the PAI dif. cross-section at this point
1009                                                  1008 
1010       fImPartDielectricConst[i+1] = fNormaliz    1009       fImPartDielectricConst[i+1] = fNormalizationCof*
1011                                     ImPartDie << 1010                               ImPartDielectricConst(k,fSplineEnergy[i+1]);
1012       fRePartDielectricConst[i+1] = fNormaliz    1011       fRePartDielectricConst[i+1] = fNormalizationCof*
1013                                     RePartDie << 1012                               RePartDielectricConst(fSplineEnergy[i+1]);
1014       fIntegralTerm[i+1] = fIntegralTerm[i] +    1013       fIntegralTerm[i+1] = fIntegralTerm[i] + fNormalizationCof*
1015                            RutherfordIntegral << 1014                      RutherfordIntegral(k,fSplineEnergy[i],
1016                                                  1015                                                 fSplineEnergy[i+1]);
1017                                                  1016 
1018       fDifPAIxSection[i+1] = DifPAIxSection(i    1017       fDifPAIxSection[i+1] = DifPAIxSection(i+1,betaGammaSq);
1019       fdNdxCerenkov[i+1]   = PAIdNdxCerenkov(    1018       fdNdxCerenkov[i+1]   = PAIdNdxCerenkov(i+1,betaGammaSq);
1020       fdNdxMM[i+1]         = PAIdNdxMM(i+1,be    1019       fdNdxMM[i+1]         = PAIdNdxMM(i+1,betaGammaSq);
1021       fdNdxPlasmon[i+1]    = PAIdNdxPlasmon(i    1020       fdNdxPlasmon[i+1]    = PAIdNdxPlasmon(i+1,betaGammaSq);
1022       fdNdxResonance[i+1]  = PAIdNdxResonance    1021       fdNdxResonance[i+1]  = PAIdNdxResonance(i+1,betaGammaSq);
1023                                                  1022 
1024                   // Condition for next divis << 1023       // Condition for next division of this segment or to pass
1025                                                  1024 
1026     if(fVerbose>0) G4cout<<"Spline, a = "<<a<    1025     if(fVerbose>0) G4cout<<"Spline, a = "<<a<<"; b = "<<b<<"; new xsc = "<<y<<"; compxsc = "<<fDifPAIxSection[i+1]<<G4endl;
1027                                                  1026 
1028                   // to higher energies       << 1027       // to higher energies
1029                                                  1028 
1030       G4double x = 2*(fDifPAIxSection[i+1] -     1029       G4double x = 2*(fDifPAIxSection[i+1] - y)/(fDifPAIxSection[i+1] + y);
1031                                                  1030 
1032       G4double delta = 2.*(fSplineEnergy[i+1]    1031       G4double delta = 2.*(fSplineEnergy[i+1]-fSplineEnergy[i])/(fSplineEnergy[i+1]+fSplineEnergy[i]);
1033                                                  1032 
1034       if( x < 0 )                                1033       if( x < 0 ) 
1035       {                                          1034       {
1036          x = -x;                              << 1035    x = -x;
1037       }                                          1036       }
1038       if( x > fError && fSplineNumber < fMaxS    1037       if( x > fError && fSplineNumber < fMaxSplineSize-1 && delta > 2.*fDelta )
1039       {                                          1038       {
1040          continue;  // next division          << 1039    continue;  // next division
1041       }                                          1040       }
1042       i += 2;  // pass to next segment           1041       i += 2;  // pass to next segment
1043                                                  1042 
1044       // Loop checking, 03-Aug-2015, Vladimir << 
1045   }   // close 'while'                           1043   }   // close 'while'
1046                                                  1044 
1047 }  // end of SplainPAI                           1045 }  // end of SplainPAI 
1048                                                  1046 
1049                                                  1047 
1050 /////////////////////////////////////////////    1048 ////////////////////////////////////////////////////////////////////
1051 //                                               1049 //
1052 // Integration over electrons that could be c    1050 // Integration over electrons that could be considered
1053 // quasi-free at energy transfer of interest     1051 // quasi-free at energy transfer of interest
1054                                                  1052 
1055 G4double G4PAIxSection::RutherfordIntegral( G    1053 G4double G4PAIxSection::RutherfordIntegral( G4int k,
1056                                             G << 1054                     G4double x1,
1057                                               << 1055                       G4double x2   )
1058 {                                                1056 {
1059    G4double  c1, c2, c3;                         1057    G4double  c1, c2, c3;
1060    // G4cout<<"RI: x1 = "<<x1<<"; "<<"x2 = "<    1058    // G4cout<<"RI: x1 = "<<x1<<"; "<<"x2 = "<<x2<<G4endl;   
1061    c1 = (x2 - x1)/x1/x2;                         1059    c1 = (x2 - x1)/x1/x2;
1062    c2 = (x2 - x1)*(x2 + x1)/x1/x1/x2/x2;         1060    c2 = (x2 - x1)*(x2 + x1)/x1/x1/x2/x2;
1063    c3 = (x2 - x1)*(x1*x1 + x1*x2 + x2*x2)/x1/    1061    c3 = (x2 - x1)*(x1*x1 + x1*x2 + x2*x2)/x1/x1/x1/x2/x2/x2;
1064    // G4cout<<" RI: c1 = "<<c1<<"; "<<"c2 = "    1062    // G4cout<<" RI: c1 = "<<c1<<"; "<<"c2 = "<<c2<<"; "<<"c3 = "<<c3<<G4endl;   
1065                                                  1063    
1066    return  fA1[k]*log(x2/x1) + fA2[k]*c1 + fA    1064    return  fA1[k]*log(x2/x1) + fA2[k]*c1 + fA3[k]*c2/2 + fA4[k]*c3/3;
1067                                                  1065 
1068 }   // end of RutherfordIntegral                 1066 }   // end of RutherfordIntegral 
1069                                                  1067 
1070                                                  1068 
1071 /////////////////////////////////////////////    1069 /////////////////////////////////////////////////////////////////
1072 //                                               1070 //
1073 // Imaginary part of dielectric constant         1071 // Imaginary part of dielectric constant
1074 // (G4int k - interval number, G4double en1 -    1072 // (G4int k - interval number, G4double en1 - energy point)
1075                                                  1073 
1076 G4double G4PAIxSection::ImPartDielectricConst    1074 G4double G4PAIxSection::ImPartDielectricConst( G4int    k ,
1077                                               << 1075                              G4double energy1 )
1078 {                                                1076 {
1079    G4double energy2,energy3,energy4,result;      1077    G4double energy2,energy3,energy4,result;
1080                                                  1078 
1081    energy2 = energy1*energy1;                    1079    energy2 = energy1*energy1;
1082    energy3 = energy2*energy1;                    1080    energy3 = energy2*energy1;
1083    energy4 = energy3*energy1;                    1081    energy4 = energy3*energy1;
1084                                                  1082    
1085    result = fA1[k]/energy1+fA2[k]/energy2+fA3    1083    result = fA1[k]/energy1+fA2[k]/energy2+fA3[k]/energy3+fA4[k]/energy4;  
1086    result *=hbarc/energy1;                       1084    result *=hbarc/energy1;
1087                                                  1085    
1088    return result;                                1086    return result;
1089                                                  1087 
1090 }  // end of ImPartDielectricConst               1088 }  // end of ImPartDielectricConst 
1091                                                  1089 
1092 /////////////////////////////////////////////    1090 /////////////////////////////////////////////////////////////////
1093 //                                               1091 //
1094 // Returns lambda of photon with energy1 in c    1092 // Returns lambda of photon with energy1 in current material 
1095                                                  1093 
1096 G4double G4PAIxSection::GetPhotonRange( G4dou    1094 G4double G4PAIxSection::GetPhotonRange( G4double energy1 )
1097 {                                                1095 {
1098   G4int i;                                       1096   G4int i;
1099   G4double energy2, energy3, energy4, result,    1097   G4double energy2, energy3, energy4, result, lambda;
1100                                                  1098 
1101   energy2 = energy1*energy1;                     1099   energy2 = energy1*energy1;
1102   energy3 = energy2*energy1;                     1100   energy3 = energy2*energy1;
1103   energy4 = energy3*energy1;                     1101   energy4 = energy3*energy1;
1104                                                  1102 
                                                   >> 1103   // G4double* SandiaCof = fSandia->GetSandiaCofForMaterialPAI(energy1);
                                                   >> 1104   // result = SandiaCof[0]/energy1+SandiaCof[1]/energy2+SandiaCof[2]/energy3+SandiaCof[3]/energy4;
                                                   >> 1105   // result *= fDensity;
                                                   >> 1106 
1105   for( i = 1; i <= fIntervalNumber; i++ )        1107   for( i = 1; i <= fIntervalNumber; i++ )
1106   {                                              1108   {
1107      if( energy1 < fEnergyInterval[i]) break;    1109      if( energy1 < fEnergyInterval[i]) break;
1108   }                                              1110   }
1109   i--;                                           1111   i--;
1110   if(i == 0) i = 1;                              1112   if(i == 0) i = 1;
1111                                                  1113 
1112   result = fA1[i]/energy1+fA2[i]/energy2+fA3[    1114   result = fA1[i]/energy1+fA2[i]/energy2+fA3[i]/energy3+fA4[i]/energy4;  
1113                                                  1115 
1114   if( result > DBL_MIN ) lambda = 1./result;     1116   if( result > DBL_MIN ) lambda = 1./result;
1115   else                   lambda = DBL_MAX;       1117   else                   lambda = DBL_MAX;
1116                                                  1118    
1117   return lambda;                                 1119   return lambda;
1118 }                                                1120 }  
1119                                                  1121 
1120 /////////////////////////////////////////////    1122 /////////////////////////////////////////////////////////////////
1121 //                                               1123 //
1122 // Return lambda of electron with energy1 in     1124 // Return lambda of electron with energy1 in current material
1123 // parametrisation from NIM A554(2005)474-493    1125 // parametrisation from NIM A554(2005)474-493 
1124                                                  1126 
1125 G4double G4PAIxSection::GetElectronRange( G4d    1127 G4double G4PAIxSection::GetElectronRange( G4double energy )
1126 {                                                1128 {
1127   G4double range;                                1129   G4double range;
1128   /*                                             1130   /*
1129   const G4MaterialTable* theMaterialTable = G    1131   const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
1130                                                  1132 
1131   G4double Z = (*theMaterialTable)[fMaterialI    1133   G4double Z = (*theMaterialTable)[fMaterialIndex]->GetIonisation()->GetZeffective();
1132   G4double A = (*theMaterialTable)[fMaterialI    1134   G4double A = (*theMaterialTable)[fMaterialIndex]->GetA();
1133                                                  1135 
1134   energy /= keV; // energy in keV in parametr    1136   energy /= keV; // energy in keV in parametrised formula
1135                                                  1137 
1136   if (energy < 10.)                              1138   if (energy < 10.)
1137   {                                              1139   {
1138     range = 3.872e-3*A/Z;                        1140     range = 3.872e-3*A/Z;
1139     range *= pow(energy,1.492);                  1141     range *= pow(energy,1.492);
1140   }                                              1142   }
1141   else                                           1143   else
1142   {                                              1144   {
1143     range = 6.97e-3*pow(energy,1.6);             1145     range = 6.97e-3*pow(energy,1.6);
1144   }                                              1146   }
1145   */                                             1147   */
1146   // Blum&Rolandi Particle Detection with Dri    1148   // Blum&Rolandi Particle Detection with Drift Chambers, p. 7
1147                                                  1149 
1148   G4double cofA = 5.37e-4*g/cm2/keV;             1150   G4double cofA = 5.37e-4*g/cm2/keV;
1149   G4double cofB = 0.9815;                        1151   G4double cofB = 0.9815;
1150   G4double cofC = 3.123e-3/keV;                  1152   G4double cofC = 3.123e-3/keV;
1151   // energy /= keV;                              1153   // energy /= keV;
1152                                                  1154 
1153   range = cofA*energy*( 1 - cofB/(1 + cofC*en    1155   range = cofA*energy*( 1 - cofB/(1 + cofC*energy) ); 
1154                                                  1156 
1155   // range *= g/cm2;                             1157   // range *= g/cm2;
1156   range /= fDensity;                             1158   range /= fDensity;
1157                                                  1159 
1158   return range;                                  1160   return range;
1159 }                                                1161 }
1160                                                  1162 
1161 /////////////////////////////////////////////    1163 //////////////////////////////////////////////////////////////////////////////
1162 //                                               1164 //
1163 // Real part of dielectric constant minus uni    1165 // Real part of dielectric constant minus unit: epsilon_1 - 1
1164 // (G4double enb - energy point)                 1166 // (G4double enb - energy point)
1165 //                                               1167 //
1166                                                  1168 
1167 G4double G4PAIxSection::RePartDielectricConst    1169 G4double G4PAIxSection::RePartDielectricConst(G4double enb)
1168 {                                                1170 {       
1169    G4double x0, x02, x03, x04, x05, x1, x2, x    1171    G4double x0, x02, x03, x04, x05, x1, x2, xx1 ,xx2 , xx12,
1170             c1, c2, c3, cof1, cof2, xln1, xln    1172             c1, c2, c3, cof1, cof2, xln1, xln2, xln3, result;
1171                                                  1173 
1172    x0 = enb;                                     1174    x0 = enb;
1173    result = 0;                                   1175    result = 0;
1174                                                  1176    
1175    for(G4int i=1;i<=fIntervalNumber-1;i++)       1177    for(G4int i=1;i<=fIntervalNumber-1;i++)
1176    {                                             1178    {
1177       x1 = fEnergyInterval[i];                   1179       x1 = fEnergyInterval[i];
1178       x2 = fEnergyInterval[i+1];                 1180       x2 = fEnergyInterval[i+1];
1179       xx1 = x1 - x0;                             1181       xx1 = x1 - x0;
1180       xx2 = x2 - x0;                             1182       xx2 = x2 - x0;
1181       xx12 = xx2/xx1;                            1183       xx12 = xx2/xx1;
1182                                                  1184       
1183       if(xx12<0)                                 1185       if(xx12<0)
1184       {                                          1186       {
1185          xx12 = -xx12;                        << 1187    xx12 = -xx12;
1186       }                                          1188       }
1187       xln1 = log(x2/x1);                         1189       xln1 = log(x2/x1);
1188       xln2 = log(xx12);                          1190       xln2 = log(xx12);
1189       xln3 = log((x2 + x0)/(x1 + x0));           1191       xln3 = log((x2 + x0)/(x1 + x0));
1190       x02 = x0*x0;                               1192       x02 = x0*x0;
1191       x03 = x02*x0;                              1193       x03 = x02*x0;
1192       x04 = x03*x0;                              1194       x04 = x03*x0;
1193       x05 = x04*x0;                              1195       x05 = x04*x0;
1194       c1  = (x2 - x1)/x1/x2;                     1196       c1  = (x2 - x1)/x1/x2;
1195       c2  = (x2 - x1)*(x2 +x1)/x1/x1/x2/x2;      1197       c2  = (x2 - x1)*(x2 +x1)/x1/x1/x2/x2;
1196       c3  = (x2 -x1)*(x1*x1 + x1*x2 + x2*x2)/    1198       c3  = (x2 -x1)*(x1*x1 + x1*x2 + x2*x2)/x1/x1/x1/x2/x2/x2;
1197                                                  1199 
1198       result -= (fA1[i]/x02 + fA3[i]/x04)*xln    1200       result -= (fA1[i]/x02 + fA3[i]/x04)*xln1;
1199       result -= (fA2[i]/x02 + fA4[i]/x04)*c1;    1201       result -= (fA2[i]/x02 + fA4[i]/x04)*c1;
1200       result -= fA3[i]*c2/2/x02;                 1202       result -= fA3[i]*c2/2/x02;
1201       result -= fA4[i]*c3/3/x02;                 1203       result -= fA4[i]*c3/3/x02;
1202                                                  1204 
1203       cof1 = fA1[i]/x02 + fA3[i]/x04;            1205       cof1 = fA1[i]/x02 + fA3[i]/x04;
1204       cof2 = fA2[i]/x03 + fA4[i]/x05;            1206       cof2 = fA2[i]/x03 + fA4[i]/x05;
1205                                                  1207 
1206       result += 0.5*(cof1 +cof2)*xln2;           1208       result += 0.5*(cof1 +cof2)*xln2;
1207       result += 0.5*(cof1 - cof2)*xln3;          1209       result += 0.5*(cof1 - cof2)*xln3;
1208    }                                             1210    } 
1209    result *= 2*hbarc/pi;                         1211    result *= 2*hbarc/pi;
1210                                                  1212    
1211    return result;                                1213    return result;
1212                                                  1214 
1213 }   // end of RePartDielectricConst              1215 }   // end of RePartDielectricConst 
1214                                                  1216 
1215 /////////////////////////////////////////////    1217 //////////////////////////////////////////////////////////////////////
1216 //                                               1218 //
1217 // PAI differential cross-section in terms of    1219 // PAI differential cross-section in terms of
1218 // simplified Allison's equation                 1220 // simplified Allison's equation
1219 //                                               1221 //
1220                                                  1222 
1221 G4double G4PAIxSection::DifPAIxSection( G4int << 1223 G4double G4PAIxSection::DifPAIxSection( G4int              i ,
                                                   >> 1224                                         G4double betaGammaSq  )
1222 {                                                1225 {        
1223    G4double cof,x1,x2,x3,x4,x5,x6,x7,x8,resul    1226    G4double cof,x1,x2,x3,x4,x5,x6,x7,x8,result;
1224                                                  1227 
1225    G4double betaBohr  = fine_structure_const;    1228    G4double betaBohr  = fine_structure_const;
                                                   >> 1229    // G4double betaBohr2 = fine_structure_const*fine_structure_const;
                                                   >> 1230    // G4double betaBohr3 = betaBohr*betaBohr2; // *4.0;
                                                   >> 1231 
1226    G4double be2  = betaGammaSq/(1 + betaGamma    1232    G4double be2  = betaGammaSq/(1 + betaGammaSq);
1227    G4double beta = std::sqrt(be2);            << 1233    G4double beta = sqrt(be2);
                                                   >> 1234    // G4double be3 = beta*be2;
1228                                                  1235 
1229    cof = 1.;                                     1236    cof = 1.;
1230    x1  = std::log(2*electron_mass_c2/fSplineE << 1237    x1  = log(2*electron_mass_c2/fSplineEnergy[i]);
1231                                                  1238 
1232    if( betaGammaSq < 0.01 ) x2 = std::log(be2 << 1239    if( betaGammaSq < 0.01 ) x2 = log(be2);
1233    else                                          1240    else
1234    {                                             1241    {
1235      x2 = -log( (1/betaGammaSq - fRePartDiele    1242      x2 = -log( (1/betaGammaSq - fRePartDielectricConst[i])*
1236                 (1/betaGammaSq - fRePartDiele << 1243           (1/betaGammaSq - fRePartDielectricConst[i]) + 
1237                 fImPartDielectricConst[i]*fIm << 1244           fImPartDielectricConst[i]*fImPartDielectricConst[i] )/2;
1238    }                                             1245    }
1239    if( fImPartDielectricConst[i] == 0.0 ||bet    1246    if( fImPartDielectricConst[i] == 0.0 ||betaGammaSq < 0.01 )
1240    {                                             1247    {
1241      x6 = 0.;                                    1248      x6 = 0.;
1242    }                                             1249    }
1243    else                                          1250    else
1244    {                                             1251    {
1245      x3 = -fRePartDielectricConst[i] + 1/beta    1252      x3 = -fRePartDielectricConst[i] + 1/betaGammaSq;
1246      x5 = -1 - fRePartDielectricConst[i] +       1253      x5 = -1 - fRePartDielectricConst[i] +
1247           be2*((1 +fRePartDielectricConst[i])    1254           be2*((1 +fRePartDielectricConst[i])*(1 + fRePartDielectricConst[i]) +
1248           fImPartDielectricConst[i]*fImPartDi << 1255     fImPartDielectricConst[i]*fImPartDielectricConst[i]);
1249                                                  1256 
1250      x7 = atan2(fImPartDielectricConst[i],x3)    1257      x7 = atan2(fImPartDielectricConst[i],x3);
1251      x6 = x5 * x7;                               1258      x6 = x5 * x7;
1252    }                                             1259    }
                                                   >> 1260     // if(fImPartDielectricConst[i] == 0) x6 = 0.;
1253                                                  1261    
1254    x4 = ((x1 + x2)*fImPartDielectricConst[i]     1262    x4 = ((x1 + x2)*fImPartDielectricConst[i] + x6)/hbarc;
1255                                                  1263 
                                                   >> 1264    //   if( x4 < 0.0 ) x4 = 0.0;
                                                   >> 1265 
1256    x8 = (1 + fRePartDielectricConst[i])*(1 +     1266    x8 = (1 + fRePartDielectricConst[i])*(1 + fRePartDielectricConst[i]) + 
1257         fImPartDielectricConst[i]*fImPartDiel    1267         fImPartDielectricConst[i]*fImPartDielectricConst[i];
1258                                                  1268 
1259    result = (x4 + cof*fIntegralTerm[i]/fSplin    1269    result = (x4 + cof*fIntegralTerm[i]/fSplineEnergy[i]/fSplineEnergy[i]);
1260                                                  1270 
1261    if( result < 1.0e-8 ) result = 1.0e-8;        1271    if( result < 1.0e-8 ) result = 1.0e-8;
1262                                                  1272 
1263    result *= fine_structure_const/be2/pi;        1273    result *= fine_structure_const/be2/pi;
1264                                                  1274 
1265    // low energy correction                      1275    // low energy correction
1266                                                  1276 
1267    G4double lowCof = fLowEnergyCof; // 6.0 ;     1277    G4double lowCof = fLowEnergyCof; // 6.0 ; // Ar ~ 4.; -> fLowCof as f(Z1,Z2)? 
1268                                                  1278 
1269    result *= (1 - std::exp(-beta/betaBohr/low << 1279    result *= (1 - exp(-beta/betaBohr/lowCof));
1270    if(x8 >= 0.0)                              << 1280 
                                                   >> 1281 
                                                   >> 1282    // result *= (1 - exp(-be2/betaBohr2/lowCof));
                                                   >> 1283 
                                                   >> 1284    // result *= (1 - exp(-be3/betaBohr3/lowCof)); // ~ be for be<<betaBohr
                                                   >> 1285 
                                                   >> 1286    // result *= (1 - exp(-be4/betaBohr4/lowCof));
                                                   >> 1287 
                                                   >> 1288    if(fDensity >= 0.1)
1271    {                                             1289    { 
1272      result /= x8;                            << 1290       result /= x8;
1273    }                                             1291    }
1274    return result;                                1292    return result;
1275                                                  1293 
1276 } // end of DifPAIxSection                       1294 } // end of DifPAIxSection 
1277                                                  1295 
1278 /////////////////////////////////////////////    1296 //////////////////////////////////////////////////////////////////////////
1279 //                                               1297 //
1280 // Calculation od dN/dx of collisions with cr    1298 // Calculation od dN/dx of collisions with creation of Cerenkov pseudo-photons
1281                                                  1299 
1282 G4double G4PAIxSection::PAIdNdxCerenkov( G4in    1300 G4double G4PAIxSection::PAIdNdxCerenkov( G4int    i ,
1283                                          G4do    1301                                          G4double betaGammaSq  )
1284 {                                                1302 {        
1285    G4double logarithm, x3, x5, argument, modu    1303    G4double logarithm, x3, x5, argument, modul2, dNdxC; 
1286    G4double be2, betaBohr2, cofBetaBohr;         1304    G4double be2, betaBohr2, cofBetaBohr;
1287                                                  1305 
1288    cofBetaBohr = 4.0;                            1306    cofBetaBohr = 4.0;
1289    betaBohr2 = fine_structure_const*fine_stru << 1307    betaBohr2   = fine_structure_const*fine_structure_const;
1290    G4double betaBohr4 = betaBohr2*betaBohr2*c << 1308    G4double betaBohr4   = betaBohr2*betaBohr2*cofBetaBohr;
1291                                                  1309 
1292    be2 = betaGammaSq/(1 + betaGammaSq);          1310    be2 = betaGammaSq/(1 + betaGammaSq);
1293    G4double be4 = be2*be2;                       1311    G4double be4 = be2*be2;
1294                                                  1312 
1295    if( betaGammaSq < 0.01 ) logarithm = std:: << 1313    if( betaGammaSq < 0.01 ) logarithm = log(1.0+betaGammaSq); // 0.0;
1296    else                                          1314    else
1297    {                                             1315    {
1298      logarithm  = -log( (1/betaGammaSq - fReP    1316      logarithm  = -log( (1/betaGammaSq - fRePartDielectricConst[i])*
1299                         (1/betaGammaSq - fReP << 1317                   (1/betaGammaSq - fRePartDielectricConst[i]) + 
1300                         fImPartDielectricCons << 1318                   fImPartDielectricConst[i]*fImPartDielectricConst[i] )*0.5;
1301      logarithm += log(1+1.0/betaGammaSq);        1319      logarithm += log(1+1.0/betaGammaSq);
1302    }                                             1320    }
1303                                                  1321 
1304    if( fImPartDielectricConst[i] == 0.0 || be    1322    if( fImPartDielectricConst[i] == 0.0 || betaGammaSq < 0.01 )
1305    {                                             1323    {
1306      argument = 0.0;                             1324      argument = 0.0;
1307    }                                             1325    }
1308    else                                          1326    else
1309    {                                             1327    {
1310      x3 = -fRePartDielectricConst[i] + 1.0/be    1328      x3 = -fRePartDielectricConst[i] + 1.0/betaGammaSq;
1311      x5 = -1.0 - fRePartDielectricConst[i] +     1329      x5 = -1.0 - fRePartDielectricConst[i] +
1312           be2*((1.0 +fRePartDielectricConst[i    1330           be2*((1.0 +fRePartDielectricConst[i])*(1.0 + fRePartDielectricConst[i]) +
1313           fImPartDielectricConst[i]*fImPartDi << 1331     fImPartDielectricConst[i]*fImPartDielectricConst[i]);
1314      if( x3 == 0.0 ) argument = 0.5*pi;          1332      if( x3 == 0.0 ) argument = 0.5*pi;
1315      else            argument = std::atan2(fI << 1333      else            argument = atan2(fImPartDielectricConst[i],x3);
1316      argument *= x5 ;                            1334      argument *= x5 ;
1317    }                                             1335    }   
1318    dNdxC = ( logarithm*fImPartDielectricConst    1336    dNdxC = ( logarithm*fImPartDielectricConst[i] + argument )/hbarc;
1319                                                  1337   
1320    if(dNdxC < 1.0e-8) dNdxC = 1.0e-8;            1338    if(dNdxC < 1.0e-8) dNdxC = 1.0e-8;
1321                                                  1339 
1322    dNdxC *= fine_structure_const/be2/pi;         1340    dNdxC *= fine_structure_const/be2/pi;
1323                                                  1341 
1324    dNdxC *= (1-std::exp(-be4/betaBohr4));     << 1342    dNdxC *= (1-exp(-be4/betaBohr4));
1325                                                  1343 
1326    modul2 = (1.0 + fRePartDielectricConst[i]) << 1344    if(fDensity >= 0.1)
1327      fImPartDielectricConst[i]*fImPartDielect << 
1328    if(modul2 >= 0.0)                          << 
1329    {                                             1345    { 
1330      dNdxC /= modul2;                         << 1346       modul2 = (1.0 + fRePartDielectricConst[i])*(1.0 + fRePartDielectricConst[i]) + 
                                                   >> 1347                     fImPartDielectricConst[i]*fImPartDielectricConst[i];
                                                   >> 1348       dNdxC /= modul2;
1331    }                                             1349    }
1332    return dNdxC;                                 1350    return dNdxC;
1333                                                  1351 
1334 } // end of PAIdNdxCerenkov                      1352 } // end of PAIdNdxCerenkov 
1335                                                  1353 
1336 /////////////////////////////////////////////    1354 //////////////////////////////////////////////////////////////////////////
1337 //                                               1355 //
1338 // Calculation od dN/dx of collisions of MM w    1356 // Calculation od dN/dx of collisions of MM with creation of Cerenkov pseudo-photons
1339                                                  1357 
1340 G4double G4PAIxSection::PAIdNdxMM( G4int    i    1358 G4double G4PAIxSection::PAIdNdxMM( G4int    i ,
1341                                          G4do    1359                                          G4double betaGammaSq  )
1342 {                                                1360 {        
1343    G4double logarithm, x3, x5, argument, dNdx    1361    G4double logarithm, x3, x5, argument, dNdxC; 
1344    G4double be2, be4, betaBohr2,betaBohr4,cof    1362    G4double be2, be4, betaBohr2,betaBohr4,cofBetaBohr;
1345                                                  1363 
1346    cofBetaBohr = 4.0;                            1364    cofBetaBohr = 4.0;
1347    betaBohr2   = fine_structure_const*fine_st    1365    betaBohr2   = fine_structure_const*fine_structure_const;
1348    betaBohr4   = betaBohr2*betaBohr2*cofBetaB    1366    betaBohr4   = betaBohr2*betaBohr2*cofBetaBohr;
1349                                                  1367 
1350    be2 = betaGammaSq/(1 + betaGammaSq);          1368    be2 = betaGammaSq/(1 + betaGammaSq);
1351    be4 = be2*be2;                                1369    be4 = be2*be2;
1352                                                  1370 
1353    if( betaGammaSq < 0.01 ) logarithm = log(1    1371    if( betaGammaSq < 0.01 ) logarithm = log(1.0+betaGammaSq); // 0.0;
1354    else                                          1372    else
1355    {                                             1373    {
1356      logarithm  = -log( (1/betaGammaSq - fReP    1374      logarithm  = -log( (1/betaGammaSq - fRePartDielectricConst[i])*
1357                         (1/betaGammaSq - fReP << 1375                   (1/betaGammaSq - fRePartDielectricConst[i]) + 
1358                         fImPartDielectricCons << 1376                   fImPartDielectricConst[i]*fImPartDielectricConst[i] )*0.5;
1359      logarithm += log(1+1.0/betaGammaSq);        1377      logarithm += log(1+1.0/betaGammaSq);
1360    }                                             1378    }
1361                                                  1379 
1362    if( fImPartDielectricConst[i] == 0.0 || be    1380    if( fImPartDielectricConst[i] == 0.0 || betaGammaSq < 0.01 )
1363    {                                             1381    {
1364      argument = 0.0;                             1382      argument = 0.0;
1365    }                                             1383    }
1366    else                                          1384    else
1367    {                                             1385    {
1368      x3 = -fRePartDielectricConst[i] + 1.0/be    1386      x3 = -fRePartDielectricConst[i] + 1.0/betaGammaSq;
1369      x5 = be2*( 1.0 + fRePartDielectricConst[    1387      x5 = be2*( 1.0 + fRePartDielectricConst[i] ) - 1.0;
1370      if( x3 == 0.0 ) argument = 0.5*pi;          1388      if( x3 == 0.0 ) argument = 0.5*pi;
1371      else            argument = atan2(fImPart    1389      else            argument = atan2(fImPartDielectricConst[i],x3);
1372      argument *= x5 ;                            1390      argument *= x5 ;
1373    }                                             1391    }   
1374    dNdxC = ( logarithm*fImPartDielectricConst    1392    dNdxC = ( logarithm*fImPartDielectricConst[i]*be2 + argument )/hbarc;
1375                                                  1393   
1376    if(dNdxC < 1.0e-8) dNdxC = 1.0e-8;            1394    if(dNdxC < 1.0e-8) dNdxC = 1.0e-8;
1377                                                  1395 
1378    dNdxC *= fine_structure_const/be2/pi;         1396    dNdxC *= fine_structure_const/be2/pi;
1379                                                  1397 
1380    dNdxC *= (1-std::exp(-be4/betaBohr4));     << 1398    dNdxC *= (1-exp(-be4/betaBohr4));
1381    return dNdxC;                                 1399    return dNdxC;
1382                                                  1400 
1383 } // end of PAIdNdxMM                            1401 } // end of PAIdNdxMM 
1384                                                  1402 
1385 /////////////////////////////////////////////    1403 //////////////////////////////////////////////////////////////////////////
1386 //                                               1404 //
1387 // Calculation od dN/dx of collisions with cr    1405 // Calculation od dN/dx of collisions with creation of longitudinal EM
1388 // excitations (plasmons, delta-electrons)       1406 // excitations (plasmons, delta-electrons)
1389                                                  1407 
1390 G4double G4PAIxSection::PAIdNdxPlasmon( G4int    1408 G4double G4PAIxSection::PAIdNdxPlasmon( G4int    i ,
1391                                         G4dou    1409                                         G4double betaGammaSq  )
1392 {                                                1410 {        
1393    G4double resonance, modul2, dNdxP, cof = 1    1411    G4double resonance, modul2, dNdxP, cof = 1.;
1394    G4double be2, betaBohr;                       1412    G4double be2, betaBohr;
1395                                                  1413   
1396    betaBohr   = fine_structure_const;            1414    betaBohr   = fine_structure_const;
1397    be2 = betaGammaSq/(1 + betaGammaSq);          1415    be2 = betaGammaSq/(1 + betaGammaSq);
1398                                                  1416 
1399    G4double beta = std::sqrt(be2);            << 1417    G4double beta = sqrt(be2);
1400                                                  1418  
1401    resonance = std::log(2*electron_mass_c2*be << 1419    resonance = log(2*electron_mass_c2*be2/fSplineEnergy[i]);  
1402    resonance *= fImPartDielectricConst[i]/hba    1420    resonance *= fImPartDielectricConst[i]/hbarc;
1403                                                  1421 
                                                   >> 1422 
1404    dNdxP = ( resonance + cof*fIntegralTerm[i]    1423    dNdxP = ( resonance + cof*fIntegralTerm[i]/fSplineEnergy[i]/fSplineEnergy[i] );
1405                                                  1424 
1406    if( dNdxP < 1.0e-8 ) dNdxP = 1.0e-8;          1425    if( dNdxP < 1.0e-8 ) dNdxP = 1.0e-8;
1407                                                  1426 
1408    dNdxP *= fine_structure_const/be2/pi;         1427    dNdxP *= fine_structure_const/be2/pi;
1409                                                  1428 
1410    dNdxP  *= (1 - std::exp(-beta/betaBohr/fLo << 1429    dNdxP  *= (1 - exp(-beta/betaBohr/fLowEnergyCof));
1411                                                  1430 
1412    modul2 = (1 + fRePartDielectricConst[i])*( << 1431    // dNdxP *= (1-exp(-be4/betaBohr4));
1413      fImPartDielectricConst[i]*fImPartDielect << 1432 
1414    if( modul2 >= 0.0 )                        << 1433    if( fDensity >= 0.1 )
1415    {                                             1434    { 
                                                   >> 1435      modul2 = (1 + fRePartDielectricConst[i])*(1 + fRePartDielectricConst[i]) + 
                                                   >> 1436         fImPartDielectricConst[i]*fImPartDielectricConst[i];
1416      dNdxP /= modul2;                            1437      dNdxP /= modul2;
1417    }                                             1438    }
1418    return dNdxP;                                 1439    return dNdxP;
1419                                                  1440 
1420 } // end of PAIdNdxPlasmon                       1441 } // end of PAIdNdxPlasmon 
1421                                                  1442 
1422 /////////////////////////////////////////////    1443 //////////////////////////////////////////////////////////////////////////
1423 //                                               1444 //
1424 // Calculation od dN/dx of collisions with cr    1445 // Calculation od dN/dx of collisions with creation of longitudinal EM
1425 // resonance excitations (plasmons, delta-ele    1446 // resonance excitations (plasmons, delta-electrons)
1426                                                  1447 
1427 G4double G4PAIxSection::PAIdNdxResonance( G4i    1448 G4double G4PAIxSection::PAIdNdxResonance( G4int    i ,
1428                                         G4dou    1449                                         G4double betaGammaSq  )
1429 {                                                1450 {        
1430    G4double resonance, modul2, dNdxP;            1451    G4double resonance, modul2, dNdxP;
1431    G4double be2, be4, betaBohr2, betaBohr4, c    1452    G4double be2, be4, betaBohr2, betaBohr4, cofBetaBohr;
1432                                                  1453 
1433    cofBetaBohr = 4.0;                            1454    cofBetaBohr = 4.0;
1434    betaBohr2   = fine_structure_const*fine_st    1455    betaBohr2   = fine_structure_const*fine_structure_const;
1435    betaBohr4   = betaBohr2*betaBohr2*cofBetaB    1456    betaBohr4   = betaBohr2*betaBohr2*cofBetaBohr;
1436                                                  1457 
1437    be2 = betaGammaSq/(1 + betaGammaSq);          1458    be2 = betaGammaSq/(1 + betaGammaSq);
1438    be4 = be2*be2;                                1459    be4 = be2*be2;
1439                                                  1460  
1440    resonance = log(2*electron_mass_c2*be2/fSp    1461    resonance = log(2*electron_mass_c2*be2/fSplineEnergy[i]);  
1441    resonance *= fImPartDielectricConst[i]/hba    1462    resonance *= fImPartDielectricConst[i]/hbarc;
1442                                                  1463 
                                                   >> 1464 
1443    dNdxP = resonance;                            1465    dNdxP = resonance;
1444                                                  1466 
1445    if( dNdxP < 1.0e-8 ) dNdxP = 1.0e-8;          1467    if( dNdxP < 1.0e-8 ) dNdxP = 1.0e-8;
1446                                                  1468 
1447    dNdxP *= fine_structure_const/be2/pi;         1469    dNdxP *= fine_structure_const/be2/pi;
1448    dNdxP *= (1 - std::exp(-be4/betaBohr4));   << 1470    dNdxP *= (1-exp(-be4/betaBohr4));
1449                                                  1471 
1450    modul2 = (1 + fRePartDielectricConst[i])*( << 1472    if( fDensity >= 0.1 )
1451      fImPartDielectricConst[i]*fImPartDielect << 
1452    if( modul2 >= 0.0 )                        << 
1453    {                                             1473    { 
                                                   >> 1474      modul2 = (1 + fRePartDielectricConst[i])*(1 + fRePartDielectricConst[i]) + 
                                                   >> 1475         fImPartDielectricConst[i]*fImPartDielectricConst[i];
1454      dNdxP /= modul2;                            1476      dNdxP /= modul2;
1455    }                                             1477    }
1456    return dNdxP;                                 1478    return dNdxP;
1457                                                  1479 
1458 } // end of PAIdNdxResonance                     1480 } // end of PAIdNdxResonance 
1459                                                  1481 
1460 /////////////////////////////////////////////    1482 ////////////////////////////////////////////////////////////////////////
1461 //                                               1483 //
1462 // Calculation of the PAI integral cross-sect    1484 // Calculation of the PAI integral cross-section
1463 // fIntegralPAIxSection[1] = specific primary    1485 // fIntegralPAIxSection[1] = specific primary ionisation, 1/cm
1464 // and fIntegralPAIxSection[0] = mean energy     1486 // and fIntegralPAIxSection[0] = mean energy loss per cm  in keV/cm
1465                                                  1487 
1466 void G4PAIxSection::IntegralPAIxSection()        1488 void G4PAIxSection::IntegralPAIxSection()
1467 {                                                1489 {
1468   fIntegralPAIxSection[fSplineNumber] = 0;       1490   fIntegralPAIxSection[fSplineNumber] = 0;
1469   fIntegralPAIdEdx[fSplineNumber]     = 0;       1491   fIntegralPAIdEdx[fSplineNumber]     = 0;
1470   fIntegralPAIxSection[0]             = 0;       1492   fIntegralPAIxSection[0]             = 0;
1471   G4int i, k = fIntervalNumber -1;               1493   G4int i, k = fIntervalNumber -1;
1472                                                  1494 
1473   for( i = fSplineNumber-1; i >= 1; i--)         1495   for( i = fSplineNumber-1; i >= 1; i--)
1474   {                                              1496   {
1475     if(fSplineEnergy[i] >= fEnergyInterval[k]    1497     if(fSplineEnergy[i] >= fEnergyInterval[k])
1476     {                                            1498     {
1477       fIntegralPAIxSection[i] = fIntegralPAIx    1499       fIntegralPAIxSection[i] = fIntegralPAIxSection[i+1] + SumOverInterval(i);
1478       fIntegralPAIdEdx[i] = fIntegralPAIdEdx[    1500       fIntegralPAIdEdx[i] = fIntegralPAIdEdx[i+1] + SumOverIntervaldEdx(i);
1479     }                                            1501     }
1480     else                                         1502     else
1481     {                                            1503     {
1482       fIntegralPAIxSection[i] = fIntegralPAIx    1504       fIntegralPAIxSection[i] = fIntegralPAIxSection[i+1] + 
1483                                    SumOverBor << 1505                              SumOverBorder(i+1,fEnergyInterval[k]);
1484       fIntegralPAIdEdx[i] = fIntegralPAIdEdx[    1506       fIntegralPAIdEdx[i] = fIntegralPAIdEdx[i+1] + 
1485                                    SumOverBor << 1507                              SumOverBorderdEdx(i+1,fEnergyInterval[k]);
1486       k--;                                       1508       k--;
1487     }                                            1509     }
1488     if(fVerbose>0) G4cout<<"i = "<<i<<"; k =     1510     if(fVerbose>0) G4cout<<"i = "<<i<<"; k = "<<k<<"; intPAIxsc[i] = "<<fIntegralPAIxSection[i]<<G4endl;
1489   }                                              1511   }
1490 }   // end of IntegralPAIxSection                1512 }   // end of IntegralPAIxSection 
1491                                                  1513 
1492 /////////////////////////////////////////////    1514 ////////////////////////////////////////////////////////////////////////
1493 //                                               1515 //
1494 // Calculation of the PAI Cerenkov integral c    1516 // Calculation of the PAI Cerenkov integral cross-section
1495 // fIntegralCrenkov[1] = specific Crenkov ion    1517 // fIntegralCrenkov[1] = specific Crenkov ionisation, 1/cm
1496 // and fIntegralCerenkov[0] = mean Cerenkov l    1518 // and fIntegralCerenkov[0] = mean Cerenkov loss per cm  in keV/cm
1497                                                  1519 
1498 void G4PAIxSection::IntegralCerenkov()           1520 void G4PAIxSection::IntegralCerenkov()
1499 {                                                1521 {
1500   G4int i, k;                                    1522   G4int i, k;
1501    fIntegralCerenkov[fSplineNumber] = 0;         1523    fIntegralCerenkov[fSplineNumber] = 0;
1502    fIntegralCerenkov[0] = 0;                     1524    fIntegralCerenkov[0] = 0;
1503    k = fIntervalNumber -1;                       1525    k = fIntervalNumber -1;
1504                                                  1526 
1505    for( i = fSplineNumber-1; i >= 1; i-- )       1527    for( i = fSplineNumber-1; i >= 1; i-- )
1506    {                                             1528    {
1507       if(fSplineEnergy[i] >= fEnergyInterval[    1529       if(fSplineEnergy[i] >= fEnergyInterval[k])
1508       {                                          1530       {
1509         fIntegralCerenkov[i] = fIntegralCeren    1531         fIntegralCerenkov[i] = fIntegralCerenkov[i+1] + SumOverInterCerenkov(i);
1510         // G4cout<<"int: i = "<<i<<"; sumC =  << 1532   // G4cout<<"int: i = "<<i<<"; sumC = "<<fIntegralCerenkov[i]<<G4endl;
1511       }                                          1533       }
1512       else                                       1534       else
1513       {                                          1535       {
1514         fIntegralCerenkov[i] = fIntegralCeren    1536         fIntegralCerenkov[i] = fIntegralCerenkov[i+1] + 
1515                                    SumOverBor << 1537                              SumOverBordCerenkov(i+1,fEnergyInterval[k]);
1516         k--;                                  << 1538   k--;
1517         // G4cout<<"bord: i = "<<i<<"; sumC = << 1539   // G4cout<<"bord: i = "<<i<<"; sumC = "<<fIntegralCerenkov[i]<<G4endl;
1518       }                                          1540       }
1519    }                                             1541    }
1520                                                  1542 
1521 }   // end of IntegralCerenkov                   1543 }   // end of IntegralCerenkov 
1522                                                  1544 
1523 /////////////////////////////////////////////    1545 ////////////////////////////////////////////////////////////////////////
1524 //                                               1546 //
1525 // Calculation of the PAI MM-Cerenkov integra    1547 // Calculation of the PAI MM-Cerenkov integral cross-section
1526 // fIntegralMM[1] = specific MM-Cerenkov ioni    1548 // fIntegralMM[1] = specific MM-Cerenkov ionisation, 1/cm
1527 // and fIntegralMM[0] = mean MM-Cerenkov loss    1549 // and fIntegralMM[0] = mean MM-Cerenkov loss per cm  in keV/cm
1528                                                  1550 
1529 void G4PAIxSection::IntegralMM()                 1551 void G4PAIxSection::IntegralMM()
1530 {                                                1552 {
1531   G4int i, k;                                    1553   G4int i, k;
1532    fIntegralMM[fSplineNumber] = 0;               1554    fIntegralMM[fSplineNumber] = 0;
1533    fIntegralMM[0] = 0;                           1555    fIntegralMM[0] = 0;
1534    k = fIntervalNumber -1;                       1556    k = fIntervalNumber -1;
1535                                                  1557 
1536    for( i = fSplineNumber-1; i >= 1; i-- )       1558    for( i = fSplineNumber-1; i >= 1; i-- )
1537    {                                             1559    {
1538       if(fSplineEnergy[i] >= fEnergyInterval[    1560       if(fSplineEnergy[i] >= fEnergyInterval[k])
1539       {                                          1561       {
1540         fIntegralMM[i] = fIntegralMM[i+1] + S    1562         fIntegralMM[i] = fIntegralMM[i+1] + SumOverInterMM(i);
1541         // G4cout<<"int: i = "<<i<<"; sumC =  << 1563   // G4cout<<"int: i = "<<i<<"; sumC = "<<fIntegralMM[i]<<G4endl;
1542       }                                          1564       }
1543       else                                       1565       else
1544       {                                          1566       {
1545         fIntegralMM[i] = fIntegralMM[i+1] +      1567         fIntegralMM[i] = fIntegralMM[i+1] + 
1546                                    SumOverBor << 1568                              SumOverBordMM(i+1,fEnergyInterval[k]);
1547         k--;                                  << 1569   k--;
1548         // G4cout<<"bord: i = "<<i<<"; sumC = << 1570   // G4cout<<"bord: i = "<<i<<"; sumC = "<<fIntegralMM[i]<<G4endl;
1549       }                                          1571       }
1550    }                                             1572    }
1551                                                  1573 
1552 }   // end of IntegralMM                         1574 }   // end of IntegralMM 
1553                                                  1575 
1554 /////////////////////////////////////////////    1576 ////////////////////////////////////////////////////////////////////////
1555 //                                               1577 //
1556 // Calculation of the PAI Plasmon integral cr    1578 // Calculation of the PAI Plasmon integral cross-section
1557 // fIntegralPlasmon[1] = splasmon primary ion    1579 // fIntegralPlasmon[1] = splasmon primary ionisation, 1/cm
1558 // and fIntegralPlasmon[0] = mean plasmon los    1580 // and fIntegralPlasmon[0] = mean plasmon loss per cm  in keV/cm
1559                                                  1581 
1560 void G4PAIxSection::IntegralPlasmon()            1582 void G4PAIxSection::IntegralPlasmon()
1561 {                                                1583 {
1562    fIntegralPlasmon[fSplineNumber] = 0;          1584    fIntegralPlasmon[fSplineNumber] = 0;
1563    fIntegralPlasmon[0] = 0;                      1585    fIntegralPlasmon[0] = 0;
1564    G4int k = fIntervalNumber -1;                 1586    G4int k = fIntervalNumber -1;
1565    for(G4int i=fSplineNumber-1;i>=1;i--)         1587    for(G4int i=fSplineNumber-1;i>=1;i--)
1566    {                                             1588    {
1567       if(fSplineEnergy[i] >= fEnergyInterval[    1589       if(fSplineEnergy[i] >= fEnergyInterval[k])
1568       {                                          1590       {
1569         fIntegralPlasmon[i] = fIntegralPlasmo    1591         fIntegralPlasmon[i] = fIntegralPlasmon[i+1] + SumOverInterPlasmon(i);
1570       }                                          1592       }
1571       else                                       1593       else
1572       {                                          1594       {
1573         fIntegralPlasmon[i] = fIntegralPlasmo    1595         fIntegralPlasmon[i] = fIntegralPlasmon[i+1] + 
1574                                    SumOverBor << 1596                              SumOverBordPlasmon(i+1,fEnergyInterval[k]);
1575         k--;                                  << 1597   k--;
1576       }                                          1598       }
1577    }                                             1599    }
1578                                                  1600 
1579 }   // end of IntegralPlasmon                    1601 }   // end of IntegralPlasmon
1580                                                  1602 
1581 /////////////////////////////////////////////    1603 ////////////////////////////////////////////////////////////////////////
1582 //                                               1604 //
1583 // Calculation of the PAI resonance integral     1605 // Calculation of the PAI resonance integral cross-section
1584 // fIntegralResonance[1] = resonance primary     1606 // fIntegralResonance[1] = resonance primary ionisation, 1/cm
1585 // and fIntegralResonance[0] = mean resonance    1607 // and fIntegralResonance[0] = mean resonance loss per cm  in keV/cm
1586                                                  1608 
1587 void G4PAIxSection::IntegralResonance()          1609 void G4PAIxSection::IntegralResonance()
1588 {                                                1610 {
1589    fIntegralResonance[fSplineNumber] = 0;        1611    fIntegralResonance[fSplineNumber] = 0;
1590    fIntegralResonance[0] = 0;                    1612    fIntegralResonance[0] = 0;
1591    G4int k = fIntervalNumber -1;                 1613    G4int k = fIntervalNumber -1;
1592    for(G4int i=fSplineNumber-1;i>=1;i--)         1614    for(G4int i=fSplineNumber-1;i>=1;i--)
1593    {                                             1615    {
1594       if(fSplineEnergy[i] >= fEnergyInterval[    1616       if(fSplineEnergy[i] >= fEnergyInterval[k])
1595       {                                          1617       {
1596         fIntegralResonance[i] = fIntegralReso    1618         fIntegralResonance[i] = fIntegralResonance[i+1] + SumOverInterResonance(i);
1597       }                                          1619       }
1598       else                                       1620       else
1599       {                                          1621       {
1600         fIntegralResonance[i] = fIntegralReso    1622         fIntegralResonance[i] = fIntegralResonance[i+1] + 
1601                                    SumOverBor << 1623                              SumOverBordResonance(i+1,fEnergyInterval[k]);
1602         k--;                                  << 1624   k--;
1603       }                                          1625       }
1604    }                                             1626    }
1605                                                  1627 
1606 }   // end of IntegralResonance                  1628 }   // end of IntegralResonance
1607                                                  1629 
1608 /////////////////////////////////////////////    1630 //////////////////////////////////////////////////////////////////////
1609 //                                               1631 //
1610 // Calculation the PAI integral cross-section    1632 // Calculation the PAI integral cross-section inside
1611 // of interval of continuous values of photo-    1633 // of interval of continuous values of photo-ionisation
1612 // cross-section. Parameter  'i' is the numbe    1634 // cross-section. Parameter  'i' is the number of interval.
1613                                                  1635 
1614 G4double G4PAIxSection::SumOverInterval( G4in    1636 G4double G4PAIxSection::SumOverInterval( G4int i )
1615 {                                                1637 {         
1616    G4double x0,x1,y0,yy1,a,b,c,result;           1638    G4double x0,x1,y0,yy1,a,b,c,result;
1617                                                  1639 
1618    x0 = fSplineEnergy[i];                        1640    x0 = fSplineEnergy[i];
1619    x1 = fSplineEnergy[i+1];                      1641    x1 = fSplineEnergy[i+1];
1620    if(fVerbose>0) G4cout<<"SumOverInterval i=    1642    if(fVerbose>0) G4cout<<"SumOverInterval i= " << i << " x0 = "<<x0<<"; x1 = "<<x1<<G4endl;
1621                                                  1643 
1622    if( x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(    1644    if( x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1623                                                  1645 
1624    y0 = fDifPAIxSection[i];                      1646    y0 = fDifPAIxSection[i];
1625    yy1 = fDifPAIxSection[i+1];                   1647    yy1 = fDifPAIxSection[i+1];
1626                                                  1648 
1627    if(fVerbose>0) G4cout<<"x0 = "<<x0<<"; x1     1649    if(fVerbose>0) G4cout<<"x0 = "<<x0<<"; x1 = "<<x1<<", y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
1628                                                  1650 
1629    c = x1/x0;                                    1651    c = x1/x0;
1630    a = log10(yy1/y0)/log10(c);                   1652    a = log10(yy1/y0)/log10(c);
1631                                                  1653 
1632    if(fVerbose>0) G4cout<<"SumOverInterval, a    1654    if(fVerbose>0) G4cout<<"SumOverInterval, a = "<<a<<"; c = "<<c<<G4endl;
1633                                                  1655 
1634    b = 0.0;                                   << 1656    // b = log10(y0) - a*log10(x0);
1635    if(a < 20.) b = y0/pow(x0,a);              << 1657    b = y0/pow(x0,a);
1636                                               << 
1637    a += 1.;                                      1658    a += 1.;
1638    if( std::abs(a) < 1.e-6 )                  << 1659    if( std::fabs(a) < 1.e-6 ) 
1639    {                                             1660    {
1640       result = b*log(x1/x0);                     1661       result = b*log(x1/x0);
1641    }                                             1662    }
1642    else                                          1663    else
1643    {                                             1664    {
1644       result = y0*(x1*pow(c,a-1) - x0)/a;        1665       result = y0*(x1*pow(c,a-1) - x0)/a;
1645    }                                             1666    }
1646    a += 1.;                                      1667    a += 1.;
1647    if( std::abs(a) < 1.e-6 )                  << 1668    if( std::fabs(a) < 1.e-6 ) 
1648    {                                             1669    {
1649      fIntegralPAIxSection[0] += b*log(x1/x0); << 1670       fIntegralPAIxSection[0] += b*log(x1/x0);
1650    }                                             1671    }
1651    else                                          1672    else
1652    {                                             1673    {
1653       fIntegralPAIxSection[0] += y0*(x1*x1*po    1674       fIntegralPAIxSection[0] += y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1654    }                                             1675    }
1655    if(fVerbose>0) G4cout<<"SumOverInterval, r    1676    if(fVerbose>0) G4cout<<"SumOverInterval, result = "<<result<<G4endl;
1656    return result;                                1677    return result;
1657                                                  1678 
1658 } //  end of SumOverInterval                     1679 } //  end of SumOverInterval
1659                                                  1680 
1660 /////////////////////////////////                1681 /////////////////////////////////
1661                                                  1682 
1662 G4double G4PAIxSection::SumOverIntervaldEdx(     1683 G4double G4PAIxSection::SumOverIntervaldEdx( G4int i )
1663 {                                                1684 {         
1664    G4double x0,x1,y0,yy1,a,b,c,result;           1685    G4double x0,x1,y0,yy1,a,b,c,result;
1665                                                  1686 
1666    x0 = fSplineEnergy[i];                        1687    x0 = fSplineEnergy[i];
1667    x1 = fSplineEnergy[i+1];                      1688    x1 = fSplineEnergy[i+1];
1668                                                  1689 
1669    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x    1690    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1670                                                  1691 
1671    y0 = fDifPAIxSection[i];                      1692    y0 = fDifPAIxSection[i];
1672    yy1 = fDifPAIxSection[i+1];                   1693    yy1 = fDifPAIxSection[i+1];
1673    c = x1/x0;                                    1694    c = x1/x0;
1674    a = log10(yy1/y0)/log10(c);                   1695    a = log10(yy1/y0)/log10(c);
1675                                               << 1696    // b = log10(y0) - a*log10(x0);
1676    b = 0.0;                                   << 1697    b = y0/pow(x0,a);
1677    if(a < 20.) b = y0/pow(x0,a);              << 
1678                                               << 
1679    a += 2;                                       1698    a += 2;
1680    if(a == 0)                                    1699    if(a == 0) 
1681    {                                             1700    {
1682      result = b*log(x1/x0);                      1701      result = b*log(x1/x0);
1683    }                                             1702    }
1684    else                                          1703    else
1685    {                                             1704    {
1686      result = y0*(x1*x1*pow(c,a-2) - x0*x0)/a    1705      result = y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1687    }                                             1706    }
1688    return result;                                1707    return result;
1689                                                  1708 
1690 } //  end of SumOverInterval                     1709 } //  end of SumOverInterval
1691                                                  1710 
1692 /////////////////////////////////////////////    1711 //////////////////////////////////////////////////////////////////////
1693 //                                               1712 //
1694 // Calculation the PAI Cerenkov integral cros    1713 // Calculation the PAI Cerenkov integral cross-section inside
1695 // of interval of continuous values of photo-    1714 // of interval of continuous values of photo-ionisation Cerenkov
1696 // cross-section. Parameter  'i' is the numbe    1715 // cross-section. Parameter  'i' is the number of interval.
1697                                                  1716 
1698 G4double G4PAIxSection::SumOverInterCerenkov(    1717 G4double G4PAIxSection::SumOverInterCerenkov( G4int i )
1699 {                                                1718 {         
1700    G4double x0,x1,y0,yy1,a,b,c,result;           1719    G4double x0,x1,y0,yy1,a,b,c,result;
1701                                                  1720 
1702    x0  = fSplineEnergy[i];                       1721    x0  = fSplineEnergy[i];
1703    x1  = fSplineEnergy[i+1];                     1722    x1  = fSplineEnergy[i+1];
1704                                                  1723 
1705    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x    1724    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1706                                                  1725 
1707    y0  = fdNdxCerenkov[i];                       1726    y0  = fdNdxCerenkov[i];
1708    yy1 = fdNdxCerenkov[i+1];                     1727    yy1 = fdNdxCerenkov[i+1];
1709    // G4cout<<"SumC, i = "<<i<<"; x0 ="<<x0<<    1728    // G4cout<<"SumC, i = "<<i<<"; x0 ="<<x0<<"; x1 = "<<x1
1710    //   <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4e    1729    //   <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
1711                                                  1730 
1712    c = x1/x0;                                    1731    c = x1/x0;
1713    a = log10(yy1/y0)/log10(c);                   1732    a = log10(yy1/y0)/log10(c);
1714                                               << 1733    b = y0/pow(x0,a);
1715    if(a > 20.0) b = 0.0;                      << 
1716    else         b = y0/pow(x0,a);             << 
1717                                                  1734 
1718    a += 1.0;                                     1735    a += 1.0;
1719    if(a == 0) result = b*log(c);                 1736    if(a == 0) result = b*log(c);
1720    else       result = y0*(x1*pow(c,a-1) - x0    1737    else       result = y0*(x1*pow(c,a-1) - x0)/a;   
1721    a += 1.0;                                     1738    a += 1.0;
1722                                                  1739 
1723    if( a == 0 ) fIntegralCerenkov[0] += b*log    1740    if( a == 0 ) fIntegralCerenkov[0] += b*log(x1/x0);
1724    else         fIntegralCerenkov[0] += y0*(x    1741    else         fIntegralCerenkov[0] += y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1725    //  G4cout<<"a = "<<a<<"; b = "<<b<<"; res    1742    //  G4cout<<"a = "<<a<<"; b = "<<b<<"; result = "<<result<<G4endl;   
1726    return result;                                1743    return result;
1727                                                  1744 
1728 } //  end of SumOverInterCerenkov                1745 } //  end of SumOverInterCerenkov
1729                                                  1746 
1730 /////////////////////////////////////////////    1747 //////////////////////////////////////////////////////////////////////
1731 //                                               1748 //
1732 // Calculation the PAI MM-Cerenkov integral c    1749 // Calculation the PAI MM-Cerenkov integral cross-section inside
1733 // of interval of continuous values of photo-    1750 // of interval of continuous values of photo-ionisation Cerenkov
1734 // cross-section. Parameter  'i' is the numbe    1751 // cross-section. Parameter  'i' is the number of interval.
1735                                                  1752 
1736 G4double G4PAIxSection::SumOverInterMM( G4int    1753 G4double G4PAIxSection::SumOverInterMM( G4int i )
1737 {                                                1754 {         
1738    G4double x0,x1,y0,yy1,a,b,c,result;           1755    G4double x0,x1,y0,yy1,a,b,c,result;
1739                                                  1756 
1740    x0  = fSplineEnergy[i];                       1757    x0  = fSplineEnergy[i];
1741    x1  = fSplineEnergy[i+1];                     1758    x1  = fSplineEnergy[i+1];
1742                                                  1759 
1743    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x    1760    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1744                                                  1761 
1745    y0  = fdNdxMM[i];                             1762    y0  = fdNdxMM[i];
1746    yy1 = fdNdxMM[i+1];                           1763    yy1 = fdNdxMM[i+1];
1747    //G4cout<<"SumC, i = "<<i<<"; x0 ="<<x0<<"    1764    //G4cout<<"SumC, i = "<<i<<"; x0 ="<<x0<<"; x1 = "<<x1
1748    //   <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4e    1765    //   <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
1749                                                  1766 
1750    c = x1/x0;                                    1767    c = x1/x0;
1751    //G4cout<<" c = "<<c<< " yy1/y0= " << yy1/    1768    //G4cout<<" c = "<<c<< " yy1/y0= " << yy1/y0 <<G4endl;   
1752    a = log10(yy1/y0)/log10(c);                   1769    a = log10(yy1/y0)/log10(c);
1753                                               << 1770    if(a > 10.0) return 0.;  
1754    b = 0.0;                                   << 1771    b = y0/pow(x0,a);
1755    if(a < 20.) b = y0/pow(x0,a);              << 
1756                                                  1772 
1757    a += 1.0;                                     1773    a += 1.0;
1758    if(a == 0) result = b*log(c);                 1774    if(a == 0) result = b*log(c);
1759    else       result = y0*(x1*pow(c,a-1) - x0    1775    else       result = y0*(x1*pow(c,a-1) - x0)/a;   
1760    a += 1.0;                                     1776    a += 1.0;
1761                                                  1777 
1762    if( a == 0 ) fIntegralMM[0] += b*log(c);      1778    if( a == 0 ) fIntegralMM[0] += b*log(c);
1763    else         fIntegralMM[0] += y0*(x1*x1*p    1779    else         fIntegralMM[0] += y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1764    //G4cout<<"a = "<<a<<"; b = "<<b<<"; resul    1780    //G4cout<<"a = "<<a<<"; b = "<<b<<"; result = "<<result<<G4endl;   
1765    return result;                                1781    return result;
1766                                                  1782 
1767 } //  end of SumOverInterMM                      1783 } //  end of SumOverInterMM
1768                                                  1784 
1769 /////////////////////////////////////////////    1785 //////////////////////////////////////////////////////////////////////
1770 //                                               1786 //
1771 // Calculation the PAI Plasmon integral cross    1787 // Calculation the PAI Plasmon integral cross-section inside
1772 // of interval of continuous values of photo-    1788 // of interval of continuous values of photo-ionisation Plasmon
1773 // cross-section. Parameter  'i' is the numbe    1789 // cross-section. Parameter  'i' is the number of interval.
1774                                                  1790 
1775 G4double G4PAIxSection::SumOverInterPlasmon(     1791 G4double G4PAIxSection::SumOverInterPlasmon( G4int i )
1776 {                                                1792 {         
1777    G4double x0,x1,y0,yy1,a,b,c,result;           1793    G4double x0,x1,y0,yy1,a,b,c,result;
1778                                                  1794 
1779    x0  = fSplineEnergy[i];                       1795    x0  = fSplineEnergy[i];
1780    x1  = fSplineEnergy[i+1];                     1796    x1  = fSplineEnergy[i+1];
1781                                                  1797 
1782    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x    1798    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1783                                                  1799 
1784    y0  = fdNdxPlasmon[i];                        1800    y0  = fdNdxPlasmon[i];
1785    yy1 = fdNdxPlasmon[i+1];                      1801    yy1 = fdNdxPlasmon[i+1];
1786    c = x1/x0;                                 << 1802    c =x1/x0;
1787    a = log10(yy1/y0)/log10(c);                   1803    a = log10(yy1/y0)/log10(c);
1788                                               << 1804    if(a > 10.0) return 0.;  
1789    b = 0.0;                                   << 1805    // b = log10(y0) - a*log10(x0);
1790    if(a < 20.) b = y0/pow(x0,a);              << 1806    b = y0/pow(x0,a);
1791                                                  1807 
1792    a += 1.0;                                     1808    a += 1.0;
1793    if(a == 0) result = b*log(x1/x0);             1809    if(a == 0) result = b*log(x1/x0);
1794    else       result = y0*(x1*pow(c,a-1) - x0    1810    else       result = y0*(x1*pow(c,a-1) - x0)/a;   
1795    a += 1.0;                                     1811    a += 1.0;
1796                                                  1812 
1797    if( a == 0 ) fIntegralPlasmon[0] += b*log(    1813    if( a == 0 ) fIntegralPlasmon[0] += b*log(x1/x0);
1798    else         fIntegralPlasmon[0] += y0*(x1    1814    else         fIntegralPlasmon[0] += y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1799                                                  1815    
1800    return result;                                1816    return result;
1801                                                  1817 
1802 } //  end of SumOverInterPlasmon                 1818 } //  end of SumOverInterPlasmon
1803                                                  1819 
1804 /////////////////////////////////////////////    1820 //////////////////////////////////////////////////////////////////////
1805 //                                               1821 //
1806 // Calculation the PAI resonance integral cro    1822 // Calculation the PAI resonance integral cross-section inside
1807 // of interval of continuous values of photo-    1823 // of interval of continuous values of photo-ionisation resonance
1808 // cross-section. Parameter  'i' is the numbe    1824 // cross-section. Parameter  'i' is the number of interval.
1809                                                  1825 
1810 G4double G4PAIxSection::SumOverInterResonance    1826 G4double G4PAIxSection::SumOverInterResonance( G4int i )
1811 {                                                1827 {         
1812    G4double x0,x1,y0,yy1,a,b,c,result;           1828    G4double x0,x1,y0,yy1,a,b,c,result;
1813                                                  1829 
1814    x0  = fSplineEnergy[i];                       1830    x0  = fSplineEnergy[i];
1815    x1  = fSplineEnergy[i+1];                     1831    x1  = fSplineEnergy[i+1];
1816                                                  1832 
1817    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x    1833    if(x1+x0 <= 0.0 || std::abs( 2.*(x1-x0)/(x1+x0) ) < 1.e-6) return 0.;
1818                                                  1834 
1819    y0  = fdNdxResonance[i];                      1835    y0  = fdNdxResonance[i];
1820    yy1 = fdNdxResonance[i+1];                    1836    yy1 = fdNdxResonance[i+1];
1821    c =x1/x0;                                     1837    c =x1/x0;
1822    a = log10(yy1/y0)/log10(c);                   1838    a = log10(yy1/y0)/log10(c);
1823                                               << 1839    if(a > 10.0) return 0.;  
1824    b = 0.0;                                   << 1840    // b = log10(y0) - a*log10(x0);
1825    if(a < 20.) b = y0/pow(x0,a);              << 1841    b = y0/pow(x0,a);
1826                                                  1842 
1827    a += 1.0;                                     1843    a += 1.0;
1828    if(a == 0) result = b*log(x1/x0);             1844    if(a == 0) result = b*log(x1/x0);
1829    else       result = y0*(x1*pow(c,a-1) - x0    1845    else       result = y0*(x1*pow(c,a-1) - x0)/a;   
1830    a += 1.0;                                     1846    a += 1.0;
1831                                                  1847 
1832    if( a == 0 ) fIntegralResonance[0] += b*lo    1848    if( a == 0 ) fIntegralResonance[0] += b*log(x1/x0);
1833    else         fIntegralResonance[0] += y0*(    1849    else         fIntegralResonance[0] += y0*(x1*x1*pow(c,a-2) - x0*x0)/a;
1834                                                  1850    
1835    return result;                                1851    return result;
1836                                                  1852 
1837 } //  end of SumOverInterResonance               1853 } //  end of SumOverInterResonance
1838                                                  1854 
1839 /////////////////////////////////////////////    1855 ///////////////////////////////////////////////////////////////////////////////
1840 //                                               1856 //
1841 // Integration of PAI cross-section for the c    1857 // Integration of PAI cross-section for the case of
1842 // passing across border between intervals       1858 // passing across border between intervals
1843                                                  1859 
1844 G4double G4PAIxSection::SumOverBorder( G4int     1860 G4double G4PAIxSection::SumOverBorder( G4int      i , 
1845                                        G4doub    1861                                        G4double en0    )
1846 {                                                1862 {               
1847   G4double x0,x1,y0,yy1,a,b,/*c,*/d,e0,result    1863   G4double x0,x1,y0,yy1,a,b,/*c,*/d,e0,result;
1848                                                  1864 
1849    e0 = en0;                                     1865    e0 = en0;
1850    x0 = fSplineEnergy[i];                        1866    x0 = fSplineEnergy[i];
1851    x1 = fSplineEnergy[i+1];                      1867    x1 = fSplineEnergy[i+1];
1852    y0 = fDifPAIxSection[i];                      1868    y0 = fDifPAIxSection[i];
1853    yy1 = fDifPAIxSection[i+1];                   1869    yy1 = fDifPAIxSection[i+1];
1854                                                  1870 
1855    //c = x1/x0;                                  1871    //c = x1/x0;
1856    d = e0/x0;                                    1872    d = e0/x0;   
1857    a = log10(yy1/y0)/log10(x1/x0);               1873    a = log10(yy1/y0)/log10(x1/x0);
                                                   >> 1874    if(a > 10.0) return 0.;  
1858                                                  1875 
1859    if(fVerbose>0) G4cout<<"SumOverBorder, a =    1876    if(fVerbose>0) G4cout<<"SumOverBorder, a = "<<a<<G4endl;
1860                                                  1877 
1861    b = 0.0;                                   << 1878    // b0 = log10(y0) - a*log10(x0);
1862    if(a < 20.) b = y0/pow(x0,a);              << 1879    b = y0/pow(x0,a);  // pow(10.,b);
1863                                                  1880    
1864    a += 1.;                                      1881    a += 1.;
1865    if( std::abs(a) < 1.e-6 )                  << 1882    if( std::fabs(a) < 1.e-6 )
1866    {                                             1883    {
1867       result = b*log(x0/e0);                     1884       result = b*log(x0/e0);
1868    }                                             1885    }
1869    else                                          1886    else
1870    {                                             1887    {
1871       result = y0*(x0 - e0*pow(d,a-1))/a;        1888       result = y0*(x0 - e0*pow(d,a-1))/a;
1872    }                                             1889    }
1873    a += 1.;                                      1890    a += 1.;
1874    if( std::abs(a) < 1.e-6 )                  << 1891    if( std::fabs(a) < 1.e-6 )
1875    {                                             1892    {
1876       fIntegralPAIxSection[0] += b*log(x0/e0)    1893       fIntegralPAIxSection[0] += b*log(x0/e0);
1877    }                                             1894    }
1878    else                                          1895    else 
1879    {                                             1896    {
1880       fIntegralPAIxSection[0] += y0*(x0*x0 -     1897       fIntegralPAIxSection[0] += y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
1881    }                                             1898    }
1882    x0 = fSplineEnergy[i - 1];                    1899    x0 = fSplineEnergy[i - 1];
1883    x1 = fSplineEnergy[i - 2];                    1900    x1 = fSplineEnergy[i - 2];
1884    y0 = fDifPAIxSection[i - 1];                  1901    y0 = fDifPAIxSection[i - 1];
1885    yy1 = fDifPAIxSection[i - 2];                 1902    yy1 = fDifPAIxSection[i - 2];
1886                                                  1903 
                                                   >> 1904    //c = x1/x0;
1887    d = e0/x0;                                    1905    d = e0/x0;   
1888    a = log10(yy1/y0)/log10(x1/x0);               1906    a = log10(yy1/y0)/log10(x1/x0);
1889                                               << 1907    //  b0 = log10(y0) - a*log10(x0);
1890    b = 0.0;                                   << 1908    b = y0/pow(x0,a);
1891    if(a < 20.) b = y0/pow(x0,a);              << 
1892                                               << 
1893    a += 1.;                                      1909    a += 1.;
1894    if( std::abs(a) < 1.e-6 )                  << 1910    if( std::fabs(a) < 1.e-6 )
1895    {                                             1911    {
1896       result += b*log(e0/x0);                    1912       result += b*log(e0/x0);
1897    }                                             1913    }
1898    else                                          1914    else
1899    {                                             1915    {
1900       result += y0*(e0*pow(d,a-1) - x0)/a;       1916       result += y0*(e0*pow(d,a-1) - x0)/a;
1901    }                                             1917    }
1902    a += 1.;                                      1918    a += 1.;
1903    if( std::abs(a) < 1.e-6 )                  << 1919    if( std::fabs(a) < 1.e-6 ) 
1904    {                                             1920    {
1905       fIntegralPAIxSection[0] += b*log(e0/x0)    1921       fIntegralPAIxSection[0] += b*log(e0/x0);
1906    }                                             1922    }
1907    else                                          1923    else
1908    {                                             1924    {
1909       fIntegralPAIxSection[0] += y0*(e0*e0*po    1925       fIntegralPAIxSection[0] += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
1910    }                                             1926    }
1911    return result;                                1927    return result;
1912                                                  1928 
1913 }                                                1929 } 
1914                                                  1930 
1915 /////////////////////////////////////////////    1931 ///////////////////////////////////////////////////////////////////////
1916                                                  1932 
1917 G4double G4PAIxSection::SumOverBorderdEdx( G4 << 1933 G4double G4PAIxSection::SumOverBorderdEdx( G4int      i , 
                                                   >> 1934                                        G4double en0    )
1918 {                                                1935 {               
1919   G4double x0,x1,y0,yy1,a,b,d,e0,result;      << 1936   G4double x0,x1,y0,yy1,a,b,/*c,*/d,e0,result;
1920                                                  1937 
1921    e0 = en0;                                     1938    e0 = en0;
1922    x0 = fSplineEnergy[i];                        1939    x0 = fSplineEnergy[i];
1923    x1 = fSplineEnergy[i+1];                      1940    x1 = fSplineEnergy[i+1];
1924    y0 = fDifPAIxSection[i];                      1941    y0 = fDifPAIxSection[i];
1925    yy1 = fDifPAIxSection[i+1];                   1942    yy1 = fDifPAIxSection[i+1];
1926                                                  1943 
                                                   >> 1944    //c = x1/x0;
1927    d = e0/x0;                                    1945    d = e0/x0;   
1928    a = log10(yy1/y0)/log10(x1/x0);               1946    a = log10(yy1/y0)/log10(x1/x0);
1929                                               << 1947    if(a > 10.0) return 0.;  
1930    b = 0.0;                                   << 1948    // b0 = log10(y0) - a*log10(x0);
1931    if(a < 20.) b = y0/pow(x0,a);              << 1949    b = y0/pow(x0,a);  // pow(10.,b);
1932                                                  1950    
1933    a += 2;                                       1951    a += 2;
1934    if(a == 0)                                    1952    if(a == 0)
1935    {                                             1953    {
1936       result = b*log(x0/e0);                     1954       result = b*log(x0/e0);
1937    }                                             1955    }
1938    else                                          1956    else 
1939    {                                             1957    {
1940       result = y0*(x0*x0 - e0*e0*pow(d,a-2))/    1958       result = y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
1941    }                                             1959    }
1942    x0 = fSplineEnergy[i - 1];                    1960    x0 = fSplineEnergy[i - 1];
1943    x1 = fSplineEnergy[i - 2];                    1961    x1 = fSplineEnergy[i - 2];
1944    y0 = fDifPAIxSection[i - 1];                  1962    y0 = fDifPAIxSection[i - 1];
1945    yy1 = fDifPAIxSection[i - 2];                 1963    yy1 = fDifPAIxSection[i - 2];
1946                                                  1964 
1947    // c = x1/x0;                                 1965    // c = x1/x0;
1948    d = e0/x0;                                    1966    d = e0/x0;   
1949    a = log10(yy1/y0)/log10(x1/x0);               1967    a = log10(yy1/y0)/log10(x1/x0);
1950                                               << 1968    //  b0 = log10(y0) - a*log10(x0);
1951    b = 0.0;                                   << 1969    b = y0/pow(x0,a);
1952    if(a < 20.) b = y0/pow(x0,a);              << 
1953                                               << 
1954    a += 2;                                       1970    a += 2;
1955    if(a == 0)                                    1971    if(a == 0) 
1956    {                                             1972    {
1957       result += b*log(e0/x0);                    1973       result += b*log(e0/x0);
1958    }                                             1974    }
1959    else                                          1975    else
1960    {                                             1976    {
1961       result += y0*(e0*e0*pow(d,a-2) - x0*x0)    1977       result += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
1962    }                                             1978    }
1963    return result;                                1979    return result;
1964                                                  1980 
1965 }                                                1981 } 
1966                                                  1982 
1967 /////////////////////////////////////////////    1983 ///////////////////////////////////////////////////////////////////////////////
1968 //                                               1984 //
1969 // Integration of Cerenkov cross-section for     1985 // Integration of Cerenkov cross-section for the case of
1970 // passing across border between intervals       1986 // passing across border between intervals
1971                                                  1987 
1972 G4double G4PAIxSection::SumOverBordCerenkov(  << 1988 G4double G4PAIxSection::SumOverBordCerenkov( G4int      i , 
                                                   >> 1989                                              G4double en0    )
1973 {                                                1990 {               
1974    G4double x0,x1,y0,yy1,a,b,e0,c,d,result;      1991    G4double x0,x1,y0,yy1,a,b,e0,c,d,result;
1975                                                  1992 
1976    e0 = en0;                                     1993    e0 = en0;
1977    x0 = fSplineEnergy[i];                        1994    x0 = fSplineEnergy[i];
1978    x1 = fSplineEnergy[i+1];                      1995    x1 = fSplineEnergy[i+1];
1979    y0 = fdNdxCerenkov[i];                        1996    y0 = fdNdxCerenkov[i];
1980    yy1 = fdNdxCerenkov[i+1];                     1997    yy1 = fdNdxCerenkov[i+1];
1981                                                  1998 
1982    //G4cout<<"SumBordC, i = "<<i<<"; en0 = "< << 1999    //  G4cout<<G4endl;
1983    //<<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl << 2000    //  G4cout<<"SumBordC, i = "<<i<<"; en0 = "<<en0<<"; x0 ="<<x0<<"; x1 = "<<x1
                                                   >> 2001    //     <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
1984    c = x1/x0;                                    2002    c = x1/x0;
1985    d = e0/x0;                                    2003    d = e0/x0;
1986    a = log10(yy1/y0)/log10(c);                   2004    a = log10(yy1/y0)/log10(c);
1987    //G4cout << "    a= " << a << " c=" << c < << 2005    if(a > 10.0) return 0.;  
1988                                               << 2006    // b0 = log10(y0) - a*log10(x0);
1989    b = 0.0;                                   << 2007    b = y0/pow(x0,a); // pow(10.,b0);   
1990    if(a < 20.) b = y0/pow(x0,a);              << 
1991                                                  2008    
1992    a += 1.0;                                     2009    a += 1.0;
1993    if( a == 0 ) result = b*log(x0/e0);           2010    if( a == 0 ) result = b*log(x0/e0);
1994    else         result = y0*(x0 - e0*pow(d,a-    2011    else         result = y0*(x0 - e0*pow(d,a-1))/a;   
1995    a += 1.0;                                     2012    a += 1.0;
1996                                                  2013 
1997    if( a == 0 ) fIntegralCerenkov[0] += b*log    2014    if( a == 0 ) fIntegralCerenkov[0] += b*log(x0/e0);
1998    else         fIntegralCerenkov[0] += y0*(x    2015    else         fIntegralCerenkov[0] += y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
1999                                                  2016 
                                                   >> 2017 // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b = "<<b<<"; result = "<<result<<G4endl;
                                                   >> 2018    
2000    x0  = fSplineEnergy[i - 1];                   2019    x0  = fSplineEnergy[i - 1];
2001    x1  = fSplineEnergy[i - 2];                   2020    x1  = fSplineEnergy[i - 2];
2002    y0  = fdNdxCerenkov[i - 1];                   2021    y0  = fdNdxCerenkov[i - 1];
2003    yy1 = fdNdxCerenkov[i - 2];                   2022    yy1 = fdNdxCerenkov[i - 2];
2004                                                  2023 
2005    // G4cout<<"x0 ="<<x0<<"; x1 = "<<x1          2024    // G4cout<<"x0 ="<<x0<<"; x1 = "<<x1
2006    //    <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4    2025    //    <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
2007                                                  2026 
2008    c = x1/x0;                                    2027    c = x1/x0;
2009    d = e0/x0;                                    2028    d = e0/x0;
2010    a  = log10(yy1/y0)/log10(c);               << 2029    a  = log10(yy1/y0)/log10(x1/x0);
2011                                               << 2030    // b0 = log10(y0) - a*log10(x0);
2012    b = 0.0;                                   << 2031    b  =  y0/pow(x0,a);  // pow(10.,b0);
2013    if(a < 20.) b = y0/pow(x0,a);              << 
2014                                                  2032 
2015    a += 1.0;                                     2033    a += 1.0;
2016    if( a == 0 ) result += b*log(e0/x0);          2034    if( a == 0 ) result += b*log(e0/x0);
2017    else         result += y0*(e0*pow(d,a-1) -    2035    else         result += y0*(e0*pow(d,a-1) - x0 )/a;
2018    a += 1.0;                                     2036    a += 1.0;
2019                                                  2037 
2020    if( a == 0 ) fIntegralCerenkov[0] += b*log << 2038    if( a == 0 )   fIntegralCerenkov[0] += b*log(e0/x0);
2021    else         fIntegralCerenkov[0] += y0*(e << 2039    else           fIntegralCerenkov[0] += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
                                                   >> 2040 
                                                   >> 2041    // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b = "
                                                   >> 2042    // <<b<<"; result = "<<result<<G4endl;    
2022                                                  2043 
2023    //G4cout<<"  a="<< a <<"  b="<< b <<"  res << 
2024    return result;                                2044    return result;
                                                   >> 2045 
2025 }                                                2046 } 
2026                                                  2047 
2027 /////////////////////////////////////////////    2048 ///////////////////////////////////////////////////////////////////////////////
2028 //                                               2049 //
2029 // Integration of MM-Cerenkov cross-section f    2050 // Integration of MM-Cerenkov cross-section for the case of
2030 // passing across border between intervals       2051 // passing across border between intervals
2031                                                  2052 
2032 G4double G4PAIxSection::SumOverBordMM( G4int  << 2053 G4double G4PAIxSection::SumOverBordMM( G4int      i , 
                                                   >> 2054                                              G4double en0    )
2033 {                                                2055 {               
2034    G4double x0,x1,y0,yy1,a,b,e0,c,d,result;      2056    G4double x0,x1,y0,yy1,a,b,e0,c,d,result;
2035                                                  2057 
2036    e0 = en0;                                     2058    e0 = en0;
2037    x0 = fSplineEnergy[i];                        2059    x0 = fSplineEnergy[i];
2038    x1 = fSplineEnergy[i+1];                      2060    x1 = fSplineEnergy[i+1];
2039    y0 = fdNdxMM[i];                              2061    y0 = fdNdxMM[i];
2040    yy1 = fdNdxMM[i+1];                           2062    yy1 = fdNdxMM[i+1];
2041                                                  2063 
                                                   >> 2064    //  G4cout<<G4endl;
2042    //  G4cout<<"SumBordC, i = "<<i<<"; en0 =     2065    //  G4cout<<"SumBordC, i = "<<i<<"; en0 = "<<en0<<"; x0 ="<<x0<<"; x1 = "<<x1
2043    //     <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G    2066    //     <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
2044    c = x1/x0;                                    2067    c = x1/x0;
2045    d = e0/x0;                                    2068    d = e0/x0;
2046    a = log10(yy1/y0)/log10(c);                   2069    a = log10(yy1/y0)/log10(c);
2047                                               << 2070    if(a > 10.0) return 0.;  
2048    if(a > 20.0) b = 0.0;                      << 2071    // b0 = log10(y0) - a*log10(x0);
2049    else         b = y0/pow(x0,a);             << 2072    b = y0/pow(x0,a); // pow(10.,b0);   
2050                                                  2073    
2051    a += 1.0;                                     2074    a += 1.0;
2052    if( a == 0 ) result = b*log(x0/e0);           2075    if( a == 0 ) result = b*log(x0/e0);
2053    else         result = y0*(x0 - e0*pow(d,a-    2076    else         result = y0*(x0 - e0*pow(d,a-1))/a;   
2054    a += 1.0;                                     2077    a += 1.0;
2055                                                  2078 
2056    if( a == 0 ) fIntegralMM[0] += b*log(x0/e0    2079    if( a == 0 ) fIntegralMM[0] += b*log(x0/e0);
2057    else         fIntegralMM[0] += y0*(x0*x0 -    2080    else         fIntegralMM[0] += y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
2058                                                  2081 
2059    // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b  << 2082 // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b = "<<b<<"; result = "<<result<<G4endl;
2060                                                  2083    
2061    x0  = fSplineEnergy[i - 1];                   2084    x0  = fSplineEnergy[i - 1];
2062    x1  = fSplineEnergy[i - 2];                   2085    x1  = fSplineEnergy[i - 2];
2063    y0  = fdNdxMM[i - 1];                         2086    y0  = fdNdxMM[i - 1];
2064    yy1 = fdNdxMM[i - 2];                         2087    yy1 = fdNdxMM[i - 2];
2065                                                  2088 
2066    // G4cout<<"x0 ="<<x0<<"; x1 = "<<x1          2089    // G4cout<<"x0 ="<<x0<<"; x1 = "<<x1
2067    //    <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4    2090    //    <<"; y0 = "<<y0<<"; yy1 = "<<yy1<<G4endl;
2068                                                  2091 
2069    c = x1/x0;                                    2092    c = x1/x0;
2070    d = e0/x0;                                    2093    d = e0/x0;
2071    a  = log10(yy1/y0)/log10(x1/x0);              2094    a  = log10(yy1/y0)/log10(x1/x0);
2072                                               << 2095    // b0 = log10(y0) - a*log10(x0);
2073    if(a > 20.0) b = 0.0;                      << 2096    b  =  y0/pow(x0,a);  // pow(10.,b0);
2074    else         b = y0/pow(x0,a);             << 
2075                                                  2097 
2076    a += 1.0;                                     2098    a += 1.0;
2077    if( a == 0 ) result += b*log(e0/x0);          2099    if( a == 0 ) result += b*log(e0/x0);
2078    else         result += y0*(e0*pow(d,a-1) -    2100    else         result += y0*(e0*pow(d,a-1) - x0 )/a;
2079    a += 1.0;                                     2101    a += 1.0;
2080                                                  2102 
2081    if( a == 0 ) fIntegralMM[0] += b*log(e0/x0 << 2103    if( a == 0 )   fIntegralMM[0] += b*log(e0/x0);
2082    else         fIntegralMM[0] += y0*(e0*e0*p << 2104    else           fIntegralMM[0] += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
2083                                                  2105 
2084    // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b     2106    // G4cout<<"a = "<<a<<"; b0 = "<<b0<<"; b = "
2085    // <<b<<"; result = "<<result<<G4endl;        2107    // <<b<<"; result = "<<result<<G4endl;    
2086                                                  2108 
2087    return result;                                2109    return result;
2088                                                  2110 
2089 }                                                2111 } 
2090                                                  2112 
2091 /////////////////////////////////////////////    2113 ///////////////////////////////////////////////////////////////////////////////
2092 //                                               2114 //
2093 // Integration of Plasmon cross-section for t    2115 // Integration of Plasmon cross-section for the case of
2094 // passing across border between intervals       2116 // passing across border between intervals
2095                                                  2117 
2096 G4double G4PAIxSection::SumOverBordPlasmon( G    2118 G4double G4PAIxSection::SumOverBordPlasmon( G4int      i , 
2097                                                  2119                                              G4double en0    )
2098 {                                                2120 {               
2099    G4double x0,x1,y0,yy1,a,b,c,d,e0,result;      2121    G4double x0,x1,y0,yy1,a,b,c,d,e0,result;
2100                                                  2122 
2101    e0 = en0;                                     2123    e0 = en0;
2102    x0 = fSplineEnergy[i];                        2124    x0 = fSplineEnergy[i];
2103    x1 = fSplineEnergy[i+1];                      2125    x1 = fSplineEnergy[i+1];
2104    y0 = fdNdxPlasmon[i];                         2126    y0 = fdNdxPlasmon[i];
2105    yy1 = fdNdxPlasmon[i+1];                      2127    yy1 = fdNdxPlasmon[i+1];
2106                                                  2128 
2107    c = x1/x0;                                    2129    c = x1/x0;
2108    d = e0/x0;                                    2130    d = e0/x0;   
2109    a = log10(yy1/y0)/log10(c);                   2131    a = log10(yy1/y0)/log10(c);
2110                                               << 2132    if(a > 10.0) return 0.;  
2111    if(a > 20.0) b = 0.0;                      << 2133    //  b0 = log10(y0) - a*log10(x0);
2112    else         b = y0/pow(x0,a);             << 2134    b = y0/pow(x0,a); //pow(10.,b);
2113                                                  2135    
2114    a += 1.0;                                     2136    a += 1.0;
2115    if( a == 0 ) result = b*log(x0/e0);           2137    if( a == 0 ) result = b*log(x0/e0);
2116    else         result = y0*(x0 - e0*pow(d,a-    2138    else         result = y0*(x0 - e0*pow(d,a-1))/a;   
2117    a += 1.0;                                     2139    a += 1.0;
2118                                                  2140 
2119    if( a == 0 ) fIntegralPlasmon[0] += b*log(    2141    if( a == 0 ) fIntegralPlasmon[0] += b*log(x0/e0);
2120    else         fIntegralPlasmon[0] += y0*(x0    2142    else         fIntegralPlasmon[0] += y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
2121                                                  2143    
2122    x0 = fSplineEnergy[i - 1];                    2144    x0 = fSplineEnergy[i - 1];
2123    x1 = fSplineEnergy[i - 2];                    2145    x1 = fSplineEnergy[i - 2];
2124    y0 = fdNdxPlasmon[i - 1];                     2146    y0 = fdNdxPlasmon[i - 1];
2125    yy1 = fdNdxPlasmon[i - 2];                    2147    yy1 = fdNdxPlasmon[i - 2];
2126                                                  2148 
2127    c = x1/x0;                                    2149    c = x1/x0;
2128    d = e0/x0;                                    2150    d = e0/x0;
2129    a = log10(yy1/y0)/log10(c);                   2151    a = log10(yy1/y0)/log10(c);
2130                                               << 2152    // b0 = log10(y0) - a*log10(x0);
2131    if(a > 20.0) b = 0.0;                      << 2153    b = y0/pow(x0,a);// pow(10.,b0);
2132    else         b = y0/pow(x0,a);             << 
2133                                                  2154 
2134    a += 1.0;                                     2155    a += 1.0;
2135    if( a == 0 ) result += b*log(e0/x0);          2156    if( a == 0 ) result += b*log(e0/x0);
2136    else         result += y0*(e0*pow(d,a-1) -    2157    else         result += y0*(e0*pow(d,a-1) - x0)/a;
2137    a += 1.0;                                     2158    a += 1.0;
2138                                                  2159 
2139    if( a == 0 )   fIntegralPlasmon[0] += b*lo    2160    if( a == 0 )   fIntegralPlasmon[0] += b*log(e0/x0);
2140    else           fIntegralPlasmon[0] += y0*(    2161    else           fIntegralPlasmon[0] += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
2141                                                  2162    
2142    return result;                                2163    return result;
                                                   >> 2164 
2143 }                                                2165 } 
2144                                                  2166 
2145 /////////////////////////////////////////////    2167 ///////////////////////////////////////////////////////////////////////////////
2146 //                                               2168 //
2147 // Integration of resonance cross-section for    2169 // Integration of resonance cross-section for the case of
2148 // passing across border between intervals       2170 // passing across border between intervals
2149                                                  2171 
2150 G4double G4PAIxSection::SumOverBordResonance(    2172 G4double G4PAIxSection::SumOverBordResonance( G4int      i , 
2151                                                  2173                                              G4double en0    )
2152 {                                                2174 {               
2153    G4double x0,x1,y0,yy1,a,b,c,d,e0,result;      2175    G4double x0,x1,y0,yy1,a,b,c,d,e0,result;
2154                                                  2176 
2155    e0 = en0;                                     2177    e0 = en0;
2156    x0 = fSplineEnergy[i];                        2178    x0 = fSplineEnergy[i];
2157    x1 = fSplineEnergy[i+1];                      2179    x1 = fSplineEnergy[i+1];
2158    y0 = fdNdxResonance[i];                       2180    y0 = fdNdxResonance[i];
2159    yy1 = fdNdxResonance[i+1];                    2181    yy1 = fdNdxResonance[i+1];
2160                                                  2182 
2161    c = x1/x0;                                    2183    c = x1/x0;
2162    d = e0/x0;                                    2184    d = e0/x0;   
2163    a = log10(yy1/y0)/log10(c);                   2185    a = log10(yy1/y0)/log10(c);
2164                                               << 2186    if(a > 10.0) return 0.;  
2165    if(a > 20.0) b = 0.0;                      << 2187    //  b0 = log10(y0) - a*log10(x0);
2166    else         b = y0/pow(x0,a);             << 2188    b = y0/pow(x0,a); //pow(10.,b);
2167                                                  2189    
2168    a += 1.0;                                     2190    a += 1.0;
2169    if( a == 0 ) result = b*log(x0/e0);           2191    if( a == 0 ) result = b*log(x0/e0);
2170    else         result = y0*(x0 - e0*pow(d,a-    2192    else         result = y0*(x0 - e0*pow(d,a-1))/a;   
2171    a += 1.0;                                     2193    a += 1.0;
2172                                                  2194 
2173    if( a == 0 ) fIntegralResonance[0] += b*lo    2195    if( a == 0 ) fIntegralResonance[0] += b*log(x0/e0);
2174    else         fIntegralResonance[0] += y0*(    2196    else         fIntegralResonance[0] += y0*(x0*x0 - e0*e0*pow(d,a-2))/a;
2175                                                  2197    
2176    x0 = fSplineEnergy[i - 1];                    2198    x0 = fSplineEnergy[i - 1];
2177    x1 = fSplineEnergy[i - 2];                    2199    x1 = fSplineEnergy[i - 2];
2178    y0 = fdNdxResonance[i - 1];                   2200    y0 = fdNdxResonance[i - 1];
2179    yy1 = fdNdxResonance[i - 2];                  2201    yy1 = fdNdxResonance[i - 2];
2180                                                  2202 
2181    c = x1/x0;                                    2203    c = x1/x0;
2182    d = e0/x0;                                    2204    d = e0/x0;
2183    a = log10(yy1/y0)/log10(c);                   2205    a = log10(yy1/y0)/log10(c);
2184                                               << 2206    // b0 = log10(y0) - a*log10(x0);
2185    if(a > 20.0) b = 0.0;                      << 2207    b = y0/pow(x0,a);// pow(10.,b0);
2186    else         b = y0/pow(x0,a);             << 
2187                                                  2208 
2188    a += 1.0;                                     2209    a += 1.0;
2189    if( a == 0 ) result += b*log(e0/x0);          2210    if( a == 0 ) result += b*log(e0/x0);
2190    else         result += y0*(e0*pow(d,a-1) -    2211    else         result += y0*(e0*pow(d,a-1) - x0)/a;
2191    a += 1.0;                                     2212    a += 1.0;
2192                                                  2213 
2193    if( a == 0 ) fIntegralResonance[0] += b*lo << 2214    if( a == 0 )   fIntegralResonance[0] += b*log(e0/x0);
2194    else         fIntegralResonance[0] += y0*( << 2215    else           fIntegralResonance[0] += y0*(e0*e0*pow(d,a-2) - x0*x0)/a;
2195                                                  2216    
2196    return result;                                2217    return result;
2197                                                  2218 
2198 }                                                2219 } 
2199                                                  2220 
2200 /////////////////////////////////////////////    2221 /////////////////////////////////////////////////////////////////////////
2201 //                                               2222 //
2202 // Returns random PAI-total energy loss over     2223 // Returns random PAI-total energy loss over step
2203                                                  2224 
2204 G4double G4PAIxSection::GetStepEnergyLoss( G4    2225 G4double G4PAIxSection::GetStepEnergyLoss( G4double step )
2205 {                                                2226 {  
2206   G4long numOfCollisions;                        2227   G4long numOfCollisions;
2207   G4double meanNumber, loss = 0.0;               2228   G4double meanNumber, loss = 0.0;
2208                                                  2229 
2209   // G4cout<<" G4PAIxSection::GetStepEnergyLo    2230   // G4cout<<" G4PAIxSection::GetStepEnergyLoss "<<G4endl;
2210                                                  2231 
2211   meanNumber = fIntegralPAIxSection[1]*step;     2232   meanNumber = fIntegralPAIxSection[1]*step;
2212   numOfCollisions = G4Poisson(meanNumber);       2233   numOfCollisions = G4Poisson(meanNumber);
2213                                                  2234 
2214   // G4cout<<"numOfCollisions = "<<numOfColli << 2235   //   G4cout<<"numOfCollisions = "<<numOfCollisions<<G4endl;
2215                                                  2236 
2216   while(numOfCollisions)                         2237   while(numOfCollisions)
2217   {                                              2238   {
2218     loss += GetEnergyTransfer();              << 2239    loss += GetEnergyTransfer();
2219     numOfCollisions--;                        << 2240    numOfCollisions--;
2220     // Loop checking, 03-Aug-2015, Vladimir I << 
2221   }                                              2241   }
2222   // G4cout<<"PAI energy loss = "<<loss/keV<<    2242   // G4cout<<"PAI energy loss = "<<loss/keV<<" keV"<<G4endl; 
2223                                                  2243 
2224   return loss;                                   2244   return loss;
2225 }                                                2245 }
2226                                                  2246 
2227 /////////////////////////////////////////////    2247 /////////////////////////////////////////////////////////////////////////
2228 //                                               2248 //
2229 // Returns random PAI-total energy transfer i    2249 // Returns random PAI-total energy transfer in one collision
2230                                                  2250 
2231 G4double G4PAIxSection::GetEnergyTransfer()      2251 G4double G4PAIxSection::GetEnergyTransfer()
2232 {                                                2252 {  
2233   G4int iTransfer ;                              2253   G4int iTransfer ;
2234                                                  2254 
2235   G4double energyTransfer, position;             2255   G4double energyTransfer, position;
2236                                                  2256 
2237   position = fIntegralPAIxSection[1]*G4Unifor    2257   position = fIntegralPAIxSection[1]*G4UniformRand();
2238                                                  2258 
2239   for( iTransfer = 1; iTransfer <= fSplineNum    2259   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2240   {                                              2260   {
2241     if( position >= fIntegralPAIxSection[iTra << 2261         if( position >= fIntegralPAIxSection[iTransfer] ) break;
2242   }                                              2262   }
2243   if(iTransfer > fSplineNumber) iTransfer--;     2263   if(iTransfer > fSplineNumber) iTransfer--;
2244                                                  2264  
2245   energyTransfer = fSplineEnergy[iTransfer];     2265   energyTransfer = fSplineEnergy[iTransfer];
2246                                                  2266 
2247   if(iTransfer > 1)                              2267   if(iTransfer > 1)
2248   {                                              2268   {
2249     energyTransfer -= (fSplineEnergy[iTransfe    2269     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2250   }                                              2270   }
2251   return energyTransfer;                         2271   return energyTransfer;
2252 }                                                2272 }
2253                                                  2273 
2254 /////////////////////////////////////////////    2274 /////////////////////////////////////////////////////////////////////////
2255 //                                               2275 //
2256 // Returns random Cerenkov energy loss over s    2276 // Returns random Cerenkov energy loss over step
2257                                                  2277 
2258 G4double G4PAIxSection::GetStepCerenkovLoss(     2278 G4double G4PAIxSection::GetStepCerenkovLoss( G4double step )
2259 {                                                2279 {  
2260   G4long numOfCollisions;                        2280   G4long numOfCollisions;
2261   G4double meanNumber, loss = 0.0;               2281   G4double meanNumber, loss = 0.0;
2262                                                  2282 
2263   // G4cout<<" G4PAIxSection::GetStepCerenkov    2283   // G4cout<<" G4PAIxSection::GetStepCerenkovLoss "<<G4endl;
2264                                                  2284 
2265   meanNumber = fIntegralCerenkov[1]*step;        2285   meanNumber = fIntegralCerenkov[1]*step;
2266   numOfCollisions = G4Poisson(meanNumber);       2286   numOfCollisions = G4Poisson(meanNumber);
2267                                                  2287 
2268   //   G4cout<<"numOfCollisions = "<<numOfCol    2288   //   G4cout<<"numOfCollisions = "<<numOfCollisions<<G4endl;
2269                                                  2289 
2270   while(numOfCollisions)                         2290   while(numOfCollisions)
2271   {                                              2291   {
2272     loss += GetCerenkovEnergyTransfer();         2292     loss += GetCerenkovEnergyTransfer();
2273     numOfCollisions--;                           2293     numOfCollisions--;
2274     // Loop checking, 03-Aug-2015, Vladimir I << 
2275   }                                              2294   }
2276   // G4cout<<"PAI Cerenkov loss = "<<loss/keV    2295   // G4cout<<"PAI Cerenkov loss = "<<loss/keV<<" keV"<<G4endl; 
2277                                                  2296 
2278   return loss;                                   2297   return loss;
2279 }                                                2298 }
2280                                                  2299 
2281 /////////////////////////////////////////////    2300 /////////////////////////////////////////////////////////////////////////
2282 //                                               2301 //
2283 // Returns random MM-Cerenkov energy loss ove    2302 // Returns random MM-Cerenkov energy loss over step
2284                                                  2303 
2285 G4double G4PAIxSection::GetStepMMLoss( G4doub    2304 G4double G4PAIxSection::GetStepMMLoss( G4double step )
2286 {                                                2305 {  
2287   G4long numOfCollisions;                        2306   G4long numOfCollisions;
2288   G4double meanNumber, loss = 0.0;               2307   G4double meanNumber, loss = 0.0;
2289                                                  2308 
2290   // G4cout<<" G4PAIxSection::GetStepMMLoss "    2309   // G4cout<<" G4PAIxSection::GetStepMMLoss "<<G4endl;
2291                                                  2310 
2292   meanNumber = fIntegralMM[1]*step;              2311   meanNumber = fIntegralMM[1]*step;
2293   numOfCollisions = G4Poisson(meanNumber);       2312   numOfCollisions = G4Poisson(meanNumber);
2294                                                  2313 
2295   //   G4cout<<"numOfCollisions = "<<numOfCol    2314   //   G4cout<<"numOfCollisions = "<<numOfCollisions<<G4endl;
2296                                                  2315 
2297   while(numOfCollisions)                         2316   while(numOfCollisions)
2298   {                                              2317   {
2299     loss += GetMMEnergyTransfer();               2318     loss += GetMMEnergyTransfer();
2300     numOfCollisions--;                           2319     numOfCollisions--;
2301     // Loop checking, 03-Aug-2015, Vladimir I << 
2302   }                                              2320   }
2303   // G4cout<<"PAI MM-Cerenkov loss = "<<loss/    2321   // G4cout<<"PAI MM-Cerenkov loss = "<<loss/keV<<" keV"<<G4endl; 
2304                                                  2322 
2305   return loss;                                   2323   return loss;
2306 }                                                2324 }
2307                                                  2325 
2308 /////////////////////////////////////////////    2326 /////////////////////////////////////////////////////////////////////////
2309 //                                               2327 //
2310 // Returns Cerenkov energy transfer in one co    2328 // Returns Cerenkov energy transfer in one collision
2311                                                  2329 
2312 G4double G4PAIxSection::GetCerenkovEnergyTran    2330 G4double G4PAIxSection::GetCerenkovEnergyTransfer()
2313 {                                                2331 {  
2314   G4int iTransfer ;                              2332   G4int iTransfer ;
2315                                                  2333 
2316   G4double energyTransfer, position;             2334   G4double energyTransfer, position;
2317                                                  2335 
2318   position = fIntegralCerenkov[1]*G4UniformRa    2336   position = fIntegralCerenkov[1]*G4UniformRand();
2319                                                  2337 
2320   for( iTransfer = 1; iTransfer <= fSplineNum    2338   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2321   {                                              2339   {
2322         if( position >= fIntegralCerenkov[iTr    2340         if( position >= fIntegralCerenkov[iTransfer] ) break;
2323   }                                              2341   }
2324   if(iTransfer > fSplineNumber) iTransfer--;     2342   if(iTransfer > fSplineNumber) iTransfer--;
2325                                                  2343  
2326   energyTransfer = fSplineEnergy[iTransfer];     2344   energyTransfer = fSplineEnergy[iTransfer];
2327                                                  2345 
2328   if(iTransfer > 1)                              2346   if(iTransfer > 1)
2329   {                                              2347   {
2330     energyTransfer -= (fSplineEnergy[iTransfe    2348     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2331   }                                              2349   }
2332   return energyTransfer;                         2350   return energyTransfer;
2333 }                                                2351 }
2334                                                  2352 
2335 /////////////////////////////////////////////    2353 /////////////////////////////////////////////////////////////////////////
2336 //                                               2354 //
2337 // Returns MM-Cerenkov energy transfer in one    2355 // Returns MM-Cerenkov energy transfer in one collision
2338                                                  2356 
2339 G4double G4PAIxSection::GetMMEnergyTransfer()    2357 G4double G4PAIxSection::GetMMEnergyTransfer()
2340 {                                                2358 {  
2341   G4int iTransfer ;                              2359   G4int iTransfer ;
2342                                                  2360 
2343   G4double energyTransfer, position;             2361   G4double energyTransfer, position;
2344                                                  2362 
2345   position = fIntegralMM[1]*G4UniformRand();     2363   position = fIntegralMM[1]*G4UniformRand();
2346                                                  2364 
2347   for( iTransfer = 1; iTransfer <= fSplineNum    2365   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2348   {                                              2366   {
2349     if( position >= fIntegralMM[iTransfer] )  << 2367         if( position >= fIntegralMM[iTransfer] ) break;
2350   }                                              2368   }
2351   if(iTransfer > fSplineNumber) iTransfer--;     2369   if(iTransfer > fSplineNumber) iTransfer--;
2352                                                  2370  
2353   energyTransfer = fSplineEnergy[iTransfer];     2371   energyTransfer = fSplineEnergy[iTransfer];
2354                                                  2372 
2355   if(iTransfer > 1)                              2373   if(iTransfer > 1)
2356   {                                              2374   {
2357     energyTransfer -= (fSplineEnergy[iTransfe    2375     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2358   }                                              2376   }
2359   return energyTransfer;                         2377   return energyTransfer;
2360 }                                                2378 }
2361                                                  2379 
2362 /////////////////////////////////////////////    2380 /////////////////////////////////////////////////////////////////////////
2363 //                                               2381 //
2364 // Returns random plasmon energy loss over st    2382 // Returns random plasmon energy loss over step
2365                                                  2383 
2366 G4double G4PAIxSection::GetStepPlasmonLoss( G    2384 G4double G4PAIxSection::GetStepPlasmonLoss( G4double step )
2367 {                                                2385 {  
2368   G4long numOfCollisions;                        2386   G4long numOfCollisions;
2369   G4double  meanNumber, loss = 0.0;              2387   G4double  meanNumber, loss = 0.0;
2370                                                  2388 
2371   // G4cout<<" G4PAIxSection::GetStepPlasmonL    2389   // G4cout<<" G4PAIxSection::GetStepPlasmonLoss "<<G4endl;
2372                                                  2390 
2373   meanNumber = fIntegralPlasmon[1]*step;         2391   meanNumber = fIntegralPlasmon[1]*step;
2374   numOfCollisions = G4Poisson(meanNumber);       2392   numOfCollisions = G4Poisson(meanNumber);
2375                                                  2393 
2376   //   G4cout<<"numOfCollisions = "<<numOfCol    2394   //   G4cout<<"numOfCollisions = "<<numOfCollisions<<G4endl;
2377                                                  2395 
2378   while(numOfCollisions)                         2396   while(numOfCollisions)
2379   {                                              2397   {
2380     loss += GetPlasmonEnergyTransfer();          2398     loss += GetPlasmonEnergyTransfer();
2381     numOfCollisions--;                           2399     numOfCollisions--;
2382     // Loop checking, 03-Aug-2015, Vladimir I << 
2383   }                                              2400   }
2384   // G4cout<<"PAI Plasmon loss = "<<loss/keV<    2401   // G4cout<<"PAI Plasmon loss = "<<loss/keV<<" keV"<<G4endl; 
2385                                                  2402 
2386   return loss;                                   2403   return loss;
2387 }                                                2404 }
2388                                                  2405 
2389 /////////////////////////////////////////////    2406 /////////////////////////////////////////////////////////////////////////
2390 //                                               2407 //
2391 // Returns plasmon energy transfer in one col    2408 // Returns plasmon energy transfer in one collision
2392                                                  2409 
2393 G4double G4PAIxSection::GetPlasmonEnergyTrans    2410 G4double G4PAIxSection::GetPlasmonEnergyTransfer()
2394 {                                                2411 {  
2395   G4int iTransfer ;                              2412   G4int iTransfer ;
2396                                                  2413 
2397   G4double energyTransfer, position;             2414   G4double energyTransfer, position;
2398                                                  2415 
2399   position = fIntegralPlasmon[1]*G4UniformRan    2416   position = fIntegralPlasmon[1]*G4UniformRand();
2400                                                  2417 
2401   for( iTransfer = 1; iTransfer <= fSplineNum    2418   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2402   {                                              2419   {
2403     if( position >= fIntegralPlasmon[iTransfe << 2420         if( position >= fIntegralPlasmon[iTransfer] ) break;
2404   }                                              2421   }
2405   if(iTransfer > fSplineNumber) iTransfer--;     2422   if(iTransfer > fSplineNumber) iTransfer--;
2406                                                  2423  
2407   energyTransfer = fSplineEnergy[iTransfer];     2424   energyTransfer = fSplineEnergy[iTransfer];
2408                                                  2425 
2409   if(iTransfer > 1)                              2426   if(iTransfer > 1)
2410   {                                              2427   {
2411     energyTransfer -= (fSplineEnergy[iTransfe    2428     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2412   }                                              2429   }
2413   return energyTransfer;                         2430   return energyTransfer;
2414 }                                                2431 }
2415                                                  2432 
2416 /////////////////////////////////////////////    2433 /////////////////////////////////////////////////////////////////////////
2417 //                                               2434 //
2418 // Returns random resonance energy loss over     2435 // Returns random resonance energy loss over step
2419                                                  2436 
2420 G4double G4PAIxSection::GetStepResonanceLoss(    2437 G4double G4PAIxSection::GetStepResonanceLoss( G4double step )
2421 {                                                2438 {  
2422   G4long numOfCollisions;                        2439   G4long numOfCollisions;
2423   G4double meanNumber, loss = 0.0;               2440   G4double meanNumber, loss = 0.0;
2424                                                  2441 
2425   // G4cout<<" G4PAIxSection::GetStepCreLosnk    2442   // G4cout<<" G4PAIxSection::GetStepCreLosnkovs "<<G4endl;
2426                                                  2443 
2427   meanNumber = fIntegralResonance[1]*step;       2444   meanNumber = fIntegralResonance[1]*step;
2428   numOfCollisions = G4Poisson(meanNumber);       2445   numOfCollisions = G4Poisson(meanNumber);
2429                                                  2446 
2430   //   G4cout<<"numOfCollisions = "<<numOfCol    2447   //   G4cout<<"numOfCollisions = "<<numOfCollisions<<G4endl;
2431                                                  2448 
2432   while(numOfCollisions)                         2449   while(numOfCollisions)
2433   {                                              2450   {
2434     loss += GetResonanceEnergyTransfer();        2451     loss += GetResonanceEnergyTransfer();
2435     numOfCollisions--;                           2452     numOfCollisions--;
2436     // Loop checking, 03-Aug-2015, Vladimir I << 
2437   }                                              2453   }
2438   // G4cout<<"PAI resonance loss = "<<loss/ke    2454   // G4cout<<"PAI resonance loss = "<<loss/keV<<" keV"<<G4endl; 
2439                                                  2455 
2440   return loss;                                   2456   return loss;
2441 }                                                2457 }
2442                                                  2458 
2443                                                  2459 
2444 /////////////////////////////////////////////    2460 /////////////////////////////////////////////////////////////////////////
2445 //                                               2461 //
2446 // Returns resonance energy transfer in one c    2462 // Returns resonance energy transfer in one collision
2447                                                  2463 
2448 G4double G4PAIxSection::GetResonanceEnergyTra    2464 G4double G4PAIxSection::GetResonanceEnergyTransfer()
2449 {                                                2465 {  
2450   G4int iTransfer ;                              2466   G4int iTransfer ;
2451                                                  2467 
2452   G4double energyTransfer, position;             2468   G4double energyTransfer, position;
2453                                                  2469 
2454   position = fIntegralResonance[1]*G4UniformR    2470   position = fIntegralResonance[1]*G4UniformRand();
2455                                                  2471 
2456   for( iTransfer = 1; iTransfer <= fSplineNum    2472   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2457   {                                              2473   {
2458     if( position >= fIntegralResonance[iTrans << 2474         if( position >= fIntegralResonance[iTransfer] ) break;
2459   }                                              2475   }
2460   if(iTransfer > fSplineNumber) iTransfer--;     2476   if(iTransfer > fSplineNumber) iTransfer--;
2461                                                  2477  
2462   energyTransfer = fSplineEnergy[iTransfer];     2478   energyTransfer = fSplineEnergy[iTransfer];
2463                                                  2479 
2464   if(iTransfer > 1)                              2480   if(iTransfer > 1)
2465   {                                              2481   {
2466     energyTransfer -= (fSplineEnergy[iTransfe    2482     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2467   }                                              2483   }
2468   return energyTransfer;                         2484   return energyTransfer;
2469 }                                                2485 }
2470                                                  2486 
2471                                                  2487 
2472 /////////////////////////////////////////////    2488 /////////////////////////////////////////////////////////////////////////
2473 //                                               2489 //
2474 // Returns Rutherford energy transfer in one     2490 // Returns Rutherford energy transfer in one collision
2475                                                  2491 
2476 G4double G4PAIxSection::GetRutherfordEnergyTr    2492 G4double G4PAIxSection::GetRutherfordEnergyTransfer()
2477 {                                                2493 {  
2478   G4int iTransfer ;                              2494   G4int iTransfer ;
2479                                                  2495 
2480   G4double energyTransfer, position;             2496   G4double energyTransfer, position;
2481                                                  2497 
2482   position = (fIntegralPlasmon[1]-fIntegralRe    2498   position = (fIntegralPlasmon[1]-fIntegralResonance[1])*G4UniformRand();
2483                                                  2499 
2484   for( iTransfer = 1; iTransfer <= fSplineNum    2500   for( iTransfer = 1; iTransfer <= fSplineNumber; iTransfer++ )
2485   {                                              2501   {
2486     if( position >= (fIntegralPlasmon[iTransf << 2502         if( position >= (fIntegralPlasmon[iTransfer]-fIntegralResonance[iTransfer]) ) break;
2487   }                                              2503   }
2488   if(iTransfer > fSplineNumber) iTransfer--;     2504   if(iTransfer > fSplineNumber) iTransfer--;
2489                                                  2505  
2490   energyTransfer = fSplineEnergy[iTransfer];     2506   energyTransfer = fSplineEnergy[iTransfer];
2491                                                  2507 
2492   if(iTransfer > 1)                              2508   if(iTransfer > 1)
2493   {                                              2509   {
2494     energyTransfer -= (fSplineEnergy[iTransfe    2510     energyTransfer -= (fSplineEnergy[iTransfer]-fSplineEnergy[iTransfer-1])*G4UniformRand();
2495   }                                              2511   }
2496   return energyTransfer;                         2512   return energyTransfer;
2497 }                                                2513 }
2498                                                  2514 
2499 /////////////////////////////////////////////    2515 /////////////////////////////////////////////////////////////////////////////
2500 //                                               2516 //
2501                                                  2517 
2502 void G4PAIxSection::CallError(G4int i, const     2518 void G4PAIxSection::CallError(G4int i, const G4String& methodName) const
2503 {                                                2519 {
2504   G4String head = "G4PAIxSection::" + methodN    2520   G4String head = "G4PAIxSection::" + methodName + "()";
2505   G4ExceptionDescription ed;                     2521   G4ExceptionDescription ed;
2506   ed << "Wrong index " << i << " fSplineNumbe    2522   ed << "Wrong index " << i << " fSplineNumber= " << fSplineNumber;
2507   G4Exception(head,"pai001",FatalException,ed    2523   G4Exception(head,"pai001",FatalException,ed);
2508 }                                                2524 }
2509                                                  2525 
2510 /////////////////////////////////////////////    2526 /////////////////////////////////////////////////////////////////////////////
2511 //                                               2527 //
2512 // Init  array of Lorentz factors                2528 // Init  array of Lorentz factors
2513 //                                               2529 //
2514                                                  2530 
2515 G4int G4PAIxSection::fNumberOfGammas = 111;      2531 G4int G4PAIxSection::fNumberOfGammas = 111;
2516                                                  2532 
2517 const G4double G4PAIxSection::fLorentzFactor[    2533 const G4double G4PAIxSection::fLorentzFactor[112] =     // fNumberOfGammas+1
2518 {                                                2534 {
2519 0.0,                                             2535 0.0,
2520 1.094989e+00, 1.107813e+00, 1.122369e+00, 1.1    2536 1.094989e+00, 1.107813e+00, 1.122369e+00, 1.138890e+00, 1.157642e+00,
2521 1.178925e+00, 1.203082e+00, 1.230500e+00, 1.2    2537 1.178925e+00, 1.203082e+00, 1.230500e+00, 1.261620e+00, 1.296942e+00, // 10
2522 1.337032e+00, 1.382535e+00, 1.434181e+00, 1.4    2538 1.337032e+00, 1.382535e+00, 1.434181e+00, 1.492800e+00, 1.559334e+00,
2523 1.634850e+00, 1.720562e+00, 1.817845e+00, 1.9    2539 1.634850e+00, 1.720562e+00, 1.817845e+00, 1.928263e+00, 2.053589e+00, // 20
2524 2.195835e+00, 2.357285e+00, 2.540533e+00, 2.7    2540 2.195835e+00, 2.357285e+00, 2.540533e+00, 2.748522e+00, 2.984591e+00,
2525 3.252533e+00, 3.556649e+00, 3.901824e+00, 4.2    2541 3.252533e+00, 3.556649e+00, 3.901824e+00, 4.293602e+00, 4.738274e+00, // 30
2526 5.242981e+00, 5.815829e+00, 6.466019e+00, 7.2    2542 5.242981e+00, 5.815829e+00, 6.466019e+00, 7.203990e+00, 8.041596e+00,
2527 8.992288e+00, 1.007133e+01, 1.129606e+01, 1.2    2543 8.992288e+00, 1.007133e+01, 1.129606e+01, 1.268614e+01, 1.426390e+01, // 40
2528 1.605467e+01, 1.808721e+01, 2.039417e+01, 2.3    2544 1.605467e+01, 1.808721e+01, 2.039417e+01, 2.301259e+01, 2.598453e+01,
2529 2.935771e+01, 3.318630e+01, 3.753180e+01, 4.2    2545 2.935771e+01, 3.318630e+01, 3.753180e+01, 4.246399e+01, 4.806208e+01, // 50
2530 5.441597e+01, 6.162770e+01, 6.981310e+01, 7.9    2546 5.441597e+01, 6.162770e+01, 6.981310e+01, 7.910361e+01, 8.964844e+01,
2531 1.016169e+02, 1.152013e+02, 1.306197e+02, 1.4    2547 1.016169e+02, 1.152013e+02, 1.306197e+02, 1.481198e+02, 1.679826e+02, // 60
2532 1.905270e+02, 2.161152e+02, 2.451581e+02, 2.7    2548 1.905270e+02, 2.161152e+02, 2.451581e+02, 2.781221e+02, 3.155365e+02,
2533 3.580024e+02, 4.062016e+02, 4.609081e+02, 5.2    2549 3.580024e+02, 4.062016e+02, 4.609081e+02, 5.230007e+02, 5.934765e+02, // 70
2534 6.734672e+02, 7.642575e+02, 8.673056e+02, 9.8    2550 6.734672e+02, 7.642575e+02, 8.673056e+02, 9.842662e+02, 1.117018e+03,
2535 1.267692e+03, 1.438709e+03, 1.632816e+03, 1.8    2551 1.267692e+03, 1.438709e+03, 1.632816e+03, 1.853128e+03, 2.103186e+03, // 80
2536 2.387004e+03, 2.709140e+03, 3.074768e+03, 3.4    2552 2.387004e+03, 2.709140e+03, 3.074768e+03, 3.489760e+03, 3.960780e+03,
2537 4.495394e+03, 5.102185e+03, 5.790900e+03, 6.5    2553 4.495394e+03, 5.102185e+03, 5.790900e+03, 6.572600e+03, 7.459837e+03, // 90
2538 8.466860e+03, 9.609843e+03, 1.090714e+04, 1.2    2554 8.466860e+03, 9.609843e+03, 1.090714e+04, 1.237959e+04, 1.405083e+04,
2539 1.594771e+04, 1.810069e+04, 2.054434e+04, 2.3    2555 1.594771e+04, 1.810069e+04, 2.054434e+04, 2.331792e+04, 2.646595e+04, // 100
2540 3.003901e+04, 3.409446e+04, 3.869745e+04, 4.3    2556 3.003901e+04, 3.409446e+04, 3.869745e+04, 4.392189e+04, 4.985168e+04,
2541 5.658206e+04, 6.422112e+04, 7.289153e+04, 8.2    2557 5.658206e+04, 6.422112e+04, 7.289153e+04, 8.273254e+04, 9.390219e+04, // 110
2542 1.065799e+05                                     2558 1.065799e+05
2543 };                                               2559 };
2544                                                  2560 
2545 /////////////////////////////////////////////    2561 ///////////////////////////////////////////////////////////////////////
2546 //                                               2562 //
2547 // The number of gamma for creation of  splin    2563 // The number of gamma for creation of  spline (near ion-min , G ~ 4 )
2548 //                                               2564 //
2549                                                  2565 
2550 const                                            2566 const
2551 G4int G4PAIxSection::fRefGammaNumber = 29;       2567 G4int G4PAIxSection::fRefGammaNumber = 29; 
2552                                                  2568 
2553                                                  2569    
2554 //                                               2570 //   
2555 // end of G4PAIxSection implementation file      2571 // end of G4PAIxSection implementation file 
2556 //                                               2572 //
2557 /////////////////////////////////////////////    2573 ////////////////////////////////////////////////////////////////////////////
2558                                                  2574 
2559                                                  2575