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 11.1.3)


  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 //
 29 // GEANT4 Class                                    29 // GEANT4 Class 
 30 //                                                 30 //
 31 // File name:     G4EmConfigurator                 31 // File name:     G4EmConfigurator
 32 //                                                 32 //
 33 // Author:        Vladimir Ivanchenko              33 // Author:        Vladimir Ivanchenko
 34 //                                                 34 //
 35 // Creation date: 14.07.2008                       35 // Creation date: 14.07.2008
 36 //                                                 36 //
 37 // Modifications:                                  37 // Modifications:
 38 //                                                 38 //
 39 // Class Description:                              39 // Class Description:
 40 //                                                 40 //
 41 // This class provides configuration EM models     41 // This class provides configuration EM models for 
 42 // particles/processes/regions                     42 // particles/processes/regions
 43 //                                                 43 //
 44                                                    44 
 45 // -------------------------------------------     45 // -------------------------------------------------------------------
 46 //                                                 46 //
 47                                                    47 
 48 #include "G4EmConfigurator.hh"                     48 #include "G4EmConfigurator.hh"
 49 #include "G4EmUtility.hh"                          49 #include "G4EmUtility.hh"
 50 #include "G4SystemOfUnits.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"              62 #include "G4TransportationWithMsc.hh"
 63                                                    63 
 64 //....oooOO0OOooo........oooOO0OOooo........oo     64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 65                                                    65 
 66 G4EmConfigurator::G4EmConfigurator(G4int val):     66 G4EmConfigurator::G4EmConfigurator(G4int val):verbose(val)
 67 {                                                  67 {
 68   index = -10;                                     68   index = -10;
 69 }                                                  69 }
 70                                                    70 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 72                                                    72  
 73 G4EmConfigurator::~G4EmConfigurator() = defaul     73 G4EmConfigurator::~G4EmConfigurator() = default;
 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; }                   85   if(nullptr == mod) { return; }
 86   if(1 < verbose) {                                86   if(1 < verbose) {
 87     G4cout << " G4EmConfigurator::SetExtraEmMo     87     G4cout << " G4EmConfigurator::SetExtraEmModel " << mod->GetName()
 88            << " for " << particleName              88            << " for " << particleName 
 89            << " and " << processName               89            << " and " << processName 
 90            << " in the region <" << regionName     90            << " in the region <" << regionName
 91            << "> Emin(MeV)= " << emin/MeV          91            << "> Emin(MeV)= " << emin/MeV
 92            << " Emax(MeV)= " << emax/MeV           92            << " Emax(MeV)= " << emax/MeV
 93            << G4endl;                              93            << G4endl;
 94   }                                                94   }
 95                                                    95 
 96   models.push_back(mod);                           96   models.push_back(mod);
 97   flucModels.push_back(fm);                        97   flucModels.push_back(fm);
 98   G4double emin0 = std::max(emin, mod->LowEner     98   G4double emin0 = std::max(emin, mod->LowEnergyLimit());
 99   G4double emax0 = std::min(emax, mod->HighEne     99   G4double emax0 = std::min(emax, mod->HighEnergyLimit());
100   mod->SetActivationHighEnergyLimit(emax0);       100   mod->SetActivationHighEnergyLimit(emax0);
101                                                   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(emin0);
106   highEnergy.push_back(emax0);                    106   highEnergy.push_back(emax0);
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(1 < 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(nullptr != models[i]) {
120         const G4Region* reg = G4EmUtility::Fin    120         const G4Region* reg = G4EmUtility::FindRegion(regions[i]);
121         if(nullptr != reg) {                      121         if(nullptr != 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                                          const 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; }                  142   if(nullptr == mod) { return; }
143   if(1 < verbose) {                               143   if(1 < verbose) {
144     G4cout << " G4EmConfigurator::SetModelForR    144     G4cout << " G4EmConfigurator::SetModelForRegion: " << mod->GetName() 
145            << G4endl;                             145            << G4endl;
146     G4cout << " For " << particleName             146     G4cout << " For " << particleName 
147            << " and " << processName              147            << " and " << processName 
148            << " in the region <" << reg->GetNa    148            << " in the region <" << reg->GetName()
149            << " Emin(MeV)= " << emin/MeV          149            << " Emin(MeV)= " << emin/MeV
150            << " Emax(MeV)= " << emax/MeV;         150            << " Emax(MeV)= " << emax/MeV;
151     if(nullptr != fm) { G4cout << " FLmodel "     151     if(nullptr != fm) { G4cout << " FLmodel " << fm->GetName(); }
152     G4cout << G4endl;                             152     G4cout << G4endl;
153   }                                               153   }
154                                                   154 
155   // Loop checking, 03-Aug-2015, Vladimir Ivan    155   // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
156   auto myParticleIterator = G4ParticleTable::G    156   auto myParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
157   myParticleIterator->reset();                    157   myParticleIterator->reset();
158   while( (*myParticleIterator)() ) {              158   while( (*myParticleIterator)() ) {
159     const G4ParticleDefinition* part = myParti    159     const G4ParticleDefinition* part = myParticleIterator->value();
160                                                   160 
161     if((part->GetParticleName() == particleNam    161     if((part->GetParticleName() == particleName) ||
162        (particleName == "all") ||                 162        (particleName == "all") ||
163        (particleName == "charged" && part->Get    163        (particleName == "charged" && part->GetPDGCharge() != 0.0)) {
164                                                   164 
165       // search for process                       165       // search for process
166       G4ProcessManager* pmanager = part->GetPr    166       G4ProcessManager* pmanager = part->GetProcessManager();
167       G4ProcessVector* plist = pmanager->GetPr    167       G4ProcessVector* plist = pmanager->GetProcessList();
168       G4int np = pmanager->GetProcessListLengt    168       G4int np = pmanager->GetProcessListLength();
169                                                   169   
170       if(1 < verbose) {                           170       if(1 < verbose) {
171         G4cout << "Check process <" << process << 171   G4cout << "Check process <" << processName << "> for " 
172                << np << " processes" << G4endl << 172          << particleName << " in list of " << np << " processes" 
                                                   >> 173          << G4endl;
173       }                                           174       }
174       G4VProcess* proc = nullptr;                 175       G4VProcess* proc = nullptr;
175       for(G4int i=0; i<np; ++i) {                 176       for(G4int i=0; i<np; ++i) {
176         if(processName == (*plist)[i]->GetProc    177         if(processName == (*plist)[i]->GetProcessName()) {
177           proc = (*plist)[i];                     178           proc = (*plist)[i];
178           break;                                  179           break;
179         }                                         180         }
180       }                                           181       }
                                                   >> 182       G4bool isCombinedMscTrans = false;
                                                   >> 183       G4TransportationWithMsc* trans = nullptr;
181       if(nullptr == proc) {                       184       if(nullptr == proc) {
182         if(processName == "msc") {                185         if(processName == "msc") {
183           for (G4int i = 0; i < np; ++i) {     << 186     for(G4int i=0; i<np; ++i) {
184             auto* trans = dynamic_cast<G4Trans << 187             trans = dynamic_cast<G4TransportationWithMsc*>((*plist)[i]);
185             if (nullptr != trans) {            << 188             if(nullptr != trans) {
186               G4cout << "G4TransportationWithM << 189         G4cout << "G4TransportationWithMsc is found out!" << G4endl;
                                                   >> 190         isCombinedMscTrans = true;
187               proc = trans;                       191               proc = trans;
188               break;                           << 192         break;
189             }                                  << 193       }
190           }                                    << 194     }
191         }                                      << 195   }
192         if (nullptr == proc) {                 << 196   if(nullptr == proc) { 
193           if (0 < verbose) {                   << 197     if(0 < verbose) {
194             G4cout << "### G4EmConfigurator WA << 198       G4cout << "### G4EmConfigurator WARNING: fails to find a process <"
195                    << "> for " << particleName << 199        << processName << "> for " << particleName << G4endl;
196           }                                    << 200     }
197           return;                              << 201     return;
198         }                                      << 202   }
199       }                                           203       }
200                                                   204 
201       if(!UpdateModelEnergyRange(mod, emin, em    205       if(!UpdateModelEnergyRange(mod, emin, emax)) { return; }
202       // classify process                         206       // classify process
203       G4int ii = proc->GetProcessSubType();       207       G4int ii = proc->GetProcessSubType();
204       auto msc = dynamic_cast<G4VMscModel*>(mo    208       auto msc = dynamic_cast<G4VMscModel*>(mod);
205       if (nullptr != msc) {                    << 209       if(isCombinedMscTrans && nullptr != msc) {
206         if (auto* trans = dynamic_cast<G4Trans << 210   trans->AddMscModel(msc, index, reg);
207           trans->AddMscModel(msc, index, reg); << 211   if(1 < verbose) {
208           if (1 < verbose) {                   << 212     G4cout << "### Added msc model order= " << index << " for " 
209             G4cout << "### Added msc model ord << 213      << particleName << " and " << proc->GetProcessName()
210                    << proc->GetProcessName() < << 214      << G4endl;
211           }                                    << 215   }
212         }                                      << 216       } else if(10 == ii && nullptr != msc) {
213         else if (10 == ii) {                   << 217   auto p = dynamic_cast<G4VMultipleScattering*>(proc);
214           auto p = dynamic_cast<G4VMultipleSca << 218   if(nullptr != p) {
215           if (nullptr != p) {                  << 219     p->AddEmModel(index, msc, reg);
216             p->AddEmModel(index, msc, reg);    << 220     if(1 < verbose) {
217             if (1 < verbose) {                 << 221       G4cout << "### Added msc model order= " << index << " for " 
218               G4cout << "### Added msc model o << 222        << particleName << " and " << processName << G4endl;
219                      << processName << G4endl; << 223     }
220             }                                  << 224   }
221           }                                    << 225       } else if(2 <= ii && 4 >= ii) {
222         }                                      << 226   auto p = dynamic_cast<G4VEnergyLossProcess*>(proc);
223         else {                                 << 227   if(nullptr != p) {
224           G4cout << "### Unable to add msc mod << 228     p->AddEmModel(index,mod,fm,reg);
225                  << G4endl;                    << 229     if(1 < verbose) {
226         }                                      << 230       G4cout << "### Added eloss model order= " << index << " for " 
227       }                                        << 231        << particleName << " and " << processName << G4endl;
228       else if (2 <= ii && 4 >= ii) {           << 232     }
229         auto p = dynamic_cast<G4VEnergyLossPro << 233   }
230         if (nullptr != p) {                    << 234       } else {
231           p->AddEmModel(index, mod, fm, reg);  << 
232           if (1 < verbose) {                   << 
233             G4cout << "### Added eloss model o << 
234                    << processName << G4endl;   << 
235           }                                    << 
236         }                                      << 
237       }                                        << 
238       else {                                   << 
239         auto p = dynamic_cast<G4VEmProcess*>(p    235         auto p = dynamic_cast<G4VEmProcess*>(proc);
240         if (nullptr != p) {                    << 236   if(nullptr != p) {
241           p->AddEmModel(index, mod, reg);      << 237     p->AddEmModel(index,mod,reg);
242           if (1 < verbose) {                   << 238     if(1 < verbose) {
243             G4cout << "### Added em model orde << 239       G4cout << "### Added em model order= " << index << " for " 
244                    << processName << G4endl;   << 240        << particleName << " and " << processName << G4endl;
245           }                                    << 241     }
246         }                                      << 242   }
247         else {                                 << 243       } 
248           G4cout << "### Unable to add em mode << 
249                  << G4endl;                    << 
250         }                                      << 
251       }                                        << 
252       return;                                     244       return;
253     }                                             245     }
254   }                                               246   }
255 }                                                 247 }
256                                                   248 
257 //....oooOO0OOooo........oooOO0OOooo........oo    249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258                                                   250 
259 void                                              251 void 
260 G4EmConfigurator::PrepareModels(const G4Partic    252 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
261                                 G4VEnergyLossP    253                                 G4VEnergyLossProcess* p)
262 {                                                 254 {
263   size_t n = particles.size();                    255   size_t n = particles.size();
264   if(1 < verbose) {                               256   if(1 < verbose) {
265     G4cout << " G4EmConfigurator::PrepareModel    257     G4cout << " G4EmConfigurator::PrepareModels for EnergyLoss n= " 
266            << n << G4endl;                        258            << n << G4endl;
267   }                                               259   }
268   if(n > 0) {                                     260   if(n > 0) {
269     G4String particleName = aParticle->GetPart    261     G4String particleName = aParticle->GetParticleName(); 
270     G4String processName  = p->GetProcessName(    262     G4String processName  = p->GetProcessName(); 
271     //G4cout <<  particleName << "  " <<  proc    263     //G4cout <<  particleName << "  " <<  processName << G4endl;
272     for(size_t i=0; i<n; ++i) {                   264     for(size_t i=0; i<n; ++i) {
273       //G4cout <<  particles[i] << "  " <<  pr    265       //G4cout <<  particles[i] << "  " <<  processes[i] << G4endl;
274       if(processName == processes[i]) {           266       if(processName == processes[i]) {
275         if((particleName == particles[i]) ||      267         if((particleName == particles[i]) ||
276            (particles[i] == "all") ||             268            (particles[i] == "all") ||
277            (particles[i] == "charged" && aPart    269            (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
278           const G4Region* reg = G4EmUtility::F    270           const G4Region* reg = G4EmUtility::FindRegion(regions[i]);
279           //G4cout << "Region " << reg << G4en    271           //G4cout << "Region " << reg << G4endl;
280           if(nullptr != reg) {                    272           if(nullptr != reg) {
281             --index;                              273             --index;
282             G4VEmModel* mod = models[i];          274             G4VEmModel* mod = models[i];
283             G4VEmFluctuationModel* fm = flucMo    275             G4VEmFluctuationModel* fm = flucModels[i];
284             if(nullptr != mod) {                  276             if(nullptr != mod) {
285               if(UpdateModelEnergyRange(mod, l    277               if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
286                 p->AddEmModel(index,mod,fm,reg    278                 p->AddEmModel(index,mod,fm,reg);
287                 if(1 < verbose) {                 279                 if(1 < verbose) {
288                   G4cout << "### Added eloss m << 280                   G4cout << "### Added eloss model order= " << index << " for " 
289                          << " and " << process << 281                          << particleName << " and " << processName 
                                                   >> 282        << " for " << reg->GetName() << G4endl;
290                 }                                 283                 }
291               }                                   284               }
292             } else if(nullptr != fm) {            285             } else if(nullptr != fm) {
293               p->SetFluctModel(fm);               286               p->SetFluctModel(fm);
294             }                                     287             }
295           }                                       288           }
296         }                                         289         }
297       }                                           290       }
298     }                                             291     }
299   }                                               292   }
300 }                                                 293 }
301                                                   294 
302 //....oooOO0OOooo........oooOO0OOooo........oo    295 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
303                                                   296 
304 void                                              297 void 
305 G4EmConfigurator::PrepareModels(const G4Partic    298 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
306                                 G4VEmProcess*     299                                 G4VEmProcess* p)
307 {                                                 300 {
308   size_t n = particles.size();                    301   size_t n = particles.size();
309   if(1 < verbose) {                               302   if(1 < verbose) {
310     G4cout << " G4EmConfigurator::PrepareModel    303     G4cout << " G4EmConfigurator::PrepareModels for EM process n= " 
311            << n << G4endl;                        304            << n << G4endl;
312   }                                               305   }
313   if(n > 0) {                                     306   if(n > 0) {
314     G4String particleName = aParticle->GetPart    307     G4String particleName = aParticle->GetParticleName(); 
315     G4String processName  = p->GetProcessName(    308     G4String processName  = p->GetProcessName(); 
316     //G4cout <<  particleName << "  " <<  part    309     //G4cout <<  particleName << "  " <<  particleName << G4endl;
317     for(size_t i=0; i<n; ++i) {                   310     for(size_t i=0; i<n; ++i) {
318       if(processName == processes[i]) {           311       if(processName == processes[i]) {
319         if((particleName == particles[i]) ||      312         if((particleName == particles[i]) ||
320            (particles[i] == "all") ||             313            (particles[i] == "all") ||
321            (particles[i] == "charged" && aPart    314            (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
322           const G4Region* reg = G4EmUtility::F    315           const G4Region* reg = G4EmUtility::FindRegion(regions[i]);
323           //G4cout << "Region " << reg << G4en    316           //G4cout << "Region " << reg << G4endl;
324           if(nullptr != reg) {                    317           if(nullptr != reg) {
325             --index;                              318             --index;
326             G4VEmModel* mod = models[i];          319             G4VEmModel* mod = models[i];
327             if(nullptr != mod) {                  320             if(nullptr != mod) {
328               if(UpdateModelEnergyRange(mod, l    321               if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) { 
329                 p->AddEmModel(index,mod,reg);     322                 p->AddEmModel(index,mod,reg);
330                 if(1 < verbose) {                 323                 if(1 < verbose) {
331                   G4cout << "### Added em mode    324                   G4cout << "### Added em model order= " << index << " for " 
332                          << particleName << "     325                          << particleName << " and " << processName << G4endl;
333                 }                                 326                 }
334               }                                   327               }
335             }                                     328             }
336           }                                       329           }
337         }                                         330         }
338       }                                           331       }
339     }                                             332     }
340   }                                               333   }
341 }                                                 334 }
342                                                   335 
343 //....oooOO0OOooo........oooOO0OOooo........oo    336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
344                                                   337 
345 void                                              338 void 
346 G4EmConfigurator::PrepareModels(const G4Partic    339 G4EmConfigurator::PrepareModels(const G4ParticleDefinition* aParticle,
347                                 G4VMultipleSca    340                                 G4VMultipleScattering* p,
348                                 G4Transportati    341                                 G4TransportationWithMsc* trans)
349 {                                                 342 {
350   size_t n = particles.size();                    343   size_t n = particles.size();
351   if(1 < verbose) {                               344   if(1 < verbose) {
352     G4cout << " G4EmConfigurator::PrepareModel    345     G4cout << " G4EmConfigurator::PrepareModels for MSC process n= " 
353            << n << G4endl;                        346            << n << G4endl;
354   }                                               347   }
355                                                   348 
356   if(n > 0) {                                     349   if(n > 0) {
357     G4String particleName = aParticle->GetPart    350     G4String particleName = aParticle->GetParticleName();
358     G4String processName = (nullptr == p) ? G4 << 351     G4String processName = (nullptr == p) ? "msc" : p->GetProcessName();
359     for(size_t i=0; i<n; ++i) {                   352     for(size_t i=0; i<n; ++i) {
360       if(processName == processes[i]) {           353       if(processName == processes[i]) {
361         if ((particleName == particles[i]) ||  << 354   if((particleName == particles[i]) ||
362             || (particles[i] == "charged" && a << 355      (particles[i] == "all") ||
363         {                                      << 356      (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
364           const G4Region* reg = G4EmUtility::F << 357     const G4Region* reg = G4EmUtility::FindRegion(regions[i]);
365           if (nullptr != reg) {                << 358     if(nullptr != reg) {
366             --index;                           << 359       --index;
367             auto mod = dynamic_cast<G4VMscMode << 360       auto mod = dynamic_cast<G4VMscModel*>(models[i]);
368             if(nullptr != mod) {                  361             if(nullptr != mod) {
369               if(UpdateModelEnergyRange(mod, l    362               if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
370                 if(nullptr != p) {                363                 if(nullptr != p) {
371                   p->AddEmModel(index, mod, re << 364       p->AddEmModel(index,mod,reg);
372                 }                              << 365     } else {
373                 else {                         << 366       trans->AddMscModel(mod,index,reg);
374                   trans->AddMscModel(mod, inde << 367     }
375                 }                              << 
376                 //G4cout << "### Added msc mod    368                 //G4cout << "### Added msc model order= " << index << " for " 
377                 //   << particleName << " and     369                 //   << particleName << " and " << processName << G4endl;
378               }                                   370               }
379             }                                     371             }
380           }                                       372           }
381         }                                         373         }
382       }                                           374       }
383     }                                             375     }
384   }                                               376   }
385 }                                                 377 }
386                                                   378 
387 //....oooOO0OOooo........oooOO0OOooo........oo    379 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
388                                                   380 
389 void G4EmConfigurator::Clear()                    381 void G4EmConfigurator::Clear()
390 {                                                 382 {
391   particles.clear();                              383   particles.clear();
392   processes.clear();                              384   processes.clear();
393   models.clear();                                 385   models.clear();
394   flucModels.clear();                             386   flucModels.clear();
395   regions.clear();                                387   regions.clear();
396   lowEnergy.clear();                              388   lowEnergy.clear();
397   highEnergy.clear();                             389   highEnergy.clear();
398 }                                                 390 }
399                                                   391 
400 //....oooOO0OOooo........oooOO0OOooo........oo    392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
401                                                   393 
402 G4bool G4EmConfigurator::UpdateModelEnergyRang    394 G4bool G4EmConfigurator::UpdateModelEnergyRange(G4VEmModel* mod, 
403                                                   395                                                 G4double emin, G4double emax)
404 {                                                 396 {
405   // energy limits                                397   // energy limits
406   G4double e1 = std::max(emin,mod->LowEnergyLi    398   G4double e1 = std::max(emin,mod->LowEnergyLimit());
407   G4double e2 = std::min(emax,mod->HighEnergyL    399   G4double e2 = std::min(emax,mod->HighEnergyLimit());
408   if(e2 <= e1) {                                  400   if(e2 <= e1) {
409     G4cout << "### G4EmConfigurator WARNING: e    401     G4cout << "### G4EmConfigurator WARNING: empty energy interval"
410            << " for <" << mod->GetName()          402            << " for <" << mod->GetName() 
411            << ">  Emin(MeV)= " << e1/CLHEP::Me    403            << ">  Emin(MeV)= " << e1/CLHEP::MeV 
412            << ">  Emax(MeV)= " << e2/CLHEP::Me    404            << ">  Emax(MeV)= " << e2/CLHEP::MeV 
413            << G4endl;                             405            << G4endl;
414     return false;                                 406     return false;        
415   }                                               407   }
416   mod->SetLowEnergyLimit(e1);                     408   mod->SetLowEnergyLimit(e1);
417   mod->SetHighEnergyLimit(e2);                    409   mod->SetHighEnergyLimit(e2);
418   if(verbose > 1) {                               410   if(verbose > 1) {
419     G4cout << "### G4EmConfigurator for " << m    411     G4cout << "### G4EmConfigurator for " << mod->GetName() 
420            << " Emin(MeV)= " << e1/MeV << " Em    412            << " Emin(MeV)= " << e1/MeV << " Emax(MeV)= " << e2/MeV 
421            << G4endl;                             413            << G4endl;
422   }                                               414   } 
423   return true;                                    415   return true;
424 }                                                 416 }
425                                                   417 
426 //....oooOO0OOooo........oooOO0OOooo........oo    418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
427                                                   419