Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // G4GeometrySampler 27 // ------------------------------------------- 28 29 #include "G4GeometrySampler.hh" 30 31 #include "G4VIStore.hh" 32 #include "G4WeightWindowStore.hh" 33 34 #include "G4VPhysicalVolume.hh" 35 #include "G4ImportanceConfigurator.hh" 36 #include "G4WeightWindowConfigurator.hh" 37 #include "G4WeightCutOffConfigurator.hh" 38 #include "G4TransportationManager.hh" 39 40 G4GeometrySampler:: 41 G4GeometrySampler(G4VPhysicalVolume *world, c 42 : fParticleName(particlename), 43 fWorld(world) 44 { 45 } 46 47 G4GeometrySampler:: 48 G4GeometrySampler(const G4String& worldName, 49 : fParticleName(particlename), 50 fWorldName(worldName) 51 { 52 fWorld = G4TransportationManager::GetTranspo 53 } 54 55 G4GeometrySampler::~G4GeometrySampler() 56 { 57 // ClearSampling(); 58 } 59 60 void G4GeometrySampler::ClearSampling() 61 { 62 delete fImportanceConfigurator; fImportanceC 63 delete fWeightWindowConfigurator; fWeightWin 64 delete fWeightCutOffConfigurator; fWeightCut 65 fIStore = nullptr; 66 fConfigurators.clear(); 67 fIsConfigured = false; 68 } 69 70 G4bool G4GeometrySampler::IsConfigured() const 71 { 72 G4bool isconf = false; 73 if (fIsConfigured) 74 { 75 G4cout << "WARNING - G4GeometrySampler::IsC 76 << " Some initialization ex 77 << " before a new initializ 78 isconf = true; 79 } 80 return isconf; 81 } 82 83 // void G4GeometrySampler::PrepareScoring(G4VS 84 // { 85 // G4cout << " preparing scoring configurato 86 // G4cout << G4endl; 87 // G4cout << G4endl; 88 // G4cout << G4endl; 89 // G4cout << " new fWorld Name: " << fWorld- 90 // G4cout << G4endl; 91 // G4cout << G4endl; 92 // G4cout << G4endl; 93 // fScoreConfigurator = new G4ScoreConfigura 94 // G4cout << " configured scoring " << G4end 95 // if (!fScoreConfigurator) 96 // { 97 // G4Exception("G4GeometrySampler::Prepare 98 // "FatalError", FatalExceptio 99 // "Failed allocation of G4Sco 100 // } 101 // } 102 103 void 104 G4GeometrySampler::PrepareImportanceSampling(G 105 con 106 { 107 G4cout << "G4GeometrySampler:: preparing imp 108 fIStore = istore; 109 // G4cout << "G4GeometrySampler:: creating 110 111 fImportanceConfigurator = 112 new G4ImportanceConfigurator(&istore->GetW 113 // new G4ImportanceConfigurator(fWorld, f 114 fImportanceConfigurator->SetWorldName(fWorld 115 116 if (!fImportanceConfigurator) 117 { 118 G4Exception("G4GeometrySampler::PrepareImp 119 "FatalError", FatalException, 120 "Failed allocation of G4Import 121 } 122 } 123 124 void 125 G4GeometrySampler::PrepareWeightRoulett(G4doub 126 G4doub 127 G4doub 128 { 129 // fGCellFinder = new G4GCellFinder(fWorld) 130 G4cout << "G4GeometrySampler:: preparing wei 131 // fGCellFinder = new G4GCellFinder(); 132 // if (!fGCellFinder) 133 // { 134 // G4Exception("G4GeometrySampler::Prepare 135 // "FatalError", FatalExceptio 136 // "Failed allocation of G4GCe 137 // } 138 139 fWeightCutOffConfigurator = 140 new G4WeightCutOffConfigurator(fWorld, fPa 141 wsurvive, 142 wlimit, 143 isource, 144 fIStore, 145 paraflag); 146 //*fGCellFinder, paraflag); 147 if (!fWeightCutOffConfigurator) 148 { 149 G4Exception("G4GeometrySampler::PrepareWei 150 "FatalError", FatalException, 151 "Failed allocation of G4Weight 152 } 153 } 154 155 void 156 G4GeometrySampler::PrepareWeightWindow(G4VWeig 157 G4VWeig 158 G4Place 159 { 160 161 G4cout << "G4GeometrySampler:: preparing wei 162 163 fWWStore = wwstore; 164 165 fWeightWindowConfigurator = 166 new G4WeightWindowConfigurator(&wwstore->G 167 *fWWStore, 168 wwAlg, 169 placeOfAct 170 } 171 172 void G4GeometrySampler::Configure() 173 { 174 if (!IsConfigured()) 175 { 176 fIsConfigured = true; 177 178 if (fImportanceConfigurator) 179 { 180 fConfigurators.push_back(fImportanceConf 181 } 182 if (fWeightWindowConfigurator) 183 { 184 fConfigurators.push_back(fWeightWindowCo 185 } 186 } 187 188 #ifdef G4MULTITHREADED 189 G4cout << " make sure AddProcess() is invoke 190 #else 191 AddProcess(); 192 #endif 193 194 return; 195 } 196 197 void G4GeometrySampler::AddProcess() 198 { 199 200 G4VSamplerConfigurator *preConf = nullptr; 201 for (auto it = fConfigurators.cbegin(); 202 it != fConfigurators.cend(); ++it) 203 { 204 G4VSamplerConfigurator *currConf =*it; 205 currConf->Configure(preConf); 206 preConf = *it; 207 } 208 if (fWeightCutOffConfigurator != nullptr) 209 { 210 fWeightCutOffConfigurator->Configure(nul 211 } 212 213 return; 214 } 215 216 void G4GeometrySampler::SetParallel(G4bool par 217 { 218 paraflag = para; 219 } 220 221 void G4GeometrySampler::SetWorld(const G4VPhys 222 { 223 fWorld = World; 224 } 225 226 void G4GeometrySampler::SetParticle(const G4St 227 { 228 fParticleName = particlename; 229 } 230