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