source: trunk/source/processes/biasing/src/G4GeometrySampler.cc @ 1253

Last change on this file since 1253 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

File size: 8.2 KB
Line 
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: G4GeometrySampler.cc,v 1.10 2008/04/21 09:10:28 ahoward Exp $
28// GEANT4 tag $Name: geant4-09-03 $
29//
30// ----------------------------------------------------------------------
31// GEANT 4 class source file
32//
33// G4GeometrySampler.cc
34//
35// ----------------------------------------------------------------------
36
37#include "G4GeometrySampler.hh"
38
39#include "G4VIStore.hh"
40#include "G4WeightWindowStore.hh"
41//#include "G4VScorer.hh"
42
43#include "G4VPhysicalVolume.hh"
44//#include "G4ScoreConfigurator.hh"
45#include "G4ImportanceConfigurator.hh"
46#include "G4WeightWindowConfigurator.hh"
47#include "G4WeightCutOffConfigurator.hh"
48//#include "G4GCellFinder.hh"
49
50 G4GeometrySampler::
51 G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
52  : fParticleName(particlename),
53    fWorld(parallelworld),
54    fImportanceConfigurator(0),
55    //    fScoreConfigurator(0),
56    //    fGCellFinder(0),
57    fWeightCutOffConfigurator(0),
58    fIStore(0),
59    fWeightWindowConfigurator(0),
60    fWWStore(0),
61    fIsConfigured(false)
62{
63  paraflag = false;
64}
65
66G4GeometrySampler::~G4GeometrySampler()
67{
68  ClearSampling();
69}
70
71void G4GeometrySampler::ClearSampling()
72{
73  if (fImportanceConfigurator)
74  {
75    delete fImportanceConfigurator;
76    fImportanceConfigurator = 0;
77  }
78  if (fWeightWindowConfigurator)
79  {
80    delete fWeightWindowConfigurator;
81    fWeightWindowConfigurator = 0;
82  }
83//   if (fScoreConfigurator)
84//   {
85//     delete fScoreConfigurator;
86//     fScoreConfigurator = 0;
87//   }
88  if (fWeightCutOffConfigurator)
89  {
90    delete fWeightCutOffConfigurator;
91    fWeightCutOffConfigurator = 0;
92  }
93//   if (fGCellFinder)
94//   {
95//     delete fGCellFinder;
96//     fGCellFinder = 0;
97//   }
98  fIStore = 0;
99  fConfigurators.clear();
100  fIsConfigured = false;
101}
102
103G4bool G4GeometrySampler::IsConfigured() const
104{
105  G4bool isconf = false;
106  if (fIsConfigured)
107  {
108   G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
109          << "          Some initalization exists, use ClearSampling()"
110          << "          before a new initialization !" << G4endl;
111   isconf = true;
112  }
113  return isconf;
114}
115
116// void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
117// {
118//   G4cout << " preparing scoring configurator " << G4endl;
119//   G4cout << G4endl;
120//   G4cout << G4endl;
121//   G4cout << G4endl;
122//   G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
123//   G4cout << G4endl;
124//   G4cout << G4endl;
125//   G4cout << G4endl;
126//   fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
127//   G4cout << " configured scoring " << G4endl;
128//   if (!fScoreConfigurator)
129//   {
130//     G4Exception("G4GeometrySampler::PrepareScoring()",
131//                 "FatalError", FatalException,
132//                 "Failed allocation of G4ScoreConfigurator !");
133//   }
134// }
135
136void
137G4GeometrySampler::PrepareImportanceSampling(G4VIStore *istore,
138                                           const G4VImportanceAlgorithm  *ialg)
139{
140  G4cout << " preparing importance sampling " << G4endl;
141  fIStore = istore;
142  G4cout << " creating istore " << G4endl;
143
144  fImportanceConfigurator =
145    new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
146
147  G4cout << " creating importance configurator " << G4endl;
148
149  if (!fImportanceConfigurator)
150  {
151    G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
152                "FatalError", FatalException,
153                "Failed allocation of G4ImportanceConfigurator !");
154  }
155}
156
157void
158G4GeometrySampler::PrepareWeightRoulett(G4double wsurvive, 
159                                            G4double wlimit,
160                                            G4double isource)
161{
162  //  fGCellFinder = new G4GCellFinder(fWorld);
163  G4cout << " preparing weight roulette" << G4endl;
164  //  fGCellFinder = new G4GCellFinder();
165//   if (!fGCellFinder)
166//   {
167//     G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
168//                 "FatalError", FatalException,
169//                 "Failed allocation of G4GCellFinder !");
170//   }
171 
172  fWeightCutOffConfigurator = 
173    new G4WeightCutOffConfigurator(fWorld, fParticleName,
174                                   wsurvive,
175                                   wlimit,
176                                   isource,
177                                   fIStore,
178                                   paraflag);
179                                   //*fGCellFinder, paraflag);
180  if (!fWeightCutOffConfigurator)
181  {
182    G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
183                "FatalError", FatalException,
184                "Failed allocation of G4WeightCutOffConfigurator !");
185  }
186}
187
188void
189G4GeometrySampler::PrepareWeightWindow(G4VWeightWindowStore *wwstore,
190                                           G4VWeightWindowAlgorithm *wwAlg,
191                                           G4PlaceOfAction placeOfAction)
192{
193
194  G4cout << " preparing weight window" << G4endl;
195
196  fWWStore = wwstore;
197 
198  fWeightWindowConfigurator =
199    new G4WeightWindowConfigurator(fWorld, fParticleName,
200                                    *fWWStore,
201                                    wwAlg,
202                                    placeOfAction, paraflag);
203}
204
205void G4GeometrySampler::Configure()
206{
207  G4cout << " entering configure " << G4endl;
208  if (!IsConfigured())
209  {
210    fIsConfigured = true;
211
212//     if (fScoreConfigurator)
213//     {
214//       G4cout << " score configurator push_back " << G4endl;
215//       fConfigurators.push_back(fScoreConfigurator);
216//       G4cout << " pushed " << G4endl;
217//     }
218    if (fImportanceConfigurator)
219    {
220      G4cout << " importance configurator push_back " << G4endl;
221      fConfigurators.push_back(fImportanceConfigurator);
222      G4cout << " pushed " << G4endl;
223    }
224    if (fWeightWindowConfigurator)
225    {
226      G4cout << " weight window configurator push_back " << G4endl;
227      fConfigurators.push_back(fWeightWindowConfigurator);
228      G4cout << " pushed " << G4endl;
229    }
230   
231    G4cout << " vsampler configurator loop " << G4endl;
232    G4VSamplerConfigurator *preConf = 0;
233    G4int i = 0;
234    for (G4Configurators::iterator it = fConfigurators.begin();
235         it != fConfigurators.end(); it++)
236    {
237      i++;
238      G4cout << " looping " << i << G4endl;
239      G4VSamplerConfigurator *currConf =*it;
240      G4cout << " sampler configurator " << G4endl;
241      currConf->Configure(preConf);
242      G4cout << " configure preconf " << G4endl;
243      preConf = *it;
244    }
245    if (fWeightCutOffConfigurator)
246    {
247      G4cout << " NEW weight window configure " << G4endl;
248      fWeightCutOffConfigurator->Configure(0);
249      G4cout << " configured " << G4endl;
250    }
251  }
252  return;
253}
254
255void G4GeometrySampler::SetParallel(G4bool para)
256{
257  paraflag = para;
258}
259
260void G4GeometrySampler::SetParticle(const G4String &particlename)
261{
262  fParticleName = particlename;
263}
264
Note: See TracBrowser for help on using the repository browser.