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 81864 2014-06-06 11:30:54Z gcosmo $ >> 27 // 26 // ------------------------------------------- 28 // ------------------------------------------------------------------- 27 // 29 // 28 // GEANT4 Class file 30 // GEANT4 Class file 29 // 31 // 30 // 32 // 31 // File name: G4LossTableManager 33 // File name: G4LossTableManager 32 // 34 // 33 // Author: Vladimir Ivanchenko 35 // Author: Vladimir Ivanchenko 34 // 36 // 35 // Creation date: 03.01.2002 37 // Creation date: 03.01.2002 36 // 38 // 37 // Modifications: by V.Ivanchenko << 39 // Modifications: 38 // 40 // >> 41 // 20-01-03 Migrade to cut per region (V.Ivanchenko) >> 42 // 15-02-03 Lambda table can be scaled (V.Ivanchenko) >> 43 // 17-02-03 Fix problem of store/restore tables (V.Ivanchenko) >> 44 // 10-03-03 Add Ion registration (V.Ivanchenko) >> 45 // 25-03-03 Add deregistration (V.Ivanchenko) >> 46 // 02-04-03 Change messenger (V.Ivanchenko) >> 47 // 26-04-03 Fix retrieve tables (V.Ivanchenko) >> 48 // 13-05-03 Add calculation of precise range (V.Ivanchenko) >> 49 // 23-07-03 Add exchange with G4EnergyLossTables (V.Ivanchenko) >> 50 // 05-10-03 Add G4VEmProcesses registration and Verbose command (V.Ivanchenko) >> 51 // 17-10-03 Add SetParameters method (V.Ivanchenko) >> 52 // 23-10-03 Add control on inactive processes (V.Ivanchenko) >> 53 // 04-11-03 Add checks in RetrievePhysicsTable (V.Ivanchenko) >> 54 // 12-11-03 G4EnergyLossSTD -> G4EnergyLossProcess (V.Ivanchenko) >> 55 // 14-01-04 Activate precise range calculation (V.Ivanchenko) >> 56 // 10-03-04 Fix a problem of Precise Range table (V.Ivanchenko) >> 57 // 08-11-04 Migration to new interface of Store/Retrieve tables (V.Ivanchenko) >> 58 // 13-01-04 Fix problem which takes place for inactivate eIoni (V.Ivanchenko) >> 59 // 25-01-04 Fix initialisation problem for ions (V.Ivanchenko) >> 60 // 11-03-05 Shift verbose level by 1 (V.Ivantchenko) >> 61 // 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko) >> 62 // 20-01-06 Introduce G4EmTableType to remove repeating code (VI) >> 63 // 23-03-06 Set flag isIonisation (VI) >> 64 // 10-05-06 Add methods SetMscStepLimitation, FacRange and MscFlag (VI) >> 65 // 22-05-06 Add methods Set/Get bremsTh (VI) >> 66 // 05-06-06 Do not clear loss_table map between runs (VI) >> 67 // 16-01-07 Create new energy loss table for e+,e-,mu+,mu- and >> 68 // left ionisation table for further usage (VI) >> 69 // 12-02-07 Add SetSkin, SetLinearLossLimit (V.Ivanchenko) >> 70 // 18-06-07 Move definition of msc parameters to G4EmProcessOptions (V.Ivanchenko) >> 71 // 21-02-08 Added G4EmSaturation (V.Ivanchenko) >> 72 // 12-04-10 Added PreparePhysicsTables and BuildPhysicsTables entries (V.Ivanchenko) >> 73 // 04-06-13 (V.Ivanchenko) Adaptation for MT mode; new method LocalPhysicsTables; >> 74 // ions expect G4GenericIon are not included in the map of energy loss >> 75 // processes for performnc reasons 39 // 76 // 40 // Class Description: 77 // Class Description: 41 // 78 // 42 // ------------------------------------------- 79 // ------------------------------------------------------------------- 43 // 80 // 44 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 //....oooOO0OOooo........oooOO0OOooo........oo 82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 83 47 #include "G4LossTableManager.hh" 84 #include "G4LossTableManager.hh" 48 #include "G4SystemOfUnits.hh" 85 #include "G4SystemOfUnits.hh" 49 << 86 #include "G4EnergyLossMessenger.hh" 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" 87 #include "G4PhysicsTable.hh" 64 #include "G4ParticleDefinition.hh" 88 #include "G4ParticleDefinition.hh" 65 #include "G4MaterialCutsCouple.hh" 89 #include "G4MaterialCutsCouple.hh" 66 #include "G4ProcessManager.hh" 90 #include "G4ProcessManager.hh" 67 #include "G4Electron.hh" 91 #include "G4Electron.hh" 68 #include "G4Proton.hh" 92 #include "G4Proton.hh" >> 93 #include "G4VMultipleScattering.hh" >> 94 #include "G4VEmProcess.hh" 69 #include "G4ProductionCutsTable.hh" 95 #include "G4ProductionCutsTable.hh" 70 #include "G4PhysicsTableHelper.hh" 96 #include "G4PhysicsTableHelper.hh" >> 97 #include "G4EmCorrections.hh" >> 98 #include "G4EmSaturation.hh" >> 99 #include "G4EmConfigurator.hh" >> 100 #include "G4ElectronIonPair.hh" 71 #include "G4EmTableType.hh" 101 #include "G4EmTableType.hh" >> 102 #include "G4LossTableBuilder.hh" >> 103 #include "G4VAtomDeexcitation.hh" 72 #include "G4Region.hh" 104 #include "G4Region.hh" 73 #include "G4PhysicalConstants.hh" 105 #include "G4PhysicalConstants.hh" >> 106 #include "G4Threading.hh" 74 107 75 #include "G4Gamma.hh" << 108 //G4ThreadLocal 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 109 83 //....oooOO0OOooo........oooOO0OOooo........oo 110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 84 111 85 static std::once_flag applyOnce; << 86 G4ThreadLocal G4LossTableManager* G4LossTableM << 87 << 88 G4LossTableManager* G4LossTableManager::Instan 112 G4LossTableManager* G4LossTableManager::Instance() 89 { 113 { 90 if(nullptr == instance) { << 114 /* 91 static G4ThreadLocalSingleton<G4LossTableM << 115 if(!theInstance) { 92 instance = inst.Instance(); << 116 theInstance = new G4LossTableManager; 93 } 117 } 94 return instance; << 118 return theInstance; >> 119 */ >> 120 static G4ThreadLocalSingleton<G4LossTableManager> instance; >> 121 return instance.Instance(); 95 } 122 } 96 123 97 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 98 125 99 G4LossTableManager::~G4LossTableManager() 126 G4LossTableManager::~G4LossTableManager() 100 { 127 { 101 for (auto const & p : loss_vector) { delete << 128 //G4cout << "### G4LossTableManager::~G4LossTableManager()" << G4endl; 102 for (auto const & p : msc_vector) { delete p << 129 for (G4int i=0; i<n_loss; ++i) { 103 for (auto const & p : emp_vector) { delete p << 130 if( loss_vector[i] ) { delete loss_vector[i]; } 104 for (auto const & p : p_vector) { delete p; << 131 } 105 << 132 size_t msc = msc_vector.size(); 106 std::size_t mod = mod_vector.size(); << 133 for (size_t j=0; j<msc; ++j) { 107 std::size_t fmod = fmod_vector.size(); << 134 if( msc_vector[j] ) { delete msc_vector[j]; } 108 for (std::size_t a=0; a<mod; ++a) { << 135 } 109 if( nullptr != mod_vector[a] ) { << 136 size_t emp = emp_vector.size(); 110 for (std::size_t b=0; b<fmod; ++b) { << 137 for (size_t k=0; k<emp; ++k) { 111 if((G4VEmModel*)(fmod_vector[b]) == mo << 138 if( emp_vector[k] ) { delete emp_vector[k]; } 112 fmod_vector[b] = nullptr; << 139 } 113 } << 140 size_t mod = mod_vector.size(); >> 141 size_t fmod = fmod_vector.size(); >> 142 for (size_t a=0; a<mod; ++a) { >> 143 if( mod_vector[a] ) { >> 144 for (size_t b=0; b<fmod; ++b) { >> 145 if((G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) { >> 146 fmod_vector[b] = 0; >> 147 } 114 } 148 } 115 delete mod_vector[a]; 149 delete mod_vector[a]; 116 mod_vector[a] = nullptr; << 117 } 150 } 118 } 151 } 119 for (auto const & p : fmod_vector) { delete << 152 for (size_t b=0; b<fmod; ++b) { 120 << 153 if( fmod_vector[b] ) { delete fmod_vector[b]; } >> 154 } 121 Clear(); 155 Clear(); >> 156 delete theMessenger; 122 delete tableBuilder; 157 delete tableBuilder; 123 delete emCorrections; 158 delete emCorrections; >> 159 delete emSaturation; 124 delete emConfigurator; 160 delete emConfigurator; 125 delete emElectronIonPair; 161 delete emElectronIonPair; 126 delete nielCalculator; << 127 delete atomDeexcitation; 162 delete atomDeexcitation; 128 delete subcutProducer; << 129 } 163 } 130 164 131 //....oooOO0OOooo........oooOO0OOooo........oo 165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 132 166 133 G4LossTableManager::G4LossTableManager() 167 G4LossTableManager::G4LossTableManager() 134 { 168 { 135 theParameters = G4EmParameters::Instance(); << 169 n_loss = 0; 136 theElectron = G4Electron::Electron(); << 170 run = -1; 137 << 171 startInitialisation = false; 138 // only one thread is the master << 172 all_tables_are_built = false; 139 std::call_once(applyOnce, [this]() { isMaste << 173 currentLoss = 0; 140 verbose = isMaster ? theParameters->Verbose( << 174 currentParticle = 0; 141 << 175 firstParticle = 0; 142 tableBuilder = new G4LossTableBuilder(isMast << 176 lossFluctuationFlag = true; 143 emCorrections = new G4EmCorrections(verbose) << 177 subCutoffFlag = false; 144 << 178 rndmStepFlag = false; 145 std::size_t n = 70; << 179 minSubRange = 0.0; 146 loss_vector.reserve(n); << 180 maxRangeVariation = 1.0; 147 part_vector.reserve(n); << 181 maxFinalStep = 0.0; 148 base_part_vector.reserve(n); << 182 minKinEnergy = 0.1*keV; 149 dedx_vector.reserve(n); << 183 maxKinEnergy = 10.0*TeV; 150 range_vector.reserve(n); << 184 nbinsLambda = 77; 151 inv_range_vector.reserve(n); << 185 nbinsPerDecade = 7; 152 tables_are_built.reserve(n); << 186 maxKinEnergyForMuons = 10.*TeV; 153 isActive.reserve(n); << 187 integral = true; 154 msc_vector.reserve(10); << 188 integralActive = false; 155 emp_vector.reserve(16); << 189 buildCSDARange = false; 156 mod_vector.reserve(150); << 190 minEnergyActive = false; 157 fmod_vector.reserve(60); << 191 maxEnergyActive = false; >> 192 maxEnergyForMuonsActive = false; >> 193 stepFunctionActive = false; >> 194 flagLPM = true; >> 195 splineFlag = true; >> 196 isMaster = true; >> 197 bremsTh = DBL_MAX; >> 198 factorForAngleLimit = 1.0; >> 199 verbose = 1; >> 200 theMessenger = new G4EnergyLossMessenger(); >> 201 theElectron = G4Electron::Electron(); >> 202 theGenericIon= 0; >> 203 tableBuilder = new G4LossTableBuilder(); >> 204 emCorrections= new G4EmCorrections(); >> 205 emSaturation = new G4EmSaturation(); >> 206 emConfigurator = new G4EmConfigurator(verbose); >> 207 emElectronIonPair = new G4ElectronIonPair(); >> 208 tableBuilder->SetSplineFlag(splineFlag); >> 209 atomDeexcitation = 0; >> 210 if(G4Threading::IsWorkerThread()) { >> 211 verbose = 0; >> 212 isMaster = false; >> 213 } 158 } 214 } 159 215 160 //....oooOO0OOooo........oooOO0OOooo........oo 216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 161 217 162 void G4LossTableManager::Clear() 218 void G4LossTableManager::Clear() 163 { 219 { 164 all_tables_are_built = false; 220 all_tables_are_built = false; 165 currentLoss = nullptr; << 221 currentLoss = 0; 166 currentParticle = nullptr; << 222 currentParticle = 0; 167 if(n_loss) { << 223 if(n_loss) 168 dedx_vector.clear(); << 224 { 169 range_vector.clear(); << 225 dedx_vector.clear(); 170 inv_range_vector.clear(); << 226 range_vector.clear(); 171 loss_map.clear(); << 227 inv_range_vector.clear(); 172 loss_vector.clear(); << 228 loss_map.clear(); 173 part_vector.clear(); << 229 loss_vector.clear(); 174 base_part_vector.clear(); << 230 part_vector.clear(); 175 tables_are_built.clear(); << 231 base_part_vector.clear(); 176 isActive.clear(); << 232 tables_are_built.clear(); 177 n_loss = 0; << 233 isActive.clear(); 178 } << 234 n_loss = 0; >> 235 } 179 } 236 } 180 237 181 //....oooOO0OOooo........oooOO0OOooo........oo 238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 182 239 183 void G4LossTableManager::Register(G4VEnergyLos 240 void G4LossTableManager::Register(G4VEnergyLossProcess* p) 184 { 241 { 185 if (nullptr == p) { return; } << 242 if(!p) { return; } 186 for (G4int i=0; i<n_loss; ++i) { 243 for (G4int i=0; i<n_loss; ++i) { 187 if(loss_vector[i] == p) { return; } 244 if(loss_vector[i] == p) { return; } 188 } 245 } 189 if(verbose > 1) { 246 if(verbose > 1) { 190 G4cout << "G4LossTableManager::Register G4 247 G4cout << "G4LossTableManager::Register G4VEnergyLossProcess : " 191 << p->GetProcessName() << " idx= " << 248 << p->GetProcessName() << " idx= " << n_loss << G4endl; 192 } 249 } 193 ++n_loss; 250 ++n_loss; 194 loss_vector.push_back(p); 251 loss_vector.push_back(p); 195 part_vector.push_back(nullptr); << 252 part_vector.push_back(0); 196 base_part_vector.push_back(nullptr); << 253 base_part_vector.push_back(0); 197 dedx_vector.push_back(nullptr); << 254 dedx_vector.push_back(0); 198 range_vector.push_back(nullptr); << 255 range_vector.push_back(0); 199 inv_range_vector.push_back(nullptr); << 256 inv_range_vector.push_back(0); 200 tables_are_built.push_back(false); 257 tables_are_built.push_back(false); 201 isActive.push_back(true); 258 isActive.push_back(true); 202 all_tables_are_built = false; 259 all_tables_are_built = false; 203 } << 260 if(!lossFluctuationFlag) { p->SetLossFluctuations(false); } 204 << 261 if(subCutoffFlag) { p->ActivateSubCutoff(true); } 205 //....oooOO0OOooo........oooOO0OOooo........oo << 262 if(rndmStepFlag) { p->SetRandomStep(true); } 206 << 263 if(stepFunctionActive) { p->SetStepFunction(maxRangeVariation, 207 void G4LossTableManager::ResetParameters() << 264 maxFinalStep); } 208 { << 265 if(integralActive) { p->SetIntegral(integral); } 209 // initialisation once per run << 266 if(minEnergyActive) { p->SetMinKinEnergy(minKinEnergy); } 210 if (!resetParam) { return; } << 267 if(maxEnergyActive) { p->SetMaxKinEnergy(maxKinEnergy); } 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 } 268 } 237 269 238 //....oooOO0OOooo........oooOO0OOooo........oo 270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 239 271 240 void G4LossTableManager::DeRegister(G4VEnergyL 272 void G4LossTableManager::DeRegister(G4VEnergyLossProcess* p) 241 { 273 { 242 if (nullptr == p) { return; } << 274 if(!p) { return; } 243 for (G4int i=0; i<n_loss; ++i) { 275 for (G4int i=0; i<n_loss; ++i) { 244 if(loss_vector[i] == p) { << 276 if(loss_vector[i] == p) { loss_vector[i] = 0; } 245 loss_vector[i] = nullptr; << 246 break; << 247 } << 248 } 277 } 249 } 278 } 250 279 251 //....oooOO0OOooo........oooOO0OOooo........oo 280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 252 281 253 void G4LossTableManager::Register(G4VMultipleS 282 void G4LossTableManager::Register(G4VMultipleScattering* p) 254 { 283 { 255 if (nullptr == p) { return; } << 284 if(!p) { return; } 256 std::size_t n = msc_vector.size(); << 285 G4int n = msc_vector.size(); 257 for (std::size_t i=0; i<n; ++i) { << 286 for (G4int i=0; i<n; ++i) { 258 if(msc_vector[i] == p) { return; } 287 if(msc_vector[i] == p) { return; } 259 } 288 } 260 if(verbose > 1) { 289 if(verbose > 1) { 261 G4cout << "G4LossTableManager::Register G4 290 G4cout << "G4LossTableManager::Register G4VMultipleScattering : " 262 << p->GetProcessName() << " idx= " << 291 << p->GetProcessName() << " idx= " << msc_vector.size() << G4endl; 263 } 292 } 264 msc_vector.push_back(p); 293 msc_vector.push_back(p); 265 } 294 } 266 295 267 //....oooOO0OOooo........oooOO0OOooo........oo 296 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 268 297 269 void G4LossTableManager::DeRegister(G4VMultipl 298 void G4LossTableManager::DeRegister(G4VMultipleScattering* p) 270 { 299 { 271 if (nullptr == p) { return; } << 300 if(!p) { return; } 272 std::size_t msc = msc_vector.size(); << 301 size_t msc = msc_vector.size(); 273 for (std::size_t i=0; i<msc; ++i) { << 302 for (size_t i=0; i<msc; ++i) { 274 if(msc_vector[i] == p) { << 303 if(msc_vector[i] == p) { msc_vector[i] = 0; } 275 msc_vector[i] = nullptr; << 276 break; << 277 } << 278 } 304 } 279 } 305 } 280 306 281 //....oooOO0OOooo........oooOO0OOooo........oo 307 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 282 308 283 void G4LossTableManager::Register(G4VEmProcess 309 void G4LossTableManager::Register(G4VEmProcess* p) 284 { 310 { 285 if (nullptr == p) { return; } << 311 if(!p) { return; } 286 std::size_t n = emp_vector.size(); << 312 G4int n = emp_vector.size(); 287 for (std::size_t i=0; i<n; ++i) { << 313 for (G4int i=0; i<n; ++i) { 288 if(emp_vector[i] == p) { return; } 314 if(emp_vector[i] == p) { return; } 289 } 315 } 290 if(verbose > 1) { 316 if(verbose > 1) { 291 G4cout << "G4LossTableManager::Register G4 317 G4cout << "G4LossTableManager::Register G4VEmProcess : " 292 << p->GetProcessName() << " idx= " << 318 << p->GetProcessName() << " idx= " << emp_vector.size() << G4endl; 293 } 319 } 294 emp_vector.push_back(p); 320 emp_vector.push_back(p); 295 } 321 } 296 322 297 //....oooOO0OOooo........oooOO0OOooo........oo 323 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 298 324 299 void G4LossTableManager::DeRegister(G4VEmProce 325 void G4LossTableManager::DeRegister(G4VEmProcess* p) 300 { 326 { 301 if (nullptr == p) { return; } << 327 if(!p) { return; } 302 std::size_t emp = emp_vector.size(); << 328 size_t emp = emp_vector.size(); 303 for (std::size_t i=0; i<emp; ++i) { << 329 for (size_t i=0; i<emp; ++i) { 304 if(emp_vector[i] == p) { << 330 if(emp_vector[i] == p) { emp_vector[i] = 0; } 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 } 331 } 339 } 332 } 340 333 341 //....oooOO0OOooo........oooOO0OOooo........oo 334 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 342 335 343 void G4LossTableManager::Register(G4VEmModel* 336 void G4LossTableManager::Register(G4VEmModel* p) 344 { 337 { 345 mod_vector.push_back(p); 338 mod_vector.push_back(p); 346 if(verbose > 1) { 339 if(verbose > 1) { 347 G4cout << "G4LossTableManager::Register G4 340 G4cout << "G4LossTableManager::Register G4VEmModel : " 348 << p->GetName() << " " << p << " << 341 << p->GetName() << G4endl; 349 } 342 } 350 } 343 } 351 344 352 //....oooOO0OOooo........oooOO0OOooo........oo 345 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 353 346 354 void G4LossTableManager::DeRegister(G4VEmModel 347 void G4LossTableManager::DeRegister(G4VEmModel* p) 355 { 348 { 356 //G4cout << "G4LossTableManager::DeRegister << 349 size_t n = mod_vector.size(); 357 std::size_t n = mod_vector.size(); << 350 for (size_t i=0; i<n; ++i) { 358 for (std::size_t i=0; i<n; ++i) { << 351 if(mod_vector[i] == p) { mod_vector[i] = 0; } 359 if(mod_vector[i] == p) { << 360 mod_vector[i] = nullptr; << 361 break; << 362 } << 363 } 352 } 364 } 353 } 365 354 366 //....oooOO0OOooo........oooOO0OOooo........oo 355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 367 356 368 void G4LossTableManager::Register(G4VEmFluctua 357 void G4LossTableManager::Register(G4VEmFluctuationModel* p) 369 { 358 { 370 fmod_vector.push_back(p); 359 fmod_vector.push_back(p); 371 if(verbose > 1) { 360 if(verbose > 1) { 372 G4cout << "G4LossTableManager::Register G4 361 G4cout << "G4LossTableManager::Register G4VEmFluctuationModel : " 373 << p->GetName() << " " << fmod_vec << 362 << p->GetName() << G4endl; 374 } 363 } 375 } 364 } 376 365 377 //....oooOO0OOooo........oooOO0OOooo........oo 366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 378 367 379 void G4LossTableManager::DeRegister(G4VEmFluct 368 void G4LossTableManager::DeRegister(G4VEmFluctuationModel* p) 380 { 369 { 381 std::size_t n = fmod_vector.size(); << 370 size_t n = fmod_vector.size(); 382 for (std::size_t i=0; i<n; ++i) { << 371 for (size_t i=0; i<n; ++i) { 383 if(fmod_vector[i] == p) { fmod_vector[i] = << 372 if(fmod_vector[i] == p) { fmod_vector[i] = 0; } 384 } 373 } 385 } 374 } 386 375 387 //....oooOO0OOooo........oooOO0OOooo........oo 376 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 388 377 389 void G4LossTableManager::RegisterExtraParticle 378 void G4LossTableManager::RegisterExtraParticle( 390 const G4ParticleDefinition* part, 379 const G4ParticleDefinition* part, 391 G4VEnergyLossProcess* p) 380 G4VEnergyLossProcess* p) 392 { 381 { 393 if (nullptr == p || nullptr == part) { retur << 382 if(!p || !part) { return; } 394 for (G4int i=0; i<n_loss; ++i) { 383 for (G4int i=0; i<n_loss; ++i) { 395 if(loss_vector[i] == p) { return; } 384 if(loss_vector[i] == p) { return; } 396 } 385 } 397 if(verbose > 1) { 386 if(verbose > 1) { 398 G4cout << "G4LossTableManager::RegisterExt 387 G4cout << "G4LossTableManager::RegisterExtraParticle " 399 << part->GetParticleName() << " G4 << 388 << part->GetParticleName() << " G4VEnergyLossProcess : " 400 << p->GetProcessName() << " idx= " << 389 << p->GetProcessName() << " idx= " << n_loss << G4endl; 401 } 390 } 402 ++n_loss; 391 ++n_loss; 403 loss_vector.push_back(p); 392 loss_vector.push_back(p); 404 part_vector.push_back(part); 393 part_vector.push_back(part); 405 base_part_vector.push_back(p->BaseParticle() 394 base_part_vector.push_back(p->BaseParticle()); 406 dedx_vector.push_back(nullptr); << 395 dedx_vector.push_back(0); 407 range_vector.push_back(nullptr); << 396 range_vector.push_back(0); 408 inv_range_vector.push_back(nullptr); << 397 inv_range_vector.push_back(0); 409 tables_are_built.push_back(false); 398 tables_are_built.push_back(false); 410 all_tables_are_built = false; 399 all_tables_are_built = false; 411 } 400 } 412 401 413 //....oooOO0OOooo........oooOO0OOooo........oo << 414 << 415 G4VEnergyLossProcess* << 416 G4LossTableManager::GetEnergyLossProcess(const << 417 { << 418 if(aParticle != currentParticle) { << 419 currentParticle = aParticle; << 420 std::map<PD,G4VEnergyLossProcess*,std::les << 421 if ((pos = loss_map.find(aParticle)) != lo << 422 currentLoss = (*pos).second; << 423 } else { << 424 currentLoss = nullptr; << 425 if(0.0 != aParticle->GetPDGCharge() && << 426 (pos = loss_map.find(theGenericIon)) != los << 427 currentLoss = (*pos).second; << 428 } << 429 } << 430 } << 431 return currentLoss; << 432 } << 433 << 434 //....oooOO0OOooo........oooOO0OOooo........oo 402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 435 403 436 void 404 void 437 G4LossTableManager::PreparePhysicsTable(const 405 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 438 G4VEne << 406 G4VEnergyLossProcess* p, >> 407 G4bool theMaster) 439 { 408 { 440 if (1 < verbose) { 409 if (1 < verbose) { 441 G4cout << "G4LossTableManager::PreparePhys 410 G4cout << "G4LossTableManager::PreparePhysicsTable for " 442 << particle->GetParticleName() << 411 << particle->GetParticleName() 443 << " and " << p->GetProcessName() < << 412 << " and " << p->GetProcessName() << " run= " << run 444 << " loss_vector " << loss_vector << 413 << " loss_vector " << loss_vector.size() << G4endl; 445 << " run=" << run << " master=" << isMast << 414 } 446 << G4endl; << 415 >> 416 isMaster = theMaster; >> 417 >> 418 if(!startInitialisation) { >> 419 tableBuilder->SetInitialisationFlag(false); >> 420 if (1 < verbose) { >> 421 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 422 << G4endl; >> 423 } 447 } 424 } 448 425 449 // start initialisation for the first run 426 // start initialisation for the first run 450 if( -1 == run ) { 427 if( -1 == run ) { 451 if (nullptr != emConfigurator) { emConfigu << 428 emConfigurator->PrepareModels(particle, p); 452 429 453 // initialise particles for given process 430 // initialise particles for given process 454 for (G4int j=0; j<n_loss; ++j) { 431 for (G4int j=0; j<n_loss; ++j) { 455 if (p == loss_vector[j] && nullptr == pa << 432 if (p == loss_vector[j] && !part_vector[j]) { 456 part_vector[j] = particle; << 433 part_vector[j] = particle; 457 if (particle->GetParticleName() == "Ge << 434 if(particle->GetParticleName() == "GenericIon") { 458 theGenericIon = particle; << 435 theGenericIon = particle; 459 } << 436 } 460 } 437 } 461 } 438 } 462 } 439 } 463 ResetParameters(); << 440 startInitialisation = true; 464 } 441 } 465 442 466 //....oooOO0OOooo........oooOO0OOooo........oo 443 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 467 444 468 void 445 void 469 G4LossTableManager::PreparePhysicsTable(const 446 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 470 G4VEmP << 447 G4VEmProcess* p, G4bool theMaster) 471 { 448 { 472 if (1 < verbose) { 449 if (1 < verbose) { 473 G4cout << "G4LossTableManager::PreparePhys 450 G4cout << "G4LossTableManager::PreparePhysicsTable for " 474 << particle->GetParticleName() << 451 << particle->GetParticleName() 475 << " and " << p->GetProcessName() << 452 << " and " << p->GetProcessName() << G4endl; 476 << " run=" << run << " master=" << isMast << 453 } 477 << G4endl; << 454 isMaster = theMaster; >> 455 >> 456 if(!startInitialisation) { >> 457 tableBuilder->SetInitialisationFlag(false); >> 458 if (1 < verbose) { >> 459 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 460 << G4endl; >> 461 } 478 } 462 } 479 463 480 // start initialisation for the first run 464 // start initialisation for the first run 481 if( -1 == run ) { 465 if( -1 == run ) { 482 if (nullptr != emConfigurator) { emConfigu << 466 emConfigurator->PrepareModels(particle, p); 483 } 467 } 484 << 468 startInitialisation = true; 485 ResetParameters(); << 486 } 469 } 487 470 488 //....oooOO0OOooo........oooOO0OOooo........oo 471 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 489 472 490 void 473 void 491 G4LossTableManager::PreparePhysicsTable(const 474 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 492 G4VMul << 475 G4VMultipleScattering* p, >> 476 G4bool theMaster) 493 { 477 { 494 if (1 < verbose) { 478 if (1 < verbose) { 495 G4cout << "G4LossTableManager::PreparePhys 479 G4cout << "G4LossTableManager::PreparePhysicsTable for " 496 << particle->GetParticleName() << 480 << particle->GetParticleName() 497 << " and " << p->GetProcessName() << 481 << " and " << p->GetProcessName() << G4endl; 498 << " run=" << run << " master=" << isMast << 482 } 499 << G4endl; << 483 >> 484 isMaster = theMaster; >> 485 >> 486 if(!startInitialisation) { >> 487 tableBuilder->SetInitialisationFlag(false); >> 488 if (1 < verbose) { >> 489 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 490 << G4endl; >> 491 } 500 } 492 } 501 493 502 // start initialisation for the first run 494 // start initialisation for the first run 503 if ( -1 == run ) { << 495 if( -1 == run ) { 504 if (nullptr != emConfigurator) { emConfigu << 496 emConfigurator->PrepareModels(particle, p); 505 } 497 } 506 << 498 startInitialisation = true; 507 ResetParameters(); << 508 } 499 } 509 500 510 //....oooOO0OOooo........oooOO0OOooo........oo 501 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 511 502 512 void 503 void 513 G4LossTableManager::BuildPhysicsTable(const G4 504 G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition*) 514 { 505 { 515 if(-1 == run && startInitialisation) { 506 if(-1 == run && startInitialisation) { 516 if (nullptr != emConfigurator) { emConfigu << 507 emConfigurator->Clear(); 517 } 508 } 518 if (startInitialisation) { resetParam = true << 519 } 509 } 520 510 521 //....oooOO0OOooo........oooOO0OOooo........oo 511 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 522 512 523 void G4LossTableManager::LocalPhysicsTables( 513 void G4LossTableManager::LocalPhysicsTables( 524 const G4ParticleDefinition* aParticle, 514 const G4ParticleDefinition* aParticle, 525 G4VEnergyLossProcess* p) 515 G4VEnergyLossProcess* p) 526 { 516 { 527 if (1 < verbose) { << 517 if(1 < verbose) { 528 G4cout << "### G4LossTableManager::LocalPh 518 G4cout << "### G4LossTableManager::LocalPhysicsTable() for " 529 << aParticle->GetParticleName() << 519 << aParticle->GetParticleName() 530 << " and process " << p->GetProcess << 520 << " and process " << p->GetProcessName() 531 << G4endl; << 521 << G4endl; 532 } 522 } 533 523 534 if(-1 == run && startInitialisation) { 524 if(-1 == run && startInitialisation) { 535 if (nullptr != emConfigurator) { emConfigu << 525 emConfigurator->Clear(); 536 firstParticle = aParticle; 526 firstParticle = aParticle; 537 } 527 } 538 528 539 if (startInitialisation) { << 529 if(startInitialisation) { 540 ++run; 530 ++run; 541 if (1 < verbose) { << 531 SetVerbose(verbose); >> 532 if(1 < verbose) { 542 G4cout << "===== G4LossTableManager::Loc 533 G4cout << "===== G4LossTableManager::LocalPhysicsTable() for run " 543 << run << " =====" << G4endl; << 534 << run << " =====" << G4endl; 544 } 535 } 545 currentParticle = nullptr; << 536 if(atomDeexcitation) { >> 537 atomDeexcitation->InitialiseAtomicDeexcitation(); >> 538 } >> 539 currentParticle = 0; 546 startInitialisation = false; 540 startInitialisation = false; 547 resetParam = true; << 548 for (G4int i=0; i<n_loss; ++i) { 541 for (G4int i=0; i<n_loss; ++i) { 549 if (nullptr != loss_vector[i]) { << 542 if(loss_vector[i]) { 550 tables_are_built[i] = false; << 543 tables_are_built[i] = false; 551 } else { 544 } else { 552 tables_are_built[i] = true; << 545 tables_are_built[i] = true; 553 part_vector[i] = nullptr; << 546 part_vector[i] = 0; 554 } 547 } 555 } 548 } 556 } 549 } 557 550 558 all_tables_are_built= true; 551 all_tables_are_built= true; 559 for (G4int i=0; i<n_loss; ++i) { 552 for (G4int i=0; i<n_loss; ++i) { 560 if(p == loss_vector[i]) { 553 if(p == loss_vector[i]) { 561 tables_are_built[i] = true; 554 tables_are_built[i] = true; 562 isActive[i] = true; 555 isActive[i] = true; >> 556 /* >> 557 const G4ProcessManager* pm = p->GetProcessManager(); >> 558 isActive[i] = false; >> 559 if(pm) { isActive[i] = pm->GetProcessActivation(p); } >> 560 */ 563 part_vector[i] = p->Particle(); 561 part_vector[i] = p->Particle(); 564 base_part_vector[i] = p->BaseParticle(); 562 base_part_vector[i] = p->BaseParticle(); 565 dedx_vector[i] = p->DEDXTable(); 563 dedx_vector[i] = p->DEDXTable(); 566 range_vector[i] = p->RangeTableForLoss() 564 range_vector[i] = p->RangeTableForLoss(); 567 inv_range_vector[i] = p->InverseRangeTab 565 inv_range_vector[i] = p->InverseRangeTable(); 568 if(0 == run && p->IsIonisationProcess()) 566 if(0 == run && p->IsIonisationProcess()) { 569 loss_map[part_vector[i]] = p; << 567 loss_map[part_vector[i]] = loss_vector[i]; 570 } 568 } 571 569 572 if(1 < verbose) { 570 if(1 < verbose) { 573 G4cout << i <<". "<< p->GetProcessNa << 571 G4cout << i <<". "<< p->GetProcessName(); 574 if(part_vector[i]) { << 572 if(part_vector[i]) { 575 G4cout << " for " << part_vector[i << 573 G4cout << " for " << part_vector[i]->GetParticleName(); 576 } << 574 } 577 G4cout << " active= " << isActive[i] << 575 G4cout << " active= " << isActive[i] 578 << " table= " << tables_are_bu << 576 << " table= " << tables_are_built[i] 579 << " isIonisation= " << p->IsI << 577 << " isIonisation= " << p->IsIonisationProcess() 580 << G4endl; << 578 << G4endl; 581 } 579 } 582 break; 580 break; 583 } else if(!tables_are_built[i]) { 581 } else if(!tables_are_built[i]) { 584 all_tables_are_built = false; 582 all_tables_are_built = false; 585 } 583 } 586 } 584 } 587 585 >> 586 // Set run time parameters >> 587 SetParameters(aParticle, p); >> 588 588 if(1 < verbose) { 589 if(1 < verbose) { 589 G4cout << "### G4LossTableManager::LocalPh 590 G4cout << "### G4LossTableManager::LocalPhysicsTable end" 590 << G4endl; << 591 << G4endl; 591 } 592 } 592 if(all_tables_are_built) { 593 if(all_tables_are_built) { 593 if(1 < verbose) { 594 if(1 < verbose) { 594 G4cout << "%%%%% All dEdx and Range tabl 595 G4cout << "%%%%% All dEdx and Range tables for worker are ready for run " 595 << run << " %%%%%" << G4endl; << 596 << run << " %%%%%" << G4endl; 596 } 597 } 597 } 598 } 598 } 599 } 599 600 600 //....oooOO0OOooo........oooOO0OOooo........oo 601 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 601 602 602 void G4LossTableManager::BuildPhysicsTable( 603 void G4LossTableManager::BuildPhysicsTable( 603 const G4ParticleDefinition* aParticle, 604 const G4ParticleDefinition* aParticle, 604 G4VEnergyLossProcess* p) 605 G4VEnergyLossProcess* p) 605 { 606 { 606 if(1 < verbose) { 607 if(1 < verbose) { 607 G4cout << "### G4LossTableManager::BuildPh 608 G4cout << "### G4LossTableManager::BuildPhysicsTable() for " 608 << aParticle->GetParticleName() 609 << aParticle->GetParticleName() 609 << " and process " << p->GetProcess << 610 << " and process " << p->GetProcessName() << G4endl; 610 } 611 } 611 // clear configurator 612 // clear configurator 612 if(-1 == run && startInitialisation) { 613 if(-1 == run && startInitialisation) { 613 if( nullptr != emConfigurator) { emConfigu << 614 emConfigurator->Clear(); 614 firstParticle = aParticle; 615 firstParticle = aParticle; 615 } 616 } 616 if(startInitialisation) { 617 if(startInitialisation) { 617 ++run; 618 ++run; 618 resetParam = true; << 619 startInitialisation = false; << 620 if(1 < verbose) { 619 if(1 < verbose) { 621 G4cout << "===== G4LossTableManager::Bui 620 G4cout << "===== G4LossTableManager::BuildPhysicsTable() for run " 622 << run << " ===== " << atomDeexci << 621 << run << " =====" << G4endl; >> 622 } >> 623 if(atomDeexcitation) { >> 624 atomDeexcitation->InitialiseAtomicDeexcitation(); 623 } 625 } 624 currentParticle = nullptr; << 626 currentParticle = 0; 625 all_tables_are_built = false; << 627 all_tables_are_built= true; >> 628 } 626 629 >> 630 // initialisation before any table is built >> 631 if ( startInitialisation && aParticle == firstParticle ) { >> 632 >> 633 startInitialisation = false; >> 634 if(1 < verbose) { >> 635 G4cout << "### G4LossTableManager start initilisation for first particle " >> 636 << firstParticle->GetParticleName() >> 637 << G4endl; >> 638 } 627 for (G4int i=0; i<n_loss; ++i) { 639 for (G4int i=0; i<n_loss; ++i) { 628 G4VEnergyLossProcess* el = loss_vector[i 640 G4VEnergyLossProcess* el = loss_vector[i]; 629 641 630 if(nullptr != el) { << 642 if(el) { 631 isActive[i] = true; 643 isActive[i] = true; 632 part_vector[i] = el->Particle(); << 644 /* 633 base_part_vector[i] = el->BaseParticle << 645 const G4ProcessManager* pm = el->GetProcessManager(); 634 tables_are_built[i] = false; << 646 isActive[i] = false; 635 if(1 < verbose) { << 647 if(pm) { isActive[i] = pm->GetProcessActivation(el); } 636 G4cout << i <<". "<< el->GetProces << 648 */ >> 649 base_part_vector[i] = el->BaseParticle(); >> 650 tables_are_built[i] = false; >> 651 all_tables_are_built= false; >> 652 if(!isActive[i]) { >> 653 el->SetIonisation(false); >> 654 tables_are_built[i] = true; >> 655 } >> 656 >> 657 if(1 < verbose) { >> 658 G4cout << i <<". "<< el->GetProcessName(); 637 if(el->Particle()) { 659 if(el->Particle()) { 638 G4cout << " for " << el->Particl << 660 G4cout << " for " << el->Particle()->GetParticleName(); 639 } << 661 } 640 G4cout << " active= " << isActive[i << 662 G4cout << " active= " << isActive[i] 641 << " table= " << tables_are_ 663 << " table= " << tables_are_built[i] 642 << " isIonisation= " << el-> << 664 << " isIonisation= " << el->IsIonisationProcess(); 643 if(base_part_vector[i]) { << 665 if(base_part_vector[i]) { 644 G4cout << " base particle " << 666 G4cout << " base particle " 645 << base_part_vector[i]->Get << 667 << base_part_vector[i]->GetParticleName(); 646 } << 668 } 647 G4cout << G4endl; << 669 G4cout << G4endl; 648 } << 670 } 649 } else { 671 } else { 650 tables_are_built[i] = true; 672 tables_are_built[i] = true; 651 part_vector[i] = nullptr; << 673 part_vector[i] = 0; 652 isActive[i] = false; << 674 isActive[i] = false; 653 } 675 } 654 } 676 } 655 } 677 } 656 678 657 if (all_tables_are_built) { << 679 // Set run time parameters 658 theParameters->SetIsPrintedFlag(true); << 680 SetParameters(aParticle, p); 659 return; << 681 660 } << 682 if (all_tables_are_built) { return; } 661 683 662 // Build tables for given particle 684 // Build tables for given particle 663 all_tables_are_built = true; 685 all_tables_are_built = true; 664 686 665 for(G4int i=0; i<n_loss; ++i) { 687 for(G4int i=0; i<n_loss; ++i) { 666 if(p == loss_vector[i] && !tables_are_buil << 688 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) { 667 const G4ParticleDefinition* curr_part = 689 const G4ParticleDefinition* curr_part = part_vector[i]; 668 if(1 < verbose) { 690 if(1 < verbose) { 669 G4cout << "### Build Table for " << p- 691 G4cout << "### Build Table for " << p->GetProcessName() 670 << " and " << curr_part->GetPar << 692 << " and " << curr_part->GetParticleName() << G4endl; 671 << " " << tables_are_built[i] << 672 << G4endl; << 673 } 693 } 674 G4VEnergyLossProcess* curr_proc = BuildT 694 G4VEnergyLossProcess* curr_proc = BuildTables(curr_part); 675 if(curr_proc) { << 695 if(curr_proc) { CopyTables(curr_part, 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 } 696 } 685 if ( !tables_are_built[i] ) { all_tables_a 697 if ( !tables_are_built[i] ) { all_tables_are_built = false; } 686 } 698 } >> 699 if(0 == run && p->IsIonisationProcess()) { loss_map[aParticle] = p; } >> 700 687 if(1 < verbose) { 701 if(1 < verbose) { 688 G4cout << "### G4LossTableManager::BuildPh 702 G4cout << "### G4LossTableManager::BuildPhysicsTable end: " 689 << "all_tables_are_built= " << all_ << 703 << "all_tables_are_built= " << all_tables_are_built 690 << aParticle->GetParticleName() << << 704 << G4endl; >> 705 } >> 706 if(all_tables_are_built) { >> 707 if(1 < verbose) { >> 708 G4cout << "%%%%% All dEdx and Range tables are built for master run= " >> 709 << run << " %%%%%" << G4endl; >> 710 } 691 } 711 } 692 } 712 } 693 713 694 //....oooOO0OOooo........oooOO0OOooo........oo 714 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 695 715 696 void G4LossTableManager::CopyTables(const G4Pa 716 void G4LossTableManager::CopyTables(const G4ParticleDefinition* part, 697 G4VEnergyL << 717 G4VEnergyLossProcess* base_proc) 698 { 718 { 699 for (G4int j=0; j<n_loss; ++j) { 719 for (G4int j=0; j<n_loss; ++j) { 700 720 701 G4VEnergyLossProcess* proc = loss_vector[j 721 G4VEnergyLossProcess* proc = loss_vector[j]; 702 722 703 if (!tables_are_built[j] && part == base_p 723 if (!tables_are_built[j] && part == base_part_vector[j]) { 704 tables_are_built[j] = true; 724 tables_are_built[j] = true; 705 // for base particle approach only ionis << 706 proc->SetDEDXTable(base_proc->Ionisation 725 proc->SetDEDXTable(base_proc->IonisationTable(),fRestricted); >> 726 proc->SetDEDXTable(base_proc->DEDXTableForSubsec(),fSubRestricted); 707 proc->SetDEDXTable(base_proc->DEDXunRest 727 proc->SetDEDXTable(base_proc->DEDXunRestrictedTable(),fTotal); 708 proc->SetCSDARangeTable(base_proc->CSDAR 728 proc->SetCSDARangeTable(base_proc->CSDARangeTable()); 709 proc->SetRangeTableForLoss(base_proc->Ra 729 proc->SetRangeTableForLoss(base_proc->RangeTableForLoss()); 710 proc->SetInverseRangeTable(base_proc->In 730 proc->SetInverseRangeTable(base_proc->InverseRangeTable()); 711 proc->SetLambdaTable(base_proc->LambdaTa 731 proc->SetLambdaTable(base_proc->LambdaTable()); >> 732 proc->SetSubLambdaTable(base_proc->SubLambdaTable()); >> 733 proc->SetIonisation(base_proc->IsIonisationProcess()); 712 if(proc->IsIonisationProcess()) { 734 if(proc->IsIonisationProcess()) { 713 range_vector[j] = base_proc->RangeTabl << 735 range_vector[j] = base_proc->RangeTableForLoss(); 714 inv_range_vector[j] = base_proc->Inver << 736 inv_range_vector[j] = base_proc->InverseRangeTable(); 715 loss_map[part_vector[j]] = proc; << 737 loss_map[part_vector[j]] = proc; 716 //G4cout << "G4LossTableManager::CopyT << 717 // << part_vector[j]->GetParticl << 718 // << " added to map " << proc < << 719 } 738 } 720 if (1 < verbose) { 739 if (1 < verbose) { 721 G4cout << " CopyTables for " << pro << 740 G4cout << "For " << proc->GetProcessName() 722 << " for " << part_vector[j]-> 741 << " for " << part_vector[j]->GetParticleName() 723 << " base_part= " << part->Get 742 << " base_part= " << part->GetParticleName() 724 << " tables are assigned" << 743 << " tables are assigned " 725 << G4endl; 744 << G4endl; 726 } 745 } 727 } 746 } >> 747 >> 748 if (theElectron == part && theElectron == proc->SecondaryParticle() ) { >> 749 proc->SetSecondaryRangeTable(base_proc->RangeTableForLoss()); >> 750 } 728 } 751 } 729 } 752 } 730 753 731 //....oooOO0OOooo........oooOO0OOooo........oo 754 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 732 755 733 G4VEnergyLossProcess* G4LossTableManager::Buil 756 G4VEnergyLossProcess* G4LossTableManager::BuildTables( 734 const G4ParticleDefiniti 757 const G4ParticleDefinition* aParticle) 735 { 758 { 736 if(1 < verbose) { 759 if(1 < verbose) { 737 G4cout << " G4LossTableManager::BuildTab << 760 G4cout << "G4LossTableManager::BuildTables() for " 738 << aParticle->GetParticleName() << 761 << aParticle->GetParticleName() << G4endl; 739 } 762 } 740 763 741 std::vector<G4PhysicsTable*> t_list; 764 std::vector<G4PhysicsTable*> t_list; 742 std::vector<G4VEnergyLossProcess*> loss_list 765 std::vector<G4VEnergyLossProcess*> loss_list; 743 std::vector<G4bool> build_flags; 766 std::vector<G4bool> build_flags; 744 G4VEnergyLossProcess* em = nullptr; << 767 G4VEnergyLossProcess* em = 0; 745 G4VEnergyLossProcess* p = nullptr; << 768 G4VEnergyLossProcess* p = 0; 746 G4int iem = 0; 769 G4int iem = 0; 747 G4PhysicsTable* dedx = nullptr; << 770 G4PhysicsTable* dedx = 0; 748 G4int i; 771 G4int i; 749 772 750 G4ProcessVector* pvec = 773 G4ProcessVector* pvec = 751 aParticle->GetProcessManager()->GetProcess 774 aParticle->GetProcessManager()->GetProcessList(); 752 G4int nvec = (G4int)pvec->size(); << 775 G4int nvec = pvec->size(); 753 776 754 for (i=0; i<n_loss; ++i) { 777 for (i=0; i<n_loss; ++i) { 755 p = loss_vector[i]; 778 p = loss_vector[i]; 756 if (nullptr != p) { << 779 if (p) { 757 G4bool yes = (aParticle == part_vector[i 780 G4bool yes = (aParticle == part_vector[i]); 758 781 759 // possible case of process sharing betw 782 // possible case of process sharing between particle/anti-particle 760 if(!yes) { 783 if(!yes) { 761 auto ptr = static_cast<G4VProcess*>(p) << 784 G4VProcess* ptr = static_cast<G4VProcess*>(p); 762 for(G4int j=0; j<nvec; ++j) { 785 for(G4int j=0; j<nvec; ++j) { 763 //G4cout << "j= " << j << " " << (*p 786 //G4cout << "j= " << j << " " << (*pvec)[j] << " " << ptr << G4endl; 764 if(ptr == (*pvec)[j]) { 787 if(ptr == (*pvec)[j]) { 765 yes = true; << 788 yes = true; 766 break; 789 break; 767 } << 790 } 768 } << 791 } 769 } 792 } 770 // process belong to this particle 793 // process belong to this particle 771 if(yes && isActive[i]) { 794 if(yes && isActive[i]) { 772 if (p->IsIonisationProcess() || !em) { << 795 if (p->IsIonisationProcess() || !em) { 773 em = p; << 796 em = p; 774 iem= i; << 797 iem= i; 775 } << 798 } 776 // tables may be shared between partic << 799 // tables may be shared between particle/anti-particle 777 G4bool val = false; << 800 G4bool val = false; 778 if (!tables_are_built[i]) { << 801 if (!tables_are_built[i]) { 779 val = true; 802 val = true; 780 dedx = p->BuildDEDXTable(fRestricted << 803 dedx = p->BuildDEDXTable(fRestricted); 781 //G4cout << "===Build DEDX table for << 804 //G4cout << "Build DEDX table for " << p->GetProcessName() 782 // << " idx= " << i << " dedx:" << d << 805 // << " idx= " << i << dedx << " " << dedx->length() << G4endl; 783 p->SetDEDXTable(dedx,fRestricted); << 806 p->SetDEDXTable(dedx,fRestricted); 784 tables_are_built[i] = true; << 807 tables_are_built[i] = true; 785 } else { << 808 } else { 786 dedx = p->DEDXTable(); 809 dedx = p->DEDXTable(); 787 } << 810 } 788 t_list.push_back(dedx); << 811 t_list.push_back(dedx); 789 loss_list.push_back(p); << 812 loss_list.push_back(p); 790 build_flags.push_back(val); 813 build_flags.push_back(val); 791 } 814 } 792 } 815 } 793 } 816 } 794 817 795 G4int n_dedx = (G4int)t_list.size(); << 818 G4int n_dedx = t_list.size(); 796 if (0 == n_dedx || !em) { 819 if (0 == n_dedx || !em) { 797 G4cout << "G4LossTableManager WARNING: no 820 G4cout << "G4LossTableManager WARNING: no DEDX processes for " 798 << aParticle->GetParticleName() << << 821 << aParticle->GetParticleName() << G4endl; 799 return nullptr; << 822 return 0; 800 } 823 } 801 G4int nSubRegions = em->NumberOfSubCutoffReg 824 G4int nSubRegions = em->NumberOfSubCutoffRegions(); 802 825 803 if (1 < verbose) { 826 if (1 < verbose) { 804 G4cout << " Start to build the sum of << 827 G4cout << "G4LossTableManager::BuildTables() start to build range tables" >> 828 << " and the sum of " << n_dedx << " processes" 805 << " iem= " << iem << " em= " << em 829 << " iem= " << iem << " em= " << em->GetProcessName() 806 << " buildCSDARange= " << theParame << 830 << " buildCSDARange= " << buildCSDARange 807 << " nSubRegions= " << nSubRegions; << 831 << " nSubRegions= " << nSubRegions 808 if(subcutProducer) { << 832 << G4endl; 809 G4cout << " SubCutProducer " << subcutPr << 810 } << 811 G4cout << G4endl; << 812 } 833 } 813 // do not build tables if producer class is << 814 if(subcutProducer) { nSubRegions = 0; } << 815 834 816 dedx = em->DEDXTable(); << 835 dedx = em->DEDXTable(); >> 836 em->SetIonisation(true); 817 em->SetDEDXTable(dedx, fIsIonisation); 837 em->SetDEDXTable(dedx, fIsIonisation); 818 838 819 if (1 < n_dedx) { 839 if (1 < n_dedx) { 820 dedx = nullptr; << 840 dedx = 0; 821 dedx = G4PhysicsTableHelper::PreparePhysic 841 dedx = G4PhysicsTableHelper::PreparePhysicsTable(dedx); 822 tableBuilder->BuildDEDXTable(dedx, t_list) 842 tableBuilder->BuildDEDXTable(dedx, t_list); 823 em->SetDEDXTable(dedx, fRestricted); 843 em->SetDEDXTable(dedx, fRestricted); 824 } 844 } 825 << 845 /* >> 846 if(2==run && "e-" == aParticle->GetParticleName()) { >> 847 G4cout << "G4LossTableManager::BuildTables for e- " << dedx << G4endl; >> 848 G4cout << (*dedx) << G4endl; >> 849 G4cout << "%%%%% Instance ID= " << (*dedx)[0]->GetInstanceID() << G4endl; >> 850 G4cout << "%%%%% LastValue= " << (*dedx)[0]->GetLastValue() << G4endl; >> 851 G4cout << "%%%%% 1.2 " << (*(dedx))[0]->Value(1.2) << G4endl; >> 852 } >> 853 */ 826 dedx_vector[iem] = dedx; 854 dedx_vector[iem] = dedx; 827 855 828 G4PhysicsTable* range = em->RangeTableForLos 856 G4PhysicsTable* range = em->RangeTableForLoss(); 829 if(!range) range = G4PhysicsTableHelper::Pr 857 if(!range) range = G4PhysicsTableHelper::PreparePhysicsTable(range); 830 range_vector[iem] = range; 858 range_vector[iem] = range; 831 859 832 G4PhysicsTable* invrange = em->InverseRangeT 860 G4PhysicsTable* invrange = em->InverseRangeTable(); 833 if(!invrange) invrange = G4PhysicsTableHelpe 861 if(!invrange) invrange = G4PhysicsTableHelper::PreparePhysicsTable(invrange); 834 inv_range_vector[iem] = invrange; 862 inv_range_vector[iem] = invrange; 835 863 836 tableBuilder->BuildRangeTable(dedx, range); << 864 tableBuilder->BuildRangeTable(dedx, range, true); 837 tableBuilder->BuildInverseRangeTable(range, << 865 tableBuilder->BuildInverseRangeTable(range, invrange, true); >> 866 >> 867 // if(1<verbose) G4cout << *dedx << G4endl; 838 868 839 em->SetRangeTableForLoss(range); 869 em->SetRangeTableForLoss(range); 840 em->SetInverseRangeTable(invrange); 870 em->SetInverseRangeTable(invrange); 841 871 >> 872 // if(1<verbose) G4cout << *range << G4endl; >> 873 >> 874 std::vector<G4PhysicsTable*> listSub; 842 std::vector<G4PhysicsTable*> listCSDA; 875 std::vector<G4PhysicsTable*> listCSDA; 843 876 844 for (i=0; i<n_dedx; ++i) { 877 for (i=0; i<n_dedx; ++i) { 845 p = loss_list[i]; 878 p = loss_list[i]; >> 879 if(p != em) { p->SetIonisation(false); } 846 if(build_flags[i]) { 880 if(build_flags[i]) { 847 p->SetLambdaTable(p->BuildLambdaTable(fR 881 p->SetLambdaTable(p->BuildLambdaTable(fRestricted)); 848 } 882 } 849 if(theParameters->BuildCSDARange()) { << 883 if (0 < nSubRegions) { >> 884 dedx = p->BuildDEDXTable(fSubRestricted); >> 885 p->SetDEDXTable(dedx,fSubRestricted); >> 886 listSub.push_back(dedx); >> 887 if(build_flags[i]) { >> 888 p->SetSubLambdaTable(p->BuildLambdaTable(fSubRestricted)); >> 889 if(p != em) { em->AddCollaborativeProcess(p); } >> 890 } >> 891 } >> 892 if(buildCSDARange) { 850 dedx = p->BuildDEDXTable(fTotal); 893 dedx = p->BuildDEDXTable(fTotal); 851 p->SetDEDXTable(dedx,fTotal); 894 p->SetDEDXTable(dedx,fTotal); 852 listCSDA.push_back(dedx); 895 listCSDA.push_back(dedx); 853 } 896 } 854 } 897 } 855 898 856 if(theParameters->BuildCSDARange()) { << 899 if (0 < nSubRegions) { >> 900 G4PhysicsTable* dedxSub = em->IonisationTableForSubsec(); >> 901 if (1 < listSub.size()) { >> 902 em->SetDEDXTable(dedxSub, fIsSubIonisation); >> 903 dedxSub = 0; >> 904 dedxSub = G4PhysicsTableHelper::PreparePhysicsTable(dedxSub); >> 905 tableBuilder->BuildDEDXTable(dedxSub, listSub); >> 906 em->SetDEDXTable(dedxSub, fSubRestricted); >> 907 } >> 908 } >> 909 if(buildCSDARange) { 857 G4PhysicsTable* dedxCSDA = em->DEDXunRestr 910 G4PhysicsTable* dedxCSDA = em->DEDXunRestrictedTable(); 858 if (1 < n_dedx) { 911 if (1 < n_dedx) { 859 dedxCSDA = G4PhysicsTableHelper::Prepare << 912 dedxCSDA = 0; >> 913 dedxCSDA = G4PhysicsTableHelper::PreparePhysicsTable(dedxCSDA); 860 tableBuilder->BuildDEDXTable(dedxCSDA, l 914 tableBuilder->BuildDEDXTable(dedxCSDA, listCSDA); 861 em->SetDEDXTable(dedxCSDA,fTotal); 915 em->SetDEDXTable(dedxCSDA,fTotal); 862 } 916 } 863 G4PhysicsTable* rCSDA = em->CSDARangeTable 917 G4PhysicsTable* rCSDA = em->CSDARangeTable(); 864 if(!rCSDA) { rCSDA = G4PhysicsTableHelper: 918 if(!rCSDA) { rCSDA = G4PhysicsTableHelper::PreparePhysicsTable(rCSDA); } 865 tableBuilder->BuildRangeTable(dedxCSDA, rC << 919 tableBuilder->BuildRangeTable(dedxCSDA, rCSDA, true); 866 em->SetCSDARangeTable(rCSDA); 920 em->SetCSDARangeTable(rCSDA); 867 } 921 } 868 922 869 if (1 < verbose) { 923 if (1 < verbose) { 870 G4cout << "G4LossTableManager::BuildTables 924 G4cout << "G4LossTableManager::BuildTables: Tables are built for " 871 << aParticle->GetParticleName() 925 << aParticle->GetParticleName() 872 << "; ionisation process: " << em-> << 926 << "; ionisation process: " << em->GetProcessName() 873 << " " << em << 874 << G4endl; 927 << G4endl; 875 } 928 } 876 return em; 929 return em; 877 } 930 } 878 931 879 //....oooOO0OOooo........oooOO0OOooo........oo 932 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 880 933 >> 934 G4EnergyLossMessenger* G4LossTableManager::GetMessenger() >> 935 { >> 936 return theMessenger; >> 937 } >> 938 >> 939 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 940 881 void G4LossTableManager::ParticleHaveNoLoss( 941 void G4LossTableManager::ParticleHaveNoLoss( 882 const G4ParticleDefinition* aParticle) 942 const G4ParticleDefinition* aParticle) 883 { 943 { 884 G4ExceptionDescription ed; 944 G4ExceptionDescription ed; 885 ed << "Energy loss process not found for " < 945 ed << "Energy loss process not found for " << aParticle->GetParticleName() 886 << " !"; 946 << " !"; 887 G4Exception("G4LossTableManager::ParticleHav 947 G4Exception("G4LossTableManager::ParticleHaveNoLoss", "em0001", 888 FatalException, ed); << 948 FatalException, ed); >> 949 >> 950 } >> 951 >> 952 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 953 >> 954 G4bool G4LossTableManager::BuildCSDARange() const >> 955 { >> 956 return buildCSDARange; >> 957 } >> 958 >> 959 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 960 >> 961 void G4LossTableManager::SetLossFluctuations(G4bool val) >> 962 { >> 963 lossFluctuationFlag = val; >> 964 for(G4int i=0; i<n_loss; ++i) { >> 965 if(loss_vector[i]) { loss_vector[i]->SetLossFluctuations(val); } >> 966 } >> 967 } >> 968 >> 969 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 970 >> 971 void G4LossTableManager::SetSubCutoff(G4bool val, const G4Region* r) >> 972 { >> 973 subCutoffFlag = val; >> 974 for(G4int i=0; i<n_loss; ++i) { >> 975 if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); } >> 976 } >> 977 } >> 978 >> 979 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 980 >> 981 void G4LossTableManager::SetIntegral(G4bool val) >> 982 { >> 983 integral = val; >> 984 integralActive = true; >> 985 for(G4int i=0; i<n_loss; ++i) { >> 986 if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); } >> 987 } >> 988 size_t emp = emp_vector.size(); >> 989 for (size_t k=0; k<emp; ++k) { >> 990 if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); } >> 991 } >> 992 } >> 993 >> 994 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 995 >> 996 void G4LossTableManager::SetMinSubRange(G4double val) >> 997 { >> 998 minSubRange = val; >> 999 for(G4int i=0; i<n_loss; ++i) { >> 1000 if(loss_vector[i]) { loss_vector[i]->SetMinSubRange(val); } >> 1001 } >> 1002 } >> 1003 >> 1004 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1005 >> 1006 void G4LossTableManager::SetRandomStep(G4bool val) >> 1007 { >> 1008 rndmStepFlag = val; >> 1009 for(G4int i=0; i<n_loss; ++i) { >> 1010 if(loss_vector[i]) { loss_vector[i]->SetRandomStep(val); } >> 1011 } >> 1012 } >> 1013 >> 1014 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1015 >> 1016 void G4LossTableManager::SetMinEnergy(G4double val) >> 1017 { >> 1018 minEnergyActive = true; >> 1019 minKinEnergy = val; >> 1020 for(G4int i=0; i<n_loss; ++i) { >> 1021 if(loss_vector[i]) { loss_vector[i]->SetMinKinEnergy(val); } >> 1022 } >> 1023 size_t emp = emp_vector.size(); >> 1024 for (size_t k=0; k<emp; ++k) { >> 1025 if(emp_vector[k]) { emp_vector[k]->SetMinKinEnergy(val); } >> 1026 } >> 1027 } >> 1028 >> 1029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1030 >> 1031 void G4LossTableManager::SetMaxEnergy(G4double val) >> 1032 { >> 1033 maxEnergyActive = true; >> 1034 maxKinEnergy = val; >> 1035 for(G4int i=0; i<n_loss; ++i) { >> 1036 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergy(val); } >> 1037 } >> 1038 size_t emp = emp_vector.size(); >> 1039 for (size_t k=0; k<emp; ++k) { >> 1040 if(emp_vector[k]) { emp_vector[k]->SetMaxKinEnergy(val); } >> 1041 } >> 1042 } >> 1043 >> 1044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1045 >> 1046 void G4LossTableManager::SetMaxEnergyForCSDARange(G4double val) >> 1047 { >> 1048 for(G4int i=0; i<n_loss; ++i) { >> 1049 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergyForCSDARange(val); } >> 1050 } >> 1051 } >> 1052 >> 1053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1054 >> 1055 void G4LossTableManager::SetMaxEnergyForMuons(G4double val) >> 1056 { >> 1057 maxEnergyForMuonsActive = true; >> 1058 maxKinEnergyForMuons = val; >> 1059 } >> 1060 >> 1061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1062 >> 1063 void G4LossTableManager::SetDEDXBinning(G4int val) >> 1064 { >> 1065 for(G4int i=0; i<n_loss; ++i) { >> 1066 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinning(val); } >> 1067 } >> 1068 } >> 1069 >> 1070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1071 >> 1072 void G4LossTableManager::SetDEDXBinningForCSDARange(G4int val) >> 1073 { >> 1074 for(G4int i=0; i<n_loss; ++i) { >> 1075 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinningForCSDARange(val); } >> 1076 } >> 1077 } >> 1078 >> 1079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1080 >> 1081 void G4LossTableManager::SetLambdaBinning(G4int val) >> 1082 { >> 1083 G4int n = val/G4int(std::log10(maxKinEnergy/minKinEnergy) + 0.5); >> 1084 if(n < 5) { >> 1085 G4cout << "G4LossTableManager::SetLambdaBinning WARNING " >> 1086 << "too small number of bins " << val << " ignored" >> 1087 << G4endl; >> 1088 return; >> 1089 } >> 1090 nbinsLambda = val; >> 1091 nbinsPerDecade = n; >> 1092 size_t emp = emp_vector.size(); >> 1093 for (size_t k=0; k<emp; ++k) { >> 1094 if(emp_vector[k]) { emp_vector[k]->SetLambdaBinning(val); } >> 1095 } >> 1096 } >> 1097 >> 1098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1099 >> 1100 G4int G4LossTableManager::GetNumberOfBinsPerDecade() const >> 1101 { >> 1102 return nbinsPerDecade; 889 } 1103 } 890 1104 891 //....oooOO0OOooo........oooOO0OOooo........oo 1105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 892 1106 893 void G4LossTableManager::SetVerbose(G4int val) 1107 void G4LossTableManager::SetVerbose(G4int val) 894 { 1108 { 895 verbose = val; 1109 verbose = val; >> 1110 for(G4int i=0; i<n_loss; ++i) { >> 1111 if(loss_vector[i]) { loss_vector[i]->SetVerboseLevel(val); } >> 1112 } >> 1113 size_t msc = msc_vector.size(); >> 1114 for (size_t j=0; j<msc; ++j) { >> 1115 if(msc_vector[j]) { msc_vector[j]->SetVerboseLevel(val); } >> 1116 } >> 1117 size_t emp = emp_vector.size(); >> 1118 for (size_t k=0; k<emp; ++k) { >> 1119 if(emp_vector[k]) { emp_vector[k]->SetVerboseLevel(val); } >> 1120 } >> 1121 emConfigurator->SetVerbose(val); >> 1122 //tableBuilder->SetVerbose(val); >> 1123 //emCorrections->SetVerbose(val); >> 1124 emSaturation->SetVerbose(val); >> 1125 emElectronIonPair->SetVerbose(val); >> 1126 if(atomDeexcitation) { atomDeexcitation->SetVerboseLevel(val); } >> 1127 } >> 1128 >> 1129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1130 >> 1131 void G4LossTableManager::SetStepFunction(G4double v1, G4double v2) >> 1132 { >> 1133 stepFunctionActive = true; >> 1134 maxRangeVariation = v1; >> 1135 maxFinalStep = v2; >> 1136 for(G4int i=0; i<n_loss; ++i) { >> 1137 if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); } >> 1138 } >> 1139 } >> 1140 >> 1141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1142 >> 1143 void G4LossTableManager::SetLinearLossLimit(G4double val) >> 1144 { >> 1145 for(G4int i=0; i<n_loss; ++i) { >> 1146 if(loss_vector[i]) { loss_vector[i]->SetLinearLossLimit(val); } >> 1147 } >> 1148 } >> 1149 >> 1150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1151 >> 1152 void G4LossTableManager::SetBuildCSDARange(G4bool val) >> 1153 { >> 1154 buildCSDARange = val; >> 1155 } >> 1156 >> 1157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1158 >> 1159 void >> 1160 G4LossTableManager::SetParameters(const G4ParticleDefinition* aParticle, >> 1161 G4VEnergyLossProcess* p) >> 1162 { >> 1163 if(stepFunctionActive) { >> 1164 p->SetStepFunction(maxRangeVariation, maxFinalStep); >> 1165 } >> 1166 if(integralActive) { p->SetIntegral(integral); } >> 1167 if(minEnergyActive) { p->SetMinKinEnergy(minKinEnergy); } >> 1168 if(maxEnergyActive) { p->SetMaxKinEnergy(maxKinEnergy); } >> 1169 // p->SetVerboseLevel(verbose); >> 1170 if(maxEnergyForMuonsActive) { >> 1171 G4double dm = std::abs(aParticle->GetPDGMass() - 105.7*MeV); >> 1172 if(dm < 5.*MeV) { p->SetMaxKinEnergy(maxKinEnergyForMuons); } >> 1173 } 896 } 1174 } 897 1175 898 //....oooOO0OOooo........oooOO0OOooo........oo 1176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 899 1177 900 const std::vector<G4VEnergyLossProcess*>& 1178 const std::vector<G4VEnergyLossProcess*>& 901 G4LossTableManager::GetEnergyLossProcessVector 1179 G4LossTableManager::GetEnergyLossProcessVector() 902 { 1180 { 903 return loss_vector; 1181 return loss_vector; 904 } 1182 } 905 1183 906 //....oooOO0OOooo........oooOO0OOooo........oo 1184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 907 1185 908 const std::vector<G4VEmProcess*>& G4LossTableM 1186 const std::vector<G4VEmProcess*>& G4LossTableManager::GetEmProcessVector() 909 { 1187 { 910 return emp_vector; 1188 return emp_vector; 911 } 1189 } 912 1190 913 //....oooOO0OOooo........oooOO0OOooo........oo 1191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 914 1192 915 const std::vector<G4VMultipleScattering*>& 1193 const std::vector<G4VMultipleScattering*>& 916 G4LossTableManager::GetMultipleScatteringVecto 1194 G4LossTableManager::GetMultipleScatteringVector() 917 { 1195 { 918 return msc_vector; 1196 return msc_vector; 919 } 1197 } 920 1198 >> 1199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1200 >> 1201 void G4LossTableManager::SetLPMFlag(G4bool val) >> 1202 { >> 1203 flagLPM = val; >> 1204 } >> 1205 >> 1206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1207 >> 1208 G4bool G4LossTableManager::LPMFlag() const >> 1209 { >> 1210 return flagLPM; >> 1211 } >> 1212 >> 1213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1214 >> 1215 void G4LossTableManager::SetSplineFlag(G4bool val) >> 1216 { >> 1217 splineFlag = val; >> 1218 tableBuilder->SetSplineFlag(splineFlag); >> 1219 } >> 1220 >> 1221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1222 >> 1223 G4bool G4LossTableManager::SplineFlag() const >> 1224 { >> 1225 return splineFlag; >> 1226 } >> 1227 >> 1228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1229 >> 1230 G4bool G4LossTableManager::IsMaster() const >> 1231 { >> 1232 return isMaster; >> 1233 } >> 1234 >> 1235 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1236 >> 1237 void G4LossTableManager::SetBremsstrahlungTh(G4double val) >> 1238 { >> 1239 bremsTh = val; >> 1240 } >> 1241 >> 1242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1243 >> 1244 G4double G4LossTableManager::BremsstrahlungTh() const >> 1245 { >> 1246 return bremsTh; >> 1247 } >> 1248 >> 1249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1250 >> 1251 void G4LossTableManager::SetFactorForAngleLimit(G4double val) >> 1252 { >> 1253 if(val > 0.0) { factorForAngleLimit = val; } >> 1254 } >> 1255 >> 1256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 1257 >> 1258 G4double G4LossTableManager::FactorForAngleLimit() const >> 1259 { >> 1260 return factorForAngleLimit; >> 1261 } >> 1262 >> 1263 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 1264 >> 1265 G4double G4LossTableManager::MinKinEnergy() const >> 1266 { >> 1267 return minKinEnergy; >> 1268 } >> 1269 >> 1270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 1271 >> 1272 G4double G4LossTableManager::MaxKinEnergy() const >> 1273 { >> 1274 return maxKinEnergy; >> 1275 } >> 1276 >> 1277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 1278 >> 1279 G4EmCorrections* G4LossTableManager::EmCorrections() >> 1280 { >> 1281 return emCorrections; >> 1282 } >> 1283 921 //....oooOO0OOooo........oooOO0OOooo........oo 1284 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 922 1285 923 G4EmSaturation* G4LossTableManager::EmSaturati 1286 G4EmSaturation* G4LossTableManager::EmSaturation() 924 { 1287 { 925 return theParameters->GetEmSaturation(); << 1288 return emSaturation; 926 } 1289 } 927 1290 928 //....oooOO0OOooo........oooOO0OOooo........oo 1291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 929 1292 930 G4EmConfigurator* G4LossTableManager::EmConfig 1293 G4EmConfigurator* G4LossTableManager::EmConfigurator() 931 { 1294 { 932 if(!emConfigurator) { << 933 emConfigurator = new G4EmConfigurator(verb << 934 } << 935 return emConfigurator; 1295 return emConfigurator; 936 } 1296 } 937 1297 938 //....oooOO0OOooo........oooOO0OOooo........oo 1298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 939 1299 940 G4ElectronIonPair* G4LossTableManager::Electro 1300 G4ElectronIonPair* G4LossTableManager::ElectronIonPair() 941 { 1301 { 942 if(!emElectronIonPair) { << 943 emElectronIonPair = new G4ElectronIonPair( << 944 } << 945 return emElectronIonPair; 1302 return emElectronIonPair; 946 } 1303 } 947 1304 948 //....oooOO0OOooo........oooOO0OOooo........oo << 1305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 949 1306 950 void G4LossTableManager::SetNIELCalculator(G4N << 1307 G4VAtomDeexcitation* G4LossTableManager::AtomDeexcitation() 951 { 1308 { 952 if(nullptr != ptr && ptr != nielCalculator) << 1309 return atomDeexcitation; 953 delete nielCalculator; << 954 nielCalculator = ptr; << 955 } << 956 } 1310 } 957 1311 958 //....oooOO0OOooo........oooOO0OOooo........oo << 1312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 959 1313 960 G4NIELCalculator* G4LossTableManager::NIELCalc << 1314 G4LossTableBuilder* G4LossTableManager::GetTableBuilder() 961 { 1315 { 962 if(!nielCalculator) { << 1316 return tableBuilder; 963 nielCalculator = new G4NIELCalculator(null << 964 } << 965 return nielCalculator; << 966 } 1317 } 967 1318 968 //....oooOO0OOooo........oooOO0OOooo........oo 1319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 969 1320 970 void G4LossTableManager::SetAtomDeexcitation(G 1321 void G4LossTableManager::SetAtomDeexcitation(G4VAtomDeexcitation* p) 971 { 1322 { 972 if(atomDeexcitation != p) { 1323 if(atomDeexcitation != p) { 973 delete atomDeexcitation; 1324 delete atomDeexcitation; 974 atomDeexcitation = p; 1325 atomDeexcitation = p; 975 } 1326 } 976 } 1327 } 977 1328 978 //....oooOO0OOooo........oooOO0OOooo........oo 1329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 979 1330 980 void G4LossTableManager::SetSubCutProducer(G4V << 1331 G4VEnergyLossProcess* >> 1332 G4LossTableManager::GetEnergyLossProcess(const G4ParticleDefinition *aParticle) 981 { 1333 { 982 if(subcutProducer != p) { << 1334 if(aParticle != currentParticle) { 983 delete subcutProducer; << 1335 currentParticle = aParticle; 984 subcutProducer = p; << 1336 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos; >> 1337 if ((pos = loss_map.find(aParticle)) != loss_map.end()) { >> 1338 currentLoss = (*pos).second; >> 1339 } else { >> 1340 currentLoss = 0; >> 1341 if(aParticle->GetParticleType() == "nucleus") { >> 1342 if ((pos = loss_map.find(theGenericIon)) != loss_map.end()) { >> 1343 currentLoss = (*pos).second; >> 1344 } >> 1345 } >> 1346 } 985 } 1347 } >> 1348 return currentLoss; 986 } 1349 } 987 1350 988 //....oooOO0OOooo........oooOO0OOooo........oo << 1351 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 989 1352 990 void G4LossTableManager::PrintEWarning(G4Strin << 1353 G4double G4LossTableManager::GetDEDX(const G4ParticleDefinition *aParticle, >> 1354 G4double kineticEnergy, >> 1355 const G4MaterialCutsCouple *couple) 991 { 1356 { 992 G4String ss = "G4LossTableManager::" + tit; << 1357 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 993 G4ExceptionDescription ed; << 1358 G4double x = 0.0; 994 /* << 1359 if(currentLoss) { x = currentLoss->GetDEDX(kineticEnergy, couple); } 995 ed << "Parameter is out of range: " << val << 1360 return x; 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 } 1361 } 1004 1362 1005 //....oooOO0OOooo........oooOO0OOooo........o << 1363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 1006 1364 1007 void G4LossTableManager::DumpHtml() << 1365 G4double G4LossTableManager::GetSubDEDX(const G4ParticleDefinition *aParticle, >> 1366 G4double kineticEnergy, >> 1367 const G4MaterialCutsCouple *couple) 1008 { 1368 { 1009 // Automatic generation of html documentati << 1369 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 1010 // List processes and models for the most i << 1370 G4double x = 0.0; 1011 // particles in descending order of importa << 1371 if(currentLoss) { x = currentLoss->GetDEDXForSubsec(kineticEnergy, couple); } 1012 // NB. for model names with length > 18 cha << 1372 return x; 1013 // to be edited by hand. Or modify G4EmMod << 1373 } 1014 << 1015 char* dirName = std::getenv("G4PhysListDocD << 1016 char* physList = std::getenv("G4PhysListNam << 1017 if (dirName && physList) { << 1018 G4String physListName = G4String(physList << 1019 G4String pathName = G4String(dirName) + " << 1020 << 1021 std::ofstream outFile; << 1022 outFile.open(pathName); << 1023 << 1024 outFile << physListName << G4endl; << 1025 outFile << std::string(physListName.lengt << 1026 << 1027 std::vector<G4ParticleDefinition*> partic << 1028 G4Gamma::Gamma(), << 1029 G4Electron::Electron(), << 1030 G4Positron::Positron(), << 1031 G4Proton::ProtonDefinition(), << 1032 G4MuonPlus::MuonPlusDefinition(), << 1033 G4MuonMinus::MuonMinusDefinition(), << 1034 }; << 1035 << 1036 std::vector<G4VEmProcess*> emproc_vector << 1037 std::vector<G4VEnergyLossProcess*> enloss << 1038 GetEnergyLossProcessVector(); << 1039 std::vector<G4VMultipleScattering*> mscat << 1040 GetMultipleScatteringVector(); << 1041 << 1042 for (auto theParticle : particles) { << 1043 outFile << G4endl << "**" << theParticl << 1044 << "**" << G4endl << G4endl << << 1045 << 1046 G4ProcessManager* pm = theParticle->Get << 1047 G4ProcessVector* pv = pm->GetProcessLi << 1048 G4int plen = pm->GetProcessListLength() << 1049 << 1050 for (auto emproc : emproc_vector) { << 1051 for (G4int i = 0; i < plen; ++i) { << 1052 G4VProcess* proc = (*pv)[i]; << 1053 if (proc == emproc) { << 1054 outFile << G4endl; << 1055 proc->ProcessDescription(outFile) << 1056 break; << 1057 } << 1058 } << 1059 } << 1060 1374 1061 for (auto mscproc : mscat_vector) { << 1375 //....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 1376 1072 for (auto enlossproc : enloss_vector) { << 1377 G4double G4LossTableManager::GetCSDARange(const G4ParticleDefinition *aParticle, 1073 for (G4int i = 0; i < plen; ++i) { << 1378 G4double kineticEnergy, 1074 G4VProcess* proc = (*pv)[i]; << 1379 const G4MaterialCutsCouple *couple) 1075 if (proc == enlossproc) { << 1380 { 1076 outFile << G4endl; << 1381 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } 1077 proc->ProcessDescription(outFile) << 1382 G4double x = DBL_MAX; 1078 break; << 1383 if(currentLoss) { x = currentLoss->GetCSDARange(kineticEnergy, couple); } 1079 } << 1384 return x; 1080 } << 1385 } 1081 } << 1386 1082 } << 1387 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 1083 outFile.close(); << 1388 1084 } << 1389 G4double G4LossTableManager::GetRangeFromRestricteDEDX( >> 1390 const G4ParticleDefinition *aParticle, >> 1391 G4double kineticEnergy, >> 1392 const G4MaterialCutsCouple *couple) >> 1393 { >> 1394 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } >> 1395 G4double x = DBL_MAX; >> 1396 if(currentLoss) { x = currentLoss->GetRangeForLoss(kineticEnergy, couple); } >> 1397 return x; 1085 } 1398 } 1086 1399 1087 //....oooOO0OOooo........oooOO0OOooo........o 1400 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 1088 1401 >> 1402 G4double G4LossTableManager::GetRange(const G4ParticleDefinition *aParticle, >> 1403 G4double kineticEnergy, >> 1404 const G4MaterialCutsCouple *couple) >> 1405 { >> 1406 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } >> 1407 G4double x = DBL_MAX; >> 1408 if(currentLoss) { x = currentLoss->GetRange(kineticEnergy, couple); } >> 1409 return x; >> 1410 } >> 1411 >> 1412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 1413 >> 1414 G4double G4LossTableManager::GetEnergy(const G4ParticleDefinition *aParticle, >> 1415 G4double range, >> 1416 const G4MaterialCutsCouple *couple) >> 1417 { >> 1418 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } >> 1419 G4double x = 0; >> 1420 if(currentLoss) { x = currentLoss->GetKineticEnergy(range, couple); } >> 1421 return x; >> 1422 } >> 1423 >> 1424 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 1425 >> 1426 G4double G4LossTableManager::GetDEDXDispersion( >> 1427 const G4MaterialCutsCouple *couple, >> 1428 const G4DynamicParticle* dp, >> 1429 G4double& length) >> 1430 { >> 1431 const G4ParticleDefinition* aParticle = dp->GetParticleDefinition(); >> 1432 if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); } >> 1433 G4double x = 0.0; >> 1434 if(currentLoss) { currentLoss->GetDEDXDispersion(couple, dp, length); } >> 1435 return x; >> 1436 } >> 1437 >> 1438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1089 1439