Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PhysicsListHelper Class Reference

#include <G4PhysicsListHelper.hh>

Public Member Functions

G4bool RegisterProcess (G4VProcess *process, G4ParticleDefinition *particle)
 
void AddTransportation ()
 
void UseCoupledTransportation (G4bool vl=true)
 
void UseHighLooperThresholds ()
 
void UseLowLooperThresholds ()
 
void CheckParticleList () const
 
void DumpOrdingParameterTable (G4int subType=-1) const
 
G4PhysicsListOrderingParameter GetOrdingParameter (G4int subType) const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 

Static Public Member Functions

static G4PhysicsListHelperGetPhysicsListHelper ()
 

Friends

class G4ThreadLocalSingleton< G4PhysicsListHelper >
 

Detailed Description

Definition at line 51 of file G4PhysicsListHelper.hh.

Member Function Documentation

◆ AddTransportation()

void G4PhysicsListHelper::AddTransportation ( )

Definition at line 229 of file G4PhysicsListHelper.cc.

230{
231 G4int verboseLevelTransport = 0;
232
233#ifdef G4VERBOSE
234 if(verboseLevel > 2)
235 {
236 G4cout << "G4PhysicsListHelper::AddTransportation() " << G4endl;
237 }
238#endif
239
240 G4int nParaWorld =
242
243 if(nParaWorld > 0 || useCoupledTransportation ||
245 {
246 auto coupledTransport = new G4CoupledTransportation(verboseLevelTransport);
247 if(theLooperThresholds == 0)
248 coupledTransport->SetLowLooperThresholds();
249 if(theLooperThresholds == 2)
250 coupledTransport->SetHighLooperThresholds();
251 theTransportationProcess = coupledTransport;
252
253 if(verboseLevel > 0)
254 {
255 G4cout << "--- G4CoupledTransportation is used " << G4endl;
256 }
257 }
258 else
259 {
260 auto simpleTransport = new G4Transportation(verboseLevelTransport);
261 if(theLooperThresholds == 0)
262 simpleTransport->SetLowLooperThresholds();
263 if(theLooperThresholds == 2)
264 simpleTransport->SetHighLooperThresholds();
265 theTransportationProcess = simpleTransport;
266 }
267
268 // loop over all particles in G4ParticleTable
269 aParticleIterator->reset();
270 while((*aParticleIterator)())
271 {
272 G4ParticleDefinition* particle = aParticleIterator->value();
273 G4ProcessManager* pmanager = particle->GetProcessManager();
274 // Add transportation process for all particles
275 if(pmanager == 0)
276 {
277 // Error !! no process manager
278#ifdef G4VERBOSE
279 if(verboseLevel > 0)
280 {
281 G4cout << "G4PhysicsListHelper::AddTransportation "
282 << " : No Process Manager for " << particle->GetParticleName()
283 << G4endl;
284 }
285#endif
286 G4Exception("G4PhysicsListHelper::AddTransportation", "Run0104",
287 FatalException, "No process manager");
288 continue;
289 }
290 // Molecule use different type transportation
291 if(particle->GetParticleType() == "Molecule")
292 continue;
293
294 // add transportation with ordering = ( -1, "first", "first" )
295 pmanager->AddProcess(theTransportationProcess);
296 pmanager->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
297 pmanager->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
298 }
299}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
@ idxPostStep
@ idxAlongStep
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleType() const
const G4String & GetParticleName() const
void reset(G4bool ifSkipIon=true)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
static G4RunManagerKernel * GetRunManagerKernel()
G4int GetNumberOfParallelWorld() const
static G4ScoringManager * GetScoringManagerIfExist()

◆ CheckParticleList()

void G4PhysicsListHelper::CheckParticleList ( ) const

Definition at line 103 of file G4PhysicsListHelper.cc.

104{
105 G4bool isElectron = false;
106 G4bool isPositron = false;
107 G4bool isGamma = false;
108 G4bool isProton = false;
109 G4bool isGenericIon = false;
110 G4bool isAnyIon = false;
111 G4bool isAnyChargedBaryon = false;
112 G4bool isEmProc = false;
113
114 // loop over all particles in G4ParticleTable
115 aParticleIterator->reset();
116 while((*aParticleIterator)())
117 {
118 G4ParticleDefinition* particle = aParticleIterator->value();
119 G4String name = particle->GetParticleName();
120 // check if any EM process exists
121 if(!isEmProc)
122 {
123 G4ProcessVector* list = particle->GetProcessManager()->GetProcessList();
124 for(std::size_t idx = 0; idx < list->size(); ++idx)
125 {
126 isEmProc = ((*list)[idx])->GetProcessType() == fElectromagnetic;
127 if(isEmProc)
128 break;
129 }
130 }
131
132 if(name == "e-")
133 isElectron = true;
134 else if(name == "e+")
135 isPositron = true;
136 else if(name == "gamma")
137 isGamma = true;
138 else if(name == "GenericIon")
139 isGenericIon = true;
140 else if(name == "proton")
141 isProton = true;
142 else if(particle->GetParticleType() == "nucleus")
143 isAnyIon = true;
144 else if(particle->GetParticleType() == "baryon")
145 {
146 if(particle->GetPDGCharge() != 0.0)
147 isAnyChargedBaryon = true;
148 }
149 }
150
151 if(!isEmProc)
152 return;
153
154 // RULE 1
155 // e+, e- and gamma should exist
156 // if one of them exist
157 G4bool isEmBasic = isElectron || isPositron || isGamma;
158 G4bool isMissingEmBasic = !isElectron || !isPositron || !isGamma;
159 if(isEmBasic && isMissingEmBasic)
160 {
161 G4String missingName = "";
162 if(!isElectron)
163 missingName += "e- ";
164 if(!isPositron)
165 missingName += "e+ ";
166 if(!isGamma)
167 missingName += "gamma ";
168
169#ifdef G4VERBOSE
170 if(verboseLevel > 0)
171 {
172 G4cout << "G4PhysicsListHelper::CheckParticleList: " << missingName
173 << " do not exist " << G4endl;
174 G4cout << " These particle are necessary for basic EM processes"
175 << G4endl;
176 }
177#endif
178 G4Exception("G4PhysicsListHelper::CheckParticleList", "Run0101",
179 FatalException, "Missing EM basic particle");
180 }
181
182 // RULE 2
183 // proton should exist
184 // if any other charged baryon exist
185 if(!isProton && isAnyChargedBaryon)
186 {
187 G4String missingName = "proton ";
188
189#ifdef G4VERBOSE
190 if(verboseLevel > 0)
191 {
192 G4cout << "G4PhysicsListHelper::CheckParticleList: " << missingName
193 << " does not exist " << G4endl;
194 G4cout << " Proton is necessary for EM baryon processes" << G4endl;
195 }
196#endif
197 missingName += " should be created ";
198 G4Exception("G4PhysicsListHelper::CheckParticleList", "Run0102",
199 FatalException, "Missing Proton");
200 }
201
202 // RULE 3
203 // GenericIonn should exist
204 // if any other ion exist
205 if(!isGenericIon && isAnyIon)
206 {
207 G4String missingName = "GenericIon ";
208
209#ifdef G4VERBOSE
210 if(verboseLevel > 0)
211 {
212 G4cout << "G4PhysicsListHelper::CheckParticleList: " << missingName
213 << " does not exist " << G4endl;
214 G4cout << " GenericIon should be created if any ion is necessary"
215 << G4endl;
216 }
217#endif
218 G4Exception("G4PhysicsListHelper::CheckParticleList", "Run0103",
219 FatalException, "Missing GenericIon");
220 }
221}
@ fElectromagnetic
bool G4bool
Definition: G4Types.hh:86
G4double GetPDGCharge() const
G4ProcessVector * GetProcessList() const
std::size_t size() const
G4bool isElectron(G4int ityp)
const char * name(G4int ptype)

◆ DumpOrdingParameterTable()

void G4PhysicsListHelper::DumpOrdingParameterTable ( G4int  subType = -1) const

Definition at line 390 of file G4PhysicsListHelper.cc.

391{
392 if(theTable == 0)
393 {
394#ifdef G4VERBOSE
395 if(verboseLevel > 0)
396 {
397 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable "
398 << " No ordering parameter table : " << ordParamFileName
399 << G4endl;
400 }
401#endif
402 return;
403 }
404 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable : "
405 << ordParamFileName << G4endl;
406 G4cout << " TypeName "
407 << " ProcessType"
408 << " SubType"
409 << " AtRest"
410 << " AlongStep"
411 << " PostStep"
412 << " Duplicable" << G4endl;
413 for(G4int i = 0; i < sizeOfTable; ++i)
414 {
415 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
416 if((subType >= 0) && (subType != tmp->processSubType))
417 continue;
418 G4cout << std::setw(18) << tmp->processTypeName << std::setw(15)
419 << tmp->processType << std::setw(15) << tmp->processSubType
420 << std::setw(15) << tmp->ordering[0] << std::setw(15)
421 << tmp->ordering[1] << std::setw(15) << tmp->ordering[2];
422 if(tmp->isDuplicable)
423 {
424 G4cout << " true";
425 }
426 else
427 {
428 G4cout << " false";
429 }
430 G4cout << G4endl;
431 }
432}

Referenced by G4UserPhysicsListMessenger::SetNewValue().

◆ GetOrdingParameter()

G4PhysicsListOrderingParameter G4PhysicsListHelper::GetOrdingParameter ( G4int  subType) const

Definition at line 435 of file G4PhysicsListHelper.cc.

437{
439
440 if(theTable == 0)
441 {
442#ifdef G4VERBOSE
443 if(verboseLevel > 0)
444 {
445 G4cout << "G4PhysicsListHelper::GetOrderingParameter : "
446 << " No ordering parameter table : " << ordParamFileName
447 << G4endl;
448 }
449#endif
450 return value;
451 }
452
453 for(G4int i = 0; i < sizeOfTable; ++i)
454 {
455 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
456 if(subType == tmp->processSubType)
457 {
458 value.processTypeName = tmp->processTypeName;
459 value.processType = tmp->processType;
460 value.processSubType = tmp->processSubType;
461 value.ordering[0] = tmp->ordering[0];
462 value.ordering[1] = tmp->ordering[1];
463 value.ordering[2] = tmp->ordering[2];
464 value.isDuplicable = tmp->isDuplicable;
465 }
466 }
467 return value;
468}

◆ GetPhysicsListHelper()

G4PhysicsListHelper * G4PhysicsListHelper::GetPhysicsListHelper ( )
static

Definition at line 92 of file G4PhysicsListHelper.cc.

93{
94 if(!pPLHelper)
95 {
97 pPLHelper = inst.Instance();
98 }
99 return pPLHelper;
100}

Referenced by G4HadronicBuilder::BuildElastic(), G4EmBuilder::ConstructBasicEmPhysics(), G4EmBuilder::ConstructCharged(), G4EmBuilder::ConstructIonEmPhysics(), G4EmBuilder::ConstructLightHadrons(), G4EmDNAChemistry::ConstructProcess(), G4EmDNAChemistry_option1::ConstructProcess(), G4EmDNAChemistry_option3::ConstructProcess(), G4EmDNAPhysics::ConstructProcess(), G4EmDNAPhysics_option1::ConstructProcess(), G4EmDNAPhysics_option2::ConstructProcess(), G4EmDNAPhysics_option3::ConstructProcess(), G4EmDNAPhysics_option4::ConstructProcess(), G4EmDNAPhysics_option5::ConstructProcess(), G4EmDNAPhysics_option6::ConstructProcess(), G4EmDNAPhysics_option7::ConstructProcess(), G4EmDNAPhysics_option8::ConstructProcess(), G4EmDNAPhysics_stationary::ConstructProcess(), G4EmDNAPhysics_stationary_option2::ConstructProcess(), G4EmDNAPhysics_stationary_option4::ConstructProcess(), G4EmDNAPhysics_stationary_option6::ConstructProcess(), G4EmExtraPhysics::ConstructProcess(), G4DecayPhysics::ConstructProcess(), G4MuonicAtomDecayPhysics::ConstructProcess(), G4RadioactiveDecayPhysics::ConstructProcess(), G4UnknownDecayPhysics::ConstructProcess(), G4EmDNAChemistry_option2::ConstructProcess(), G4EmDNAPhysicsActivator::ConstructProcess(), G4EmLivermorePhysics::ConstructProcess(), G4EmLowEPPhysics::ConstructProcess(), G4EmPenelopePhysics::ConstructProcess(), G4EmStandardPhysics::ConstructProcess(), G4EmStandardPhysics_option1::ConstructProcess(), G4EmStandardPhysics_option2::ConstructProcess(), G4EmStandardPhysics_option3::ConstructProcess(), G4EmStandardPhysics_option4::ConstructProcess(), G4EmStandardPhysicsGS::ConstructProcess(), G4EmStandardPhysicsSS::ConstructProcess(), G4EmStandardPhysicsWVI::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronPhysicsFTFQGSP_BERT::ConstructProcess(), G4VUserPhysicsList::G4VUserPhysicsList(), G4VUPLData::initialize(), G4VPhysicsConstructor::RegisterProcess(), and G4UserPhysicsListMessenger::SetNewValue().

◆ GetVerboseLevel()

G4int G4PhysicsListHelper::GetVerboseLevel ( ) const
inline

Definition at line 136 of file G4PhysicsListHelper.hh.

137{
138 return verboseLevel;
139}

Referenced by G4MuonicAtomDecayPhysics::ConstructProcess().

◆ RegisterProcess()

G4bool G4PhysicsListHelper::RegisterProcess ( G4VProcess process,
G4ParticleDefinition particle 
)

Definition at line 471 of file G4PhysicsListHelper.cc.

473{
474 if(theTable == 0)
475 {
476#ifdef G4VERBOSE
477 if(verboseLevel > 0)
478 {
479 G4cout << "G4PhysicsListHelper::RegisterProcess :"
480 << " No ordering parameter table : " << ordParamFileName
481 << G4endl;
482 }
483#endif
484 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0107",
485 FatalException, "No Ordering Parameter Table");
486 return false;
487 }
488
489 const G4String pName = process->GetProcessName();
490 const G4int pType = process->GetProcessType();
491 const G4int pSubType = process->GetProcessSubType();
492
493#ifdef G4VERBOSE
494 if(verboseLevel > 2)
495 {
496 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName
497 << " Process Type = " << pType << " SubType = " << pSubType << " to "
498 << particle->GetParticleName() << G4endl;
499 }
500#endif
501
502 // Check Process Type/SubType
503 if((pType < 1) || (pSubType < 1))
504 {
505#ifdef G4VERBOSE
506 if(verboseLevel > 0)
507 {
508 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
509 << particle->GetParticleName()
510 << " has illegal Process Type = " << pType
511 << " SubType = " << pSubType << G4endl;
512 }
513#endif
514 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0108",
515 FatalException, "No Matching process Type/SubType");
516 return false;
517 }
518
519 G4bool isFound = false;
520 G4int ord[3];
521 G4bool duplicable = false;
522 for(G4int i = 0; i < sizeOfTable; ++i)
523 {
524 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
525 if((tmp->processType == pType) && (tmp->processSubType == pSubType))
526 {
527 ord[0] = tmp->ordering[0];
528 ord[1] = tmp->ordering[1];
529 ord[2] = tmp->ordering[2];
530 duplicable = tmp->isDuplicable;
531 isFound = true;
532 break;
533 }
534 }
535 if(!isFound)
536 {
537#ifdef G4VERBOSE
538 if(verboseLevel > 0)
539 {
540 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
541 << particle->GetParticleName() << " with type/subtype =" << pType
542 << "/" << pSubType
543 << " is not registered in OrdingParameterTable " << G4endl;
544 }
545#endif
546 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0109",
547 FatalException, "No Matching process Type/SubType");
548 return false;
549 }
550
551 // Check Process Manager
552 G4ProcessManager* pManager = particle->GetProcessManager();
553 if(pManager == 0)
554 {
555 // Error !! no process manager
556#ifdef G4VERBOSE
557 if(verboseLevel > 0)
558 {
559 G4cout << "G4PhysicsListHelper::RegisterProcess "
560 << " : No Process Manager for " << particle->GetParticleName()
561 << G4endl;
562 }
563#endif
564 G4Exception("G4PhysicsListHelper::RegisterProcess ", "Riun0110",
565 FatalException, "No process manager");
566 return false;
567 }
568
569 // Check Duplication
570 if(!duplicable)
571 {
572 G4bool duplicated = false;
573 G4ProcessVector* pList = pManager->GetProcessList();
574 for(std::size_t idx = 0; idx < pList->size(); ++idx)
575 {
576 const G4VProcess* p = (*pList)[idx];
577 if((p->GetProcessType() == pType) && (p->GetProcessSubType() == pSubType))
578 {
579 duplicated = true;
580#ifdef G4VERBOSE
581 if(verboseLevel > 0)
582 {
583 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
584 << particle->GetParticleName()
585 << " with type/subtype =" << pType << "/" << pSubType
586 << " is has same subType as " << p->GetProcessName()
587 << " for " << particle->GetParticleName() << G4endl;
588 G4cout << "It will not be added !!" << G4endl;
589 }
590#endif
591 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0111",
592 JustWarning, "Duplication of processes");
593 }
594 }
595 if(duplicated)
596 return false;
597 }
598
599 // Add Process
600 G4int code = pManager->AddProcess(process);
601 if(code < 0)
602 return false;
603
604 // Set Ordering Parameter
605 for(G4int idx = 0; idx < 3; ++idx)
606 {
608 static_cast<G4ProcessVectorDoItIndex>(idx);
609 if(ord[idx] < 0)
610 {
611 // Do Nothing because NO DOIT
612 }
613 else if(ord[idx] == 0)
614 {
615 pManager->SetProcessOrderingToFirst(process, idxOrd);
616 }
617 else if(ord[idx] < 9999)
618 {
619 pManager->SetProcessOrdering(process, idxOrd, ord[idx]);
620 }
621 else
622 {
623 pManager->SetProcessOrderingToLast(process, idxOrd);
624 }
625 }
626#ifdef G4VERBOSE
627 if(verboseLevel > 1)
628 {
629 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
630 << particle->GetParticleName() << " with type/subtype =" << pType
631 << "/" << pSubType
632 << " is successfully registered with ordering parameters " << ord[0]
633 << ":" << ord[1] << ":" << ord[2] << G4endl;
634 }
635#endif
636 return true;
637}
@ JustWarning
G4ProcessVectorDoItIndex
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:388
G4int GetProcessSubType() const
Definition: G4VProcess.hh:400
const G4String & GetProcessName() const
Definition: G4VProcess.hh:382
Definition: inftrees.h:24

Referenced by G4HadronicBuilder::BuildElastic(), G4EmBuilder::ConstructBasicEmPhysics(), G4EmBuilder::ConstructCharged(), G4EmBuilder::ConstructIonEmPhysics(), G4EmBuilder::ConstructLightHadrons(), G4EmDNAChemistry_option1::ConstructProcess(), G4EmDNAChemistry_option3::ConstructProcess(), G4EmDNAPhysics::ConstructProcess(), G4EmDNAPhysics_option1::ConstructProcess(), G4EmDNAPhysics_option2::ConstructProcess(), G4EmDNAPhysics_option3::ConstructProcess(), G4EmDNAPhysics_option4::ConstructProcess(), G4EmDNAPhysics_option5::ConstructProcess(), G4EmDNAPhysics_option6::ConstructProcess(), G4EmDNAPhysics_option7::ConstructProcess(), G4EmDNAPhysics_option8::ConstructProcess(), G4EmDNAPhysics_stationary::ConstructProcess(), G4EmDNAPhysics_stationary_option2::ConstructProcess(), G4EmDNAPhysics_stationary_option4::ConstructProcess(), G4EmDNAPhysics_stationary_option6::ConstructProcess(), G4EmExtraPhysics::ConstructProcess(), G4DecayPhysics::ConstructProcess(), G4UnknownDecayPhysics::ConstructProcess(), G4EmDNAPhysicsActivator::ConstructProcess(), G4EmLivermorePhysics::ConstructProcess(), G4EmLowEPPhysics::ConstructProcess(), G4EmPenelopePhysics::ConstructProcess(), G4EmStandardPhysics::ConstructProcess(), G4EmStandardPhysics_option1::ConstructProcess(), G4EmStandardPhysics_option2::ConstructProcess(), G4EmStandardPhysics_option3::ConstructProcess(), G4EmStandardPhysics_option4::ConstructProcess(), G4EmStandardPhysicsGS::ConstructProcess(), G4EmStandardPhysicsSS::ConstructProcess(), G4EmStandardPhysicsWVI::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronPhysicsFTFQGSP_BERT::ConstructProcess(), and G4VPhysicsConstructor::RegisterProcess().

◆ SetVerboseLevel()

void G4PhysicsListHelper::SetVerboseLevel ( G4int  value)
inline

Definition at line 131 of file G4PhysicsListHelper.hh.

132{
133 verboseLevel = value;
134}

Referenced by G4MuonicAtomDecayPhysics::ConstructProcess().

◆ UseCoupledTransportation()

void G4PhysicsListHelper::UseCoupledTransportation ( G4bool  vl = true)
inline

Definition at line 126 of file G4PhysicsListHelper.hh.

127{
128 useCoupledTransportation = vl;
129}

◆ UseHighLooperThresholds()

void G4PhysicsListHelper::UseHighLooperThresholds ( )
inline

Definition at line 78 of file G4PhysicsListHelper.hh.

78{ theLooperThresholds = 2; }

◆ UseLowLooperThresholds()

void G4PhysicsListHelper::UseLowLooperThresholds ( )
inline

Definition at line 79 of file G4PhysicsListHelper.hh.

79{ theLooperThresholds = 0; }

Friends And Related Function Documentation

◆ G4ThreadLocalSingleton< G4PhysicsListHelper >

Definition at line 136 of file G4PhysicsListHelper.hh.


The documentation for this class was generated from the following files: