ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GeometrySampler.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GeometrySampler.cc
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 // GEANT 4 class source file
30 //
31 // G4GeometrySampler.cc
32 //
33 // ----------------------------------------------------------------------
34 
35 #include "G4GeometrySampler.hh"
36 
37 #include "G4VIStore.hh"
38 #include "G4WeightWindowStore.hh"
39 //#include "G4VScorer.hh"
40 
41 #include "G4VPhysicalVolume.hh"
42 //#include "G4ScoreConfigurator.hh"
46 //#include "G4GCellFinder.hh"
48 
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 }
67 
69  G4GeometrySampler(G4String worldName, const G4String &particlename)
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 }
87 
89 {
90  // ClearSampling();
91 }
92 
94 {
96  {
99  }
101  {
104  }
105 // if (fScoreConfigurator)
106 // {
107 // delete fScoreConfigurator;
108 // fScoreConfigurator = 0;
109 // }
111  {
114  }
115 // if (fGCellFinder)
116 // {
117 // delete fGCellFinder;
118 // fGCellFinder = 0;
119 // }
120  fIStore = 0;
121  fConfigurators.clear();
122  fIsConfigured = false;
123 }
124 
126 {
127  G4bool isconf = false;
128  if (fIsConfigured)
129  {
130  G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
131  << " Some initalization exists, use ClearSampling()"
132  << " before a new initialization !" << G4endl;
133  isconf = true;
134  }
135  return isconf;
136 }
137 
138 // void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
139 // {
140 // G4cout << " preparing scoring configurator " << G4endl;
141 // G4cout << G4endl;
142 // G4cout << G4endl;
143 // G4cout << G4endl;
144 // G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
145 // G4cout << G4endl;
146 // G4cout << G4endl;
147 // G4cout << G4endl;
148 // fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
149 // G4cout << " configured scoring " << G4endl;
150 // if (!fScoreConfigurator)
151 // {
152 // G4Exception("G4GeometrySampler::PrepareScoring()",
153 // "FatalError", FatalException,
154 // "Failed allocation of G4ScoreConfigurator !");
155 // }
156 // }
157 
158 void
160  const G4VImportanceAlgorithm *ialg)
161 {
162  G4cout << "G4GeometrySampler:: preparing importance sampling WorldName is " << fWorldName << G4endl;
163  fIStore = istore;
164  // G4cout << "G4GeometrySampler:: creating istore, worldVolume: " << fWorld->GetName() << G4endl;
165 
168  // new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
170 
172  {
173  G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
174  "FatalError", FatalException,
175  "Failed allocation of G4ImportanceConfigurator !");
176  }
177 }
178 
179 void
181  G4double wlimit,
182  G4double isource)
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 
196  wsurvive,
197  wlimit,
198  isource,
199  fIStore,
200  paraflag);
201  //*fGCellFinder, paraflag);
203  {
204  G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
205  "FatalError", FatalException,
206  "Failed allocation of G4WeightCutOffConfigurator !");
207  }
208 }
209 
210 void
213  G4PlaceOfAction placeOfAction)
214 {
215 
216  G4cout << "G4GeometrySampler:: preparing weight window" << G4endl;
217 
218  fWWStore = wwstore;
219 
222  *fWWStore,
223  wwAlg,
224  placeOfAction, paraflag);
225 
226  // fWeightWindowConfigurator =
227  // new G4WeightWindowConfigurator(fWorld, fParticleName,
228  // *fWWStore,
229  // wwAlg,
230  // placeOfAction, paraflag);
231 
232 }
233 
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 // }
247  {
249  }
251  {
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 }
285 
287 {
288 
289  G4VSamplerConfigurator *preConf = 0;
290  G4int i = 0;
291  for (G4Configurators::iterator it = fConfigurators.begin();
292  it != fConfigurators.end(); it++)
293  {
294  i++;
295  G4VSamplerConfigurator *currConf =*it;
296  currConf->Configure(preConf);
297  preConf = *it;
298  }
300  {
302  }
303 
304  return;
305 }
306 
308 {
309  paraflag = para;
310 }
311 
313 {
314  fWorld = World;
315 }
316 
317 void G4GeometrySampler::SetParticle(const G4String &particlename)
318 {
319  fParticleName = particlename;
320 }
321