Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4EmConfigurator.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4EmConfigurator.cc 106507 2017-10-12 08:24:49Z gcosmo $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 Class
31 //
32 // File name: G4EmConfigurator
33 //
34 // Author: Vladimir Ivanchenko
35 //
36 // Creation date: 14.07.2008
37 //
38 // Modifications:
39 //
40 // Class Description:
41 //
42 // This class provides configuration EM models for
43 // particles/processes/regions
44 //
45 
46 // -------------------------------------------------------------------
47 //
48 
49 #include "G4EmConfigurator.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 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  index = -10;
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {}
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78  const G4String& processName,
79  G4VEmModel* mod,
80  const G4String& regionName,
81  G4double emin,
82  G4double emax,
84 {
85  if(!mod) { return; }
86  if(1 < verbose) {
87  G4cout << " G4EmConfigurator::SetExtraEmModel " << mod->GetName()
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->LowEnergyLimit());
99  G4double emax0 = std::min(emax, mod->HighEnergyLimit());
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........oooOO0OOooo........oooOO0OOooo......
110 
112 {
113  size_t n = models.size();
114  if(0 < verbose) {
115  G4cout << "### G4EmConfigurator::AddModels n= " << n << G4endl;
116  }
117  if(n > 0) {
118  for(size_t i=0; i<n; ++i) {
119  if(models[i]) {
121  if(reg) {
122  --index;
124  particles[i],processes[i],
125  lowEnergy[i],highEnergy[i]);
126  }
127  }
128  }
129  }
130  Clear();
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
137  G4Region* reg,
138  const G4String& particleName,
139  const G4String& processName,
140  G4double emin, G4double emax)
141 {
142  if(!mod) { return; }
143  if(1 < verbose) {
144  G4cout << " G4EmConfigurator::SetModelForRegion: " << mod->GetName()
145  << G4endl;
146  G4cout << " For " << particleName
147  << " and " << processName
148  << " in the region <" << reg->GetName()
149  << " Emin(MeV)= " << emin/MeV
150  << " Emax(MeV)= " << emax/MeV;
151  if(fm) { G4cout << " FLmodel " << fm->GetName(); }
152  G4cout << G4endl;
153  }
154 
155  // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
156  auto myParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
157  myParticleIterator->reset();
158  while( (*myParticleIterator)() ) {
159  const G4ParticleDefinition* part = myParticleIterator->value();
160 
161  if((part->GetParticleName() == particleName) ||
162  (particleName == "all") ||
163  (particleName == "charged" && part->GetPDGCharge() != 0.0)) {
164 
165  // search for process
166  G4ProcessManager* pmanager = part->GetProcessManager();
167  G4ProcessVector* plist = pmanager->GetProcessList();
168  G4int np = pmanager->GetProcessListLength();
169 
170  if(1 < verbose) {
171  G4cout << "Check process <" << processName << "> for "
172  << particleName << " in list of " << np << " processes"
173  << G4endl;
174  }
175  G4VProcess* proc = nullptr;
176  for(G4int i=0; i<np; ++i) {
177  if(processName == (*plist)[i]->GetProcessName()) {
178  proc = (*plist)[i];
179  break;
180  }
181  }
182  if(!proc) {
183  G4cout << "### G4EmConfigurator WARNING: fails to find a process <"
184  << processName << "> for " << particleName << G4endl;
185  return;
186  }
187 
188  if(!UpdateModelEnergyRange(mod, emin, emax)) { return; }
189  // classify process
190  G4int ii = proc->GetProcessSubType();
191  if(10 == ii) {
192  G4VMultipleScattering* p = static_cast<G4VMultipleScattering*>(proc);
193  p->AddEmModel(index,mod,reg);
194  if(1 < verbose) {
195  G4cout << "### Added msc model order= " << index << " for "
196  << particleName << " and " << processName << G4endl;
197  }
198  } else if(2 <= ii && 4 >= ii) {
199  G4VEnergyLossProcess* p = static_cast<G4VEnergyLossProcess*>(proc);
200  p->AddEmModel(index,mod,fm,reg);
201  if(1 < verbose) {
202  G4cout << "### Added eloss model order= " << index << " for "
203  << particleName << " and " << processName << G4endl;
204  }
205  } else {
206  G4VEmProcess* p = static_cast<G4VEmProcess*>(proc);
207  p->AddEmModel(index,mod,reg);
208  if(1 < verbose) {
209  G4cout << "### Added em model order= " << index << " for "
210  << particleName << " and " << processName << G4endl;
211  }
212  }
213  return;
214  }
215  }
216 }
217 
218 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
219 
220 void
223 {
224  size_t n = particles.size();
225  if(1 < verbose) {
226  G4cout << " G4EmConfigurator::PrepareModels for EnergyLoss n= "
227  << n << G4endl;
228  }
229  if(n > 0) {
230  G4String particleName = aParticle->GetParticleName();
231  G4String processName = p->GetProcessName();
232  //G4cout << particleName << " " << processName << G4endl;
233  for(size_t i=0; i<n; ++i) {
234  //G4cout << particles[i] << " " << processes[i] << G4endl;
235  if(processName == processes[i]) {
236  if((particleName == particles[i]) ||
237  (particles[i] == "all") ||
238  (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
240  //G4cout << "Region " << reg << G4endl;
241  if(reg) {
242  --index;
243  G4VEmModel* mod = models[i];
245  if(mod) {
246  if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
247  p->AddEmModel(index,mod,fm,reg);
248  if(1 < verbose) {
249  G4cout << "### Added eloss model order= " << index << " for "
250  << particleName << " and " << processName << G4endl;
251  }
252  }
253  } else if(fm) {
254  p->SetFluctModel(fm);
255  }
256  }
257  }
258  }
259  }
260  }
261 }
262 
263 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
264 
265 void
267  G4VEmProcess* p)
268 {
269  size_t n = particles.size();
270  if(1 < verbose) {
271  G4cout << " G4EmConfigurator::PrepareModels for EM process n= "
272  << n << G4endl;
273  }
274  if(n > 0) {
275  G4String particleName = aParticle->GetParticleName();
276  G4String processName = p->GetProcessName();
277  //G4cout << particleName << " " << particleName << G4endl;
278  for(size_t i=0; i<n; ++i) {
279  if(processName == processes[i]) {
280  if((particleName == particles[i]) ||
281  (particles[i] == "all") ||
282  (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
284  //G4cout << "Region " << reg << G4endl;
285  if(reg) {
286  --index;
287  G4VEmModel* mod = models[i];
288  if(mod) {
289  if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
290  p->AddEmModel(index,mod,reg);
291  if(1 < verbose) {
292  G4cout << "### Added em model order= " << index << " for "
293  << particleName << " and " << processName << G4endl;
294  }
295  }
296  }
297  }
298  }
299  }
300  }
301  }
302 }
303 
304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
305 
306 void
309 {
310  size_t n = particles.size();
311  if(1 < verbose) {
312  G4cout << " G4EmConfigurator::PrepareModels for MSC process n= "
313  << n << G4endl;
314  }
315 
316  if(n > 0) {
317  G4String particleName = aParticle->GetParticleName();
318  G4String processName = p->GetProcessName();
319  for(size_t i=0; i<n; ++i) {
320  if(processName == processes[i]) {
321  if((particleName == particles[i]) ||
322  (particles[i] == "all") ||
323  (particles[i] == "charged" && aParticle->GetPDGCharge() != 0.0)) {
325  if(reg) {
326  --index;
327  G4VEmModel* mod = models[i];
328  if(mod) {
329  if(UpdateModelEnergyRange(mod, lowEnergy[i], highEnergy[i])) {
330  p->AddEmModel(index,mod,reg);
331  //G4cout << "### Added msc model order= " << index << " for "
332  // << particleName << " and " << processName << G4endl;
333  }
334  }
335  }
336  }
337  }
338  }
339  }
340 }
341 
342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
343 
345 {
346  particles.clear();
347  processes.clear();
348  models.clear();
349  flucModels.clear();
350  regions.clear();
351  lowEnergy.clear();
352  highEnergy.clear();
353 }
354 
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356 
358 {
359  // search for region
360  G4Region* reg = 0;
362  G4String r = regionName;
363  if(r == "" || r == "world" || r == "World") {
364  r = "DefaultRegionForTheWorld";
365  }
366  reg = regStore->GetRegion(r, true);
367  if(!reg) {
368  G4cout << "### G4EmConfigurator WARNING: fails to find a region <"
369  << r << G4endl;
370  } else if(verbose > 1) {
371  G4cout << "### G4EmConfigurator finds out G4Region <" << r << ">"
372  << G4endl;
373  }
374  return reg;
375 }
376 
377 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
378 
380  G4double emin, G4double emax)
381 {
382  // energy limits
383  G4double e1 = std::max(emin,mod->LowEnergyLimit());
384  G4double e2 = std::min(emax,mod->HighEnergyLimit());
385  if(e2 <= e1) {
386  G4cout << "### G4EmConfigurator WARNING: empty energy interval"
387  << " for <" << mod->GetName()
388  << "> Emin(MeV)= " << e1/CLHEP::MeV
389  << "> Emax(MeV)= " << e2/CLHEP::MeV
390  << G4endl;
391  return false;
392  }
393  mod->SetLowEnergyLimit(e1);
394  mod->SetHighEnergyLimit(e2);
395  if(verbose > 1) {
396  G4cout << "### G4EmConfigurator for " << mod->GetName()
397  << " Emin(MeV)= " << e1/MeV << " Emax(MeV)= " << e2/MeV
398  << G4endl;
399  }
400  return true;
401 }
402 
403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::vector< G4String > regions
std::vector< G4String > processes
static G4ParticleTable * GetParticleTable()
static constexpr double MeV
Definition: G4SIunits.hh:214
void SetHighEnergyLimit(G4double)
Definition: G4VEmModel.hh:707
const G4String & GetName() const
G4int GetProcessListLength() const
const G4String & GetName() const
#define G4endl
Definition: G4ios.hh:61
const char * p
Definition: xmltok.h:285
const G4String & GetParticleName() const
void SetActivationHighEnergyLimit(G4double)
Definition: G4VEmModel.hh:721
G4double GetPDGCharge() const
static const G4double emax
void SetExtraEmModel(const G4String &particleName, const G4String &processName, G4VEmModel *, const G4String &regionName="", G4double emin=0.0, G4double emax=DBL_MAX, G4VEmFluctuationModel *fm=nullptr)
G4ProcessVector * GetProcessList() const
G4PTblDicIterator * GetIterator() const
void reset(G4bool ifSkipIon=true)
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:616
std::vector< G4double > lowEnergy
std::vector< G4String > particles
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
TString part[npart]
Definition: Style.C:32
std::vector< G4double > highEnergy
void AddEmModel(G4int, G4VEmModel *, G4VEmFluctuationModel *fluc=0, const G4Region *region=nullptr)
static constexpr double MeV
const G4String & GetProcessName() const
Definition: G4VProcess.hh:411
void SetFluctModel(G4VEmFluctuationModel *)
static G4RegionStore * GetInstance()
int G4int
Definition: G4Types.hh:78
const G4String & GetName() const
Definition: G4VEmModel.hh:777
G4ProcessManager * GetProcessManager() const
void SetLowEnergyLimit(G4double)
Definition: G4VEmModel.hh:714
void PrepareModels(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4GLOB_DLL std::ostream G4cout
void AddEmModel(G4int, G4VEmModel *, const G4Region *region=nullptr)
void AddEmModel(G4int order, G4VEmModel *, const G4Region *region=nullptr)
Char_t n[5]
static const G4double reg
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:609
G4Region * FindRegion(const G4String &)
std::vector< G4VEmFluctuationModel * > flucModels
std::vector< G4VEmModel * > models
G4EmConfigurator(G4int verboseLevel=1)
void SetModelForRegion(G4VEmModel *model, G4VEmFluctuationModel *fm, G4Region *reg, const G4String &particleName, const G4String &processName, G4double emin, G4double emax)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool UpdateModelEnergyRange(G4VEmModel *mod, G4double emin, G4double emax)
G4int GetProcessSubType() const
Definition: G4VProcess.hh:429