Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 G4ParallelGeometriesLimiterProcessAddLimiterProcess (G4ProcessManager *pmanager, const G4String &processName="biasLimiter")
 

Detailed Description

Definition at line 52 of file G4BiasingHelper.hh.

Member Function Documentation

◆ ActivateNonPhysicsBiasing()

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,
104 ordDefault);
105}
@ ordInActive
@ ordDefault
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)

Referenced by G4GenericBiasingPhysics::ConstructProcess().

◆ ActivatePhysicsBiasing()

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 (std::size_t 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}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
@ idxPostStep
@ idxAtRest
@ idxAlongStep
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4ProcessVector * GetProcessList() const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
std::size_t size() const

Referenced by G4GenericBiasingPhysics::ConstructProcess().

◆ AddLimiterProcess()

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 (std::size_t 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}
@ JustWarning
bool G4bool
Definition: G4Types.hh:86
const G4String & GetParticleName() const
G4ParticleDefinition * GetParticleType() const
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)

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