Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // 26 // ------------------------------------------- 24 // ------------------------------------------------------------------- 27 // 25 // 28 // GEANT4 Class file 26 // GEANT4 Class file 29 // 27 // 30 // 28 // 31 // File name: G4LossTableManager 29 // File name: G4LossTableManager 32 // 30 // 33 // Author: Vladimir Ivanchenko << 31 // Author: Vladimir Ivanchenko 34 // << 32 // 35 // Creation date: 03.01.2002 33 // Creation date: 03.01.2002 36 // 34 // 37 // Modifications: by V.Ivanchenko << 35 // Modifications: 38 // << 39 // 36 // 40 // Class Description: << 37 // Class Description: 41 // 38 // 42 // ------------------------------------------- 39 // ------------------------------------------------------------------- 43 // 40 // 44 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 43 47 #include "G4LossTableManager.hh" 44 #include "G4LossTableManager.hh" 48 #include "G4SystemOfUnits.hh" << 45 #include "G4EnergyLossMessengerSTD.hh" 49 << 50 #include "G4VMultipleScattering.hh" << 51 #include "G4VEmProcess.hh" << 52 << 53 #include "G4EmParameters.hh" << 54 #include "G4EmSaturation.hh" << 55 #include "G4EmConfigurator.hh" << 56 #include "G4ElectronIonPair.hh" << 57 #include "G4NIELCalculator.hh" << 58 #include "G4EmCorrections.hh" << 59 #include "G4LossTableBuilder.hh" << 60 #include "G4VAtomDeexcitation.hh" << 61 #include "G4VSubCutProducer.hh" << 62 << 63 #include "G4PhysicsTable.hh" 46 #include "G4PhysicsTable.hh" 64 #include "G4ParticleDefinition.hh" 47 #include "G4ParticleDefinition.hh" 65 #include "G4MaterialCutsCouple.hh" << 48 #include "G4Material.hh" 66 #include "G4ProcessManager.hh" 49 #include "G4ProcessManager.hh" 67 #include "G4Electron.hh" 50 #include "G4Electron.hh" 68 #include "G4Proton.hh" << 69 #include "G4ProductionCutsTable.hh" << 70 #include "G4PhysicsTableHelper.hh" << 71 #include "G4EmTableType.hh" << 72 #include "G4Region.hh" << 73 #include "G4PhysicalConstants.hh" << 74 << 75 #include "G4Gamma.hh" << 76 #include "G4Positron.hh" << 77 #include "G4OpticalPhoton.hh" << 78 #include "G4Neutron.hh" << 79 #include "G4MuonPlus.hh" << 80 #include "G4MuonMinus.hh" << 81 #include "G4GenericIon.hh" << 82 51 83 //....oooOO0OOooo........oooOO0OOooo........oo << 52 G4LossTableManager* G4LossTableManager::theInstance = 0; 84 53 85 static std::once_flag applyOnce; << 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 86 G4ThreadLocal G4LossTableManager* G4LossTableM << 87 55 88 G4LossTableManager* G4LossTableManager::Instan 56 G4LossTableManager* G4LossTableManager::Instance() 89 { 57 { 90 if(nullptr == instance) { << 58 if(0 == theInstance) { 91 static G4ThreadLocalSingleton<G4LossTableM << 59 theInstance = new G4LossTableManager(); 92 instance = inst.Instance(); << 93 } 60 } 94 return instance; << 61 return theInstance; 95 } 62 } 96 63 97 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 98 65 99 G4LossTableManager::~G4LossTableManager() 66 G4LossTableManager::~G4LossTableManager() 100 { 67 { 101 for (auto const & p : loss_vector) { delete << 68 delete theMessenger; 102 for (auto const & p : msc_vector) { delete p << 103 for (auto const & p : emp_vector) { delete p << 104 for (auto const & p : p_vector) { delete p; << 105 << 106 std::size_t mod = mod_vector.size(); << 107 std::size_t fmod = fmod_vector.size(); << 108 for (std::size_t a=0; a<mod; ++a) { << 109 if( nullptr != mod_vector[a] ) { << 110 for (std::size_t b=0; b<fmod; ++b) { << 111 if((G4VEmModel*)(fmod_vector[b]) == mo << 112 fmod_vector[b] = nullptr; << 113 } << 114 } << 115 delete mod_vector[a]; << 116 mod_vector[a] = nullptr; << 117 } << 118 } << 119 for (auto const & p : fmod_vector) { delete << 120 << 121 Clear(); << 122 delete tableBuilder; 69 delete tableBuilder; 123 delete emCorrections; << 124 delete emConfigurator; << 125 delete emElectronIonPair; << 126 delete nielCalculator; << 127 delete atomDeexcitation; << 128 delete subcutProducer; << 129 } 70 } 130 71 131 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 132 73 133 G4LossTableManager::G4LossTableManager() 74 G4LossTableManager::G4LossTableManager() 134 { << 75 { 135 theParameters = G4EmParameters::Instance(); << 76 n_loss = 0; 136 theElectron = G4Electron::Electron(); << 77 all_tables_are_built = false; 137 << 78 all_particles_are_mapped = false; 138 // only one thread is the master << 79 electron_table_are_built = false; 139 std::call_once(applyOnce, [this]() { isMaste << 80 currentLoss = 0; 140 verbose = isMaster ? theParameters->Verbose( << 81 currentParticle = 0; 141 << 82 lossFluctuationFlag = true; 142 tableBuilder = new G4LossTableBuilder(isMast << 83 subCutoffFlag = false; 143 emCorrections = new G4EmCorrections(verbose) << 84 rndmStepFlag = false; 144 << 85 minSubRange = 0.0; 145 std::size_t n = 70; << 86 maxRangeVariation = 1.0; 146 loss_vector.reserve(n); << 87 maxFinalStep = 0.0; 147 part_vector.reserve(n); << 88 eIonisation = 0; 148 base_part_vector.reserve(n); << 89 minKinEnergy = 0.1*eV; 149 dedx_vector.reserve(n); << 90 maxKinEnergy = 100.0*GeV; 150 range_vector.reserve(n); << 91 theMessenger = new G4EnergyLossMessengerSTD(); 151 inv_range_vector.reserve(n); << 92 theElectron = G4Electron::Electron(); 152 tables_are_built.reserve(n); << 93 tableBuilder = new G4LossTableBuilder(); 153 isActive.reserve(n); << 94 integral = true; 154 msc_vector.reserve(10); << 95 verbose = 0; 155 emp_vector.reserve(16); << 156 mod_vector.reserve(150); << 157 fmod_vector.reserve(60); << 158 } 96 } 159 97 160 //....oooOO0OOooo........oooOO0OOooo........oo 98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 161 99 162 void G4LossTableManager::Clear() 100 void G4LossTableManager::Clear() 163 { << 101 { 164 all_tables_are_built = false; 102 all_tables_are_built = false; 165 currentLoss = nullptr; << 103 all_particles_are_mapped = false; 166 currentParticle = nullptr; << 104 electron_table_are_built = false; 167 if(n_loss) { << 105 eIonisation = 0; 168 dedx_vector.clear(); << 106 currentLoss = 0; 169 range_vector.clear(); << 107 currentParticle = 0; 170 inv_range_vector.clear(); << 108 if(n_loss) 171 loss_map.clear(); << 109 { 172 loss_vector.clear(); << 110 for(G4int i=0; i<n_loss; i++) 173 part_vector.clear(); << 111 { 174 base_part_vector.clear(); << 112 if(dedx_vector[i]) dedx_vector[i]->clearAndDestroy(); 175 tables_are_built.clear(); << 113 if(range_vector[i]) range_vector[i]->clearAndDestroy(); 176 isActive.clear(); << 114 if(inv_range_vector[i]) inv_range_vector[i]->clearAndDestroy(); 177 n_loss = 0; << 115 } 178 } << 116 >> 117 dedx_vector.clear(); >> 118 range_vector.clear(); >> 119 inv_range_vector.clear(); >> 120 loss_map.clear(); >> 121 loss_vector.clear(); >> 122 part_vector.clear(); >> 123 base_part_vector.clear(); >> 124 tables_are_built.clear(); >> 125 n_loss = 0; >> 126 } 179 } 127 } 180 128 181 //....oooOO0OOooo........oooOO0OOooo........oo 129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 182 130 183 void G4LossTableManager::Register(G4VEnergyLos << 131 void G4LossTableManager::Register(G4VEnergyLossSTD* p) 184 { 132 { 185 if (nullptr == p) { return; } << 133 n_loss++; 186 for (G4int i=0; i<n_loss; ++i) { << 187 if(loss_vector[i] == p) { return; } << 188 } << 189 if(verbose > 1) { << 190 G4cout << "G4LossTableManager::Register G4 << 191 << p->GetProcessName() << " idx= " << 192 } << 193 ++n_loss; << 194 loss_vector.push_back(p); 134 loss_vector.push_back(p); 195 part_vector.push_back(nullptr); << 135 part_vector.push_back(0); 196 base_part_vector.push_back(nullptr); << 136 base_part_vector.push_back(0); 197 dedx_vector.push_back(nullptr); << 137 dedx_vector.push_back(0); 198 range_vector.push_back(nullptr); << 138 range_vector.push_back(0); 199 inv_range_vector.push_back(nullptr); << 139 inv_range_vector.push_back(0); 200 tables_are_built.push_back(false); 140 tables_are_built.push_back(false); 201 isActive.push_back(true); << 141 all_particles_are_mapped = false; 202 all_tables_are_built = false; 142 all_tables_are_built = false; >> 143 /* >> 144 p->SetLossFluctuations(lossFluctuationFlag); >> 145 p->SetSubCutoff(subCutoffFlag); >> 146 p->SetRandomStep(rndmStepFlag); >> 147 p->SetMinSubRange(minSubRange); >> 148 p->SetMinKinEnergy(minKinEnergy); >> 149 p->SetMaxKinEnergy(maxKinEnergy); >> 150 p->SetStepLimits(maxRangeVariation, maxFinalStep); >> 151 p->SetIntegral(integral); >> 152 */ 203 } 153 } 204 154 205 //....oooOO0OOooo........oooOO0OOooo........oo << 155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 206 << 207 void G4LossTableManager::ResetParameters() << 208 { << 209 // initialisation once per run << 210 if (!resetParam) { return; } << 211 resetParam = false; << 212 startInitialisation = true; << 213 verbose = theParameters->Verbose(); << 214 if(!isMaster) { << 215 verbose = theParameters->WorkerVerbose(); << 216 } else { << 217 if(verbose > 0) { theParameters->Dump(); } << 218 } << 219 << 220 tableBuilder->InitialiseBaseMaterials(); << 221 if (nullptr != nielCalculator) { nielCalcula << 222 << 223 emCorrections->SetVerbose(verbose); << 224 if(nullptr != emConfigurator) { emConfigurat << 225 if(nullptr != emElectronIonPair) { emElectro << 226 if(nullptr != atomDeexcitation) { << 227 atomDeexcitation->SetVerboseLevel(verbose) << 228 atomDeexcitation->InitialiseAtomicDeexcita << 229 } << 230 if (1 < verbose) { << 231 G4cout << "====== G4LossTableManager::Rese << 232 << " Nloss=" << loss_vector.size() << 233 << " run=" << run << " master=" << isMast << 234 << G4endl; << 235 } << 236 } << 237 << 238 //....oooOO0OOooo........oooOO0OOooo........oo << 239 << 240 void G4LossTableManager::DeRegister(G4VEnergyL << 241 { << 242 if (nullptr == p) { return; } << 243 for (G4int i=0; i<n_loss; ++i) { << 244 if(loss_vector[i] == p) { << 245 loss_vector[i] = nullptr; << 246 break; << 247 } << 248 } << 249 } << 250 << 251 //....oooOO0OOooo........oooOO0OOooo........oo << 252 << 253 void G4LossTableManager::Register(G4VMultipleS << 254 { << 255 if (nullptr == p) { return; } << 256 std::size_t n = msc_vector.size(); << 257 for (std::size_t i=0; i<n; ++i) { << 258 if(msc_vector[i] == p) { return; } << 259 } << 260 if(verbose > 1) { << 261 G4cout << "G4LossTableManager::Register G4 << 262 << p->GetProcessName() << " idx= " << 263 } << 264 msc_vector.push_back(p); << 265 } << 266 << 267 //....oooOO0OOooo........oooOO0OOooo........oo << 268 << 269 void G4LossTableManager::DeRegister(G4VMultipl << 270 { << 271 if (nullptr == p) { return; } << 272 std::size_t msc = msc_vector.size(); << 273 for (std::size_t i=0; i<msc; ++i) { << 274 if(msc_vector[i] == p) { << 275 msc_vector[i] = nullptr; << 276 break; << 277 } << 278 } << 279 } << 280 << 281 //....oooOO0OOooo........oooOO0OOooo........oo << 282 << 283 void G4LossTableManager::Register(G4VEmProcess << 284 { << 285 if (nullptr == p) { return; } << 286 std::size_t n = emp_vector.size(); << 287 for (std::size_t i=0; i<n; ++i) { << 288 if(emp_vector[i] == p) { return; } << 289 } << 290 if(verbose > 1) { << 291 G4cout << "G4LossTableManager::Register G4 << 292 << p->GetProcessName() << " idx= " << 293 } << 294 emp_vector.push_back(p); << 295 } << 296 << 297 //....oooOO0OOooo........oooOO0OOooo........oo << 298 << 299 void G4LossTableManager::DeRegister(G4VEmProce << 300 { << 301 if (nullptr == p) { return; } << 302 std::size_t emp = emp_vector.size(); << 303 for (std::size_t i=0; i<emp; ++i) { << 304 if(emp_vector[i] == p) { << 305 emp_vector[i] = nullptr; << 306 break; << 307 } << 308 } << 309 } << 310 << 311 //....oooOO0OOooo........oooOO0OOooo........oo << 312 << 313 void G4LossTableManager::Register(G4VProcess* << 314 { << 315 if (nullptr == p) { return; } << 316 std::size_t n = p_vector.size(); << 317 for (std::size_t i=0; i<n; ++i) { << 318 if(p_vector[i] == p) { return; } << 319 } << 320 if(verbose > 1) { << 321 G4cout << "G4LossTableManager::Register G4 << 322 << p->GetProcessName() << " idx= " << 323 } << 324 p_vector.push_back(p); << 325 } << 326 << 327 //....oooOO0OOooo........oooOO0OOooo........oo << 328 156 329 void G4LossTableManager::DeRegister(G4VProcess << 157 void G4LossTableManager::Initialise() 330 { 158 { 331 if (nullptr == p) { return; } << 159 all_tables_are_built = true; 332 std::size_t emp = p_vector.size(); << 160 for(G4int j=0; j<n_loss; j++) { 333 for (std::size_t i=0; i<emp; ++i) { << 161 if(1 < verbose) { 334 if(p_vector[i] == p) { << 162 G4String nm = "unknown"; 335 p_vector[i] = nullptr; << 163 const G4ParticleDefinition* pd = loss_vector[j]->Particle(); 336 break; << 164 if(pd) nm = pd->GetParticleName(); >> 165 G4cout << "For " << loss_vector[j]->GetProcessName() >> 166 << " for " << nm >> 167 << " tables_are_built= " << tables_are_built[j] >> 168 << G4endl; 337 } 169 } 338 } << 170 if(!loss_vector[j]->TablesAreBuilt()) { 339 } << 171 all_tables_are_built = false; 340 << 341 //....oooOO0OOooo........oooOO0OOooo........oo << 342 << 343 void G4LossTableManager::Register(G4VEmModel* << 344 { << 345 mod_vector.push_back(p); << 346 if(verbose > 1) { << 347 G4cout << "G4LossTableManager::Register G4 << 348 << p->GetName() << " " << p << " << 349 } << 350 } << 351 << 352 //....oooOO0OOooo........oooOO0OOooo........oo << 353 << 354 void G4LossTableManager::DeRegister(G4VEmModel << 355 { << 356 //G4cout << "G4LossTableManager::DeRegister << 357 std::size_t n = mod_vector.size(); << 358 for (std::size_t i=0; i<n; ++i) { << 359 if(mod_vector[i] == p) { << 360 mod_vector[i] = nullptr; << 361 break; 172 break; 362 } 173 } 363 } 174 } 364 } << 365 << 366 //....oooOO0OOooo........oooOO0OOooo........oo << 367 << 368 void G4LossTableManager::Register(G4VEmFluctua << 369 { << 370 fmod_vector.push_back(p); << 371 if(verbose > 1) { << 372 G4cout << "G4LossTableManager::Register G4 << 373 << p->GetName() << " " << fmod_vec << 374 } << 375 } << 376 << 377 //....oooOO0OOooo........oooOO0OOooo........oo << 378 << 379 void G4LossTableManager::DeRegister(G4VEmFluct << 380 { << 381 std::size_t n = fmod_vector.size(); << 382 for (std::size_t i=0; i<n; ++i) { << 383 if(fmod_vector[i] == p) { fmod_vector[i] = << 384 } << 385 } << 386 << 387 //....oooOO0OOooo........oooOO0OOooo........oo << 388 << 389 void G4LossTableManager::RegisterExtraParticle << 390 const G4ParticleDefinition* part, << 391 G4VEnergyLossProcess* p) << 392 { << 393 if (nullptr == p || nullptr == part) { retur << 394 for (G4int i=0; i<n_loss; ++i) { << 395 if(loss_vector[i] == p) { return; } << 396 } << 397 if(verbose > 1) { << 398 G4cout << "G4LossTableManager::RegisterExt << 399 << part->GetParticleName() << " G4 << 400 << p->GetProcessName() << " idx= " << 401 } << 402 ++n_loss; << 403 loss_vector.push_back(p); << 404 part_vector.push_back(part); << 405 base_part_vector.push_back(p->BaseParticle() << 406 dedx_vector.push_back(nullptr); << 407 range_vector.push_back(nullptr); << 408 inv_range_vector.push_back(nullptr); << 409 tables_are_built.push_back(false); << 410 all_tables_are_built = false; << 411 } << 412 << 413 //....oooOO0OOooo........oooOO0OOooo........oo << 414 175 415 G4VEnergyLossProcess* << 176 // All tables have to be rebuilt 416 G4LossTableManager::GetEnergyLossProcess(const << 177 if(all_particles_are_mapped && all_tables_are_built) { 417 { << 178 for(G4int i=0; i<n_loss; i++) { 418 if(aParticle != currentParticle) { << 179 tables_are_built[i] = false; 419 currentParticle = aParticle; << 420 std::map<PD,G4VEnergyLossProcess*,std::les << 421 if ((pos = loss_map.find(aParticle)) != lo << 422 currentLoss = (*pos).second; << 423 } else { << 424 currentLoss = nullptr; << 425 if(0.0 != aParticle->GetPDGCharge() && << 426 (pos = loss_map.find(theGenericIon)) != los << 427 currentLoss = (*pos).second; << 428 } << 429 } 180 } >> 181 all_tables_are_built = false; >> 182 electron_table_are_built = false; >> 183 loss_map.clear(); 430 } 184 } 431 return currentLoss; << 432 } << 433 185 434 //....oooOO0OOooo........oooOO0OOooo........oo << 186 // map all particles >> 187 if(!all_particles_are_mapped) { 435 188 436 void << 189 const G4ParticleDefinition* pd; 437 G4LossTableManager::PreparePhysicsTable(const << 190 for(G4int i=0; i<n_loss; i++) { 438 G4VEne << 191 if(!part_vector[i]) { 439 { << 192 pd = loss_vector[i]->Particle(); 440 if (1 < verbose) { << 193 if(!pd) { 441 G4cout << "G4LossTableManager::PreparePhys << 194 pd = loss_vector[i]->GetProcessManager()->GetParticleType(); 442 << particle->GetParticleName() << 195 loss_vector[i]->SetParticle(pd); 443 << " and " << p->GetProcessName() < << 196 } 444 << " loss_vector " << loss_vector << 197 if(pd == theElectron) eIonisation = loss_vector[i]; 445 << " run=" << run << " master=" << isMast << 198 part_vector[i] = pd; 446 << G4endl; << 199 pd = loss_vector[i]->BaseParticle(); 447 } << 200 base_part_vector[i] = pd; 448 << 449 // start initialisation for the first run << 450 if( -1 == run ) { << 451 if (nullptr != emConfigurator) { emConfigu << 452 << 453 // initialise particles for given process << 454 for (G4int j=0; j<n_loss; ++j) { << 455 if (p == loss_vector[j] && nullptr == pa << 456 part_vector[j] = particle; << 457 if (particle->GetParticleName() == "Ge << 458 theGenericIon = particle; << 459 } << 460 } 201 } 461 } 202 } >> 203 all_particles_are_mapped = true; 462 } 204 } 463 ResetParameters(); << 205 if(1 < verbose) { 464 } << 206 G4cout << "electron_table_are_built= " << electron_table_are_built 465 << 207 << " all_tables_are_built= " << all_tables_are_built 466 //....oooOO0OOooo........oooOO0OOooo........oo << 208 << " all_particles_are_mapped= " << all_particles_are_mapped 467 << 209 << G4endl; 468 void << 469 G4LossTableManager::PreparePhysicsTable(const << 470 G4VEmP << 471 { << 472 if (1 < verbose) { << 473 G4cout << "G4LossTableManager::PreparePhys << 474 << particle->GetParticleName() << 475 << " and " << p->GetProcessName() << 476 << " run=" << run << " master=" << isMast << 477 << G4endl; << 478 } << 479 << 480 // start initialisation for the first run << 481 if( -1 == run ) { << 482 if (nullptr != emConfigurator) { emConfigu << 483 } 210 } 484 211 485 ResetParameters(); << 486 } 212 } 487 213 488 //....oooOO0OOooo........oooOO0OOooo........oo << 214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 489 215 490 void << 216 void G4LossTableManager::BuildDEDXTable(const G4ParticleDefinition* aParticle) 491 G4LossTableManager::PreparePhysicsTable(const << 492 G4VMul << 493 { 217 { 494 if (1 < verbose) { << 495 G4cout << "G4LossTableManager::PreparePhys << 496 << particle->GetParticleName() << 497 << " and " << p->GetProcessName() << 498 << " run=" << run << " master=" << isMast << 499 << G4endl; << 500 } << 501 << 502 // start initialisation for the first run << 503 if ( -1 == run ) { << 504 if (nullptr != emConfigurator) { emConfigu << 505 } << 506 << 507 ResetParameters(); << 508 } << 509 218 510 //....oooOO0OOooo........oooOO0OOooo........oo << 219 if(1 < verbose) { 511 << 220 G4cout << "G4LossTableManager::BuildDEDXTable() for " 512 void << 221 << aParticle->GetParticleName() 513 G4LossTableManager::BuildPhysicsTable(const G4 << 514 { << 515 if(-1 == run && startInitialisation) { << 516 if (nullptr != emConfigurator) { emConfigu << 517 } << 518 if (startInitialisation) { resetParam = true << 519 } << 520 << 521 //....oooOO0OOooo........oooOO0OOooo........oo << 522 << 523 void G4LossTableManager::LocalPhysicsTables( << 524 const G4ParticleDefinition* aParticle, << 525 G4VEnergyLossProcess* p) << 526 { << 527 if (1 < verbose) { << 528 G4cout << "### G4LossTableManager::LocalPh << 529 << aParticle->GetParticleName() << 530 << " and process " << p->GetProcess << 531 << G4endl; 222 << G4endl; 532 } 223 } 533 224 534 if(-1 == run && startInitialisation) { << 225 Initialise(); 535 if (nullptr != emConfigurator) { emConfigu << 536 firstParticle = aParticle; << 537 } << 538 226 539 if (startInitialisation) { << 227 // identify all particles and built electron table 540 ++run; << 228 if(!electron_table_are_built) { 541 if (1 < verbose) { << 229 eIonisation = BuildTables(theElectron); 542 G4cout << "===== G4LossTableManager::Loc << 230 electron_table_are_built = true; 543 << run << " =====" << G4endl; << 544 } << 545 currentParticle = nullptr; << 546 startInitialisation = false; << 547 resetParam = true; << 548 for (G4int i=0; i<n_loss; ++i) { << 549 if (nullptr != loss_vector[i]) { << 550 tables_are_built[i] = false; << 551 } else { << 552 tables_are_built[i] = true; << 553 part_vector[i] = nullptr; << 554 } << 555 } << 556 } 231 } 557 232 558 all_tables_are_built= true; << 233 // If particle is not an electron 559 for (G4int i=0; i<n_loss; ++i) { << 234 if(aParticle != theElectron) { 560 if(p == loss_vector[i]) { << 235 for(G4int i=0; i<n_loss; i++) { 561 tables_are_built[i] = true; << 562 isActive[i] = true; << 563 part_vector[i] = p->Particle(); << 564 base_part_vector[i] = p->BaseParticle(); << 565 dedx_vector[i] = p->DEDXTable(); << 566 range_vector[i] = p->RangeTableForLoss() << 567 inv_range_vector[i] = p->InverseRangeTab << 568 if(0 == run && p->IsIonisationProcess()) << 569 loss_map[part_vector[i]] = p; << 570 } << 571 236 572 if(1 < verbose) { << 237 if(1 < verbose) { 573 G4cout << i <<". "<< p->GetProcessNa << 238 G4String nm = "0"; 574 if(part_vector[i]) { << 239 G4String nm1= "0"; 575 G4cout << " for " << part_vector[i << 240 G4String nm2= "0"; 576 } << 241 const G4ParticleDefinition* pd = loss_vector[i]->Particle(); 577 G4cout << " active= " << isActive[i] << 242 const G4ParticleDefinition* bpd = loss_vector[i]->BaseParticle(); 578 << " table= " << tables_are_bu << 243 if(pd) nm = pd->GetParticleName(); 579 << " isIonisation= " << p->IsI << 244 if(bpd) nm2 = bpd->GetParticleName(); >> 245 if(part_vector[i]) nm1 = part_vector[i]->GetParticleName(); >> 246 G4cout << "For " << loss_vector[i]->GetProcessName() >> 247 << " for " << nm >> 248 << " (" << nm1 << ") " >> 249 << " base_part= " << nm2 >> 250 << " tables_are_built= " << tables_are_built[i] 580 << G4endl; 251 << G4endl; 581 } 252 } 582 break; << 253 if(aParticle == part_vector[i]) { 583 } else if(!tables_are_built[i]) { << 254 if(tables_are_built[i]) break; 584 all_tables_are_built = false; << 255 base_part_vector[i] = loss_vector[i]->BaseParticle(); >> 256 if(!base_part_vector[i]) { >> 257 G4VEnergyLossSTD* hIonisation = BuildTables(aParticle); >> 258 for(G4int j=0; j<i; j++) { >> 259 if(aParticle == base_part_vector[j]) { >> 260 tables_are_built[j] = true; >> 261 G4VEnergyLossSTD* em = loss_vector[j]; >> 262 em->Initialise(); >> 263 em->SetDEDXTable(hIonisation->DEDXTable()); >> 264 em->SetRangeTable(hIonisation->RangeTable()); >> 265 em->SetInverseRangeTable(hIonisation->InverseRangeTable()); >> 266 loss_map[part_vector[j]] = hIonisation; >> 267 if(em->SecondaryParticle() == theElectron) { >> 268 em->SetSecondaryRangeTable(eIonisation->RangeTable()); >> 269 } >> 270 } >> 271 } >> 272 } else { >> 273 G4VEnergyLossSTD* em = loss_vector[i]; >> 274 for(G4int j=0; j<n_loss; j++) { >> 275 if(part_vector[j] == base_part_vector[i]) { >> 276 G4VEnergyLossSTD* hIonisation = loss_vector[j]; >> 277 if(tables_are_built[j] && hIonisation->DEDXTable()) { >> 278 tables_are_built[i] = true; >> 279 em->Initialise(); >> 280 em->SetDEDXTable(hIonisation->DEDXTable()); >> 281 em->SetRangeTable(hIonisation->RangeTable()); >> 282 em->SetInverseRangeTable(hIonisation->InverseRangeTable()); >> 283 loss_map[part_vector[i]] = hIonisation; >> 284 if(em->SecondaryParticle() == theElectron) { >> 285 em->SetSecondaryRangeTable(eIonisation->RangeTable()); >> 286 } >> 287 break; >> 288 } >> 289 } >> 290 } >> 291 } >> 292 break; >> 293 } 585 } 294 } 586 } 295 } 587 << 588 if(1 < verbose) { 296 if(1 < verbose) { 589 G4cout << "### G4LossTableManager::LocalPh << 297 G4cout << "G4LossTableManager::BuildDEDXTable: end; " >> 298 << "all_tables_are_built= " << all_tables_are_built 590 << G4endl; 299 << G4endl; 591 } 300 } 592 if(all_tables_are_built) { << 593 if(1 < verbose) { << 594 G4cout << "%%%%% All dEdx and Range tabl << 595 << run << " %%%%%" << G4endl; << 596 } << 597 } << 598 } 301 } 599 302 600 //....oooOO0OOooo........oooOO0OOooo........oo << 303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 601 304 602 void G4LossTableManager::BuildPhysicsTable( << 305 void G4LossTableManager::RetrieveDEDXTable(const G4ParticleDefinition* aParticle, 603 const G4ParticleDefinition* aParticle, << 306 G4VEnergyLossSTD* theModel) 604 G4VEnergyLossProcess* p) << 605 { 307 { 606 if(1 < verbose) { << 308 for(G4int i=0; i<n_loss; i++) { 607 G4cout << "### G4LossTableManager::BuildPh << 309 if(theModel == loss_vector[i]) { 608 << aParticle->GetParticleName() << 310 tables_are_built[i] = true; 609 << " and process " << p->GetProcess << 311 if(theModel->DEDXTable()) { 610 } << 312 for(G4int j=0; j<n_loss; j++) { 611 // clear configurator << 313 if(j != i && tables_are_built[j]) { 612 if(-1 == run && startInitialisation) { << 314 if(aParticle == base_part_vector[j]) { 613 if( nullptr != emConfigurator) { emConfigu << 315 G4VEnergyLossSTD* em = loss_vector[j]; 614 firstParticle = aParticle; << 316 em->SetDEDXTable(theModel->DEDXTable()); 615 } << 317 em->SetRangeTable(theModel->RangeTable()); 616 if(startInitialisation) { << 318 em->SetInverseRangeTable(theModel->InverseRangeTable()); 617 ++run; << 319 loss_map[part_vector[j]] = theModel; 618 resetParam = true; << 320 } 619 startInitialisation = false; << 321 } 620 if(1 < verbose) { << 322 } 621 G4cout << "===== G4LossTableManager::Bui << 622 << run << " ===== " << atomDeexci << 623 } << 624 currentParticle = nullptr; << 625 all_tables_are_built = false; << 626 << 627 for (G4int i=0; i<n_loss; ++i) { << 628 G4VEnergyLossProcess* el = loss_vector[i << 629 << 630 if(nullptr != el) { << 631 isActive[i] = true; << 632 part_vector[i] = el->Particle(); << 633 base_part_vector[i] = el->BaseParticle << 634 tables_are_built[i] = false; << 635 if(1 < verbose) { << 636 G4cout << i <<". "<< el->GetProces << 637 if(el->Particle()) { << 638 G4cout << " for " << el->Particl << 639 } << 640 G4cout << " active= " << isActive[i << 641 << " table= " << tables_are_ << 642 << " isIonisation= " << el-> << 643 if(base_part_vector[i]) { << 644 G4cout << " base particle " << 645 << base_part_vector[i]->Get << 646 } << 647 G4cout << G4endl; << 648 } << 649 } else { 323 } else { 650 tables_are_built[i] = true; << 324 const G4ParticleDefinition* bp = theModel->BaseParticle(); 651 part_vector[i] = nullptr; << 325 for(G4int j=0; j<n_loss; j++) { 652 isActive[i] = false; << 326 if(j != i && tables_are_built[j]) { >> 327 if(bp == part_vector[j] && loss_vector[j]->DEDXTable()) { >> 328 G4VEnergyLossSTD* hIonisation = loss_vector[j]; >> 329 theModel->SetDEDXTable(hIonisation->DEDXTable()); >> 330 theModel->SetRangeTable(hIonisation->RangeTable()); >> 331 theModel->SetInverseRangeTable(hIonisation->InverseRangeTable()); >> 332 loss_map[part_vector[j]] = hIonisation; >> 333 break; >> 334 } >> 335 } >> 336 } 653 } 337 } >> 338 break; 654 } 339 } 655 } 340 } 656 341 657 if (all_tables_are_built) { << 342 // identify all particles and built electron table 658 theParameters->SetIsPrintedFlag(true); << 343 if(aParticle == theElectron) { 659 return; << 344 electron_table_are_built = true; 660 } << 345 for(G4int i=0; i<n_loss; i++) { 661 << 346 if(loss_vector[i]->SecondaryParticle() == theElectron) { 662 // Build tables for given particle << 347 loss_vector[i]->SetSecondaryRangeTable(theModel->RangeTable()); 663 all_tables_are_built = true; << 664 << 665 for(G4int i=0; i<n_loss; ++i) { << 666 if(p == loss_vector[i] && !tables_are_buil << 667 const G4ParticleDefinition* curr_part = << 668 if(1 < verbose) { << 669 G4cout << "### Build Table for " << p- << 670 << " and " << curr_part->GetPar << 671 << " " << tables_are_built[i] << 672 << G4endl; << 673 } << 674 G4VEnergyLossProcess* curr_proc = BuildT << 675 if(curr_proc) { << 676 CopyTables(curr_part, curr_proc); << 677 if(p == curr_proc && 0 == run && p->Is << 678 loss_map[aParticle] = p; << 679 //G4cout << "G4LossTableManager::Bui << 680 // << aParticle->GetParticleName << 681 // << " added to map " << p << 682 } << 683 } 348 } 684 } 349 } 685 if ( !tables_are_built[i] ) { all_tables_a << 686 } << 687 if(1 < verbose) { << 688 G4cout << "### G4LossTableManager::BuildPh << 689 << "all_tables_are_built= " << all_ << 690 << aParticle->GetParticleName() << << 691 } 350 } 692 } 351 } 693 352 694 //....oooOO0OOooo........oooOO0OOooo........oo << 353 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 695 << 696 void G4LossTableManager::CopyTables(const G4Pa << 697 G4VEnergyL << 698 { << 699 for (G4int j=0; j<n_loss; ++j) { << 700 << 701 G4VEnergyLossProcess* proc = loss_vector[j << 702 << 703 if (!tables_are_built[j] && part == base_p << 704 tables_are_built[j] = true; << 705 // for base particle approach only ionis << 706 proc->SetDEDXTable(base_proc->Ionisation << 707 proc->SetDEDXTable(base_proc->DEDXunRest << 708 proc->SetCSDARangeTable(base_proc->CSDAR << 709 proc->SetRangeTableForLoss(base_proc->Ra << 710 proc->SetInverseRangeTable(base_proc->In << 711 proc->SetLambdaTable(base_proc->LambdaTa << 712 if(proc->IsIonisationProcess()) { << 713 range_vector[j] = base_proc->RangeTabl << 714 inv_range_vector[j] = base_proc->Inver << 715 loss_map[part_vector[j]] = proc; << 716 //G4cout << "G4LossTableManager::CopyT << 717 // << part_vector[j]->GetParticl << 718 // << " added to map " << proc < << 719 } << 720 if (1 < verbose) { << 721 G4cout << " CopyTables for " << pro << 722 << " for " << part_vector[j]-> << 723 << " base_part= " << part->Get << 724 << " tables are assigned" << 725 << G4endl; << 726 } << 727 } << 728 } << 729 } << 730 << 731 //....oooOO0OOooo........oooOO0OOooo........oo << 732 354 733 G4VEnergyLossProcess* G4LossTableManager::Buil << 355 G4VEnergyLossSTD* G4LossTableManager::BuildTables(const G4ParticleDefinition* aParticle) 734 const G4ParticleDefiniti << 735 { 356 { 736 if(1 < verbose) { 357 if(1 < verbose) { 737 G4cout << " G4LossTableManager::BuildTab << 358 G4cout << "G4LossTableManager::BuildTables() for " 738 << aParticle->GetParticleName() << 359 << aParticle->GetParticleName() << G4endl; 739 } 360 } 740 361 741 std::vector<G4PhysicsTable*> t_list; << 362 // Check is it new particle or all tables have to be rebuilt 742 std::vector<G4VEnergyLossProcess*> loss_list << 363 G4std::vector<G4PhysicsTable*> list; 743 std::vector<G4bool> build_flags; << 364 list.clear(); 744 G4VEnergyLossProcess* em = nullptr; << 365 G4std::vector<G4VEnergyLossSTD*> loss_list; 745 G4VEnergyLossProcess* p = nullptr; << 366 loss_list.clear(); >> 367 G4VEnergyLossSTD* em = 0; 746 G4int iem = 0; 368 G4int iem = 0; 747 G4PhysicsTable* dedx = nullptr; << 369 G4bool no_el = true; 748 G4int i; << 749 370 750 G4ProcessVector* pvec = << 371 for(G4int i=0; i<n_loss; i++) { 751 aParticle->GetProcessManager()->GetProcess << 372 if(aParticle == part_vector[i]) { 752 G4int nvec = (G4int)pvec->size(); << 373 base_part_vector[i] = loss_vector[i]->BaseParticle(); 753 << 374 loss_vector[i]->Initialise(); 754 for (i=0; i<n_loss; ++i) { << 375 if(no_el && loss_vector[i]->SecondaryParticle() == theElectron) { 755 p = loss_vector[i]; << 376 em = loss_vector[i]; 756 if (nullptr != p) { << 377 iem= i; 757 G4bool yes = (aParticle == part_vector[i << 378 no_el = false; 758 << 379 } 759 // possible case of process sharing betw << 380 if(!em) { 760 if(!yes) { << 381 em = loss_vector[i]; 761 auto ptr = static_cast<G4VProcess*>(p) << 382 iem= i; 762 for(G4int j=0; j<nvec; ++j) { << 383 } 763 //G4cout << "j= " << j << " " << (*p << 384 tables_are_built[i] = true; 764 if(ptr == (*pvec)[j]) { << 385 list.push_back(loss_vector[i]->BuildDEDXTable()); 765 yes = true; << 386 loss_list.push_back(loss_vector[i]); 766 break; << 767 } << 768 } << 769 } << 770 // process belong to this particle << 771 if(yes && isActive[i]) { << 772 if (p->IsIonisationProcess() || !em) { << 773 em = p; << 774 iem= i; << 775 } << 776 // tables may be shared between partic << 777 G4bool val = false; << 778 if (!tables_are_built[i]) { << 779 val = true; << 780 dedx = p->BuildDEDXTable(fRestricted << 781 //G4cout << "===Build DEDX table for << 782 // << " idx= " << i << " dedx:" << d << 783 p->SetDEDXTable(dedx,fRestricted); << 784 tables_are_built[i] = true; << 785 } else { << 786 dedx = p->DEDXTable(); << 787 } << 788 t_list.push_back(dedx); << 789 loss_list.push_back(p); << 790 build_flags.push_back(val); << 791 } << 792 } 387 } 793 } 388 } 794 389 795 G4int n_dedx = (G4int)t_list.size(); << 390 G4int n_dedx = list.size(); 796 if (0 == n_dedx || !em) { << 391 if(!n_dedx) return 0; 797 G4cout << "G4LossTableManager WARNING: no << 798 << aParticle->GetParticleName() << << 799 return nullptr; << 800 } << 801 G4int nSubRegions = em->NumberOfSubCutoffReg << 802 << 803 if (1 < verbose) { << 804 G4cout << " Start to build the sum of << 805 << " iem= " << iem << " em= " << em << 806 << " buildCSDARange= " << theParame << 807 << " nSubRegions= " << nSubRegions; << 808 if(subcutProducer) { << 809 G4cout << " SubCutProducer " << subcutPr << 810 } << 811 G4cout << G4endl; << 812 } << 813 // do not build tables if producer class is << 814 if(subcutProducer) { nSubRegions = 0; } << 815 392 816 dedx = em->DEDXTable(); << 393 if(aParticle == theElectron) eIonisation = em; 817 em->SetDEDXTable(dedx, fIsIonisation); << 818 394 819 if (1 < n_dedx) { << 395 if(0 < verbose) { 820 dedx = nullptr; << 396 G4cout << "G4LossTableManager::BuildTables() start to build range tables" 821 dedx = G4PhysicsTableHelper::PreparePhysic << 397 << " and the sum of " << n_dedx << " processes" 822 tableBuilder->BuildDEDXTable(dedx, t_list) << 398 << G4endl; 823 em->SetDEDXTable(dedx, fRestricted); << 824 } 399 } 825 400 >> 401 G4PhysicsTable* dedx = list[0]; >> 402 if(1 < n_dedx) { >> 403 dedx = tableBuilder->BuildDEDXTable(list); >> 404 for(G4int i=0; i<n_dedx; i++) { >> 405 list[i]->clearAndDestroy(); >> 406 } >> 407 } >> 408 em->SetDEDXTable(dedx); 826 dedx_vector[iem] = dedx; 409 dedx_vector[iem] = dedx; 827 << 410 G4PhysicsTable* range = tableBuilder->BuildRangeTable(dedx); 828 G4PhysicsTable* range = em->RangeTableForLos << 411 em->SetRangeTable(range); 829 if(!range) range = G4PhysicsTableHelper::Pr << 830 range_vector[iem] = range; 412 range_vector[iem] = range; 831 << 413 G4PhysicsTable* invrange = tableBuilder->BuildInverseRangeTable(dedx, range); 832 G4PhysicsTable* invrange = em->InverseRangeT << 833 if(!invrange) invrange = G4PhysicsTableHelpe << 834 inv_range_vector[iem] = invrange; << 835 << 836 tableBuilder->BuildRangeTable(dedx, range); << 837 tableBuilder->BuildInverseRangeTable(range, << 838 << 839 em->SetRangeTableForLoss(range); << 840 em->SetInverseRangeTable(invrange); 414 em->SetInverseRangeTable(invrange); >> 415 inv_range_vector[iem] = invrange; 841 416 842 std::vector<G4PhysicsTable*> listCSDA; << 417 loss_map[aParticle] = em; 843 << 418 for(G4int j=0; j<n_dedx; j++) { 844 for (i=0; i<n_dedx; ++i) { << 419 if(loss_list[j]->SecondaryParticle() == theElectron) { 845 p = loss_list[i]; << 420 loss_list[j]->SetSecondaryRangeTable(eIonisation->RangeTable()); 846 if(build_flags[i]) { << 847 p->SetLambdaTable(p->BuildLambdaTable(fR << 848 } << 849 if(theParameters->BuildCSDARange()) { << 850 dedx = p->BuildDEDXTable(fTotal); << 851 p->SetDEDXTable(dedx,fTotal); << 852 listCSDA.push_back(dedx); << 853 } << 854 } << 855 << 856 if(theParameters->BuildCSDARange()) { << 857 G4PhysicsTable* dedxCSDA = em->DEDXunRestr << 858 if (1 < n_dedx) { << 859 dedxCSDA = G4PhysicsTableHelper::Prepare << 860 tableBuilder->BuildDEDXTable(dedxCSDA, l << 861 em->SetDEDXTable(dedxCSDA,fTotal); << 862 } 421 } 863 G4PhysicsTable* rCSDA = em->CSDARangeTable << 864 if(!rCSDA) { rCSDA = G4PhysicsTableHelper: << 865 tableBuilder->BuildRangeTable(dedxCSDA, rC << 866 em->SetCSDARangeTable(rCSDA); << 867 } 422 } 868 << 423 if(1 < verbose) { 869 if (1 < verbose) { << 424 G4cout << "G4LossTableManager::BuildTables: Tables are built" 870 G4cout << "G4LossTableManager::BuildTables << 425 << " for " << em->GetProcessName() 871 << aParticle->GetParticleName() << 872 << "; ionisation process: " << em-> << 873 << " " << em << 874 << G4endl; 426 << G4endl; 875 } 427 } 876 return em; 428 return em; 877 } 429 } 878 430 879 //....oooOO0OOooo........oooOO0OOooo........oo << 880 << 881 void G4LossTableManager::ParticleHaveNoLoss( << 882 const G4ParticleDefinition* aParticle) << 883 { << 884 G4ExceptionDescription ed; << 885 ed << "Energy loss process not found for " < << 886 << " !"; << 887 G4Exception("G4LossTableManager::ParticleHav << 888 FatalException, ed); << 889 } << 890 << 891 //....oooOO0OOooo........oooOO0OOooo........oo << 892 << 893 void G4LossTableManager::SetVerbose(G4int val) << 894 { << 895 verbose = val; << 896 } << 897 << 898 //....oooOO0OOooo........oooOO0OOooo........oo << 899 << 900 const std::vector<G4VEnergyLossProcess*>& << 901 G4LossTableManager::GetEnergyLossProcessVector << 902 { << 903 return loss_vector; << 904 } << 905 << 906 //....oooOO0OOooo........oooOO0OOooo........oo << 907 << 908 const std::vector<G4VEmProcess*>& G4LossTableM << 909 { << 910 return emp_vector; << 911 } << 912 << 913 //....oooOO0OOooo........oooOO0OOooo........oo << 914 << 915 const std::vector<G4VMultipleScattering*>& << 916 G4LossTableManager::GetMultipleScatteringVecto << 917 { << 918 return msc_vector; << 919 } << 920 << 921 //....oooOO0OOooo........oooOO0OOooo........oo 431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 922 432 923 G4EmSaturation* G4LossTableManager::EmSaturati << 433 void G4LossTableManager::SetLossFluctuations(G4bool val) 924 { 434 { 925 return theParameters->GetEmSaturation(); << 435 lossFluctuationFlag = val; >> 436 for(G4int i=0; i<n_loss; i++) { >> 437 loss_vector[i]->SetLossFluctuations(val); >> 438 } 926 } 439 } 927 440 928 //....oooOO0OOooo........oooOO0OOooo........oo 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 929 442 930 G4EmConfigurator* G4LossTableManager::EmConfig << 443 void G4LossTableManager::SetSubCutoff(G4bool val) 931 { 444 { 932 if(!emConfigurator) { << 445 subCutoffFlag = val; 933 emConfigurator = new G4EmConfigurator(verb << 446 for(G4int i=0; i<n_loss; i++) { >> 447 loss_vector[i]->SetSubCutoff(val); 934 } 448 } 935 return emConfigurator; << 936 } 449 } 937 450 938 //....oooOO0OOooo........oooOO0OOooo........oo 451 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 939 452 940 G4ElectronIonPair* G4LossTableManager::Electro << 453 void G4LossTableManager::SetIntegral(G4bool val) 941 { 454 { 942 if(!emElectronIonPair) { << 455 integral = val; 943 emElectronIonPair = new G4ElectronIonPair( << 456 for(G4int i=0; i<n_loss; i++) { >> 457 loss_vector[i]->SetIntegral(val); 944 } 458 } 945 return emElectronIonPair; << 946 } 459 } 947 460 948 //....oooOO0OOooo........oooOO0OOooo........oo 461 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 949 462 950 void G4LossTableManager::SetNIELCalculator(G4N << 463 void G4LossTableManager::SetMinSubRange(G4double val) 951 { 464 { 952 if(nullptr != ptr && ptr != nielCalculator) << 465 minSubRange = val; 953 delete nielCalculator; << 466 for(G4int i=0; i<n_loss; i++) { 954 nielCalculator = ptr; << 467 loss_vector[i]->SetMinSubRange(val); 955 } 468 } 956 } 469 } 957 470 958 //....oooOO0OOooo........oooOO0OOooo........oo 471 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 959 472 960 G4NIELCalculator* G4LossTableManager::NIELCalc << 473 void G4LossTableManager::SetRandomStep(G4bool val) 961 { 474 { 962 if(!nielCalculator) { << 475 rndmStepFlag = val; 963 nielCalculator = new G4NIELCalculator(null << 476 for(G4int i=0; i<n_loss; i++) { >> 477 loss_vector[i]->SetRandomStep(val); 964 } 478 } 965 return nielCalculator; << 966 } 479 } 967 480 968 //....oooOO0OOooo........oooOO0OOooo........oo << 481 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 969 << 482 970 void G4LossTableManager::SetAtomDeexcitation(G << 483 void G4LossTableManager::SetMinEnergy(G4double val) 971 { 484 { 972 if(atomDeexcitation != p) { << 485 minKinEnergy = val; 973 delete atomDeexcitation; << 486 for(G4int i=0; i<n_loss; i++) { 974 atomDeexcitation = p; << 487 loss_vector[i]->SetMinKinEnergy(val); 975 } 488 } 976 } 489 } 977 490 978 //....oooOO0OOooo........oooOO0OOooo........oo << 491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 979 492 980 void G4LossTableManager::SetSubCutProducer(G4V << 493 void G4LossTableManager::SetMaxEnergy(G4double val) 981 { 494 { 982 if(subcutProducer != p) { << 495 maxKinEnergy = val; 983 delete subcutProducer; << 496 for(G4int i=0; i<n_loss; i++) { 984 subcutProducer = p; << 497 loss_vector[i]->SetMaxKinEnergy(val); 985 } 498 } 986 } 499 } 987 500 988 //....oooOO0OOooo........oooOO0OOooo........oo << 501 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 989 502 990 void G4LossTableManager::PrintEWarning(G4Strin << 503 void G4LossTableManager::SetStepLimits(G4double v1, G4double v2) 991 { 504 { 992 G4String ss = "G4LossTableManager::" + tit; << 505 maxRangeVariation = v1; 993 G4ExceptionDescription ed; << 506 maxFinalStep = v2; 994 /* << 507 for(G4int i=0; i<n_loss; i++) { 995 ed << "Parameter is out of range: " << val << 508 loss_vector[i]->SetStepLimits(v1, v2); 996 << " it will have no effect!\n" << " ## " << 509 } 997 << " nbins= " << nbinsLambda << 998 << " nbinsPerDecade= " << nbinsPerDecade << 999 << " Emin(keV)= " << minKinEnergy/keV << 1000 << " Emax(GeV)= " << maxKinEnergy/GeV; << 1001 */ << 1002 G4Exception(ss, "em0044", JustWarning, ed); << 1003 } 510 } 1004 511 1005 //....oooOO0OOooo........oooOO0OOooo........o 512 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1006 513 1007 void G4LossTableManager::DumpHtml() << 514 G4bool G4LossTableManager::StorePhysicsTable(G4VEnergyLossSTD* el, 1008 { << 515 const G4String& dedx_file, 1009 // Automatic generation of html documentati << 516 const G4String& range_file, 1010 // List processes and models for the most i << 517 const G4String& inv_range_file, 1011 // particles in descending order of importa << 518 G4bool ascii) 1012 // NB. for model names with length > 18 cha << 519 { 1013 // to be edited by hand. Or modify G4EmMod << 520 G4int i=0; 1014 << 521 for(i=0; i<n_loss; i++) { 1015 char* dirName = std::getenv("G4PhysListDocD << 522 if(el == loss_vector[i]) break; 1016 char* physList = std::getenv("G4PhysListNam << 523 } 1017 if (dirName && physList) { << 524 1018 G4String physListName = G4String(physList << 525 // store stopping power table 1019 G4String pathName = G4String(dirName) + " << 526 if (dedx_vector[i]) { 1020 << 527 if ( !dedx_vector[i]->StorePhysicsTable(dedx_file, ascii) ){ 1021 std::ofstream outFile; << 528 G4cout << "Fatal error theDEDXTable->StorePhysicsTable in <" 1022 outFile.open(pathName); << 529 << dedx_file << ">" 1023 << 530 << G4endl; 1024 outFile << physListName << G4endl; << 531 return false; 1025 outFile << std::string(physListName.lengt << 532 } 1026 << 533 } 1027 std::vector<G4ParticleDefinition*> partic << 1028 G4Gamma::Gamma(), << 1029 G4Electron::Electron(), << 1030 G4Positron::Positron(), << 1031 G4Proton::ProtonDefinition(), << 1032 G4MuonPlus::MuonPlusDefinition(), << 1033 G4MuonMinus::MuonMinusDefinition(), << 1034 }; << 1035 << 1036 std::vector<G4VEmProcess*> emproc_vector << 1037 std::vector<G4VEnergyLossProcess*> enloss << 1038 GetEnergyLossProcessVector(); << 1039 std::vector<G4VMultipleScattering*> mscat << 1040 GetMultipleScatteringVector(); << 1041 << 1042 for (auto theParticle : particles) { << 1043 outFile << G4endl << "**" << theParticl << 1044 << "**" << G4endl << G4endl << << 1045 << 1046 G4ProcessManager* pm = theParticle->Get << 1047 G4ProcessVector* pv = pm->GetProcessLi << 1048 G4int plen = pm->GetProcessListLength() << 1049 << 1050 for (auto emproc : emproc_vector) { << 1051 for (G4int i = 0; i < plen; ++i) { << 1052 G4VProcess* proc = (*pv)[i]; << 1053 if (proc == emproc) { << 1054 outFile << G4endl; << 1055 proc->ProcessDescription(outFile) << 1056 break; << 1057 } << 1058 } << 1059 } << 1060 << 1061 for (auto mscproc : mscat_vector) { << 1062 for (G4int i = 0; i < plen; ++i) { << 1063 G4VProcess* proc = (*pv)[i]; << 1064 if (proc == mscproc) { << 1065 outFile << G4endl; << 1066 proc->ProcessDescription(outFile) << 1067 break; << 1068 } << 1069 } << 1070 } << 1071 534 1072 for (auto enlossproc : enloss_vector) { << 535 if (range_vector[i]) { 1073 for (G4int i = 0; i < plen; ++i) { << 536 if ( !range_vector[i]->StorePhysicsTable(range_file, ascii) ){ 1074 G4VProcess* proc = (*pv)[i]; << 537 G4cout << "Fatal error theRangeTable->StorePhysicsTable in <" 1075 if (proc == enlossproc) { << 538 << range_file << ">" 1076 outFile << G4endl; << 539 << G4endl; 1077 proc->ProcessDescription(outFile) << 540 return false; 1078 break; << 541 } 1079 } << 542 } 1080 } << 543 1081 } << 544 if (inv_range_vector[i]) { >> 545 if ( !inv_range_vector[i]->StorePhysicsTable(inv_range_file, ascii) ){ >> 546 G4cout << "Fatal error theInverseRangeTable->StorePhysicsTable in <" >> 547 << inv_range_file << ">" >> 548 << G4endl; >> 549 return false; 1082 } 550 } 1083 outFile.close(); << 1084 } 551 } 1085 } << 552 return true; >> 553 } >> 554 >> 555 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 1086 556 1087 //....oooOO0OOooo........oooOO0OOooo........o << 1088 557 1089 558