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