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 92921 2015-09-21 15:06:51Z 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" >> 86 #include "G4EnergyLossMessenger.hh" 49 87 50 #include "G4VMultipleScattering.hh" 88 #include "G4VMultipleScattering.hh" 51 #include "G4VEmProcess.hh" 89 #include "G4VEmProcess.hh" 52 90 53 #include "G4EmParameters.hh" << 54 #include "G4EmSaturation.hh" 91 #include "G4EmSaturation.hh" 55 #include "G4EmConfigurator.hh" 92 #include "G4EmConfigurator.hh" 56 #include "G4ElectronIonPair.hh" 93 #include "G4ElectronIonPair.hh" 57 #include "G4NIELCalculator.hh" << 58 #include "G4EmCorrections.hh" << 59 #include "G4LossTableBuilder.hh" << 60 #include "G4VAtomDeexcitation.hh" << 61 #include "G4VSubCutProducer.hh" << 62 94 63 #include "G4PhysicsTable.hh" 95 #include "G4PhysicsTable.hh" 64 #include "G4ParticleDefinition.hh" 96 #include "G4ParticleDefinition.hh" 65 #include "G4MaterialCutsCouple.hh" 97 #include "G4MaterialCutsCouple.hh" 66 #include "G4ProcessManager.hh" 98 #include "G4ProcessManager.hh" 67 #include "G4Electron.hh" 99 #include "G4Electron.hh" 68 #include "G4Proton.hh" 100 #include "G4Proton.hh" 69 #include "G4ProductionCutsTable.hh" 101 #include "G4ProductionCutsTable.hh" 70 #include "G4PhysicsTableHelper.hh" 102 #include "G4PhysicsTableHelper.hh" 71 #include "G4EmTableType.hh" 103 #include "G4EmTableType.hh" 72 #include "G4Region.hh" 104 #include "G4Region.hh" 73 #include "G4PhysicalConstants.hh" 105 #include "G4PhysicalConstants.hh" 74 << 106 #include "G4Threading.hh" 75 #include "G4Gamma.hh" << 76 #include "G4Positron.hh" << 77 #include "G4OpticalPhoton.hh" << 78 #include "G4Neutron.hh" << 79 #include "G4MuonPlus.hh" << 80 #include "G4MuonMinus.hh" << 81 #include "G4GenericIon.hh" << 82 107 83 //....oooOO0OOooo........oooOO0OOooo........oo 108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 84 109 85 static std::once_flag applyOnce; << 110 G4ThreadLocal G4LossTableManager* G4LossTableManager::instance = 0; 86 G4ThreadLocal G4LossTableManager* G4LossTableM << 87 111 88 G4LossTableManager* G4LossTableManager::Instan 112 G4LossTableManager* G4LossTableManager::Instance() 89 { 113 { 90 if(nullptr == instance) { << 114 if(!instance) { 91 static G4ThreadLocalSingleton<G4LossTableM 115 static G4ThreadLocalSingleton<G4LossTableManager> inst; 92 instance = inst.Instance(); 116 instance = inst.Instance(); 93 } 117 } 94 return instance; 118 return instance; 95 } 119 } 96 120 97 //....oooOO0OOooo........oooOO0OOooo........oo 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 98 122 99 G4LossTableManager::~G4LossTableManager() 123 G4LossTableManager::~G4LossTableManager() 100 { 124 { 101 for (auto const & p : loss_vector) { delete << 125 //G4cout << "### G4LossTableManager::~G4LossTableManager()" << G4endl; 102 for (auto const & p : msc_vector) { delete p << 126 for (G4int i=0; i<n_loss; ++i) { 103 for (auto const & p : emp_vector) { delete p << 127 //G4cout << "### eloss #" << i << G4endl; 104 for (auto const & p : p_vector) { delete p; << 128 if( loss_vector[i] ) { 105 << 129 delete loss_vector[i]; 106 std::size_t mod = mod_vector.size(); << 130 } 107 std::size_t fmod = fmod_vector.size(); << 131 } 108 for (std::size_t a=0; a<mod; ++a) { << 132 size_t msc = msc_vector.size(); 109 if( nullptr != mod_vector[a] ) { << 133 for (size_t j=0; j<msc; ++j) { 110 for (std::size_t b=0; b<fmod; ++b) { << 134 if( msc_vector[j] ) { delete msc_vector[j]; } >> 135 } >> 136 size_t emp = emp_vector.size(); >> 137 for (size_t k=0; k<emp; ++k) { >> 138 if( emp_vector[k] ) { delete emp_vector[k]; } >> 139 } >> 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) { 111 if((G4VEmModel*)(fmod_vector[b]) == mo 145 if((G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) { 112 fmod_vector[b] = nullptr; << 146 fmod_vector[b] = 0; 113 } 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; 163 delete subcutProducer; 129 } 164 } 130 165 131 //....oooOO0OOooo........oooOO0OOooo........oo 166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 132 167 133 G4LossTableManager::G4LossTableManager() 168 G4LossTableManager::G4LossTableManager() 134 { 169 { 135 theParameters = G4EmParameters::Instance(); 170 theParameters = G4EmParameters::Instance(); 136 theElectron = G4Electron::Electron(); << 171 n_loss = 0; 137 << 172 run = -1; 138 // only one thread is the master << 173 startInitialisation = false; 139 std::call_once(applyOnce, [this]() { isMaste << 174 all_tables_are_built = false; 140 verbose = isMaster ? theParameters->Verbose( << 175 currentLoss = nullptr; 141 << 176 currentParticle = nullptr; 142 tableBuilder = new G4LossTableBuilder(isMast << 177 firstParticle = nullptr; 143 emCorrections = new G4EmCorrections(verbose) << 178 subCutoffFlag = false; 144 << 179 maxRangeVariation = 0.2; 145 std::size_t n = 70; << 180 maxFinalStep = CLHEP::mm; 146 loss_vector.reserve(n); << 181 integral = true; 147 part_vector.reserve(n); << 182 integralActive = false; 148 base_part_vector.reserve(n); << 183 stepFunctionActive = false; 149 dedx_vector.reserve(n); << 184 isMaster = true; 150 range_vector.reserve(n); << 185 verbose = theParameters->Verbose(); 151 inv_range_vector.reserve(n); << 186 theMessenger = new G4EnergyLossMessenger(); 152 tables_are_built.reserve(n); << 187 theElectron = G4Electron::Electron(); 153 isActive.reserve(n); << 188 theGenericIon= nullptr; 154 msc_vector.reserve(10); << 189 if(G4Threading::IsWorkerThread()) { 155 emp_vector.reserve(16); << 190 verbose = theParameters->WorkerVerbose(); 156 mod_vector.reserve(150); << 191 isMaster = false; 157 fmod_vector.reserve(60); << 192 } >> 193 tableBuilder = new G4LossTableBuilder(); >> 194 emCorrections= new G4EmCorrections(verbose); >> 195 emSaturation = nullptr; >> 196 emConfigurator = nullptr; >> 197 emElectronIonPair = nullptr; >> 198 atomDeexcitation = nullptr; >> 199 subcutProducer = nullptr; 158 } 200 } 159 201 160 //....oooOO0OOooo........oooOO0OOooo........oo 202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 161 203 162 void G4LossTableManager::Clear() 204 void G4LossTableManager::Clear() 163 { 205 { 164 all_tables_are_built = false; 206 all_tables_are_built = false; 165 currentLoss = nullptr; 207 currentLoss = nullptr; 166 currentParticle = nullptr; 208 currentParticle = nullptr; 167 if(n_loss) { << 209 if(n_loss) 168 dedx_vector.clear(); << 210 { 169 range_vector.clear(); << 211 dedx_vector.clear(); 170 inv_range_vector.clear(); << 212 range_vector.clear(); 171 loss_map.clear(); << 213 inv_range_vector.clear(); 172 loss_vector.clear(); << 214 loss_map.clear(); 173 part_vector.clear(); << 215 loss_vector.clear(); 174 base_part_vector.clear(); << 216 part_vector.clear(); 175 tables_are_built.clear(); << 217 base_part_vector.clear(); 176 isActive.clear(); << 218 tables_are_built.clear(); 177 n_loss = 0; << 219 isActive.clear(); 178 } << 220 n_loss = 0; >> 221 } 179 } 222 } 180 223 181 //....oooOO0OOooo........oooOO0OOooo........oo 224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 182 225 183 void G4LossTableManager::Register(G4VEnergyLos 226 void G4LossTableManager::Register(G4VEnergyLossProcess* p) 184 { 227 { 185 if (nullptr == p) { return; } << 228 if(!p) { return; } 186 for (G4int i=0; i<n_loss; ++i) { 229 for (G4int i=0; i<n_loss; ++i) { 187 if(loss_vector[i] == p) { return; } 230 if(loss_vector[i] == p) { return; } 188 } 231 } 189 if(verbose > 1) { 232 if(verbose > 1) { 190 G4cout << "G4LossTableManager::Register G4 233 G4cout << "G4LossTableManager::Register G4VEnergyLossProcess : " 191 << p->GetProcessName() << " idx= " 234 << p->GetProcessName() << " idx= " << n_loss << G4endl; 192 } 235 } 193 ++n_loss; 236 ++n_loss; 194 loss_vector.push_back(p); 237 loss_vector.push_back(p); 195 part_vector.push_back(nullptr); 238 part_vector.push_back(nullptr); 196 base_part_vector.push_back(nullptr); 239 base_part_vector.push_back(nullptr); 197 dedx_vector.push_back(nullptr); 240 dedx_vector.push_back(nullptr); 198 range_vector.push_back(nullptr); 241 range_vector.push_back(nullptr); 199 inv_range_vector.push_back(nullptr); 242 inv_range_vector.push_back(nullptr); 200 tables_are_built.push_back(false); 243 tables_are_built.push_back(false); 201 isActive.push_back(true); 244 isActive.push_back(true); 202 all_tables_are_built = false; 245 all_tables_are_built = false; >> 246 if(subCutoffFlag) { p->ActivateSubCutoff(true); } >> 247 if(stepFunctionActive) { p->SetStepFunction(maxRangeVariation, >> 248 maxFinalStep); } >> 249 if(integralActive) { p->SetIntegral(integral); } 203 } 250 } 204 251 205 //....oooOO0OOooo........oooOO0OOooo........oo 252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 206 253 207 void G4LossTableManager::ResetParameters() 254 void G4LossTableManager::ResetParameters() 208 { 255 { 209 // initialisation once per run << 210 if (!resetParam) { return; } << 211 resetParam = false; << 212 startInitialisation = true; << 213 verbose = theParameters->Verbose(); 256 verbose = theParameters->Verbose(); 214 if(!isMaster) { 257 if(!isMaster) { 215 verbose = theParameters->WorkerVerbose(); 258 verbose = theParameters->WorkerVerbose(); 216 } else { << 217 if(verbose > 0) { theParameters->Dump(); } << 218 } 259 } 219 << 260 tableBuilder->SetSplineFlag(theParameters->Spline()); 220 tableBuilder->InitialiseBaseMaterials(); << 261 tableBuilder->SetInitialisationFlag(false); 221 if (nullptr != nielCalculator) { nielCalcula << 222 << 223 emCorrections->SetVerbose(verbose); 262 emCorrections->SetVerbose(verbose); 224 if(nullptr != emConfigurator) { emConfigurat << 263 if(emSaturation) { emSaturation->SetVerbose(verbose); } 225 if(nullptr != emElectronIonPair) { emElectro << 264 if(emConfigurator) { emConfigurator->SetVerbose(verbose); }; 226 if(nullptr != atomDeexcitation) { << 265 if(emElectronIonPair) { emElectronIonPair->SetVerbose(verbose); }; >> 266 if(atomDeexcitation) { 227 atomDeexcitation->SetVerboseLevel(verbose) 267 atomDeexcitation->SetVerboseLevel(verbose); 228 atomDeexcitation->InitialiseAtomicDeexcita 268 atomDeexcitation->InitialiseAtomicDeexcitation(); 229 } 269 } 230 if (1 < verbose) { << 231 G4cout << "====== G4LossTableManager::Rese << 232 << " Nloss=" << loss_vector.size() << 233 << " run=" << run << " master=" << isMast << 234 << G4endl; << 235 } << 236 } 270 } 237 271 238 //....oooOO0OOooo........oooOO0OOooo........oo 272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 239 273 240 void G4LossTableManager::DeRegister(G4VEnergyL 274 void G4LossTableManager::DeRegister(G4VEnergyLossProcess* p) 241 { 275 { 242 if (nullptr == p) { return; } << 276 if(!p) { return; } 243 for (G4int i=0; i<n_loss; ++i) { 277 for (G4int i=0; i<n_loss; ++i) { 244 if(loss_vector[i] == p) { << 278 if(loss_vector[i] == p) { loss_vector[i] = nullptr; } 245 loss_vector[i] = nullptr; << 246 break; << 247 } << 248 } 279 } 249 } 280 } 250 281 251 //....oooOO0OOooo........oooOO0OOooo........oo 282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 252 283 253 void G4LossTableManager::Register(G4VMultipleS 284 void G4LossTableManager::Register(G4VMultipleScattering* p) 254 { 285 { 255 if (nullptr == p) { return; } << 286 if(!p) { return; } 256 std::size_t n = msc_vector.size(); << 287 G4int n = msc_vector.size(); 257 for (std::size_t i=0; i<n; ++i) { << 288 for (G4int i=0; i<n; ++i) { 258 if(msc_vector[i] == p) { return; } 289 if(msc_vector[i] == p) { return; } 259 } 290 } 260 if(verbose > 1) { 291 if(verbose > 1) { 261 G4cout << "G4LossTableManager::Register G4 292 G4cout << "G4LossTableManager::Register G4VMultipleScattering : " 262 << p->GetProcessName() << " idx= " 293 << p->GetProcessName() << " idx= " << msc_vector.size() << G4endl; 263 } 294 } 264 msc_vector.push_back(p); 295 msc_vector.push_back(p); 265 } 296 } 266 297 267 //....oooOO0OOooo........oooOO0OOooo........oo 298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 268 299 269 void G4LossTableManager::DeRegister(G4VMultipl 300 void G4LossTableManager::DeRegister(G4VMultipleScattering* p) 270 { 301 { 271 if (nullptr == p) { return; } << 302 if(!p) { return; } 272 std::size_t msc = msc_vector.size(); << 303 size_t msc = msc_vector.size(); 273 for (std::size_t i=0; i<msc; ++i) { << 304 for (size_t i=0; i<msc; ++i) { 274 if(msc_vector[i] == p) { << 305 if(msc_vector[i] == p) { msc_vector[i] = nullptr; } 275 msc_vector[i] = nullptr; << 276 break; << 277 } << 278 } 306 } 279 } 307 } 280 308 281 //....oooOO0OOooo........oooOO0OOooo........oo 309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 282 310 283 void G4LossTableManager::Register(G4VEmProcess 311 void G4LossTableManager::Register(G4VEmProcess* p) 284 { 312 { 285 if (nullptr == p) { return; } << 313 if(!p) { return; } 286 std::size_t n = emp_vector.size(); << 314 G4int n = emp_vector.size(); 287 for (std::size_t i=0; i<n; ++i) { << 315 for (G4int i=0; i<n; ++i) { 288 if(emp_vector[i] == p) { return; } 316 if(emp_vector[i] == p) { return; } 289 } 317 } 290 if(verbose > 1) { 318 if(verbose > 1) { 291 G4cout << "G4LossTableManager::Register G4 319 G4cout << "G4LossTableManager::Register G4VEmProcess : " 292 << p->GetProcessName() << " idx= " 320 << p->GetProcessName() << " idx= " << emp_vector.size() << G4endl; 293 } 321 } 294 emp_vector.push_back(p); 322 emp_vector.push_back(p); 295 } 323 } 296 324 297 //....oooOO0OOooo........oooOO0OOooo........oo 325 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 298 326 299 void G4LossTableManager::DeRegister(G4VEmProce 327 void G4LossTableManager::DeRegister(G4VEmProcess* p) 300 { 328 { 301 if (nullptr == p) { return; } << 329 if(!p) { return; } 302 std::size_t emp = emp_vector.size(); << 330 size_t emp = emp_vector.size(); 303 for (std::size_t i=0; i<emp; ++i) { << 331 for (size_t i=0; i<emp; ++i) { 304 if(emp_vector[i] == p) { << 332 if(emp_vector[i] == p) { emp_vector[i] = nullptr; } 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 } 333 } 339 } 334 } 340 335 341 //....oooOO0OOooo........oooOO0OOooo........oo 336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 342 337 343 void G4LossTableManager::Register(G4VEmModel* 338 void G4LossTableManager::Register(G4VEmModel* p) 344 { 339 { 345 mod_vector.push_back(p); 340 mod_vector.push_back(p); 346 if(verbose > 1) { 341 if(verbose > 1) { 347 G4cout << "G4LossTableManager::Register G4 342 G4cout << "G4LossTableManager::Register G4VEmModel : " 348 << p->GetName() << " " << p << " << 343 << p->GetName() << G4endl; 349 } 344 } 350 } 345 } 351 346 352 //....oooOO0OOooo........oooOO0OOooo........oo 347 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 353 348 354 void G4LossTableManager::DeRegister(G4VEmModel 349 void G4LossTableManager::DeRegister(G4VEmModel* p) 355 { 350 { 356 //G4cout << "G4LossTableManager::DeRegister << 351 size_t n = mod_vector.size(); 357 std::size_t n = mod_vector.size(); << 352 for (size_t i=0; i<n; ++i) { 358 for (std::size_t i=0; i<n; ++i) { << 353 if(mod_vector[i] == p) { mod_vector[i] = nullptr; } 359 if(mod_vector[i] == p) { << 360 mod_vector[i] = nullptr; << 361 break; << 362 } << 363 } 354 } 364 } 355 } 365 356 366 //....oooOO0OOooo........oooOO0OOooo........oo 357 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 367 358 368 void G4LossTableManager::Register(G4VEmFluctua 359 void G4LossTableManager::Register(G4VEmFluctuationModel* p) 369 { 360 { 370 fmod_vector.push_back(p); 361 fmod_vector.push_back(p); 371 if(verbose > 1) { 362 if(verbose > 1) { 372 G4cout << "G4LossTableManager::Register G4 363 G4cout << "G4LossTableManager::Register G4VEmFluctuationModel : " 373 << p->GetName() << " " << fmod_vec << 364 << p->GetName() << G4endl; 374 } 365 } 375 } 366 } 376 367 377 //....oooOO0OOooo........oooOO0OOooo........oo 368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 378 369 379 void G4LossTableManager::DeRegister(G4VEmFluct 370 void G4LossTableManager::DeRegister(G4VEmFluctuationModel* p) 380 { 371 { 381 std::size_t n = fmod_vector.size(); << 372 size_t n = fmod_vector.size(); 382 for (std::size_t i=0; i<n; ++i) { << 373 for (size_t i=0; i<n; ++i) { 383 if(fmod_vector[i] == p) { fmod_vector[i] = 374 if(fmod_vector[i] == p) { fmod_vector[i] = nullptr; } 384 } 375 } 385 } 376 } 386 377 387 //....oooOO0OOooo........oooOO0OOooo........oo 378 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 388 379 389 void G4LossTableManager::RegisterExtraParticle 380 void G4LossTableManager::RegisterExtraParticle( 390 const G4ParticleDefinition* part, 381 const G4ParticleDefinition* part, 391 G4VEnergyLossProcess* p) 382 G4VEnergyLossProcess* p) 392 { 383 { 393 if (nullptr == p || nullptr == part) { retur << 384 if(!p || !part) { return; } 394 for (G4int i=0; i<n_loss; ++i) { 385 for (G4int i=0; i<n_loss; ++i) { 395 if(loss_vector[i] == p) { return; } 386 if(loss_vector[i] == p) { return; } 396 } 387 } 397 if(verbose > 1) { 388 if(verbose > 1) { 398 G4cout << "G4LossTableManager::RegisterExt 389 G4cout << "G4LossTableManager::RegisterExtraParticle " 399 << part->GetParticleName() << " G4 390 << part->GetParticleName() << " G4VEnergyLossProcess : " 400 << p->GetProcessName() << " idx= " 391 << p->GetProcessName() << " idx= " << n_loss << G4endl; 401 } 392 } 402 ++n_loss; 393 ++n_loss; 403 loss_vector.push_back(p); 394 loss_vector.push_back(p); 404 part_vector.push_back(part); 395 part_vector.push_back(part); 405 base_part_vector.push_back(p->BaseParticle() 396 base_part_vector.push_back(p->BaseParticle()); 406 dedx_vector.push_back(nullptr); 397 dedx_vector.push_back(nullptr); 407 range_vector.push_back(nullptr); 398 range_vector.push_back(nullptr); 408 inv_range_vector.push_back(nullptr); 399 inv_range_vector.push_back(nullptr); 409 tables_are_built.push_back(false); 400 tables_are_built.push_back(false); 410 all_tables_are_built = false; 401 all_tables_are_built = false; 411 } 402 } 412 403 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 404 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 435 405 436 void 406 void 437 G4LossTableManager::PreparePhysicsTable(const 407 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 438 G4VEne << 408 G4VEnergyLossProcess* p, >> 409 G4bool theMaster) 439 { 410 { 440 if (1 < verbose) { 411 if (1 < verbose) { 441 G4cout << "G4LossTableManager::PreparePhys 412 G4cout << "G4LossTableManager::PreparePhysicsTable for " 442 << particle->GetParticleName() 413 << particle->GetParticleName() 443 << " and " << p->GetProcessName() < 414 << " and " << p->GetProcessName() << " run= " << run 444 << " loss_vector " << loss_vector << 415 << " loss_vector " << loss_vector.size() << G4endl; 445 << " run=" << run << " master=" << isMast << 416 } 446 << G4endl; << 417 >> 418 isMaster = theMaster; >> 419 >> 420 if(!startInitialisation) { >> 421 ResetParameters(); >> 422 if (1 < verbose) { >> 423 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 424 << G4endl; >> 425 } 447 } 426 } 448 427 449 // start initialisation for the first run 428 // start initialisation for the first run 450 if( -1 == run ) { 429 if( -1 == run ) { 451 if (nullptr != emConfigurator) { emConfigu << 430 if(emConfigurator) { emConfigurator->PrepareModels(particle, p); } 452 431 453 // initialise particles for given process 432 // initialise particles for given process 454 for (G4int j=0; j<n_loss; ++j) { 433 for (G4int j=0; j<n_loss; ++j) { 455 if (p == loss_vector[j] && nullptr == pa << 434 if (p == loss_vector[j] && !part_vector[j]) { 456 part_vector[j] = particle; 435 part_vector[j] = particle; 457 if (particle->GetParticleName() == "Ge << 436 if(particle->GetParticleName() == "GenericIon") { 458 theGenericIon = particle; 437 theGenericIon = particle; 459 } 438 } 460 } 439 } 461 } 440 } 462 } 441 } 463 ResetParameters(); << 442 startInitialisation = true; 464 } 443 } 465 444 466 //....oooOO0OOooo........oooOO0OOooo........oo 445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 467 446 468 void 447 void 469 G4LossTableManager::PreparePhysicsTable(const 448 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 470 G4VEmP << 449 G4VEmProcess* p, G4bool theMaster) 471 { 450 { 472 if (1 < verbose) { 451 if (1 < verbose) { 473 G4cout << "G4LossTableManager::PreparePhys 452 G4cout << "G4LossTableManager::PreparePhysicsTable for " 474 << particle->GetParticleName() 453 << particle->GetParticleName() 475 << " and " << p->GetProcessName() << 454 << " and " << p->GetProcessName() << G4endl; 476 << " run=" << run << " master=" << isMast << 455 } 477 << G4endl; << 456 isMaster = theMaster; >> 457 >> 458 if(!startInitialisation) { >> 459 ResetParameters(); >> 460 if (1 < verbose) { >> 461 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 462 << G4endl; >> 463 } 478 } 464 } 479 465 480 // start initialisation for the first run 466 // start initialisation for the first run 481 if( -1 == run ) { 467 if( -1 == run ) { 482 if (nullptr != emConfigurator) { emConfigu << 468 if(emConfigurator) { emConfigurator->PrepareModels(particle, p); } 483 } 469 } 484 << 470 startInitialisation = true; 485 ResetParameters(); << 486 } 471 } 487 472 488 //....oooOO0OOooo........oooOO0OOooo........oo 473 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 489 474 490 void 475 void 491 G4LossTableManager::PreparePhysicsTable(const 476 G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle, 492 G4VMul << 477 G4VMultipleScattering* p, >> 478 G4bool theMaster) 493 { 479 { 494 if (1 < verbose) { 480 if (1 < verbose) { 495 G4cout << "G4LossTableManager::PreparePhys 481 G4cout << "G4LossTableManager::PreparePhysicsTable for " 496 << particle->GetParticleName() 482 << particle->GetParticleName() 497 << " and " << p->GetProcessName() << 483 << " and " << p->GetProcessName() << G4endl; 498 << " run=" << run << " master=" << isMast << 484 } 499 << G4endl; << 485 >> 486 isMaster = theMaster; >> 487 >> 488 if(!startInitialisation) { >> 489 ResetParameters(); >> 490 if (1 < verbose) { >> 491 G4cout << "====== G4LossTableManager::PreparePhysicsTable start =====" >> 492 << G4endl; >> 493 } 500 } 494 } 501 495 502 // start initialisation for the first run 496 // start initialisation for the first run 503 if ( -1 == run ) { << 497 if( -1 == run ) { 504 if (nullptr != emConfigurator) { emConfigu << 498 if(emConfigurator) { emConfigurator->PrepareModels(particle, p); } 505 } 499 } 506 << 500 startInitialisation = true; 507 ResetParameters(); << 508 } 501 } 509 502 510 //....oooOO0OOooo........oooOO0OOooo........oo 503 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 511 504 512 void 505 void 513 G4LossTableManager::BuildPhysicsTable(const G4 506 G4LossTableManager::BuildPhysicsTable(const G4ParticleDefinition*) 514 { 507 { 515 if(-1 == run && startInitialisation) { 508 if(-1 == run && startInitialisation) { 516 if (nullptr != emConfigurator) { emConfigu << 509 if(emConfigurator) { emConfigurator->Clear(); } 517 } 510 } 518 if (startInitialisation) { resetParam = true << 519 } 511 } 520 512 521 //....oooOO0OOooo........oooOO0OOooo........oo 513 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 522 514 523 void G4LossTableManager::LocalPhysicsTables( 515 void G4LossTableManager::LocalPhysicsTables( 524 const G4ParticleDefinition* aParticle, 516 const G4ParticleDefinition* aParticle, 525 G4VEnergyLossProcess* p) 517 G4VEnergyLossProcess* p) 526 { 518 { 527 if (1 < verbose) { << 519 if(1 < verbose) { 528 G4cout << "### G4LossTableManager::LocalPh 520 G4cout << "### G4LossTableManager::LocalPhysicsTable() for " 529 << aParticle->GetParticleName() 521 << aParticle->GetParticleName() 530 << " and process " << p->GetProcess << 522 << " and process " << p->GetProcessName() 531 << G4endl; 523 << G4endl; 532 } 524 } 533 525 534 if(-1 == run && startInitialisation) { 526 if(-1 == run && startInitialisation) { 535 if (nullptr != emConfigurator) { emConfigu << 527 if(emConfigurator) { emConfigurator->Clear(); } 536 firstParticle = aParticle; 528 firstParticle = aParticle; 537 } 529 } 538 530 539 if (startInitialisation) { << 531 if(startInitialisation) { 540 ++run; 532 ++run; 541 if (1 < verbose) { << 533 SetVerbose(verbose); >> 534 if(1 < verbose) { 542 G4cout << "===== G4LossTableManager::Loc 535 G4cout << "===== G4LossTableManager::LocalPhysicsTable() for run " 543 << run << " =====" << G4endl; 536 << run << " =====" << G4endl; 544 } 537 } >> 538 if(0 < verbose) { emSaturation->DumpG4BirksCoefficients(); } 545 currentParticle = nullptr; 539 currentParticle = nullptr; 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] = nullptr; 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; 563 part_vector[i] = p->Particle(); 556 part_vector[i] = p->Particle(); 564 base_part_vector[i] = p->BaseParticle(); 557 base_part_vector[i] = p->BaseParticle(); 565 dedx_vector[i] = p->DEDXTable(); 558 dedx_vector[i] = p->DEDXTable(); 566 range_vector[i] = p->RangeTableForLoss() 559 range_vector[i] = p->RangeTableForLoss(); 567 inv_range_vector[i] = p->InverseRangeTab 560 inv_range_vector[i] = p->InverseRangeTable(); 568 if(0 == run && p->IsIonisationProcess()) 561 if(0 == run && p->IsIonisationProcess()) { 569 loss_map[part_vector[i]] = p; << 562 loss_map[part_vector[i]] = loss_vector[i]; 570 } 563 } 571 564 572 if(1 < verbose) { 565 if(1 < verbose) { 573 G4cout << i <<". "<< p->GetProcessNa 566 G4cout << i <<". "<< p->GetProcessName(); 574 if(part_vector[i]) { 567 if(part_vector[i]) { 575 G4cout << " for " << part_vector[i 568 G4cout << " for " << part_vector[i]->GetParticleName(); 576 } 569 } 577 G4cout << " active= " << isActive[i] 570 G4cout << " active= " << isActive[i] 578 << " table= " << tables_are_bu 571 << " table= " << tables_are_built[i] 579 << " isIonisation= " << p->IsI 572 << " isIonisation= " << p->IsIonisationProcess() 580 << G4endl; 573 << G4endl; 581 } 574 } 582 break; 575 break; 583 } else if(!tables_are_built[i]) { 576 } else if(!tables_are_built[i]) { 584 all_tables_are_built = false; 577 all_tables_are_built = false; 585 } 578 } 586 } 579 } 587 580 >> 581 // Set run time parameters >> 582 SetParameters(aParticle, p); >> 583 588 if(1 < verbose) { 584 if(1 < verbose) { 589 G4cout << "### G4LossTableManager::LocalPh 585 G4cout << "### G4LossTableManager::LocalPhysicsTable end" 590 << G4endl; 586 << G4endl; 591 } 587 } 592 if(all_tables_are_built) { 588 if(all_tables_are_built) { 593 if(1 < verbose) { 589 if(1 < verbose) { 594 G4cout << "%%%%% All dEdx and Range tabl 590 G4cout << "%%%%% All dEdx and Range tables for worker are ready for run " 595 << run << " %%%%%" << G4endl; 591 << run << " %%%%%" << G4endl; 596 } 592 } 597 } 593 } 598 } 594 } 599 595 600 //....oooOO0OOooo........oooOO0OOooo........oo 596 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 601 597 602 void G4LossTableManager::BuildPhysicsTable( 598 void G4LossTableManager::BuildPhysicsTable( 603 const G4ParticleDefinition* aParticle, 599 const G4ParticleDefinition* aParticle, 604 G4VEnergyLossProcess* p) 600 G4VEnergyLossProcess* p) 605 { 601 { 606 if(1 < verbose) { 602 if(1 < verbose) { 607 G4cout << "### G4LossTableManager::BuildPh 603 G4cout << "### G4LossTableManager::BuildPhysicsTable() for " 608 << aParticle->GetParticleName() 604 << aParticle->GetParticleName() 609 << " and process " << p->GetProcess 605 << " and process " << p->GetProcessName() << G4endl; 610 } 606 } 611 // clear configurator 607 // clear configurator 612 if(-1 == run && startInitialisation) { 608 if(-1 == run && startInitialisation) { 613 if( nullptr != emConfigurator) { emConfigu << 609 if(emConfigurator) { emConfigurator->Clear(); } 614 firstParticle = aParticle; 610 firstParticle = aParticle; 615 } 611 } 616 if(startInitialisation) { 612 if(startInitialisation) { 617 ++run; 613 ++run; 618 resetParam = true; << 619 startInitialisation = false; << 620 if(1 < verbose) { 614 if(1 < verbose) { 621 G4cout << "===== G4LossTableManager::Bui 615 G4cout << "===== G4LossTableManager::BuildPhysicsTable() for run " 622 << run << " ===== " << atomDeexci 616 << run << " ===== " << atomDeexcitation << G4endl; 623 } 617 } 624 currentParticle = nullptr; 618 currentParticle = nullptr; 625 all_tables_are_built = false; << 619 all_tables_are_built= true; >> 620 } >> 621 >> 622 // initialisation before any table is built >> 623 if ( startInitialisation && aParticle == firstParticle ) { 626 624 >> 625 startInitialisation = false; >> 626 if(1 < verbose) { >> 627 G4cout << "### G4LossTableManager start initilisation for first particle " >> 628 << firstParticle->GetParticleName() >> 629 << G4endl; >> 630 } 627 for (G4int i=0; i<n_loss; ++i) { 631 for (G4int i=0; i<n_loss; ++i) { 628 G4VEnergyLossProcess* el = loss_vector[i 632 G4VEnergyLossProcess* el = loss_vector[i]; 629 633 630 if(nullptr != el) { << 634 if(el) { 631 isActive[i] = true; 635 isActive[i] = true; 632 part_vector[i] = el->Particle(); << 633 base_part_vector[i] = el->BaseParticle 636 base_part_vector[i] = el->BaseParticle(); 634 tables_are_built[i] = false; << 637 tables_are_built[i] = false; >> 638 all_tables_are_built= false; >> 639 if(!isActive[i]) { >> 640 el->SetIonisation(false); >> 641 tables_are_built[i] = true; >> 642 } >> 643 635 if(1 < verbose) { 644 if(1 < verbose) { 636 G4cout << i <<". "<< el->GetProces 645 G4cout << i <<". "<< el->GetProcessName(); 637 if(el->Particle()) { 646 if(el->Particle()) { 638 G4cout << " for " << el->Particl 647 G4cout << " for " << el->Particle()->GetParticleName(); 639 } 648 } 640 G4cout << " active= " << isActive[i 649 G4cout << " active= " << isActive[i] 641 << " table= " << tables_are_ 650 << " table= " << tables_are_built[i] 642 << " isIonisation= " << el-> 651 << " isIonisation= " << el->IsIonisationProcess(); 643 if(base_part_vector[i]) { 652 if(base_part_vector[i]) { 644 G4cout << " base particle " 653 G4cout << " base particle " 645 << base_part_vector[i]->Get 654 << base_part_vector[i]->GetParticleName(); 646 } 655 } 647 G4cout << G4endl; 656 G4cout << G4endl; 648 } 657 } 649 } else { 658 } else { 650 tables_are_built[i] = true; 659 tables_are_built[i] = true; 651 part_vector[i] = nullptr; 660 part_vector[i] = nullptr; 652 isActive[i] = false; 661 isActive[i] = false; 653 } 662 } 654 } 663 } 655 } 664 } 656 665 657 if (all_tables_are_built) { << 666 // Set run time parameters 658 theParameters->SetIsPrintedFlag(true); << 667 SetParameters(aParticle, p); 659 return; << 668 660 } << 669 if (all_tables_are_built) { return; } 661 670 662 // Build tables for given particle 671 // Build tables for given particle 663 all_tables_are_built = true; 672 all_tables_are_built = true; 664 673 665 for(G4int i=0; i<n_loss; ++i) { 674 for(G4int i=0; i<n_loss; ++i) { 666 if(p == loss_vector[i] && !tables_are_buil << 675 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) { 667 const G4ParticleDefinition* curr_part = 676 const G4ParticleDefinition* curr_part = part_vector[i]; 668 if(1 < verbose) { 677 if(1 < verbose) { 669 G4cout << "### Build Table for " << p- 678 G4cout << "### Build Table for " << p->GetProcessName() 670 << " and " << curr_part->GetPar << 679 << " and " << curr_part->GetParticleName() << G4endl; 671 << " " << tables_are_built[i] << 672 << G4endl; << 673 } 680 } 674 G4VEnergyLossProcess* curr_proc = BuildT 681 G4VEnergyLossProcess* curr_proc = BuildTables(curr_part); 675 if(curr_proc) { << 682 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 } 683 } 685 if ( !tables_are_built[i] ) { all_tables_a 684 if ( !tables_are_built[i] ) { all_tables_are_built = false; } 686 } 685 } >> 686 if(0 == run && p->IsIonisationProcess()) { loss_map[aParticle] = p; } >> 687 687 if(1 < verbose) { 688 if(1 < verbose) { 688 G4cout << "### G4LossTableManager::BuildPh 689 G4cout << "### G4LossTableManager::BuildPhysicsTable end: " 689 << "all_tables_are_built= " << all_ << 690 << "all_tables_are_built= " << all_tables_are_built 690 << aParticle->GetParticleName() << << 691 << G4endl; >> 692 } >> 693 if(all_tables_are_built) { >> 694 if(1 < verbose) { >> 695 G4cout << "%%%%% All dEdx and Range tables are built for master run= " >> 696 << run << " %%%%%" << G4endl; >> 697 } 691 } 698 } 692 } 699 } 693 700 694 //....oooOO0OOooo........oooOO0OOooo........oo 701 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 695 702 696 void G4LossTableManager::CopyTables(const G4Pa 703 void G4LossTableManager::CopyTables(const G4ParticleDefinition* part, 697 G4VEnergyL 704 G4VEnergyLossProcess* base_proc) 698 { 705 { 699 for (G4int j=0; j<n_loss; ++j) { 706 for (G4int j=0; j<n_loss; ++j) { 700 707 701 G4VEnergyLossProcess* proc = loss_vector[j 708 G4VEnergyLossProcess* proc = loss_vector[j]; 702 709 703 if (!tables_are_built[j] && part == base_p 710 if (!tables_are_built[j] && part == base_part_vector[j]) { 704 tables_are_built[j] = true; 711 tables_are_built[j] = true; 705 // for base particle approach only ionis << 706 proc->SetDEDXTable(base_proc->Ionisation 712 proc->SetDEDXTable(base_proc->IonisationTable(),fRestricted); >> 713 proc->SetDEDXTable(base_proc->DEDXTableForSubsec(),fSubRestricted); 707 proc->SetDEDXTable(base_proc->DEDXunRest 714 proc->SetDEDXTable(base_proc->DEDXunRestrictedTable(),fTotal); 708 proc->SetCSDARangeTable(base_proc->CSDAR 715 proc->SetCSDARangeTable(base_proc->CSDARangeTable()); 709 proc->SetRangeTableForLoss(base_proc->Ra 716 proc->SetRangeTableForLoss(base_proc->RangeTableForLoss()); 710 proc->SetInverseRangeTable(base_proc->In 717 proc->SetInverseRangeTable(base_proc->InverseRangeTable()); 711 proc->SetLambdaTable(base_proc->LambdaTa 718 proc->SetLambdaTable(base_proc->LambdaTable()); >> 719 proc->SetSubLambdaTable(base_proc->SubLambdaTable()); >> 720 proc->SetIonisation(base_proc->IsIonisationProcess()); 712 if(proc->IsIonisationProcess()) { 721 if(proc->IsIonisationProcess()) { 713 range_vector[j] = base_proc->RangeTabl 722 range_vector[j] = base_proc->RangeTableForLoss(); 714 inv_range_vector[j] = base_proc->Inver 723 inv_range_vector[j] = base_proc->InverseRangeTable(); 715 loss_map[part_vector[j]] = proc; 724 loss_map[part_vector[j]] = proc; 716 //G4cout << "G4LossTableManager::CopyT << 717 // << part_vector[j]->GetParticl << 718 // << " added to map " << proc < << 719 } 725 } 720 if (1 < verbose) { 726 if (1 < verbose) { 721 G4cout << " CopyTables for " << pro << 727 G4cout << "For " << proc->GetProcessName() 722 << " for " << part_vector[j]-> 728 << " for " << part_vector[j]->GetParticleName() 723 << " base_part= " << part->Get 729 << " base_part= " << part->GetParticleName() 724 << " tables are assigned" << 730 << " tables are assigned " 725 << G4endl; 731 << G4endl; 726 } 732 } 727 } 733 } >> 734 >> 735 if (theElectron == part && theElectron == proc->SecondaryParticle() ) { >> 736 proc->SetSecondaryRangeTable(base_proc->RangeTableForLoss()); >> 737 } 728 } 738 } 729 } 739 } 730 740 731 //....oooOO0OOooo........oooOO0OOooo........oo 741 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 732 742 733 G4VEnergyLossProcess* G4LossTableManager::Buil 743 G4VEnergyLossProcess* G4LossTableManager::BuildTables( 734 const G4ParticleDefiniti 744 const G4ParticleDefinition* aParticle) 735 { 745 { 736 if(1 < verbose) { 746 if(1 < verbose) { 737 G4cout << " G4LossTableManager::BuildTab << 747 G4cout << "G4LossTableManager::BuildTables() for " 738 << aParticle->GetParticleName() << 748 << aParticle->GetParticleName() << G4endl; 739 } 749 } 740 750 741 std::vector<G4PhysicsTable*> t_list; 751 std::vector<G4PhysicsTable*> t_list; 742 std::vector<G4VEnergyLossProcess*> loss_list 752 std::vector<G4VEnergyLossProcess*> loss_list; 743 std::vector<G4bool> build_flags; 753 std::vector<G4bool> build_flags; 744 G4VEnergyLossProcess* em = nullptr; 754 G4VEnergyLossProcess* em = nullptr; 745 G4VEnergyLossProcess* p = nullptr; 755 G4VEnergyLossProcess* p = nullptr; 746 G4int iem = 0; 756 G4int iem = 0; 747 G4PhysicsTable* dedx = nullptr; << 757 G4PhysicsTable* dedx = 0; 748 G4int i; 758 G4int i; 749 759 750 G4ProcessVector* pvec = 760 G4ProcessVector* pvec = 751 aParticle->GetProcessManager()->GetProcess 761 aParticle->GetProcessManager()->GetProcessList(); 752 G4int nvec = (G4int)pvec->size(); << 762 G4int nvec = pvec->size(); 753 763 754 for (i=0; i<n_loss; ++i) { 764 for (i=0; i<n_loss; ++i) { 755 p = loss_vector[i]; 765 p = loss_vector[i]; 756 if (nullptr != p) { << 766 if (p) { 757 G4bool yes = (aParticle == part_vector[i 767 G4bool yes = (aParticle == part_vector[i]); 758 768 759 // possible case of process sharing betw 769 // possible case of process sharing between particle/anti-particle 760 if(!yes) { 770 if(!yes) { 761 auto ptr = static_cast<G4VProcess*>(p) << 771 G4VProcess* ptr = static_cast<G4VProcess*>(p); 762 for(G4int j=0; j<nvec; ++j) { 772 for(G4int j=0; j<nvec; ++j) { 763 //G4cout << "j= " << j << " " << (*p 773 //G4cout << "j= " << j << " " << (*pvec)[j] << " " << ptr << G4endl; 764 if(ptr == (*pvec)[j]) { 774 if(ptr == (*pvec)[j]) { 765 yes = true; 775 yes = true; 766 break; 776 break; 767 } 777 } 768 } 778 } 769 } 779 } 770 // process belong to this particle 780 // process belong to this particle 771 if(yes && isActive[i]) { 781 if(yes && isActive[i]) { 772 if (p->IsIonisationProcess() || !em) { 782 if (p->IsIonisationProcess() || !em) { 773 em = p; 783 em = p; 774 iem= i; 784 iem= i; 775 } 785 } 776 // tables may be shared between partic 786 // tables may be shared between particle/anti-particle 777 G4bool val = false; 787 G4bool val = false; 778 if (!tables_are_built[i]) { 788 if (!tables_are_built[i]) { 779 val = true; 789 val = true; 780 dedx = p->BuildDEDXTable(fRestricted 790 dedx = p->BuildDEDXTable(fRestricted); 781 //G4cout << "===Build DEDX table for << 791 //G4cout << "Build DEDX table for " << p->GetProcessName() 782 // << " idx= " << i << " dedx:" << d << 792 // << " idx= " << i << dedx << " " << dedx->length() << G4endl; 783 p->SetDEDXTable(dedx,fRestricted); 793 p->SetDEDXTable(dedx,fRestricted); 784 tables_are_built[i] = true; 794 tables_are_built[i] = true; 785 } else { 795 } else { 786 dedx = p->DEDXTable(); 796 dedx = p->DEDXTable(); 787 } 797 } 788 t_list.push_back(dedx); 798 t_list.push_back(dedx); 789 loss_list.push_back(p); 799 loss_list.push_back(p); 790 build_flags.push_back(val); 800 build_flags.push_back(val); 791 } 801 } 792 } 802 } 793 } 803 } 794 804 795 G4int n_dedx = (G4int)t_list.size(); << 805 G4int n_dedx = t_list.size(); 796 if (0 == n_dedx || !em) { 806 if (0 == n_dedx || !em) { 797 G4cout << "G4LossTableManager WARNING: no 807 G4cout << "G4LossTableManager WARNING: no DEDX processes for " 798 << aParticle->GetParticleName() << 808 << aParticle->GetParticleName() << G4endl; 799 return nullptr; << 809 return 0; 800 } 810 } 801 G4int nSubRegions = em->NumberOfSubCutoffReg 811 G4int nSubRegions = em->NumberOfSubCutoffRegions(); 802 812 803 if (1 < verbose) { 813 if (1 < verbose) { 804 G4cout << " Start to build the sum of << 814 G4cout << "G4LossTableManager::BuildTables() start to build range tables" >> 815 << " and the sum of " << n_dedx << " processes" 805 << " iem= " << iem << " em= " << em 816 << " iem= " << iem << " em= " << em->GetProcessName() 806 << " buildCSDARange= " << theParame 817 << " buildCSDARange= " << theParameters->BuildCSDARange() 807 << " nSubRegions= " << nSubRegions; 818 << " nSubRegions= " << nSubRegions; 808 if(subcutProducer) { 819 if(subcutProducer) { 809 G4cout << " SubCutProducer " << subcutPr 820 G4cout << " SubCutProducer " << subcutProducer->GetName(); 810 } 821 } 811 G4cout << G4endl; 822 G4cout << G4endl; 812 } 823 } 813 // do not build tables if producer class is 824 // do not build tables if producer class is defined 814 if(subcutProducer) { nSubRegions = 0; } 825 if(subcutProducer) { nSubRegions = 0; } 815 826 816 dedx = em->DEDXTable(); << 827 dedx = em->DEDXTable(); >> 828 em->SetIonisation(true); 817 em->SetDEDXTable(dedx, fIsIonisation); 829 em->SetDEDXTable(dedx, fIsIonisation); 818 830 819 if (1 < n_dedx) { 831 if (1 < n_dedx) { 820 dedx = nullptr; << 832 dedx = 0; 821 dedx = G4PhysicsTableHelper::PreparePhysic 833 dedx = G4PhysicsTableHelper::PreparePhysicsTable(dedx); 822 tableBuilder->BuildDEDXTable(dedx, t_list) 834 tableBuilder->BuildDEDXTable(dedx, t_list); 823 em->SetDEDXTable(dedx, fRestricted); 835 em->SetDEDXTable(dedx, fRestricted); 824 } 836 } 825 837 >> 838 /* >> 839 if(2==run && "e-" == aParticle->GetParticleName()) { >> 840 G4cout << "G4LossTableManager::BuildTables for e- " << dedx << G4endl; >> 841 G4cout << (*dedx) << G4endl; >> 842 G4cout << "%%%%% Instance ID= " << (*dedx)[0]->GetInstanceID() << G4endl; >> 843 G4cout << "%%%%% LastValue= " << (*dedx)[0]->GetLastValue() << G4endl; >> 844 G4cout << "%%%%% 1.2 " << (*(dedx))[0]->Value(1.2) << G4endl; >> 845 } >> 846 */ 826 dedx_vector[iem] = dedx; 847 dedx_vector[iem] = dedx; 827 848 828 G4PhysicsTable* range = em->RangeTableForLos 849 G4PhysicsTable* range = em->RangeTableForLoss(); 829 if(!range) range = G4PhysicsTableHelper::Pr 850 if(!range) range = G4PhysicsTableHelper::PreparePhysicsTable(range); 830 range_vector[iem] = range; 851 range_vector[iem] = range; 831 852 832 G4PhysicsTable* invrange = em->InverseRangeT 853 G4PhysicsTable* invrange = em->InverseRangeTable(); 833 if(!invrange) invrange = G4PhysicsTableHelpe 854 if(!invrange) invrange = G4PhysicsTableHelper::PreparePhysicsTable(invrange); 834 inv_range_vector[iem] = invrange; 855 inv_range_vector[iem] = invrange; 835 856 836 tableBuilder->BuildRangeTable(dedx, range); << 857 tableBuilder->BuildRangeTable(dedx, range, true); 837 tableBuilder->BuildInverseRangeTable(range, << 858 tableBuilder->BuildInverseRangeTable(range, invrange, true); >> 859 >> 860 // if(1<verbose) G4cout << *dedx << G4endl; 838 861 839 em->SetRangeTableForLoss(range); 862 em->SetRangeTableForLoss(range); 840 em->SetInverseRangeTable(invrange); 863 em->SetInverseRangeTable(invrange); 841 864 >> 865 // if(1<verbose) G4cout << *range << G4endl; >> 866 >> 867 std::vector<G4PhysicsTable*> listSub; 842 std::vector<G4PhysicsTable*> listCSDA; 868 std::vector<G4PhysicsTable*> listCSDA; 843 869 844 for (i=0; i<n_dedx; ++i) { 870 for (i=0; i<n_dedx; ++i) { 845 p = loss_list[i]; 871 p = loss_list[i]; >> 872 if(p != em) { p->SetIonisation(false); } 846 if(build_flags[i]) { 873 if(build_flags[i]) { 847 p->SetLambdaTable(p->BuildLambdaTable(fR 874 p->SetLambdaTable(p->BuildLambdaTable(fRestricted)); 848 } 875 } >> 876 if (0 < nSubRegions) { >> 877 dedx = p->BuildDEDXTable(fSubRestricted); >> 878 p->SetDEDXTable(dedx,fSubRestricted); >> 879 listSub.push_back(dedx); >> 880 if(build_flags[i]) { >> 881 p->SetSubLambdaTable(p->BuildLambdaTable(fSubRestricted)); >> 882 if(p != em) { em->AddCollaborativeProcess(p); } >> 883 } >> 884 } 849 if(theParameters->BuildCSDARange()) { 885 if(theParameters->BuildCSDARange()) { 850 dedx = p->BuildDEDXTable(fTotal); 886 dedx = p->BuildDEDXTable(fTotal); 851 p->SetDEDXTable(dedx,fTotal); 887 p->SetDEDXTable(dedx,fTotal); 852 listCSDA.push_back(dedx); 888 listCSDA.push_back(dedx); 853 } 889 } 854 } 890 } 855 891 >> 892 if (0 < nSubRegions) { >> 893 G4PhysicsTable* dedxSub = em->IonisationTableForSubsec(); >> 894 if (1 < listSub.size()) { >> 895 em->SetDEDXTable(dedxSub, fIsSubIonisation); >> 896 dedxSub = 0; >> 897 dedxSub = G4PhysicsTableHelper::PreparePhysicsTable(dedxSub); >> 898 tableBuilder->BuildDEDXTable(dedxSub, listSub); >> 899 em->SetDEDXTable(dedxSub, fSubRestricted); >> 900 } >> 901 } 856 if(theParameters->BuildCSDARange()) { 902 if(theParameters->BuildCSDARange()) { 857 G4PhysicsTable* dedxCSDA = em->DEDXunRestr 903 G4PhysicsTable* dedxCSDA = em->DEDXunRestrictedTable(); 858 if (1 < n_dedx) { 904 if (1 < n_dedx) { >> 905 dedxCSDA = nullptr; 859 dedxCSDA = G4PhysicsTableHelper::Prepare 906 dedxCSDA = G4PhysicsTableHelper::PreparePhysicsTable(dedxCSDA); 860 tableBuilder->BuildDEDXTable(dedxCSDA, l 907 tableBuilder->BuildDEDXTable(dedxCSDA, listCSDA); 861 em->SetDEDXTable(dedxCSDA,fTotal); 908 em->SetDEDXTable(dedxCSDA,fTotal); 862 } 909 } 863 G4PhysicsTable* rCSDA = em->CSDARangeTable 910 G4PhysicsTable* rCSDA = em->CSDARangeTable(); 864 if(!rCSDA) { rCSDA = G4PhysicsTableHelper: 911 if(!rCSDA) { rCSDA = G4PhysicsTableHelper::PreparePhysicsTable(rCSDA); } 865 tableBuilder->BuildRangeTable(dedxCSDA, rC << 912 tableBuilder->BuildRangeTable(dedxCSDA, rCSDA, true); 866 em->SetCSDARangeTable(rCSDA); 913 em->SetCSDARangeTable(rCSDA); 867 } 914 } 868 915 869 if (1 < verbose) { 916 if (1 < verbose) { 870 G4cout << "G4LossTableManager::BuildTables 917 G4cout << "G4LossTableManager::BuildTables: Tables are built for " 871 << aParticle->GetParticleName() 918 << aParticle->GetParticleName() 872 << "; ionisation process: " << em-> 919 << "; ionisation process: " << em->GetProcessName() 873 << " " << em 920 << " " << em 874 << G4endl; 921 << G4endl; 875 } 922 } 876 return em; 923 return em; 877 } 924 } 878 925 879 //....oooOO0OOooo........oooOO0OOooo........oo 926 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 880 927 >> 928 G4EnergyLossMessenger* G4LossTableManager::GetMessenger() >> 929 { >> 930 return theMessenger; >> 931 } >> 932 >> 933 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 934 881 void G4LossTableManager::ParticleHaveNoLoss( 935 void G4LossTableManager::ParticleHaveNoLoss( 882 const G4ParticleDefinition* aParticle) 936 const G4ParticleDefinition* aParticle) 883 { 937 { 884 G4ExceptionDescription ed; 938 G4ExceptionDescription ed; 885 ed << "Energy loss process not found for " < 939 ed << "Energy loss process not found for " << aParticle->GetParticleName() 886 << " !"; 940 << " !"; 887 G4Exception("G4LossTableManager::ParticleHav 941 G4Exception("G4LossTableManager::ParticleHaveNoLoss", "em0001", 888 FatalException, ed); 942 FatalException, ed); 889 } 943 } 890 944 891 //....oooOO0OOooo........oooOO0OOooo........oo 945 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 892 946 893 void G4LossTableManager::SetVerbose(G4int val) << 947 void G4LossTableManager::SetLossFluctuations(G4bool /*val*/) >> 948 { >> 949 } >> 950 >> 951 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 952 >> 953 void G4LossTableManager::SetSubCutoff(G4bool val, const G4Region* r) >> 954 { >> 955 subCutoffFlag = val; >> 956 for(G4int i=0; i<n_loss; ++i) { >> 957 if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); } >> 958 } >> 959 } >> 960 >> 961 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 962 >> 963 void G4LossTableManager::SetIntegral(G4bool val) >> 964 { >> 965 integral = val; >> 966 integralActive = true; >> 967 for(G4int i=0; i<n_loss; ++i) { >> 968 if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); } >> 969 } >> 970 size_t emp = emp_vector.size(); >> 971 for (size_t k=0; k<emp; ++k) { >> 972 if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); } >> 973 } >> 974 } >> 975 >> 976 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 977 >> 978 void G4LossTableManager::SetMinSubRange(G4double /*val*/) >> 979 { >> 980 } >> 981 >> 982 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 983 >> 984 void G4LossTableManager::SetRandomStep(G4bool /*val*/) >> 985 { >> 986 } >> 987 >> 988 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 989 >> 990 void G4LossTableManager::SetMinEnergy(G4double val) >> 991 { >> 992 theParameters->SetMinEnergy(val); >> 993 } >> 994 >> 995 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 996 >> 997 void G4LossTableManager::SetMaxEnergy(G4double val) >> 998 { >> 999 theParameters->SetMaxEnergy(val); >> 1000 } >> 1001 >> 1002 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1003 >> 1004 void G4LossTableManager::SetMaxEnergyForCSDARange(G4double val) >> 1005 { >> 1006 theParameters->SetMaxEnergyForCSDARange(val); >> 1007 } >> 1008 >> 1009 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1010 >> 1011 void G4LossTableManager::SetMaxEnergyForMuons(G4double val) >> 1012 { >> 1013 theParameters->SetMaxEnergy(val); >> 1014 } >> 1015 >> 1016 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1017 >> 1018 void G4LossTableManager::SetDEDXBinning(G4int val) >> 1019 { >> 1020 theParameters->SetNumberOfBins(val); >> 1021 } >> 1022 >> 1023 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1024 >> 1025 void G4LossTableManager::SetDEDXBinningForCSDARange(G4int /*n*/) >> 1026 { >> 1027 } >> 1028 >> 1029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1030 >> 1031 void G4LossTableManager::SetLambdaBinning(G4int val) 894 { 1032 { 895 verbose = val; << 1033 theParameters->SetNumberOfBins(val); 896 } 1034 } 897 1035 898 //....oooOO0OOooo........oooOO0OOooo........oo 1036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 899 1037 >> 1038 void G4LossTableManager::SetVerbose(G4int /*val*/) >> 1039 { >> 1040 } >> 1041 >> 1042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1043 >> 1044 void G4LossTableManager::SetStepFunction(G4double v1, G4double v2) >> 1045 { >> 1046 if(0.0 < v1 && 0.0 < v2 && v2 < 1.e+50) { >> 1047 stepFunctionActive = true; >> 1048 maxRangeVariation = v1; >> 1049 maxFinalStep = v2; >> 1050 for(G4int i=0; i<n_loss; ++i) { >> 1051 if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); } >> 1052 } >> 1053 } else if(v1 <= 0.0) { >> 1054 PrintEWarning("SetStepFunction", v1); >> 1055 } else { >> 1056 PrintEWarning("SetStepFunction", v2); >> 1057 } >> 1058 } >> 1059 >> 1060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1061 >> 1062 void G4LossTableManager::SetLinearLossLimit(G4double /*val*/) >> 1063 { >> 1064 } >> 1065 >> 1066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1067 >> 1068 void G4LossTableManager::SetBuildCSDARange(G4bool /*val*/) >> 1069 { >> 1070 } >> 1071 >> 1072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1073 >> 1074 void >> 1075 G4LossTableManager::SetParameters(const G4ParticleDefinition* /*aParticle*/, >> 1076 G4VEnergyLossProcess* p) >> 1077 { >> 1078 if(stepFunctionActive) { >> 1079 p->SetStepFunction(maxRangeVariation, maxFinalStep); >> 1080 } >> 1081 if(integralActive) { p->SetIntegral(integral); } >> 1082 } >> 1083 >> 1084 >> 1085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... >> 1086 900 const std::vector<G4VEnergyLossProcess*>& 1087 const std::vector<G4VEnergyLossProcess*>& 901 G4LossTableManager::GetEnergyLossProcessVector 1088 G4LossTableManager::GetEnergyLossProcessVector() 902 { 1089 { 903 return loss_vector; 1090 return loss_vector; 904 } 1091 } 905 1092 906 //....oooOO0OOooo........oooOO0OOooo........oo 1093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 907 1094 908 const std::vector<G4VEmProcess*>& G4LossTableM 1095 const std::vector<G4VEmProcess*>& G4LossTableManager::GetEmProcessVector() 909 { 1096 { 910 return emp_vector; 1097 return emp_vector; 911 } 1098 } 912 1099 913 //....oooOO0OOooo........oooOO0OOooo........oo 1100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 914 1101 915 const std::vector<G4VMultipleScattering*>& 1102 const std::vector<G4VMultipleScattering*>& 916 G4LossTableManager::GetMultipleScatteringVecto 1103 G4LossTableManager::GetMultipleScatteringVector() 917 { 1104 { 918 return msc_vector; 1105 return msc_vector; 919 } 1106 } 920 1107 921 //....oooOO0OOooo........oooOO0OOooo........oo 1108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 922 1109 923 G4EmSaturation* G4LossTableManager::EmSaturati 1110 G4EmSaturation* G4LossTableManager::EmSaturation() 924 { 1111 { 925 return theParameters->GetEmSaturation(); << 1112 if(!emSaturation) { emSaturation = new G4EmSaturation(verbose); } >> 1113 return emSaturation; 926 } 1114 } 927 1115 928 //....oooOO0OOooo........oooOO0OOooo........oo 1116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 929 1117 930 G4EmConfigurator* G4LossTableManager::EmConfig 1118 G4EmConfigurator* G4LossTableManager::EmConfigurator() 931 { 1119 { 932 if(!emConfigurator) { << 1120 if(!emConfigurator) { emConfigurator = new G4EmConfigurator(verbose); } 933 emConfigurator = new G4EmConfigurator(verb << 934 } << 935 return emConfigurator; 1121 return emConfigurator; 936 } 1122 } 937 1123 938 //....oooOO0OOooo........oooOO0OOooo........oo 1124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 939 1125 940 G4ElectronIonPair* G4LossTableManager::Electro 1126 G4ElectronIonPair* G4LossTableManager::ElectronIonPair() 941 { 1127 { 942 if(!emElectronIonPair) { 1128 if(!emElectronIonPair) { 943 emElectronIonPair = new G4ElectronIonPair( 1129 emElectronIonPair = new G4ElectronIonPair(verbose); 944 } 1130 } 945 return emElectronIonPair; 1131 return emElectronIonPair; 946 } 1132 } 947 1133 948 //....oooOO0OOooo........oooOO0OOooo........oo << 949 << 950 void G4LossTableManager::SetNIELCalculator(G4N << 951 { << 952 if(nullptr != ptr && ptr != nielCalculator) << 953 delete nielCalculator; << 954 nielCalculator = ptr; << 955 } << 956 } << 957 << 958 //....oooOO0OOooo........oooOO0OOooo........oo << 959 << 960 G4NIELCalculator* G4LossTableManager::NIELCalc << 961 { << 962 if(!nielCalculator) { << 963 nielCalculator = new G4NIELCalculator(null << 964 } << 965 return nielCalculator; << 966 } << 967 << 968 //....oooOO0OOooo........oooOO0OOooo........oo 1134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 969 1135 970 void G4LossTableManager::SetAtomDeexcitation(G 1136 void G4LossTableManager::SetAtomDeexcitation(G4VAtomDeexcitation* p) 971 { 1137 { 972 if(atomDeexcitation != p) { 1138 if(atomDeexcitation != p) { 973 delete atomDeexcitation; 1139 delete atomDeexcitation; 974 atomDeexcitation = p; 1140 atomDeexcitation = p; 975 } 1141 } 976 } 1142 } 977 1143 978 //....oooOO0OOooo........oooOO0OOooo........oo 1144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 979 1145 980 void G4LossTableManager::SetSubCutProducer(G4V 1146 void G4LossTableManager::SetSubCutProducer(G4VSubCutProducer* p) 981 { 1147 { 982 if(subcutProducer != p) { 1148 if(subcutProducer != p) { 983 delete subcutProducer; 1149 delete subcutProducer; 984 subcutProducer = p; 1150 subcutProducer = p; 985 } 1151 } 986 } 1152 } 987 1153 988 //....oooOO0OOooo........oooOO0OOooo........oo 1154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 989 1155 990 void G4LossTableManager::PrintEWarning(G4Strin 1156 void G4LossTableManager::PrintEWarning(G4String tit, G4double /*val*/) 991 { 1157 { 992 G4String ss = "G4LossTableManager::" + tit; 1158 G4String ss = "G4LossTableManager::" + tit; 993 G4ExceptionDescription ed; 1159 G4ExceptionDescription ed; 994 /* 1160 /* 995 ed << "Parameter is out of range: " << val 1161 ed << "Parameter is out of range: " << val 996 << " it will have no effect!\n" << " ## " 1162 << " it will have no effect!\n" << " ## " 997 << " nbins= " << nbinsLambda 1163 << " nbins= " << nbinsLambda 998 << " nbinsPerDecade= " << nbinsPerDecade 1164 << " nbinsPerDecade= " << nbinsPerDecade 999 << " Emin(keV)= " << minKinEnergy/keV 1165 << " Emin(keV)= " << minKinEnergy/keV 1000 << " Emax(GeV)= " << maxKinEnergy/GeV; 1166 << " Emax(GeV)= " << maxKinEnergy/GeV; 1001 */ 1167 */ 1002 G4Exception(ss, "em0044", JustWarning, ed); 1168 G4Exception(ss, "em0044", JustWarning, ed); 1003 } 1169 } 1004 1170 1005 //....oooOO0OOooo........oooOO0OOooo........o 1171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1006 << 1007 void G4LossTableManager::DumpHtml() << 1008 { << 1009 // Automatic generation of html documentati << 1010 // List processes and models for the most i << 1011 // particles in descending order of importa << 1012 // NB. for model names with length > 18 cha << 1013 // to be edited by hand. Or modify G4EmMod << 1014 << 1015 char* dirName = std::getenv("G4PhysListDocD << 1016 char* physList = std::getenv("G4PhysListNam << 1017 if (dirName && physList) { << 1018 G4String physListName = G4String(physList << 1019 G4String pathName = G4String(dirName) + " << 1020 << 1021 std::ofstream outFile; << 1022 outFile.open(pathName); << 1023 << 1024 outFile << physListName << G4endl; << 1025 outFile << std::string(physListName.lengt << 1026 << 1027 std::vector<G4ParticleDefinition*> partic << 1028 G4Gamma::Gamma(), << 1029 G4Electron::Electron(), << 1030 G4Positron::Positron(), << 1031 G4Proton::ProtonDefinition(), << 1032 G4MuonPlus::MuonPlusDefinition(), << 1033 G4MuonMinus::MuonMinusDefinition(), << 1034 }; << 1035 << 1036 std::vector<G4VEmProcess*> emproc_vector << 1037 std::vector<G4VEnergyLossProcess*> enloss << 1038 GetEnergyLossProcessVector(); << 1039 std::vector<G4VMultipleScattering*> mscat << 1040 GetMultipleScatteringVector(); << 1041 << 1042 for (auto theParticle : particles) { << 1043 outFile << G4endl << "**" << theParticl << 1044 << "**" << G4endl << G4endl << << 1045 << 1046 G4ProcessManager* pm = theParticle->Get << 1047 G4ProcessVector* pv = pm->GetProcessLi << 1048 G4int plen = pm->GetProcessListLength() << 1049 << 1050 for (auto emproc : emproc_vector) { << 1051 for (G4int i = 0; i < plen; ++i) { << 1052 G4VProcess* proc = (*pv)[i]; << 1053 if (proc == emproc) { << 1054 outFile << G4endl; << 1055 proc->ProcessDescription(outFile) << 1056 break; << 1057 } << 1058 } << 1059 } << 1060 << 1061 for (auto mscproc : mscat_vector) { << 1062 for (G4int i = 0; i < plen; ++i) { << 1063 G4VProcess* proc = (*pv)[i]; << 1064 if (proc == mscproc) { << 1065 outFile << G4endl; << 1066 proc->ProcessDescription(outFile) << 1067 break; << 1068 } << 1069 } << 1070 } << 1071 << 1072 for (auto enlossproc : enloss_vector) { << 1073 for (G4int i = 0; i < plen; ++i) { << 1074 G4VProcess* proc = (*pv)[i]; << 1075 if (proc == enlossproc) { << 1076 outFile << G4endl; << 1077 proc->ProcessDescription(outFile) << 1078 break; << 1079 } << 1080 } << 1081 } << 1082 } << 1083 outFile.close(); << 1084 } << 1085 } << 1086 << 1087 //....oooOO0OOooo........oooOO0OOooo........o << 1088 << 1089 1172