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