Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ImportanceConfigurator.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// ----------------------------------------------------------------------
29// Class G4ImportanceConfigurator
30//
31// Author: Michael Dressel (Michael.Dressel@cern.ch)
32// ----------------------------------------------------------------------
33
35
37#include "G4ProcessPlacer.hh"
39
41#include "G4AutoLock.hh"
42
43#ifdef G4MULTITHREADED
44namespace {
45 G4Mutex BiasConfigMutex = G4MUTEX_INITIALIZER;
46}
47#endif
48
51 const G4String &particlename,
52 G4VIStore &istore,
53 const G4VImportanceAlgorithm *ialg, G4bool para)
54 : fWorld(worldvolume),
55 fWorldName(worldvolume->GetName()),
56 fPlacer(particlename),
57 fIStore(istore),
58 fDeleteIalg( ( ! ialg) ),
59 fIalgorithm(( (fDeleteIalg) ?
60 new G4ImportanceAlgorithm : ialg)),
61 fImportanceProcess(0),
62 paraflag(para)
63{;}
64
66G4ImportanceConfigurator(const G4String &worldvolumeName,
67 const G4String &particlename,
68 G4VIStore &istore,
69 const G4VImportanceAlgorithm *ialg, G4bool para)
70: fWorldName(worldvolumeName),
71 fPlacer(particlename),
72 fIStore(istore),
73 fDeleteIalg( ( ! ialg) ),
74 fIalgorithm(( (fDeleteIalg) ?
75 new G4ImportanceAlgorithm : ialg)),
76 fImportanceProcess(0),
77 paraflag(para)
78{
81}
82
84{
85 if (fImportanceProcess)
86 {
87 fPlacer.RemoveProcess(fImportanceProcess);
88 delete fImportanceProcess;
89 }
90 if (fDeleteIalg)
91 {
92 delete fIalgorithm;
93 }
94}
95
96void
98{
99 G4cout << "G4ImportanceConfigurator:: entering importance configure, paraflag " << paraflag << G4endl;
100 const G4VTrackTerminator *terminator = 0;
101 if (preConf)
102 {
103 terminator = preConf->GetTrackTerminator();
104 };
105
106
107#ifdef G4MULTITHREADED
108 G4AutoLock l(&BiasConfigMutex);
109#endif
110 fImportanceProcess =
111 new G4ImportanceProcess(*fIalgorithm,
112 fIStore,
113 terminator,"ImportanceProcess",paraflag);
114
115 if (!fImportanceProcess)
116 {
117 G4Exception("G4ImportanceConfigurator::Configure()",
118 "FatalError", FatalException,
119 "Failed allocation of G4ImportanceProcess !");
120 }
121
122 // G4cout << "G4ImportanceConfigurator:: setting parallel World " << paraflag << G4endl;
123 if(paraflag) fImportanceProcess->SetParallelWorld(fWorld->GetName());
124#ifdef G4MULTITHREADED
125 l.unlock();
126// G4MUTEXUNLOCK(&G4ImportanceConfigurator::BiasConfigMutex);
127#endif
128 // if(paraflag) fImportanceProcess->SetParallelWorld(fWorldName);
129 // G4cout << "G4ImportanceConfigurator:: set " << paraflag << " name: " << fWorld->GetName() << G4endl;
130 // getchar();
131 fPlacer.AddProcessAsSecondDoIt(fImportanceProcess);
132}
133
135GetTrackTerminator() const
136{
137 return fImportanceProcess;
138}
139
141{
142 G4cout << " G4ImportanceConfigurator:: setting world name: " << name << G4endl;
143 fWorldName = name;
144}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4ImportanceConfigurator(const G4VPhysicalVolume *worldvolume, const G4String &particlename, G4VIStore &istore, const G4VImportanceAlgorithm *ialg, G4bool paraflag)
void SetWorldName(const G4String &Name)
virtual void Configure(G4VSamplerConfigurator *preConf)
virtual const G4VTrackTerminator * GetTrackTerminator() const
void SetParallelWorld(const G4String &parallelWorldName)
G4VPhysicalVolume * GetWorldVolume() const
virtual void AddProcessAsSecondDoIt(G4VProcess *process)
virtual void RemoveProcess(G4VProcess *process)
G4VPhysicalVolume * GetParallelWorld(const G4String &worldName)
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
const G4String & GetName() const
virtual const G4VTrackTerminator * GetTrackTerminator() const =0