Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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

void G4PhysicsListHelper::AddTransportation ( )

Definition at line 207 of file G4PhysicsListHelper.cc.

208 {
209  G4int verboseLevelTransport = 0;
210 
211 #ifdef G4VERBOSE
212  if (verboseLevel >2){
213  G4cout << "G4PhysicsListHelper::AddTransportation() "<< G4endl;
214  }
215 #endif
216 
217  G4int nParaWorld =
219 
220  if ( nParaWorld>0 ||
221  useCoupledTransportation ||
223 #ifdef G4VERBOSE
224  if (verboseLevel >0) {
225  G4cout << " G4PhysicsListHelper::AddTransportation()"
226  << "--- G4CoupledTransportation is used "
227  << G4endl;
228  }
229 #endif
230  theTransportationProcess = new G4CoupledTransportation(verboseLevelTransport);
231  } else {
232  theTransportationProcess = new G4Transportation(verboseLevelTransport);
233  }
234 
235  // loop over all particles in G4ParticleTable
236  aParticleIterator->reset();
237  while( (*aParticleIterator)() ){
238  G4ParticleDefinition* particle = aParticleIterator->value();
239  G4ProcessManager* pmanager = particle->GetProcessManager();
240  // Add transportation process for all particles
241  if ( pmanager == 0) {
242  // Error !! no process manager
243 #ifdef G4VERBOSE
244  if (verboseLevel>0){
245  G4cout << "G4PhysicsListHelper::AddTransportation "
246  <<" : No Process Manager for "
247  << particle->GetParticleName() << G4endl;
248  }
249 #endif
250  G4Exception("G4PhysicsListHelper::AddTransportation",
251  "Run0104", FatalException,
252  "No process manager");
253  continue;
254  }
255  // Molecule use different type transportation
256  if(particle->GetParticleType() == "Molecule") continue;
257 
258  // add transportation with ordering = ( -1, "first", "first" )
259  pmanager ->AddProcess(theTransportationProcess);
260  pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
261  pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
262  }
263 }
G4int GetNumberOfParallelWorld() const
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
int G4int
Definition: G4Types.hh:78
static G4RunManagerKernel * GetRunManagerKernel()
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
void reset(G4bool ifSkipIon=true)
static G4ScoringManager * GetScoringManagerIfExist()
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
const G4String & GetParticleType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ProcessManager * GetProcessManager() const
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void G4PhysicsListHelper::CheckParticleList ( ) const

Definition at line 99 of file G4PhysicsListHelper.cc.

100 {
101  bool isElectron = false;
102  bool isPositron = false;
103  bool isGamma = false;
104  bool isProton = false;
105  bool isGenericIon = false;
106  bool isAnyIon = false;
107  bool isAnyChargedBaryon = false;
108  bool isEmProc = false;
109 
110  // loop over all particles in G4ParticleTable
111  aParticleIterator->reset();
112  while( (*aParticleIterator)() ){
113  G4ParticleDefinition* particle = aParticleIterator->value();
114  G4String name = particle->GetParticleName();
115  // check if any EM process exists
116  if (!isEmProc) {
117  G4ProcessVector* list = particle->GetProcessManager()->GetProcessList();
118  for (int idx=0; idx<list->size(); idx++){
119  isEmProc = ((*list)[idx])->GetProcessType() == fElectromagnetic;
120  if (isEmProc) break;
121  }
122  }
123 
124  if ( name == "e-") isElectron = true;
125  else if ( name == "e+") isPositron = true;
126  else if ( name == "gamma") isGamma = true;
127  else if ( name == "GenericIon") isGenericIon = true;
128  else if ( name == "proton") isProton = true;
129  else if ( particle->GetParticleType() == "nucleus") 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  bool isEmBasic = isElectron || isPositron || isGamma;
141  bool 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: "
151  << missingName << " do not exist " << G4endl;
152  G4cout << " These particle are necessary for basic EM processes"
153  << G4endl;
154  }
155 #endif
156  G4Exception("G4PhysicsListHelper::CheckParticleList",
157  "Run0101", FatalException,
158  "Missing EM basic particle");
159  }
160 
161  // RULE 2
162  // proton should exist
163  // if any other charged baryon exist
164  if (!isProton && isAnyChargedBaryon) {
165  G4String missingName="proton ";
166 
167 #ifdef G4VERBOSE
168  if (verboseLevel >0){
169  G4cout << "G4PhysicsListHelper::CheckParticleList: "
170  << missingName << " does not exist "<< G4endl;
171  G4cout << " Proton is necessary for EM baryon processes" << G4endl;
172  }
173 #endif
174  missingName += " should be created ";
175  G4Exception("G4PhysicsListHelper::CheckParticleList",
176  "Run0102", FatalException,
177  "Missing Proton");
178  }
179 
180  // RULE 3
181  // GenericIonn should exist
182  // if any other ion exist
183  if (!isGenericIon && isAnyIon) {
184  G4String missingName="GenericIon ";
185 
186 #ifdef G4VERBOSE
187  if (verboseLevel >0){
188  G4cout << "G4PhysicsListHelper::CheckParticleList: "
189  << missingName << " does not exist "<< G4endl;
190  G4cout << " GenericIon should be created if any ion is necessary" << G4endl;
191  }
192 #endif
193  G4Exception("G4PhysicsListHelper::CheckParticleList",
194  "Run0103", FatalException,
195  "Missing GenericIon");
196  }
197 
198 }
const XML_Char * name
Definition: expat.h:151
G4bool isElectron(G4int ityp)
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
void reset(G4bool ifSkipIon=true)
const G4String & GetParticleType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int size() const
G4ProcessManager * GetProcessManager() const
#define G4endl
Definition: G4ios.hh:61
G4double GetPDGCharge() const
G4ProcessVector * GetProcessList() const

Here is the call graph for this function:

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

Definition at line 345 of file G4PhysicsListHelper.cc.

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

Here is the caller graph for this function:

G4PhysicsListOrderingParameter G4PhysicsListHelper::GetOrdingParameter ( G4int  subType) const

Definition at line 382 of file G4PhysicsListHelper.cc.

383 {
385 
386  if (theTable==0) {
387 #ifdef G4VERBOSE
388  if (verboseLevel >0) {
389  G4cout << "G4PhysicsListHelper::GetOrderingParameter : "
390  << " No ordering parameter table : " << ordParamFileName
391  << G4endl;
392  }
393 #endif
394  return value;
395  }
396 
397  for (int i=0; i<sizeOfTable ; i++){
398  G4PhysicsListOrderingParameter* tmp=&(theTable->at(i));
399  if (subType == tmp->processSubType){
400  value.processTypeName = tmp->processTypeName;
401  value.processType = tmp->processType;
402  value.processSubType = tmp->processSubType;
403  value.ordering[0] = tmp->ordering[0];
404  value.ordering[1] = tmp->ordering[1];
405  value.ordering[2] = tmp->ordering[2];
406  value.isDuplicable = tmp->isDuplicable;
407  }
408  }
409  return value;
410 }
G4GLOB_DLL std::ostream G4cout
const XML_Char int const XML_Char * value
Definition: expat.h:331
#define G4endl
Definition: G4ios.hh:61
G4PhysicsListHelper * G4PhysicsListHelper::GetPhysicsListHelper ( )
static

Definition at line 89 of file G4PhysicsListHelper.cc.

90 {
91  if (!pPLHelper)
92  {
93  pPLHelper = new G4PhysicsListHelper;
94  }
95  return pPLHelper;
96 }

Here is the caller graph for this function:

G4int G4PhysicsListHelper::GetVerboseLevel ( ) const
inline

Definition at line 132 of file G4PhysicsListHelper.hh.

133 {
134  return verboseLevel;
135 }
G4bool G4PhysicsListHelper::RegisterProcess ( G4VProcess process,
G4ParticleDefinition particle 
)

Definition at line 413 of file G4PhysicsListHelper.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PhysicsListHelper::SetVerboseLevel ( G4int  value)
inline

Definition at line 126 of file G4PhysicsListHelper.hh.

127 {
128  verboseLevel = value;
129 }
const XML_Char int const XML_Char * value
Definition: expat.h:331
void G4PhysicsListHelper::UseCoupledTransportation ( G4bool  vl = true)
inline

Definition at line 120 of file G4PhysicsListHelper.hh.

121 {
122  useCoupledTransportation = vl;
123 }

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