00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4GeometrySampler.hh"
00037
00038 #include "G4VIStore.hh"
00039 #include "G4WeightWindowStore.hh"
00040
00041
00042 #include "G4VPhysicalVolume.hh"
00043
00044 #include "G4ImportanceConfigurator.hh"
00045 #include "G4WeightWindowConfigurator.hh"
00046 #include "G4WeightCutOffConfigurator.hh"
00047
00048
00049 G4GeometrySampler::
00050 G4GeometrySampler(G4VPhysicalVolume *parallelworld, const G4String &particlename)
00051 : fParticleName(particlename),
00052 fWorld(parallelworld),
00053 fImportanceConfigurator(0),
00054
00055
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
00083
00084
00085
00086
00087 if (fWeightCutOffConfigurator)
00088 {
00089 delete fWeightCutOffConfigurator;
00090 fWeightCutOffConfigurator = 0;
00091 }
00092
00093
00094
00095
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
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
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
00162 G4cout << " preparing weight roulette" << G4endl;
00163
00164
00165
00166
00167
00168
00169
00170
00171 fWeightCutOffConfigurator =
00172 new G4WeightCutOffConfigurator(fWorld, fParticleName,
00173 wsurvive,
00174 wlimit,
00175 isource,
00176 fIStore,
00177 paraflag);
00178
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
00212
00213
00214
00215
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