Geant4 9.6.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 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 ()
 

Detailed Description

Definition at line 50 of file G4PhysicsListHelper.hh.

Member Function Documentation

◆ AddTransportation()

void G4PhysicsListHelper::AddTransportation ( )

Definition at line 205 of file G4PhysicsListHelper.cc.

206{
207 G4int verboseLevelTransport = 0;
208
209#ifdef G4VERBOSE
210 if (verboseLevel >2){
211 G4cout << "G4PhysicsListHelper::AddTransportation() "<< G4endl;
212 }
213#endif
214
215 G4int nParaWorld =
217
218 if ( nParaWorld>0 ||
219 useCoupledTransportation ||
221#ifdef G4VERBOSE
222 if (verboseLevel >0) {
223 G4cout << " G4PhysicsListHelper::AddTransportation()"
224 << "--- G4CoupledTransportation is used "
225 << G4endl;
226 }
227#endif
228 theTransportationProcess = new G4CoupledTransportation(verboseLevelTransport);
229 } else {
230 theTransportationProcess = new G4Transportation(verboseLevelTransport);
231 }
232
233 // loop over all particles in G4ParticleTable
234 theParticleIterator->reset();
235 while( (*theParticleIterator)() ){
236 G4ParticleDefinition* particle = theParticleIterator->value();
237 G4ProcessManager* pmanager = particle->GetProcessManager();
238 // Add transportation process for all particles
239 if ( pmanager == 0) {
240 // Error !! no process manager
241#ifdef G4VERBOSE
242 if (verboseLevel>0){
243 G4cout << "G4PhysicsListHelper::AddTransportation "
244 <<" : No Process Manager for "
245 << particle->GetParticleName() << G4endl;
246 }
247#endif
248 G4Exception("G4PhysicsListHelper::AddTransportation",
249 "Run0104", FatalException,
250 "No process manager");
251 continue;
252 }
253 // add transportation with ordering = ( -1, "first", "first" )
254 pmanager ->AddProcess(theTransportationProcess);
255 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
256 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
257 }
258}
@ FatalException
@ idxPostStep
@ idxAlongStep
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
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()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4VUserPhysicsList::AddTransportation().

◆ CheckParticleList()

void G4PhysicsListHelper::CheckParticleList ( ) const

Definition at line 97 of file G4PhysicsListHelper.cc.

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

Referenced by G4VUserPhysicsList::CheckParticleList().

◆ DumpOrdingParameterTable()

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

Definition at line 340 of file G4PhysicsListHelper.cc.

341{
342 if (theTable==0) {
343#ifdef G4VERBOSE
344 if (verboseLevel >0) {
345 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable "
346 << " No ordering parameter table : " << ordParamFileName
347 << G4endl;
348 }
349#endif
350 return;
351 }
352 G4cout << "G4PhysicsListHelper::DumpOrdingParameterTable : "
353 << ordParamFileName << G4endl;
354 G4cout << " TypeName "
355 << " ProcessType" << " SubType"
356 << " AtRest" << " AlongStep" << " PostStep"
357 << " Duplicable" << G4endl;
358 for (int i=0; i<sizeOfTable ; i++){
359 G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
360 if ((subType>=0) && (subType!=tmp->processSubType)) continue;
361 G4cout << std::setw(18) << tmp->processTypeName
362 << std::setw(15) << tmp->processType
363 << std::setw(15) << tmp->processSubType
364 << std::setw(15) << tmp->ordering[0]
365 << std::setw(15) << tmp->ordering[1]
366 << std::setw(15) << tmp->ordering[2];
367 if (tmp->isDuplicable) {
368 G4cout << " true";
369 } else {
370 G4cout << " false";
371 }
372 G4cout <<G4endl;
373 }
374}

Referenced by G4UserPhysicsListMessenger::SetNewValue().

◆ GetOrdingParameter()

G4PhysicsListOrderingParameter G4PhysicsListHelper::GetOrdingParameter ( G4int  subType) const

Definition at line 377 of file G4PhysicsListHelper.cc.

378{
380
381 if (theTable==0) {
382#ifdef G4VERBOSE
383 if (verboseLevel >0) {
384 G4cout << "G4PhysicsListHelper::GetOrderingParameter : "
385 << " No ordering parameter table : " << ordParamFileName
386 << G4endl;
387 }
388#endif
389 return value;
390 }
391
392 for (int i=0; i<sizeOfTable ; i++){
393 G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
394 if (subType == tmp->processSubType){
395 value.processTypeName = tmp->processTypeName;
396 value.processType = tmp->processType;
397 value.processSubType = tmp->processSubType;
398 value.ordering[0] = tmp->ordering[0];
399 value.ordering[1] = tmp->ordering[1];
400 value.ordering[2] = tmp->ordering[2];
401 value.isDuplicable = tmp->isDuplicable;
402 }
403 }
404 return value;
405}

◆ GetPhysicsListHelper()

◆ GetVerboseLevel()

G4int G4PhysicsListHelper::GetVerboseLevel ( ) const
inline

Definition at line 132 of file G4PhysicsListHelper.hh.

133{
134 return verboseLevel;
135}

◆ RegisterProcess()

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

Definition at line 408 of file G4PhysicsListHelper.cc.

410{
411 if (theTable==0) {
412#ifdef G4VERBOSE
413 if (verboseLevel >0) {
414 G4cout << "G4PhysicsListHelper::RegisterProcess :"
415 << " No ordering parameter table : " << ordParamFileName
416 << G4endl;
417 }
418#endif
419 G4Exception("G4PhysicsListHelper::RegisterPorcess",
420 "Run0107", FatalException,
421 "No Ordering Parameter Table");
422 return false;
423 }
424
425 const G4String pName = process->GetProcessName();
426 const G4int pType = process->GetProcessType();
427 const G4int pSubType = process->GetProcessSubType();
428
429#ifdef G4VERBOSE
430 if (verboseLevel >2) {
431 G4cout << "G4PhysicsListHelper::RegisterProcess :"
432 << pName << " Process Type = " << pType
433 << " SubType = "<< pSubType
434 << " to " << particle->GetParticleName()
435 << G4endl;
436 }
437#endif
438
439 // Check Process Type/SubType
440 if ((pType <1)||(pSubType<1)) {
441#ifdef G4VERBOSE
442 if (verboseLevel >0) {
443 G4cout << "G4PhysicsListHelper::RegisterProcess :"
444 << pName << " for " << particle->GetParticleName()
445 << " has illegal Process Type = " << pType
446 << " SubType = "<< pSubType << G4endl;
447 }
448#endif
449 G4Exception("G4PhysicsListHelper::RegisterPorcess",
450 "Run0108", FatalException,
451 "No Matching process Type/SubType");
452 return false;
453 }
454
455 G4bool isFound = false;
456 G4int ord[3];
457 G4bool duplicable = false;
458 for (int i=0; i<sizeOfTable ; i++){
459 G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
460 if ((tmp->processType==pType)&&(tmp->processSubType==pSubType)){
461 ord[0] = tmp->ordering[0];
462 ord[1] = tmp->ordering[1];
463 ord[2] = tmp->ordering[2];
464 duplicable = tmp->isDuplicable;
465 isFound = true;
466 break;
467 }
468 }
469 if (!isFound) {
470#ifdef G4VERBOSE
471 if (verboseLevel >0) {
472 G4cout << "G4PhysicsListHelper::RegisterProcess :"
473 << pName << " for " << particle->GetParticleName()
474 << " with type/subtype ="
475 << pType << "/" << pSubType
476 << " is not reigstered in OrdingParameterTable "
477 << G4endl;
478 }
479#endif
480 G4Exception("G4PhysicsListHelper::RegisterPorcess",
481 "Run0109", FatalException,
482 "No Matching process Type/SubType");
483 return false;
484 }
485
486 // Check Process Manager
487 G4ProcessManager* pManager = particle->GetProcessManager();
488 if ( pManager == 0) {
489 // Error !! no process manager
490#ifdef G4VERBOSE
491 if (verboseLevel>0){
492 G4cout << "G4PhysicsListHelper::RegisterProcess "
493 <<" : No Process Manager for "
494 << particle->GetParticleName() << G4endl;
495 }
496#endif
497 G4Exception("G4PhysicsListHelper::RegisterProcess ",
498 "Riun0110", FatalException,
499 "No process manager");
500 return false;
501 }
502
503 // Check Duplication
504 if (!duplicable){
505 G4bool duplicated = false;
506 G4ProcessVector* pList = pManager->GetProcessList();
507 for (G4int idx=0; idx<pList->size(); idx++) {
508 const G4VProcess* p = (*pList)[idx];
509 if ((p->GetProcessType()== pType) &&
510 (p->GetProcessSubType()== pSubType)){
511 duplicated = true;
512#ifdef G4VERBOSE
513 if (verboseLevel >0) {
514 G4cout << "G4PhysicsListHelper::RegisterProcess :"
515 << pName << " for " << particle->GetParticleName()
516 << " with type/subtype ="
517 << pType << "/" << pSubType
518 << " is has same subType as "
519 << p->GetProcessName()
520 << " for " << particle->GetParticleName()
521 << G4endl;
522 G4cout << "It will not be added !!" << G4endl;
523 }
524#endif
525 G4Exception("G4PhysicsListHelper::RegisterPorcess",
526 "Run0111", JustWarning,
527 "Duplication of processes");
528 }
529 }
530 if (duplicated) return false;
531 }
532
533 // Add Process
534 G4int code = pManager ->AddProcess(process);
535 if (code <0) return false;
536
537 // Set Ordering Parameter
538 for(G4int idx=0; idx<3; idx++){
539 G4ProcessVectorDoItIndex idxOrd = static_cast<G4ProcessVectorDoItIndex>(idx);
540 if (ord[idx]<0) {
541 // Do Nothing because NO DOIT
542 } else if (ord[idx]==0) {
543 pManager->SetProcessOrderingToFirst( process, idxOrd );
544 } else if (ord[idx]<9999) {
545 pManager->SetProcessOrdering( process, idxOrd , ord[idx]);
546 } else {
547 pManager->SetProcessOrderingToLast( process, idxOrd );
548 }
549 }
550#ifdef G4VERBOSE
551 if (verboseLevel >1) {
552 G4cout << "G4PhysicsListHelper::RegisterProcess :"
553 << pName << " for " << particle->GetParticleName()
554 << " with type/subtype ="
555 << pType << "/" << pSubType
556 << " is sucessfully registered with ordering parameters "
557 << ord[0] << ":" << ord[1] << ":" << ord[2]
558 << G4endl;
559 }
560#endif
561 return true;
562}
@ JustWarning
G4ProcessVectorDoItIndex
bool G4bool
Definition: G4Types.hh:67
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:385
G4int GetProcessSubType() const
Definition: G4VProcess.hh:397
const G4String & GetProcessName() const
Definition: G4VProcess.hh:379

Referenced by G4DecayPhysics::ConstructProcess(), G4EmDNAPhysics::ConstructProcess(), G4EmDNAPhysicsChemistry::ConstructProcess(), G4EmLivermorePhysics::ConstructProcess(), G4EmLivermorePolarizedPhysics::ConstructProcess(), G4EmLowEPPhysics::ConstructProcess(), G4EmPenelopePhysics::ConstructProcess(), G4EmStandardPhysics::ConstructProcess(), G4EmStandardPhysics_option1::ConstructProcess(), G4EmStandardPhysics_option2::ConstructProcess(), G4EmStandardPhysics_option3::ConstructProcess(), G4EmStandardPhysics_option4::ConstructProcess(), G4VPhysicsConstructor::RegisterProcess(), and G4VUserPhysicsList::RegisterProcess().

◆ SetVerboseLevel()

void G4PhysicsListHelper::SetVerboseLevel ( G4int  value)
inline

Definition at line 126 of file G4PhysicsListHelper.hh.

127{
128 verboseLevel = value;
129}

Referenced by G4VUserPhysicsList::G4VUserPhysicsList(), and G4VUserPhysicsList::SetVerboseLevel().

◆ UseCoupledTransportation()

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

Definition at line 120 of file G4PhysicsListHelper.hh.

121{
122 useCoupledTransportation = vl;
123}

Referenced by G4VUserPhysicsList::UseCoupledTransportation().


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