Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4EmCalculator.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/utils/src/G4EmCalculator.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4EmCalculator.cc (Version 9.6.p4)


  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 // $Id$
 26 //                                                 27 //
 27 // -------------------------------------------     28 // -------------------------------------------------------------------
 28 //                                                 29 //
 29 // GEANT4 Class file                               30 // GEANT4 Class file
 30 //                                                 31 //
 31 //                                                 32 //
 32 // File name:     G4EmCalculator                   33 // File name:     G4EmCalculator
 33 //                                                 34 //
 34 // Author:        Vladimir Ivanchenko              35 // Author:        Vladimir Ivanchenko
 35 //                                                 36 //
 36 // Creation date: 28.06.2004                       37 // Creation date: 28.06.2004
 37 //                                                 38 //
                                                   >>  39 // Modifications:
                                                   >>  40 // 12.09.2004 Add verbosity (V.Ivanchenko)
                                                   >>  41 // 17.11.2004 Change signature of methods, add new methods (V.Ivanchenko)
                                                   >>  42 // 08.04.2005 Major optimisation of internal interfaces (V.Ivantchenko)
                                                   >>  43 // 08.05.2005 Use updated interfaces (V.Ivantchenko)
                                                   >>  44 // 23.10.2005 Fix computations for ions (V.Ivantchenko)
                                                   >>  45 // 11.01.2006 Add GetCSDARange (V.Ivantchenko)
                                                   >>  46 // 26.01.2006 Rename GetRange -> GetRangeFromRestricteDEDX (V.Ivanchenko)
                                                   >>  47 // 14.03.2006 correction in GetCrossSectionPerVolume (mma)
                                                   >>  48 //            suppress GetCrossSectionPerAtom
                                                   >>  49 //            elm->GetA() in ComputeCrossSectionPerAtom
                                                   >>  50 // 22.03.2006 Add ComputeElectronicDEDX and ComputeTotalDEDX (V.Ivanchenko)
                                                   >>  51 // 13.05.2006 Add Corrections for ion stopping (V.Ivanchenko)
                                                   >>  52 // 29.09.2006 Uncomment computation of smoothing factor (V.Ivanchenko)
                                                   >>  53 // 27.10.2006 Change test energy to access lowEnergy model from 
                                                   >>  54 //            10 keV to 1 keV (V. Ivanchenko)
                                                   >>  55 // 15.03.2007 Add ComputeEnergyCutFromRangeCut methods (V.Ivanchenko)
                                                   >>  56 // 21.04.2008 Updated computations for ions (V.Ivanchenko)
 38 //                                                 57 //
 39 // Class Description: V.Ivanchenko & M.Novak   <<  58 // Class Description:
 40 //                                                 59 //
 41 // -------------------------------------------     60 // -------------------------------------------------------------------
 42 //                                                 61 //
 43 //....oooOO0OOooo........oooOO0OOooo........oo     62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 44 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 45                                                    64 
 46 #include "G4EmCalculator.hh"                       65 #include "G4EmCalculator.hh"
 47 #include "G4SystemOfUnits.hh"                      66 #include "G4SystemOfUnits.hh"
 48 #include "G4LossTableManager.hh"                   67 #include "G4LossTableManager.hh"
 49 #include "G4EmParameters.hh"                   << 
 50 #include "G4NistManager.hh"                    << 
 51 #include "G4DynamicParticle.hh"                << 
 52 #include "G4VEmProcess.hh"                         68 #include "G4VEmProcess.hh"
 53 #include "G4VEnergyLossProcess.hh"                 69 #include "G4VEnergyLossProcess.hh"
 54 #include "G4VMultipleScattering.hh"                70 #include "G4VMultipleScattering.hh"
 55 #include "G4Material.hh"                           71 #include "G4Material.hh"
 56 #include "G4MaterialCutsCouple.hh"                 72 #include "G4MaterialCutsCouple.hh"
 57 #include "G4ParticleDefinition.hh"                 73 #include "G4ParticleDefinition.hh"
 58 #include "G4ParticleTable.hh"                      74 #include "G4ParticleTable.hh"
 59 #include "G4IonTable.hh"                       << 
 60 #include "G4PhysicsTable.hh"                       75 #include "G4PhysicsTable.hh"
 61 #include "G4ProductionCutsTable.hh"                76 #include "G4ProductionCutsTable.hh"
 62 #include "G4ProcessManager.hh"                     77 #include "G4ProcessManager.hh"
 63 #include "G4ionEffectiveCharge.hh"                 78 #include "G4ionEffectiveCharge.hh"
 64 #include "G4RegionStore.hh"                        79 #include "G4RegionStore.hh"
 65 #include "G4Element.hh"                            80 #include "G4Element.hh"
 66 #include "G4EmCorrections.hh"                      81 #include "G4EmCorrections.hh"
 67 #include "G4GenericIon.hh"                         82 #include "G4GenericIon.hh"
 68 #include "G4ProcessVector.hh"                      83 #include "G4ProcessVector.hh"
 69 #include "G4Gamma.hh"                              84 #include "G4Gamma.hh"
 70 #include "G4Electron.hh"                       << 
 71 #include "G4Positron.hh"                       << 
 72 #include "G4EmUtility.hh"                      << 
 73                                                    85 
 74 //....oooOO0OOooo........oooOO0OOooo........oo     86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 75                                                    87 
 76 G4EmCalculator::G4EmCalculator()                   88 G4EmCalculator::G4EmCalculator()
 77 {                                                  89 {
 78   manager = G4LossTableManager::Instance();        90   manager = G4LossTableManager::Instance();
 79   nist    = G4NistManager::Instance();         << 
 80   theParameters = G4EmParameters::Instance();  << 
 81   corr    = manager->EmCorrections();              91   corr    = manager->EmCorrections();
 82   cutenergy[0] = cutenergy[1] = cutenergy[2] = <<  92   nLocalMaterials    = 0;
 83   theGenericIon = G4GenericIon::GenericIon();  <<  93   verbose            = 0;
 84   ionEffCharge  = new G4ionEffectiveCharge();  <<  94   currentCoupleIndex = 0;
 85   dynParticle   = new G4DynamicParticle();     <<  95   currentCouple      = 0;
 86   ionTable      = G4ParticleTable::GetParticle <<  96   currentMaterial    = 0;
                                                   >>  97   currentParticle    = 0;
                                                   >>  98   lambdaParticle     = 0;
                                                   >>  99   baseParticle       = 0;
                                                   >> 100   currentLambda      = 0;
                                                   >> 101   currentModel       = 0;
                                                   >> 102   currentProcess     = 0;
                                                   >> 103   loweModel          = 0;
                                                   >> 104   chargeSquare       = 1.0;
                                                   >> 105   massRatio          = 1.0;
                                                   >> 106   mass               = 0.0;
                                                   >> 107   currentCut         = 0.0;
                                                   >> 108   currentParticleName= "";
                                                   >> 109   currentMaterialName= "";
                                                   >> 110   currentName        = "";
                                                   >> 111   lambdaName         = "";
                                                   >> 112   theGenericIon      = G4GenericIon::GenericIon();
                                                   >> 113   ionEffCharge       = new G4ionEffectiveCharge();
                                                   >> 114   isIon              = false;
                                                   >> 115   isApplicable       = false;
 87 }                                                 116 }
 88                                                   117 
 89 //....oooOO0OOooo........oooOO0OOooo........oo    118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 90                                                   119 
 91 G4EmCalculator::~G4EmCalculator()                 120 G4EmCalculator::~G4EmCalculator()
 92 {                                                 121 {
 93   delete ionEffCharge;                            122   delete ionEffCharge;
 94   delete dynParticle;                          << 
 95   for (G4int i=0; i<nLocalMaterials; ++i) {       123   for (G4int i=0; i<nLocalMaterials; ++i) {
 96     delete localCouples[i];                       124     delete localCouples[i];
 97   }                                               125   }
 98 }                                                 126 }
 99                                                   127 
100 //....oooOO0OOooo........oooOO0OOooo........oo    128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
101                                                   129 
102 G4double G4EmCalculator::GetDEDX(G4double kinE << 130 G4double G4EmCalculator::GetDEDX(G4double kinEnergy, const G4ParticleDefinition* p,
103                                  const G4Parti << 131                                  const G4Material* mat, const G4Region* region)
104                                  const G4Mater << 
105                                  const G4Regio << 
106 {                                                 132 {
107   G4double res = 0.0;                             133   G4double res = 0.0;
108   const G4MaterialCutsCouple* couple = FindCou    134   const G4MaterialCutsCouple* couple = FindCouple(mat, region);
109   if(nullptr != couple && UpdateParticle(p, ki << 135   if(couple && UpdateParticle(p, kinEnergy) ) {
110     res = manager->GetDEDX(p, kinEnergy, coupl    136     res = manager->GetDEDX(p, kinEnergy, couple);
111                                                   137     
112     if(isIon) {                                   138     if(isIon) {
113       if(FindEmModel(p, currentProcessName, ki    139       if(FindEmModel(p, currentProcessName, kinEnergy)) {
114         G4double length = CLHEP::nm;           << 140   G4double length = CLHEP::nm;
115         G4double eloss = res*length;           << 141   G4double eloss = res*length;
116         //G4cout << "### GetDEDX: E= " << kinE << 142   //G4cout << "### GetDEDX: E= " << kinEnergy << " dedx0= " << res 
117         //       << " de= " << eloss << G4endl << 143   //       << " de= " << eloss << G4endl;; 
118         dynParticle->SetKineticEnergy(kinEnerg << 144   G4double niel  = 0.0;
                                                   >> 145         dynParticle.SetKineticEnergy(kinEnergy);
119         currentModel->GetChargeSquareRatio(p,     146         currentModel->GetChargeSquareRatio(p, mat, kinEnergy);
120         currentModel->CorrectionsAlongStep(cou << 147   currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
121         res = eloss/length;                    << 148   res = eloss/length; 
122              //G4cout << " de1= " << eloss <<  << 149       //G4cout << " de1= " << eloss << " res1= " << res 
123         //       << " " << p->GetParticleName( << 150   //       << " " << p->GetParticleName() <<G4endl;;
124       }                                           151       }
125     }                                             152     } 
126                                                   153     
127     if(verbose>0) {                               154     if(verbose>0) {
128       G4cout << "G4EmCalculator::GetDEDX: E(Me    155       G4cout << "G4EmCalculator::GetDEDX: E(MeV)= " << kinEnergy/MeV
129              << " DEDX(MeV/mm)= " << res*mm/Me << 156        << " DEDX(MeV/mm)= " << res*mm/MeV
130              << " DEDX(MeV*cm^2/g)= " << res*g << 157        << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
131              << "  " <<  p->GetParticleName()  << 158        << "  " <<  p->GetParticleName()
132              << " in " <<  mat->GetName()      << 159        << " in " <<  mat->GetName()
133              << " isIon= " << isIon            << 160        << " isIon= " << isIon
134              << G4endl;                        << 161        << G4endl;
135     }                                             162     }
136   }                                               163   }
137   return res;                                     164   return res;
138 }                                                 165 }
139                                                   166 
140 //....oooOO0OOooo........oooOO0OOooo........oo    167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141                                                   168 
                                                   >> 169 G4double G4EmCalculator::GetDEDX(G4double kinEnergy, const G4String& particle,
                                                   >> 170                                  const G4String& material, const G4String& reg)
                                                   >> 171 {
                                                   >> 172   return GetDEDX(kinEnergy,FindParticle(particle),
                                                   >> 173      FindMaterial(material),FindRegion(reg));
                                                   >> 174 }
                                                   >> 175 
                                                   >> 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 177 
142 G4double G4EmCalculator::GetRangeFromRestricte    178 G4double G4EmCalculator::GetRangeFromRestricteDEDX(G4double kinEnergy, 
143                                                << 179                const G4ParticleDefinition* p,
144                                                << 180                const G4Material* mat,
145                                                << 181                const G4Region* region)
146 {                                                 182 {
147   G4double res = 0.0;                             183   G4double res = 0.0;
148   const G4MaterialCutsCouple* couple = FindCou    184   const G4MaterialCutsCouple* couple = FindCouple(mat,region);
149   if(couple && UpdateParticle(p, kinEnergy)) {    185   if(couple && UpdateParticle(p, kinEnergy)) {
150     res = manager->GetRangeFromRestricteDEDX(p    186     res = manager->GetRangeFromRestricteDEDX(p, kinEnergy, couple);
151     if(verbose>1) {                            << 187     if(verbose>0) {
152       G4cout << " G4EmCalculator::GetRangeFrom << 188       G4cout << "G4EmCalculator::GetRange: E(MeV)= " << kinEnergy/MeV
153        << kinEnergy/MeV                        << 189        << " range(mm)= " << res/mm
154              << " range(mm)= " << res/mm       << 190        << "  " <<  p->GetParticleName()
155              << "  " <<  p->GetParticleName()  << 191        << " in " <<  mat->GetName()
156              << " in " <<  mat->GetName()      << 192        << G4endl;
157              << G4endl;                        << 
158     }                                             193     }
159   }                                               194   }
160   return res;                                     195   return res;
161 }                                                 196 }
162                                                   197 
163 //....oooOO0OOooo........oooOO0OOooo........oo    198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
164                                                   199 
165 G4double G4EmCalculator::GetCSDARange(G4double    200 G4double G4EmCalculator::GetCSDARange(G4double kinEnergy, 
166                                       const G4 << 201               const G4ParticleDefinition* p,
167                                       const G4 << 202               const G4Material* mat, 
168                                       const G4 << 203               const G4Region* region)
169 {                                                 204 {
170   G4double res = 0.0;                             205   G4double res = 0.0;
171   if(!theParameters->BuildCSDARange()) {       << 
172     G4ExceptionDescription ed;                 << 
173     ed << "G4EmCalculator::GetCSDARange: CSDA  << 
174        << " use UI command: /process/eLoss/CSD << 
175     G4Exception("G4EmCalculator::GetCSDARange" << 
176                 JustWarning, ed);              << 
177     return res;                                << 
178   }                                            << 
179                                                << 
180   const G4MaterialCutsCouple* couple = FindCou    206   const G4MaterialCutsCouple* couple = FindCouple(mat,region);
181   if(nullptr != couple && UpdateParticle(p, ki << 207   if(couple && UpdateParticle(p, kinEnergy)) {
182     res = manager->GetCSDARange(p, kinEnergy,     208     res = manager->GetCSDARange(p, kinEnergy, couple);
183     if(verbose>1) {                            << 209     if(verbose>0) {
184       G4cout << " G4EmCalculator::GetCSDARange << 210       G4cout << "G4EmCalculator::GetRange: E(MeV)= " << kinEnergy/MeV
185              << " range(mm)= " << res/mm       << 211        << " range(mm)= " << res/mm
186              << "  " <<  p->GetParticleName()  << 212        << "  " <<  p->GetParticleName()
187              << " in " <<  mat->GetName()      << 213        << " in " <<  mat->GetName()
188              << G4endl;                        << 214        << G4endl;
189     }                                             215     }
190   }                                               216   }
191   return res;                                     217   return res;
192 }                                                 218 }
193                                                   219 
194 //....oooOO0OOooo........oooOO0OOooo........oo    220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
195                                                   221 
196 G4double G4EmCalculator::GetRange(G4double kin    222 G4double G4EmCalculator::GetRange(G4double kinEnergy, 
197                                   const G4Part << 223           const G4ParticleDefinition* p,
198                                   const G4Mate << 224           const G4Material* mat, 
199                                   const G4Regi << 225           const G4Region* region)
200 {                                                 226 {
201   G4double res = 0.0;                             227   G4double res = 0.0;
202   if(theParameters->BuildCSDARange()) {        << 228   const G4MaterialCutsCouple* couple = FindCouple(mat,region);
203     res = GetCSDARange(kinEnergy, p, mat, regi << 229   if(couple && UpdateParticle(p, kinEnergy)) {
204   } else {                                     << 230     res = manager->GetRange(p, kinEnergy, couple);
205     res = GetRangeFromRestricteDEDX(kinEnergy, << 231     if(verbose>0) {
                                                   >> 232       G4cout << "G4EmCalculator::GetRange: E(MeV)= " << kinEnergy/MeV
                                                   >> 233        << " range(mm)= " << res/mm
                                                   >> 234        << "  " <<  p->GetParticleName()
                                                   >> 235        << " in " <<  mat->GetName()
                                                   >> 236        << G4endl;
                                                   >> 237     }
206   }                                               238   }
207   return res;                                     239   return res;
208 }                                                 240 }
209                                                   241 
210 //....oooOO0OOooo........oooOO0OOooo........oo    242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
211                                                   243 
                                                   >> 244 G4double G4EmCalculator::GetRangeFromRestricteDEDX(G4double kinEnergy, 
                                                   >> 245                const G4String& particle,
                                                   >> 246                const G4String& material, 
                                                   >> 247                const G4String& reg)
                                                   >> 248 {
                                                   >> 249   return GetRangeFromRestricteDEDX(kinEnergy,FindParticle(particle),
                                                   >> 250            FindMaterial(material),FindRegion(reg));
                                                   >> 251 }
                                                   >> 252 
                                                   >> 253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 254 
                                                   >> 255 G4double G4EmCalculator::GetCSDARange(G4double kinEnergy, 
                                                   >> 256               const G4String& particle,
                                                   >> 257               const G4String& material, 
                                                   >> 258               const G4String& reg)
                                                   >> 259 {
                                                   >> 260   return GetCSDARange(kinEnergy,FindParticle(particle),
                                                   >> 261       FindMaterial(material),FindRegion(reg));
                                                   >> 262 }
                                                   >> 263 
                                                   >> 264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 265 
                                                   >> 266 G4double G4EmCalculator::GetRange(G4double kinEnergy, 
                                                   >> 267           const G4String& particle,
                                                   >> 268           const G4String& material, 
                                                   >> 269           const G4String& reg)
                                                   >> 270 {
                                                   >> 271   return GetRange(kinEnergy,FindParticle(particle),
                                                   >> 272       FindMaterial(material),FindRegion(reg));
                                                   >> 273 }
                                                   >> 274 
                                                   >> 275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 276 
212 G4double G4EmCalculator::GetKinEnergy(G4double    277 G4double G4EmCalculator::GetKinEnergy(G4double range, 
213                                       const G4 << 278               const G4ParticleDefinition* p,
214                                       const G4    279                                       const G4Material* mat,
215                                       const G4 << 280               const G4Region* region)
216 {                                                 281 {
217   G4double res = 0.0;                             282   G4double res = 0.0;
218   const G4MaterialCutsCouple* couple = FindCou    283   const G4MaterialCutsCouple* couple = FindCouple(mat,region);
219   if(nullptr != couple && UpdateParticle(p, 1. << 284   if(couple && UpdateParticle(p, 1.0*GeV)) {
220     res = manager->GetEnergy(p, range, couple)    285     res = manager->GetEnergy(p, range, couple);
221     if(verbose>0) {                               286     if(verbose>0) {
222       G4cout << "G4EmCalculator::GetKinEnergy:    287       G4cout << "G4EmCalculator::GetKinEnergy: Range(mm)= " << range/mm
223              << " KinE(MeV)= " << res/MeV      << 288        << " KinE(MeV)= " << res/MeV
224              << "  " <<  p->GetParticleName()  << 289        << "  " <<  p->GetParticleName()
225              << " in " <<  mat->GetName()      << 290        << " in " <<  mat->GetName()
226              << G4endl;                        << 291        << G4endl;
227     }                                             292     }
228   }                                               293   }
229   return res;                                     294   return res;
230 }                                                 295 }
231                                                   296 
232 //....oooOO0OOooo........oooOO0OOooo........oo    297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
233                                                   298 
                                                   >> 299 G4double G4EmCalculator::GetKinEnergy(G4double range, const G4String& particle,
                                                   >> 300                                       const G4String& material, const G4String& reg)
                                                   >> 301 {
                                                   >> 302   return GetKinEnergy(range,FindParticle(particle),
                                                   >> 303           FindMaterial(material),FindRegion(reg));
                                                   >> 304 }
                                                   >> 305 
                                                   >> 306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 307 
234 G4double G4EmCalculator::GetCrossSectionPerVol    308 G4double G4EmCalculator::GetCrossSectionPerVolume(G4double kinEnergy,
235                                             co    309                                             const G4ParticleDefinition* p,
236                                             co    310                                             const G4String& processName,
237                                             co << 311               const G4Material* mat,
238                                             co << 312               const G4Region* region)
239 {                                                 313 {
240   G4double res = 0.0;                             314   G4double res = 0.0;
241   const G4MaterialCutsCouple* couple = FindCou    315   const G4MaterialCutsCouple* couple = FindCouple(mat,region);
242                                                   316 
243   if(nullptr != couple && UpdateParticle(p, ki << 317   if(couple && UpdateParticle(p, kinEnergy)) {
244     if(FindEmModel(p, processName, kinEnergy)) << 318     G4int idx = couple->GetIndex();
245       G4int idx      = couple->GetIndex();     << 319     FindLambdaTable(p, processName, kinEnergy);
246       G4int procType = -1;                     << 320 
247       FindLambdaTable(p, processName, kinEnerg << 321     if(currentLambda) {
248                                                << 322       G4double e = kinEnergy*massRatio;
249       G4VEmProcess* emproc = FindDiscreteProce << 323       res = (((*currentLambda)[idx])->Value(e))*chargeSquare;
250       if(nullptr != emproc) {                  << 324     } else {
251   res = emproc->GetCrossSection(kinEnergy, cou << 325       res = ComputeCrossSectionPerVolume(kinEnergy, p, processName, mat, 
252       } else if(currentLambda) {               << 326            kinEnergy);
253         // special tables are built for Msc mo << 
254   // procType is set in FindLambdaTable        << 
255         if(procType==2) {                      << 
256           auto mscM = static_cast<G4VMscModel* << 
257           mscM->SetCurrentCouple(couple);      << 
258           G4double tr1Mfp = mscM->GetTransport << 
259           if (tr1Mfp<DBL_MAX) {                << 
260             res = 1./tr1Mfp;                   << 
261           }                                    << 
262         } else {                               << 
263           G4double e = kinEnergy*massRatio;    << 
264           res = (((*currentLambda)[idx])->Valu << 
265         }                                      << 
266       } else {                                 << 
267         res = ComputeCrossSectionPerVolume(kin << 
268       }                                        << 
269       if(verbose>0) {                          << 
270         G4cout << "G4EmCalculator::GetXSPerVol << 
271                << " cross(cm-1)= " << res*cm   << 
272                << "  " <<  p->GetParticleName( << 
273                << " in " <<  mat->GetName();   << 
274         if(verbose>1)                          << 
275           G4cout << "  idx= " << idx << "  Esc << 
276            << kinEnergy*massRatio              << 
277            << "  q2= " << chargeSquare;        << 
278         G4cout << G4endl;                      << 
279       }                                        << 
280     }                                             327     }
                                                   >> 328     if(verbose>0) {
                                                   >> 329       G4cout << "G4EmCalculator::GetXSPerVolume: E(MeV)= " << kinEnergy/MeV
                                                   >> 330        << " cross(cm-1)= " << res*cm
                                                   >> 331        << "  " <<  p->GetParticleName()
                                                   >> 332        << " in " <<  mat->GetName();
                                                   >> 333       if(verbose>1) 
                                                   >> 334   G4cout << "  idx= " << idx << "  Escaled((MeV)= " 
                                                   >> 335          << kinEnergy*massRatio 
                                                   >> 336          << "  q2= " << chargeSquare; 
                                                   >> 337       G4cout << G4endl;
                                                   >> 338     } 
281   }                                               339   }
282   return res;                                     340   return res;
283 }                                                 341 }
284                                                   342 
285 //....oooOO0OOooo........oooOO0OOooo........oo    343 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
286                                                   344 
                                                   >> 345 G4double G4EmCalculator::GetCrossSectionPerVolume(G4double kinEnergy,
                                                   >> 346                                             const G4String& particle,
                                                   >> 347               const G4String& processName,
                                                   >> 348                                             const G4String& material,
                                                   >> 349               const G4String& reg)
                                                   >> 350 {
                                                   >> 351   return GetCrossSectionPerVolume(kinEnergy,FindParticle(particle),processName,
                                                   >> 352                                   FindMaterial(material),FindRegion(reg));
                                                   >> 353 }
                                                   >> 354 
                                                   >> 355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 356 
287 G4double G4EmCalculator::GetShellIonisationCro    357 G4double G4EmCalculator::GetShellIonisationCrossSectionPerAtom(
288                                          const << 358            const G4String& particle, 
289                                          G4int    359                                          G4int Z, 
290                                          G4Ato << 360            G4AtomicShellEnumerator shell,
291                                          G4dou << 361            G4double kinEnergy)
292 {                                                 362 {
293   G4double res = 0.0;                             363   G4double res = 0.0;
294   const G4ParticleDefinition* p = FindParticle    364   const G4ParticleDefinition* p = FindParticle(particle);
295   G4VAtomDeexcitation* ad = manager->AtomDeexc    365   G4VAtomDeexcitation* ad = manager->AtomDeexcitation();
296   if(nullptr != p && nullptr != ad) {          << 366   if(p && ad) { 
297     res = ad->GetShellIonisationCrossSectionPe    367     res = ad->GetShellIonisationCrossSectionPerAtom(p, Z, shell, kinEnergy); 
298   }                                               368   }
299   return res;                                     369   return res;
300 }                                                 370 }
301                                                   371 
302 //....oooOO0OOooo........oooOO0OOooo........oo    372 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
303                                                   373 
304 G4double G4EmCalculator::GetMeanFreePath(G4dou    374 G4double G4EmCalculator::GetMeanFreePath(G4double kinEnergy,
305                                          const    375                                          const G4ParticleDefinition* p,
306                                          const    376                                          const G4String& processName,
307                                          const << 377            const G4Material* mat,
308                                          const    378                                          const G4Region* region)
309 {                                                 379 {
310   G4double res = DBL_MAX;                         380   G4double res = DBL_MAX;
311   G4double x = GetCrossSectionPerVolume(kinEne    381   G4double x = GetCrossSectionPerVolume(kinEnergy,p, processName, mat,region);
312   if(x > 0.0) { res = 1.0/x; }                    382   if(x > 0.0) { res = 1.0/x; }
313   if(verbose>1) {                                 383   if(verbose>1) {
314     G4cout << "G4EmCalculator::GetMeanFreePath    384     G4cout << "G4EmCalculator::GetMeanFreePath: E(MeV)= " << kinEnergy/MeV
315            << " MFP(mm)= " << res/mm           << 385      << " MFP(mm)= " << res/mm
316            << "  " <<  p->GetParticleName()    << 386      << "  " <<  p->GetParticleName()
317            << " in " <<  mat->GetName()        << 387      << " in " <<  mat->GetName()
318            << G4endl;                          << 388      << G4endl;
319   }                                               389   }
320   return res;                                     390   return res;
321 }                                                 391 }
322                                                   392 
323 //....oooOO0OOooo........oooOO0OOooo........oo    393 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
324                                                   394 
                                                   >> 395 G4double G4EmCalculator::GetMeanFreePath(G4double kinEnergy,
                                                   >> 396                                          const G4String& particle,
                                                   >> 397            const G4String& processName,
                                                   >> 398                                          const G4String& material,
                                                   >> 399            const G4String& reg)
                                                   >> 400 {
                                                   >> 401   return GetMeanFreePath(kinEnergy,FindParticle(particle),processName,
                                                   >> 402                          FindMaterial(material),FindRegion(reg));
                                                   >> 403 }
                                                   >> 404 
                                                   >> 405 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 406 
325 void G4EmCalculator::PrintDEDXTable(const G4Pa    407 void G4EmCalculator::PrintDEDXTable(const G4ParticleDefinition* p)
326 {                                                 408 {
327   const G4VEnergyLossProcess* elp = manager->G << 409   const G4VEnergyLossProcess* elp = FindEnergyLossProcess(p);
328   G4cout << "##### DEDX Table for " << p->GetP    410   G4cout << "##### DEDX Table for " << p->GetParticleName() << G4endl;
329   if(nullptr != elp) G4cout << *(elp->DEDXTabl << 411   if(elp) G4cout << *(elp->DEDXTable()) << G4endl;
330 }                                                 412 }
331                                                   413 
332 //....oooOO0OOooo........oooOO0OOooo........oo    414 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
333                                                   415 
334 void G4EmCalculator::PrintRangeTable(const G4P    416 void G4EmCalculator::PrintRangeTable(const G4ParticleDefinition* p)
335 {                                                 417 {
336   const G4VEnergyLossProcess* elp = manager->G << 418   const G4VEnergyLossProcess* elp = FindEnergyLossProcess(p);
337   G4cout << "##### Range Table for " << p->Get    419   G4cout << "##### Range Table for " << p->GetParticleName() << G4endl;
338   if(nullptr != elp) G4cout << *(elp->RangeTab << 420   if(elp) G4cout << *(elp->RangeTableForLoss()) << G4endl;
339 }                                                 421 }
340                                                   422 
341 //....oooOO0OOooo........oooOO0OOooo........oo    423 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
342                                                   424 
343 void G4EmCalculator::PrintInverseRangeTable(co    425 void G4EmCalculator::PrintInverseRangeTable(const G4ParticleDefinition* p)
344 {                                                 426 {
345   const G4VEnergyLossProcess* elp = manager->G << 427   const G4VEnergyLossProcess* elp = FindEnergyLossProcess(p);
346   G4cout << "### G4EmCalculator: Inverse Range    428   G4cout << "### G4EmCalculator: Inverse Range Table for " 
347          << p->GetParticleName() << G4endl;    << 429    << p->GetParticleName() << G4endl;
348   if(nullptr != elp) G4cout << *(elp->InverseR << 430   if(elp) G4cout << *(elp->InverseRangeTable()) << G4endl;
349 }                                                 431 }
350                                                   432 
351 //....oooOO0OOooo........oooOO0OOooo........oo    433 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
352                                                   434 
353 G4double G4EmCalculator::ComputeDEDX(G4double     435 G4double G4EmCalculator::ComputeDEDX(G4double kinEnergy,
354                                      const G4P    436                                      const G4ParticleDefinition* p,
355                                      const G4S    437                                      const G4String& processName,
356                                      const G4M << 438              const G4Material* mat,
357                                            G4d    439                                            G4double cut)
358 {                                                 440 {
359   SetupMaterial(mat);                          << 441   currentMaterial = mat;
                                                   >> 442   currentMaterialName = mat->GetName();
360   G4double res = 0.0;                             443   G4double res = 0.0;
361   if(verbose > 1) {                               444   if(verbose > 1) {
362     G4cout << "### G4EmCalculator::ComputeDEDX    445     G4cout << "### G4EmCalculator::ComputeDEDX: " << p->GetParticleName()
363            << " in " << currentMaterialName       446            << " in " << currentMaterialName
364            << " e(MeV)= " << kinEnergy/MeV <<     447            << " e(MeV)= " << kinEnergy/MeV << "  cut(MeV)= " << cut/MeV
365            << G4endl;                          << 448      << G4endl;
366   }                                               449   }
367   if(UpdateParticle(p, kinEnergy)) {              450   if(UpdateParticle(p, kinEnergy)) {
368     if(FindEmModel(p, processName, kinEnergy))    451     if(FindEmModel(p, processName, kinEnergy)) {
369       G4double escaled = kinEnergy*massRatio;     452       G4double escaled = kinEnergy*massRatio;
370       if(nullptr != baseParticle) {            << 453       if(baseParticle) {
371   res = currentModel->ComputeDEDXPerVolume(mat << 454         res = currentModel->ComputeDEDXPerVolume(
372                                                << 455         mat, baseParticle, escaled, cut) * chargeSquare;
373   if(verbose > 1) {                            << 456         if(verbose > 1) {
374     G4cout << "Particle: " << p->GetParticleNa << 457           G4cout <<  baseParticle->GetParticleName()
375      << " E(MeV)=" << kinEnergy                << 458      << " Escaled(MeV)= " << escaled;
376      << " Base particle: " << baseParticle->Ge << 
377      << " Escaled(MeV)= " << escaled           << 
378      << " q2=" << chargeSquare << G4endl;      << 
379   }                                            << 
380       } else {                                 << 
381   res = currentModel->ComputeDEDXPerVolume(mat << 
382   if(verbose > 1) {                            << 
383     G4cout << "Particle: " << p->GetParticleNa << 
384      << " E(MeV)=" << kinEnergy << G4endl;     << 
385   }                                               459   }
                                                   >> 460       } else {
                                                   >> 461         res = currentModel->ComputeDEDXPerVolume(mat, p, kinEnergy, cut);
                                                   >> 462         if(verbose > 1) { G4cout <<  " no basePart E(MeV)= " << kinEnergy << " "; }
386       }                                           463       }
387       if(verbose > 1) {                           464       if(verbose > 1) {
388   G4cout << currentModel->GetName() << ": DEDX    465   G4cout << currentModel->GetName() << ": DEDX(MeV/mm)= " << res*mm/MeV
389          << " DEDX(MeV*cm^2/g)= "                 466          << " DEDX(MeV*cm^2/g)= "
390          << res*gram/(MeV*cm2*mat->GetDensity(    467          << res*gram/(MeV*cm2*mat->GetDensity())
391          << G4endl;                               468          << G4endl;
392       }                                           469       }
                                                   >> 470 
393       // emulate smoothing procedure              471       // emulate smoothing procedure
394       if(applySmoothing && nullptr != loweMode << 472       G4double eth = currentModel->LowEnergyLimit();
395   G4double eth = currentModel->LowEnergyLimit( << 473       // G4cout << "massRatio= " << massRatio << " eth= " << eth << G4endl;
396   G4double res0 = 0.0;                         << 474       if(loweModel) {
397   G4double res1 = 0.0;                         << 475         G4double res0 = 0.0;
398   if(nullptr != baseParticle) {                << 476         G4double res1 = 0.0;
399     res1 = chargeSquare*                       << 477         if(baseParticle) {
400       currentModel->ComputeDEDXPerVolume(mat,  << 478           res1 = currentModel->ComputeDEDXPerVolume(mat, baseParticle, eth, cut)
401     res0 = chargeSquare*                       << 479                * chargeSquare;
402       loweModel->ComputeDEDXPerVolume(mat, bas << 480           res0 = loweModel->ComputeDEDXPerVolume(mat, baseParticle, eth, cut)
                                                   >> 481                * chargeSquare;
403   } else {                                        482   } else {
404     res1 = currentModel->ComputeDEDXPerVolume(    483     res1 = currentModel->ComputeDEDXPerVolume(mat, p, eth, cut);
405     res0 = loweModel->ComputeDEDXPerVolume(mat    484     res0 = loweModel->ComputeDEDXPerVolume(mat, p, eth, cut);
406   }                                               485   }
407   if(res1 > 0.0 && escaled > 0.0) {            << 
408     res *= (1.0 + (res0/res1 - 1.0)*eth/escale << 
409   }                                            << 
410   if(verbose > 1) {                               486   if(verbose > 1) {
411     G4cout << "At boundary energy(MeV)= " << e    487     G4cout << "At boundary energy(MeV)= " << eth/MeV
412      << " DEDX(MeV/mm)= " << res0*mm/MeV << "  << 488      << " DEDX(MeV/mm)= " << res1*mm/MeV
413      << " after correction DEDX(MeV/mm)=" << r << 489      << G4endl;
                                                   >> 490   }
                                                   >> 491   
                                                   >> 492         //G4cout << "eth= " << eth << " escaled= " << escaled
                                                   >> 493   //       << " res0= " << res0 << " res1= "
                                                   >> 494         //       << res1 <<  "  q2= " << chargeSquare << G4endl;
                                                   >> 495   
                                                   >> 496         if(res1 > 0.0 && escaled > 0.0) {
                                                   >> 497     res *= (1.0 + (res0/res1 - 1.0)*eth/escaled);
414   }                                               498   }
415       }                                           499       } 
416       // correction for ions                   << 500 
                                                   >> 501       // low energy correction for ions
417       if(isIon) {                                 502       if(isIon) {
418   const G4double length = CLHEP::nm;           << 503         G4double length = CLHEP::nm;
419   if(UpdateCouple(mat, cut)) {                 << 504   const G4Region* r = 0;
420     G4double eloss = res*length;               << 505   const G4MaterialCutsCouple* couple = FindCouple(mat, r);
421     dynParticle->SetKineticEnergy(kinEnergy);  << 506         G4double eloss = res*length;
422     currentModel->CorrectionsAlongStep(current << 507         G4double niel  = 0.0;
423                                              l << 508         dynParticle.SetKineticEnergy(kinEnergy);
424     res = eloss/length;                        << 509         currentModel->GetChargeSquareRatio(p, mat, kinEnergy);
425                                                << 510         currentModel->CorrectionsAlongStep(couple,&dynParticle,eloss,niel,length);
426     if(verbose > 1) {                          << 511         res = eloss/length; 
427       G4cout << "After Corrections: DEDX(MeV/m << 512   
428        << " DEDX(MeV*cm^2/g)= "                << 513   if(verbose > 1) {
429        << res*gram/(MeV*cm2*mat->GetDensity()) << 514     G4cout << "After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
430     }                                          << 515      << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
                                                   >> 516      << G4endl;
431   }                                               517   }
432       }                                           518       }
433       if(verbose > 0) {                        << 519     }
434   G4cout << "## E(MeV)= " << kinEnergy/MeV     << 520       
435          << " DEDX(MeV/mm)= " << res*mm/MeV    << 521     if(verbose > 0) {
436          << " DEDX(MeV*cm^2/g)= " << res*gram/ << 522       G4cout << "Sum: E(MeV)= " << kinEnergy/MeV
437          << " cut(MeV)= " << cut/MeV           << 523        << " DEDX(MeV/mm)= " << res*mm/MeV
438          << "  " <<  p->GetParticleName()      << 524        << " DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->GetDensity())
439          << " in " <<  currentMaterialName     << 525        << " cut(MeV)= " << cut/MeV
440          << " Zi^2= " << chargeSquare          << 526        << "  " <<  p->GetParticleName()
441          << " isIon=" << isIon                 << 527        << " in " <<  currentMaterialName
442          << G4endl;                            << 528        << " Zi^2= " << chargeSquare
443       }                                        << 529        << " isIon=" << isIon
                                                   >> 530        << G4endl;
444     }                                             531     }
445   }                                               532   }
446   return res;                                     533   return res;
447 }                                                 534 }
448                                                   535 
449 //....oooOO0OOooo........oooOO0OOooo........oo    536 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
450                                                   537 
451 G4double G4EmCalculator::ComputeElectronicDEDX    538 G4double G4EmCalculator::ComputeElectronicDEDX(G4double kinEnergy,
452                                                << 539                  const G4ParticleDefinition* part,
453                                                << 540                  const G4Material* mat,
454                                                << 541                  G4double cut)
455 {                                                 542 {
456   SetupMaterial(mat);                          << 543   currentMaterial = mat;
                                                   >> 544   currentMaterialName = mat->GetName();
457   G4double dedx = 0.0;                            545   G4double dedx = 0.0;
458   if(UpdateParticle(part, kinEnergy)) {           546   if(UpdateParticle(part, kinEnergy)) {
459                                                   547 
460     G4LossTableManager* lManager = G4LossTable    548     G4LossTableManager* lManager = G4LossTableManager::Instance();
461     const std::vector<G4VEnergyLossProcess*> v    549     const std::vector<G4VEnergyLossProcess*> vel =
462       lManager->GetEnergyLossProcessVector();     550       lManager->GetEnergyLossProcessVector();
463     std::size_t n = vel.size();                << 551     G4int n = vel.size();
464                                                   552 
465     //G4cout << "ComputeElectronicDEDX for " <    553     //G4cout << "ComputeElectronicDEDX for " << part->GetParticleName() 
466     //           << " n= " << n << G4endl;     << 554     //     << " n= " << n << G4endl;
467                                                   555  
468     for(std::size_t i=0; i<n; ++i) {           << 556     for(G4int i=0; i<n; ++i) {
469       if(vel[i]) {                                557       if(vel[i]) {
470         auto p = static_cast<G4VProcess*>(vel[ << 558   G4VProcess* p = reinterpret_cast<G4VProcess*>(vel[i]);
471         if(ActiveForParticle(part, p)) {       << 559   if(ActiveForParticle(part, p)) {
472           //G4cout << "idx= " << i << " " << ( << 560     //G4cout << "idx= " << i << " " << (vel[i])->GetProcessName()
473           //  << "  " << (vel[i])->Particle()- << 561     //   << "  " << (vel[i])->Particle()->GetParticleName() << G4endl; 
474           dedx += ComputeDEDX(kinEnergy,part,( << 562     dedx += ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),mat,cut);
475         }                                      << 563   }
476       }                                           564       }
477     }                                             565     }
478   }                                               566   }
479   return dedx;                                    567   return dedx;
480 }                                                 568 }
481                                                   569 
482 //....oooOO0OOooo........oooOO0OOooo........oo    570 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
483                                                   571 
484 G4double                                       << 572 G4double G4EmCalculator::ComputeElectronicDEDX(G4double kinEnergy, const G4String& part,
485 G4EmCalculator::ComputeDEDXForCutInRange(G4dou << 573                  const G4String& mat, G4double cut)
486                                          const << 
487                                          const << 
488                                          G4dou << 
489 {                                                 574 {
490   SetupMaterial(mat);                          << 575   return ComputeElectronicDEDX(kinEnergy,FindParticle(part),FindMaterial(mat),cut);
491   G4double dedx = 0.0;                         << 
492   if(UpdateParticle(part, kinEnergy)) {        << 
493                                                << 
494     G4LossTableManager* lManager = G4LossTable << 
495     const std::vector<G4VEnergyLossProcess*> v << 
496       lManager->GetEnergyLossProcessVector();  << 
497     std::size_t n = vel.size();                << 
498                                                << 
499     if(mat != cutMaterial) {                   << 
500       cutMaterial = mat;                       << 
501       cutenergy[0] =                           << 
502         ComputeEnergyCutFromRangeCut(rangecut, << 
503       cutenergy[1] =                           << 
504         ComputeEnergyCutFromRangeCut(rangecut, << 
505       cutenergy[2] =                           << 
506         ComputeEnergyCutFromRangeCut(rangecut, << 
507     }                                          << 
508                                                << 
509     //G4cout << "ComputeElectronicDEDX for " < << 
510     //           << " n= " << n << G4endl;     << 
511                                                << 
512     for(std::size_t i=0; i<n; ++i) {           << 
513       if(vel[i]) {                             << 
514         auto p = static_cast<G4VProcess*>(vel[ << 
515         if(ActiveForParticle(part, p)) {       << 
516           //G4cout << "idx= " << i << " " << ( << 
517           // << "  " << (vel[i])->Particle()-> << 
518           const G4ParticleDefinition* sec = (v << 
519           std::size_t idx = 0;                 << 
520           if(sec == G4Electron::Electron()) {  << 
521           else if(sec == G4Positron::Positron( << 
522                                                << 
523           dedx += ComputeDEDX(kinEnergy,part,( << 
524                               mat,cutenergy[id << 
525         }                                      << 
526       }                                        << 
527     }                                          << 
528   }                                            << 
529   return dedx;                                 << 
530 }                                                 576 }
531                                                   577 
532 //....oooOO0OOooo........oooOO0OOooo........oo    578 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
533                                                   579 
534 G4double G4EmCalculator::ComputeTotalDEDX(G4do    580 G4double G4EmCalculator::ComputeTotalDEDX(G4double kinEnergy, 
535                                           cons << 581             const G4ParticleDefinition* part,
536                                           cons << 582             const G4Material* mat, 
537                                           G4do << 583             G4double cut)
538 {                                                 584 {
539   G4double dedx = ComputeElectronicDEDX(kinEne    585   G4double dedx = ComputeElectronicDEDX(kinEnergy,part,mat,cut);
540   if(mass > 700.*MeV) { dedx += ComputeNuclear    586   if(mass > 700.*MeV) { dedx += ComputeNuclearDEDX(kinEnergy,part,mat); }
541   return dedx;                                    587   return dedx;
542 }                                                 588 }
543                                                   589 
544 //....oooOO0OOooo........oooOO0OOooo........oo    590 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
545                                                   591 
                                                   >> 592 G4double G4EmCalculator::ComputeTotalDEDX(G4double kinEnergy, 
                                                   >> 593             const G4String& part,
                                                   >> 594             const G4String& mat, 
                                                   >> 595             G4double cut)
                                                   >> 596 {
                                                   >> 597   return ComputeTotalDEDX(kinEnergy,FindParticle(part),FindMaterial(mat),cut);
                                                   >> 598 }
                                                   >> 599 
                                                   >> 600 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 601 
                                                   >> 602 G4double G4EmCalculator::ComputeDEDX(G4double kinEnergy,
                                                   >> 603                                      const G4String& particle,
                                                   >> 604              const G4String& processName,
                                                   >> 605                                      const G4String& material,
                                                   >> 606                                            G4double cut)
                                                   >> 607 {
                                                   >> 608   return ComputeDEDX(kinEnergy,FindParticle(particle),processName,
                                                   >> 609                      FindMaterial(material),cut);
                                                   >> 610 }
                                                   >> 611 
                                                   >> 612 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 613 
546 G4double G4EmCalculator::ComputeNuclearDEDX(G4    614 G4double G4EmCalculator::ComputeNuclearDEDX(G4double kinEnergy,
547                                       const G4    615                                       const G4ParticleDefinition* p,
548                                       const G4 << 616               const G4Material* mat)
549 {                                                 617 {
550   G4double res = 0.0;                          << 618 
551   G4VEmProcess* nucst = FindDiscreteProcess(p, << 619   G4double res = corr->NuclearDEDX(p, mat, kinEnergy, false);
552   if(nucst) {                                  << 
553     G4VEmModel* mod = nucst->EmModel();        << 
554     if(mod) {                                  << 
555       mod->SetFluctuationFlag(false);          << 
556       res = mod->ComputeDEDXPerVolume(mat, p,  << 
557     }                                          << 
558   }                                            << 
559                                                   620 
560   if(verbose > 1) {                               621   if(verbose > 1) {
561     G4cout <<  p->GetParticleName() << " E(MeV    622     G4cout <<  p->GetParticleName() << " E(MeV)= " << kinEnergy/MeV
562            << " NuclearDEDX(MeV/mm)= " << res* << 623      << " NuclearDEDX(MeV/mm)= " << res*mm/MeV
563            << " NuclearDEDX(MeV*cm^2/g)= "     << 624      << " NuclearDEDX(MeV*cm^2/g)= "
564            << res*gram/(MeV*cm2*mat->GetDensit << 625      << res*gram/(MeV*cm2*mat->GetDensity())
565            << G4endl;                          << 626      << G4endl;
566   }                                               627   }
567   return res;                                     628   return res;
568 }                                                 629 }
569                                                   630 
570 //....oooOO0OOooo........oooOO0OOooo........oo    631 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
571                                                   632 
                                                   >> 633 G4double G4EmCalculator::ComputeNuclearDEDX(G4double kinEnergy,
                                                   >> 634                                       const G4String& particle,
                                                   >> 635               const G4String& material)
                                                   >> 636 {
                                                   >> 637   return ComputeNuclearDEDX(kinEnergy,FindParticle(particle),
                                                   >> 638           FindMaterial(material));
                                                   >> 639 }
                                                   >> 640 
                                                   >> 641 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 642 
572 G4double G4EmCalculator::ComputeCrossSectionPe    643 G4double G4EmCalculator::ComputeCrossSectionPerVolume(
573                                                   644                                                    G4double kinEnergy,
574                                              c    645                                              const G4ParticleDefinition* p,
575                                              c    646                                              const G4String& processName,
576                                              c << 647                const G4Material* mat,
577                                                   648                                                    G4double cut)
578 {                                                 649 {
579   SetupMaterial(mat);                          << 650   currentMaterial = mat;
                                                   >> 651   currentMaterialName = mat->GetName();
580   G4double res = 0.0;                             652   G4double res = 0.0;
581   if(UpdateParticle(p, kinEnergy)) {              653   if(UpdateParticle(p, kinEnergy)) {
582     if(FindEmModel(p, processName, kinEnergy))    654     if(FindEmModel(p, processName, kinEnergy)) {
583       G4double e = kinEnergy;                     655       G4double e = kinEnergy;
584       G4double aCut = std::max(cut, theParamet << 
585       if(baseParticle) {                          656       if(baseParticle) {
586         e *= kinEnergy*massRatio;              << 657   e *= kinEnergy*massRatio;
587         res = currentModel->CrossSectionPerVol << 658   res = currentModel->CrossSectionPerVolume(
588               mat, baseParticle, e, aCut, e) * << 659         mat, baseParticle, e, cut, e) * chargeSquare;
589       } else {                                    660       } else {
590         res = currentModel->CrossSectionPerVol << 661   res = currentModel->CrossSectionPerVolume(mat, p, e, cut, e);
591       }                                           662       }
592       if(verbose>0) {                             663       if(verbose>0) {
593         G4cout << "G4EmCalculator::ComputeXSPe << 664   G4cout << "G4EmCalculator::ComputeXSPerVolume: E(MeV)= " << kinEnergy/MeV
594                << kinEnergy/MeV                << 665          << " cross(cm-1)= " << res*cm
595                << " cross(cm-1)= " << res*cm   << 666          << " cut(keV)= " << cut/keV
596                << " cut(keV)= " << aCut/keV    << 667          << "  " <<  p->GetParticleName()
597                << "  " <<  p->GetParticleName( << 668          << " in " <<  mat->GetName()
598                << " in " <<  mat->GetName()    << 669          << G4endl;
599                << G4endl;                      << 
600       }                                           670       }
601     }                                             671     }
602   }                                               672   }
603   return res;                                     673   return res;
604 }                                                 674 }
605                                                   675 
606 //....oooOO0OOooo........oooOO0OOooo........oo    676 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
607                                                   677 
608 G4double                                       << 678 G4double G4EmCalculator::ComputeCrossSectionPerVolume(
609 G4EmCalculator::ComputeCrossSectionPerAtom(G4d << 679                                                    G4double kinEnergy,
610                                            con << 680                                              const G4String& particle,
611                                            con << 681                const G4String& processName,
612                                            G4d << 682                                              const G4String& material,
613                                            G4d << 683                                                    G4double cut)
614 {                                                 684 {
615   G4double res = 0.0;                          << 685   return ComputeCrossSectionPerVolume(kinEnergy,FindParticle(particle),
616   if(UpdateParticle(p, kinEnergy)) {           << 686               processName,
617     G4int iz = G4lrint(Z);                     << 687                                       FindMaterial(material),cut);
618     CheckMaterial(iz);                         << 
619     if(FindEmModel(p, processName, kinEnergy)) << 
620       G4double e = kinEnergy;                  << 
621       G4double aCut = std::max(cut, theParamet << 
622       if(baseParticle) {                       << 
623         e *= kinEnergy*massRatio;              << 
624         currentModel->InitialiseForElement(bas << 
625         res = currentModel->ComputeCrossSectio << 
626               baseParticle, e, Z, A, aCut) * c << 
627       } else {                                 << 
628         currentModel->InitialiseForElement(p,  << 
629         res = currentModel->ComputeCrossSectio << 
630       }                                        << 
631       if(verbose>0) {                          << 
632         G4cout << "E(MeV)= " << kinEnergy/MeV  << 
633                << " cross(barn)= " << res/barn << 
634                << "  " <<  p->GetParticleName( << 
635                << " Z= " <<  Z << " A= " << A/ << 
636                << " cut(keV)= " << aCut/keV    << 
637                << G4endl;                      << 
638       }                                        << 
639     }                                          << 
640   }                                            << 
641   return res;                                  << 
642 }                                                 688 }
643                                                   689 
644 //....oooOO0OOooo........oooOO0OOooo........oo    690 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
645                                                   691 
646 G4double                                       << 692 G4double G4EmCalculator::ComputeCrossSectionPerAtom(
647 G4EmCalculator::ComputeCrossSectionPerShell(G4 << 693                                                    G4double kinEnergy,
648                                             co << 694                const G4ParticleDefinition* p,
649                                             co << 695                                              const G4String& processName,
650                                             G4 << 696                      G4double Z, G4double A,
651                                             G4 << 697                                        G4double cut)
652 {                                                 698 {
653   G4double res = 0.0;                             699   G4double res = 0.0;
654   if(UpdateParticle(p, kinEnergy)) {              700   if(UpdateParticle(p, kinEnergy)) {
655     CheckMaterial(Z);                          << 
656     if(FindEmModel(p, processName, kinEnergy))    701     if(FindEmModel(p, processName, kinEnergy)) {
657       G4double e = kinEnergy;                     702       G4double e = kinEnergy;
658       G4double aCut = std::max(cut, theParamet << 703       if(baseParticle) {
659       if(nullptr != baseParticle) {            << 704   e *= kinEnergy*massRatio;
660         e *= kinEnergy*massRatio;              << 705   res = currentModel->ComputeCrossSectionPerAtom(
661         currentModel->InitialiseForElement(bas << 706         baseParticle, e, Z, A, cut) * chargeSquare;
662         res =                                  << 
663           currentModel->ComputeCrossSectionPer << 
664                                                << 
665       } else {                                    707       } else {
666         currentModel->InitialiseForElement(p,  << 708   res = currentModel->ComputeCrossSectionPerAtom(p, e, Z, A, cut);
667         res = currentModel->ComputeCrossSectio << 
668       }                                           709       }
669       if(verbose>0) {                             710       if(verbose>0) {
670         G4cout << "E(MeV)= " << kinEnergy/MeV  << 711   G4cout << "E(MeV)= " << kinEnergy/MeV
671                << " cross(barn)= " << res/barn << 712          << " cross(barn)= " << res/barn
672                << "  " <<  p->GetParticleName( << 713          << "  " <<  p->GetParticleName()
673                << " Z= " <<  Z << " shellIdx=  << 714          << " Z= " <<  Z << " A= " << A/(g/mole) << " g/mole"
674                << " cut(keV)= " << aCut/keV    << 
675          << G4endl;                               715          << G4endl;
676       }                                           716       }
677     }                                             717     }
678   }                                               718   }
679   return res;                                     719   return res;
680 }                                                 720 }
681                                                   721 
682 //....oooOO0OOooo........oooOO0OOooo........oo    722 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
683                                                   723 
                                                   >> 724 G4double G4EmCalculator::ComputeCrossSectionPerAtom(G4double kinEnergy,
                                                   >> 725                                               const G4String& particle,
                                                   >> 726                                               const G4String& processName,
                                                   >> 727                 const G4Element* elm,
                                                   >> 728                                         G4double cut)
                                                   >> 729 {
                                                   >> 730   return ComputeCrossSectionPerAtom(kinEnergy,FindParticle(particle),
                                                   >> 731             processName,
                                                   >> 732                                     elm->GetZ(),elm->GetN(),cut);
                                                   >> 733 }
                                                   >> 734 
                                                   >> 735 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 736 
684 G4double                                          737 G4double 
685 G4EmCalculator::ComputeGammaAttenuationLength(    738 G4EmCalculator::ComputeGammaAttenuationLength(G4double kinEnergy, 
686                                                << 739                 const G4Material* mat)
687 {                                                 740 {
688   G4double res = 0.0;                             741   G4double res = 0.0;
689   const G4ParticleDefinition* gamma = G4Gamma:    742   const G4ParticleDefinition* gamma = G4Gamma::Gamma();
690   res += ComputeCrossSectionPerVolume(kinEnerg    743   res += ComputeCrossSectionPerVolume(kinEnergy, gamma, "conv", mat, 0.0);
691   res += ComputeCrossSectionPerVolume(kinEnerg    744   res += ComputeCrossSectionPerVolume(kinEnergy, gamma, "compt", mat, 0.0);
692   res += ComputeCrossSectionPerVolume(kinEnerg    745   res += ComputeCrossSectionPerVolume(kinEnergy, gamma, "phot", mat, 0.0);
693   res += ComputeCrossSectionPerVolume(kinEnerg    746   res += ComputeCrossSectionPerVolume(kinEnergy, gamma, "Rayl", mat, 0.0);
694   if(res > 0.0) { res = 1.0/res; }                747   if(res > 0.0) { res = 1.0/res; }
695   return res;                                     748   return res;
696 }                                                 749 }
697                                                   750 
698 //....oooOO0OOooo........oooOO0OOooo........oo    751 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
699                                                   752 
700 G4double G4EmCalculator::ComputeShellIonisatio    753 G4double G4EmCalculator::ComputeShellIonisationCrossSectionPerAtom(
701                                          const << 754            const G4String& particle, 
702                                          G4int    755                                          G4int Z, 
703                                          G4Ato << 756            G4AtomicShellEnumerator shell,
704                                          G4dou << 757            G4double kinEnergy,
705                                          const << 758            const G4Material* mat)
706 {                                                 759 {
707   G4double res = 0.0;                             760   G4double res = 0.0;
708   const G4ParticleDefinition* p = FindParticle    761   const G4ParticleDefinition* p = FindParticle(particle);
709   G4VAtomDeexcitation* ad = manager->AtomDeexc    762   G4VAtomDeexcitation* ad = manager->AtomDeexcitation();
710   if(p && ad) {                                   763   if(p && ad) { 
711     res = ad->ComputeShellIonisationCrossSecti    764     res = ad->ComputeShellIonisationCrossSectionPerAtom(p, Z, shell, 
712                                                << 765               kinEnergy, mat); 
713   }                                               766   }
714   return res;                                     767   return res;
715 }                                                 768 }
716                                                   769 
717 //....oooOO0OOooo........oooOO0OOooo........oo    770 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
718                                                   771 
719 G4double G4EmCalculator::ComputeMeanFreePath(G    772 G4double G4EmCalculator::ComputeMeanFreePath(G4double kinEnergy,
720                                              c    773                                              const G4ParticleDefinition* p,
721                                              c    774                                              const G4String& processName,
722                                              c << 775                const G4Material* mat,
723                                              G << 776                                                    G4double cut)
724 {                                                 777 {
725   G4double mfp = DBL_MAX;                         778   G4double mfp = DBL_MAX;
726   G4double x =                                 << 779   G4double x = ComputeCrossSectionPerVolume(kinEnergy, p, processName, mat, cut);
727     ComputeCrossSectionPerVolume(kinEnergy, p, << 
728   if(x > 0.0) { mfp = 1.0/x; }                    780   if(x > 0.0) { mfp = 1.0/x; }
729   if(verbose>1) {                                 781   if(verbose>1) {
730     G4cout << "E(MeV)= " << kinEnergy/MeV         782     G4cout << "E(MeV)= " << kinEnergy/MeV
731            << " MFP(mm)= " << mfp/mm           << 783      << " MFP(mm)= " << mfp/mm
732            << "  " <<  p->GetParticleName()    << 784      << "  " <<  p->GetParticleName()
733            << " in " <<  mat->GetName()        << 785      << " in " <<  mat->GetName()
734            << G4endl;                          << 786      << G4endl;
735   }                                               787   }
736   return mfp;                                     788   return mfp;
737 }                                                 789 }
738                                                   790 
739 //....oooOO0OOooo........oooOO0OOooo........oo    791 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
740                                                   792 
                                                   >> 793 G4double G4EmCalculator::ComputeMeanFreePath(G4double kinEnergy,
                                                   >> 794                                              const G4String& particle,
                                                   >> 795                                              const G4String& processName,
                                                   >> 796                                              const G4String& material,
                                                   >> 797                                                    G4double cut)
                                                   >> 798 {
                                                   >> 799   return ComputeMeanFreePath(kinEnergy,FindParticle(particle),processName,
                                                   >> 800                              FindMaterial(material),cut);
                                                   >> 801 }
                                                   >> 802 
                                                   >> 803 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 804 
741 G4double G4EmCalculator::ComputeEnergyCutFromR    805 G4double G4EmCalculator::ComputeEnergyCutFromRangeCut(
742                          G4double range,          806                          G4double range, 
743                          const G4ParticleDefin << 807        const G4ParticleDefinition* part,
744                          const G4Material* mat << 808        const G4Material* mat)
745 {                                                 809 {
746   return G4ProductionCutsTable::GetProductionC    810   return G4ProductionCutsTable::GetProductionCutsTable()->
747     ConvertRangeToEnergy(part, mat, range);       811     ConvertRangeToEnergy(part, mat, range);
748 }                                                 812 }
749                                                   813 
750 //....oooOO0OOooo........oooOO0OOooo........oo    814 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
751                                                   815 
                                                   >> 816 G4double G4EmCalculator::ComputeEnergyCutFromRangeCut(
                                                   >> 817                          G4double range, 
                                                   >> 818        const G4String& particle,
                                                   >> 819        const G4String& material)
                                                   >> 820 {
                                                   >> 821   return ComputeEnergyCutFromRangeCut(range,FindParticle(particle),
                                                   >> 822               FindMaterial(material));
                                                   >> 823 }
                                                   >> 824 
                                                   >> 825 
                                                   >> 826 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 827 
752 G4bool G4EmCalculator::UpdateParticle(const G4    828 G4bool G4EmCalculator::UpdateParticle(const G4ParticleDefinition* p,
753                                       G4double << 829               G4double kinEnergy)
754 {                                                 830 {
755   if(p != currentParticle) {                      831   if(p != currentParticle) {
756                                                   832 
757     // new particle                               833     // new particle
758     currentParticle = p;                          834     currentParticle = p;
759     dynParticle->SetDefinition(const_cast<G4Pa << 835     dynParticle.SetDefinition(const_cast<G4ParticleDefinition*>(p));
760     dynParticle->SetKineticEnergy(kinEnergy);  << 836     dynParticle.SetKineticEnergy(kinEnergy);
761     baseParticle    = nullptr;                 << 837     baseParticle    = 0;
762     currentParticleName = p->GetParticleName()    838     currentParticleName = p->GetParticleName();
763     massRatio       = 1.0;                        839     massRatio       = 1.0;
764     mass            = p->GetPDGMass();            840     mass            = p->GetPDGMass();
765     chargeSquare    = 1.0;                        841     chargeSquare    = 1.0;
766     currentProcess  = manager->GetEnergyLossPr << 842     currentProcess  = FindEnergyLossProcess(p);
767     currentProcessName = "";                      843     currentProcessName = "";
768     isIon = false;                                844     isIon = false;
769                                                   845 
770     // ionisation process exist                   846     // ionisation process exist
771     if(nullptr != currentProcess) {            << 847     if(currentProcess) {
772       currentProcessName = currentProcess->Get    848       currentProcessName = currentProcess->GetProcessName();
773       baseParticle = currentProcess->BaseParti    849       baseParticle = currentProcess->BaseParticle();
774       if(currentProcessName == "ionIoni" && p- << 
775         baseParticle = theGenericIon;          << 
776         isIon = true;                          << 
777       }                                        << 
778                                                   850 
779       // base particle is used                    851       // base particle is used
780       if(nullptr != baseParticle) {            << 852       if(baseParticle) {
781         massRatio = baseParticle->GetPDGMass() << 853   massRatio = baseParticle->GetPDGMass()/p->GetPDGMass();
782         G4double q = p->GetPDGCharge()/basePar << 854   G4double q = p->GetPDGCharge()/baseParticle->GetPDGCharge();
783         chargeSquare = q*q;                    << 855   chargeSquare = q*q;
784       }                                           856       } 
                                                   >> 857 
                                                   >> 858       if(p->GetParticleType()   == "nucleus" 
                                                   >> 859    && currentParticleName != "deuteron"  
                                                   >> 860    && currentParticleName != "triton"
                                                   >> 861    && currentParticleName != "alpha+"
                                                   >> 862    && currentParticleName != "helium"
                                                   >> 863    && currentParticleName != "hydrogen"
                                                   >> 864    ) {
                                                   >> 865   isIon = true;
                                                   >> 866   massRatio = theGenericIon->GetPDGMass()/p->GetPDGMass();
                                                   >> 867         baseParticle = theGenericIon;
                                                   >> 868   //      G4cout << p->GetParticleName()
                                                   >> 869   // << " in " << currentMaterial->GetName()
                                                   >> 870   //       << "  e= " << kinEnergy << G4endl;
                                                   >> 871       }
785     }                                             872     }
786   }                                               873   }
                                                   >> 874 
787   // Effective charge for ions                    875   // Effective charge for ions
788   if(isIon && nullptr != currentProcess) {     << 876   if(isIon) {
789     chargeSquare =                                877     chargeSquare =
790       corr->EffectiveChargeSquareRatio(p, curr << 878       corr->EffectiveChargeSquareRatio(p, currentMaterial, kinEnergy)
791     currentProcess->SetDynamicMassCharge(massR << 879       * corr->EffectiveChargeCorrection(p,currentMaterial,kinEnergy);
792     if(verbose>1) {                            << 880     if(currentProcess) {
793       G4cout <<"\n NewIon: massR= "<< massRati << 881       currentProcess->SetDynamicMassCharge(massRatio,chargeSquare);
794        << chargeSquare << "  " << currentProce << 882       //G4cout << "NewP: massR= " << massRatio << "   q2= " << chargeSquare << G4endl;
795     }                                             883     }
796   }                                               884   }
797   return true;                                    885   return true;
798 }                                                 886 }
799                                                   887 
800 //....oooOO0OOooo........oooOO0OOooo........oo    888 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
801                                                   889 
802 const G4ParticleDefinition* G4EmCalculator::Fi    890 const G4ParticleDefinition* G4EmCalculator::FindParticle(const G4String& name)
803 {                                                 891 {
804   const G4ParticleDefinition* p = nullptr;     << 892   const G4ParticleDefinition* p = 0;
805   if(name != currentParticleName) {               893   if(name != currentParticleName) {
806     p = G4ParticleTable::GetParticleTable()->F    894     p = G4ParticleTable::GetParticleTable()->FindParticle(name);
807     if(nullptr == p) {                         << 895     if(!p) {
808       G4cout << "### WARNING: G4EmCalculator::    896       G4cout << "### WARNING: G4EmCalculator::FindParticle fails to find " 
809              << name << G4endl;                << 897        << name << G4endl;
810     }                                             898     }
811   } else {                                        899   } else {
812     p = currentParticle;                          900     p = currentParticle;
813   }                                               901   }
814   return p;                                       902   return p;
815 }                                                 903 }
816                                                   904 
817 //....oooOO0OOooo........oooOO0OOooo........oo    905 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
818                                                   906 
819 const G4ParticleDefinition* G4EmCalculator::Fi    907 const G4ParticleDefinition* G4EmCalculator::FindIon(G4int Z, G4int A)
820 {                                                 908 {
821   const G4ParticleDefinition* p = ionTable->Ge << 909   const G4ParticleDefinition* p = 
                                                   >> 910     G4ParticleTable::GetParticleTable()->FindIon(Z,A,0,Z);
822   return p;                                       911   return p;
823 }                                                 912 }
824                                                   913 
825 //....oooOO0OOooo........oooOO0OOooo........oo    914 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
826                                                   915 
827 const G4Material* G4EmCalculator::FindMaterial    916 const G4Material* G4EmCalculator::FindMaterial(const G4String& name)
828 {                                                 917 {
829   if(name != currentMaterialName) {               918   if(name != currentMaterialName) {
830     SetupMaterial(G4Material::GetMaterial(name << 919     currentMaterial = G4Material::GetMaterial(name);
831     if(nullptr == currentMaterial) {           << 920     currentMaterialName = name;
                                                   >> 921     if(!currentMaterial)
832       G4cout << "### WARNING: G4EmCalculator::    922       G4cout << "### WARNING: G4EmCalculator::FindMaterial fails to find " 
833              << name << G4endl;                << 923        << name << G4endl;
834     }                                          << 
835   }                                               924   }
836   return currentMaterial;                         925   return currentMaterial;
837 }                                                 926 }
838                                                   927 
839 //....oooOO0OOooo........oooOO0OOooo........oo    928 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
840                                                   929 
841 const G4Region* G4EmCalculator::FindRegion(con    930 const G4Region* G4EmCalculator::FindRegion(const G4String& reg)
842 {                                                 931 {
843   return G4EmUtility::FindRegion(reg);         << 932   const G4Region* r = 0;
                                                   >> 933   if(reg != "" && reg != "world") {
                                                   >> 934     r = G4RegionStore::GetInstance()->GetRegion(reg);
                                                   >> 935   } else {
                                                   >> 936     r = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld");
                                                   >> 937   }
                                                   >> 938   return r;
844 }                                                 939 }
845                                                   940 
846 //....oooOO0OOooo........oooOO0OOooo........oo    941 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
847                                                   942 
848 const G4MaterialCutsCouple* G4EmCalculator::Fi    943 const G4MaterialCutsCouple* G4EmCalculator::FindCouple(
849                             const G4Material*  << 944           const G4Material* material,
850                             const G4Region* re << 945           const G4Region* region)
851 {                                                 946 {
852   const G4MaterialCutsCouple* couple = nullptr << 947   if(!material) return 0;
853   SetupMaterial(material);                     << 948   currentMaterial = material;
854   if(nullptr != currentMaterial) {             << 949   currentMaterialName = material->GetName();
855     // Access to materials                     << 950   // Access to materials
856     const G4ProductionCutsTable* theCoupleTabl << 951   const G4ProductionCutsTable* theCoupleTable=
857       G4ProductionCutsTable::GetProductionCuts << 952         G4ProductionCutsTable::GetProductionCutsTable();
858     const G4Region* r = region;                << 953   const G4Region* r = region;
859     if(nullptr != r) {                         << 954   if(!r) {
860       couple = theCoupleTable->GetMaterialCuts << 955     r = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld");
861                                                << 
862     } else {                                   << 
863       G4RegionStore* store = G4RegionStore::Ge << 
864       std::size_t nr = store->size();          << 
865       if(0 < nr) {                             << 
866         for(std::size_t i=0; i<nr; ++i) {      << 
867           couple = theCoupleTable->GetMaterial << 
868             material, ((*store)[i])->GetProduc << 
869           if(nullptr != couple) { break; }     << 
870         }                                      << 
871       }                                        << 
872     }                                          << 
873   }                                               956   }
874   if(nullptr == couple) {                      << 957   return theCoupleTable->GetMaterialCutsCouple(material,r->GetProductionCuts());
875     G4ExceptionDescription ed;                 << 958 
876     ed << "G4EmCalculator::FindCouple: fail fo << 
877        << currentMaterialName << ">";          << 
878     if(region) { ed << " and region " << regio << 
879     G4Exception("G4EmCalculator::FindCouple",  << 
880                 FatalException, ed);           << 
881   }                                            << 
882   return couple;                               << 
883 }                                                 959 }
884                                                   960 
885 //....oooOO0OOooo........oooOO0OOooo........oo    961 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
886                                                   962 
887 G4bool G4EmCalculator::UpdateCouple(const G4Ma    963 G4bool G4EmCalculator::UpdateCouple(const G4Material* material, G4double cut)
888 {                                                 964 {
889   SetupMaterial(material);                     << 965   if(!material) return false;
890   if(!currentMaterial) { return false; }       << 966   currentMaterial = material;
                                                   >> 967   currentMaterialName = material->GetName();
891   for (G4int i=0; i<nLocalMaterials; ++i) {       968   for (G4int i=0; i<nLocalMaterials; ++i) {
892     if(material == localMaterials[i] && cut ==    969     if(material == localMaterials[i] && cut == localCuts[i]) {
893       currentCouple = localCouples[i];            970       currentCouple = localCouples[i];
894       currentCoupleIndex = currentCouple->GetI    971       currentCoupleIndex = currentCouple->GetIndex();
895       currentCut = cut;                           972       currentCut = cut;
896       return true;                                973       return true;
897     }                                             974     }
898   }                                               975   }
899   const G4MaterialCutsCouple* cc = new G4Mater    976   const G4MaterialCutsCouple* cc = new G4MaterialCutsCouple(material);
900   localMaterials.push_back(material);             977   localMaterials.push_back(material);
901   localCouples.push_back(cc);                     978   localCouples.push_back(cc);
902   localCuts.push_back(cut);                       979   localCuts.push_back(cut);
903   ++nLocalMaterials;                           << 980   nLocalMaterials++;
904   currentCouple = cc;                             981   currentCouple = cc;
905   currentCoupleIndex = currentCouple->GetIndex    982   currentCoupleIndex = currentCouple->GetIndex();
906   currentCut = cut;                               983   currentCut = cut;
907   return true;                                    984   return true;
908 }                                                 985 }
909                                                   986 
910 //....oooOO0OOooo........oooOO0OOooo........oo    987 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
911                                                   988 
912 void G4EmCalculator::FindLambdaTable(const G4P    989 void G4EmCalculator::FindLambdaTable(const G4ParticleDefinition* p,
913                                      const G4S    990                                      const G4String& processName,
914                                      G4double  << 991              G4double kinEnergy)
915 {                                                 992 {
916   // Search for the process                       993   // Search for the process
917   if (!currentLambda || p != lambdaParticle ||    994   if (!currentLambda || p != lambdaParticle || processName != lambdaName) {
918     lambdaName     = processName;                 995     lambdaName     = processName;
919     currentLambda  = nullptr;                  << 996     currentLambda  = 0;
920     lambdaParticle = p;                           997     lambdaParticle = p;
921     isApplicable   = false;                    << 
922                                                   998 
923     const G4ParticleDefinition* part = (isIon) << 999     const G4ParticleDefinition* part = p;
                                                   >> 1000     if(isIon) { part = theGenericIon; }
924                                                   1001 
925     // Search for energy loss process             1002     // Search for energy loss process
926     currentName = processName;                    1003     currentName = processName;
927     currentModel = nullptr;                    << 1004     currentModel = 0;
928     loweModel = nullptr;                       << 1005     loweModel = 0;
929                                                   1006 
930     G4VEnergyLossProcess* elproc = FindEnLossP    1007     G4VEnergyLossProcess* elproc = FindEnLossProcess(part, processName);
931     if(nullptr != elproc) {                    << 1008     if(elproc) {
932       currentLambda = elproc->LambdaTable();      1009       currentLambda = elproc->LambdaTable();
933       proctype      = 0;                       << 1010       if(currentLambda) {
934       if(nullptr != currentLambda) {           << 1011   isApplicable = true;
935         isApplicable = true;                   << 1012   if(verbose>1) { 
936         if(verbose>1) {                        << 1013     G4cout << "G4VEnergyLossProcess is found out: " << currentName 
937           G4cout << "G4VEnergyLossProcess is f << 1014      << G4endl;
938                  << G4endl;                    << 1015   }
939         }                                      << 
940       }                                           1016       }
941       curProcess = elproc;                     << 
942       return;                                     1017       return;
943     }                                             1018     }
944                                                   1019 
945     // Search for discrete process                1020     // Search for discrete process 
946     G4VEmProcess* proc = FindDiscreteProcess(p    1021     G4VEmProcess* proc = FindDiscreteProcess(part, processName);
947     if(nullptr != proc) {                      << 1022     if(proc) {
948       currentLambda = proc->LambdaTable();        1023       currentLambda = proc->LambdaTable();
949       proctype      = 1;                       << 1024       if(currentLambda) {
950       if(nullptr != currentLambda) {           << 1025   isApplicable    = true;
951         isApplicable = true;                   << 1026   if(verbose>1) { 
952         if(verbose>1) {                        << 1027     G4cout << "G4VEmProcess is found out: " << currentName << G4endl;
953           G4cout << "G4VEmProcess is found out << 1028   }
954         }                                      << 
955       }                                           1029       }
956       curProcess = proc;                       << 
957       return;                                     1030       return;
958     }                                             1031     }
959                                                   1032 
960     // Search for msc process                     1033     // Search for msc process
961     G4VMultipleScattering* msc = FindMscProces    1034     G4VMultipleScattering* msc = FindMscProcess(part, processName);
962     if(nullptr != msc) {                       << 1035     if(msc) {
963       currentModel = msc->SelectModel(kinEnerg    1036       currentModel = msc->SelectModel(kinEnergy,0);
964       proctype     = 2;                        << 1037       /*
965       if(nullptr != currentModel) {            << 1038       if(currentModel) {
966         currentLambda = currentModel->GetCross << 1039   currentLambda = currentModel->GetCrossSectionTable();
967         if(nullptr != currentLambda) {         << 1040         if(currentLambda) {
968           isApplicable = true;                 << 1041     isApplicable    = true;
969           if(verbose>1) {                      << 1042     if(verbose>1) { 
970             G4cout << "G4VMultipleScattering i << 1043       G4cout << "G4VMultipleScattering is found out: " << currentName 
971                    << G4endl;                  << 1044        << G4endl;
972           }                                    << 1045     }
973         }                                      << 1046   }
974       }                                           1047       }
975       curProcess = msc;                        << 1048       */
976     }                                             1049     }
977   }                                               1050   }
978 }                                                 1051 }
979                                                   1052 
980 //....oooOO0OOooo........oooOO0OOooo........oo    1053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
981                                                   1054 
982 G4bool G4EmCalculator::FindEmModel(const G4Par    1055 G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
983                                    const G4Str    1056                                    const G4String& processName,
984                                             G4 << 1057                    G4double kinEnergy)
985 {                                                 1058 {
986   isApplicable = false;                           1059   isApplicable = false;
987   if(nullptr == p || nullptr == currentMateria << 1060   if(!p) {
988     G4cout << "G4EmCalculator::FindEmModel WAR << 1061     G4cout << "G4EmCalculator::FindEmModel WARNING: no particle defined" 
989            << " or materail defined; particle: << 1062      << G4endl;
990     return isApplicable;                          1063     return isApplicable;
991   }                                               1064   }
992   G4String partname =  p->GetParticleName();      1065   G4String partname =  p->GetParticleName();
                                                   >> 1066   const G4ParticleDefinition* part = p;
993   G4double scaledEnergy = kinEnergy*massRatio;    1067   G4double scaledEnergy = kinEnergy*massRatio;
994   const G4ParticleDefinition* part = (isIon) ? << 1068   if(isIon) { part = theGenericIon; } 
995                                                   1069 
996   if(verbose > 1) {                               1070   if(verbose > 1) {
997     G4cout << "## G4EmCalculator::FindEmModel     1071     G4cout << "## G4EmCalculator::FindEmModel for " << partname
998            << " (type= " << p->GetParticleType    1072            << " (type= " << p->GetParticleType()
999            << ") and " << processName << " at     1073            << ") and " << processName << " at E(MeV)= " << scaledEnergy 
1000            << G4endl;                         << 1074      << G4endl;
1001     if(p != part) { G4cout << "  GenericIon i    1075     if(p != part) { G4cout << "  GenericIon is the base particle" << G4endl; }
1002   }                                              1076   }
1003                                                  1077 
1004   // Search for energy loss process              1078   // Search for energy loss process
1005   currentName = processName;                     1079   currentName = processName;
1006   currentModel = nullptr;                     << 1080   currentModel = 0;
1007   loweModel = nullptr;                        << 1081   loweModel = 0;
1008   std::size_t idx = 0;                        << 1082   size_t idx   = 0;
1009                                                  1083 
1010   G4VEnergyLossProcess* elproc = FindEnLossPr    1084   G4VEnergyLossProcess* elproc = FindEnLossProcess(part, processName);
1011   if(nullptr != elproc) {                     << 1085   if(elproc) {
1012     currentModel = elproc->SelectModelForMate    1086     currentModel = elproc->SelectModelForMaterial(scaledEnergy, idx);
1013     currentModel->InitialiseForMaterial(part, << 
1014     currentModel->SetupForMaterial(part, curr << 
1015     G4double eth = currentModel->LowEnergyLim    1087     G4double eth = currentModel->LowEnergyLimit();
1016     if(eth > 0.0) {                              1088     if(eth > 0.0) {
1017       loweModel = elproc->SelectModelForMater    1089       loweModel = elproc->SelectModelForMaterial(eth - CLHEP::eV, idx);
1018       if(loweModel == currentModel) { loweMod << 1090       if(loweModel == currentModel) { loweModel = 0; }
1019       else {                                  << 
1020         loweModel->InitialiseForMaterial(part << 
1021         loweModel->SetupForMaterial(part, cur << 
1022       }                                       << 
1023     }                                            1091     }
1024   }                                              1092   }
1025                                                  1093 
1026   // Search for discrete process                 1094   // Search for discrete process 
1027   if(nullptr == currentModel) {               << 1095   if(!currentModel) {
1028     G4VEmProcess* proc = FindDiscreteProcess(    1096     G4VEmProcess* proc = FindDiscreteProcess(part, processName);
1029     if(nullptr != proc) {                     << 1097     if(proc) {
1030       currentModel = proc->SelectModelForMate    1098       currentModel = proc->SelectModelForMaterial(kinEnergy, idx);
1031       currentModel->InitialiseForMaterial(par << 
1032       currentModel->SetupForMaterial(part, cu << 
1033       G4double eth = currentModel->LowEnergyL    1099       G4double eth = currentModel->LowEnergyLimit();
1034       if(eth > 0.0) {                            1100       if(eth > 0.0) {
1035         loweModel = proc->SelectModelForMater << 1101   loweModel = proc->SelectModelForMaterial(eth - CLHEP::eV, idx);
1036         if(loweModel == currentModel) { loweM << 1102   if(loweModel == currentModel) { loweModel = 0; }
1037         else {                                << 
1038           loweModel->InitialiseForMaterial(pa << 
1039           loweModel->SetupForMaterial(part, c << 
1040         }                                     << 
1041       }                                          1103       }
1042     }                                            1104     }
1043   }                                              1105   }
1044                                                  1106 
1045   // Search for msc process                      1107   // Search for msc process
1046   if(nullptr == currentModel) {               << 1108   if(!currentModel) {
1047     G4VMultipleScattering* proc = FindMscProc    1109     G4VMultipleScattering* proc = FindMscProcess(part, processName);
1048     if(nullptr != proc) {                     << 1110     if(proc) {
1049       currentModel = proc->SelectModel(kinEne    1111       currentModel = proc->SelectModel(kinEnergy, idx);
1050       loweModel = nullptr;                    << 1112       loweModel = 0;
1051     }                                            1113     }
1052   }                                              1114   }
1053   if(nullptr != currentModel) {               << 1115   if(currentModel) {
1054     if(loweModel == currentModel) { loweModel << 1116     if(loweModel == currentModel) { loweModel = 0; }
1055     isApplicable = true;                         1117     isApplicable = true;
1056     currentModel->InitialiseForMaterial(part, << 
1057     if(loweModel) {                           << 
1058       loweModel->InitialiseForMaterial(part,  << 
1059     }                                         << 
1060     if(verbose > 1) {                            1118     if(verbose > 1) {
1061       G4cout << "   Model <" << currentModel-    1119       G4cout << "   Model <" << currentModel->GetName() 
1062              << "> Emin(MeV)= " << currentMod << 1120        << "> Emin(MeV)= " << currentModel->LowEnergyLimit()/MeV
1063              << " for " << part->GetParticleN << 1121        << " for " << part->GetParticleName();
1064       if(nullptr != elproc) {                 << 1122       if(elproc) { 
1065         G4cout << " and " << elproc->GetProce << 1123   G4cout << " and " << elproc->GetProcessName() << "  " << elproc 
1066                << G4endl;                     << 1124          << G4endl;
1067       }                                          1125       }
1068       if(nullptr != loweModel) {              << 1126       if(loweModel) { 
1069         G4cout << " LowEnergy model <" << low << 1127   G4cout << " LowEnergy model <" << loweModel->GetName() << ">"; 
1070       }                                          1128       }
1071       G4cout << G4endl;                          1129       G4cout << G4endl;
1072     }                                            1130     } 
1073   }                                              1131   }
1074   return isApplicable;                           1132   return isApplicable;
1075 }                                                1133 }
1076                                                  1134 
1077 //....oooOO0OOooo........oooOO0OOooo........o    1135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1078                                                  1136 
                                                   >> 1137 G4VEnergyLossProcess* G4EmCalculator::FindEnergyLossProcess(
                                                   >> 1138                       const G4ParticleDefinition* p)
                                                   >> 1139 {
                                                   >> 1140   G4VEnergyLossProcess* elp = 0;
                                                   >> 1141   G4String partname =  p->GetParticleName();
                                                   >> 1142   const G4ParticleDefinition* part = p;
                                                   >> 1143   
                                                   >> 1144   if(p->GetParticleType() == "nucleus" 
                                                   >> 1145      && currentParticleName != "deuteron"  
                                                   >> 1146      && currentParticleName != "triton"
                                                   >> 1147      && currentParticleName != "alpha+"
                                                   >> 1148      && currentParticleName != "helium"
                                                   >> 1149      && currentParticleName != "hydrogen"
                                                   >> 1150      ) { part = theGenericIon; } 
                                                   >> 1151 
                                                   >> 1152   elp = G4LossTableManager::Instance()->GetEnergyLossProcess(part);
                                                   >> 1153   return elp;
                                                   >> 1154 }
                                                   >> 1155 
                                                   >> 1156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 1157 
1079 G4VEnergyLossProcess*                            1158 G4VEnergyLossProcess* 
1080 G4EmCalculator::FindEnLossProcess(const G4Par    1159 G4EmCalculator::FindEnLossProcess(const G4ParticleDefinition* part,
1081                                   const G4Str << 1160           const G4String& processName)
1082 {                                                1161 {
1083   G4VEnergyLossProcess* proc = nullptr;       << 1162   G4VEnergyLossProcess* proc = 0;
1084   const std::vector<G4VEnergyLossProcess*> v     1163   const std::vector<G4VEnergyLossProcess*> v = 
1085     manager->GetEnergyLossProcessVector();    << 1164     G4LossTableManager::Instance()->GetEnergyLossProcessVector();
1086   std::size_t n = v.size();                   << 1165   G4int n = v.size();
1087   for(std::size_t i=0; i<n; ++i) {            << 1166   for(G4int i=0; i<n; ++i) {
1088     if((v[i])->GetProcessName() == processNam    1167     if((v[i])->GetProcessName() == processName) {
1089       auto p = static_cast<G4VProcess*>(v[i]) << 1168       G4VProcess* p = reinterpret_cast<G4VProcess*>(v[i]);
1090       if(ActiveForParticle(part, p)) {           1169       if(ActiveForParticle(part, p)) {
1091         proc = v[i];                             1170         proc = v[i];
1092         break;                                << 1171   break;
1093       }                                          1172       }
1094     }                                            1173     }
1095   }                                              1174   }
1096   return proc;                                   1175   return proc;
1097 }                                                1176 }
1098                                                  1177 
1099 //....oooOO0OOooo........oooOO0OOooo........o    1178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1100                                                  1179 
1101 G4VEmProcess*                                    1180 G4VEmProcess* 
1102 G4EmCalculator::FindDiscreteProcess(const G4P    1181 G4EmCalculator::FindDiscreteProcess(const G4ParticleDefinition* part,
1103                                     const G4S << 1182             const G4String& processName)
1104 {                                                1183 {
1105   G4VEmProcess* proc = nullptr;               << 1184   G4VEmProcess* proc = 0;
1106   auto v = manager->GetEmProcessVector();     << 1185   const std::vector<G4VEmProcess*> v = 
1107   std::size_t n = v.size();                   << 1186     G4LossTableManager::Instance()->GetEmProcessVector();
1108   for(std::size_t i=0; i<n; ++i) {            << 1187   G4int n = v.size();
1109     const G4String& pName = v[i]->GetProcessN << 1188   for(G4int i=0; i<n; ++i) {
1110     if(pName == "GammaGeneralProc") {         << 1189     if((v[i])->GetProcessName() == processName) {
1111       proc = v[i]->GetEmProcess(processName); << 1190       G4VProcess* p = reinterpret_cast<G4VProcess*>(v[i]);
1112       break;                                  << 
1113     } else if(pName == processName) {         << 
1114       const auto p = static_cast<G4VProcess*> << 
1115       if(ActiveForParticle(part, p)) {           1191       if(ActiveForParticle(part, p)) {
1116         proc = v[i];                             1192         proc = v[i];
1117         break;                                << 1193   break;
1118       }                                          1194       }
1119     }                                            1195     }
1120   }                                              1196   }
1121   return proc;                                   1197   return proc;
1122 }                                                1198 }
1123                                                  1199 
1124 //....oooOO0OOooo........oooOO0OOooo........o    1200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1125                                                  1201 
1126 G4VMultipleScattering*                           1202 G4VMultipleScattering* 
1127 G4EmCalculator::FindMscProcess(const G4Partic    1203 G4EmCalculator::FindMscProcess(const G4ParticleDefinition* part,
1128                                const G4String << 1204              const G4String& processName)
1129 {                                                1205 {
1130   G4VMultipleScattering* proc = nullptr;      << 1206   G4VMultipleScattering* proc = 0;
1131   const std::vector<G4VMultipleScattering*> v    1207   const std::vector<G4VMultipleScattering*> v = 
1132     manager->GetMultipleScatteringVector();   << 1208     G4LossTableManager::Instance()->GetMultipleScatteringVector();
1133   std::size_t n = v.size();                   << 1209   G4int n = v.size();
1134   for(std::size_t i=0; i<n; ++i) {            << 1210   for(G4int i=0; i<n; ++i) {
1135     if((v[i])->GetProcessName() == processNam    1211     if((v[i])->GetProcessName() == processName) {
1136       auto p = static_cast<G4VProcess*>(v[i]) << 1212       G4VProcess* p = reinterpret_cast<G4VProcess*>(v[i]);
1137       if(ActiveForParticle(part, p)) {           1213       if(ActiveForParticle(part, p)) {
1138         proc = v[i];                             1214         proc = v[i];
1139         break;                                << 1215   break;
1140       }                                          1216       }
1141     }                                            1217     }
1142   }                                              1218   }
1143   return proc;                                   1219   return proc;
1144 }                                                1220 }
1145                                                  1221 
1146 //....oooOO0OOooo........oooOO0OOooo........o    1222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1147                                                  1223 
1148 G4VProcess* G4EmCalculator::FindProcess(const << 
1149                                         const << 
1150 {                                             << 
1151   G4VProcess* proc = nullptr;                 << 
1152   const G4ProcessManager* procman = part->Get << 
1153   G4ProcessVector* pv = procman->GetProcessLi << 
1154   G4int nproc = (G4int)pv->size();            << 
1155   for(G4int i=0; i<nproc; ++i) {              << 
1156     if(processName == (*pv)[i]->GetProcessNam << 
1157       proc = (*pv)[i];                        << 
1158       break;                                  << 
1159     }                                         << 
1160   }                                           << 
1161   return proc;                                << 
1162 }                                             << 
1163                                               << 
1164 //....oooOO0OOooo........oooOO0OOooo........o << 
1165                                               << 
1166 G4bool G4EmCalculator::ActiveForParticle(cons    1224 G4bool G4EmCalculator::ActiveForParticle(const G4ParticleDefinition* part,
1167                                          G4VP << 1225            G4VProcess* proc)
1168 {                                                1226 {
1169   G4ProcessManager* pm = part->GetProcessMana    1227   G4ProcessManager* pm = part->GetProcessManager();
1170   G4ProcessVector* pv = pm->GetProcessList();    1228   G4ProcessVector* pv = pm->GetProcessList();
1171   G4int n = (G4int)pv->size();                << 1229   G4int n = pv->size();
1172   G4bool res = false;                            1230   G4bool res = false;
1173   for(G4int i=0; i<n; ++i) {                     1231   for(G4int i=0; i<n; ++i) {
1174     if((*pv)[i] == proc) {                       1232     if((*pv)[i] == proc) {
1175       if(pm->GetProcessActivation(i)) { res =    1233       if(pm->GetProcessActivation(i)) { res = true; }
1176       break;                                     1234       break;
1177     }                                            1235     }
1178   }                                              1236   }
1179   return res;                                    1237   return res;
1180 }                                             << 
1181                                               << 
1182 //....oooOO0OOooo........oooOO0OOooo........o << 
1183                                               << 
1184 void G4EmCalculator::SetupMaterial(const G4Ma << 
1185 {                                             << 
1186   if(mat) {                                   << 
1187     currentMaterial = mat;                    << 
1188     currentMaterialName = mat->GetName();     << 
1189   } else {                                    << 
1190     currentMaterial = nullptr;                << 
1191     currentMaterialName = "";                 << 
1192   }                                           << 
1193 }                                             << 
1194                                               << 
1195 //....oooOO0OOooo........oooOO0OOooo........o << 
1196                                               << 
1197 void G4EmCalculator::SetupMaterial(const G4St << 
1198 {                                             << 
1199   SetupMaterial(nist->FindOrBuildMaterial(mna << 
1200 }                                             << 
1201                                               << 
1202 //....oooOO0OOooo........oooOO0OOooo........o << 
1203                                               << 
1204 void G4EmCalculator::CheckMaterial(G4int Z)   << 
1205 {                                             << 
1206   G4bool isFound = false;                     << 
1207   if(nullptr != currentMaterial) {            << 
1208     G4int nn = (G4int)currentMaterial->GetNum << 
1209     for(G4int i=0; i<nn; ++i) {               << 
1210       if(Z == currentMaterial->GetElement(i)- << 
1211         isFound = true;                       << 
1212         break;                                << 
1213       }                                       << 
1214     }                                         << 
1215   }                                           << 
1216   if(!isFound) {                              << 
1217     SetupMaterial(nist->FindOrBuildSimpleMate << 
1218   }                                           << 
1219 }                                                1238 }
1220                                                  1239 
1221 //....oooOO0OOooo........oooOO0OOooo........o    1240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1222                                                  1241 
1223 void G4EmCalculator::SetVerbose(G4int verb)      1242 void G4EmCalculator::SetVerbose(G4int verb)
1224 {                                                1243 {
1225   verbose = verb;                                1244   verbose = verb;
1226 }                                                1245 }
1227                                                  1246 
1228 //....oooOO0OOooo........oooOO0OOooo........o    1247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1229                                                  1248 
1230                                                  1249