Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4VEmProcess.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/G4VEmProcess.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4VEmProcess.cc (Version 10.1.p2)


  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: G4VEmProcess.cc 88981 2015-03-17 10:14:15Z gcosmo $
                                                   >>  27 //
 26 // -------------------------------------------     28 // -------------------------------------------------------------------
 27 //                                                 29 //
 28 // GEANT4 Class file                               30 // GEANT4 Class file
 29 //                                                 31 //
 30 //                                                 32 //
 31 // File name:     G4VEmProcess                     33 // File name:     G4VEmProcess
 32 //                                                 34 //
 33 // Author:        Vladimir Ivanchenko on base      35 // Author:        Vladimir Ivanchenko on base of Laszlo Urban code
 34 //                                                 36 //
 35 // Creation date: 01.10.2003                       37 // Creation date: 01.10.2003
 36 //                                                 38 //
 37 // Modifications: by V.Ivanchenko              <<  39 // Modifications:
                                                   >>  40 // 30-06-04 make it to be pure discrete process (V.Ivanchenko)
                                                   >>  41 // 30-09-08 optimise integral option (V.Ivanchenko)
                                                   >>  42 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko)
                                                   >>  43 // 11-03-05 Shift verbose level by 1, add applyCuts and killPrimary flags (VI)
                                                   >>  44 // 14-03-05 Update logic PostStepDoIt (V.Ivanchenko)
                                                   >>  45 // 08-04-05 Major optimisation of internal interfaces (V.Ivanchenko)
                                                   >>  46 // 18-04-05 Use G4ParticleChangeForGamma (V.Ivanchenko)
                                                   >>  47 // 25-07-05 Add protection: integral mode only for charged particles (VI)
                                                   >>  48 // 04-09-05 default lambdaFactor 0.8 (V.Ivanchenko)
                                                   >>  49 // 11-01-06 add A to parameters of ComputeCrossSectionPerAtom (VI)
                                                   >>  50 // 12-09-06 add SetModel() (mma)
                                                   >>  51 // 12-04-07 remove double call to Clear model manager (V.Ivanchenko)
                                                   >>  52 // 27-10-07 Virtual functions moved to source (V.Ivanchenko)
                                                   >>  53 // 24-06-09 Removed hidden bin in G4PhysicsVector (V.Ivanchenko)
                                                   >>  54 // 17-02-10 Added pointer currentParticle (VI)
                                                   >>  55 // 30-05-12 allow Russian roulette, brem splitting (D. Sawkey)
 38 //                                                 56 //
 39 // Class Description: based class for discrete <<  57 // Class Description:
 40 //                                                 58 //
 41                                                    59 
 42 // -------------------------------------------     60 // -------------------------------------------------------------------
 43 //                                                 61 //
 44 //....oooOO0OOooo........oooOO0OOooo........oo     62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 45 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 46                                                    64 
 47 #include "G4VEmProcess.hh"                         65 #include "G4VEmProcess.hh"
 48 #include "G4PhysicalConstants.hh"                  66 #include "G4PhysicalConstants.hh"
 49 #include "G4SystemOfUnits.hh"                      67 #include "G4SystemOfUnits.hh"
 50 #include "G4ProcessManager.hh"                     68 #include "G4ProcessManager.hh"
 51 #include "G4LossTableManager.hh"                   69 #include "G4LossTableManager.hh"
 52 #include "G4LossTableBuilder.hh"                   70 #include "G4LossTableBuilder.hh"
 53 #include "G4Step.hh"                               71 #include "G4Step.hh"
 54 #include "G4ParticleDefinition.hh"                 72 #include "G4ParticleDefinition.hh"
 55 #include "G4VEmModel.hh"                           73 #include "G4VEmModel.hh"
 56 #include "G4DataVector.hh"                         74 #include "G4DataVector.hh"
 57 #include "G4PhysicsTable.hh"                       75 #include "G4PhysicsTable.hh"
 58 #include "G4EmDataHandler.hh"                  << 
 59 #include "G4PhysicsLogVector.hh"                   76 #include "G4PhysicsLogVector.hh"
 60 #include "G4VParticleChange.hh"                    77 #include "G4VParticleChange.hh"
 61 #include "G4ProductionCutsTable.hh"                78 #include "G4ProductionCutsTable.hh"
 62 #include "G4Region.hh"                             79 #include "G4Region.hh"
 63 #include "G4Gamma.hh"                              80 #include "G4Gamma.hh"
 64 #include "G4Electron.hh"                           81 #include "G4Electron.hh"
 65 #include "G4Positron.hh"                           82 #include "G4Positron.hh"
 66 #include "G4PhysicsTableHelper.hh"                 83 #include "G4PhysicsTableHelper.hh"
 67 #include "G4EmBiasingManager.hh"                   84 #include "G4EmBiasingManager.hh"
 68 #include "G4EmParameters.hh"                   << 
 69 #include "G4EmProcessSubType.hh"               << 
 70 #include "G4EmTableUtil.hh"                    << 
 71 #include "G4EmUtility.hh"                      << 
 72 #include "G4DNAModelSubType.hh"                << 
 73 #include "G4GenericIon.hh"                         85 #include "G4GenericIon.hh"
 74 #include "G4Log.hh"                                86 #include "G4Log.hh"
 75 #include <iostream>                            << 
 76                                                    87 
 77 //....oooOO0OOooo........oooOO0OOooo........oo     88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 78                                                    89 
 79 G4VEmProcess::G4VEmProcess(const G4String& nam     90 G4VEmProcess::G4VEmProcess(const G4String& name, G4ProcessType type):
 80   G4VDiscreteProcess(name, type)               <<  91   G4VDiscreteProcess(name, type),
                                                   >>  92   secondaryParticle(0),
                                                   >>  93   buildLambdaTable(true),
                                                   >>  94   numberOfModels(0),
                                                   >>  95   theLambdaTable(0),
                                                   >>  96   theLambdaTablePrim(0),
                                                   >>  97   theDensityFactor(0),
                                                   >>  98   theDensityIdx(0),
                                                   >>  99   integral(false),
                                                   >> 100   applyCuts(false),
                                                   >> 101   startFromNull(false),
                                                   >> 102   splineFlag(true),
                                                   >> 103   currentModel(0),
                                                   >> 104   particle(0),
                                                   >> 105   currentParticle(0),
                                                   >> 106   currentCouple(0)
 81 {                                                 107 {
 82   theParameters = G4EmParameters::Instance();     108   theParameters = G4EmParameters::Instance();
 83   SetVerboseLevel(1);                             109   SetVerboseLevel(1);
 84                                                   110 
 85   // Size of tables                            << 111   // Size of tables assuming spline
 86   minKinEnergy = 0.1*CLHEP::keV;               << 112   minKinEnergy = 0.1*keV;
 87   maxKinEnergy = 100.0*CLHEP::TeV;             << 113   maxKinEnergy = 10.0*TeV;
                                                   >> 114   nLambdaBins  = 77;
                                                   >> 115   minKinEnergyPrim = DBL_MAX;
                                                   >> 116   actBinning = false;
                                                   >> 117   actSpline = false;
                                                   >> 118   actMinKinEnergy = false;
                                                   >> 119   actMaxKinEnergy = false;
 88                                                   120 
 89   // default lambda factor                        121   // default lambda factor
 90   invLambdaFactor = 1.0/lambdaFactor;          << 122   lambdaFactor  = 0.8;
                                                   >> 123 
                                                   >> 124   // default limit on polar angle
                                                   >> 125   biasFactor = fFactor = 1.0;
 91                                                   126 
 92   // particle types                               127   // particle types
 93   theGamma = G4Gamma::Gamma();                 << 128   theGamma     = G4Gamma::Gamma();
 94   theElectron = G4Electron::Electron();        << 129   theElectron  = G4Electron::Electron();
 95   thePositron = G4Positron::Positron();        << 130   thePositron  = G4Positron::Positron();
                                                   >> 131 
                                                   >> 132   theCuts = theCutsGamma = theCutsElectron = theCutsPositron = 0;
 96                                                   133 
 97   pParticleChange = &fParticleChange;             134   pParticleChange = &fParticleChange;
 98   fParticleChange.SetSecondaryWeightByProcess(    135   fParticleChange.SetSecondaryWeightByProcess(true);
 99   secParticles.reserve(5);                        136   secParticles.reserve(5);
100                                                   137 
                                                   >> 138   baseMaterial = currentMaterial = 0;
                                                   >> 139 
                                                   >> 140   preStepLambda = preStepKinEnergy = 0.0;
                                                   >> 141   mfpKinEnergy  = DBL_MAX;
                                                   >> 142 
                                                   >> 143   idxLambda = idxLambdaPrim = currentCoupleIndex 
                                                   >> 144     = basedCoupleIndex = 0;
                                                   >> 145 
101   modelManager = new G4EmModelManager();          146   modelManager = new G4EmModelManager();
                                                   >> 147   biasManager  = 0;
                                                   >> 148   biasFlag     = false; 
                                                   >> 149   weightFlag   = false;
102   lManager = G4LossTableManager::Instance();      150   lManager = G4LossTableManager::Instance();
103   lManager->Register(this);                       151   lManager->Register(this);
104   isTheMaster = lManager->IsMaster();          << 152   secID = fluoID = augerID = biasID = -1;
105   G4LossTableBuilder* bld = lManager->GetTable << 153   mainSecondaries = 100;
106   theDensityFactor = bld->GetDensityFactors(); << 154   if("phot" == GetProcessName() || "compt" == GetProcessName()) { 
107   theDensityIdx = bld->GetCoupleIndexes();     << 155     mainSecondaries = 1; 
                                                   >> 156   }
108 }                                                 157 }
109                                                   158 
110 //....oooOO0OOooo........oooOO0OOooo........oo    159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
111                                                   160 
112 G4VEmProcess::~G4VEmProcess()                     161 G4VEmProcess::~G4VEmProcess()
113 {                                                 162 {
114   if(isTheMaster) {                            << 163   /*
115     delete theData;                            << 164   if(1 < verboseLevel) {
116     delete theEnergyOfCrossSectionMax;         << 165     G4cout << "G4VEmProcess destruct " << GetProcessName() 
                                                   >> 166      << "  " << this << "  " <<  theLambdaTable <<G4endl;
                                                   >> 167   }
                                                   >> 168   */
                                                   >> 169   if(lManager->IsMaster()) {
                                                   >> 170     if(theLambdaTable) {
                                                   >> 171       theLambdaTable->clearAndDestroy();
                                                   >> 172       delete theLambdaTable;
                                                   >> 173     }
                                                   >> 174     if(theLambdaTablePrim) {
                                                   >> 175       theLambdaTablePrim->clearAndDestroy();
                                                   >> 176       delete theLambdaTablePrim;
                                                   >> 177     }
                                                   >> 178     G4PhysicsModelCatalog::Destroy();
117   }                                               179   }
118   delete modelManager;                            180   delete modelManager;
119   delete biasManager;                             181   delete biasManager;
120   lManager->DeRegister(this);                     182   lManager->DeRegister(this);
                                                   >> 183   //G4cout << "G4VEmProcess removed " << G4endl; 
121 }                                                 184 }
122                                                   185 
123 //....oooOO0OOooo........oooOO0OOooo........oo    186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
124                                                   187 
125 void G4VEmProcess::AddEmModel(G4int order, G4V << 188 void G4VEmProcess::Clear()
126                               const G4Region*  << 
127 {                                                 189 {
128   if(nullptr == ptr) { return; }               << 190   currentCouple = 0;
129   G4VEmFluctuationModel* fm = nullptr;         << 191   preStepLambda = 0.0;
130   modelManager->AddEmModel(order, ptr, fm, reg << 192   mfpKinEnergy  = DBL_MAX;
131   ptr->SetParticleChange(pParticleChange);     << 193   idxLambda = idxLambdaPrim = 0;
132 }                                                 194 }
133                                                   195 
134 //....oooOO0OOooo........oooOO0OOooo........oo    196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
135                                                   197 
136 void G4VEmProcess::SetEmModel(G4VEmModel* ptr, << 198 G4double G4VEmProcess::MinPrimaryEnergy(const G4ParticleDefinition*,
                                                   >> 199           const G4Material*)
137 {                                                 200 {
138   if(nullptr == ptr) { return; }               << 201   return 0.0;
139   if(!emModels.empty()) {                      << 202 }
140     for(auto & em : emModels) { if(em == ptr)  << 203 
141   }                                            << 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
142   emModels.push_back(ptr);                     << 205 
                                                   >> 206 void G4VEmProcess::AddEmModel(G4int order, G4VEmModel* p, 
                                                   >> 207             const G4Region* region)
                                                   >> 208 {
                                                   >> 209   G4VEmFluctuationModel* fm = 0;
                                                   >> 210   modelManager->AddEmModel(order, p, fm, region);
                                                   >> 211   if(p) { p->SetParticleChange(pParticleChange); }
                                                   >> 212 }
                                                   >> 213 
                                                   >> 214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 215 
                                                   >> 216 void G4VEmProcess::SetEmModel(G4VEmModel* p, G4int index) 
                                                   >> 217 {
                                                   >> 218   G4int n = emModels.size();
                                                   >> 219   if(index >= n) { for(G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
                                                   >> 220   emModels[index] = p;
                                                   >> 221 }
                                                   >> 222 
                                                   >> 223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 224 
                                                   >> 225 G4VEmModel* G4VEmProcess::EmModel(G4int index) const
                                                   >> 226 {
                                                   >> 227   G4VEmModel* p = 0;
                                                   >> 228   if(index >= 0 && index <  G4int(emModels.size())) { p = emModels[index]; }
                                                   >> 229   return p;
                                                   >> 230 }
                                                   >> 231 
                                                   >> 232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 233 
                                                   >> 234 void G4VEmProcess::UpdateEmModel(const G4String& nam, 
                                                   >> 235          G4double emin, G4double emax)
                                                   >> 236 {
                                                   >> 237   modelManager->UpdateEmModel(nam, emin, emax);
                                                   >> 238 }
                                                   >> 239 
                                                   >> 240 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 241 
                                                   >> 242 G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) const
                                                   >> 243 {
                                                   >> 244   return modelManager->GetModel(idx, ver);
143 }                                                 245 }
144                                                   246 
145 //....oooOO0OOooo........oooOO0OOooo........oo    247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
146                                                   248 
147 void G4VEmProcess::PreparePhysicsTable(const G    249 void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
148 {                                                 250 {
149   if(nullptr == particle) { SetParticle(&part) << 251   G4bool isMaster = true;
                                                   >> 252   const G4VEmProcess* masterProcess = 
                                                   >> 253     static_cast<const G4VEmProcess*>(GetMasterProcess());
                                                   >> 254   if(masterProcess && masterProcess != this) { isMaster = false; }
                                                   >> 255 
                                                   >> 256   if(!particle) { SetParticle(&part); }
150                                                   257 
151   if(part.GetParticleType() == "nucleus" &&       258   if(part.GetParticleType() == "nucleus" && 
152      part.GetParticleSubType() == "generic") {    259      part.GetParticleSubType() == "generic") {
153                                                   260 
154     G4String pname = part.GetParticleName();      261     G4String pname = part.GetParticleName();
155     if(pname != "deuteron" && pname != "triton    262     if(pname != "deuteron" && pname != "triton" &&
156        pname != "He3" && pname != "alpha" && p << 263        pname != "alpha" && pname != "He3" &&
157        pname != "helium" && pname != "hydrogen << 264        pname != "alpha+"   && pname != "helium" &&
                                                   >> 265        pname != "hydrogen") {
158                                                   266 
159       particle = G4GenericIon::GenericIon();      267       particle = G4GenericIon::GenericIon();
160       isIon = true;                            << 
161     }                                             268     }
162   }                                               269   }
                                                   >> 270 
                                                   >> 271   if(1 < verboseLevel) {
                                                   >> 272     G4cout << "G4VEmProcess::PreparePhysicsTable() for "
                                                   >> 273            << GetProcessName()
                                                   >> 274            << " and particle " << part.GetParticleName()
                                                   >> 275      << " local particle " << particle->GetParticleName() 
                                                   >> 276            << G4endl;
                                                   >> 277   }
                                                   >> 278 
163   if(particle != &part) { return; }               279   if(particle != &part) { return; }
164                                                   280 
165   lManager->PreparePhysicsTable(&part, this);  << 281   G4LossTableBuilder* bld = lManager->GetTableBuilder();
166                                                   282 
167   // for new run                               << 283   lManager->PreparePhysicsTable(&part, this, isMaster);
168   currentCouple = nullptr;                     << 
169   preStepLambda = 0.0;                         << 
170   fLambdaEnergy = 0.0;                         << 
171                                                   284 
                                                   >> 285   Clear();
172   InitialiseProcess(particle);                    286   InitialiseProcess(particle);
173                                                   287 
174   G4LossTableBuilder* bld = lManager->GetTable << 
175   const G4ProductionCutsTable* theCoupleTable=    288   const G4ProductionCutsTable* theCoupleTable=
176     G4ProductionCutsTable::GetProductionCutsTa    289     G4ProductionCutsTable::GetProductionCutsTable();
177   theCutsGamma    = theCoupleTable->GetEnergyC << 290   size_t n = theCoupleTable->GetTableSize();
178   theCutsElectron = theCoupleTable->GetEnergyC << 291 
179   theCutsPositron = theCoupleTable->GetEnergyC << 292   theEnergyOfCrossSectionMax.resize(n, 0.0);
                                                   >> 293   theCrossSectionMax.resize(n, DBL_MAX);
180                                                   294 
181   // initialisation of the process                295   // initialisation of the process  
182   if(!actMinKinEnergy) { minKinEnergy = thePar    296   if(!actMinKinEnergy) { minKinEnergy = theParameters->MinKinEnergy(); }
183   if(!actMaxKinEnergy) { maxKinEnergy = thePar    297   if(!actMaxKinEnergy) { maxKinEnergy = theParameters->MaxKinEnergy(); }
                                                   >> 298   if(isMaster) { SetVerboseLevel(theParameters->Verbose()); }
                                                   >> 299   else {  SetVerboseLevel(theParameters->WorkerVerbose()); }
                                                   >> 300   applyCuts = theParameters->ApplyCuts();
                                                   >> 301   lambdaFactor = theParameters->LambdaFactor();
184                                                   302 
185   applyCuts       = theParameters->ApplyCuts() << 303   // initialisation of models
186   lambdaFactor    = theParameters->LambdaFacto << 304   numberOfModels = modelManager->NumberOfModels();
187   invLambdaFactor = 1.0/lambdaFactor;          << 305   for(G4int i=0; i<numberOfModels; ++i) {
188   theParameters->DefineRegParamForEM(this);    << 306     G4VEmModel* mod = modelManager->GetModel(i);
                                                   >> 307     if(0 == i) { currentModel = mod; }
                                                   >> 308     mod->SetPolarAngleLimit(theParameters->MscThetaLimit());
                                                   >> 309     mod->SetMasterThread(isMaster);
                                                   >> 310     if(mod->HighEnergyLimit() > maxKinEnergy) {
                                                   >> 311       mod->SetHighEnergyLimit(maxKinEnergy);
                                                   >> 312     }
                                                   >> 313   }
189                                                   314 
190   // integral option may be disabled           << 315   if(lManager->AtomDeexcitation()) { modelManager->SetFluoFlag(true); }
191   if(!theParameters->Integral()) { fXSType = f << 316   theCuts = modelManager->Initialise(particle,secondaryParticle,
                                                   >> 317              2.,verboseLevel);
                                                   >> 318   theCutsGamma    = theCoupleTable->GetEnergyCutsVector(idxG4GammaCut);
                                                   >> 319   theCutsElectron = theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut);
                                                   >> 320   theCutsPositron = theCoupleTable->GetEnergyCutsVector(idxG4PositronCut);
192                                                   321 
193   // prepare tables                               322   // prepare tables
194   if(isTheMaster) {                            << 323   if(buildLambdaTable && isMaster){
195     if(nullptr == theData) { theData = new G4E << 324     theLambdaTable = 
196                                                << 325       G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTable);
197     if(buildLambdaTable) {                     << 326     bld->InitialiseBaseMaterials(theLambdaTable);
198       theLambdaTable = theData->MakeTable(0);  << 327   }
199       bld->InitialiseBaseMaterials(theLambdaTa << 328   // high energy table
200     }                                          << 329   if(isMaster && minKinEnergyPrim < maxKinEnergy){
201     // high energy table                       << 330     theLambdaTablePrim = 
202     if(minKinEnergyPrim < maxKinEnergy) {      << 331       G4PhysicsTableHelper::PreparePhysicsTable(theLambdaTablePrim);
203       theLambdaTablePrim = theData->MakeTable( << 332     bld->InitialiseBaseMaterials(theLambdaTablePrim);
204       bld->InitialiseBaseMaterials(theLambdaTa << 
205     }                                          << 
206   }                                            << 
207   // models                                    << 
208   baseMat = bld->GetBaseMaterialFlag();        << 
209   numberOfModels = modelManager->NumberOfModel << 
210   currentModel = modelManager->GetModel(0);    << 
211   if(nullptr != lManager->AtomDeexcitation())  << 
212     modelManager->SetFluoFlag(true);           << 
213   }                                               333   }
214   // forced biasing                               334   // forced biasing
215   if(nullptr != biasManager) {                 << 335   if(biasManager) { 
216     biasManager->Initialise(part, GetProcessNa << 336     biasManager->Initialise(part,GetProcessName(),verboseLevel); 
217     biasFlag = false;                          << 337     biasFlag = false; 
218   }                                            << 338   }
219                                                << 339   // defined ID of secondary particles
220   theCuts =                                    << 340   G4String nam1 = GetProcessName();
221     G4EmTableUtil::PrepareEmProcess(this, part << 341   G4String nam2 = nam1 + "_fluo" ;
222                                     modelManag << 342   G4String nam3 = nam1 + "_auger";
223                                     secID, tri << 343   G4String nam4 = nam1 + "_split";
224                                     verboseLev << 344   secID   = G4PhysicsModelCatalog::Register(nam1); 
                                                   >> 345   fluoID  = G4PhysicsModelCatalog::Register(nam2); 
                                                   >> 346   augerID = G4PhysicsModelCatalog::Register(nam3); 
                                                   >> 347   biasID  = G4PhysicsModelCatalog::Register(nam4); 
225 }                                                 348 }
226                                                   349 
227 //....oooOO0OOooo........oooOO0OOooo........oo    350 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
228                                                   351 
229 void G4VEmProcess::BuildPhysicsTable(const G4P    352 void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
230 {                                                 353 {
231   if(nullptr == masterProc) {                  << 354   G4bool isMaster = true;
232     if(isTheMaster) { masterProc = this; }     << 355   const G4VEmProcess* masterProc = 
233     else { masterProc = static_cast<const G4VE << 356     static_cast<const G4VEmProcess*>(GetMasterProcess());
234   }                                            << 357   if(masterProc && masterProc != this) { isMaster = false; }
235   G4int nModels = modelManager->NumberOfModels << 358 
236   G4bool isLocked = theParameters->IsPrintLock << 359   G4String num = part.GetParticleName();
237   G4bool toBuild = (buildLambdaTable || minKin << 360   if(1 < verboseLevel) {
238                                                << 361     G4cout << "### G4VEmProcess::BuildPhysicsTable() for "
239   G4EmTableUtil::BuildEmProcess(this, masterPr << 362            << GetProcessName()
240                                 nModels, verbo << 363            << " and particle " << num
241                                 isLocked, toBu << 364      << " buildLambdaTable= " << buildLambdaTable
                                                   >> 365      << " isMaster= " << isMaster 
                                                   >> 366            << G4endl;
                                                   >> 367   }
                                                   >> 368 
                                                   >> 369   if(particle == &part) { 
                                                   >> 370 
                                                   >> 371     G4LossTableBuilder* bld = lManager->GetTableBuilder();
                                                   >> 372 
                                                   >> 373     // worker initialisation
                                                   >> 374     if(!isMaster) {
                                                   >> 375       theLambdaTable = masterProc->LambdaTable();
                                                   >> 376       theLambdaTablePrim = masterProc->LambdaTablePrim();
                                                   >> 377 
                                                   >> 378       if(theLambdaTable) {
                                                   >> 379   bld->InitialiseBaseMaterials(theLambdaTable);
                                                   >> 380       } else if(theLambdaTablePrim) {
                                                   >> 381   bld->InitialiseBaseMaterials(theLambdaTablePrim);
                                                   >> 382       }
                                                   >> 383       theDensityFactor = bld->GetDensityFactors();
                                                   >> 384       theDensityIdx = bld->GetCoupleIndexes();
                                                   >> 385       if(theLambdaTable) { FindLambdaMax(); }
                                                   >> 386 
                                                   >> 387       // local initialisation of models
                                                   >> 388       G4bool printing = true;
                                                   >> 389       numberOfModels = modelManager->NumberOfModels();
                                                   >> 390       for(G4int i=0; i<numberOfModels; ++i) {
                                                   >> 391   G4VEmModel* mod = GetModelByIndex(i, printing);
                                                   >> 392   G4VEmModel* mod0= masterProc->GetModelByIndex(i, printing);
                                                   >> 393   mod->InitialiseLocal(particle, mod0);
                                                   >> 394       }
                                                   >> 395     // master thread
                                                   >> 396     } else {
                                                   >> 397       theDensityFactor = bld->GetDensityFactors();
                                                   >> 398       theDensityIdx = bld->GetCoupleIndexes();
                                                   >> 399       if(buildLambdaTable || minKinEnergyPrim < maxKinEnergy) {
                                                   >> 400   BuildLambdaTable();
                                                   >> 401       }
                                                   >> 402     }
                                                   >> 403   }
                                                   >> 404 
                                                   >> 405   // explicitly defined printout by particle name
                                                   >> 406   if(1 < verboseLevel || 
                                                   >> 407      (0 < verboseLevel && (num == "gamma" || num == "e-" || 
                                                   >> 408          num == "e+"    || num == "mu+" || 
                                                   >> 409          num == "mu-"   || num == "proton"|| 
                                                   >> 410          num == "pi+"   || num == "pi-" || 
                                                   >> 411          num == "kaon+" || num == "kaon-" || 
                                                   >> 412          num == "alpha" || num == "anti_proton" || 
                                                   >> 413          num == "GenericIon")))
                                                   >> 414     { 
                                                   >> 415       PrintInfoProcess(part); 
                                                   >> 416     }
                                                   >> 417 
                                                   >> 418   if(1 < verboseLevel) {
                                                   >> 419     G4cout << "### G4VEmProcess::BuildPhysicsTable() done for "
                                                   >> 420            << GetProcessName()
                                                   >> 421            << " and particle " << num
                                                   >> 422            << G4endl;
                                                   >> 423   }
242 }                                                 424 }
243                                                   425 
244 //....oooOO0OOooo........oooOO0OOooo........oo    426 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
245                                                   427 
246 void G4VEmProcess::BuildLambdaTable()             428 void G4VEmProcess::BuildLambdaTable()
247 {                                                 429 {
248   G4double scale = theParameters->MaxKinEnergy << 430   if(1 < verboseLevel) {
249   G4int nbin =                                 << 431     G4cout << "G4EmProcess::BuildLambdaTable() for process "
250     theParameters->NumberOfBinsPerDecade()*G4l << 432            << GetProcessName() << " and particle "
251   if(actBinning) { nbin = std::max(nbin, nLamb << 433            << particle->GetParticleName() << "  " << this
252   scale = nbin/G4Log(scale);                   << 434            << G4endl;
253                                                << 435   }
                                                   >> 436 
                                                   >> 437   // Access to materials
                                                   >> 438   const G4ProductionCutsTable* theCoupleTable=
                                                   >> 439         G4ProductionCutsTable::GetProductionCutsTable();
                                                   >> 440   size_t numOfCouples = theCoupleTable->GetTableSize();
                                                   >> 441 
254   G4LossTableBuilder* bld = lManager->GetTable    442   G4LossTableBuilder* bld = lManager->GetTableBuilder();
255   G4EmTableUtil::BuildLambdaTable(this, partic << 443 
256                                   bld, theLamb << 444   G4PhysicsLogVector* aVector = 0;
257                                   minKinEnergy << 445   G4PhysicsLogVector* aVectorPrim = 0;
258                                   maxKinEnergy << 446   G4PhysicsLogVector* bVectorPrim = 0;
259                                   startFromNul << 447 
                                                   >> 448   G4double scale = 
                                                   >> 449     G4Log(theParameters->MaxKinEnergy()/theParameters->MinKinEnergy()); 
                                                   >> 450   G4int nbin = theParameters->NumberOfBins();
                                                   >> 451   if(actBinning) { nbin = std::max(nbin, nLambdaBins); }
                                                   >> 452   G4double emax1 = std::min(maxKinEnergy, minKinEnergyPrim);
                                                   >> 453   if(!actSpline) { splineFlag = theParameters->Spline(); }
                                                   >> 454     
                                                   >> 455   for(size_t i=0; i<numOfCouples; ++i) {
                                                   >> 456 
                                                   >> 457     if (bld->GetFlag(i)) {
                                                   >> 458 
                                                   >> 459       // create physics vector and fill it
                                                   >> 460       const G4MaterialCutsCouple* couple = 
                                                   >> 461   theCoupleTable->GetMaterialCutsCouple(i);
                                                   >> 462 
                                                   >> 463       // build main table
                                                   >> 464       if(buildLambdaTable) {
                                                   >> 465   delete (*theLambdaTable)[i];
                                                   >> 466 
                                                   >> 467   // if start from zero then change the scale
                                                   >> 468   G4double emin = minKinEnergy;
                                                   >> 469   G4bool startNull = false;
                                                   >> 470   if(startFromNull) {
                                                   >> 471     G4double e = MinPrimaryEnergy(particle,couple->GetMaterial());
                                                   >> 472           if(e >= emin) {
                                                   >> 473       emin = e;
                                                   >> 474       startNull = true;
                                                   >> 475     }
                                                   >> 476   }
                                                   >> 477   G4double emax = emax1;
                                                   >> 478   if(emax <= emin) { emax = 2*emin; }
                                                   >> 479   G4int bin = G4lrint(nbin*G4Log(emax/emin)/scale);
                                                   >> 480   if(bin < 3) { bin = 3; }
                                                   >> 481   aVector = new G4PhysicsLogVector(emin, emax, bin);
                                                   >> 482   aVector->SetSpline(splineFlag);
                                                   >> 483   modelManager->FillLambdaVector(aVector, couple, startNull);
                                                   >> 484   if(splineFlag) { aVector->FillSecondDerivatives(); }
                                                   >> 485   G4PhysicsTableHelper::SetPhysicsVector(theLambdaTable, i, aVector);
                                                   >> 486       }
                                                   >> 487       // build high energy table 
                                                   >> 488       if(minKinEnergyPrim < maxKinEnergy) { 
                                                   >> 489   delete (*theLambdaTablePrim)[i];
                                                   >> 490 
                                                   >> 491   // start not from zero
                                                   >> 492   if(!bVectorPrim) {
                                                   >> 493     G4int bin = G4lrint(nbin*G4Log(maxKinEnergy/minKinEnergyPrim)/scale);
                                                   >> 494     if(bin < 3) { bin = 3; }
                                                   >> 495     aVectorPrim = 
                                                   >> 496       new G4PhysicsLogVector(minKinEnergyPrim, maxKinEnergy, bin);
                                                   >> 497     bVectorPrim = aVectorPrim;
                                                   >> 498   } else {
                                                   >> 499     aVectorPrim = new G4PhysicsLogVector(*bVectorPrim);
                                                   >> 500   }
                                                   >> 501   // always use spline
                                                   >> 502   aVectorPrim->SetSpline(splineFlag);
                                                   >> 503   modelManager->FillLambdaVector(aVectorPrim, couple, false, 
                                                   >> 504                fIsCrossSectionPrim);
                                                   >> 505   aVectorPrim->FillSecondDerivatives();
                                                   >> 506   G4PhysicsTableHelper::SetPhysicsVector(theLambdaTablePrim, i, 
                                                   >> 507                  aVectorPrim);
                                                   >> 508       }
                                                   >> 509     }
                                                   >> 510   }
                                                   >> 511 
                                                   >> 512   if(buildLambdaTable) { FindLambdaMax(); }
                                                   >> 513 
                                                   >> 514   if(1 < verboseLevel) {
                                                   >> 515     G4cout << "Lambda table is built for "
                                                   >> 516            << particle->GetParticleName()
                                                   >> 517            << G4endl;
                                                   >> 518   }
260 }                                                 519 }
261                                                   520 
262 //....oooOO0OOooo........oooOO0OOooo........oo    521 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
263                                                   522 
264 void G4VEmProcess::StreamInfo(std::ostream& ou << 523 void G4VEmProcess::PrintInfoProcess(const G4ParticleDefinition& part)
265                   const G4ParticleDefinition&  << 524 {
266 {                                              << 525   if(verboseLevel > 0) {
267   G4String indent = (rst ? "  " : "");         << 526     G4cout << std::setprecision(6);
268   out << std::setprecision(6);                 << 527     G4cout << G4endl << GetProcessName() << ":   for  "
269   out << G4endl << indent << GetProcessName()  << 528            << part.GetParticleName();
270   if (!rst) {                                  << 529     if(integral)  { G4cout << ", integral: 1 "; }
271     out << " for " << part.GetParticleName();  << 530     if(applyCuts) { G4cout << ", applyCuts: 1 "; }
272   }                                            << 531     G4cout << "    SubType= " << GetProcessSubType();;
273   if(fXSType != fEmNoIntegral)  { out << " XSt << 532     if(biasFactor != 1.0) { G4cout << "   BiasingFactor= " << biasFactor; }
274   if(applyCuts) { out << " applyCuts:1 "; }    << 533     G4cout << "  BuildTable= " << buildLambdaTable;
275   G4int subtype = GetProcessSubType();         << 534     G4cout << G4endl;
276   out << " SubType=" << subtype;               << 535     if(buildLambdaTable) {
277   if (subtype == fAnnihilation) {              << 536       if(particle == &part) { 
278     G4int mod = theParameters->PositronAtRestM << 537   size_t length = theLambdaTable->length();
279     const G4String namp[2] = {"Simple", "Allis << 538   for(size_t i=0; i<length; ++i) {
280     out << " AtRestModel:" << namp[mod];       << 539     G4PhysicsVector* v = (*theLambdaTable)[i];
281   }                                            << 540     if(v) { 
282   if(biasFactor != 1.0) { out << "  BiasingFac << 541       G4cout << "      Lambda table from ";
283   out << " BuildTable=" << buildLambdaTable << << 542       G4double emin = v->Energy(0);
284   if(buildLambdaTable) {                       << 543       G4double emax = v->GetMaxEnergy();
285     if(particle == &part) {                    << 544       G4int nbin = v->GetVectorLength() - 1;
286       for(auto & v : *theLambdaTable) {        << 545       if(emin > minKinEnergy) { G4cout << "threshold "; }
287         if(nullptr != v) {                     << 546       else { G4cout << G4BestUnit(emin,"Energy"); } 
288           out << "      Lambda table from ";   << 547       G4cout << " to "
289           G4double emin = v->Energy(0);        << 548        << G4BestUnit(emax,"Energy")
290           G4double emax = v->GetMaxEnergy();   << 549        << ", " << G4lrint(nbin/std::log10(emax/emin))
291           G4int nbin = G4int(v->GetVectorLengt << 550        << " bins per decade, spline: " 
292           if(emin > minKinEnergy) { out << "th << 551        << splineFlag
293           else { out << G4BestUnit(emin,"Energ << 552        << G4endl;
294           out << " to "                        << 553       break;
295               << G4BestUnit(emax,"Energy")     << 554     }
296               << ", " << G4lrint(nbin/std::log << 555   }
297               << " bins/decade, spline: "      << 556       } else {
298               << splineFlag << G4endl;         << 557   G4cout << "      Used Lambda table of " 
299           break;                               << 558          << particle->GetParticleName() << G4endl;;
300         }                                      << 
301       }                                           559       }
302     } else {                                   << 
303       out << "      Used Lambda table of "     << 
304       << particle->GetParticleName() << G4endl << 
305     }                                             560     }
306   }                                            << 561     if(minKinEnergyPrim < maxKinEnergy) {
307   if(minKinEnergyPrim < maxKinEnergy) {        << 562       if(particle == &part) { 
308     if(particle == &part) {                    << 563   size_t length = theLambdaTablePrim->length();
309       for(auto & v : *theLambdaTablePrim) {    << 564   for(size_t i=0; i<length; ++i) {
310         if(nullptr != v) {                     << 565     G4PhysicsVector* v = (*theLambdaTablePrim)[i];
311           out << "      LambdaPrime table from << 566     if(v) { 
312               << G4BestUnit(v->Energy(0),"Ener << 567       G4cout << "      LambdaPrime table from "
313               << " to "                        << 568        << G4BestUnit(v->Energy(0),"Energy") 
314               << G4BestUnit(v->GetMaxEnergy(), << 569        << " to "
315               << " in " << v->GetVectorLength( << 570        << G4BestUnit(v->GetMaxEnergy(),"Energy")
316               << " bins " << G4endl;           << 571        << " in " << v->GetVectorLength()-1
317           break;                               << 572        << " bins " 
318         }                                      << 573        << G4endl;
                                                   >> 574       break;
                                                   >> 575     }
                                                   >> 576   }
                                                   >> 577       } else {
                                                   >> 578   G4cout << "      Used LambdaPrime table of " 
                                                   >> 579          << particle->GetParticleName() << G4endl;;
319       }                                           580       }
320     } else {                                   << 
321       out << "      Used LambdaPrime table of  << 
322                << particle->GetParticleName()  << 
323     }                                             581     }
                                                   >> 582     PrintInfo();
                                                   >> 583     modelManager->DumpModelList(verboseLevel);
324   }                                               584   }
325   StreamProcessInfo(out);                      << 
326   modelManager->DumpModelList(out, verboseLeve << 
327                                                   585 
328   if(verboseLevel > 2 && buildLambdaTable) {      586   if(verboseLevel > 2 && buildLambdaTable) {
329     out << "      LambdaTable address= " << th << 587     G4cout << "      LambdaTable address= " << theLambdaTable << G4endl;
330     if(theLambdaTable && particle == &part) {     588     if(theLambdaTable && particle == &part) { 
331       out << (*theLambdaTable) << G4endl;      << 589       G4cout << (*theLambdaTable) << G4endl; 
332     }                                             590     }
333   }                                               591   }
334 }                                                 592 }
335                                                   593 
336 //....oooOO0OOooo........oooOO0OOooo........oo    594 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
337                                                   595 
338 void G4VEmProcess::StartTracking(G4Track* trac    596 void G4VEmProcess::StartTracking(G4Track* track)
339 {                                                 597 {
340   // reset parameters for the new track           598   // reset parameters for the new track
341   currentParticle = track->GetParticleDefiniti    599   currentParticle = track->GetParticleDefinition();
342   theNumberOfInteractionLengthLeft = -1.0;        600   theNumberOfInteractionLengthLeft = -1.0;
343   mfpKinEnergy = DBL_MAX;                      << 601   mfpKinEnergy = DBL_MAX; 
344   preStepLambda = 0.0;                         << 
345                                                << 
346   if(isIon) { massRatio = proton_mass_c2/curre << 
347                                                   602 
348   // forced biasing only for primary particles    603   // forced biasing only for primary particles
349   if(biasManager) {                               604   if(biasManager) {
350     if(0 == track->GetParentID()) {               605     if(0 == track->GetParentID()) {
351       // primary particle                         606       // primary particle
352       biasFlag = true;                            607       biasFlag = true; 
353       biasManager->ResetForcedInteraction();      608       biasManager->ResetForcedInteraction(); 
354     }                                             609     }
355   }                                               610   }
356 }                                                 611 }
357                                                   612 
358 //....oooOO0OOooo........oooOO0OOooo........oo    613 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
359                                                   614 
360 G4double G4VEmProcess::PostStepGetPhysicalInte    615 G4double G4VEmProcess::PostStepGetPhysicalInteractionLength(
361                              const G4Track& tr    616                              const G4Track& track,
362                              G4double   previo    617                              G4double   previousStepSize,
363                              G4ForceCondition*    618                              G4ForceCondition* condition)
364 {                                                 619 {
365   *condition = NotForced;                         620   *condition = NotForced;
366   G4double x = DBL_MAX;                           621   G4double x = DBL_MAX;
367                                                   622 
368   DefineMaterial(track.GetMaterialCutsCouple() << 
369   preStepKinEnergy = track.GetKineticEnergy();    623   preStepKinEnergy = track.GetKineticEnergy();
370   const G4double scaledEnergy = preStepKinEner << 624   DefineMaterial(track.GetMaterialCutsCouple());
371   SelectModel(scaledEnergy, currentCoupleIndex << 625   SelectModel(preStepKinEnergy, currentCoupleIndex);
372   /*                                           << 626 
373   G4cout << "PostStepGetPhysicalInteractionLen << 627   if(!currentModel->IsActive(preStepKinEnergy)) { 
374          << "  couple: " << currentCouple << G << 
375   */                                           << 
376   if(!currentModel->IsActive(scaledEnergy)) {  << 
377     theNumberOfInteractionLengthLeft = -1.0;      628     theNumberOfInteractionLengthLeft = -1.0;
378     currentInteractionLength = DBL_MAX;           629     currentInteractionLength = DBL_MAX;
379     mfpKinEnergy = DBL_MAX;                    << 
380     preStepLambda = 0.0;                       << 
381     return x;                                     630     return x; 
382   }                                               631   }
383                                                   632  
384   // forced biasing only for primary particles    633   // forced biasing only for primary particles
385   if(biasManager) {                               634   if(biasManager) {
386     if(0 == track.GetParentID()) {                635     if(0 == track.GetParentID()) {
387       if(biasFlag &&                              636       if(biasFlag && 
388          biasManager->ForcedInteractionRegion( << 637    biasManager->ForcedInteractionRegion(currentCoupleIndex)) {
389         return biasManager->GetStepLimit((G4in << 638         return biasManager->GetStepLimit(currentCoupleIndex, previousStepSize);
390       }                                           639       }
391     }                                             640     }
392   }                                               641   }
393                                                   642 
394   // compute mean free path                       643   // compute mean free path
                                                   >> 644   if(preStepKinEnergy < mfpKinEnergy) {
                                                   >> 645     if (integral) { ComputeIntegralLambda(preStepKinEnergy); }
                                                   >> 646     else { preStepLambda = GetCurrentLambda(preStepKinEnergy); }
                                                   >> 647 
                                                   >> 648     // zero cross section
                                                   >> 649     if(preStepLambda <= 0.0) { 
                                                   >> 650       theNumberOfInteractionLengthLeft = -1.0;
                                                   >> 651       currentInteractionLength = DBL_MAX;
                                                   >> 652     }
                                                   >> 653   }
395                                                   654 
396   ComputeIntegralLambda(preStepKinEnergy, trac << 655   // non-zero cross section
397                                                << 656   if(preStepLambda > 0.0) { 
398   // zero cross section                        << 
399   if(preStepLambda <= 0.0) {                   << 
400     theNumberOfInteractionLengthLeft = -1.0;   << 
401     currentInteractionLength = DBL_MAX;        << 
402                                                << 
403   } else {                                     << 
404                                                   657 
405     // non-zero cross section                  << 
406     if (theNumberOfInteractionLengthLeft < 0.0    658     if (theNumberOfInteractionLengthLeft < 0.0) {
407                                                   659 
408       // beggining of tracking (or just after     660       // beggining of tracking (or just after DoIt of this process)
409       theNumberOfInteractionLengthLeft = -G4Lo << 661       theNumberOfInteractionLengthLeft =  -G4Log( G4UniformRand() );
410       theInitialNumberOfInteractionLength = th    662       theInitialNumberOfInteractionLength = theNumberOfInteractionLengthLeft; 
411                                                   663 
412     } else {                                   << 664     } else if(currentInteractionLength < DBL_MAX) {
413                                                   665 
                                                   >> 666       // subtract NumberOfInteractionLengthLeft using previous step
414       theNumberOfInteractionLengthLeft -=         667       theNumberOfInteractionLengthLeft -= 
415         previousStepSize/currentInteractionLen << 668   previousStepSize/currentInteractionLength;
                                                   >> 669       //SubtractNumberOfInteractionLengthLeft(previousStepSize);
416       theNumberOfInteractionLengthLeft =          670       theNumberOfInteractionLengthLeft = 
417         std::max(theNumberOfInteractionLengthL << 671   std::max(theNumberOfInteractionLengthLeft, 0.0);
418     }                                             672     }
419                                                   673 
420     // new mean free path and step limit for t    674     // new mean free path and step limit for the next step
421     currentInteractionLength = 1.0/preStepLamb    675     currentInteractionLength = 1.0/preStepLambda;
422     x = theNumberOfInteractionLengthLeft * cur    676     x = theNumberOfInteractionLengthLeft * currentInteractionLength;
423   }                                            << 677     /*
424   return x;                                    << 678 #ifdef G4VERBOSE
425 }                                              << 679     if (verboseLevel>2){
426                                                << 680       G4cout << "G4VEmProcess::PostStepGetPhysicalInteractionLength ";
427 //....oooOO0OOooo........oooOO0OOooo........oo << 681       G4cout << "[ " << GetProcessName() << "]" << G4endl; 
428                                                << 682       G4cout << " for " << currentParticle->GetParticleName() 
429 void G4VEmProcess::ComputeIntegralLambda(G4dou << 683        << " in Material  " <<  currentMaterial->GetName()
430 {                                              << 684        << " Ekin(MeV)= " << preStepKinEnergy/MeV 
431   if (fXSType == fEmNoIntegral) {              << 685        <<G4endl;
432     preStepLambda = GetCurrentLambda(e, LogEki << 686       G4cout << " MeanFreePath = " << currentInteractionLength/cm << "[cm]" 
433                                                << 687        << " InteractionLength= " << x/cm <<"[cm] " <<G4endl;
434   } else if (fXSType == fEmIncreasing) {       << 
435     if(e*invLambdaFactor < mfpKinEnergy) {     << 
436       preStepLambda = GetCurrentLambda(e, LogE << 
437       mfpKinEnergy = (preStepLambda > 0.0) ? e << 
438     }                                          << 
439                                                << 
440   } else if(fXSType == fEmDecreasing) {        << 
441     if(e < mfpKinEnergy) {                     << 
442       const G4double e1 = e*lambdaFactor;      << 
443       preStepLambda = GetCurrentLambda(e1);    << 
444       mfpKinEnergy = e1;                       << 
445     }                                          << 
446                                                << 
447   } else if(fXSType == fEmOnePeak) {           << 
448     const G4double epeak = (*theEnergyOfCrossS << 
449     if(e <= epeak) {                           << 
450       if(e*invLambdaFactor < mfpKinEnergy) {   << 
451         preStepLambda = GetCurrentLambda(e, Lo << 
452         mfpKinEnergy = (preStepLambda > 0.0) ? << 
453       }                                        << 
454     } else if(e < mfpKinEnergy) {              << 
455       const G4double e1 = std::max(epeak, e*la << 
456       preStepLambda = GetCurrentLambda(e1);    << 
457       mfpKinEnergy = e1;                       << 
458     }                                             688     }
459   } else {                                     << 689 #endif
460     preStepLambda = GetCurrentLambda(e, LogEki << 690     */
461   }                                               691   }
                                                   >> 692   return x;
462 }                                                 693 }
463                                                   694 
464 //....oooOO0OOooo........oooOO0OOooo........oo    695 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
465                                                   696 
466 G4VParticleChange* G4VEmProcess::PostStepDoIt(    697 G4VParticleChange* G4VEmProcess::PostStepDoIt(const G4Track& track,
467                                                   698                                               const G4Step& step)
468 {                                                 699 {
469   // clear number of interaction lengths in an << 700   // In all cases clear number of interaction lengths
470   theNumberOfInteractionLengthLeft = -1.0;        701   theNumberOfInteractionLengthLeft = -1.0;
471   mfpKinEnergy = DBL_MAX;                      << 702   mfpKinEnergy = DBL_MAX; 
472                                                   703 
473   fParticleChange.InitializeForPostStep(track)    704   fParticleChange.InitializeForPostStep(track);
474                                                   705 
475   // Do not make anything if particle is stopp    706   // Do not make anything if particle is stopped, the annihilation then
476   // should be performed by the AtRestDoIt!       707   // should be performed by the AtRestDoIt!
477   if (track.GetTrackStatus() == fStopButAlive)    708   if (track.GetTrackStatus() == fStopButAlive) { return &fParticleChange; }
478                                                   709 
479   const G4double finalT = track.GetKineticEner << 710   G4double finalT = track.GetKineticEnergy();
480                                                   711 
481   // forced process - should happen only once     712   // forced process - should happen only once per track
482   if(biasFlag) {                                  713   if(biasFlag) {
483     if(biasManager->ForcedInteractionRegion((G << 714     if(biasManager->ForcedInteractionRegion(currentCoupleIndex)) {
484       biasFlag = false;                           715       biasFlag = false;
485     }                                             716     }
486   }                                               717   }
487                                                   718 
488   // check active and select model             << 
489   const G4double scaledEnergy = finalT*massRat << 
490   SelectModel(scaledEnergy, currentCoupleIndex << 
491   if(!currentModel->IsActive(scaledEnergy)) {  << 
492                                                << 
493   // Integral approach                            719   // Integral approach
494   if (fXSType != fEmNoIntegral) {              << 720   if (integral) {
495     const G4double logFinalT =                 << 721     G4double lx = GetLambda(finalT, currentCouple);
496       track.GetDynamicParticle()->GetLogKineti << 722     if(preStepLambda<lx && 1 < verboseLevel) {
497     const G4double lx = std::max(GetCurrentLam << 
498 #ifdef G4VERBOSE                               << 
499     if(preStepLambda < lx && 1 < verboseLevel) << 
500       G4cout << "WARNING: for " << currentPart    723       G4cout << "WARNING: for " << currentParticle->GetParticleName() 
501              << " and " << GetProcessName() << << 724              << " and " << GetProcessName()
502              << " preLambda= " << preStepLambd << 725              << " E(MeV)= " << finalT/MeV
503              << " < " << lx << " (postLambda)  << 726              << " preLambda= " << preStepLambda << " < " 
                                                   >> 727        << lx << " (postLambda) "
                                                   >> 728        << G4endl;  
504     }                                             729     }
505 #endif                                         << 730 
506     // if false interaction then use new cross << 731     if(preStepLambda*G4UniformRand() > lx) {
507     // if both values are zero - no interactio << 732       ClearNumberOfInteractionLengthLeft();
508     if(preStepLambda*G4UniformRand() >= lx) {  << 
509       return &fParticleChange;                    733       return &fParticleChange;
510     }                                             734     }
511   }                                               735   }
512                                                   736 
                                                   >> 737   SelectModel(finalT, currentCoupleIndex);
                                                   >> 738   if(!currentModel->IsActive(finalT)) { return &fParticleChange; }
                                                   >> 739 
513   // define new weight for primary and seconda    740   // define new weight for primary and secondaries
514   G4double weight = fParticleChange.GetParentW    741   G4double weight = fParticleChange.GetParentWeight();
515   if(weightFlag) {                                742   if(weightFlag) { 
516     weight /= biasFactor;                         743     weight /= biasFactor; 
517     fParticleChange.ProposeWeight(weight);        744     fParticleChange.ProposeWeight(weight);
518   }                                               745   }
519                                                   746   
520 #ifdef G4VERBOSE                               << 747   /*  
521   if(1 < verboseLevel) {                       << 748   if(0 < verboseLevel) {
522     G4cout << "G4VEmProcess::PostStepDoIt: Sam    749     G4cout << "G4VEmProcess::PostStepDoIt: Sample secondary; E= "
523            << finalT/MeV                          750            << finalT/MeV
524            << " MeV; model= (" << currentModel    751            << " MeV; model= (" << currentModel->LowEnergyLimit()
525            << ", " <<  currentModel->HighEnerg    752            << ", " <<  currentModel->HighEnergyLimit() << ")"
526            << G4endl;                             753            << G4endl;
527   }                                               754   }
528 #endif                                         << 755   */
529                                                   756 
530   // sample secondaries                           757   // sample secondaries
531   secParticles.clear();                           758   secParticles.clear();
532   currentModel->SampleSecondaries(&secParticle    759   currentModel->SampleSecondaries(&secParticles, 
533                                   currentCoupl << 760           currentCouple, 
534                                   track.GetDyn << 761           track.GetDynamicParticle(),
535                                   (*theCuts)[c << 762           (*theCuts)[currentCoupleIndex]);
536                                                   763 
537   G4int num0 = (G4int)secParticles.size();     << 764   G4int num0 = secParticles.size();
538                                                   765 
539   // splitting or Russian roulette                766   // splitting or Russian roulette
540   if(biasManager) {                               767   if(biasManager) {
541     if(biasManager->SecondaryBiasingRegion((G4 << 768     if(biasManager->SecondaryBiasingRegion(currentCoupleIndex)) {
542       G4double eloss = 0.0;                       769       G4double eloss = 0.0;
543       weight *= biasManager->ApplySecondaryBia    770       weight *= biasManager->ApplySecondaryBiasing(
544         secParticles, track, currentModel, &fP    771         secParticles, track, currentModel, &fParticleChange, eloss, 
545         (G4int)currentCoupleIndex, (*theCuts)[ << 772         currentCoupleIndex, (*theCuts)[currentCoupleIndex],
546         step.GetPostStepPoint()->GetSafety()); << 773   step.GetPostStepPoint()->GetSafety());
547       if(eloss > 0.0) {                           774       if(eloss > 0.0) {
548         eloss += fParticleChange.GetLocalEnerg << 775   eloss += fParticleChange.GetLocalEnergyDeposit();
549         fParticleChange.ProposeLocalEnergyDepo    776         fParticleChange.ProposeLocalEnergyDeposit(eloss);
550       }                                           777       }
551     }                                             778     }
552   }                                               779   }
553                                                   780 
554   // save secondaries                             781   // save secondaries
555   G4int num = (G4int)secParticles.size();      << 782   G4int num = secParticles.size();
556   if(num > 0) {                                   783   if(num > 0) {
557                                                   784 
558     fParticleChange.SetNumberOfSecondaries(num    785     fParticleChange.SetNumberOfSecondaries(num);
559     G4double edep = fParticleChange.GetLocalEn    786     G4double edep = fParticleChange.GetLocalEnergyDeposit();
560     G4double time = track.GetGlobalTime();        787     G4double time = track.GetGlobalTime();
561                                                << 
562     G4int n1(0), n2(0);                        << 
563     if(num0 > mainSecondaries) {               << 
564       currentModel->FillNumberOfSecondaries(n1 << 
565     }                                          << 
566                                                   788      
567     for (G4int i=0; i<num; ++i) {                 789     for (G4int i=0; i<num; ++i) {
568       G4DynamicParticle* dp = secParticles[i]; << 790       if (secParticles[i]) {
569       if (nullptr != dp) {                     << 791         G4DynamicParticle* dp = secParticles[i];
570         const G4ParticleDefinition* p = dp->Ge    792         const G4ParticleDefinition* p = dp->GetParticleDefinition();
571         G4double e = dp->GetKineticEnergy();      793         G4double e = dp->GetKineticEnergy();
572         G4bool good = true;                       794         G4bool good = true;
573         if(applyCuts) {                           795         if(applyCuts) {
574           if (p == theGamma) {                 << 796     if (p == theGamma) {
575             if (e < (*theCutsGamma)[currentCou << 797       if (e < (*theCutsGamma)[currentCoupleIndex]) { good = false; }
576                                                   798 
577           } else if (p == theElectron) {       << 799     } else if (p == theElectron) {
578             if (e < (*theCutsElectron)[current << 800       if (e < (*theCutsElectron)[currentCoupleIndex]) { good = false; }
579                                                   801 
580           } else if (p == thePositron) {       << 802     } else if (p == thePositron) {
581             if (electron_mass_c2 < (*theCutsGa << 803       if (electron_mass_c2 < (*theCutsGamma)[currentCoupleIndex] &&
582                 e < (*theCutsPositron)[current << 804     e < (*theCutsPositron)[currentCoupleIndex]) {
583               good = false;                    << 805         good = false;
584               e += 2.0*electron_mass_c2;       << 806         e += 2.0*electron_mass_c2;
585             }                                  << 807       }
586           }                                    << 808     }
587           // added secondary if it is good     << 809     // added secondary if it is good
588         }                                         810         }
589         if (good) {                               811         if (good) { 
590           G4Track* t = new G4Track(dp, time, t    812           G4Track* t = new G4Track(dp, time, track.GetPosition());
591           t->SetTouchableHandle(track.GetTouch    813           t->SetTouchableHandle(track.GetTouchableHandle());
592           if (biasManager) {                   << 814           t->SetWeight(weight);
593             t->SetWeight(weight * biasManager- << 
594           } else {                             << 
595             t->SetWeight(weight);              << 
596           }                                    << 
597           pParticleChange->AddSecondary(t);       815           pParticleChange->AddSecondary(t);
598                                                   816 
599           // define type of secondary          << 817     // define type of secondary
600           if(i < mainSecondaries) {            << 818           if(i < mainSecondaries) { t->SetCreatorModelIndex(secID); }
601             t->SetCreatorModelID(secID);       << 819           else if(i < num0) {
602             if(GetProcessSubType() == fCompton << 820             if(p == theGamma) { 
603               t->SetCreatorModelID(_ComptonGam << 821         t->SetCreatorModelIndex(fluoID);
604             }                                  << 822       } else {
605           } else if(i < mainSecondaries + n1)  << 823         t->SetCreatorModelIndex(augerID);
606             t->SetCreatorModelID(tripletID);   << 824       }
607           } else if(i < mainSecondaries + n1 + << 825     } else {
608             t->SetCreatorModelID(_IonRecoil);  << 826       t->SetCreatorModelIndex(biasID);
609           } else {                             << 827     }
610             if(i < num0) {                     << 828  
611               if(p == theGamma) {              << 829           //G4cout << "Secondary(post step) has weight " << t->GetWeight() 
612                 t->SetCreatorModelID(fluoID);  << 830     // << ", Ekin= " << t->GetKineticEnergy()/MeV << " MeV" <<G4endl;
613               } else {                         << 
614                 t->SetCreatorModelID(augerID); << 
615               }                                << 
616             } else {                           << 
617               t->SetCreatorModelID(biasID);    << 
618             }                                  << 
619           }                                    << 
620           /*                                   << 
621           G4cout << "Secondary(post step) has  << 
622                  << ", Ekin= " << t->GetKineti << 
623                  << GetProcessName() << " fluo << 
624                  << " augerID= " << augerID << << 
625           */                                   << 
626         } else {                                  831         } else {
627           delete dp;                           << 832     delete dp;
628           edep += e;                           << 833     edep += e;
629         }                                      << 834   }
630       }                                           835       } 
631     }                                             836     }
632     fParticleChange.ProposeLocalEnergyDeposit(    837     fParticleChange.ProposeLocalEnergyDeposit(edep);
633   }                                               838   }
634                                                   839 
635   if(0.0 == fParticleChange.GetProposedKinetic    840   if(0.0 == fParticleChange.GetProposedKineticEnergy() &&
636      fAlive == fParticleChange.GetTrackStatus(    841      fAlive == fParticleChange.GetTrackStatus()) {
637     if(particle->GetProcessManager()->GetAtRes    842     if(particle->GetProcessManager()->GetAtRestProcessVector()->size() > 0)
638          { fParticleChange.ProposeTrackStatus(    843          { fParticleChange.ProposeTrackStatus(fStopButAlive); }
639     else { fParticleChange.ProposeTrackStatus(    844     else { fParticleChange.ProposeTrackStatus(fStopAndKill); }
640   }                                               845   }
641                                                   846 
642   return &fParticleChange;                        847   return &fParticleChange;
643 }                                                 848 }
644                                                   849 
645 //....oooOO0OOooo........oooOO0OOooo........oo    850 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
646                                                   851 
647 G4bool G4VEmProcess::StorePhysicsTable(const G    852 G4bool G4VEmProcess::StorePhysicsTable(const G4ParticleDefinition* part,
648                                        const G << 853                const G4String& directory,
649                                        G4bool  << 854                      G4bool ascii)
650 {                                                 855 {
651   if(!isTheMaster || part != particle) { retur << 856   G4bool yes = true;
652   if(G4EmTableUtil::StoreTable(this, part, the << 857   const G4VEmProcess* masterProc = 
653              directory, "Lambda",              << 858     static_cast<const G4VEmProcess*>(GetMasterProcess());
654                                verboseLevel, a << 859   if(masterProc && masterProc != this) { return yes; }
655      G4EmTableUtil::StoreTable(this, part, the << 860 
656              directory, "LambdaPrim",          << 861   if ( theLambdaTable && part == particle) {
657                                verboseLevel, a << 862     const G4String name = 
658      return true;                              << 863       GetPhysicsTableFileName(part,directory,"Lambda",ascii);
                                                   >> 864     yes = theLambdaTable->StorePhysicsTable(name,ascii);
                                                   >> 865 
                                                   >> 866     if ( yes ) {
                                                   >> 867       G4cout << "Physics table is stored for " << particle->GetParticleName()
                                                   >> 868              << " and process " << GetProcessName()
                                                   >> 869        << " in the directory <" << directory
                                                   >> 870        << "> " << G4endl;
                                                   >> 871     } else {
                                                   >> 872       G4cout << "Fail to store Physics Table for " 
                                                   >> 873        << particle->GetParticleName()
                                                   >> 874              << " and process " << GetProcessName()
                                                   >> 875        << " in the directory <" << directory
                                                   >> 876        << "> " << G4endl;
                                                   >> 877     }
                                                   >> 878   }
                                                   >> 879   if ( theLambdaTablePrim && part == particle) {
                                                   >> 880     const G4String name = 
                                                   >> 881       GetPhysicsTableFileName(part,directory,"LambdaPrim",ascii);
                                                   >> 882     yes = theLambdaTablePrim->StorePhysicsTable(name,ascii);
                                                   >> 883 
                                                   >> 884     if ( yes ) {
                                                   >> 885       G4cout << "Physics table prim is stored for " 
                                                   >> 886        << particle->GetParticleName()
                                                   >> 887              << " and process " << GetProcessName()
                                                   >> 888        << " in the directory <" << directory
                                                   >> 889        << "> " << G4endl;
                                                   >> 890     } else {
                                                   >> 891       G4cout << "Fail to store Physics Table Prim for " 
                                                   >> 892        << particle->GetParticleName()
                                                   >> 893              << " and process " << GetProcessName()
                                                   >> 894        << " in the directory <" << directory
                                                   >> 895        << "> " << G4endl;
                                                   >> 896     }
659   }                                               897   }
660   return false;                                << 898   return yes;
661 }                                                 899 }
662                                                   900 
663 //....oooOO0OOooo........oooOO0OOooo........oo    901 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
664                                                   902 
665 G4bool G4VEmProcess::RetrievePhysicsTable(cons    903 G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
666                                           cons << 904                     const G4String& directory,
667                                           G4bo << 905             G4bool ascii)
668 {                                                 906 {
669   if(!isTheMaster || part != particle) { retur << 907   if(1 < verboseLevel) {
                                                   >> 908     G4cout << "G4VEmProcess::RetrievePhysicsTable() for "
                                                   >> 909            << part->GetParticleName() << " and process "
                                                   >> 910      << GetProcessName() << G4endl;
                                                   >> 911   }
670   G4bool yes = true;                              912   G4bool yes = true;
                                                   >> 913 
                                                   >> 914   if((!buildLambdaTable && minKinEnergyPrim > maxKinEnergy) 
                                                   >> 915      || particle != part) { return yes; }
                                                   >> 916 
                                                   >> 917   const G4String particleName = part->GetParticleName();
                                                   >> 918   G4String filename;
                                                   >> 919 
671   if(buildLambdaTable) {                          920   if(buildLambdaTable) {
672     yes = G4EmTableUtil::RetrieveTable(this, p << 921     filename = GetPhysicsTableFileName(part,directory,"Lambda",ascii);
673                                        "Lambda << 922     yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTable,
674                                        ascii,  << 923                  filename,ascii);
675   }                                            << 924     if ( yes ) {
676   if(yes && minKinEnergyPrim < maxKinEnergy) { << 925       if (0 < verboseLevel) {
677     yes = G4EmTableUtil::RetrieveTable(this, p << 926   G4cout << "Lambda table for " << particleName 
678                                        "Lambda << 927          << " is Retrieved from <"
679                                        ascii,  << 928          << filename << ">"
                                                   >> 929          << G4endl;
                                                   >> 930       }
                                                   >> 931       if(theParameters->Spline()) {
                                                   >> 932   size_t n = theLambdaTable->length();
                                                   >> 933   for(size_t i=0; i<n; ++i) {
                                                   >> 934     if((* theLambdaTable)[i]) {
                                                   >> 935       (* theLambdaTable)[i]->SetSpline(true);
                                                   >> 936     }
                                                   >> 937   }
                                                   >> 938       }
                                                   >> 939     } else {
                                                   >> 940       if (1 < verboseLevel) {
                                                   >> 941   G4cout << "Lambda table for " << particleName << " in file <"
                                                   >> 942          << filename << "> is not exist"
                                                   >> 943          << G4endl;
                                                   >> 944       }
                                                   >> 945     }
                                                   >> 946   }
                                                   >> 947   if(minKinEnergyPrim < maxKinEnergy) {
                                                   >> 948     filename = GetPhysicsTableFileName(part,directory,"LambdaPrim",ascii);
                                                   >> 949     yes = G4PhysicsTableHelper::RetrievePhysicsTable(theLambdaTablePrim,
                                                   >> 950                  filename,ascii);
                                                   >> 951     if ( yes ) {
                                                   >> 952       if (0 < verboseLevel) {
                                                   >> 953   G4cout << "Lambda table prim for " << particleName 
                                                   >> 954          << " is Retrieved from <"
                                                   >> 955          << filename << ">"
                                                   >> 956          << G4endl;
                                                   >> 957       }
                                                   >> 958       if(theParameters->Spline()) {
                                                   >> 959   size_t n = theLambdaTablePrim->length();
                                                   >> 960   for(size_t i=0; i<n; ++i) {
                                                   >> 961     if((* theLambdaTablePrim)[i]) {
                                                   >> 962       (* theLambdaTablePrim)[i]->SetSpline(true);
                                                   >> 963     }
                                                   >> 964   }
                                                   >> 965       }
                                                   >> 966     } else {
                                                   >> 967       if (1 < verboseLevel) {
                                                   >> 968   G4cout << "Lambda table prim for " << particleName << " in file <"
                                                   >> 969          << filename << "> is not exist"
                                                   >> 970          << G4endl;
                                                   >> 971       }
                                                   >> 972     }
680   }                                               973   }
                                                   >> 974 
681   return yes;                                     975   return yes;
682 }                                                 976 }
683                                                   977 
684 //....oooOO0OOooo........oooOO0OOooo........oo    978 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
685                                                   979 
686 G4double G4VEmProcess::GetCrossSection(G4doubl << 980 G4double 
687                                        const G << 981 G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
                                                   >> 982             const G4MaterialCutsCouple* couple)
688 {                                                 983 {
689   CurrentSetup(couple, kinEnergy);             << 984   // Cross section per atom is calculated
690   return GetCurrentLambda(kinEnergy, G4Log(kin << 985   DefineMaterial(couple);
                                                   >> 986   G4double cross = 0.0;
                                                   >> 987   if(buildLambdaTable && theLambdaTable) {
                                                   >> 988     cross = GetCurrentLambda(kineticEnergy);
                                                   >> 989   } else {
                                                   >> 990     SelectModel(kineticEnergy, currentCoupleIndex);
                                                   >> 991     cross = fFactor*currentModel->CrossSectionPerVolume(currentMaterial,
                                                   >> 992               currentParticle,
                                                   >> 993               kineticEnergy);
                                                   >> 994   }
                                                   >> 995 
                                                   >> 996   if(cross < 0.0) { cross = 0.0; }
                                                   >> 997   return cross;
691 }                                                 998 }
692                                                   999 
693 //....oooOO0OOooo........oooOO0OOooo........oo    1000 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
694                                                   1001 
695 G4double G4VEmProcess::GetMeanFreePath(const G    1002 G4double G4VEmProcess::GetMeanFreePath(const G4Track& track,
696                                        G4doubl << 1003                G4double,
697                                        G4Force << 1004                G4ForceCondition* condition)
698 {                                                 1005 {
699   *condition = NotForced;                         1006   *condition = NotForced;
700   return G4VEmProcess::MeanFreePath(track);       1007   return G4VEmProcess::MeanFreePath(track);
701 }                                                 1008 }
702                                                   1009 
703 //....oooOO0OOooo........oooOO0OOooo........oo    1010 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
704                                                   1011 
705 G4double                                       << 1012 G4double G4VEmProcess::MeanFreePath(const G4Track& track)
706 G4VEmProcess::ComputeCrossSectionPerAtom(G4dou << 
707                                          G4dou << 
708 {                                                 1013 {
709   SelectModel(kinEnergy, currentCoupleIndex);  << 1014   DefineMaterial(track.GetMaterialCutsCouple());
710   return (currentModel) ?                      << 1015   preStepLambda = GetCurrentLambda(track.GetKineticEnergy());
711     currentModel->ComputeCrossSectionPerAtom(c << 1016   G4double x = DBL_MAX;
712                                              Z << 1017   if(0.0 < preStepLambda) { x = 1.0/preStepLambda; }
                                                   >> 1018   return x;
713 }                                                 1019 }
714                                                   1020 
715 //....oooOO0OOooo........oooOO0OOooo........oo    1021 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
716                                                   1022 
717 G4PhysicsVector*                               << 1023 G4double 
718 G4VEmProcess::LambdaPhysicsVector(const G4Mate << 1024 G4VEmProcess::ComputeCrossSectionPerAtom(G4double kineticEnergy, 
                                                   >> 1025            G4double Z, G4double A, G4double cut)
719 {                                                 1026 {
720   DefineMaterial(couple);                      << 1027   SelectModel(kineticEnergy, currentCoupleIndex);
721   G4PhysicsVector* newv = new G4PhysicsLogVect << 1028   G4double x = 0.0;
722                                                << 1029   if(currentModel) {
723   return newv;                                 << 1030     x = currentModel->ComputeCrossSectionPerAtom(currentParticle,kineticEnergy,
                                                   >> 1031              Z,A,cut);
                                                   >> 1032   }
                                                   >> 1033   return x;
724 }                                                 1034 }
725                                                   1035 
726 //....oooOO0OOooo........oooOO0OOooo........oo    1036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
727                                                   1037 
728 const G4Element* G4VEmProcess::GetCurrentEleme << 1038 void G4VEmProcess::FindLambdaMax()
729 {                                                 1039 {
730   return (nullptr != currentModel) ?           << 1040   if(1 < verboseLevel) {
731     currentModel->GetCurrentElement(currentMat << 1041     G4cout << "### G4VEmProcess::FindLambdaMax: " 
                                                   >> 1042      << particle->GetParticleName() 
                                                   >> 1043            << " and process " << GetProcessName() << "  " << G4endl; 
                                                   >> 1044   }
                                                   >> 1045   size_t n = theLambdaTable->length();
                                                   >> 1046   G4PhysicsVector* pv;
                                                   >> 1047   G4double e, ss, emax, smax;
                                                   >> 1048 
                                                   >> 1049   size_t i;
                                                   >> 1050 
                                                   >> 1051   // first loop on existing vectors
                                                   >> 1052   for (i=0; i<n; ++i) {
                                                   >> 1053     pv = (*theLambdaTable)[i];
                                                   >> 1054     if(pv) {
                                                   >> 1055       size_t nb = pv->GetVectorLength();
                                                   >> 1056       emax = DBL_MAX;
                                                   >> 1057       smax = 0.0;
                                                   >> 1058       if(nb > 0) {
                                                   >> 1059   for (size_t j=0; j<nb; ++j) {
                                                   >> 1060     e = pv->Energy(j);
                                                   >> 1061     ss = (*pv)(j);
                                                   >> 1062     if(ss > smax) {
                                                   >> 1063       smax = ss;
                                                   >> 1064       emax = e;
                                                   >> 1065     }
                                                   >> 1066   }
                                                   >> 1067       }
                                                   >> 1068       theEnergyOfCrossSectionMax[i] = emax;
                                                   >> 1069       theCrossSectionMax[i] = smax;
                                                   >> 1070       if(1 < verboseLevel) {
                                                   >> 1071   G4cout << "For " << particle->GetParticleName() 
                                                   >> 1072          << " Max CS at i= " << i << " emax(MeV)= " << emax/MeV
                                                   >> 1073          << " lambda= " << smax << G4endl;
                                                   >> 1074       }
                                                   >> 1075     }
                                                   >> 1076   }
                                                   >> 1077   // second loop using base materials
                                                   >> 1078   for (i=0; i<n; ++i) {
                                                   >> 1079     pv = (*theLambdaTable)[i];
                                                   >> 1080     if(!pv){
                                                   >> 1081       G4int j = (*theDensityIdx)[i];
                                                   >> 1082       theEnergyOfCrossSectionMax[i] = theEnergyOfCrossSectionMax[j];
                                                   >> 1083       theCrossSectionMax[i] = (*theDensityFactor)[i]*theCrossSectionMax[j];
                                                   >> 1084     }
                                                   >> 1085   }
732 }                                                 1086 }
733                                                   1087 
734 //....oooOO0OOooo........oooOO0OOooo........oo    1088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
735                                                   1089 
736 const G4Element* G4VEmProcess::GetTargetElemen << 1090 G4PhysicsVector* 
                                                   >> 1091 G4VEmProcess::LambdaPhysicsVector(const G4MaterialCutsCouple*)
737 {                                                 1092 {
738   return (nullptr != currentModel) ?           << 1093   G4PhysicsVector* v = 
739     currentModel->GetCurrentElement(currentMat << 1094     new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nLambdaBins);
                                                   >> 1095   v->SetSpline(theParameters->Spline());
                                                   >> 1096   return v;
740 }                                                 1097 }
741                                                   1098 
742 //....oooOO0OOooo........oooOO0OOooo........oo    1099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
743                                                   1100 
744 const G4Isotope* G4VEmProcess::GetTargetIsotop << 1101 const G4Element* G4VEmProcess::GetCurrentElement() const
745 {                                                 1102 {
746   return (nullptr != currentModel) ?           << 1103   const G4Element* elm = 0;
747     currentModel->GetCurrentIsotope(GetCurrent << 1104   if(currentModel) {elm = currentModel->GetCurrentElement(); }
                                                   >> 1105   return elm;
748 }                                                 1106 }
749                                                   1107 
750 //....oooOO0OOooo........oooOO0OOooo........oo    1108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
751                                                   1109 
752 void G4VEmProcess::SetCrossSectionBiasingFacto    1110 void G4VEmProcess::SetCrossSectionBiasingFactor(G4double f, G4bool flag)
753 {                                                 1111 {
754   if(f > 0.0) {                                   1112   if(f > 0.0) { 
755     biasFactor = f;                               1113     biasFactor = f; 
756     weightFlag = flag;                            1114     weightFlag = flag;
757     if(1 < verboseLevel) {                        1115     if(1 < verboseLevel) {
758       G4cout << "### SetCrossSectionBiasingFac    1116       G4cout << "### SetCrossSectionBiasingFactor: for " 
759              << particle->GetParticleName()    << 1117        << particle->GetParticleName() 
760              << " and process " << GetProcessN << 1118        << " and process " << GetProcessName()
761              << " biasFactor= " << f << " weig << 1119        << " biasFactor= " << f << " weightFlag= " << flag 
762              << G4endl;                        << 1120        << G4endl; 
763     }                                             1121     }
764   }                                               1122   }
765 }                                                 1123 }
766                                                   1124 
767 //....oooOO0OOooo........oooOO0OOooo........oo    1125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
768                                                   1126 
769 void                                              1127 void 
770 G4VEmProcess::ActivateForcedInteraction(G4doub    1128 G4VEmProcess::ActivateForcedInteraction(G4double length, const G4String& r,
771                                         G4bool << 1129           G4bool flag)
772 {                                                 1130 {
773   if(nullptr == biasManager) { biasManager = n << 1131   if(!biasManager) { biasManager = new G4EmBiasingManager(); }
774   if(1 < verboseLevel) {                          1132   if(1 < verboseLevel) {
775     G4cout << "### ActivateForcedInteraction:     1133     G4cout << "### ActivateForcedInteraction: for " 
776            << particle->GetParticleName()      << 1134      << particle->GetParticleName() 
777            << " and process " << GetProcessNam << 1135      << " and process " << GetProcessName()
778            << " length(mm)= " << length/mm     << 1136      << " length(mm)= " << length/mm
779            << " in G4Region <" << r            << 1137      << " in G4Region <" << r 
780            << "> weightFlag= " << flag         << 1138      << "> weightFlag= " << flag 
781            << G4endl;                          << 1139      << G4endl; 
782   }                                               1140   }
783   weightFlag = flag;                              1141   weightFlag = flag;
784   biasManager->ActivateForcedInteraction(lengt    1142   biasManager->ActivateForcedInteraction(length, r);
785 }                                                 1143 }
786                                                   1144 
787 //....oooOO0OOooo........oooOO0OOooo........oo    1145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
788                                                   1146 
789 void                                              1147 void
790 G4VEmProcess::ActivateSecondaryBiasing(const G    1148 G4VEmProcess::ActivateSecondaryBiasing(const G4String& region,
791                  G4double factor,                 1149                  G4double factor,
792                  G4double energyLimit)            1150                  G4double energyLimit)
793 {                                                 1151 {
794   if (0.0 <= factor) {                            1152   if (0.0 <= factor) {
795                                                   1153 
796     // Range cut can be applied only for e-       1154     // Range cut can be applied only for e-
797     if(0.0 == factor && secondaryParticle != G    1155     if(0.0 == factor && secondaryParticle != G4Electron::Electron())
798       { return; }                                 1156       { return; }
799                                                   1157 
800     if(!biasManager) { biasManager = new G4EmB    1158     if(!biasManager) { biasManager = new G4EmBiasingManager(); }
801     biasManager->ActivateSecondaryBiasing(regi    1159     biasManager->ActivateSecondaryBiasing(region, factor, energyLimit);
802     if(1 < verboseLevel) {                        1160     if(1 < verboseLevel) {
803       G4cout << "### ActivateSecondaryBiasing:    1161       G4cout << "### ActivateSecondaryBiasing: for "
804        << " process " << GetProcessName()         1162        << " process " << GetProcessName()
805        << " factor= " << factor                   1163        << " factor= " << factor
806        << " in G4Region <" << region              1164        << " in G4Region <" << region
807        << "> energyLimit(MeV)= " << energyLimi    1165        << "> energyLimit(MeV)= " << energyLimit/MeV
808        << G4endl;                                 1166        << G4endl;
809     }                                             1167     }
810   }                                               1168   }
811 }                                                 1169 }
812                                                   1170 
813 //....oooOO0OOooo........oooOO0OOooo........oo    1171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
814                                                   1172 
815 void G4VEmProcess::SetLambdaBinning(G4int n)      1173 void G4VEmProcess::SetLambdaBinning(G4int n)
816 {                                                 1174 {
817   if(5 < n && n < 10000000) {                     1175   if(5 < n && n < 10000000) {  
818     nLambdaBins = n;                              1176     nLambdaBins = n; 
819     actBinning = true;                            1177     actBinning = true;
820   } else {                                        1178   } else { 
821     G4double e = (G4double)n;                     1179     G4double e = (G4double)n;
822     PrintWarning("SetLambdaBinning", e);          1180     PrintWarning("SetLambdaBinning", e); 
823   }                                               1181   } 
824 }                                                 1182 }
825                                                   1183 
826 //....oooOO0OOooo........oooOO0OOooo........oo    1184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
827                                                   1185 
828 void G4VEmProcess::SetMinKinEnergy(G4double e)    1186 void G4VEmProcess::SetMinKinEnergy(G4double e)
829 {                                                 1187 {
830   if(1.e-3*eV < e && e < maxKinEnergy) {          1188   if(1.e-3*eV < e && e < maxKinEnergy) { 
831     nLambdaBins = G4lrint(nLambdaBins*G4Log(ma    1189     nLambdaBins = G4lrint(nLambdaBins*G4Log(maxKinEnergy/e)
832                           /G4Log(maxKinEnergy/ << 1190         /G4Log(maxKinEnergy/minKinEnergy));
833     minKinEnergy = e;                             1191     minKinEnergy = e;
834     actMinKinEnergy = true;                       1192     actMinKinEnergy = true;
835   } else { PrintWarning("SetMinKinEnergy", e);    1193   } else { PrintWarning("SetMinKinEnergy", e); } 
836 }                                                 1194 }
837                                                   1195 
838 //....oooOO0OOooo........oooOO0OOooo........oo    1196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
839                                                   1197 
840 void G4VEmProcess::SetMaxKinEnergy(G4double e)    1198 void G4VEmProcess::SetMaxKinEnergy(G4double e)
841 {                                                 1199 {
842   if(minKinEnergy < e && e < 1.e+6*TeV) {         1200   if(minKinEnergy < e && e < 1.e+6*TeV) { 
843     nLambdaBins = G4lrint(nLambdaBins*G4Log(e/    1201     nLambdaBins = G4lrint(nLambdaBins*G4Log(e/minKinEnergy)
844                           /G4Log(maxKinEnergy/ << 1202         /G4Log(maxKinEnergy/minKinEnergy));
845     maxKinEnergy = e;                             1203     maxKinEnergy = e;
846     actMaxKinEnergy = true;                       1204     actMaxKinEnergy = true;
847   } else { PrintWarning("SetMaxKinEnergy", e);    1205   } else { PrintWarning("SetMaxKinEnergy", e); } 
848 }                                                 1206 }
849                                                   1207 
850 //....oooOO0OOooo........oooOO0OOooo........oo    1208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
851                                                   1209 
852 void G4VEmProcess::SetMinKinEnergyPrim(G4doubl    1210 void G4VEmProcess::SetMinKinEnergyPrim(G4double e)
853 {                                                 1211 {
854   if(theParameters->MinKinEnergy() <= e &&        1212   if(theParameters->MinKinEnergy() <= e && 
855      e <= theParameters->MaxKinEnergy()) { min    1213      e <= theParameters->MaxKinEnergy()) { minKinEnergyPrim = e; } 
856   else { PrintWarning("SetMinKinEnergyPrim", e    1214   else { PrintWarning("SetMinKinEnergyPrim", e); } 
857 }                                                 1215 }
858                                                   1216 
859 //....oooOO0OOooo........oooOO0OOooo........oo    1217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
860                                                   1218 
861 G4VEmProcess* G4VEmProcess::GetEmProcess(const << 
862 {                                              << 
863   return (nam == GetProcessName()) ? this : nu << 
864 }                                              << 
865                                                << 
866 //....oooOO0OOooo........oooOO0OOooo........oo << 
867                                                << 
868 G4double G4VEmProcess::PolarAngleLimit() const << 
869 {                                              << 
870   return theParameters->MscThetaLimit();       << 
871 }                                              << 
872                                                << 
873 //....oooOO0OOooo........oooOO0OOooo........oo << 
874                                                << 
875 void G4VEmProcess::PrintWarning(G4String tit,     1219 void G4VEmProcess::PrintWarning(G4String tit, G4double val)
876 {                                                 1220 {
877   G4String ss = "G4VEmProcess::" + tit;           1221   G4String ss = "G4VEmProcess::" + tit;
878   G4ExceptionDescription ed;                      1222   G4ExceptionDescription ed;
879   ed << "Parameter is out of range: " << val      1223   ed << "Parameter is out of range: " << val 
880      << " it will have no effect!\n" << "  Pro    1224      << " it will have no effect!\n" << "  Process " 
881      << GetProcessName() << "  nbins= " << the    1225      << GetProcessName() << "  nbins= " << theParameters->NumberOfBins()
882      << " Emin(keV)= " << theParameters->MinKi    1226      << " Emin(keV)= " << theParameters->MinKinEnergy()/keV 
883      << " Emax(GeV)= " << theParameters->MaxKi    1227      << " Emax(GeV)= " << theParameters->MaxKinEnergy()/GeV;
884   G4Exception(ss, "em0044", JustWarning, ed);     1228   G4Exception(ss, "em0044", JustWarning, ed);
885 }                                              << 
886                                                << 
887 //....oooOO0OOooo........oooOO0OOooo........oo << 
888                                                << 
889 void G4VEmProcess::ProcessDescription(std::ost << 
890 {                                              << 
891   if(nullptr != particle) {                    << 
892     StreamInfo(out, *particle, true);          << 
893   }                                            << 
894 }                                                 1229 }
895                                                   1230 
896 //....oooOO0OOooo........oooOO0OOooo........oo    1231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
897                                                   1232