G4GeometrySampler.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // ----------------------------------------------------------------------
00030 // GEANT 4 class source file
00031 //
00032 // G4GeometrySampler.cc
00033 //
00034 // ----------------------------------------------------------------------
00035 
00036 #include "G4GeometrySampler.hh"
00037 
00038 #include "G4VIStore.hh"
00039 #include "G4WeightWindowStore.hh"
00040 //#include "G4VScorer.hh"
00041 
00042 #include "G4VPhysicalVolume.hh"
00043 //#include "G4ScoreConfigurator.hh"
00044 #include "G4ImportanceConfigurator.hh"
00045 #include "G4WeightWindowConfigurator.hh"
00046 #include "G4WeightCutOffConfigurator.hh"
00047 //#include "G4GCellFinder.hh"
00048 
00049  G4GeometrySampler::
00050  G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
00051   : fParticleName(particlename),
00052     fWorld(parallelworld),
00053     fImportanceConfigurator(0),
00054     //    fScoreConfigurator(0),
00055     //    fGCellFinder(0),
00056     fWeightCutOffConfigurator(0),
00057     fIStore(0),
00058     fWeightWindowConfigurator(0),
00059     fWWStore(0),
00060     fIsConfigured(false)
00061 {
00062   paraflag = false;
00063 }
00064 
00065 G4GeometrySampler::~G4GeometrySampler()
00066 {
00067   ClearSampling();
00068 }
00069 
00070 void G4GeometrySampler::ClearSampling()
00071 {
00072   if (fImportanceConfigurator)
00073   {
00074     delete fImportanceConfigurator;
00075     fImportanceConfigurator = 0;
00076   }
00077   if (fWeightWindowConfigurator)
00078   {
00079     delete fWeightWindowConfigurator;
00080     fWeightWindowConfigurator = 0;
00081   }
00082 //   if (fScoreConfigurator)
00083 //   {
00084 //     delete fScoreConfigurator;
00085 //     fScoreConfigurator = 0;
00086 //   }
00087   if (fWeightCutOffConfigurator)
00088   {
00089     delete fWeightCutOffConfigurator;
00090     fWeightCutOffConfigurator = 0;
00091   }
00092 //   if (fGCellFinder)
00093 //   {
00094 //     delete fGCellFinder;
00095 //     fGCellFinder = 0;
00096 //   }
00097   fIStore = 0;
00098   fConfigurators.clear();
00099   fIsConfigured = false;
00100 }
00101 
00102 G4bool G4GeometrySampler::IsConfigured() const
00103 {
00104   G4bool isconf = false;
00105   if (fIsConfigured)
00106   {
00107    G4cout << "WARNING - G4GeometrySampler::IsConfigured()"
00108           << "          Some initalization exists, use ClearSampling()"
00109           << "          before a new initialization !" << G4endl;
00110    isconf = true;
00111   }
00112   return isconf;
00113 }
00114 
00115 // void G4GeometrySampler::PrepareScoring(G4VScorer *scorer)
00116 // {
00117 //   G4cout << " preparing scoring configurator " << G4endl;
00118 //   G4cout << G4endl;
00119 //   G4cout << G4endl;
00120 //   G4cout << G4endl;
00121 //   G4cout << " new fWorld Name: " << fWorld->GetName() << G4endl;
00122 //   G4cout << G4endl;
00123 //   G4cout << G4endl;
00124 //   G4cout << G4endl;
00125 //   fScoreConfigurator = new G4ScoreConfigurator(fWorld, fParticleName, *scorer, paraflag);
00126 //   G4cout << " configured scoring " << G4endl;
00127 //   if (!fScoreConfigurator)
00128 //   {
00129 //     G4Exception("G4GeometrySampler::PrepareScoring()",
00130 //                 "FatalError", FatalException,
00131 //                 "Failed allocation of G4ScoreConfigurator !");
00132 //   }
00133 // }
00134 
00135 void
00136 G4GeometrySampler::PrepareImportanceSampling(G4VIStore *istore,
00137                                            const G4VImportanceAlgorithm  *ialg)
00138 {
00139   G4cout << " preparing importance sampling " << G4endl;
00140   fIStore = istore;
00141   G4cout << " creating istore " << G4endl;
00142 
00143   fImportanceConfigurator =
00144     new G4ImportanceConfigurator(fWorld, fParticleName, *fIStore, ialg, paraflag);
00145 
00146   G4cout << " creating importance configurator " << G4endl;
00147 
00148   if (!fImportanceConfigurator)
00149   {
00150     G4Exception("G4GeometrySampler::PrepareImportanceSampling()",
00151                 "FatalError", FatalException,
00152                 "Failed allocation of G4ImportanceConfigurator !");
00153   }
00154 }
00155 
00156 void
00157 G4GeometrySampler::PrepareWeightRoulett(G4double wsurvive, 
00158                                             G4double wlimit,
00159                                             G4double isource)
00160 {
00161   //  fGCellFinder = new G4GCellFinder(fWorld);
00162   G4cout << " preparing weight roulette" << G4endl;
00163   //  fGCellFinder = new G4GCellFinder();
00164 //   if (!fGCellFinder)
00165 //   {
00166 //     G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
00167 //                 "FatalError", FatalException,
00168 //                 "Failed allocation of G4GCellFinder !");
00169 //   }
00170   
00171   fWeightCutOffConfigurator = 
00172     new G4WeightCutOffConfigurator(fWorld, fParticleName,
00173                                    wsurvive,
00174                                    wlimit,
00175                                    isource,
00176                                    fIStore,
00177                                    paraflag);
00178                                    //*fGCellFinder, paraflag);
00179   if (!fWeightCutOffConfigurator)
00180   {
00181     G4Exception("G4GeometrySampler::PrepareWeightRoulett()",
00182                 "FatalError", FatalException,
00183                 "Failed allocation of G4WeightCutOffConfigurator !");
00184   }
00185 }
00186 
00187 void
00188 G4GeometrySampler::PrepareWeightWindow(G4VWeightWindowStore *wwstore,
00189                                            G4VWeightWindowAlgorithm *wwAlg,
00190                                            G4PlaceOfAction placeOfAction)
00191 {
00192 
00193   G4cout << " preparing weight window" << G4endl;
00194 
00195   fWWStore = wwstore;
00196   
00197   fWeightWindowConfigurator =
00198     new G4WeightWindowConfigurator(fWorld, fParticleName,
00199                                     *fWWStore,
00200                                     wwAlg,
00201                                     placeOfAction, paraflag);
00202 }
00203 
00204 void G4GeometrySampler::Configure()
00205 {
00206   G4cout << " entering configure " << G4endl;
00207   if (!IsConfigured())
00208   {
00209     fIsConfigured = true;
00210 
00211 //     if (fScoreConfigurator)
00212 //     {
00213 //       G4cout << " score configurator push_back " << G4endl;
00214 //       fConfigurators.push_back(fScoreConfigurator);
00215 //       G4cout << " pushed " << G4endl;
00216 //     }
00217     if (fImportanceConfigurator)
00218     {
00219       G4cout << " importance configurator push_back " << G4endl;
00220       fConfigurators.push_back(fImportanceConfigurator);
00221       G4cout << " pushed " << G4endl;
00222     }
00223     if (fWeightWindowConfigurator)
00224     {
00225       G4cout << " weight window configurator push_back " << G4endl;
00226       fConfigurators.push_back(fWeightWindowConfigurator);
00227       G4cout << " pushed " << G4endl;
00228     }
00229     
00230     G4cout << " vsampler configurator loop " << G4endl;
00231     G4VSamplerConfigurator *preConf = 0;
00232     G4int i = 0;
00233     for (G4Configurators::iterator it = fConfigurators.begin();
00234          it != fConfigurators.end(); it++)
00235     {
00236       i++;
00237       G4cout << " looping " << i << G4endl;
00238       G4VSamplerConfigurator *currConf =*it;
00239       G4cout << " sampler configurator " << G4endl;
00240       currConf->Configure(preConf);
00241       G4cout << " configure preconf " << G4endl;
00242       preConf = *it;
00243     }
00244     if (fWeightCutOffConfigurator)
00245     {
00246       G4cout << " NEW weight window configure " << G4endl;
00247       fWeightCutOffConfigurator->Configure(0);
00248       G4cout << " configured " << G4endl;
00249     }
00250   }
00251   return;
00252 }
00253 
00254 void G4GeometrySampler::SetParallel(G4bool para)
00255 {
00256   paraflag = para;
00257 }
00258 
00259 void G4GeometrySampler::SetParticle(const G4String &particlename)
00260 {
00261   fParticleName = particlename;
00262 }
00263 

Generated on Mon May 27 17:48:22 2013 for Geant4 by  doxygen 1.4.7