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


** Warning: Cannot open xref database.

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