Geant4 Cross Reference

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


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
                                                   >>  26 // $Id: G4EmConfigurator.cc,v 1.9 2010-07-29 11:13:28 vnivanch Exp $
                                                   >>  27 // GEANT4 tag $Name: geant4-09-04-patch-01 $
 26 //                                                 28 //
 27 // -------------------------------------------     29 // -------------------------------------------------------------------
 28 //                                                 30 //
 29 // GEANT4 Class                                    31 // GEANT4 Class 
 30 //                                                 32 //
 31 // File name:     G4EmConfigurator                 33 // File name:     G4EmConfigurator
 32 //                                                 34 //
 33 // Author:        Vladimir Ivanchenko              35 // Author:        Vladimir Ivanchenko
 34 //                                                 36 //
 35 // Creation date: 14.07.2008                       37 // Creation date: 14.07.2008
 36 //                                                 38 //
 37 // Modifications:                                  39 // Modifications:
 38 //                                                 40 //
 39 // Class Description:                              41 // Class Description:
 40 //                                                 42 //
 41 // This class provides configuration EM models     43 // This class provides configuration EM models for 
 42 // particles/processes/regions                     44 // particles/processes/regions
 43 //                                                 45 //
 44                                                    46 
 45 // -------------------------------------------     47 // -------------------------------------------------------------------
 46 //                                                 48 //
 47                                                    49 
 48 #include "G4EmConfigurator.hh"                     50 #include "G4EmConfigurator.hh"
 49 #include "G4EmUtility.hh"                      << 
 50 #include "G4SystemOfUnits.hh"                  << 
 51 #include "G4ParticleTable.hh"                      51 #include "G4ParticleTable.hh"
 52 #include "G4ParticleDefinition.hh"                 52 #include "G4ParticleDefinition.hh"
 53 #include "G4ProcessManager.hh"                     53 #include "G4ProcessManager.hh"
 54 #include "G4VProcess.hh"                           54 #include "G4VProcess.hh"
 55 #include "G4ProcessVector.hh"                      55 #include "G4ProcessVector.hh"
 56 #include "G4RegionStore.hh"                        56 #include "G4RegionStore.hh"
 57 #include "G4Region.hh"                             57 #include "G4Region.hh"
 58 #include "G4DummyModel.hh"                         58 #include "G4DummyModel.hh"
 59 #include "G4VEnergyLossProcess.hh"                 59 #include "G4VEnergyLossProcess.hh"
 60 #include "G4VEmProcess.hh"                         60 #include "G4VEmProcess.hh"
 61 #include "G4VMultipleScattering.hh"                61 #include "G4VMultipleScattering.hh"
 62 #include "G4TransportationWithMsc.hh"          << 
 63                                                    62 
 64 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65                                                    64 
 66 G4EmConfigurator::G4EmConfigurator(G4int val):     65 G4EmConfigurator::G4EmConfigurator(G4int val):verbose(val)
 67 {                                                  66 {
 68   index = -10;                                     67   index = -10;
 69 }                                                  68 }
 70                                                    69 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    71  
 73 G4EmConfigurator::~G4EmConfigurator() = defaul <<  72 G4EmConfigurator::~G4EmConfigurator()
                                                   >>  73 {}
 74                                                    74 
 75 //....oooOO0OOooo........oooOO0OOooo........oo     75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 76                                                    76 
 77 void G4EmConfigurator::SetExtraEmModel(const G     77 void G4EmConfigurator::SetExtraEmModel(const G4String& particleName,
 78                                        const G <<  78                const G4String& processName,
 79                                        G4VEmMo <<  79                G4VEmModel* mod,
 80                                        const G <<  80                const G4String& regionName,
 81                                        G4doubl <<  81                G4double emin,
 82                                        G4doubl <<  82                G4double emax,
 83                                        G4VEmFl <<  83                G4VEmFluctuationModel* fm)
 84 {                                                  84 {
 85   if(nullptr == mod) { return; }               << 
 86   if(1 < verbose) {                                85   if(1 < verbose) {
 87     G4cout << " G4EmConfigurator::SetExtraEmMo     86     G4cout << " G4EmConfigurator::SetExtraEmModel " << mod->GetName()
 88            << " for " << particleName          <<  87      << " for " << particleName 
 89            << " and " << processName           <<  88      << " and " << processName 
 90            << " in the region <" << regionName <<  89      << " in the region <" << regionName
 91            << "> Emin(MeV)= " << emin/MeV      <<  90      << "> Emin(MeV)= " << emin/MeV
 92            << " Emax(MeV)= " << emax/MeV       <<  91      << " Emax(MeV)= " << emax/MeV
 93            << G4endl;                          <<  92      << G4endl;
                                                   >>  93   }
                                                   >>  94   if(mod || fm) {
                                                   >>  95     models.push_back(mod);
                                                   >>  96     flucModels.push_back(fm);
                                                   >>  97   } else {
                                                   >>  98     models.push_back(new G4DummyModel());
                                                   >>  99     flucModels.push_back(0);
 94   }                                               100   }
 95                                                   101 
 96   models.push_back(mod);                       << 
 97   flucModels.push_back(fm);                    << 
 98   G4double emin0 = std::max(emin, mod->LowEner << 
 99   G4double emax0 = std::min(emax, mod->HighEne << 
100   mod->SetActivationHighEnergyLimit(emax0);    << 
101                                                << 
102   particles.push_back(particleName);              102   particles.push_back(particleName);
103   processes.push_back(processName);               103   processes.push_back(processName);
104   regions.push_back(regionName);                  104   regions.push_back(regionName);
105   lowEnergy.push_back(emin0);                  << 105   lowEnergy.push_back(emin);
106   highEnergy.push_back(emax0);                 << 106   highEnergy.push_back(emax);
107 }                                                 107 }
108                                                   108 
109 //....oooOO0OOooo........oooOO0OOooo........oo    109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110                                                   110 
111 void G4EmConfigurator::AddModels()                111 void G4EmConfigurator::AddModels()
112 {                                                 112 {
113   size_t n = models.size();                       113   size_t n = models.size();
114   if(1 < verbose) {                            << 114   if(0 < verbose) {
115     G4cout << "### G4EmConfigurator::AddModels    115     G4cout << "### G4EmConfigurator::AddModels n= " << n << G4endl;
116   }                                               116   }
117   if(n > 0) {                                     117   if(n > 0) {
118     for(size_t i=0; i<n; ++i) {                   118     for(size_t i=0; i<n; ++i) {
119       if(nullptr != models[i]) {               << 119       if(models[i]) {
120         const G4Region* reg = G4EmUtility::Fin << 120         G4Region* reg = FindRegion(regions[i]);
121         if(nullptr != reg) {                   << 121         if(reg) {
122           --index;                             << 122     --index;
123           SetModelForRegion(models[i],flucMode << 123     SetModelForRegion(models[i],flucModels[i],reg,
124                             particles[i],proce << 124           particles[i],processes[i],
125                             lowEnergy[i],highE << 125           lowEnergy[i],highEnergy[i]);
126         }                                      << 126   }
127       }                                           127       }
128     }                                             128     }
129   }                                               129   }
130   Clear();                                        130   Clear();
131 }                                                 131 }
132                                                   132 
133 //....oooOO0OOooo........oooOO0OOooo........oo    133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134                                                   134 
135 void G4EmConfigurator::SetModelForRegion(G4VEm    135 void G4EmConfigurator::SetModelForRegion(G4VEmModel* mod,
136                                          G4VEm << 136            G4VEmFluctuationModel* fm,
137                                          const << 137                                          G4Region* reg,
138                                          const << 138            const G4String& particleName,
139                                          const << 139            const G4String& processName,
140                                          G4dou << 140            G4double emin, G4double emax)
141 {                                                 141 {
142   if(nullptr == mod) { return; }               << 
143   if(1 < verbose) {                               142   if(1 < verbose) {
144     G4cout << " G4EmConfigurator::SetModelForR    143     G4cout << " G4EmConfigurator::SetModelForRegion: " << mod->GetName() 
145            << G4endl;                          << 144      << G4endl;
146     G4cout << " For " << particleName             145     G4cout << " For " << particleName 
147            << " and " << processName           << 146      << " and " << processName 
148            << " in the region <" << reg->GetNa << 147      << " in the region <" << reg->GetName()
149            << " Emin(MeV)= " << emin/MeV       << 148      << " Emin(MeV)= " << emin/MeV
150            << " Emax(MeV)= " << emax/MeV;      << 149      << " Emax(MeV)= " << emax/MeV;
151     if(nullptr != fm) { G4cout << " FLmodel "  << 150     if(fm) { G4cout << " FLmodel " << fm->GetName(); }
152     G4cout << G4endl;                             151     G4cout << G4endl;
153   }                                               152   }
                                                   >> 153   G4ParticleTable::G4PTblDicIterator* theParticleIterator = 
                                                   >> 154     G4ParticleTable::GetParticleTable()->GetIterator(); 
                                                   >> 155 
                                                   >> 156   theParticleIterator->reset();
                                                   >> 157   while( (*theParticleIterator)() ) {
                                                   >> 158     const G4ParticleDefinition* part = theParticleIterator->value();
154                                                   159 
155   // Loop checking, 03-Aug-2015, Vladimir Ivan << 160     //G4cout << particleName << " " << part->GetParticleName() << G4endl;
156   auto myParticleIterator = G4ParticleTable::G << 
157   myParticleIterator->reset();                 << 
158   while( (*myParticleIterator)() ) {           << 
159     const G4ParticleDefinition* part = myParti << 
160                                                   161 
161     if((part->GetParticleName() == particleNam    162     if((part->GetParticleName() == particleName) ||
162        (particleName == "all") ||                 163        (particleName == "all") ||
163        (particleName == "charged" && part->Get    164        (particleName == "charged" && part->GetPDGCharge() != 0.0)) {
164                                                   165 
165       // search for process                       166       // search for process
166       G4ProcessManager* pmanager = part->GetPr    167       G4ProcessManager* pmanager = part->GetProcessManager();
167       G4ProcessVector* plist = pmanager->GetPr    168       G4ProcessVector* plist = pmanager->GetProcessList();
168       G4int np = pmanager->GetProcessListLengt    169       G4int np = pmanager->GetProcessListLength();
169                                                   170   
170       if(1 < verbose) {                        << 171       //G4cout << processName << " in list of " << np << G4endl;
171         G4cout << "Check process <" << process << 172 
172                << np << " processes" << G4endl << 173       G4VProcess* proc = 0;
173       }                                        << 
174       G4VProcess* proc = nullptr;              << 
175       for(G4int i=0; i<np; ++i) {                 174       for(G4int i=0; i<np; ++i) {
176         if(processName == (*plist)[i]->GetProc << 175   if(processName == (*plist)[i]->GetProcessName()) {
177           proc = (*plist)[i];                  << 176     proc = (*plist)[i];
178           break;                               << 177     break;
179         }                                      << 178   }
180       }                                        << 
181       if(nullptr == proc) {                    << 
182         if(processName == "msc") {             << 
183           for (G4int i = 0; i < np; ++i) {     << 
184             auto* trans = dynamic_cast<G4Trans << 
185             if (nullptr != trans) {            << 
186               G4cout << "G4TransportationWithM << 
187               proc = trans;                    << 
188               break;                           << 
189             }                                  << 
190           }                                    << 
191         }                                      << 
192         if (nullptr == proc) {                 << 
193           if (0 < verbose) {                   << 
194             G4cout << "### G4EmConfigurator WA << 
195                    << "> for " << particleName << 
196           }                                    << 
197           return;                              << 
198         }                                      << 
199       }                                           179       }
                                                   >> 180       if(!proc) {
                                                   >> 181   G4cout << "### G4EmConfigurator WARNING: fails to find a process <"
                                                   >> 182          << processName << "> for " << particleName << G4endl;
                                                   >> 183         return; 
                                                   >> 184       } 
200                                                   185 
201       if(!UpdateModelEnergyRange(mod, emin, em << 186       if(mod) {
                                                   >> 187   if(!UpdateModelEnergyRange(mod, emin, emax)) { return; }
                                                   >> 188       }
202       // classify process                         189       // classify process
203       G4int ii = proc->GetProcessSubType();       190       G4int ii = proc->GetProcessSubType();
204       auto msc = dynamic_cast<G4VMscModel*>(mo << 191       if(10 == ii && mod) {
205       if (nullptr != msc) {                    << 192   G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
206         if (auto* trans = dynamic_cast<G4Trans << 193   p->AddEmModel(index,mod,reg);
207           trans->AddMscModel(msc, index, reg); << 194   if(1 < verbose) {
208           if (1 < verbose) {                   << 195     G4cout << "### Added msc model order= " << index << " for " 
209             G4cout << "### Added msc model ord << 196      << particleName << " and " << processName << G4endl;
210                    << proc->GetProcessName() < << 197   }
211           }                                    << 198   return;
212         }                                      << 199       } else if(2 <= ii && 4 >= ii) {
213         else if (10 == ii) {                   << 200   G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
214           auto p = dynamic_cast<G4VMultipleSca << 201         if(!mod && fm) {
215           if (nullptr != p) {                  << 202     p->SetFluctModel(fm);
216             p->AddEmModel(index, msc, reg);    << 203   } else { 
217             if (1 < verbose) {                 << 204     p->AddEmModel(index,mod,fm,reg);
218               G4cout << "### Added msc model o << 205     if(1 < verbose) {
219                      << processName << G4endl; << 206       G4cout << "### Added eloss model order= " << index << " for " 
220             }                                  << 207        << particleName << " and " << processName << G4endl;
221           }                                    << 208     }
222         }                                      << 209   }
223         else {                                 << 210   return;
224           G4cout << "### Unable to add msc mod << 211       } else if(mod) {
225                  << G4endl;                    << 212   G4VEmProcess* p = static_cast<G4VEmProcess*>(proc);
226         }                                      << 213   p->AddEmModel(index,mod,reg);
227       }                                        << 214   if(1 < verbose) {
228       else if (2 <= ii && 4 >= ii) {           << 215     G4cout << "### Added em model order= " << index << " for " 
229         auto p = dynamic_cast<G4VEnergyLossPro << 216      << particleName << " and " << processName << G4endl;
230         if (nullptr != p) {                    << 217   }
231           p->AddEmModel(index, mod, fm, reg);  << 218   return;
232           if (1 < verbose) {                   << 219       } else {
233             G4cout << "### Added eloss model o << 220   return;
234                    << processName << G4endl;   << 
235           }                                    << 
236         }                                      << 
237       }                                        << 
238       else {                                   << 
239         auto p = dynamic_cast<G4VEmProcess*>(p << 
240         if (nullptr != p) {                    << 
241           p->AddEmModel(index, mod, reg);      << 
242           if (1 < verbose) {                   << 
243             G4cout << "### Added em model orde << 
244                    << processName << G4endl;   << 
245           }                                    << 
246         }                                      << 
247         else {                                 << 
248           G4cout << "### Unable to add em mode << 
249                  << G4endl;                    << 
250         }                                      << 
251       }                                           221       }
252       return;                                  << 
253     }                                             222     }
254   }                                               223   }
255 }                                                 224 }
256                                                   225 
257 //....oooOO0OOooo........oooOO0OOooo........oo    226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258                                                   227 
259 void                                              228 void 
260 G4EmConfigurator::PrepareModels(const G4Partic    229 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
261                                 G4VEnergyLossP << 230         G4VEnergyLossProcess* p)
262 {                                                 231 {
263   size_t n = particles.size();                    232   size_t n = particles.size();
264   if(1 < verbose) {                               233   if(1 < verbose) {
265     G4cout << " G4EmConfigurator::PrepareModel    234     G4cout << " G4EmConfigurator::PrepareModels for EnergyLoss n= " 
266            << n << G4endl;                     << 235      << n << G4endl;
267   }                                               236   }
268   if(n > 0) {                                     237   if(n > 0) {
269     G4String particleName = aParticle->GetPart    238     G4String particleName = aParticle->GetParticleName(); 
270     G4String processName  = p->GetProcessName(    239     G4String processName  = p->GetProcessName(); 
271     //G4cout <<  particleName << "  " <<  proc    240     //G4cout <<  particleName << "  " <<  processName << G4endl;
272     for(size_t i=0; i<n; ++i) {                   241     for(size_t i=0; i<n; ++i) {
273       //G4cout <<  particles[i] << "  " <<  pr    242       //G4cout <<  particles[i] << "  " <<  processes[i] << G4endl;
274       if(processName == processes[i]) {           243       if(processName == processes[i]) {
275         if((particleName == particles[i]) ||      244         if((particleName == particles[i]) ||
276            (particles[i] == "all") ||          << 245      (particles[i] == "all") ||
277            (particles[i] == "charged" && aPart << 246      (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
278           const G4Region* reg = G4EmUtility::F << 247     G4Region* reg = FindRegion(regions[i]);
279           //G4cout << "Region " << reg << G4en << 248     //G4cout << "Region " << reg << G4endl;
280           if(nullptr != reg) {                 << 249     if(reg) {
281             --index;                           << 250       --index;
282             G4VEmModel* mod = models[i];       << 251       G4VEmModel* mod = models[i];
283             G4VEmFluctuationModel* fm = flucMo << 252       G4VEmFluctuationModel* fm = flucModels[i];
284             if(nullptr != mod) {               << 253       if(mod) {
285               if(UpdateModelEnergyRange(mod, l << 254         if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
286                 p->AddEmModel(index,mod,fm,reg << 255     p->AddEmModel(index,mod,fm,reg);
287                 if(1 < verbose) {              << 256     if(1 < verbose) {
288                   G4cout << "### Added eloss m << 257       G4cout << "### Added eloss model order= " << index << " for " 
289                          << " and " << process << 258        << particleName << " and " << processName << G4endl;
290                 }                              << 259     }
291               }                                << 260         }
292             } else if(nullptr != fm) {         << 261             } else if(fm) {
293               p->SetFluctModel(fm);            << 262         p->SetFluctModel(fm);
294             }                                  << 263       }
295           }                                    << 264     }
296         }                                      << 265   }
297       }                                           266       }
298     }                                             267     }
299   }                                               268   }
300 }                                                 269 }
301                                                   270 
302 //....oooOO0OOooo........oooOO0OOooo........oo    271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
303                                                   272 
304 void                                              273 void 
305 G4EmConfigurator::PrepareModels(const G4Partic    274 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
306                                 G4VEmProcess*  << 275         G4VEmProcess* p)
307 {                                                 276 {
308   size_t n = particles.size();                    277   size_t n = particles.size();
309   if(1 < verbose) {                               278   if(1 < verbose) {
310     G4cout << " G4EmConfigurator::PrepareModel    279     G4cout << " G4EmConfigurator::PrepareModels for EM process n= " 
311            << n << G4endl;                     << 280      << n << G4endl;
312   }                                               281   }
313   if(n > 0) {                                     282   if(n > 0) {
314     G4String particleName = aParticle->GetPart    283     G4String particleName = aParticle->GetParticleName(); 
315     G4String processName  = p->GetProcessName(    284     G4String processName  = p->GetProcessName(); 
316     //G4cout <<  particleName << "  " <<  part    285     //G4cout <<  particleName << "  " <<  particleName << G4endl;
317     for(size_t i=0; i<n; ++i) {                   286     for(size_t i=0; i<n; ++i) {
318       if(processName == processes[i]) {           287       if(processName == processes[i]) {
319         if((particleName == particles[i]) ||      288         if((particleName == particles[i]) ||
320            (particles[i] == "all") ||          << 289      (particles[i] == "all") ||
321            (particles[i] == "charged" && aPart << 290      (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
322           const G4Region* reg = G4EmUtility::F << 291     G4Region* reg = FindRegion(regions[i]);
323           //G4cout << "Region " << reg << G4en << 292     //G4cout << "Region " << reg << G4endl;
324           if(nullptr != reg) {                 << 293     if(reg) {
325             --index;                           << 294       --index;
326             G4VEmModel* mod = models[i];       << 295       G4VEmModel* mod = models[i];
327             if(nullptr != mod) {               << 296       if(mod) {
328               if(UpdateModelEnergyRange(mod, l << 297         if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 
329                 p->AddEmModel(index,mod,reg);  << 298     p->AddEmModel(index,mod,reg);
330                 if(1 < verbose) {              << 299     if(1 < verbose) {
331                   G4cout << "### Added em mode << 300       G4cout << "### Added em model order= " << index << " for " 
332                          << particleName << "  << 301        << particleName << " and " << processName << G4endl;
333                 }                              << 302     }
334               }                                << 303         }
335             }                                  << 304       }
336           }                                    << 305     }
337         }                                      << 306   }
338       }                                           307       }
339     }                                             308     }
340   }                                               309   }
341 }                                                 310 }
342                                                   311 
343 //....oooOO0OOooo........oooOO0OOooo........oo    312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344                                                   313 
345 void                                              314 void 
346 G4EmConfigurator::PrepareModels(const G4Partic    315 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
347                                 G4VMultipleSca << 316         G4VMultipleScattering* p)
348                                 G4Transportati << 
349 {                                                 317 {
350   size_t n = particles.size();                    318   size_t n = particles.size();
351   if(1 < verbose) {                               319   if(1 < verbose) {
352     G4cout << " G4EmConfigurator::PrepareModel    320     G4cout << " G4EmConfigurator::PrepareModels for MSC process n= " 
353            << n << G4endl;                     << 321      << n << G4endl;
354   }                                               322   }
355                                                   323 
356   if(n > 0) {                                     324   if(n > 0) {
357     G4String particleName = aParticle->GetPart << 325     G4String particleName = aParticle->GetParticleName(); 
358     G4String processName = (nullptr == p) ? G4 << 326     G4String processName  = p->GetProcessName(); 
359     for(size_t i=0; i<n; ++i) {                   327     for(size_t i=0; i<n; ++i) {
360       if(processName == processes[i]) {           328       if(processName == processes[i]) {
361         if ((particleName == particles[i]) ||  << 329         if((particleName == particles[i]) ||
362             || (particles[i] == "charged" && a << 330      (particles[i] == "all") ||
363         {                                      << 331      (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
364           const G4Region* reg = G4EmUtility::F << 332     G4Region* reg = FindRegion(regions[i]);
365           if (nullptr != reg) {                << 333     if(reg) {
366             --index;                           << 334       --index;
367             auto mod = dynamic_cast<G4VMscMode << 335       G4VEmModel* mod = models[i];
368             if(nullptr != mod) {               << 336       if(mod) {
369               if(UpdateModelEnergyRange(mod, l << 337         if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 
370                 if(nullptr != p) {             << 338     p->AddEmModel(index,mod,reg);
371                   p->AddEmModel(index, mod, re << 339     G4cout << "### Added msc model order= " << index << " for " 
372                 }                              << 340            << particleName << " and " << processName << G4endl;
373                 else {                         << 341         }
374                   trans->AddMscModel(mod, inde << 342       }
375                 }                              << 343     }
376                 //G4cout << "### Added msc mod << 344   }
377                 //   << particleName << " and  << 
378               }                                << 
379             }                                  << 
380           }                                    << 
381         }                                      << 
382       }                                           345       }
383     }                                             346     }
384   }                                               347   }
385 }                                                 348 }
386                                                   349 
387 //....oooOO0OOooo........oooOO0OOooo........oo    350 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
388                                                   351 
389 void G4EmConfigurator::Clear()                    352 void G4EmConfigurator::Clear()
390 {                                                 353 {
391   particles.clear();                              354   particles.clear();
392   processes.clear();                              355   processes.clear();
393   models.clear();                                 356   models.clear();
394   flucModels.clear();                             357   flucModels.clear();
395   regions.clear();                                358   regions.clear();
396   lowEnergy.clear();                              359   lowEnergy.clear();
397   highEnergy.clear();                             360   highEnergy.clear();
398 }                                                 361 }
399                                                   362 
400 //....oooOO0OOooo........oooOO0OOooo........oo    363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
401                                                   364 
                                                   >> 365 G4Region* G4EmConfigurator::FindRegion(const G4String& regionName)
                                                   >> 366 {
                                                   >> 367   // search for region
                                                   >> 368   G4Region* reg = 0;
                                                   >> 369   G4RegionStore* regStore = G4RegionStore::GetInstance();
                                                   >> 370   G4String r = regionName;
                                                   >> 371   if(r == "" || r == "world" || r == "World") { 
                                                   >> 372     r = "DefaultRegionForTheWorld";
                                                   >> 373   }
                                                   >> 374   reg = regStore->GetRegion(r, true); 
                                                   >> 375   if(!reg) {
                                                   >> 376     G4cout << "### G4EmConfigurator WARNING: fails to find a region <"
                                                   >> 377      << r << G4endl;
                                                   >> 378   } else if(verbose > 1) {
                                                   >> 379     G4cout << "### G4EmConfigurator finds out G4Region <" << r << ">" 
                                                   >> 380      << G4endl;
                                                   >> 381   } 
                                                   >> 382   return reg;  
                                                   >> 383 }
                                                   >> 384 
                                                   >> 385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 386 
402 G4bool G4EmConfigurator::UpdateModelEnergyRang    387 G4bool G4EmConfigurator::UpdateModelEnergyRange(G4VEmModel* mod, 
403                                                << 388             G4double emin, G4double emax)
404 {                                                 389 {
405   // energy limits                                390   // energy limits
406   G4double e1 = std::max(emin,mod->LowEnergyLi    391   G4double e1 = std::max(emin,mod->LowEnergyLimit());
407   G4double e2 = std::min(emax,mod->HighEnergyL    392   G4double e2 = std::min(emax,mod->HighEnergyLimit());
408   if(e2 <= e1) {                                  393   if(e2 <= e1) {
409     G4cout << "### G4EmConfigurator WARNING: e    394     G4cout << "### G4EmConfigurator WARNING: empty energy interval"
410            << " for <" << mod->GetName()       << 395      << " for <" << mod->GetName() 
411            << ">  Emin(MeV)= " << e1/CLHEP::Me << 396      << ">  Emin(MeV)= " << e1/CLHEP::MeV 
412            << ">  Emax(MeV)= " << e2/CLHEP::Me << 397      << ">  Emax(MeV)= " << e2/CLHEP::MeV 
413            << G4endl;                          << 398      << G4endl;
414     return false;                              << 399     return false; 
415   }                                               400   }
416   mod->SetLowEnergyLimit(e1);                     401   mod->SetLowEnergyLimit(e1);
417   mod->SetHighEnergyLimit(e2);                    402   mod->SetHighEnergyLimit(e2);
418   if(verbose > 1) {                               403   if(verbose > 1) {
419     G4cout << "### G4EmConfigurator for " << m    404     G4cout << "### G4EmConfigurator for " << mod->GetName() 
420            << " Emin(MeV)= " << e1/MeV << " Em << 405      << " Emin(MeV)= " << e1/MeV << " Emax(MeV)= " << e2/MeV 
421            << G4endl;                          << 406      << G4endl;
422   }                                               407   } 
423   return true;                                    408   return true;
424 }                                                 409 }
425                                                   410 
426 //....oooOO0OOooo........oooOO0OOooo........oo    411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
427                                                   412