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 9.6)


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