Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/utils/src/G4EmModelManager.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/G4EmModelManager.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4EmModelManager.cc (Version 9.4.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4EmModelManager.cc,v 1.63 2010-10-15 10:22:13 vnivanch Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-09-04-patch-01 $
 26 //                                                 28 //
 27 // -------------------------------------------     29 // -------------------------------------------------------------------
 28 //                                                 30 //
 29 // GEANT4 Class file                               31 // GEANT4 Class file
 30 //                                                 32 //
 31 //                                                 33 //
 32 // File name:     G4EmModelManager                 34 // File name:     G4EmModelManager
 33 //                                                 35 //
 34 // Author:        Vladimir Ivanchenko              36 // Author:        Vladimir Ivanchenko
 35 //                                                 37 //
 36 // Creation date: 07.05.2002                       38 // Creation date: 07.05.2002
 37 //                                                 39 //
 38 // Modifications: V.Ivanchenko                 <<  40 // Modifications:
                                                   >>  41 //
                                                   >>  42 // 23-12-02 V.Ivanchenko change interface in order to move
                                                   >>  43 //                           to cut per region
                                                   >>  44 // 20-01-03 Migrade to cut per region (V.Ivanchenko)
                                                   >>  45 // 24-01-03 Make models region aware (V.Ivanchenko)
                                                   >>  46 // 13-02-03 The set of models is defined for region (V.Ivanchenko)
                                                   >>  47 // 06-03-03 Fix in energy intervals for models (V.Ivanchenko)
                                                   >>  48 // 13-04-03 Add startFromNull (V.Ivanchenko)
                                                   >>  49 // 13-05-03 Add calculation of precise range (V.Ivanchenko)
                                                   >>  50 // 16-07-03 Replace G4Material by G4MaterialCutCouple in dE/dx and CrossSection
                                                   >>  51 //          calculation (V.Ivanchenko)
                                                   >>  52 // 21-07-03 Add UpdateEmModel method (V.Ivanchenko)
                                                   >>  53 // 03-11-03 Substitute STL vector for G4RegionModels (V.Ivanchenko)
                                                   >>  54 // 26-01-04 Fix in energy range conditions (V.Ivanchenko)
                                                   >>  55 // 24-03-05 Remove check or IsInCharge (V.Ivanchenko)
                                                   >>  56 // 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko)
                                                   >>  57 // 18-08-05 Fix cut for e+e- pair production (V.Ivanchenko)
                                                   >>  58 // 29-11-05 Add protection for arithmetic operations with cut=DBL_MAX (V.Ivanchenko)
                                                   >>  59 // 20-01-06 Introduce G4EmTableType and reducing number of methods (VI)
                                                   >>  60 // 13-05-06 Add GetModel by index method (VI)
                                                   >>  61 // 15-03-07 Add maxCutInRange (V.Ivanchenko)
                                                   >>  62 // 12-04-07 Add verbosity at destruction (V.Ivanchenko)
                                                   >>  63 // 08-04-08 Fixed and simplified initialisation of G4RegionModel (VI)
                                                   >>  64 // 03-08-09 Create internal vectors only it is needed (VI)
 39 //                                                 65 //
 40 // Class Description:                              66 // Class Description:
 41 //                                                 67 //
 42 // It is the unified energy loss process it ca     68 // It is the unified energy loss process it calculates the continuous
 43 // energy loss for charged particles using a s     69 // energy loss for charged particles using a set of Energy Loss
 44 // models valid for different energy regions.      70 // models valid for different energy regions. There are a possibility
 45 // to create and access to dE/dx and range tab     71 // to create and access to dE/dx and range tables, or to calculate
 46 // that information on fly.                        72 // that information on fly.
 47 // -------------------------------------------     73 // -------------------------------------------------------------------
 48 //                                                 74 //
 49 //....oooOO0OOooo........oooOO0OOooo........oo     75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 50 //....oooOO0OOooo........oooOO0OOooo........oo     76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 51                                                    77 
 52 #include "G4EmModelManager.hh"                     78 #include "G4EmModelManager.hh"
 53 #include "G4SystemOfUnits.hh"                  << 
 54 #include "G4PhysicsTable.hh"                   << 
 55 #include "G4PhysicsVector.hh"                  << 
 56 #include "G4VMscModel.hh"                      << 
 57                                                << 
 58 #include "G4Step.hh"                           << 
 59 #include "G4ParticleDefinition.hh"             << 
 60 #include "G4PhysicsVector.hh"                  << 
 61 #include "G4MaterialCutsCouple.hh"             << 
 62 #include "G4ProductionCutsTable.hh"            << 
 63 #include "G4RegionStore.hh"                    << 
 64 #include "G4Gamma.hh"                          << 
 65 #include "G4Electron.hh"                       << 
 66 #include "G4Positron.hh"                       << 
 67 #include "G4UnitsTable.hh"                     << 
 68 #include "G4DataVector.hh"                     << 
 69                                                    79 
 70 //....oooOO0OOooo........oooOO0OOooo........oo     80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 71                                                    81 
 72 G4RegionModels::G4RegionModels(G4int nMod, std     82 G4RegionModels::G4RegionModels(G4int nMod, std::vector<G4int>& indx, 
 73                                G4DataVector& l <<  83              G4DataVector& lowE, const G4Region* reg)
 74 {                                                  84 {
 75   nModelsForRegion      = nMod;                    85   nModelsForRegion      = nMod;
 76   theListOfModelIndexes = new G4int [nModelsFo     86   theListOfModelIndexes = new G4int [nModelsForRegion];
 77   lowKineticEnergy      = new G4double [nModel     87   lowKineticEnergy      = new G4double [nModelsForRegion+1];
 78   for (G4int i=0; i<nModelsForRegion; ++i) {       88   for (G4int i=0; i<nModelsForRegion; ++i) {
 79     theListOfModelIndexes[i] = indx[i];            89     theListOfModelIndexes[i] = indx[i];
 80     lowKineticEnergy[i] = lowE[i];                 90     lowKineticEnergy[i] = lowE[i];
 81   }                                                91   }
 82   lowKineticEnergy[nModelsForRegion] = lowE[nM     92   lowKineticEnergy[nModelsForRegion] = lowE[nModelsForRegion];
 83   theRegion = reg;                                 93   theRegion = reg;
 84 }                                                  94 }
 85                                                    95 
 86 //....oooOO0OOooo........oooOO0OOooo........oo     96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 87                                                    97 
 88 G4RegionModels::~G4RegionModels()                  98 G4RegionModels::~G4RegionModels()
 89 {                                                  99 {
 90   delete [] theListOfModelIndexes;                100   delete [] theListOfModelIndexes;
 91   delete [] lowKineticEnergy;                     101   delete [] lowKineticEnergy;
 92 }                                                 102 }
 93                                                   103 
 94 //....oooOO0OOooo........oooOO0OOooo........oo    104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
                                                   >> 105 
                                                   >> 106 #include "G4Step.hh"
                                                   >> 107 #include "G4ParticleDefinition.hh"
                                                   >> 108 #include "G4PhysicsVector.hh"
                                                   >> 109 #include "G4Gamma.hh"
                                                   >> 110 #include "G4Positron.hh"
                                                   >> 111 #include "G4MaterialCutsCouple.hh"
                                                   >> 112 #include "G4ProductionCutsTable.hh"
                                                   >> 113 #include "G4RegionStore.hh"
                                                   >> 114 #include "G4Gamma.hh"
                                                   >> 115 #include "G4Positron.hh"
                                                   >> 116 #include "G4UnitsTable.hh"
                                                   >> 117 #include "G4DataVector.hh"
                                                   >> 118 
 95 //....oooOO0OOooo........oooOO0OOooo........oo    119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 96                                                   120 
 97 G4EmModelManager::G4EmModelManager()           << 121 G4EmModelManager::G4EmModelManager():
                                                   >> 122   nEmModels(0),
                                                   >> 123   nRegions(0),
                                                   >> 124   particle(0),
                                                   >> 125   verboseLevel(0)
 98 {                                                 126 {
                                                   >> 127   maxSubCutInRange = 0.7*mm;
 99   models.reserve(4);                              128   models.reserve(4);
100   flucModels.reserve(4);                          129   flucModels.reserve(4);
101   regions.reserve(4);                             130   regions.reserve(4);
102   orderOfModels.reserve(4);                       131   orderOfModels.reserve(4);
103   isUsed.reserve(4);                              132   isUsed.reserve(4);
                                                   >> 133   severalModels = true;
                                                   >> 134   currRegionModel = 0;
                                                   >> 135   currModel = 0;
104 }                                                 136 }
105                                                   137 
106 //....oooOO0OOooo........oooOO0OOooo........oo    138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107                                                   139 
108 G4EmModelManager::~G4EmModelManager()             140 G4EmModelManager::~G4EmModelManager()
109 {                                                 141 {
110   verboseLevel = 0; // no verbosity at destruc    142   verboseLevel = 0; // no verbosity at destruction
111   Clear();                                        143   Clear();
112   delete theCutsNew;                           << 
113 }                                                 144 }
114                                                   145 
115 //....oooOO0OOooo........oooOO0OOooo........oo    146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
116                                                   147 
117 void G4EmModelManager::Clear()                    148 void G4EmModelManager::Clear()
118 {                                                 149 {
119   if(1 < verboseLevel) {                          150   if(1 < verboseLevel) {
120     G4cout << "G4EmModelManager::Clear()" << G    151     G4cout << "G4EmModelManager::Clear()" << G4endl;
121   }                                               152   }
122   std::size_t n = setOfRegionModels.size();    << 153   size_t n = setOfRegionModels.size();
123   for(std::size_t i=0; i<n; ++i) {             << 154   if(n > 0) {
124     delete setOfRegionModels[i];               << 155     for(size_t i=0; i<n; ++i) {
125     setOfRegionModels[i] = nullptr;            << 156       delete setOfRegionModels[i];
                                                   >> 157       setOfRegionModels[i] = 0;
                                                   >> 158     }
126   }                                               159   }
127 }                                                 160 }
128                                                   161 
129 //....oooOO0OOooo........oooOO0OOooo........oo    162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
130                                                   163 
131 void G4EmModelManager::AddEmModel(G4int num, G    164 void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p,
132                                   G4VEmFluctua    165                                   G4VEmFluctuationModel* fm, const G4Region* r)
133 {                                                 166 {
134   if(nullptr == p) {                           << 167   if(!p) {
135     G4cout << "G4EmModelManager::AddEmModel WA    168     G4cout << "G4EmModelManager::AddEmModel WARNING: no model defined." 
136            << G4endl;                          << 169      << G4endl;
137     return;                                       170     return;
138   }                                               171   }
139   models.push_back(p);                            172   models.push_back(p);
140   flucModels.push_back(fm);                       173   flucModels.push_back(fm);
141   regions.push_back(r);                           174   regions.push_back(r);
142   orderOfModels.push_back(num);                   175   orderOfModels.push_back(num);
143   isUsed.push_back(0);                            176   isUsed.push_back(0);
144   p->DefineForRegion(r);                          177   p->DefineForRegion(r);
145   ++nEmModels;                                 << 178   nEmModels++;
146 }                                                 179 }
147                                                   180 
148 //....oooOO0OOooo........oooOO0OOooo........oo    181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
149                                                   182 
150 G4VEmModel* G4EmModelManager::GetModel(G4int i << 183 void G4EmModelManager::UpdateEmModel(const G4String& nam, 
                                                   >> 184              G4double emin, G4double emax)
151 {                                                 185 {
152   G4VEmModel* model = nullptr;                 << 186   if (nEmModels > 0) {
153   if(idx >= 0 && idx < nEmModels) { model = mo << 187     for(G4int i=0; i<nEmModels; ++i) {
154   else if(verboseLevel > 0 && ver) {           << 188       if(nam == models[i]->GetName()) {
155     G4cout << "G4EmModelManager::GetModel WARN << 189         models[i]->SetLowEnergyLimit(emin);
156            << "index " << idx << " is wrong Nm << 190         models[i]->SetHighEnergyLimit(emax);
157            << nEmModels;                       << 191   break;
158     if(nullptr != particle) {                  << 192       }
159       G4cout << " for " << particle->GetPartic << 
160     }                                             193     }
161     G4cout<< G4endl;                           << 
162   }                                               194   }
163   return model;                                << 195   G4cout << "G4EmModelManager::UpdateEmModel WARNING: no model <"
                                                   >> 196          << nam << "> is found out"
                                                   >> 197    << G4endl;
164 }                                                 198 }
165                                                   199 
166 //....oooOO0OOooo........oooOO0OOooo........oo    200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
167                                                   201 
168 G4VEmModel* G4EmModelManager::GetRegionModel(G << 202 G4VEmModel* G4EmModelManager::GetModel(G4int i, G4bool ver)
169 {                                                 203 {
170   G4RegionModels* rm = setOfRegionModels[idxOf << 204   G4VEmModel* m = 0;
171   return (k < rm->NumberOfModels()) ? models[r << 205   if(i >= 0 && i < nEmModels) {m = models[i];}
172 }                                              << 206   else if(verboseLevel > 0 && ver) { 
173                                                << 207     G4cout << "G4EmModelManager::GetModel WARNING: "
174 //....oooOO0OOooo........oooOO0OOooo........oo << 208      << "index " << i << " is wrong Nmodels= "
175                                                << 209      << nEmModels;
176 G4int G4EmModelManager::NumberOfRegionModels(s << 210     if(particle) G4cout << " for " << particle->GetParticleName(); 
177 {                                              << 211     G4cout<< G4endl;
178   G4RegionModels* rm = setOfRegionModels[idxOf << 212   }
179   return rm->NumberOfModels();                 << 213   return m;
180 }                                                 214 }
181                                                   215 
182 //....oooOO0OOooo........oooOO0OOooo........oo    216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
183                                                   217 
184 const G4DataVector*                               218 const G4DataVector* 
185 G4EmModelManager::Initialise(const G4ParticleD    219 G4EmModelManager::Initialise(const G4ParticleDefinition* p,
186                              const G4ParticleD << 220            const G4ParticleDefinition* secondaryParticle,
187                              G4int verb)       << 221            G4double minSubRange,
                                                   >> 222            G4int val)
188 {                                                 223 {
189   verboseLevel = verb;                         << 224   verboseLevel = val;
                                                   >> 225   G4String partname = p->GetParticleName();
190   if(1 < verboseLevel) {                          226   if(1 < verboseLevel) {
191     G4cout << "G4EmModelManager::Initialise()     227     G4cout << "G4EmModelManager::Initialise() for "
192            << p->GetParticleName() << "  Nmode << 228            << partname << G4endl;
193   }                                               229   }
194   // Are models defined?                          230   // Are models defined?
195   if(nEmModels < 1) {                             231   if(nEmModels < 1) {
196     G4ExceptionDescription ed;                 << 232     G4Exception("G4EmModelManager::Initialise: no model defined for " + partname);
197     ed << "No models found out for " << p->Get << 
198        << " !";                                << 
199     G4Exception("G4EmModelManager::Initialise" << 
200                 FatalException, ed);           << 
201   }                                               233   }
202                                                   234 
203   particle = p;                                   235   particle = p;
204   Clear(); // needed if run is not first          236   Clear(); // needed if run is not first
205                                                   237 
206   G4RegionStore* regionStore = G4RegionStore::    238   G4RegionStore* regionStore = G4RegionStore::GetInstance();
207   const G4Region* world =                         239   const G4Region* world = 
208     regionStore->GetRegion("DefaultRegionForTh    240     regionStore->GetRegion("DefaultRegionForTheWorld", false);
209                                                   241 
210   // Identify the list of regions with differe    242   // Identify the list of regions with different set of models
211   nRegions = 1;                                   243   nRegions = 1;
212   std::vector<const G4Region*> setr;              244   std::vector<const G4Region*> setr;
213   setr.push_back(world);                          245   setr.push_back(world);
214   G4bool isWorld = false;                         246   G4bool isWorld = false;
215                                                   247 
216   for (G4int ii=0; ii<nEmModels; ++ii) {          248   for (G4int ii=0; ii<nEmModels; ++ii) {
217     const G4Region* r = regions[ii];              249     const G4Region* r = regions[ii];
218     if ( r == nullptr || r == world) {         << 250     if ( r == 0 || r == world) {
219       isWorld = true;                             251       isWorld = true;
220       regions[ii] = world;                        252       regions[ii] = world;
221     } else {                                      253     } else {
222       G4bool newRegion = true;                    254       G4bool newRegion = true;
223       if (nRegions>1) {                           255       if (nRegions>1) {
224         for (G4int j=1; j<nRegions; ++j) {        256         for (G4int j=1; j<nRegions; ++j) {
225           if ( r == setr[j] ) { newRegion = fa << 257     if ( r == setr[j] ) newRegion = false;
226         }                                         258         }
227       }                                           259       }
228       if (newRegion) {                            260       if (newRegion) {
229         setr.push_back(r);                        261         setr.push_back(r);
230         ++nRegions;                            << 262   nRegions++;
231       }                                           263       }
232     }                                             264     }
233   }                                               265   }
234   // Are models defined?                          266   // Are models defined?
235   if(!isWorld) {                                  267   if(!isWorld) {
236     G4ExceptionDescription ed;                 << 268     G4Exception("G4EmModelManager::Initialise: no models defined for " + 
237     ed << "No models defined for the World vol << 269     partname + " in the World volume");
238        << p->GetParticleName() << " !";        << 
239     G4Exception("G4EmModelManager::Initialise" << 
240                 FatalException, ed);           << 
241   }                                               270   }
242                                                   271 
243   G4ProductionCutsTable* theCoupleTable=          272   G4ProductionCutsTable* theCoupleTable=
244     G4ProductionCutsTable::GetProductionCutsTa    273     G4ProductionCutsTable::GetProductionCutsTable();
245   std::size_t numOfCouples = theCoupleTable->G << 274   size_t numOfCouples = theCoupleTable->GetTableSize();
246                                                   275 
247   // prepare vectors, shortcut for the case of    276   // prepare vectors, shortcut for the case of only 1 model
248   // or only one region                        << 
249   if(nRegions > 1 && nEmModels > 1) {             277   if(nRegions > 1 && nEmModels > 1) {
250     idxOfRegionModels.resize(numOfCouples,0);  << 278     if(numOfCouples > idxOfRegionModels.size()) idxOfRegionModels.resize(numOfCouples);
251     setOfRegionModels.resize((std::size_t)nReg << 
252   } else {                                     << 
253     idxOfRegionModels.resize(1,0);             << 
254     setOfRegionModels.resize(1,nullptr);       << 
255   }                                               279   }
                                                   >> 280   size_t nr = 1;
                                                   >> 281   if(nEmModels > 1) nr = nRegions;
                                                   >> 282   if(nr > setOfRegionModels.size()) setOfRegionModels.resize(nr);
256                                                   283 
257   std::vector<G4int>    modelAtRegion(nEmModel    284   std::vector<G4int>    modelAtRegion(nEmModels);
258   std::vector<G4int>    modelOrd(nEmModels);      285   std::vector<G4int>    modelOrd(nEmModels);
259   G4DataVector          eLow(nEmModels+1);        286   G4DataVector          eLow(nEmModels+1);
260   G4DataVector          eHigh(nEmModels);         287   G4DataVector          eHigh(nEmModels);
261                                                   288 
262   if(1 < verboseLevel) {                       << 
263     G4cout << "    Nregions= " << nRegions     << 
264            << "  Nmodels= " << nEmModels << G4 << 
265   }                                            << 
266                                                << 
267   // Order models for regions                     289   // Order models for regions
268   for (G4int reg=0; reg<nRegions; ++reg) {        290   for (G4int reg=0; reg<nRegions; ++reg) {
269     const G4Region* region = setr[reg];           291     const G4Region* region = setr[reg];
270     G4int n = 0;                                  292     G4int n = 0;
271                                                   293 
272     for (G4int ii=0; ii<nEmModels; ++ii) {        294     for (G4int ii=0; ii<nEmModels; ++ii) {
273                                                   295 
274       G4VEmModel* model = models[ii];             296       G4VEmModel* model = models[ii];
275       if ( region == regions[ii] ) {              297       if ( region == regions[ii] ) {
276                                                   298 
277         G4double tmin = model->LowEnergyLimit( << 299   G4double tmin = model->LowEnergyLimit();
278         G4double tmax = model->HighEnergyLimit << 300   G4double tmax = model->HighEnergyLimit();
279         G4int  ord    = orderOfModels[ii];     << 301   G4int  ord    = orderOfModels[ii];
280         G4bool push   = true;                  << 302   G4bool push   = true;
281         G4bool insert = false;                 << 303   G4bool insert = false;
282         G4int  idx    = n;                     << 304   G4int  idx    = n;
283                                                << 305 
284         if(1 < verboseLevel) {                 << 306   if(1 < verboseLevel) {
285           G4cout << "Model #" << ii            << 307     G4cout << "Model #" << ii 
286                  << " <" << model->GetName() < << 308      << " <" << model->GetName() << "> for region <";
287           if (region) G4cout << region->GetNam << 309     if (region) G4cout << region->GetName();
288           G4cout << ">  "                      << 310     G4cout << ">  "
289                  << " tmin(MeV)= " << tmin/MeV << 311      << " tmin(MeV)= " << tmin/MeV
290                  << "; tmax(MeV)= " << tmax/Me << 312      << "; tmax(MeV)= " << tmax/MeV
291                  << "; order= " << ord         << 313      << "; order= " << ord
292      << "; tminAct= " << model->LowEnergyActiv << 314      << G4endl;
293      << "; tmaxAct= " << model->HighEnergyActi << 315   }
294                  << G4endl;                    << 
295         }                                      << 
296                                                   316         
297   static const G4double limitdelta = 0.01*eV;  << 317   if(n > 0) {
298         if(n > 0) {                            << 
299                                                   318 
300           // extend energy range to previous m << 319     // extend energy range to previous models
301           tmin = std::min(tmin, eHigh[n-1]);   << 320     tmin = std::min(tmin, eHigh[n-1]);
302           tmax = std::max(tmax, eLow[0]);      << 321     tmax = std::max(tmax, eLow[0]);
303           //G4cout << "tmin= " << tmin << "  t << 322     //G4cout << "tmin= " << tmin << "  tmax= " 
304           //           << tmax << "  ord= " << << 323     //     << tmax << "  ord= " << ord <<G4endl;
305           // empty energy range                << 324     // empty energy range
306           if( tmax - tmin <= limitdelta) { pus << 325     if( tmax - tmin <= eV) push = false;
307           // low-energy model                  << 326     // low-energy model
308           else if (tmax == eLow[0]) {          << 327     else if (tmax == eLow[0]) {
309             push = false;                      << 328       push = false;
310             insert = true;                     << 329       insert = true;
311             idx = 0;                           << 330       idx = 0;
312             // resolve intersections           << 331       // resolve intersections
313           } else if(tmin < eHigh[n-1]) {       << 332     } else if(tmin < eHigh[n-1]) { 
314             // compare order                   << 333       // compare order
315             for(G4int k=0; k<n; ++k) {         << 334       for(G4int k=0; k<n; ++k) {
316               // new model has higher order pa << 335         // new model has lower application 
317         // so, its application area may be red << 336         if(ord >= modelOrd[k]) {
318         // to avoid intersections              << 337     if(tmin < eHigh[k]  && tmin >= eLow[k]) tmin = eHigh[k];
319               if(ord >= modelOrd[k]) {         << 338     if(tmax <= eHigh[k] && tmax >  eLow[k]) tmax = eLow[k];
320                 if(tmin < eHigh[k]  && tmin >= << 339     if(tmax > eHigh[k] && tmin < eLow[k]) {
321                 if(tmax <= eHigh[k] && tmax >  << 340       if(tmax - eHigh[k] > eLow[k] - tmin) tmin = eHigh[k];
322                 if(tmax > eHigh[k] && tmin < e << 341       else tmax = eLow[k];
323                   if(tmax - eHigh[k] > eLow[k] << 342     }
324                   else { tmax = eLow[k]; }     << 343     if( tmax - tmin <= eV) {
325                 }                              << 344       push = false;
326                 if( tmax - tmin <= limitdelta) << 345       break;
327                   push = false;                << 346     }
328                   break;                       << 347         }
329                 }                              << 348       }
330               }                                << 349       //G4cout << "tmin= " << tmin << "  tmax= " 
331             }                                  << 350       //     << tmax << "  push= " << push << " idx= " << idx <<G4endl;
332       // this model has lower order parameter  << 351       if(push) {
333       // other models, with which there may be << 352         if (tmax == eLow[0]) {
334       // so, appliction area of such models ma << 
335                                                << 
336       // insert below the first model          << 
337       if (tmax <= eLow[0]) {                   << 
338         push = false;                          << 
339         insert = true;                         << 
340         idx = 0;                               << 
341         // resolve intersections               << 
342       } else if(tmin < eHigh[n-1]) {           << 
343         // last energy interval                << 
344         if(tmin > eLow[n-1] && tmax >= eHigh[n << 
345     eHigh[n-1] = tmin;                         << 
346     // first energy interval                   << 
347         } else if(tmin <= eLow[0] && tmax < eH << 
348     eLow[0] = tmax;                            << 
349     push = false;                                 353     push = false;
350     insert = true;                                354     insert = true;
351     idx = 0;                                      355     idx = 0;
352     // loop over all models                    << 356     // continue resolve intersections
353         } else {                               << 357         } else if(tmin < eHigh[n-1]) { 
354     for(G4int k=n-1; k>=0; --k) {              << 358     // last energy interval
355       if(tmin <= eLow[k] && tmax >= eHigh[k])  << 359     if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) {
356         // full overlap exclude previous model << 360       eHigh[n-1] = tmin;
357         isUsed[modelAtRegion[k]] = 0;          << 361       // first energy interval
358         idx = k;                               << 362     } else if(tmin <= eLow[0] && tmax < eHigh[0]) {
359         if(k < n-1) {                          << 363       eLow[0] = tmax;
360           // shift upper models and change ind << 364       push = false;
361           for(G4int kk=k; kk<n-1; ++kk) {      << 365       insert = true;
362       modelAtRegion[kk] = modelAtRegion[kk+1]; << 366       idx = 0;
363       modelOrd[kk] = modelOrd[kk+1];           << 367     } else {
364       eLow[kk] = eLow[kk+1];                   << 368       // find energy interval to replace
365       eHigh[kk] = eHigh[kk+1];                 << 369       for(G4int k=0; k<n; ++k) { 
366           }                                    << 370         if(tmin <= eLow[k] && tmax >= eHigh[k]) {
367                       ++k;                     << 371           push = false;
368         }                                      << 372           modelAtRegion[k] = ii;
369         --n;                                   << 373           modelOrd[k] = ord;
370       } else {                                 << 374           isUsed[ii] = 1;
371         // partially reduce previous model are << 375         } 
372         if(tmin <= eLow[k] && tmax > eLow[k])  << 376       }
373           eLow[k] = tmax;                      << 377     }
374                       idx = k;                 << 
375                       insert = true;           << 
376                       push = false;            << 
377         } else if(tmin < eHigh[k] && tmax >= e << 
378           eHigh[k] = tmin;                     << 
379                       idx = k + 1;             << 
380                       if(idx < n) {            << 
381       insert = true;                           << 
382       push = false;                            << 
383           }                                    << 
384         } else if(tmin > eLow[k] && tmax < eHi << 
385           if(eHigh[k] - tmax > tmin - eLow[k]) << 
386       eLow[k] = tmax;                          << 
387                         idx = k;               << 
388                         insert = true;         << 
389       push = false;                            << 
390           } else {                             << 
391       eHigh[k] = tmin;                         << 
392       idx = k + 1;                             << 
393       if(idx < n) {                            << 
394         insert = true;                         << 
395         push = false;                          << 
396       }                                        << 
397           }                                    << 
398         }                                      << 
399                   }                            << 
400                 }                              << 
401               }                                << 
402             }                                  << 
403           }                                    << 
404         }                                      << 
405   // provide space for the new model           << 
406         if(insert) {                           << 
407           for(G4int k=n-1; k>=idx; --k) {      << 
408             modelAtRegion[k+1] = modelAtRegion << 
409             modelOrd[k+1] = modelOrd[k];       << 
410             eLow[k+1]  = eLow[k];              << 
411             eHigh[k+1] = eHigh[k];             << 
412           }                                    << 
413         }                                      << 
414         //G4cout << "push= " << push << " inse << 
415   //       << " idx= " << idx <<G4endl;        << 
416   // the model is added                        << 
417         if (push || insert) {                  << 
418           ++n;                                 << 
419           modelAtRegion[idx] = ii;             << 
420           modelOrd[idx] = ord;                 << 
421           eLow[idx]  = tmin;                   << 
422           eHigh[idx] = tmax;                   << 
423           isUsed[ii] = 1;                      << 
424         }                                      << 
425   // exclude models with zero energy range     << 
426   for(G4int k=n-1; k>=0; --k) {                << 
427     if(eHigh[k] - eLow[k] <= limitdelta) {     << 
428       isUsed[modelAtRegion[k]] = 0;            << 
429       if(k < n-1) {                            << 
430         for(G4int kk=k; kk<n-1; ++kk) {        << 
431     modelAtRegion[kk] = modelAtRegion[kk+1];   << 
432     modelOrd[kk] = modelOrd[kk+1];             << 
433     eLow[kk] = eLow[kk+1];                     << 
434     eHigh[kk] = eHigh[kk+1];                   << 
435         }                                         378         }
436       }                                           379       }
437       --n;                                     << 
438     }                                             380     }
439   }                                               381   }
                                                   >> 382   if(insert) {
                                                   >> 383     for(G4int k=n-1; k>=idx; --k) {    
                                                   >> 384       modelAtRegion[k+1] = modelAtRegion[k];
                                                   >> 385       modelOrd[k+1] = modelOrd[k];
                                                   >> 386       eLow[k+1]  = eLow[k];
                                                   >> 387       eHigh[k+1] = eHigh[k];
                                                   >> 388     }
                                                   >> 389   }
                                                   >> 390   //G4cout << "push= " << push << " insert= " << insert 
                                                   >> 391   //<< " idx= " << idx <<G4endl;
                                                   >> 392   if (push || insert) {
                                                   >> 393     ++n;
                                                   >> 394     modelAtRegion[idx] = ii;
                                                   >> 395     modelOrd[idx] = ord;
                                                   >> 396     eLow[idx]  = tmin;
                                                   >> 397     eHigh[idx] = tmax;
                                                   >> 398     isUsed[ii] = 1;
                                                   >> 399   }
440       }                                           400       }
441     }                                             401     }
442     eLow[0] = 0.0;                                402     eLow[0] = 0.0;
443     eLow[n] = eHigh[n-1];                         403     eLow[n] = eHigh[n-1];
444                                                   404 
445     if(1 < verboseLevel) {                        405     if(1 < verboseLevel) {
446       G4cout << "### New G4RegionModels set wi << 406       G4cout << "New G4RegionModels set with " << n << " models for region <";
447              << " models for region <";        << 407       if (region) G4cout << region->GetName();
448       if (region) { G4cout << region->GetName( << 
449       G4cout << ">  Elow(MeV)= ";                 408       G4cout << ">  Elow(MeV)= ";
450       for(G4int iii=0; iii<=n; ++iii) {G4cout  << 409       for(G4int ii=0; ii<=n; ++ii) {G4cout << eLow[ii]/MeV << " ";}
451       G4cout << G4endl;                           410       G4cout << G4endl;
452     }                                             411     }
453     auto rm = new G4RegionModels(n, modelAtReg << 412     G4RegionModels* rm = new G4RegionModels(n, modelAtRegion, eLow, region);
454     setOfRegionModels[reg] = rm;                  413     setOfRegionModels[reg] = rm;
455     // shortcut                                << 414     if(1 == nEmModels) break;
456     if(1 == nEmModels) { break; }              << 
457   }                                               415   }
458                                                   416 
459   currRegionModel = setOfRegionModels[0];         417   currRegionModel = setOfRegionModels[0];
460   currModel = models[0];                       << 
461                                                   418 
462   // Access to materials and build cuts           419   // Access to materials and build cuts
463   std::size_t idx = 1;                         << 420   size_t idx = 1;
464   if(nullptr != secondaryParticle) {           << 421   if(secondaryParticle) {
465     if( secondaryParticle == G4Gamma::Gamma()     422     if( secondaryParticle == G4Gamma::Gamma() )           { idx = 0; }
466     else if( secondaryParticle == G4Electron:: << 
467     else if( secondaryParticle == G4Positron::    423     else if( secondaryParticle == G4Positron::Positron()) { idx = 2; }
468     else { idx = 3; }                          << 
469   }                                               424   }
470                                                   425 
471   theCuts =                                    << 426   if(numOfCouples > theCuts.size()) { theCuts.resize(numOfCouples); }
472     static_cast<const G4DataVector*>(theCouple << 427   if(minSubRange < 1.0 && numOfCouples > theSubCuts.size()) {
473                                                << 428     theSubCuts.resize(numOfCouples);
474   // for the second run the check on cuts shou << 429   }
475   if(nullptr != theCutsNew) { *theCutsNew = *t << 430   for(size_t i=0; i<numOfCouples; ++i) {
476                                                << 
477   //  G4cout << "========Start define cuts" << << 
478   // define cut values                         << 
479   for(std::size_t i=0; i<numOfCouples; ++i) {  << 
480                                                   431 
481     const G4MaterialCutsCouple* couple =          432     const G4MaterialCutsCouple* couple = 
482       theCoupleTable->GetMaterialCutsCouple((G << 433       theCoupleTable->GetMaterialCutsCouple(i);
483     const G4Material* material = couple->GetMa    434     const G4Material* material = couple->GetMaterial();
484     const G4ProductionCuts* pcuts = couple->Ge    435     const G4ProductionCuts* pcuts = couple->GetProductionCuts();
485                                                   436  
486     G4int reg = 0;                                437     G4int reg = 0;
487     if(nRegions > 1 && nEmModels > 1) {           438     if(nRegions > 1 && nEmModels > 1) {
488       reg = nRegions;                             439       reg = nRegions;
489       // Loop checking, 03-Aug-2015, Vladimir  << 
490       do {--reg;} while (reg>0 && pcuts != (se    440       do {--reg;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts()));
491       idxOfRegionModels[i] = reg;                 441       idxOfRegionModels[i] = reg;
492     }                                             442     }
493     if(1 < verboseLevel) {                        443     if(1 < verboseLevel) {
494       G4cout << "G4EmModelManager::Initialise(    444       G4cout << "G4EmModelManager::Initialise() for "
495              << material->GetName()            << 445        << material->GetName()
496              << " indexOfCouple= " << i        << 446        << " indexOfCouple= " << i
497              << " indexOfRegion= " << reg      << 447        << " indexOfRegion= " << reg
498              << G4endl;                        << 448        << G4endl;
499     }                                          << 449     }
500                                                << 450 
501     G4double cut = (*theCuts)[i];              << 451     G4double cut = (*theCoupleTable->GetEnergyCutsVector(idx))[i]; 
502     if(nullptr != secondaryParticle) {         << 452     G4double subcut = DBL_MAX;
503                                                << 453     if(secondaryParticle) {
504       // note that idxOfRegionModels[] not alw << 454 
505       G4int inn = 0;                           << 455       // compute subcut 
506       G4int nnm = 1;                           << 456       if( cut < DBL_MAX && minSubRange < 1.0) {
507       if(nRegions > 1 && nEmModels > 1) {      << 457   subcut = minSubRange*cut;
508         inn = idxOfRegionModels[i];            << 458         G4double rcut = std::min(minSubRange*pcuts->GetProductionCut(idx), 
                                                   >> 459          maxSubCutInRange);
                                                   >> 460   G4double tcutmax = 
                                                   >> 461     theCoupleTable->ConvertRangeToEnergy(secondaryParticle,material,rcut);
                                                   >> 462   if(tcutmax < subcut) { subcut = tcutmax; }
509       }                                           463       }
510       // check cuts and introduce upper limits << 
511       //G4cout << "idx= " << i << " cut(keV)=  << 
512       currRegionModel = setOfRegionModels[inn] << 
513       nnm = currRegionModel->NumberOfModels(); << 
514                                                << 
515       //G4cout << "idx= " << i << " Nmod= " << << 
516                                                << 
517       for(G4int jj=0; jj<nnm; ++jj) {          << 
518         //G4cout << "jj= " << jj << "  modidx= << 
519         //       << currRegionModel->ModelInde << 
520         currModel = models[currRegionModel->Mo << 
521         G4double cutlim = currModel->MinEnergy << 
522         if(cutlim > cut) {                     << 
523           if(nullptr == theCutsNew) { theCutsN << 
524           (*theCutsNew)[i] = cutlim;           << 
525           /*                                   << 
526           G4cout << "### " << partname << " en << 
527                  << material->GetName()        << 
528                  << "  Cut was changed from "  << 
529                  << cutlim/keV << " keV " << " << 
530                  << currModel->GetName() << G4 << 
531           */                                   << 
532         }                                      << 
533       }                                        << 
534     }                                             464     }
                                                   >> 465     theCuts[i] = cut;
                                                   >> 466     if(minSubRange < 1.0) { theSubCuts[i] = subcut; }
535   }                                               467   }
536   if(nullptr != theCutsNew) { theCuts = theCut << 
537                                                   468 
538   // initialize models                            469   // initialize models
539   G4int nn = 0;                                   470   G4int nn = 0;
540   severalModels = true;                           471   severalModels = true;
541   for(G4int jj=0; jj<nEmModels; ++jj) {           472   for(G4int jj=0; jj<nEmModels; ++jj) {
542     if(1 == isUsed[jj]) {                         473     if(1 == isUsed[jj]) {
543       ++nn;                                       474       ++nn;
544       currModel = models[jj];                     475       currModel = models[jj];
545       currModel->Initialise(particle, *theCuts << 476       currModel->Initialise(particle, theCuts);
546       if(nullptr != flucModels[jj]) { flucMode << 477       if(flucModels[jj]) flucModels[jj]->InitialiseMe(particle);
547     }                                             478     }
548   }                                               479   }
549   if(1 == nn) { severalModels = false; }          480   if(1 == nn) { severalModels = false; }
550                                                   481 
551   if(1 < verboseLevel) {                          482   if(1 < verboseLevel) {
552     G4cout << "G4EmModelManager for " << parti << 483     G4cout << "G4EmModelManager for " << particle->GetParticleName() 
553            << " is initialised; nRegions=  " <    484            << " is initialised; nRegions=  " << nRegions
554            << " severalModels: " << severalMod << 
555            << G4endl;                             485            << G4endl;
556   }                                               486   }
557   return theCuts;                              << 487 
                                                   >> 488   return &theCuts;
558 }                                                 489 }
559                                                   490 
560 //....oooOO0OOooo........oooOO0OOooo........oo    491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
561                                                   492 
562 void G4EmModelManager::FillDEDXVector(G4Physic    493 void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector,
563                                       const G4 << 494               const G4MaterialCutsCouple* couple,
564                                       G4EmTabl    495                                       G4EmTableType tType)
565 {                                                 496 {
566   std::size_t i = couple->GetIndex();          << 497   size_t i = couple->GetIndex();
567   G4double cut  = (fTotal == tType) ? DBL_MAX  << 498   G4double cut = theCuts[i];
                                                   >> 499   G4double emin = 0.0;
                                                   >> 500 
                                                   >> 501   if(fTotal == tType) cut = DBL_MAX;
                                                   >> 502   else if(fSubRestricted == tType) {
                                                   >> 503     emin = cut;
                                                   >> 504     if(theSubCuts.size() > 0) emin = theSubCuts[i];
                                                   >> 505   }
568                                                   506 
569   if(1 < verboseLevel) {                          507   if(1 < verboseLevel) {
570     G4cout << "G4EmModelManager::FillDEDXVecto    508     G4cout << "G4EmModelManager::FillDEDXVector() for "
571            << couple->GetMaterial()->GetName()    509            << couple->GetMaterial()->GetName()
572            << "  cut(MeV)= " << cut            << 510      << "  cut(MeV)= " << cut
573            << "  Type " << tType               << 511      << "  emin(MeV)= " << emin
574            << "  for " << particle->GetParticl << 512      << "  Type " << tType
                                                   >> 513      << "  for " << particle->GetParticleName()
575            << G4endl;                             514            << G4endl;
576   }                                               515   }
577                                                   516 
578   G4int reg  = 0;                                 517   G4int reg  = 0;
579   if(nRegions > 1 && nEmModels > 1) { reg = id << 518   if(nRegions > 1 && nEmModels > 1) reg = idxOfRegionModels[i];
580   const G4RegionModels* regModels = setOfRegio    519   const G4RegionModels* regModels = setOfRegionModels[reg];
581   G4int nmod = regModels->NumberOfModels();       520   G4int nmod = regModels->NumberOfModels();
582                                                   521 
583   // Calculate energy losses vector               522   // Calculate energy losses vector
584   std::size_t totBinsLoss = aVector->GetVector << 
585   G4double del = 0.0;                          << 
586   G4int    k0  = 0;                            << 
587                                                   523 
588   for(std::size_t j=0; j<totBinsLoss; ++j) {   << 524   //G4cout << "nmod= " << nmod << G4endl;
                                                   >> 525   size_t totBinsLoss = aVector->GetVectorLength();
                                                   >> 526   for(size_t j=0; j<totBinsLoss; ++j) {
                                                   >> 527 
589     G4double e = aVector->Energy(j);              528     G4double e = aVector->Energy(j);
                                                   >> 529     G4double del = 0.0;
590                                                   530 
591     // Choose a model of energy losses            531     // Choose a model of energy losses
592     G4int k = 0;                                  532     G4int k = 0;
593     if (nmod > 1) {                               533     if (nmod > 1) {
594       k = nmod;                                   534       k = nmod;
595       // Loop checking, 03-Aug-2015, Vladimir  << 
596       do {--k;} while (k>0 && e <= regModels->    535       do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
597       //G4cout << "k= " << k << G4endl;           536       //G4cout << "k= " << k << G4endl;
598       if(k > 0 && k != k0) {                   << 537       if(k > 0) {
599         k0 = k;                                << 
600         G4double elow = regModels->LowEdgeEner    538         G4double elow = regModels->LowEdgeEnergy(k);
601   G4double dedx1 =                             << 539   G4double dedx1 = ComputeDEDX(models[regModels->ModelIndex(k-1)],
602     models[regModels->ModelIndex(k-1)]->Comput << 540              couple,elow,cut,emin);
603         G4double dedx2 =                       << 541   G4double dedx2 = ComputeDEDX(models[regModels->ModelIndex(k)],
604     models[regModels->ModelIndex(k)]->ComputeD << 542              couple,elow,cut,emin);
605         del = (dedx2 > 0.0) ? (dedx1/dedx2 - 1 << 543         del = (dedx1 - dedx2)*elow/e;
606         //G4cout << "elow= " << elow           << 544   //G4cout << "elow= " << elow 
607         //       << " dedx1= " << dedx1 << " d << 545   //       << " dedx1= " << dedx1 << " dedx2= " << dedx2 << G4endl;
608       }                                           546       }
609     }                                             547     }
610     G4double dedx = (1.0 + del/e)*             << 548     G4double dedx = ComputeDEDX(models[regModels->ModelIndex(k)],
611     models[regModels->ModelIndex(k)]->ComputeD << 549         couple,e,cut,emin) + del;
612                                                   550 
                                                   >> 551     if(dedx < 0.0) dedx = 0.0;
613     if(2 < verboseLevel) {                        552     if(2 < verboseLevel) {
614       G4cout << "Material= " << couple->GetMat    553       G4cout << "Material= " << couple->GetMaterial()->GetName()
615              << "   E(MeV)= " << e/MeV         << 554        << "   E(MeV)= " << e/MeV
616              << "  dEdx(MeV/mm)= " << dedx*mm/ << 555        << "  dEdx(MeV/mm)= " << dedx*mm/MeV
617              << "  del= " << del*mm/MeV<< " k= << 556        << "  del= " << del*mm/MeV<< " k= " << k 
618              << " modelIdx= " << regModels->Mo << 557        << " modelIdx= " << regModels->ModelIndex(k)
619              << G4endl;                        << 558        << G4endl;
620     }                                             559     }
621     dedx = std::max(dedx, 0.0);                << 
622     aVector->PutValue(j, dedx);                   560     aVector->PutValue(j, dedx);
623   }                                               561   }
624 }                                                 562 }
625                                                   563 
626 //....oooOO0OOooo........oooOO0OOooo........oo    564 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
627                                                   565 
628 void G4EmModelManager::FillLambdaVector(G4Phys    566 void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector,
629                                         const  << 567           const G4MaterialCutsCouple* couple,
630                                         G4bool << 568                 G4bool startFromNull,
631                                         G4EmTa << 569           G4EmTableType tType)
632 {                                                 570 {
633   std::size_t i = couple->GetIndex();          << 571   size_t i = couple->GetIndex();
634   G4double cut  = (*theCuts)[i];               << 572   G4double cut  = theCuts[i];
635   G4double tmax = DBL_MAX;                        573   G4double tmax = DBL_MAX;
                                                   >> 574   if (fSubRestricted == tType) {
                                                   >> 575     tmax = cut;
                                                   >> 576     if(theSubCuts.size() > 0) cut  = theSubCuts[i];
                                                   >> 577   }
636                                                   578 
637   G4int reg  = 0;                                 579   G4int reg  = 0;
638   if(nRegions > 1 && nEmModels > 1) { reg  = i << 580   if(nRegions > 1 && nEmModels > 1) reg  = idxOfRegionModels[i];
639   const G4RegionModels* regModels = setOfRegio    581   const G4RegionModels* regModels = setOfRegionModels[reg];
640   G4int nmod = regModels->NumberOfModels();       582   G4int nmod = regModels->NumberOfModels();
641   if(1 < verboseLevel) {                          583   if(1 < verboseLevel) {
642     G4cout << "G4EmModelManager::FillLambdaVec    584     G4cout << "G4EmModelManager::FillLambdaVector() for "
643            << particle->GetParticleName()         585            << particle->GetParticleName()
644            << " in " << couple->GetMaterial()-    586            << " in " << couple->GetMaterial()->GetName()
645            << " Emin(MeV)= " << aVector->Energ << 587      << " Ecut(MeV)= " << cut
646            << " Emax(MeV)= " << aVector->GetMa << 588      << " Emax(MeV)= " << tmax
647            << " cut= " << cut                  << 589      << " Type " << tType   
648            << " Type " << tType                << 590      << " nmod= " << nmod
649            << " nmod= " << nmod                << 
650            << G4endl;                             591            << G4endl;
651   }                                               592   }
652                                                   593 
                                                   >> 594 
653   // Calculate lambda vector                      595   // Calculate lambda vector
654   std::size_t totBinsLambda = aVector->GetVect << 596   size_t totBinsLambda = aVector->GetVectorLength();
655   G4double del = 0.0;                          << 597   for(size_t j=0; j<totBinsLambda; ++j) {
656   G4int    k0  = 0;                            << 
657   G4int     k  = 0;                            << 
658   G4VEmModel* mod = models[regModels->ModelInd << 
659   for(std::size_t j=0; j<totBinsLambda; ++j) { << 
660                                                   598 
661     G4double e = aVector->Energy(j);              599     G4double e = aVector->Energy(j);
662                                                   600 
                                                   >> 601     G4double del = 0.0;
                                                   >> 602 
663     // Choose a model                             603     // Choose a model 
                                                   >> 604     G4int k = 0;
                                                   >> 605     G4VEmModel* mod = models[regModels->ModelIndex(0)]; 
664     if (nmod > 1) {                               606     if (nmod > 1) {
665       k = nmod;                                   607       k = nmod;
666       // Loop checking, 03-Aug-2015, Vladimir  << 
667       do {--k;} while (k>0 && e <= regModels->    608       do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k));
668       if(k > 0 && k != k0) {                   << 609       if(k > 0) {
669         k0 = k;                                << 
670         G4double elow = regModels->LowEdgeEner    610         G4double elow = regModels->LowEdgeEnergy(k);
671         G4VEmModel* mod1 = models[regModels->M << 611         G4VEmModel* m = models[regModels->ModelIndex(k-1)]; 
672         G4double xs1  = mod1->CrossSection(cou << 612   G4double xs1  = m->CrossSection(couple,particle,elow,cut,tmax);
673         mod = models[regModels->ModelIndex(k)]    613         mod = models[regModels->ModelIndex(k)]; 
674         G4double xs2 = mod->CrossSection(coupl << 614   G4double xs2 = mod->CrossSection(couple,particle,elow,cut,tmax);
675         del = (xs2 > 0.0) ? (xs1/xs2 - 1.0)*el << 615         del = (xs1 - xs2)*elow/e;
676         //G4cout << "New model k=" << k << " E << 
677         //       << " Elow(MeV)= " << elow/MeV << 
678       }                                           616       }
679     }                                             617     }
680     G4double cross = (1.0 + del/e)*mod->CrossS << 618     G4double cross = mod->CrossSection(couple,particle,e,cut,tmax) + del;
681     if(fIsCrossSectionPrim == tType) { cross * << 
682                                                   619     
683     if(j==0 && startFromNull) { cross = 0.0; } << 620     if(j==0 && startFromNull) cross = 0.0;
684                                                   621 
685     if(2 < verboseLevel) {                        622     if(2 < verboseLevel) {
686       G4cout << "FillLambdaVector: " << j << "    623       G4cout << "FillLambdaVector: " << j << ".   e(MeV)= " << e/MeV
687              << "  cross(1/mm)= " << cross*mm  << 624        << "  cross(1/mm)= " << cross*mm
688              << " del= " << del*mm << " k= " < << 625        << " del= " << del*mm << " k= " << k 
689              << " modelIdx= " << regModels->Mo << 626        << " modelIdx= " << regModels->ModelIndex(k)
690              << G4endl;                        << 627        << G4endl;
691     }                                             628     }
692     cross = std::max(cross, 0.0);              << 629     if(cross < 0.0) cross = 0.0;
                                                   >> 630 
693     aVector->PutValue(j, cross);                  631     aVector->PutValue(j, cross);
694   }                                               632   }
695 }                                                 633 }
696                                                   634 
697 //....oooOO0OOooo........oooOO0OOooo........oo    635 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
698                                                   636 
699 void G4EmModelManager::DumpModelList(std::ostr << 637 void G4EmModelManager::DumpModelList(G4int verb)
700 {                                                 638 {
701   if(verb == 0) { return; }                       639   if(verb == 0) { return; }
702   for(G4int i=0; i<nRegions; ++i) {               640   for(G4int i=0; i<nRegions; ++i) {
703     G4RegionModels* r = setOfRegionModels[i];     641     G4RegionModels* r = setOfRegionModels[i];
704     const G4Region* reg = r->Region();            642     const G4Region* reg = r->Region();
705     G4int n = r->NumberOfModels();                643     G4int n = r->NumberOfModels();  
706     if(n > 0) {                                   644     if(n > 0) {
707       out << "      ===== EM models for the G4 << 645       G4cout << "      ===== EM models for the G4Region  " << reg->GetName()
708     << " ======" << G4endl;                    << 646        << " ======" << G4endl;;
709       for(G4int j=0; j<n; ++j) {                  647       for(G4int j=0; j<n; ++j) {
710         G4VEmModel* model = models[r->ModelInd << 648   G4VEmModel* m = models[r->ModelIndex(j)];
711         G4double emin =                        << 649   G4cout << std::setw(20);
712           std::max(r->LowEdgeEnergy(j),model-> << 650   G4cout << m->GetName() << " :   Emin= " 
713         G4double emax =                        << 651          << std::setw(8) << G4BestUnit(r->LowEdgeEnergy(j),"Energy")
714           std::min(r->LowEdgeEnergy(j+1),model << 652          << "      Emax=   " 
715         if(emax > emin) {                      << 653          << std::setw(8) << G4BestUnit(r->LowEdgeEnergy(j+1),"Energy");
716     out << std::setw(20);                      << 654   G4VEmAngularDistribution* an = m->GetAngularDistribution();
717     out << model->GetName() << " : Emin="      << 655         if(an) { G4cout << "  " << an->GetName(); }
718         << std::setw(5) << G4BestUnit(emin,"En << 656   G4cout << G4endl;
719         << " Emax="                            << 
720         << std::setw(5) << G4BestUnit(emax,"En << 
721     G4PhysicsTable* table = model->GetCrossSec << 
722     if(table) {                                << 
723       std::size_t kk = table->size();          << 
724       for(std::size_t k=0; k<kk; ++k) {        << 
725         const G4PhysicsVector* v = (*table)[k] << 
726         if(v) {                                << 
727     G4int nn = G4int(v->GetVectorLength() - 1) << 
728     out << " Nbins=" << nn << " "              << 
729         << std::setw(3) << G4BestUnit(v->Energ << 
730         << " - "                               << 
731         << std::setw(3) << G4BestUnit(v->Energ << 
732     break;                                     << 
733         }                                      << 
734       }                                        << 
735           }                                    << 
736     G4VEmAngularDistribution* an = model->GetA << 
737     if(an) { out << "  " << an->GetName(); }   << 
738     if(fluoFlag && model->DeexcitationFlag())  << 
739       out << " Fluo";                          << 
740     }                                          << 
741     out << G4endl;                             << 
742           auto msc = dynamic_cast<G4VMscModel* << 
743           if(msc != nullptr) msc->DumpParamete << 
744   }                                            << 
745       }                                           657       }  
746     }                                             658     }
747     if(1 == nEmModels) { break; }              << 659     if(1 == nEmModels) break; 
748   }                                            << 
749   if(theCutsNew) {                             << 
750     out << "      ===== Limit on energy thresh << 
751   }                                               660   }
752 }                                                 661 }
753                                                   662 
754 //....oooOO0OOooo........oooOO0OOooo........oo    663 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
755                                                   664