Geant4 11.2.2
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 49 of file G4PhysicsListHelper.hh.

Member Function Documentation

◆ AddTransportation()

void G4PhysicsListHelper::AddTransportation ( )

Definition at line 196 of file G4PhysicsListHelper.cc.

197{
198 G4int verboseLevelTransport = 0;
199
200#ifdef G4VERBOSE
201 if (verboseLevel > 2) {
202 G4cout << "G4PhysicsListHelper::AddTransportation() " << G4endl;
203 }
204#endif
205
207
208 if (nParaWorld > 0 || useCoupledTransportation
210 {
211 auto coupledTransport = new G4CoupledTransportation(verboseLevelTransport);
212 if (theLooperThresholds == 0) coupledTransport->SetLowLooperThresholds();
213 if (theLooperThresholds == 2) coupledTransport->SetHighLooperThresholds();
214 theTransportationProcess = coupledTransport;
215
216 if (verboseLevel > 0) {
217 G4cout << "--- G4CoupledTransportation is used " << G4endl;
218 }
219 }
220 else {
221 auto simpleTransport = new G4Transportation(verboseLevelTransport);
222 if (theLooperThresholds == 0) simpleTransport->SetLowLooperThresholds();
223 if (theLooperThresholds == 2) simpleTransport->SetHighLooperThresholds();
224 theTransportationProcess = simpleTransport;
225 }
226
227 // loop over all particles in G4ParticleTable
228 aParticleIterator->reset();
229 while ((*aParticleIterator)()) {
230 G4ParticleDefinition* particle = aParticleIterator->value();
231 G4ProcessManager* pmanager = particle->GetProcessManager();
232 // Add transportation process for all particles
233 if (pmanager == nullptr) {
234 // Error !! no process manager
235#ifdef G4VERBOSE
236 if (verboseLevel > 0) {
237 G4cout << "G4PhysicsListHelper::AddTransportation "
238 << " : No Process Manager for " << particle->GetParticleName() << G4endl;
239 }
240#endif
241 G4Exception("G4PhysicsListHelper::AddTransportation", "Run0104", FatalException,
242 "No process manager");
243 continue;
244 }
245 // Molecule use different type transportation
246 if (particle->GetParticleType() == "Molecule") continue;
247
248 // add transportation with ordering = ( -1, "first", "first" )
249 pmanager->AddProcess(theTransportationProcess);
250 pmanager->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
251 pmanager->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
252 }
253}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
@ idxPostStep
@ idxAlongStep
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
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 93 of file G4PhysicsListHelper.cc.

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

289{
290 if (theTable == nullptr) {
291#ifdef G4VERBOSE
292 if (verboseLevel > 0) {
293 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable "
294 << " No ordering parameter table : " << ordParamFileName << G4endl;
295 }
296#endif
297 return;
298 }
299 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable : " << ordParamFileName << G4endl;
300 G4cout << " TypeName "
301 << " ProcessType"
302 << " SubType"
303 << " AtRest"
304 << " AlongStep"
305 << " PostStep"
306 << " Duplicable" << G4endl;
307 for (G4int i = 0; i < sizeOfTable; ++i) {
308 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
309 if ((subType >= 0) && (subType != tmp->processSubType)) continue;
310 G4cout << std::setw(18) << tmp->processTypeName << std::setw(15) << tmp->processType
311 << std::setw(15) << tmp->processSubType << std::setw(15) << tmp->ordering[0]
312 << std::setw(15) << tmp->ordering[1] << std::setw(15) << tmp->ordering[2];
313 if (tmp->isDuplicable) {
314 G4cout << " true";
315 }
316 else {
317 G4cout << " false";
318 }
319 G4cout << G4endl;
320 }
321}

Referenced by G4UserPhysicsListMessenger::SetNewValue().

◆ GetOrdingParameter()

G4PhysicsListOrderingParameter G4PhysicsListHelper::GetOrdingParameter ( G4int subType) const

Definition at line 324 of file G4PhysicsListHelper.cc.

325{
327
328 if (theTable == nullptr) {
329#ifdef G4VERBOSE
330 if (verboseLevel > 0) {
331 G4cout << "G4PhysicsListHelper::GetOrderingParameter : "
332 << " No ordering parameter table : " << ordParamFileName << G4endl;
333 }
334#endif
335 return value;
336 }
337
338 for (G4int i = 0; i < sizeOfTable; ++i) {
339 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
340 if (subType == tmp->processSubType) {
341 value.processTypeName = tmp->processTypeName;
342 value.processType = tmp->processType;
343 value.processSubType = tmp->processSubType;
344 value.ordering[0] = tmp->ordering[0];
345 value.ordering[1] = tmp->ordering[1];
346 value.ordering[2] = tmp->ordering[2];
347 value.isDuplicable = tmp->isDuplicable;
348 }
349 }
350 return value;
351}

◆ GetPhysicsListHelper()

G4PhysicsListHelper * G4PhysicsListHelper::GetPhysicsListHelper ( )
static

Definition at line 83 of file G4PhysicsListHelper.cc.

84{
85 if (pPLHelper == nullptr) {
87 pPLHelper = inst.Instance();
88 }
89 return pPLHelper;
90}

Referenced by G4HadronicBuilder::BuildElastic(), G4HadronicBuilder::BuildFTFP_INCLXX(), G4HadProcesses::BuildNeutronElastic(), G4HadProcesses::BuildNeutronInelasticAndCapture(), G4EmBuilder::ConstructBasicEmPhysics(), G4EmBuilder::ConstructCharged(), G4EmBuilder::ConstructChargedSS(), G4EmBuilder::ConstructElectronMscProcess(), G4EmBuilder::ConstructElectronSSProcess(), G4EmBuilder::ConstructIonEmPhysics(), G4EmBuilder::ConstructIonEmPhysicsSS(), G4EmBuilder::ConstructLightHadrons(), G4EmBuilder::ConstructLightHadronsSS(), G4DecayPhysics::ConstructProcess(), G4EmDNAChemistry::ConstructProcess(), G4EmDNAChemistry_option1::ConstructProcess(), G4EmDNAChemistry_option2::ConstructProcess(), G4EmDNAChemistry_option3::ConstructProcess(), G4EmExtraPhysics::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(), G4HadronDElasticPhysics::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronHElasticPhysics::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronInelasticQBBC_ABLA::ConstructProcess(), G4HadronPhysicsFTFQGSP_BERT::ConstructProcess(), G4MuonicAtomDecayPhysics::ConstructProcess(), G4RadioactiveDecayPhysics::ConstructProcess(), G4UnknownDecayPhysics::ConstructProcess(), G4EmDNABuilder::ConstructStandardEmPhysics(), G4EmDNABuilder::FindOrBuildAttachment(), G4EmDNABuilder::FindOrBuildChargeDecrease(), G4EmDNABuilder::FindOrBuildChargeIncrease(), G4EmDNABuilder::FindOrBuildElastic(), G4EmDNABuilder::FindOrBuildElectronSolvation(), G4EmDNABuilder::FindOrBuildExcitation(), G4EmDNABuilder::FindOrBuildIonisation(), G4EmDNABuilder::FindOrBuildVibExcitation(), G4VUserPhysicsList::G4VUserPhysicsList(), G4VUPLData::initialize(), G4VPhysicsConstructor::RegisterProcess(), and G4UserPhysicsListMessenger::SetNewValue().

◆ GetVerboseLevel()

G4int G4PhysicsListHelper::GetVerboseLevel ( ) const
inline

Definition at line 127 of file G4PhysicsListHelper.hh.

128{
129 return verboseLevel;
130}

Referenced by G4MuonicAtomDecayPhysics::ConstructProcess().

◆ RegisterProcess()

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

Definition at line 354 of file G4PhysicsListHelper.cc.

355{
356 if (theTable == nullptr) {
357#ifdef G4VERBOSE
358 if (verboseLevel > 0) {
359 G4cout << "G4PhysicsListHelper::RegisterProcess :"
360 << " No ordering parameter table : " << ordParamFileName << G4endl;
361 }
362#endif
363 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0107", FatalException,
364 "No Ordering Parameter Table");
365 return false;
366 }
367
368 const G4String pName = process->GetProcessName();
369 const G4int pType = process->GetProcessType();
370 const G4int pSubType = process->GetProcessSubType();
371
372#ifdef G4VERBOSE
373 if (verboseLevel > 2) {
374 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " Process Type = " << pType
375 << " SubType = " << pSubType << " to " << particle->GetParticleName() << G4endl;
376 }
377#endif
378
379 // Check Process Type/SubType
380 if ((pType < 1) || (pSubType < 1)) {
381#ifdef G4VERBOSE
382 if (verboseLevel > 0) {
383 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
384 << particle->GetParticleName() << " has illegal Process Type = " << pType
385 << " SubType = " << pSubType << G4endl;
386 }
387#endif
388 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0108", FatalException,
389 "No Matching process Type/SubType");
390 return false;
391 }
392
393 G4bool isFound = false;
394 G4int ord[3];
395 G4bool duplicable = false;
396 for (G4int i = 0; i < sizeOfTable; ++i) {
397 G4PhysicsListOrderingParameter* tmp = &(theTable->at(i));
398 if ((tmp->processType == pType) && (tmp->processSubType == pSubType)) {
399 ord[0] = tmp->ordering[0];
400 ord[1] = tmp->ordering[1];
401 ord[2] = tmp->ordering[2];
402 duplicable = tmp->isDuplicable;
403 isFound = true;
404 break;
405 }
406 }
407 if (!isFound) {
408#ifdef G4VERBOSE
409 if (verboseLevel > 0) {
410 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
411 << particle->GetParticleName() << " with type/subtype =" << pType << "/" << pSubType
412 << " is not registered in OrdingParameterTable " << G4endl;
413 }
414#endif
415 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0109", FatalException,
416 "No Matching process Type/SubType");
417 return false;
418 }
419
420 // Check Process Manager
421 G4ProcessManager* pManager = particle->GetProcessManager();
422 if (pManager == nullptr) {
423 // Error !! no process manager
424#ifdef G4VERBOSE
425 if (verboseLevel > 0) {
426 G4cout << "G4PhysicsListHelper::RegisterProcess "
427 << " : No Process Manager for " << particle->GetParticleName() << G4endl;
428 }
429#endif
430 G4Exception("G4PhysicsListHelper::RegisterProcess ", "Riun0110", FatalException,
431 "No process manager");
432 return false;
433 }
434
435 // Check Duplication
436 if (!duplicable) {
437 G4bool duplicated = false;
438 G4ProcessVector* pList = pManager->GetProcessList();
439 for (G4int idx = 0; idx < (G4int)pList->size(); ++idx) {
440 const G4VProcess* p = (*pList)[idx];
441 if ((p->GetProcessType() == pType) && (p->GetProcessSubType() == pSubType)) {
442 duplicated = true;
443#ifdef G4VERBOSE
444 if (verboseLevel > 0) {
445 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
446 << particle->GetParticleName() << " with type/subtype =" << pType << "/"
447 << pSubType << " is has same subType as " << p->GetProcessName() << " for "
448 << particle->GetParticleName() << G4endl;
449 G4cout << "It will not be added !!" << G4endl;
450 }
451#endif
452 G4Exception("G4PhysicsListHelper::RegisterProcess", "Run0111", JustWarning,
453 "Duplication of processes");
454 }
455 }
456 if (duplicated) return false;
457 }
458
459 // Add Process
460 G4int code = pManager->AddProcess(process);
461 if (code < 0) return false;
462
463 // Set Ordering Parameter
464 for (G4int idx = 0; idx < 3; ++idx) {
465 auto idxOrd = static_cast<G4ProcessVectorDoItIndex>(idx);
466 if (ord[idx] < 0) {
467 // Do Nothing because NO DOIT
468 }
469 else if (ord[idx] == 0) {
470 pManager->SetProcessOrderingToFirst(process, idxOrd);
471 }
472 else if (ord[idx] < 9999) {
473 pManager->SetProcessOrdering(process, idxOrd, ord[idx]);
474 }
475 else {
476 pManager->SetProcessOrderingToLast(process, idxOrd);
477 }
478 }
479#ifdef G4VERBOSE
480 if (verboseLevel > 1) {
481 G4cout << "G4PhysicsListHelper::RegisterProcess :" << pName << " for "
482 << particle->GetParticleName() << " with type/subtype =" << pType << "/" << pSubType
483 << " is successfully registered with ordering parameters " << ord[0] << ":" << ord[1]
484 << ":" << ord[2] << G4endl;
485 }
486#endif
487 return true;
488}
@ JustWarning
G4ProcessVectorDoItIndex
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4ProcessType GetProcessType() const
G4int GetProcessSubType() const
const G4String & GetProcessName() const

Referenced by G4HadronicBuilder::BuildElastic(), G4HadronicBuilder::BuildFTFP_INCLXX(), G4HadProcesses::BuildNeutronElastic(), G4HadProcesses::BuildNeutronInelasticAndCapture(), G4EmBuilder::ConstructBasicEmPhysics(), G4EmBuilder::ConstructCharged(), G4EmBuilder::ConstructChargedSS(), G4EmBuilder::ConstructElectronMscProcess(), G4EmBuilder::ConstructElectronSSProcess(), G4EmBuilder::ConstructIonEmPhysics(), G4EmBuilder::ConstructIonEmPhysicsSS(), G4EmBuilder::ConstructLightHadrons(), G4EmBuilder::ConstructLightHadronsSS(), G4DecayPhysics::ConstructProcess(), G4EmDNAChemistry_option1::ConstructProcess(), G4EmDNAChemistry_option3::ConstructProcess(), G4EmExtraPhysics::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(), G4HadronDElasticPhysics::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronHElasticPhysics::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronInelasticQBBC_ABLA::ConstructProcess(), G4HadronPhysicsFTFQGSP_BERT::ConstructProcess(), G4UnknownDecayPhysics::ConstructProcess(), G4EmDNABuilder::ConstructStandardEmPhysics(), G4EmDNABuilder::FindOrBuildAttachment(), G4EmDNABuilder::FindOrBuildChargeDecrease(), G4EmDNABuilder::FindOrBuildChargeIncrease(), G4EmDNABuilder::FindOrBuildElastic(), G4EmDNABuilder::FindOrBuildElectronSolvation(), G4EmDNABuilder::FindOrBuildExcitation(), G4EmDNABuilder::FindOrBuildIonisation(), G4EmDNABuilder::FindOrBuildVibExcitation(), and G4VPhysicsConstructor::RegisterProcess().

◆ SetVerboseLevel()

void G4PhysicsListHelper::SetVerboseLevel ( G4int value)
inline

Definition at line 122 of file G4PhysicsListHelper.hh.

123{
124 verboseLevel = value;
125}

Referenced by G4MuonicAtomDecayPhysics::ConstructProcess().

◆ UseCoupledTransportation()

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

Definition at line 117 of file G4PhysicsListHelper.hh.

118{
119 useCoupledTransportation = vl;
120}

◆ UseHighLooperThresholds()

void G4PhysicsListHelper::UseHighLooperThresholds ( )
inline

Definition at line 69 of file G4PhysicsListHelper.hh.

69{ theLooperThresholds = 2; }

◆ UseLowLooperThresholds()

void G4PhysicsListHelper::UseLowLooperThresholds ( )
inline

Definition at line 70 of file G4PhysicsListHelper.hh.

70{ theLooperThresholds = 0; }

Friends And Related Symbol Documentation

◆ G4ThreadLocalSingleton< G4PhysicsListHelper >

Definition at line 127 of file G4PhysicsListHelper.hh.


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