Geant4 Cross Reference

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


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // -------------------------------------------     26 // -------------------------------------------------------------------
 27 //                                                 27 //
 28 // GEANT4 Class file                               28 // GEANT4 Class file
 29 //                                                 29 //
 30 //                                                 30 //
 31 // File name:     G4VEmModel                       31 // File name:     G4VEmModel
 32 //                                                 32 //
 33 // Author:        Vladimir Ivanchenko              33 // Author:        Vladimir Ivanchenko
 34 //                                                 34 //
 35 // Creation date: 25.07.2005                       35 // Creation date: 25.07.2005
 36 //                                                 36 //
 37 // Modifications:                                  37 // Modifications:
 38 // 25.10.2005 Set default highLimit=100.TeV (V     38 // 25.10.2005 Set default highLimit=100.TeV (V.Ivanchenko)
 39 // 06.02.2006 add method ComputeMeanFreePath()     39 // 06.02.2006 add method ComputeMeanFreePath() (mma)
 40 // 16.02.2009 Move implementations of virtual      40 // 16.02.2009 Move implementations of virtual methods to source (VI)
 41 //                                                 41 //
 42 //                                                 42 //
 43 // Class Description:                              43 // Class Description:
 44 //                                                 44 //
 45 // Abstract interface to energy loss models        45 // Abstract interface to energy loss models
 46                                                    46 
 47 // -------------------------------------------     47 // -------------------------------------------------------------------
 48 //                                                 48 //
 49                                                    49 
 50 #include "G4VEmModel.hh"                           50 #include "G4VEmModel.hh"
 51 #include "G4ElementData.hh"                        51 #include "G4ElementData.hh"
 52 #include "G4LossTableManager.hh"                   52 #include "G4LossTableManager.hh"
 53 #include "G4LossTableBuilder.hh"                   53 #include "G4LossTableBuilder.hh"
 54 #include "G4ProductionCutsTable.hh"                54 #include "G4ProductionCutsTable.hh"
 55 #include "G4ParticleChangeForLoss.hh"              55 #include "G4ParticleChangeForLoss.hh"
 56 #include "G4ParticleChangeForGamma.hh"             56 #include "G4ParticleChangeForGamma.hh"
 57 #include "G4EmParameters.hh"                   << 
 58 #include "G4SystemOfUnits.hh"                      57 #include "G4SystemOfUnits.hh"
 59 #include "G4EmUtility.hh"                      << 
 60 #include "G4Log.hh"                                58 #include "G4Log.hh"
 61 #include "Randomize.hh"                            59 #include "Randomize.hh"
 62 #include <iostream>                                60 #include <iostream>
 63                                                    61 
 64 //....oooOO0OOooo........oooOO0OOooo........oo     62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 66                                                    64 
 67 G4VEmModel::G4VEmModel(const G4String& nam):       65 G4VEmModel::G4VEmModel(const G4String& nam):
 68   inveplus(1.0/CLHEP::eplus),                  <<  66   flucModel(nullptr),anglModel(nullptr), name(nam), lowLimit(0.1*CLHEP::keV), 
 69   lowLimit(0.1*CLHEP::keV),                    <<  67   highLimit(100.0*CLHEP::TeV),eMinActive(0.0),eMaxActive(DBL_MAX),
 70   highLimit(100.0*CLHEP::TeV),                 <<  68   polarAngleLimit(CLHEP::pi),secondaryThreshold(DBL_MAX),
 71   polarAngleLimit(CLHEP::pi),                  <<  69   theLPMflag(false),flagDeexcitation(false),flagForceBuildTable(false),
 72   name(nam)                                    <<  70   isMaster(true),fElementData(nullptr),pParticleChange(nullptr),
                                                   >>  71   xSectionTable(nullptr),pBaseMaterial(nullptr),idxTable(0),
                                                   >>  72   lossFlucFlag(true),inveplus(1.0/CLHEP::eplus),pFactor(1.0),
                                                   >>  73   fCurrentCouple(nullptr),fCurrentElement(nullptr),fCurrentIsotope(nullptr),
                                                   >>  74   fTripletModel(nullptr),nsec(5) 
 73 {                                                  75 {
 74   xsec.resize(nsec);                               76   xsec.resize(nsec);
                                                   >>  77   nSelectors = 0;
                                                   >>  78   elmSelectors = nullptr;
                                                   >>  79   localElmSelectors = true;
                                                   >>  80   localTable = true;
                                                   >>  81   useAngularGenerator = false;
                                                   >>  82   useBaseMaterials = true;
                                                   >>  83   isLocked = false;
                                                   >>  84 
 75   fEmManager = G4LossTableManager::Instance();     85   fEmManager = G4LossTableManager::Instance();
 76   fEmManager->Register(this);                      86   fEmManager->Register(this);
 77   isMaster = fEmManager->IsMaster();           << 
 78                                                << 
 79   G4LossTableBuilder* bld = fEmManager->GetTab     87   G4LossTableBuilder* bld = fEmManager->GetTableBuilder();
 80   theDensityFactor = bld->GetDensityFactors();     88   theDensityFactor = bld->GetDensityFactors();
 81   theDensityIdx = bld->GetCoupleIndexes();         89   theDensityIdx = bld->GetCoupleIndexes();
 82 }                                                  90 }
 83                                                    91 
 84 //....oooOO0OOooo........oooOO0OOooo........oo     92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 85                                                    93 
 86 G4VEmModel::~G4VEmModel()                          94 G4VEmModel::~G4VEmModel()
 87 {                                                  95 {
 88   if(localElmSelectors) {                          96   if(localElmSelectors) { 
 89     for(G4int i=0; i<nSelectors; ++i) {            97     for(G4int i=0; i<nSelectors; ++i) { 
 90       delete (*elmSelectors)[i];                   98       delete (*elmSelectors)[i]; 
 91     }                                              99     }
 92     delete elmSelectors;                          100     delete elmSelectors; 
 93   }                                               101   }
 94   delete anglModel;                               102   delete anglModel;
 95                                                   103   
 96   if(localTable && xSectionTable != nullptr) {    104   if(localTable && xSectionTable != nullptr) { 
 97     xSectionTable->clearAndDestroy();             105     xSectionTable->clearAndDestroy();
 98     delete xSectionTable;                         106     delete xSectionTable;
 99     xSectionTable = nullptr;                      107     xSectionTable = nullptr; 
100   }                                               108   }
                                                   >> 109   if(isMaster && fElementData != nullptr) {
                                                   >> 110     delete fElementData;
                                                   >> 111     fElementData = nullptr;
                                                   >> 112   }
101   fEmManager->DeRegister(this);                   113   fEmManager->DeRegister(this);
102 }                                                 114 }
103                                                   115 
104 //....oooOO0OOooo........oooOO0OOooo........oo    116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105                                                   117 
106 G4ParticleChangeForLoss* G4VEmModel::GetPartic    118 G4ParticleChangeForLoss* G4VEmModel::GetParticleChangeForLoss()
107 {                                                 119 {
108   G4ParticleChangeForLoss* p = nullptr;           120   G4ParticleChangeForLoss* p = nullptr;
109   if (pParticleChange != nullptr) {               121   if (pParticleChange != nullptr) {
110     p = static_cast<G4ParticleChangeForLoss*>(    122     p = static_cast<G4ParticleChangeForLoss*>(pParticleChange);
111   } else {                                        123   } else {
112     p = new G4ParticleChangeForLoss();            124     p = new G4ParticleChangeForLoss();
113     pParticleChange = p;                          125     pParticleChange = p;
114   }                                               126   }
115   if(fTripletModel != nullptr) { fTripletModel    127   if(fTripletModel != nullptr) { fTripletModel->SetParticleChange(p); }
116   return p;                                       128   return p;
117 }                                                 129 }
118                                                   130 
119 //....oooOO0OOooo........oooOO0OOooo........oo    131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120                                                   132 
121 G4ParticleChangeForGamma* G4VEmModel::GetParti    133 G4ParticleChangeForGamma* G4VEmModel::GetParticleChangeForGamma()
122 {                                                 134 {
123   G4ParticleChangeForGamma* p = nullptr;          135   G4ParticleChangeForGamma* p = nullptr;
124   if (pParticleChange != nullptr) {               136   if (pParticleChange != nullptr) {
125     p = static_cast<G4ParticleChangeForGamma*>    137     p = static_cast<G4ParticleChangeForGamma*>(pParticleChange);
126   } else {                                        138   } else {
127     p = new G4ParticleChangeForGamma();           139     p = new G4ParticleChangeForGamma();
128     pParticleChange = p;                          140     pParticleChange = p;
129   }                                               141   }
130   if(fTripletModel != nullptr) { fTripletModel    142   if(fTripletModel != nullptr) { fTripletModel->SetParticleChange(p); }
131   return p;                                       143   return p;
132 }                                                 144 }
133                                                   145 
134 //....oooOO0OOooo........oooOO0OOooo........oo    146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135                                                   147 
136 void G4VEmModel::InitialiseElementSelectors(co    148 void G4VEmModel::InitialiseElementSelectors(const G4ParticleDefinition* part, 
137                                             co    149                                             const G4DataVector& cuts)
138 {                                                 150 {
                                                   >> 151   // using spline for element selectors should be investigated in details
                                                   >> 152   // because small number of points may provide biased results
                                                   >> 153   // large number of points requires significant increase of memory
                                                   >> 154   G4bool spline = false;
                                                   >> 155   
                                                   >> 156   //G4cout << "IES: for " << GetName() << " Emin(MeV)= " << lowLimit/MeV 
                                                   >> 157   //         << " Emax(MeV)= " << highLimit/MeV << G4endl;
                                                   >> 158   
                                                   >> 159   // two times less bins because probability functon is normalized 
                                                   >> 160   // so correspondingly is more smooth
139   if(highLimit <= lowLimit) { return; }           161   if(highLimit <= lowLimit) { return; }
140   G4EmUtility::InitialiseElementSelectors(this << 162 
141   localElmSelectors = true;                    << 163   G4int nbinsPerDec = G4EmParameters::Instance()->NumberOfBinsPerDecade();
                                                   >> 164 
                                                   >> 165   G4ProductionCutsTable* theCoupleTable=
                                                   >> 166     G4ProductionCutsTable::GetProductionCutsTable();
                                                   >> 167   G4int numOfCouples = theCoupleTable->GetTableSize();
                                                   >> 168 
                                                   >> 169   // prepare vector
                                                   >> 170   if(!elmSelectors) {
                                                   >> 171     elmSelectors = new std::vector<G4EmElementSelector*>;
                                                   >> 172   }
                                                   >> 173   if(numOfCouples > nSelectors) { 
                                                   >> 174     for(G4int i=nSelectors; i<numOfCouples; ++i) { 
                                                   >> 175       elmSelectors->push_back(nullptr); 
                                                   >> 176     }
                                                   >> 177     nSelectors = numOfCouples;
                                                   >> 178   }
                                                   >> 179 
                                                   >> 180   // initialise vector
                                                   >> 181   for(G4int i=0; i<numOfCouples; ++i) {
                                                   >> 182 
                                                   >> 183     // no need in element selectors for infionite cuts
                                                   >> 184     if(cuts[i] == DBL_MAX) { continue; }
                                                   >> 185    
                                                   >> 186     auto couple = theCoupleTable->GetMaterialCutsCouple(i); 
                                                   >> 187     auto material = couple->GetMaterial();
                                                   >> 188     SetCurrentCouple(couple);
                                                   >> 189 
                                                   >> 190     // selector already exist check if should be deleted
                                                   >> 191     G4bool create = true;
                                                   >> 192     if((*elmSelectors)[i]) {
                                                   >> 193       if(material == ((*elmSelectors)[i])->GetMaterial()) { create = false; }
                                                   >> 194       else { delete (*elmSelectors)[i]; }
                                                   >> 195     }
                                                   >> 196     if(create) {
                                                   >> 197       G4double emin = std::max(lowLimit, 
                                                   >> 198                                MinPrimaryEnergy(material, part, cuts[i]));
                                                   >> 199       G4double emax = std::max(highLimit, 10*emin);
                                                   >> 200       static const G4double invlog106 = 1.0/(6*G4Log(10.));
                                                   >> 201       G4int nbins = (G4int)(nbinsPerDec*G4Log(emax/emin)*invlog106);
                                                   >> 202       nbins = std::max(nbins, 3);
                                                   >> 203 
                                                   >> 204       (*elmSelectors)[i] = new G4EmElementSelector(this,material,nbins,
                                                   >> 205                                                    emin,emax,spline);
                                                   >> 206     }
                                                   >> 207     ((*elmSelectors)[i])->Initialise(part, cuts[i]);
                                                   >> 208     /*      
                                                   >> 209       G4cout << "G4VEmModel::InitialiseElmSelectors i= " << i 
                                                   >> 210              << "  "  << part->GetParticleName() 
                                                   >> 211              << " for " << GetName() << "  cut= " << cuts[i] 
                                                   >> 212              << "  " << (*elmSelectors)[i] << G4endl;      
                                                   >> 213       ((*elmSelectors)[i])->Dump(part);
                                                   >> 214     */
                                                   >> 215   } 
142 }                                                 216 }
143                                                   217 
144 //....oooOO0OOooo........oooOO0OOooo........oo    218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
145                                                   219 
146 void G4VEmModel::InitialiseLocal(const G4Parti << 220 void G4VEmModel::InitialiseLocal(const G4ParticleDefinition*, 
                                                   >> 221                                  G4VEmModel*)
147 {}                                                222 {}
148                                                   223 
149 //....oooOO0OOooo........oooOO0OOooo........oo    224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
150                                                   225 
151 void G4VEmModel::InitialiseForMaterial(const G    226 void G4VEmModel::InitialiseForMaterial(const G4ParticleDefinition* part,
152                                        const G    227                                        const G4Material* material)
153 {                                                 228 {
154   if(material != nullptr) {                       229   if(material != nullptr) {
155     G4int n = (G4int)material->GetNumberOfElem << 230     size_t n = material->GetNumberOfElements();
156     for(G4int i=0; i<n; ++i) {                 << 231     for(size_t i=0; i<n; ++i) {
157       G4int Z = material->GetElement(i)->GetZa    232       G4int Z = material->GetElement(i)->GetZasInt();
158       InitialiseForElement(part, Z);              233       InitialiseForElement(part, Z);
159     }                                             234     }
160   }                                               235   }
161 }                                                 236 }
162                                                   237 
163 //....oooOO0OOooo........oooOO0OOooo........oo    238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164                                                   239 
165 void G4VEmModel::InitialiseForElement(const G4    240 void G4VEmModel::InitialiseForElement(const G4ParticleDefinition*, G4int)
166 {}                                                241 {}
167                                                   242 
168 //....oooOO0OOooo........oooOO0OOooo........oo    243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169                                                   244 
170 G4double G4VEmModel::ComputeDEDXPerVolume(cons    245 G4double G4VEmModel::ComputeDEDXPerVolume(const G4Material*,
171                                           cons    246                                           const G4ParticleDefinition*,
172                                           G4do    247                                           G4double,G4double)
173 {                                                 248 {
174   return 0.0;                                     249   return 0.0;
175 }                                                 250 }
176                                                   251 
177 //....oooOO0OOooo........oooOO0OOooo........oo    252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178                                                   253 
179 G4double G4VEmModel::CrossSectionPerVolume(con << 254 G4double G4VEmModel::CrossSectionPerVolume(const G4Material* material,
180                                            con    255                                            const G4ParticleDefinition* p,
181                                            G4d    256                                            G4double ekin,
182                                            G4d    257                                            G4double emin,
183                                            G4d    258                                            G4double emax)
184 {                                                 259 {
185   SetupForMaterial(p, mat, ekin);              << 260   SetupForMaterial(p, material, ekin);
186   const G4double* theAtomNumDensityVector = ma << 261   G4double cross = 0.0;
187   G4int nelm = (G4int)mat->GetNumberOfElements << 262   const G4double* theAtomNumDensityVector = 
                                                   >> 263     material->GetVecNbOfAtomsPerVolume();
                                                   >> 264   G4int nelm = material->GetNumberOfElements(); 
188   if(nelm > nsec) {                               265   if(nelm > nsec) {
189     xsec.resize(nelm);                            266     xsec.resize(nelm);
190     nsec = nelm;                                  267     nsec = nelm;
191   }                                               268   }
192   G4double cross = 0.0;                        << 
193   for (G4int i=0; i<nelm; ++i) {                  269   for (G4int i=0; i<nelm; ++i) {
194     cross += theAtomNumDensityVector[i]*          270     cross += theAtomNumDensityVector[i]*
195       ComputeCrossSectionPerAtom(p,mat->GetEle << 271       ComputeCrossSectionPerAtom(p,material->GetElement(i),ekin,emin,emax);
196     xsec[i] = cross;                              272     xsec[i] = cross;
197   }                                               273   }
198   return cross;                                   274   return cross;
199 }                                                 275 }
200                                                   276 
201 //....oooOO0OOooo........oooOO0OOooo........oo    277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
202                                                   278 
203 G4double G4VEmModel::GetPartialCrossSection(co    279 G4double G4VEmModel::GetPartialCrossSection(const G4Material*, G4int,
204                                             co    280                                             const G4ParticleDefinition*,
205                                             G4    281                                             G4double)
206 {                                                 282 { 
207   return 0.0;                                     283   return 0.0;
208 }                                                 284 }
209                                                   285 
210 //....oooOO0OOooo........oooOO0OOooo........oo    286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
211                                                   287 
212 void G4VEmModel::StartTracking(G4Track*)          288 void G4VEmModel::StartTracking(G4Track*)
213 {}                                                289 {}
214                                                   290 
215 //....oooOO0OOooo........oooOO0OOooo........oo    291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216                                                   292 
217 const G4Element* G4VEmModel::SelectRandomAtom( << 293 const G4Element* G4VEmModel::SelectRandomAtom(const G4Material* material,
218                                                   294                                               const G4ParticleDefinition* pd,
219                                                   295                                               G4double kinEnergy,
220                                                   296                                               G4double tcut,
221                                                   297                                               G4double tmax)
222 {                                                 298 {
223   G4int n = (G4int)mat->GetNumberOfElements(); << 299   size_t n = material->GetNumberOfElements();
224   fCurrentElement = mat->GetElement(0);        << 300   fCurrentElement = material->GetElement(0);
225   if (n > 1) {                                    301   if (n > 1) {
226     const G4double x = G4UniformRand()*        << 302     G4double x = G4UniformRand()*
227       G4VEmModel::CrossSectionPerVolume(mat,pd << 303       G4VEmModel::CrossSectionPerVolume(material,pd,kinEnergy,tcut,tmax);
228     for(G4int i=0; i<n; ++i) {                 << 304     for(size_t i=0; i<n; ++i) {
229       if (x <= xsec[i]) {                         305       if (x <= xsec[i]) {
230         fCurrentElement = mat->GetElement(i);  << 306         fCurrentElement = material->GetElement(i);
231         break;                                    307         break;
232       }                                           308       }
233     }                                             309     }
234   }                                               310   }
235   return fCurrentElement;                         311   return fCurrentElement;
236 }                                                 312 }
237                                                << 
238 //....oooOO0OOooo........oooOO0OOooo........oo    313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
239                                                   314 
240 const G4Element* G4VEmModel::GetCurrentElement << 315 G4int G4VEmModel::SelectRandomAtomNumber(const G4Material* mat)
241 {                                                 316 {
242   const G4Element* elm = fCurrentElement;      << 317   // this algorith assumes that cross section is proportional to
243   if(nullptr == elm && nullptr != mat) {       << 318   // number electrons multiplied by number of atoms
244     elm = G4EmUtility::SampleRandomElement(mat << 319   size_t nn = mat->GetNumberOfElements();
                                                   >> 320   fCurrentElement = mat->GetElement(0);
                                                   >> 321   if(1 < nn) {
                                                   >> 322     const G4double* at = mat->GetVecNbOfAtomsPerVolume();
                                                   >> 323     G4double tot = mat->GetTotNbOfAtomsPerVolume()*G4UniformRand();
                                                   >> 324     for(size_t i=0; i<nn; ++i) {
                                                   >> 325       tot -= at[i];
                                                   >> 326       if(tot <= 0.0) { 
                                                   >> 327   fCurrentElement = mat->GetElement(i);
                                                   >> 328   break; 
                                                   >> 329       }
                                                   >> 330     }
245   }                                               331   }
246   return elm;                                  << 332   return fCurrentElement->GetZasInt();
247 }                                              << 
248                                                << 
249 //....oooOO0OOooo........oooOO0OOooo........oo << 
250                                                << 
251 G4int G4VEmModel::SelectRandomAtomNumber(const << 
252 {                                              << 
253   const G4Element* elm = GetCurrentElement(mat << 
254   return (nullptr == elm) ? 0 : elm->GetZasInt << 
255 }                                                 333 }
256                                                   334 
257 //....oooOO0OOooo........oooOO0OOooo........oo    335 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
258                                                   336 
259 const G4Isotope* G4VEmModel::GetCurrentIsotope << 337 G4int G4VEmModel::SelectIsotopeNumber(const G4Element* elm)
260 {                                                 338 {
261   const G4Isotope* iso = nullptr;              << 339   SetCurrentElement(elm);
262   const G4Element* el = elm;                   << 340   size_t ni = elm->GetNumberOfIsotopes();
263   if(nullptr == el && nullptr != fCurrentCoupl << 341   fCurrentIsotope = elm->GetIsotope(0);
264     el = GetCurrentElement(fCurrentCouple->Get << 342   size_t idx = 0;
265   }                                            << 343   if(ni > 1) {
266   if(nullptr != el) {                          << 344     const G4double* ab = elm->GetRelativeAbundanceVector();
267     iso = G4EmUtility::SampleRandomIsotope(el) << 345     G4double x = G4UniformRand();
                                                   >> 346     for(; idx<ni; ++idx) {
                                                   >> 347       x -= ab[idx];
                                                   >> 348       if (x <= 0.0) { 
                                                   >> 349   fCurrentIsotope = elm->GetIsotope(idx);
                                                   >> 350   break; 
                                                   >> 351       }
                                                   >> 352     }
268   }                                               353   }
269   return iso;                                  << 354   return fCurrentIsotope->GetN();
270 }                                              << 
271                                                << 
272 //....oooOO0OOooo........oooOO0OOooo........oo << 
273                                                << 
274 G4int G4VEmModel::SelectIsotopeNumber(const G4 << 
275 {                                              << 
276   auto iso = GetCurrentIsotope(elm);           << 
277   return (nullptr != iso) ? iso->GetN() : 0;   << 
278 }                                                 355 }
279                                                   356 
280 //....oooOO0OOooo........oooOO0OOooo........oo    357 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
281                                                   358 
282 G4double G4VEmModel::ComputeCrossSectionPerAto    359 G4double G4VEmModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition*,
283                                                   360                                                 G4double, G4double, G4double,
284                                                   361                                                 G4double, G4double)
285 {                                                 362 {
286   return 0.0;                                     363   return 0.0;
287 }                                                 364 }
288                                                   365 
289 //....oooOO0OOooo........oooOO0OOooo........oo    366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
290                                                   367 
291 G4double                                          368 G4double 
292 G4VEmModel::ComputeCrossSectionPerShell(const     369 G4VEmModel::ComputeCrossSectionPerShell(const G4ParticleDefinition*,
293                                         G4int,    370                                         G4int, G4int, 
294                                         G4doub    371                                         G4double, G4double, G4double)
295 {                                                 372 {
296   return 0.0;                                     373   return 0.0;
297 }                                                 374 }
298                                                   375 
299 //....oooOO0OOooo........oooOO0OOooo........oo    376 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
300                                                   377 
301 void G4VEmModel::DefineForRegion(const G4Regio    378 void G4VEmModel::DefineForRegion(const G4Region*) 
302 {}                                                379 {}
303                                                   380 
304 //....oooOO0OOooo........oooOO0OOooo........oo    381 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
305                                                   382 
306 void G4VEmModel::FillNumberOfSecondaries(G4int << 
307                                          G4int << 
308 {                                              << 
309   numberOfTriplets = 0;                        << 
310   numberOfRecoil = 0;                          << 
311 }                                              << 
312                                                << 
313 //....oooOO0OOooo........oooOO0OOooo........oo << 
314                                                << 
315 G4double G4VEmModel::ChargeSquareRatio(const G    383 G4double G4VEmModel::ChargeSquareRatio(const G4Track& track)
316 {                                                 384 {
317   return GetChargeSquareRatio(track.GetParticl    385   return GetChargeSquareRatio(track.GetParticleDefinition(), 
318                               track.GetMateria    386                               track.GetMaterial(), track.GetKineticEnergy());
319 }                                                 387 }
320                                                   388 
321 //....oooOO0OOooo........oooOO0OOooo........oo    389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
322                                                   390 
323 G4double G4VEmModel::GetChargeSquareRatio(cons    391 G4double G4VEmModel::GetChargeSquareRatio(const G4ParticleDefinition* p,
324                                           cons    392                                           const G4Material*, G4double)
325 {                                                 393 {
326   const G4double q = p->GetPDGCharge()*inveplu << 394   G4double q = p->GetPDGCharge()*inveplus;
327   return q*q;                                     395   return q*q;
328 }                                                 396 }
329                                                   397 
330 //....oooOO0OOooo........oooOO0OOooo........oo    398 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
331                                                   399 
332 G4double G4VEmModel::GetParticleCharge(const G    400 G4double G4VEmModel::GetParticleCharge(const G4ParticleDefinition* p,
333                                        const G    401                                        const G4Material*, G4double)
334 {                                                 402 {
335   return p->GetPDGCharge();                       403   return p->GetPDGCharge();
336 }                                                 404 }
337                                                   405 
338 //....oooOO0OOooo........oooOO0OOooo........oo    406 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
339                                                   407 
340 void G4VEmModel::CorrectionsAlongStep(const G4    408 void G4VEmModel::CorrectionsAlongStep(const G4MaterialCutsCouple*,
341                                       const G4    409                                       const G4DynamicParticle*,
342                                       const G4 << 410                                       G4double&,G4double&,G4double)
343 {}                                                411 {}
344                                                   412 
345 //....oooOO0OOooo........oooOO0OOooo........oo    413 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
346                                                   414 
347 G4double G4VEmModel::Value(const G4MaterialCut    415 G4double G4VEmModel::Value(const G4MaterialCutsCouple* couple,
348                            const G4ParticleDef    416                            const G4ParticleDefinition* p, G4double e)
349 {                                                 417 {
350   SetCurrentCouple(couple);                       418   SetCurrentCouple(couple);
351   return pFactor*e*e*CrossSectionPerVolume(pBa    419   return pFactor*e*e*CrossSectionPerVolume(pBaseMaterial,p,e,0.0,DBL_MAX);
352 }                                                 420 }
353                                                   421 
354 //....oooOO0OOooo........oooOO0OOooo........oo    422 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
355                                                   423 
356 G4double G4VEmModel::MinPrimaryEnergy(const G4    424 G4double G4VEmModel::MinPrimaryEnergy(const G4Material*,
357                                       const G4    425                                       const G4ParticleDefinition*,
358                                       G4double    426                                       G4double)
359 {                                                 427 {
360   return 0.0;                                     428   return 0.0;
361 }                                                 429 }
362                                                   430 
363 //....oooOO0OOooo........oooOO0OOooo........oo    431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
364                                                   432 
365 G4double G4VEmModel::MinEnergyCut(const G4Part    433 G4double G4VEmModel::MinEnergyCut(const G4ParticleDefinition*, 
366                                   const G4Mate    434                                   const G4MaterialCutsCouple*)
367 {                                                 435 {
368   return 0.0;                                     436   return 0.0;
369 }                                                 437 }
370                                                   438 
371 //....oooOO0OOooo........oooOO0OOooo........oo    439 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
372                                                   440 
373 G4double G4VEmModel::MaxSecondaryEnergy(const     441 G4double G4VEmModel::MaxSecondaryEnergy(const G4ParticleDefinition*,
374                                         G4doub    442                                         G4double kineticEnergy)
375 {                                                 443 {
376   return kineticEnergy;                           444   return kineticEnergy;
377 }                                                 445 }
378                                                   446 
379 //....oooOO0OOooo........oooOO0OOooo........oo    447 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
380                                                   448 
381 void G4VEmModel::SetupForMaterial(const G4Part << 449 void G4VEmModel::SetupForMaterial(const G4ParticleDefinition*,
382                                   const G4Mate << 450                                   const G4Material*, G4double)
383 {                                              << 451 {}
384   GetChargeSquareRatio(p, mat, ekin);          << 
385 }                                              << 
386                                                   452 
387 //....oooOO0OOooo........oooOO0OOooo........oo    453 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
388                                                   454 
389 void                                              455 void 
390 G4VEmModel::SetParticleChange(G4VParticleChang    456 G4VEmModel::SetParticleChange(G4VParticleChange* p, G4VEmFluctuationModel* f)
391 {                                                 457 {
392   if(p != nullptr && pParticleChange != p) { p << 458   if(p  != nullptr && pParticleChange != p) { pParticleChange = p; }
393   if(flucModel != f) { flucModel = f; }           459   if(flucModel != f) { flucModel = f; }
394 }                                                 460 }
395                                                   461 
396 //....oooOO0OOooo........oooOO0OOooo........oo    462 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
397                                                   463 
398 void G4VEmModel::SetCrossSectionTable(G4Physic    464 void G4VEmModel::SetCrossSectionTable(G4PhysicsTable* p, G4bool isLocal)
399 {                                                 465 {
400   xSectionTable = p;                           << 466   if(p != xSectionTable) {
401   localTable = isLocal;                        << 467     if(xSectionTable != nullptr && localTable) { 
402 }                                              << 468       xSectionTable->clearAndDestroy(); 
403                                                << 469       delete xSectionTable;
404 //....oooOO0OOooo........oooOO0OOooo........oo << 470     }
405                                                << 471     xSectionTable = p;
406 void G4VEmModel::SetLPMFlag(G4bool)            << 
407 {                                              << 
408   if (G4EmParameters::Instance()->Verbose() >  << 
409     G4ExceptionDescription ed;                 << 
410     ed << "The obsolete method SetLPMFlag(..)  << 
411        << " is called. Please, use G4EmParamet << 
412        << " instead";                          << 
413     G4Exception("G4VEmModel::SetLPMFlag", "em0 << 
414   }                                               472   }
                                                   >> 473   localTable = isLocal;
415 }                                                 474 }
416                                                << 
417 //....oooOO0OOooo........oooOO0OOooo........oo << 
418                                                << 
419 void G4VEmModel::SetMasterThread(G4bool)       << 
420 {}                                             << 
421                                                   475 
422 //....oooOO0OOooo........oooOO0OOooo........oo    476 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
423                                                   477 
424 void  G4VEmModel::ModelDescription(std::ostrea    478 void  G4VEmModel::ModelDescription(std::ostream& outFile) const
425 {                                                 479 {
426   outFile << "The description for this model h    480   outFile << "The description for this model has not been written yet.\n";
427 }                                                 481 }
428                                                   482 
429 //....oooOO0OOooo........oooOO0OOooo........oo    483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
430                                                   484