Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeometrySampler Class Reference

#include <G4GeometrySampler.hh>

+ Inheritance diagram for G4GeometrySampler:

Public Member Functions

 G4GeometrySampler (G4VPhysicalVolume *worldvolume, const G4String &particlename)
 
 G4GeometrySampler (G4String worldvolumeName, const G4String &particlename)
 
virtual ~G4GeometrySampler ()
 
virtual void PrepareImportanceSampling (G4VIStore *istore, const G4VImportanceAlgorithm *ialg)
 
virtual void PrepareWeightRoulett (G4double wsurvive, G4double wlimit, G4double isource)
 
virtual void PrepareWeightWindow (G4VWeightWindowStore *wwstore, G4VWeightWindowAlgorithm *wwAlg, G4PlaceOfAction placeOfAction)
 
virtual void Configure ()
 
virtual void AddProcess ()
 
virtual void ClearSampling ()
 
virtual G4bool IsConfigured () const
 
void SetParallel (G4bool paraflag)
 
void SetWorld (const G4VPhysicalVolume *world)
 
void SetParticle (const G4String &particlename)
 
G4String GetParticleName ()
 
- Public Member Functions inherited from G4VSampler
 G4VSampler ()
 
virtual ~G4VSampler ()
 
virtual void PrepareImportanceSampling (G4VIStore *istore, const G4VImportanceAlgorithm *ialg=0)=0
 
virtual void PrepareWeightRoulett (G4double wsurvive=0.5, G4double wlimit=0.25, G4double isource=1)=0
 
virtual void PrepareWeightWindow (G4VWeightWindowStore *wwstore, G4VWeightWindowAlgorithm *wwAlg=0, G4PlaceOfAction placeOfAction=onBoundary)=0
 
virtual void Configure ()=0
 
virtual void ClearSampling ()=0
 
virtual G4bool IsConfigured () const =0
 
virtual void SetParallel (G4bool paraflag)=0
 

Detailed Description

Definition at line 52 of file G4GeometrySampler.hh.

Constructor & Destructor Documentation

◆ G4GeometrySampler() [1/2]

G4GeometrySampler::G4GeometrySampler ( G4VPhysicalVolume worldvolume,
const G4String particlename 
)
explicit

Definition at line 49 of file G4GeometrySampler.cc.

51 : fParticleName(particlename),
52 fWorld(world),
53 fImportanceConfigurator(0),
54 // fScoreConfigurator(0),
55 // fGCellFinder(0),
56 fWeightCutOffConfigurator(0),
57 fIStore(0),
58 fWeightWindowConfigurator(0),
59 fWWStore(0),
60 fIsConfigured(false)
61{
62 paraflag = false;
63 // fWorldName = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetName();
64 // if(fWorld == G4TransportationManager::GetTransportationManager()->GetParallelWorld(fWorld->GetName())) paraflag = true;
65 // G4cout << "G4GeometrySampler:: Making geometry sampler with world: " << fWorld->GetName() << G4endl;
66}

◆ G4GeometrySampler() [2/2]

G4GeometrySampler::G4GeometrySampler ( G4String  worldvolumeName,
const G4String particlename 
)
explicit

Definition at line 68 of file G4GeometrySampler.cc.

70 : fParticleName(particlename),
71 fWorldName(worldName),
72 fImportanceConfigurator(0),
73 // fScoreConfigurator(0),
74 // fGCellFinder(0),
75 fWeightCutOffConfigurator(0),
76 fIStore(0),
77 fWeightWindowConfigurator(0),
78 fWWStore(0),
79 fIsConfigured(false)
80{
81 paraflag = false;
83 // fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
84 // G4cout << "G4GeometrySampler:: Making geometry sampler with world: " << fWorld->GetName() << G4endl;
85 //G4TransportationManager::GetTransportationManager()->GetParallelWorld(parallelworldName)
86}
G4VPhysicalVolume * GetWorldVolume() const
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const

◆ ~G4GeometrySampler()

G4GeometrySampler::~G4GeometrySampler ( )
virtual

Definition at line 88 of file G4GeometrySampler.cc.

89{
90 // ClearSampling();
91}

Member Function Documentation

◆ AddProcess()

void G4GeometrySampler::AddProcess ( )
virtual

Definition at line 286 of file G4GeometrySampler.cc.

287{
288
289 G4VSamplerConfigurator *preConf = nullptr;
290 for (auto it = fConfigurators.cbegin();
291 it != fConfigurators.cend(); ++it)
292 {
293 G4VSamplerConfigurator *currConf =*it;
294 currConf->Configure(preConf);
295 preConf = *it;
296 }
297 if (fWeightCutOffConfigurator != nullptr)
298 {
299 fWeightCutOffConfigurator->Configure(nullptr);
300 }
301
302 return;
303}
virtual void Configure(G4VSamplerConfigurator *preConf)=0
virtual void Configure(G4VSamplerConfigurator *preConf)

Referenced by Configure(), G4ImportanceBiasing::ConstructProcess(), and G4WeightWindowBiasing::ConstructProcess().

◆ ClearSampling()

void G4GeometrySampler::ClearSampling ( )
virtual

Implements G4VSampler.

Definition at line 93 of file G4GeometrySampler.cc.

94{
95 if (fImportanceConfigurator)
96 {
97 delete fImportanceConfigurator;
98 fImportanceConfigurator = 0;
99 }
100 if (fWeightWindowConfigurator)
101 {
102 delete fWeightWindowConfigurator;
103 fWeightWindowConfigurator = 0;
104 }
105// if (fScoreConfigurator)
106// {
107// delete fScoreConfigurator;
108// fScoreConfigurator = 0;
109// }
110 if (fWeightCutOffConfigurator)
111 {
112 delete fWeightCutOffConfigurator;
113 fWeightCutOffConfigurator = 0;
114 }
115// if (fGCellFinder)
116// {
117// delete fGCellFinder;
118// fGCellFinder = 0;
119// }
120 fIStore = 0;
121 fConfigurators.clear();
122 fIsConfigured = false;
123}

◆ Configure()

void G4GeometrySampler::Configure ( )
virtual

Implements G4VSampler.

Definition at line 234 of file G4GeometrySampler.cc.

235{
236 if (!IsConfigured())
237 {
238 fIsConfigured = true;
239
240// if (fScoreConfigurator)
241// {
242// G4cout << " score configurator push_back " << G4endl;
243// fConfigurators.push_back(fScoreConfigurator);
244// G4cout << " pushed " << G4endl;
245// }
246 if (fImportanceConfigurator)
247 {
248 fConfigurators.push_back(fImportanceConfigurator);
249 }
250 if (fWeightWindowConfigurator)
251 {
252 fConfigurators.push_back(fWeightWindowConfigurator);
253 }
254
255 // G4cout << " vsampler configurator loop " << G4endl;
256 // G4VSamplerConfigurator *preConf = 0;
257 // G4int i = 0;
258 // for (G4Configurators::iterator it = fConfigurators.begin();
259 // it != fConfigurators.end(); it++)
260 // {
261 // i++;
262 // G4cout << " looping " << i << G4endl;
263 // G4VSamplerConfigurator *currConf =*it;
264 // G4cout << " sampler configurator " << G4endl;
265 // currConf->Configure(preConf);
266 // G4cout << " configure preconf " << G4endl;
267 // preConf = *it;
268 // }
269 // if (fWeightCutOffConfigurator)
270 // {
271 // G4cout << " NEW weight window configure " << G4endl;
272 // fWeightCutOffConfigurator->Configure(0);
273 // G4cout << " configured " << G4endl;
274 // }
275 }
276
277#ifdef G4MULTITHREADED
278 G4cout << " make sure AddProcess() is invoked for biasing!!! " << G4endl;
279#else
280 AddProcess();
281#endif
282
283 return;
284}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
virtual G4bool IsConfigured() const
virtual void AddProcess()

Referenced by G4ImportanceBiasing::ConstructProcess(), and G4WeightWindowBiasing::ConstructProcess().

◆ GetParticleName()

G4String G4GeometrySampler::GetParticleName ( )
inline

Definition at line 83 of file G4GeometrySampler.hh.

83{return fParticleName;};

◆ IsConfigured()

G4bool G4GeometrySampler::IsConfigured ( ) const
virtual

Implements G4VSampler.

Definition at line 125 of file G4GeometrySampler.cc.

126{
127 G4bool isconf = false;
128 if (fIsConfigured)
129 {
130 G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
131 << " Some initialization exists, use ClearSampling()"
132 << " before a new initialization !" << G4endl;
133 isconf = true;
134 }
135 return isconf;
136}
bool G4bool
Definition: G4Types.hh:86

Referenced by Configure().

◆ PrepareImportanceSampling()

void G4GeometrySampler::PrepareImportanceSampling ( G4VIStore istore,
const G4VImportanceAlgorithm ialg 
)
virtual

Implements G4VSampler.

Definition at line 159 of file G4GeometrySampler.cc.

161{
162 G4cout << "G4GeometrySampler:: preparing importance sampling WorldName is " << fWorldName << G4endl;
163 fIStore = istore;
164 // G4cout << "G4GeometrySampler:: creating istore, worldVolume: " << fWorld->GetName() << G4endl;
165
166 fImportanceConfigurator =
167 new G4ImportanceConfigurator(&istore->GetWorldVolume(), fParticleName, *fIStore, ialg, paraflag);
168 // new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
169 fImportanceConfigurator->SetWorldName(fWorldName);
170
171 if (!fImportanceConfigurator)
172 {
173 G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
174 "FatalError", FatalException,
175 "Failed allocation of G4ImportanceConfigurator !");
176 }
177}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
void SetWorldName(const G4String &Name)
virtual const G4VPhysicalVolume & GetWorldVolume() const =0

Referenced by G4ImportanceBiasing::ConstructProcess().

◆ PrepareWeightRoulett()

void G4GeometrySampler::PrepareWeightRoulett ( G4double  wsurvive,
G4double  wlimit,
G4double  isource 
)
virtual

Implements G4VSampler.

Definition at line 180 of file G4GeometrySampler.cc.

183{
184 // fGCellFinder = new G4GCellFinder(fWorld);
185 G4cout << "G4GeometrySampler:: preparing weight roulette" << G4endl;
186 // fGCellFinder = new G4GCellFinder();
187// if (!fGCellFinder)
188// {
189// G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
190// "FatalError", FatalException,
191// "Failed allocation of G4GCellFinder !");
192// }
193
194 fWeightCutOffConfigurator =
195 new G4WeightCutOffConfigurator(fWorld, fParticleName,
196 wsurvive,
197 wlimit,
198 isource,
199 fIStore,
200 paraflag);
201 //*fGCellFinder, paraflag);
202 if (!fWeightCutOffConfigurator)
203 {
204 G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
205 "FatalError", FatalException,
206 "Failed allocation of G4WeightCutOffConfigurator !");
207 }
208}

◆ PrepareWeightWindow()

void G4GeometrySampler::PrepareWeightWindow ( G4VWeightWindowStore wwstore,
G4VWeightWindowAlgorithm wwAlg,
G4PlaceOfAction  placeOfAction 
)
virtual

Implements G4VSampler.

Definition at line 211 of file G4GeometrySampler.cc.

214{
215
216 G4cout << "G4GeometrySampler:: preparing weight window" << G4endl;
217
218 fWWStore = wwstore;
219
220 fWeightWindowConfigurator =
221 new G4WeightWindowConfigurator(&wwstore->GetWorldVolume(), fParticleName,
222 *fWWStore,
223 wwAlg,
224 placeOfAction, paraflag);
225
226 // fWeightWindowConfigurator =
227 // new G4WeightWindowConfigurator(fWorld, fParticleName,
228 // *fWWStore,
229 // wwAlg,
230 // placeOfAction, paraflag);
231
232}
virtual const G4VPhysicalVolume & GetWorldVolume() const =0

Referenced by G4WeightWindowBiasing::ConstructProcess().

◆ SetParallel()

void G4GeometrySampler::SetParallel ( G4bool  paraflag)
virtual

Implements G4VSampler.

Definition at line 305 of file G4GeometrySampler.cc.

306{
307 paraflag = para;
308}

Referenced by G4ImportanceBiasing::ConstructProcess(), and G4WeightWindowBiasing::ConstructProcess().

◆ SetParticle()

void G4GeometrySampler::SetParticle ( const G4String particlename)

Definition at line 315 of file G4GeometrySampler.cc.

316{
317 fParticleName = particlename;
318}

◆ SetWorld()

void G4GeometrySampler::SetWorld ( const G4VPhysicalVolume world)

Definition at line 310 of file G4GeometrySampler.cc.

311{
312 fWorld = World;
313}

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