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 // 36 // >> 37 // 20-01-03 Migrade to cut per region (V.Ivanchenko) >> 38 // 15-02-03 Lambda table can be scaled (V.Ivanchenko) >> 39 // 17-02-03 Fix problem of store/restore tables (V.Ivanchenko) >> 40 // 10-03-03 Add Ion registration (V.Ivanchenko) >> 41 // 25-03-03 Add deregistration (V.Ivanchenko) >> 42 // 02-04-03 Change messenger (V.Ivanchenko) >> 43 // 26-04-03 Fix retrieve tables (V.Ivanchenko) >> 44 // 13-05-03 Add calculation of precise range (V.Ivanchenko) 39 // 45 // 40 // Class Description: 46 // Class Description: 41 // 47 // 42 // ------------------------------------------- 48 // ------------------------------------------------------------------- 43 // 49 // 44 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 52 47 #include "G4LossTableManager.hh" 53 #include "G4LossTableManager.hh" 48 #include "G4SystemOfUnits.hh" << 54 #include "G4EnergyLossMessenger.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" 55 #include "G4PhysicsTable.hh" 64 #include "G4ParticleDefinition.hh" 56 #include "G4ParticleDefinition.hh" 65 #include "G4MaterialCutsCouple.hh" 57 #include "G4MaterialCutsCouple.hh" 66 #include "G4ProcessManager.hh" 58 #include "G4ProcessManager.hh" 67 #include "G4Electron.hh" 59 #include "G4Electron.hh" 68 #include "G4Proton.hh" << 60 #include "G4VMultipleScattering.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 61 83 //....oooOO0OOooo........oooOO0OOooo........oo << 62 G4LossTableManager* G4LossTableManager::theInstance = 0; 84 63 85 static std::once_flag applyOnce; << 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 86 G4ThreadLocal G4LossTableManager* G4LossTableM << 87 65 88 G4LossTableManager* G4LossTableManager::Instan 66 G4LossTableManager* G4LossTableManager::Instance() 89 { 67 { 90 if(nullptr == instance) { << 68 if(0 == theInstance) { 91 static G4ThreadLocalSingleton<G4LossTableM << 69 theInstance = new G4LossTableManager(); 92 instance = inst.Instance(); << 93 } 70 } 94 return instance; << 71 return theInstance; 95 } 72 } 96 73 97 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 98 75 99 G4LossTableManager::~G4LossTableManager() 76 G4LossTableManager::~G4LossTableManager() 100 { 77 { 101 for (auto const & p : loss_vector) { delete << 78 for (G4int i=0; i<n_loss; i++) { 102 for (auto const & p : msc_vector) { delete p << 79 if( loss_vector[i] ) delete loss_vector[i]; 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 } 80 } 119 for (auto const & p : fmod_vector) { delete << 81 size_t msc = msc_vector.size(); 120 << 82 for (size_t j=0; j<msc; j++) { 121 Clear(); << 83 if(msc_vector[j] ) delete msc_vector[j]; >> 84 } Clear(); >> 85 delete theMessenger; 122 delete tableBuilder; 86 delete tableBuilder; 123 delete emCorrections; << 124 delete emConfigurator; << 125 delete emElectronIonPair; << 126 delete nielCalculator; << 127 delete atomDeexcitation; << 128 delete subcutProducer; << 129 } 87 } 130 88 131 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 132 90 133 G4LossTableManager::G4LossTableManager() 91 G4LossTableManager::G4LossTableManager() 134 { 92 { 135 theParameters = G4EmParameters::Instance(); << 93 n_loss = 0; 136 theElectron = G4Electron::Electron(); << 94 first_entry = true; 137 << 95 all_tables_are_built = false; 138 // only one thread is the master << 96 all_tables_are_stored = false; 139 std::call_once(applyOnce, [this]() { isMaste << 97 electron_table_are_built = false; 140 verbose = isMaster ? theParameters->Verbose( << 98 currentLoss = 0; 141 << 99 currentParticle = 0; 142 tableBuilder = new G4LossTableBuilder(isMast << 100 lossFluctuationFlag = true; 143 emCorrections = new G4EmCorrections(verbose) << 101 subCutoffFlag = false; 144 << 102 rndmStepFlag = false; 145 std::size_t n = 70; << 103 minSubRange = 0.0; 146 loss_vector.reserve(n); << 104 maxRangeVariation = 1.0; 147 part_vector.reserve(n); << 105 maxFinalStep = 0.0; 148 base_part_vector.reserve(n); << 106 eIonisation = 0; 149 dedx_vector.reserve(n); << 107 minKinEnergy = 0.1*eV; 150 range_vector.reserve(n); << 108 maxKinEnergy = 100.0*GeV; 151 inv_range_vector.reserve(n); << 109 theMessenger = new G4EnergyLossMessenger(); 152 tables_are_built.reserve(n); << 110 theElectron = G4Electron::Electron(); 153 isActive.reserve(n); << 111 tableBuilder = new G4LossTableBuilder(); 154 msc_vector.reserve(10); << 112 integral = true; 155 emp_vector.reserve(16); << 113 integralActive = false; 156 mod_vector.reserve(150); << 114 buildPreciseRange = false; 157 fmod_vector.reserve(60); << 115 minEnergyActive = false; >> 116 maxEnergyActive = false; >> 117 verbose = 0; 158 } 118 } 159 119 160 //....oooOO0OOooo........oooOO0OOooo........oo 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 161 121 162 void G4LossTableManager::Clear() 122 void G4LossTableManager::Clear() 163 { 123 { 164 all_tables_are_built = false; 124 all_tables_are_built = false; 165 currentLoss = nullptr; << 125 electron_table_are_built = false; 166 currentParticle = nullptr; << 126 eIonisation = 0; 167 if(n_loss) { << 127 currentLoss = 0; 168 dedx_vector.clear(); << 128 currentParticle = 0; 169 range_vector.clear(); << 129 if(n_loss) 170 inv_range_vector.clear(); << 130 { 171 loss_map.clear(); << 131 dedx_vector.clear(); 172 loss_vector.clear(); << 132 range_vector.clear(); 173 part_vector.clear(); << 133 inv_range_vector.clear(); 174 base_part_vector.clear(); << 134 loss_map.clear(); 175 tables_are_built.clear(); << 135 loss_vector.clear(); 176 isActive.clear(); << 136 part_vector.clear(); 177 n_loss = 0; << 137 base_part_vector.clear(); 178 } << 138 tables_are_built.clear(); >> 139 n_loss = 0; >> 140 } 179 } 141 } 180 142 181 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 182 144 183 void G4LossTableManager::Register(G4VEnergyLos << 145 void G4LossTableManager::Register(G4VEnergyLossSTD* p) 184 { 146 { 185 if (nullptr == p) { return; } << 147 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); 148 loss_vector.push_back(p); 195 part_vector.push_back(nullptr); << 149 part_vector.push_back(0); 196 base_part_vector.push_back(nullptr); << 150 base_part_vector.push_back(0); 197 dedx_vector.push_back(nullptr); << 151 dedx_vector.push_back(0); 198 range_vector.push_back(nullptr); << 152 range_vector.push_back(0); 199 inv_range_vector.push_back(nullptr); << 153 inv_range_vector.push_back(0); 200 tables_are_built.push_back(false); 154 tables_are_built.push_back(false); 201 isActive.push_back(true); << 202 all_tables_are_built = false; 155 all_tables_are_built = false; >> 156 if(integralActive) p->SetIntegral(integral); >> 157 if(minEnergyActive) p->SetMinKinEnergy(minKinEnergy); >> 158 if(maxEnergyActive) p->SetMaxKinEnergy(maxKinEnergy); 203 } 159 } 204 160 205 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 206 162 207 void G4LossTableManager::ResetParameters() << 163 void G4LossTableManager::DeRegister(G4VEnergyLossSTD* p) 208 { 164 { 209 // initialisation once per run << 165 for (G4int i=0; i<n_loss; i++) { 210 if (!resetParam) { return; } << 166 if(loss_vector[i] == p) loss_vector[i] = 0; 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 } 167 } 249 } 168 } 250 169 251 //....oooOO0OOooo........oooOO0OOooo........oo 170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 252 171 253 void G4LossTableManager::Register(G4VMultipleS 172 void G4LossTableManager::Register(G4VMultipleScattering* p) 254 { 173 { 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); 174 msc_vector.push_back(p); 265 } 175 } 266 176 267 //....oooOO0OOooo........oooOO0OOooo........oo 177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 268 178 269 void G4LossTableManager::DeRegister(G4VMultipl 179 void G4LossTableManager::DeRegister(G4VMultipleScattering* p) 270 { 180 { 271 if (nullptr == p) { return; } << 181 size_t msc = msc_vector.size(); 272 std::size_t msc = msc_vector.size(); << 182 for (size_t i=0; i<msc; i++) { 273 for (std::size_t i=0; i<msc; ++i) { << 183 if(msc_vector[i] == p) msc_vector[i] = 0; 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 } 184 } 294 emp_vector.push_back(p); << 295 } 185 } 296 186 297 //....oooOO0OOooo........oooOO0OOooo........oo 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 298 188 299 void G4LossTableManager::DeRegister(G4VEmProce << 189 void G4LossTableManager::RegisterIon(const G4ParticleDefinition* ion, G4VEnergyLossSTD* p) 300 { 190 { 301 if (nullptr == p) { return; } << 191 loss_map[ion] = p; 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 } 192 } 310 193 311 //....oooOO0OOooo........oooOO0OOooo........oo 194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 312 195 313 void G4LossTableManager::Register(G4VProcess* << 196 G4EnergyLossMessenger* G4LossTableManager::GetMessenger() 314 { 197 { 315 if (nullptr == p) { return; } << 198 return theMessenger; 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 } 199 } 326 200 327 //....oooOO0OOooo........oooOO0OOooo........oo 201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 328 202 329 void G4LossTableManager::DeRegister(G4VProcess << 203 void G4LossTableManager::ParticleHaveNoLoss(const G4ParticleDefinition* aParticle) 330 { 204 { 331 if (nullptr == p) { return; } << 205 G4String s = "G4LossTableManager:: dE/dx table not found for " 332 std::size_t emp = p_vector.size(); << 206 + aParticle->GetParticleName() + "!"; 333 for (std::size_t i=0; i<emp; ++i) { << 207 G4Exception(s); 334 if(p_vector[i] == p) { << 208 exit(1); 335 p_vector[i] = nullptr; << 336 break; << 337 } << 338 } << 339 } 209 } 340 210 341 //....oooOO0OOooo........oooOO0OOooo........oo << 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 342 212 343 void G4LossTableManager::Register(G4VEmModel* << 213 void G4LossTableManager::Initialise(const G4ParticleDefinition* aParticle) 344 { 214 { 345 mod_vector.push_back(p); << 215 if (first_entry) { 346 if(verbose > 1) { << 216 first_entry = false; 347 G4cout << "G4LossTableManager::Register G4 << 217 firstParticle = aParticle; 348 << p->GetName() << " " << p << " << 349 } 218 } 350 } << 351 219 352 //....oooOO0OOooo........oooOO0OOooo........oo << 220 for(G4int j=0; j<n_loss; j++) { 353 221 354 void G4LossTableManager::DeRegister(G4VEmModel << 222 const G4ParticleDefinition* pd = loss_vector[j]->Particle(); 355 { << 223 if (!pd) { 356 //G4cout << "G4LossTableManager::DeRegister << 224 pd = loss_vector[j]->GetProcessManager()->GetParticleType(); 357 std::size_t n = mod_vector.size(); << 225 loss_vector[j]->SetParticle(pd); 358 for (std::size_t i=0; i<n; ++i) { << 359 if(mod_vector[i] == p) { << 360 mod_vector[i] = nullptr; << 361 break; << 362 } 226 } 363 } << 227 if(!tables_are_built[j]) all_tables_are_built = false; 364 } << 228 if(pd != part_vector[j]) { 365 << 229 part_vector[j] = pd; 366 //....oooOO0OOooo........oooOO0OOooo........oo << 230 base_part_vector[j] = loss_vector[j]->BaseParticle(); 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 << 415 G4VEnergyLossProcess* << 416 G4LossTableManager::GetEnergyLossProcess(const << 417 { << 418 if(aParticle != currentParticle) { << 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 } 231 } 430 } << 232 if(1 < verbose) { 431 return currentLoss; << 233 G4String nm = "unknown"; 432 } << 234 if(pd) nm = pd->GetParticleName(); 433 << 235 G4cout << "For " << loss_vector[j]->GetProcessName() 434 //....oooOO0OOooo........oooOO0OOooo........oo << 236 << " for " << nm 435 << 237 << " tables_are_built= " << tables_are_built[j] 436 void << 238 << " procFlag= " << loss_vector[j]->TablesAreBuilt() 437 G4LossTableManager::PreparePhysicsTable(const << 239 << " all_tables_are_built= " << all_tables_are_built 438 G4VEne << 240 << G4endl; 439 { << 440 if (1 < verbose) { << 441 G4cout << "G4LossTableManager::PreparePhys << 442 << particle->GetParticleName() << 443 << " and " << p->GetProcessName() < << 444 << " loss_vector " << loss_vector << 445 << " run=" << run << " master=" << isMast << 446 << G4endl; << 447 } << 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 } << 461 } 241 } 462 } 242 } 463 ResetParameters(); << 464 } << 465 << 466 //....oooOO0OOooo........oooOO0OOooo........oo << 467 243 468 void << 244 // All tables have to be rebuilt 469 G4LossTableManager::PreparePhysicsTable(const << 245 if (all_tables_are_built && firstParticle == aParticle) { 470 G4VEmP << 246 for (G4int i=0; i<n_loss; i++) { 471 { << 247 tables_are_built[i] = false; 472 if (1 < verbose) { << 248 } 473 G4cout << "G4LossTableManager::PreparePhys << 249 all_tables_are_built = false; 474 << particle->GetParticleName() << 250 electron_table_are_built = false; 475 << " and " << p->GetProcessName() << 251 loss_map.clear(); 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 } 252 } 484 253 485 ResetParameters(); << 254 if(1 < verbose) { 486 } << 255 G4cout << "electron_table_are_built= " << electron_table_are_built 487 << 256 << " all_tables_are_built= " << all_tables_are_built 488 //....oooOO0OOooo........oooOO0OOooo........oo << 257 << G4endl; 489 << 490 void << 491 G4LossTableManager::PreparePhysicsTable(const << 492 G4VMul << 493 { << 494 if (1 < verbose) { << 495 G4cout << "G4LossTableManager::PreparePhys << 496 << particle->GetParticleName() << 497 << " and " << p->GetProcessName() << 498 << " run=" << run << " master=" << isMast << 499 << G4endl; << 500 } 258 } 501 259 502 // start initialisation for the first run << 503 if ( -1 == run ) { << 504 if (nullptr != emConfigurator) { emConfigu << 505 } << 506 << 507 ResetParameters(); << 508 } 260 } 509 261 510 //....oooOO0OOooo........oooOO0OOooo........oo << 262 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 511 263 512 void << 264 void G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition* aParticle) 513 G4LossTableManager::BuildPhysicsTable(const G4 << 514 { 265 { 515 if(-1 == run && startInitialisation) { << 516 if (nullptr != emConfigurator) { emConfigu << 517 } << 518 if (startInitialisation) { resetParam = true << 519 } << 520 266 521 //....oooOO0OOooo........oooOO0OOooo........oo << 267 if(0 < verbose) { 522 << 268 G4cout << "G4LossTableManager::BuildDEDXTable() for " 523 void G4LossTableManager::LocalPhysicsTables( << 524 const G4ParticleDefinition* aParticle, << 525 G4VEnergyLossProcess* p) << 526 { << 527 if (1 < verbose) { << 528 G4cout << "### G4LossTableManager::LocalPh << 529 << aParticle->GetParticleName() 269 << aParticle->GetParticleName() 530 << " and process " << p->GetProcess << 531 << G4endl; 270 << G4endl; 532 } 271 } 533 272 534 if(-1 == run && startInitialisation) { << 273 Initialise(aParticle); 535 if (nullptr != emConfigurator) { emConfigu << 536 firstParticle = aParticle; << 537 } << 538 274 539 if (startInitialisation) { << 275 // identify all particles and built electron table 540 ++run; << 276 if(!electron_table_are_built) { 541 if (1 < verbose) { << 277 eIonisation = BuildTables(theElectron); 542 G4cout << "===== G4LossTableManager::Loc << 278 currentLoss = eIonisation; 543 << run << " =====" << G4endl; << 279 currentParticle = theElectron; 544 } << 280 electron_table_are_built = true; 545 currentParticle = nullptr; << 281 } 546 startInitialisation = false; << 282 547 resetParam = true; << 283 // If particle is not an electron 548 for (G4int i=0; i<n_loss; ++i) { << 284 if(aParticle != theElectron) { 549 if (nullptr != loss_vector[i]) { << 285 for(G4int i=0; i<n_loss; i++) { 550 tables_are_built[i] = false; << 286 551 } else { << 287 if(aParticle == part_vector[i]) { 552 tables_are_built[i] = true; << 288 if(tables_are_built[i]) break; 553 part_vector[i] = nullptr; << 289 if(!base_part_vector[i]) { >> 290 G4VEnergyLossSTD* hIonisation = BuildTables(aParticle); >> 291 for(G4int j=0; j<i; j++) { >> 292 if (aParticle == base_part_vector[j]) { >> 293 tables_are_built[j] = true; >> 294 G4VEnergyLossSTD* em = loss_vector[j]; >> 295 em->Initialise(); >> 296 em->SetDEDXTable(hIonisation->DEDXTable()); >> 297 em->SetRangeTable(hIonisation->RangeTable()); >> 298 em->SetInverseRangeTable(hIonisation->InverseRangeTable()); >> 299 em->SetLambdaTable(hIonisation->LambdaTable()); >> 300 em->SetSubLambdaTable(hIonisation->SubLambdaTable()); >> 301 loss_map[part_vector[j]] = em; >> 302 if (em->SecondaryParticle() == theElectron) { >> 303 em->SetSecondaryRangeTable(eIonisation->RangeTable()); >> 304 } >> 305 if (0 < verbose) { >> 306 G4cout << "For " << loss_vector[j]->GetProcessName() >> 307 << " for " << part_vector[j]->GetParticleName() >> 308 << " base_part= " << base_part_vector[j]->GetParticleName() >> 309 << " tables_are_built= " << G4endl; >> 310 } >> 311 } >> 312 } >> 313 } else { >> 314 G4VEnergyLossSTD* em = loss_vector[i]; >> 315 for(G4int j=0; j<n_loss; j++) { >> 316 if (tables_are_built[j] && part_vector[j] == base_part_vector[i]) { >> 317 G4VEnergyLossSTD* hIonisation = loss_vector[j]; >> 318 tables_are_built[i] = true; >> 319 em->Initialise(); >> 320 em->SetDEDXTable(hIonisation->DEDXTable()); >> 321 em->SetRangeTable(hIonisation->RangeTable()); >> 322 em->SetInverseRangeTable(hIonisation->InverseRangeTable()); >> 323 em->SetLambdaTable(hIonisation->LambdaTable()); >> 324 em->SetSubLambdaTable(hIonisation->SubLambdaTable()); >> 325 loss_map[part_vector[i]] = em; >> 326 if (em->SecondaryParticle() == theElectron) >> 327 em->SetSecondaryRangeTable(eIonisation->RangeTable()); >> 328 if (0 < verbose) { >> 329 G4cout << "For " << em->GetProcessName() >> 330 << " for " << part_vector[i]->GetParticleName() >> 331 << " base_part= " << base_part_vector[i]->GetParticleName() >> 332 << " tables_are_built= " << G4endl; >> 333 } >> 334 break; >> 335 } >> 336 } >> 337 } >> 338 break; 554 } 339 } 555 } 340 } 556 } 341 } 557 342 558 all_tables_are_built= true; << 343 all_tables_are_built = true; 559 for (G4int i=0; i<n_loss; ++i) { << 344 for (G4int ii=0; ii<n_loss; ii++) { 560 if(p == loss_vector[i]) { << 345 if ( !tables_are_built[ii] ) { 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 << 572 if(1 < verbose) { << 573 G4cout << i <<". "<< p->GetProcessNa << 574 if(part_vector[i]) { << 575 G4cout << " for " << part_vector[i << 576 } << 577 G4cout << " active= " << isActive[i] << 578 << " table= " << tables_are_bu << 579 << " isIonisation= " << p->IsI << 580 << G4endl; << 581 } << 582 break; << 583 } else if(!tables_are_built[i]) { << 584 all_tables_are_built = false; 346 all_tables_are_built = false; >> 347 break; 585 } 348 } 586 } 349 } 587 350 588 if(1 < verbose) { 351 if(1 < verbose) { 589 G4cout << "### G4LossTableManager::LocalPh << 352 G4cout << "G4LossTableManager::BuildDEDXTable: end; " >> 353 << "all_tables_are_built= " << all_tables_are_built 590 << G4endl; 354 << G4endl; 591 } 355 } 592 if(all_tables_are_built) { << 593 if(1 < verbose) { << 594 G4cout << "%%%%% All dEdx and Range tabl << 595 << run << " %%%%%" << G4endl; << 596 } << 597 } << 598 } 356 } 599 357 600 //....oooOO0OOooo........oooOO0OOooo........oo << 358 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 601 359 602 void G4LossTableManager::BuildPhysicsTable( << 360 void G4LossTableManager::RetrievePhysicsTables(const G4ParticleDefinition* aParticle, 603 const G4ParticleDefinition* aParticle, << 361 G4VEnergyLossSTD* theLoss) 604 G4VEnergyLossProcess* p) << 605 { 362 { 606 if(1 < verbose) { << 363 if(0 < verbose) { 607 G4cout << "### G4LossTableManager::BuildPh << 364 G4cout << "G4LossTableManager::RetrievePhysicsTable() for " 608 << aParticle->GetParticleName() 365 << aParticle->GetParticleName() 609 << " and process " << p->GetProcess << 366 << G4endl; 610 } 367 } 611 // clear configurator << 368 if (first_entry) Initialise(aParticle); 612 if(-1 == run && startInitialisation) { << 369 if (all_tables_are_built) return; 613 if( nullptr != emConfigurator) { emConfigu << 614 firstParticle = aParticle; << 615 } << 616 if(startInitialisation) { << 617 ++run; << 618 resetParam = true; << 619 startInitialisation = false; << 620 if(1 < verbose) { << 621 G4cout << "===== G4LossTableManager::Bui << 622 << run << " ===== " << atomDeexci << 623 } << 624 currentParticle = nullptr; << 625 all_tables_are_built = false; << 626 370 627 for (G4int i=0; i<n_loss; ++i) { << 371 G4bool hasRange = false; 628 G4VEnergyLossProcess* el = loss_vector[i << 372 for (G4int i=0; i<n_loss; i++) { 629 << 373 if ( theLoss == loss_vector[i] ) { 630 if(nullptr != el) { << 374 tables_are_built[i] = true; 631 isActive[i] = true; << 375 if (theLoss->RangeTable()) { 632 part_vector[i] = el->Particle(); << 376 if (part_vector[i] == theElectron) { 633 base_part_vector[i] = el->BaseParticle << 377 eIonisation = theLoss; 634 tables_are_built[i] = false; << 378 currentLoss = theLoss; 635 if(1 < verbose) { << 379 currentParticle = theElectron; 636 G4cout << i <<". "<< el->GetProces << 380 electron_table_are_built = true; 637 if(el->Particle()) { << 381 } 638 G4cout << " for " << el->Particl << 382 loss_map[part_vector[i]] = theLoss; 639 } << 383 hasRange = true; 640 G4cout << " active= " << isActive[i << 384 if (0 < verbose) { 641 << " table= " << tables_are_ << 385 G4cout << "dEdx and Range tables are defined for " 642 << " isIonisation= " << el-> << 386 << aParticle->GetParticleName() 643 if(base_part_vector[i]) { << 387 << G4endl; 644 G4cout << " base particle " << 645 << base_part_vector[i]->Get << 646 } << 647 G4cout << G4endl; << 648 } 388 } 649 } else { << 650 tables_are_built[i] = true; << 651 part_vector[i] = nullptr; << 652 isActive[i] = false; << 653 } 389 } 654 } 390 } 655 } << 391 if (electron_table_are_built && theLoss->SecondaryParticle() == theElectron) 656 << 392 theLoss->SetSecondaryRangeTable(eIonisation->RangeTable()); 657 if (all_tables_are_built) { << 393 } 658 theParameters->SetIsPrintedFlag(true); << 394 659 return; << 395 if ( hasRange ) { 660 } << 396 for (G4int j=0; j<n_loss; j++) { 661 << 397 if ( base_part_vector[j] == aParticle && !tables_are_built[j] ) { 662 // Build tables for given particle << 398 G4VEnergyLossSTD* em = loss_vector[j]; 663 all_tables_are_built = true; << 399 tables_are_built[j] = true; 664 << 400 em->Initialise(); 665 for(G4int i=0; i<n_loss; ++i) { << 401 em->SetDEDXTable(theLoss->DEDXTable()); 666 if(p == loss_vector[i] && !tables_are_buil << 402 em->SetRangeTable(theLoss->RangeTable()); 667 const G4ParticleDefinition* curr_part = << 403 em->SetInverseRangeTable(theLoss->InverseRangeTable()); 668 if(1 < verbose) { << 404 em->SetLambdaTable(theLoss->LambdaTable()); 669 G4cout << "### Build Table for " << p- << 405 em->SetSubLambdaTable(theLoss->SubLambdaTable()); 670 << " and " << curr_part->GetPar << 406 if (electron_table_are_built && em->SecondaryParticle() == theElectron) 671 << " " << tables_are_built[i] << 407 em->SetSecondaryRangeTable(eIonisation->RangeTable()); 672 << G4endl; << 408 loss_map[part_vector[j]] = em; 673 } << 409 if (1 < verbose) { 674 G4VEnergyLossProcess* curr_proc = BuildT << 410 G4String nm = "0"; 675 if(curr_proc) { << 411 G4String nm1= "0"; 676 CopyTables(curr_part, curr_proc); << 412 G4String nm2= "0"; 677 if(p == curr_proc && 0 == run && p->Is << 413 const G4ParticleDefinition* pd = part_vector[j]; 678 loss_map[aParticle] = p; << 414 const G4ParticleDefinition* bpd = base_part_vector[j]; 679 //G4cout << "G4LossTableManager::Bui << 415 if (pd) nm = pd->GetParticleName(); 680 // << aParticle->GetParticleName << 416 if (bpd) nm2 = bpd->GetParticleName(); 681 // << " added to map " << p << 417 if (part_vector[j]) nm1 = part_vector[j]->GetParticleName(); >> 418 G4cout << "For " << loss_vector[j]->GetProcessName() >> 419 << " for " << nm >> 420 << " (" << nm1 << ") " >> 421 << " base_part= " << nm2 >> 422 << " tables_are_built= " << tables_are_built[j] >> 423 << G4endl; 682 } 424 } 683 } 425 } 684 } 426 } 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 } 427 } 692 } << 693 << 694 //....oooOO0OOooo........oooOO0OOooo........oo << 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 428 703 if (!tables_are_built[j] && part == base_p << 429 all_tables_are_built = true; 704 tables_are_built[j] = true; << 430 for (G4int ii=0; ii<n_loss; ii++) { 705 // for base particle approach only ionis << 431 if ( !tables_are_built[ii] ) { 706 proc->SetDEDXTable(base_proc->Ionisation << 432 all_tables_are_built = false; 707 proc->SetDEDXTable(base_proc->DEDXunRest << 433 break; 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 } 434 } 728 } 435 } >> 436 >> 437 if(0 < verbose) { >> 438 G4cout << "G4LossTableManager::RetrievePhysicsTable: end; " >> 439 << "all_tables_are_built= " << all_tables_are_built >> 440 << G4endl; >> 441 } 729 } 442 } 730 443 731 //....oooOO0OOooo........oooOO0OOooo........oo << 444 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 732 445 733 G4VEnergyLossProcess* G4LossTableManager::Buil << 446 G4VEnergyLossSTD* G4LossTableManager::BuildTables(const G4ParticleDefinition* aParticle) 734 const G4ParticleDefiniti << 735 { 447 { 736 if(1 < verbose) { << 448 if(0 < verbose) { 737 G4cout << " G4LossTableManager::BuildTab << 449 G4cout << "G4LossTableManager::BuildTables() for " 738 << aParticle->GetParticleName() << 450 << aParticle->GetParticleName() << G4endl; 739 } 451 } 740 452 741 std::vector<G4PhysicsTable*> t_list; << 453 // Check is it new particle or all tables have to be rebuilt 742 std::vector<G4VEnergyLossProcess*> loss_list << 454 std::vector<G4PhysicsTable*> list; 743 std::vector<G4bool> build_flags; << 455 list.clear(); 744 G4VEnergyLossProcess* em = nullptr; << 456 std::vector<G4VEnergyLossSTD*> loss_list; 745 G4VEnergyLossProcess* p = nullptr; << 457 loss_list.clear(); >> 458 G4VEnergyLossSTD* em = 0; 746 G4int iem = 0; 459 G4int iem = 0; 747 G4PhysicsTable* dedx = nullptr; << 460 G4bool no_el = true; 748 G4int i; << 749 461 750 G4ProcessVector* pvec = << 462 for (G4int i=0; i<n_loss; i++) { 751 aParticle->GetProcessManager()->GetProcess << 463 if (aParticle == part_vector[i]) { 752 G4int nvec = (G4int)pvec->size(); << 464 loss_vector[i]->Initialise(); 753 << 465 if(no_el && loss_vector[i]->SecondaryParticle() == theElectron) { 754 for (i=0; i<n_loss; ++i) { << 466 em = loss_vector[i]; 755 p = loss_vector[i]; << 467 iem= i; 756 if (nullptr != p) { << 468 no_el = false; 757 G4bool yes = (aParticle == part_vector[i << 469 } 758 << 470 if(!em) { 759 // possible case of process sharing betw << 471 em = loss_vector[i]; 760 if(!yes) { << 472 iem= i; 761 auto ptr = static_cast<G4VProcess*>(p) << 762 for(G4int j=0; j<nvec; ++j) { << 763 //G4cout << "j= " << j << " " << (*p << 764 if(ptr == (*pvec)[j]) { << 765 yes = true; << 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 } 473 } >> 474 tables_are_built[i] = true; >> 475 list.push_back(loss_vector[i]->BuildDEDXTable()); >> 476 loss_list.push_back(loss_vector[i]); 792 } 477 } 793 } 478 } 794 479 795 G4int n_dedx = (G4int)t_list.size(); << 480 G4int n_dedx = list.size(); 796 if (0 == n_dedx || !em) { << 481 if (!n_dedx) return 0; 797 G4cout << "G4LossTableManager WARNING: no << 482 798 << aParticle->GetParticleName() << << 483 if (aParticle == theElectron) eIonisation = em; 799 return nullptr; << 800 } << 801 G4int nSubRegions = em->NumberOfSubCutoffReg << 802 484 803 if (1 < verbose) { 485 if (1 < verbose) { 804 G4cout << " Start to build the sum of << 486 G4cout << "G4LossTableManager::BuildTables() start to build range tables" 805 << " iem= " << iem << " em= " << em << 487 << " and the sum of " << n_dedx << " processes" 806 << " buildCSDARange= " << theParame << 488 << G4endl; 807 << " nSubRegions= " << nSubRegions; << 808 if(subcutProducer) { << 809 G4cout << " SubCutProducer " << subcutPr << 810 } << 811 G4cout << G4endl; << 812 } 489 } 813 // do not build tables if producer class is << 814 if(subcutProducer) { nSubRegions = 0; } << 815 << 816 dedx = em->DEDXTable(); << 817 em->SetDEDXTable(dedx, fIsIonisation); << 818 490 >> 491 G4PhysicsTable* dedx = list[0]; 819 if (1 < n_dedx) { 492 if (1 < n_dedx) { 820 dedx = nullptr; << 493 dedx = tableBuilder->BuildDEDXTable(list); 821 dedx = G4PhysicsTableHelper::PreparePhysic << 494 for(G4int i=0; i<n_dedx; i++) { 822 tableBuilder->BuildDEDXTable(dedx, t_list) << 495 list[i]->clearAndDestroy(); 823 em->SetDEDXTable(dedx, fRestricted); << 496 } 824 } 497 } 825 << 498 em->SetDEDXTable(dedx); 826 dedx_vector[iem] = dedx; 499 dedx_vector[iem] = dedx; 827 << 500 G4PhysicsTable* range = tableBuilder->BuildRangeTable(dedx); 828 G4PhysicsTable* range = em->RangeTableForLos << 501 G4PhysicsTable* invrange = tableBuilder->BuildInverseRangeTable(dedx, range); 829 if(!range) range = G4PhysicsTableHelper::Pr << 830 range_vector[iem] = range; << 831 << 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); 502 em->SetInverseRangeTable(invrange); 841 << 503 inv_range_vector[iem] = invrange; 842 std::vector<G4PhysicsTable*> listCSDA; << 504 if(buildPreciseRange) { 843 << 505 range->clearAndDestroy(); 844 for (i=0; i<n_dedx; ++i) { << 506 std::vector<G4PhysicsTable*> newlist; 845 p = loss_list[i]; << 507 for (G4int i=0; i<n_dedx; i++) { 846 if(build_flags[i]) { << 508 newlist.push_back(loss_list[i]->BuildDEDXTableForPreciseRange()); 847 p->SetLambdaTable(p->BuildLambdaTable(fR << 509 } >> 510 G4PhysicsTable* dedxForRange = newlist[0]; >> 511 if (1 < n_dedx) dedxForRange = tableBuilder->BuildDEDXTable(newlist); >> 512 range = tableBuilder->BuildRangeTable(dedx); >> 513 for(G4int j=0; j<n_dedx; j++) { >> 514 newlist[j]->clearAndDestroy(); 848 } 515 } 849 if(theParameters->BuildCSDARange()) { << 850 dedx = p->BuildDEDXTable(fTotal); << 851 p->SetDEDXTable(dedx,fTotal); << 852 listCSDA.push_back(dedx); << 853 } << 854 } 516 } >> 517 em->SetRangeTable(range); >> 518 range_vector[iem] = range; 855 519 856 if(theParameters->BuildCSDARange()) { << 520 loss_map[aParticle] = em; 857 G4PhysicsTable* dedxCSDA = em->DEDXunRestr << 521 for (G4int j=0; j<n_dedx; j++) { 858 if (1 < n_dedx) { << 522 if(loss_list[j]->SecondaryParticle() == theElectron) 859 dedxCSDA = G4PhysicsTableHelper::Prepare << 523 loss_list[j]->SetSecondaryRangeTable(eIonisation->RangeTable()); 860 tableBuilder->BuildDEDXTable(dedxCSDA, l << 524 861 em->SetDEDXTable(dedxCSDA,fTotal); << 525 G4PhysicsTable* lambdaTable = loss_list[j]->BuildLambdaTable(); >> 526 loss_list[j]->SetLambdaTable(lambdaTable); >> 527 if (0 < loss_list[j]->NumberOfSubCutoffRegions()) { >> 528 lambdaTable = loss_list[j]->BuildLambdaSubTable(); >> 529 loss_list[j]->SetSubLambdaTable(lambdaTable); 862 } 530 } 863 G4PhysicsTable* rCSDA = em->CSDARangeTable << 864 if(!rCSDA) { rCSDA = G4PhysicsTableHelper: << 865 tableBuilder->BuildRangeTable(dedxCSDA, rC << 866 em->SetCSDARangeTable(rCSDA); << 867 } 531 } 868 << 532 if (0 < verbose) { 869 if (1 < verbose) { << 870 G4cout << "G4LossTableManager::BuildTables 533 G4cout << "G4LossTableManager::BuildTables: Tables are built for " 871 << aParticle->GetParticleName() 534 << aParticle->GetParticleName() 872 << "; ionisation process: " << em-> << 535 << "; ionisation process: " << em->GetProcessName() 873 << " " << em << 874 << G4endl; 536 << G4endl; 875 } 537 } 876 return em; 538 return em; 877 } 539 } 878 540 879 //....oooOO0OOooo........oooOO0OOooo........oo << 541 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 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 542 915 const std::vector<G4VMultipleScattering*>& << 543 void G4LossTableManager::SetLossFluctuations(G4bool val) 916 G4LossTableManager::GetMultipleScatteringVecto << 917 { 544 { 918 return msc_vector; << 545 lossFluctuationFlag = val; >> 546 for(G4int i=0; i<n_loss; i++) { >> 547 loss_vector[i]->SetLossFluctuations(val); >> 548 } 919 } 549 } 920 550 921 //....oooOO0OOooo........oooOO0OOooo........oo 551 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 922 552 923 G4EmSaturation* G4LossTableManager::EmSaturati << 553 void G4LossTableManager::SetSubCutoff(G4bool val) 924 { 554 { 925 return theParameters->GetEmSaturation(); << 555 subCutoffFlag = val; >> 556 for(G4int i=0; i<n_loss; i++) { >> 557 loss_vector[i]->SetSubCutoff(val); >> 558 } 926 } 559 } 927 560 928 //....oooOO0OOooo........oooOO0OOooo........oo 561 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 929 562 930 G4EmConfigurator* G4LossTableManager::EmConfig << 563 void G4LossTableManager::SetIntegral(G4bool val) 931 { 564 { 932 if(!emConfigurator) { << 565 integral = val; 933 emConfigurator = new G4EmConfigurator(verb << 566 integralActive = true; >> 567 for(G4int i=0; i<n_loss; i++) { >> 568 loss_vector[i]->SetIntegral(val); 934 } 569 } 935 return emConfigurator; << 936 } 570 } 937 571 938 //....oooOO0OOooo........oooOO0OOooo........oo 572 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 939 573 940 G4ElectronIonPair* G4LossTableManager::Electro << 574 void G4LossTableManager::SetMinSubRange(G4double val) 941 { 575 { 942 if(!emElectronIonPair) { << 576 minSubRange = val; 943 emElectronIonPair = new G4ElectronIonPair( << 577 for(G4int i=0; i<n_loss; i++) { >> 578 loss_vector[i]->SetMinSubRange(val); 944 } 579 } 945 return emElectronIonPair; << 946 } 580 } 947 581 948 //....oooOO0OOooo........oooOO0OOooo........oo 582 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 949 583 950 void G4LossTableManager::SetNIELCalculator(G4N << 584 void G4LossTableManager::SetRandomStep(G4bool val) 951 { 585 { 952 if(nullptr != ptr && ptr != nielCalculator) << 586 rndmStepFlag = val; 953 delete nielCalculator; << 587 for(G4int i=0; i<n_loss; i++) { 954 nielCalculator = ptr; << 588 loss_vector[i]->SetRandomStep(val); 955 } 589 } 956 } 590 } 957 591 958 //....oooOO0OOooo........oooOO0OOooo........oo 592 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 959 593 960 G4NIELCalculator* G4LossTableManager::NIELCalc << 594 void G4LossTableManager::SetMinEnergy(G4double val) 961 { 595 { 962 if(!nielCalculator) { << 596 minEnergyActive = true; 963 nielCalculator = new G4NIELCalculator(null << 597 minKinEnergy = val; >> 598 for(G4int i=0; i<n_loss; i++) { >> 599 loss_vector[i]->SetMinKinEnergy(val); 964 } 600 } 965 return nielCalculator; << 966 } 601 } 967 602 968 //....oooOO0OOooo........oooOO0OOooo........oo << 603 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 969 << 604 970 void G4LossTableManager::SetAtomDeexcitation(G << 605 void G4LossTableManager::SetMaxEnergy(G4double val) 971 { 606 { 972 if(atomDeexcitation != p) { << 607 maxEnergyActive = true; 973 delete atomDeexcitation; << 608 maxKinEnergy = val; 974 atomDeexcitation = p; << 609 for(G4int i=0; i<n_loss; i++) { >> 610 loss_vector[i]->SetMaxKinEnergy(val); 975 } 611 } 976 } 612 } 977 613 978 //....oooOO0OOooo........oooOO0OOooo........oo << 614 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 979 615 980 void G4LossTableManager::SetSubCutProducer(G4V << 616 void G4LossTableManager::SetStepLimits(G4double v1, G4double v2) 981 { 617 { 982 if(subcutProducer != p) { << 618 maxRangeVariation = v1; 983 delete subcutProducer; << 619 maxFinalStep = v2; 984 subcutProducer = p; << 620 for(G4int i=0; i<n_loss; i++) { >> 621 loss_vector[i]->SetStepLimits(v1, v2); 985 } 622 } 986 } 623 } 987 624 988 //....oooOO0OOooo........oooOO0OOooo........oo << 625 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 989 626 990 void G4LossTableManager::PrintEWarning(G4Strin << 627 void G4LossTableManager::SetBuildPreciseRange(G4bool val) 991 { 628 { 992 G4String ss = "G4LossTableManager::" + tit; << 629 buildPreciseRange = val; 993 G4ExceptionDescription ed; << 994 /* << 995 ed << "Parameter is out of range: " << val << 996 << " it will have no effect!\n" << " ## " << 997 << " nbins= " << nbinsLambda << 998 << " nbinsPerDecade= " << nbinsPerDecade << 999 << " Emin(keV)= " << minKinEnergy/keV << 1000 << " Emax(GeV)= " << maxKinEnergy/GeV; << 1001 */ << 1002 G4Exception(ss, "em0044", JustWarning, ed); << 1003 } 630 } 1004 631 1005 //....oooOO0OOooo........oooOO0OOooo........o 632 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1006 633 1007 void G4LossTableManager::DumpHtml() << 1008 { << 1009 // Automatic generation of html documentati << 1010 // List processes and models for the most i << 1011 // particles in descending order of importa << 1012 // NB. for model names with length > 18 cha << 1013 // to be edited by hand. Or modify G4EmMod << 1014 << 1015 char* dirName = std::getenv("G4PhysListDocD << 1016 char* physList = std::getenv("G4PhysListNam << 1017 if (dirName && physList) { << 1018 G4String physListName = G4String(physList << 1019 G4String pathName = G4String(dirName) + " << 1020 << 1021 std::ofstream outFile; << 1022 outFile.open(pathName); << 1023 << 1024 outFile << physListName << G4endl; << 1025 outFile << std::string(physListName.lengt << 1026 << 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 << 1072 for (auto enlossproc : enloss_vector) { << 1073 for (G4int i = 0; i < plen; ++i) { << 1074 G4VProcess* proc = (*pv)[i]; << 1075 if (proc == enlossproc) { << 1076 outFile << G4endl; << 1077 proc->ProcessDescription(outFile) << 1078 break; << 1079 } << 1080 } << 1081 } << 1082 } << 1083 outFile.close(); << 1084 } << 1085 } << 1086 << 1087 //....oooOO0OOooo........oooOO0OOooo........o << 1088 634 1089 635