Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4BiasingHelper Class Reference

#include <G4BiasingHelper.hh>

Static Public Member Functions

static G4bool ActivatePhysicsBiasing (G4ProcessManager *pmanager, G4String physicsProcessToBias, G4String wrappedName="")
 
static void ActivateNonPhysicsBiasing (G4ProcessManager *pmanager, G4String nonPhysicsProcessName="")
 
static
G4ParallelGeometriesLimiterProcess
AddLimiterProcess (G4ProcessManager *pmanager, const G4String &processName="biasLimiter")
 

Detailed Description

Definition at line 53 of file G4BiasingHelper.hh.

Member Function Documentation

void G4BiasingHelper::ActivateNonPhysicsBiasing ( G4ProcessManager pmanager,
G4String  nonPhysicsProcessName = "" 
)
static

Definition at line 95 of file G4BiasingHelper.cc.

97 {
98  G4BiasingProcessInterface* biasingNonPhys(0);
99  if ( nonPhysicsProcessName == "" ) biasingNonPhys = new G4BiasingProcessInterface();
100  else biasingNonPhys = new G4BiasingProcessInterface(nonPhysicsProcessName );
101  pmanager->AddProcess( biasingNonPhys,
102  ordInActive,
103  ordInActive,
104  ordDefault);
105 }
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4BiasingHelper::ActivatePhysicsBiasing ( G4ProcessManager pmanager,
G4String  physicsProcessToBias,
G4String  wrappedName = "" 
)
static

Definition at line 32 of file G4BiasingHelper.cc.

35 {
36  G4VProcess* physicsProcess(0);
37 
38  G4ProcessVector* vprocess = pmanager->GetProcessList();
39  for (G4int ip = 0 ; ip < vprocess->size() ; ip++)
40  {
41  if ( (*vprocess)[ip]->GetProcessName() == physicsProcessToBias )
42  {
43  physicsProcess = (*vprocess)[ip];
44  break;
45  }
46  }
47 
48  // -- process not found, return "false" to tell about failure
49  if ( physicsProcess == 0 ) return false;
50 
51  // -- process is not a physics one, return "false" to tell about failure
52  G4int processType = physicsProcess->GetProcessType();
53  if ( ( processType != 2 ) && // EM
54  ( processType != 3 ) && // Optical
55  ( processType != 4 ) && // Hadronic
56  ( processType != 6 ) ) // Decay
57  return false;
58 
59  // -- prevent wrapper of wrapper...
60  if ( dynamic_cast< G4BiasingProcessInterface* >( physicsProcess ) ) return false;
61 
62  // -- remember process indeces:
63  G4int atRestIndex = pmanager->GetProcessOrdering(physicsProcess, idxAtRest );
64  G4int alongStepIndex = pmanager->GetProcessOrdering(physicsProcess, idxAlongStep);
65  G4int postStepIndex = pmanager->GetProcessOrdering(physicsProcess, idxPostStep );
66 
67  // -- now remove the physic process, that will be replaced by a wrapped version:
68  G4VProcess* removed = pmanager->RemoveProcess(physicsProcess);
69  if ( removed != physicsProcess )
70  {
72  ed << "Internal inconsistency in processes handling. Please report !" << G4endl;
73  G4Exception("G4BiasingHelper::ActivatePhysicsBiasing(...)",
74  "BIAS.GEN.01",
76  ed);
77  }
78 
79  G4BiasingProcessInterface* biasingWrapper = new G4BiasingProcessInterface( physicsProcess,
80  atRestIndex != ordInActive,
81  alongStepIndex != ordInActive,
82  postStepIndex != ordInActive,
83  wrappedName);
84 
85  if ( alongStepIndex == -1 ) alongStepIndex = ordDefault;
86 
87  pmanager->AddProcess( biasingWrapper,
88  atRestIndex,
89  alongStepIndex,
90  postStepIndex);
91 
92  return true;
93 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
int G4int
Definition: G4Types.hh:78
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int size() const
#define G4endl
Definition: G4ios.hh:61
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4ProcessVector * GetProcessList() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4ParallelGeometriesLimiterProcess * G4BiasingHelper::AddLimiterProcess ( G4ProcessManager pmanager,
const G4String processName = "biasLimiter" 
)
static

Definition at line 107 of file G4BiasingHelper.cc.

108 {
109  G4ParallelGeometriesLimiterProcess* toReturn = nullptr;
110 
111  G4ProcessVector* processList = pmanager->GetProcessList();
112  G4bool noInstance = true;
113  for (G4int i = 0 ; i < processList->size() ; i++)
114  {
115  G4VProcess* process = (*processList)[i];
116  if ( dynamic_cast< G4ParallelGeometriesLimiterProcess* >( process ) )
117  {
118  noInstance = false;
119 
121  ed << "Trying to re-add a G4ParallelGeometriesLimiterProcess process to the process manager for '"<<
122  pmanager->GetParticleType()->GetParticleName() << " (PDG : " << pmanager->GetParticleType()->GetPDGEncoding() << " )"
123  << " while one is already present." << G4endl;
124  G4Exception("G4BiasingHelper::AddBiasingProcessLimiter(G4ProcessManager* pmanager)",
125  "BIAS.GEN.28",
126  JustWarning, ed,
127  "Call ignored.");
128  break;
129  }
130  }
131 
132  if ( noInstance )
133  {
135  pmanager->AddProcess ( biasingLimiter );
136  pmanager->SetProcessOrderingToSecond( biasingLimiter, idxAlongStep );
137  pmanager->SetProcessOrderingToLast ( biasingLimiter, idxPostStep );
138 
139  toReturn = biasingLimiter;
140  }
141 
142  return toReturn;
143 
144 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
bool G4bool
Definition: G4Types.hh:79
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4ParticleDefinition * GetParticleType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int size() const
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
#define G4endl
Definition: G4ios.hh:61
G4ProcessVector * GetProcessList() const

Here is the call graph for this function:


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