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