Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4GeometrySampler.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// $Id$
28//
29// ----------------------------------------------------------------------
30// GEANT 4 class source file
31//
32// G4GeometrySampler.cc
33//
34// ----------------------------------------------------------------------
35
36#include "G4GeometrySampler.hh"
37
38#include "G4VIStore.hh"
40//#include "G4VScorer.hh"
41
42#include "G4VPhysicalVolume.hh"
43//#include "G4ScoreConfigurator.hh"
47//#include "G4GCellFinder.hh"
48
50 G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
51 : fParticleName(particlename),
52 fWorld(parallelworld),
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}
64
66{
68}
69
71{
72 if (fImportanceConfigurator)
73 {
74 delete fImportanceConfigurator;
75 fImportanceConfigurator = 0;
76 }
77 if (fWeightWindowConfigurator)
78 {
79 delete fWeightWindowConfigurator;
80 fWeightWindowConfigurator = 0;
81 }
82// if (fScoreConfigurator)
83// {
84// delete fScoreConfigurator;
85// fScoreConfigurator = 0;
86// }
87 if (fWeightCutOffConfigurator)
88 {
89 delete fWeightCutOffConfigurator;
90 fWeightCutOffConfigurator = 0;
91 }
92// if (fGCellFinder)
93// {
94// delete fGCellFinder;
95// fGCellFinder = 0;
96// }
97 fIStore = 0;
98 fConfigurators.clear();
99 fIsConfigured = false;
100}
101
103{
104 G4bool isconf = false;
105 if (fIsConfigured)
106 {
107 G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
108 << " Some initalization exists, use ClearSampling()"
109 << " before a new initialization !" << G4endl;
110 isconf = true;
111 }
112 return isconf;
113}
114
115// void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
116// {
117// G4cout << " preparing scoring configurator " << G4endl;
118// G4cout << G4endl;
119// G4cout << G4endl;
120// G4cout << G4endl;
121// G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
122// G4cout << G4endl;
123// G4cout << G4endl;
124// G4cout << G4endl;
125// fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
126// G4cout << " configured scoring " << G4endl;
127// if (!fScoreConfigurator)
128// {
129// G4Exception("G4GeometrySampler::PrepareScoring()",
130// "FatalError", FatalException,
131// "Failed allocation of G4ScoreConfigurator !");
132// }
133// }
134
135void
137 const G4VImportanceAlgorithm *ialg)
138{
139 G4cout << " preparing importance sampling " << G4endl;
140 fIStore = istore;
141 G4cout << " creating istore " << G4endl;
142
143 fImportanceConfigurator =
144 new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
145
146 G4cout << " creating importance configurator " << G4endl;
147
148 if (!fImportanceConfigurator)
149 {
150 G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
151 "FatalError", FatalException,
152 "Failed allocation of G4ImportanceConfigurator !");
153 }
154}
155
156void
158 G4double wlimit,
159 G4double isource)
160{
161 // fGCellFinder = new G4GCellFinder(fWorld);
162 G4cout << " preparing weight roulette" << G4endl;
163 // fGCellFinder = new G4GCellFinder();
164// if (!fGCellFinder)
165// {
166// G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
167// "FatalError", FatalException,
168// "Failed allocation of G4GCellFinder !");
169// }
170
171 fWeightCutOffConfigurator =
172 new G4WeightCutOffConfigurator(fWorld, fParticleName,
173 wsurvive,
174 wlimit,
175 isource,
176 fIStore,
177 paraflag);
178 //*fGCellFinder, paraflag);
179 if (!fWeightCutOffConfigurator)
180 {
181 G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
182 "FatalError", FatalException,
183 "Failed allocation of G4WeightCutOffConfigurator !");
184 }
185}
186
187void
190 G4PlaceOfAction placeOfAction)
191{
192
193 G4cout << " preparing weight window" << G4endl;
194
195 fWWStore = wwstore;
196
197 fWeightWindowConfigurator =
198 new G4WeightWindowConfigurator(fWorld, fParticleName,
199 *fWWStore,
200 wwAlg,
201 placeOfAction, paraflag);
202}
203
205{
206 G4cout << " entering configure " << G4endl;
207 if (!IsConfigured())
208 {
209 fIsConfigured = true;
210
211// if (fScoreConfigurator)
212// {
213// G4cout << " score configurator push_back " << G4endl;
214// fConfigurators.push_back(fScoreConfigurator);
215// G4cout << " pushed " << G4endl;
216// }
217 if (fImportanceConfigurator)
218 {
219 G4cout << " importance configurator push_back " << G4endl;
220 fConfigurators.push_back(fImportanceConfigurator);
221 G4cout << " pushed " << G4endl;
222 }
223 if (fWeightWindowConfigurator)
224 {
225 G4cout << " weight window configurator push_back " << G4endl;
226 fConfigurators.push_back(fWeightWindowConfigurator);
227 G4cout << " pushed " << G4endl;
228 }
229
230 G4cout << " vsampler configurator loop " << G4endl;
231 G4VSamplerConfigurator *preConf = 0;
232 G4int i = 0;
233 for (G4Configurators::iterator it = fConfigurators.begin();
234 it != fConfigurators.end(); it++)
235 {
236 i++;
237 G4cout << " looping " << i << G4endl;
238 G4VSamplerConfigurator *currConf =*it;
239 G4cout << " sampler configurator " << G4endl;
240 currConf->Configure(preConf);
241 G4cout << " configure preconf " << G4endl;
242 preConf = *it;
243 }
244 if (fWeightCutOffConfigurator)
245 {
246 G4cout << " NEW weight window configure " << G4endl;
247 fWeightCutOffConfigurator->Configure(0);
248 G4cout << " configured " << G4endl;
249 }
250 }
251 return;
252}
253
255{
256 paraflag = para;
257}
258
260{
261 fParticleName = particlename;
262}
263
@ FatalException
G4PlaceOfAction
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void SetParticle(const G4String &particlename)
void SetParallel(G4bool paraflag)
virtual void PrepareWeightRoulett(G4double wsurvive, G4double wlimit, G4double isource)
virtual G4bool IsConfigured() const
virtual void ClearSampling()
virtual void PrepareWeightWindow(G4VWeightWindowStore *wwstore, G4VWeightWindowAlgorithm *wwAlg, G4PlaceOfAction placeOfAction)
virtual void PrepareImportanceSampling(G4VIStore *istore, const G4VImportanceAlgorithm *ialg)
virtual ~G4GeometrySampler()
virtual void Configure()
G4GeometrySampler(G4VPhysicalVolume *worldvolume, const G4String &particlename)
virtual void Configure(G4VSamplerConfigurator *preConf)=0
virtual void Configure(G4VSamplerConfigurator *preConf)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41