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.2)


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