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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/biasing/importance/src/G4GeometrySampler.cc (Version 11.3.0) and /processes/biasing/importance/src/G4GeometrySampler.cc (Version 10.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4GeometrySampler                           <<  26 //
                                                   >>  27 //
                                                   >>  28 // ----------------------------------------------------------------------
                                                   >>  29 // GEANT 4 class source file
                                                   >>  30 //
                                                   >>  31 // G4GeometrySampler.cc
                                                   >>  32 //
 27 // -------------------------------------------     33 // ----------------------------------------------------------------------
 28                                                    34 
 29 #include "G4GeometrySampler.hh"                    35 #include "G4GeometrySampler.hh"
 30                                                    36 
 31 #include "G4VIStore.hh"                            37 #include "G4VIStore.hh"
 32 #include "G4WeightWindowStore.hh"                  38 #include "G4WeightWindowStore.hh"
                                                   >>  39 //#include "G4VScorer.hh"
 33                                                    40 
 34 #include "G4VPhysicalVolume.hh"                    41 #include "G4VPhysicalVolume.hh"
                                                   >>  42 //#include "G4ScoreConfigurator.hh"
 35 #include "G4ImportanceConfigurator.hh"             43 #include "G4ImportanceConfigurator.hh"
 36 #include "G4WeightWindowConfigurator.hh"           44 #include "G4WeightWindowConfigurator.hh"
 37 #include "G4WeightCutOffConfigurator.hh"           45 #include "G4WeightCutOffConfigurator.hh"
                                                   >>  46 //#include "G4GCellFinder.hh"
 38 #include "G4TransportationManager.hh"              47 #include "G4TransportationManager.hh"
 39                                                    48 
 40  G4GeometrySampler::                               49  G4GeometrySampler::
 41  G4GeometrySampler(G4VPhysicalVolume *world, c <<  50  G4GeometrySampler(G4VPhysicalVolume *world, const G4String &particlename)
 42   : fParticleName(particlename),                   51   : fParticleName(particlename),
 43     fWorld(world)                              <<  52     fWorld(world),
 44 {                                              <<  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;
 45 }                                                  66 }
 46                                                    67 
 47  G4GeometrySampler::                               68  G4GeometrySampler::
 48  G4GeometrySampler(const G4String& worldName,  <<  69  G4GeometrySampler(G4String worldName, const G4String &particlename)
 49   : fParticleName(particlename),                   70   : fParticleName(particlename),
 50     fWorldName(worldName)                      <<  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)
 51 {                                                  80 {
                                                   >>  81   paraflag = false;
 52   fWorld = G4TransportationManager::GetTranspo     82   fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
                                                   >>  83   //  fWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
                                                   >>  84   //  G4cout << "G4GeometrySampler:: Making geometry sampler with world: " << fWorld->GetName() << G4endl;
                                                   >>  85   //G4TransportationManager::GetTransportationManager()->GetParallelWorld(parallelworldName)
 53 }                                                  86 }
 54                                                    87 
 55 G4GeometrySampler::~G4GeometrySampler()            88 G4GeometrySampler::~G4GeometrySampler()
 56 {                                                  89 {
 57   // ClearSampling();                              90   // ClearSampling();
 58 }                                                  91 }
 59                                                    92 
 60 void G4GeometrySampler::ClearSampling()            93 void G4GeometrySampler::ClearSampling()
 61 {                                                  94 {
 62   delete fImportanceConfigurator; fImportanceC <<  95   if (fImportanceConfigurator)
 63   delete fWeightWindowConfigurator; fWeightWin <<  96   {
 64   delete fWeightCutOffConfigurator; fWeightCut <<  97     delete fImportanceConfigurator;
 65   fIStore = nullptr;                           <<  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;
 66   fConfigurators.clear();                         121   fConfigurators.clear();
 67   fIsConfigured = false;                          122   fIsConfigured = false;
 68 }                                                 123 }
 69                                                   124 
 70 G4bool G4GeometrySampler::IsConfigured() const    125 G4bool G4GeometrySampler::IsConfigured() const
 71 {                                                 126 {
 72   G4bool isconf = false;                          127   G4bool isconf = false;
 73   if (fIsConfigured)                              128   if (fIsConfigured)
 74   {                                               129   {
 75    G4cout << "WARNING - G4GeometrySampler::IsC    130    G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
 76           << "          Some initialization ex << 131           << "          Some initalization exists, use ClearSampling()"
 77           << "          before a new initializ    132           << "          before a new initialization !" << G4endl;
 78    isconf = true;                                 133    isconf = true;
 79   }                                               134   }
 80   return isconf;                                  135   return isconf;
 81 }                                                 136 }
 82                                                   137 
 83 // void G4GeometrySampler::PrepareScoring(G4VS    138 // void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
 84 // {                                              139 // {
 85 //   G4cout << " preparing scoring configurato    140 //   G4cout << " preparing scoring configurator " << G4endl;
 86 //   G4cout << G4endl;                            141 //   G4cout << G4endl;
 87 //   G4cout << G4endl;                            142 //   G4cout << G4endl;
 88 //   G4cout << G4endl;                            143 //   G4cout << G4endl;
 89 //   G4cout << " new fWorld Name: " << fWorld-    144 //   G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
 90 //   G4cout << G4endl;                            145 //   G4cout << G4endl;
 91 //   G4cout << G4endl;                            146 //   G4cout << G4endl;
 92 //   G4cout << G4endl;                            147 //   G4cout << G4endl;
 93 //   fScoreConfigurator = new G4ScoreConfigura    148 //   fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
 94 //   G4cout << " configured scoring " << G4end    149 //   G4cout << " configured scoring " << G4endl;
 95 //   if (!fScoreConfigurator)                     150 //   if (!fScoreConfigurator)
 96 //   {                                            151 //   {
 97 //     G4Exception("G4GeometrySampler::Prepare    152 //     G4Exception("G4GeometrySampler::PrepareScoring()",
 98 //                 "FatalError", FatalExceptio    153 //                 "FatalError", FatalException,
 99 //                 "Failed allocation of G4Sco    154 //                 "Failed allocation of G4ScoreConfigurator !");
100 //   }                                            155 //   }
101 // }                                              156 // }
102                                                   157 
103 void                                              158 void
104 G4GeometrySampler::PrepareImportanceSampling(G    159 G4GeometrySampler::PrepareImportanceSampling(G4VIStore* istore,
105                                            con    160                                            const G4VImportanceAlgorithm  *ialg)
106 {                                                 161 {
107   G4cout << "G4GeometrySampler:: preparing imp    162   G4cout << "G4GeometrySampler:: preparing importance sampling WorldName is " << fWorldName << G4endl;
108   fIStore = istore;                               163   fIStore = istore;
109   //  G4cout << "G4GeometrySampler:: creating     164   //  G4cout << "G4GeometrySampler:: creating istore, worldVolume: " << fWorld->GetName() << G4endl;
110                                                   165 
111   fImportanceConfigurator =                       166   fImportanceConfigurator =
112     new G4ImportanceConfigurator(&istore->GetW    167     new G4ImportanceConfigurator(&istore->GetWorldVolume(), fParticleName, *fIStore, ialg, paraflag);
113   //    new G4ImportanceConfigurator(fWorld, f    168   //    new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
114   fImportanceConfigurator->SetWorldName(fWorld    169   fImportanceConfigurator->SetWorldName(fWorldName);
115                                                   170 
116   if (!fImportanceConfigurator)                   171   if (!fImportanceConfigurator)
117   {                                               172   {
118     G4Exception("G4GeometrySampler::PrepareImp    173     G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
119                 "FatalError", FatalException,     174                 "FatalError", FatalException,
120                 "Failed allocation of G4Import    175                 "Failed allocation of G4ImportanceConfigurator !");
121   }                                               176   }
122 }                                                 177 }
123                                                   178 
124 void                                              179 void
125 G4GeometrySampler::PrepareWeightRoulett(G4doub    180 G4GeometrySampler::PrepareWeightRoulett(G4double wsurvive, 
126                                         G4doub << 181                                             G4double wlimit,
127                                         G4doub << 182                                             G4double isource)
128 {                                                 183 {
129   //  fGCellFinder = new G4GCellFinder(fWorld)    184   //  fGCellFinder = new G4GCellFinder(fWorld);
130   G4cout << "G4GeometrySampler:: preparing wei    185   G4cout << "G4GeometrySampler:: preparing weight roulette" << G4endl;
131   //  fGCellFinder = new G4GCellFinder();         186   //  fGCellFinder = new G4GCellFinder();
132 //   if (!fGCellFinder)                           187 //   if (!fGCellFinder)
133 //   {                                            188 //   {
134 //     G4Exception("G4GeometrySampler::Prepare    189 //     G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
135 //                 "FatalError", FatalExceptio    190 //                 "FatalError", FatalException,
136 //                 "Failed allocation of G4GCe    191 //                 "Failed allocation of G4GCellFinder !");
137 //   }                                            192 //   }
138                                                   193   
139   fWeightCutOffConfigurator =                     194   fWeightCutOffConfigurator = 
140     new G4WeightCutOffConfigurator(fWorld, fPa    195     new G4WeightCutOffConfigurator(fWorld, fParticleName,
141                                    wsurvive,      196                                    wsurvive,
142                                    wlimit,        197                                    wlimit,
143                                    isource,       198                                    isource,
144                                    fIStore,       199                                    fIStore,
145            paraflag);                             200            paraflag);
146            //*fGCellFinder, paraflag);            201            //*fGCellFinder, paraflag);
147   if (!fWeightCutOffConfigurator)                 202   if (!fWeightCutOffConfigurator)
148   {                                               203   {
149     G4Exception("G4GeometrySampler::PrepareWei    204     G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
150                 "FatalError", FatalException,     205                 "FatalError", FatalException,
151                 "Failed allocation of G4Weight    206                 "Failed allocation of G4WeightCutOffConfigurator !");
152   }                                               207   }
153 }                                                 208 }
154                                                   209 
155 void                                              210 void
156 G4GeometrySampler::PrepareWeightWindow(G4VWeig    211 G4GeometrySampler::PrepareWeightWindow(G4VWeightWindowStore *wwstore,
157                                        G4VWeig << 212                                            G4VWeightWindowAlgorithm *wwAlg,
158                                        G4Place << 213                                            G4PlaceOfAction placeOfAction)
159 {                                                 214 {
160                                                   215 
161   G4cout << "G4GeometrySampler:: preparing wei    216   G4cout << "G4GeometrySampler:: preparing weight window" << G4endl;
162                                                   217 
163   fWWStore = wwstore;                             218   fWWStore = wwstore;
164                                                   219   
165   fWeightWindowConfigurator =                     220   fWeightWindowConfigurator =
166     new G4WeightWindowConfigurator(&wwstore->G    221     new G4WeightWindowConfigurator(&wwstore->GetWorldVolume(), fParticleName,
167                                     *fWWStore,    222                                     *fWWStore,
168                                     wwAlg,        223                                     wwAlg,
169                                     placeOfAct    224                                     placeOfAction, paraflag);
                                                   >> 225 
                                                   >> 226   // fWeightWindowConfigurator =
                                                   >> 227   //   new G4WeightWindowConfigurator(fWorld, fParticleName,
                                                   >> 228   //                                   *fWWStore,
                                                   >> 229   //                                   wwAlg,
                                                   >> 230   //                                   placeOfAction, paraflag);
                                                   >> 231 
170 }                                                 232 }
171                                                   233 
172 void G4GeometrySampler::Configure()               234 void G4GeometrySampler::Configure()
173 {                                                 235 {
174   if (!IsConfigured())                            236   if (!IsConfigured())
175   {                                               237   {
176     fIsConfigured = true;                         238     fIsConfigured = true;
177                                                   239 
                                                   >> 240 //     if (fScoreConfigurator)
                                                   >> 241 //     {
                                                   >> 242 //       G4cout << " score configurator push_back " << G4endl;
                                                   >> 243 //       fConfigurators.push_back(fScoreConfigurator);
                                                   >> 244 //       G4cout << " pushed " << G4endl;
                                                   >> 245 //     }
178     if (fImportanceConfigurator)                  246     if (fImportanceConfigurator)
179     {                                             247     {
180       fConfigurators.push_back(fImportanceConf    248       fConfigurators.push_back(fImportanceConfigurator);
181     }                                             249     }
182     if (fWeightWindowConfigurator)                250     if (fWeightWindowConfigurator)
183     {                                             251     {
184       fConfigurators.push_back(fWeightWindowCo    252       fConfigurators.push_back(fWeightWindowConfigurator);
185     }                                             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     // }
186   }                                               275   }
187                                                   276 
188 #ifdef G4MULTITHREADED                            277 #ifdef G4MULTITHREADED
189   G4cout << " make sure AddProcess() is invoke    278   G4cout << " make sure AddProcess() is invoked for biasing!!! " << G4endl;
190 #else                                             279 #else
191   AddProcess();                                   280   AddProcess();
192 #endif                                            281 #endif
193                                                   282 
194   return;                                         283   return;
195 }                                                 284 }
196                                                   285 
197 void G4GeometrySampler::AddProcess()              286 void G4GeometrySampler::AddProcess()
198 {                                                 287 {
199                                                   288 
200   G4VSamplerConfigurator *preConf = nullptr;   << 289   G4VSamplerConfigurator *preConf = 0;
201   for (auto it = fConfigurators.cbegin();      << 290   G4int i = 0;
202        it != fConfigurators.cend(); ++it)      << 291   for (G4Configurators::iterator it = fConfigurators.begin();
                                                   >> 292        it != fConfigurators.end(); it++)
203     {                                             293     {
                                                   >> 294       i++;
204       G4VSamplerConfigurator *currConf =*it;      295       G4VSamplerConfigurator *currConf =*it;
205       currConf->Configure(preConf);               296       currConf->Configure(preConf);
206       preConf = *it;                              297       preConf = *it;
207     }                                             298     }
208   if (fWeightCutOffConfigurator != nullptr)    << 299   if (fWeightCutOffConfigurator)
209     {                                             300     {
210       fWeightCutOffConfigurator->Configure(nul << 301       fWeightCutOffConfigurator->Configure(0);
211     }                                             302     }
212                                                   303 
213   return;                                         304   return;
214 }                                                 305 }
215                                                   306 
216 void G4GeometrySampler::SetParallel(G4bool par    307 void G4GeometrySampler::SetParallel(G4bool para)
217 {                                                 308 {
218   paraflag = para;                                309   paraflag = para;
219 }                                                 310 }
220                                                   311 
221 void G4GeometrySampler::SetWorld(const G4VPhys    312 void G4GeometrySampler::SetWorld(const G4VPhysicalVolume* World)
222 {                                                 313 {
223   fWorld = World;                                 314   fWorld = World;
224 }                                                 315 }
225                                                   316 
226 void G4GeometrySampler::SetParticle(const G4St << 317 void G4GeometrySampler::SetParticle(const G4String &particlename)
227 {                                                 318 {
228   fParticleName = particlename;                   319   fParticleName = particlename;
229 }                                                 320 }
                                                   >> 321 
230                                                   322