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 // G4VUserPhysicsList implementation << 27 // 26 // 28 // Original author: H.Kurashige (Kobe Universi << 27 // $Id: G4VUserPhysicsList.cc,v 1.64 2008/05/09 13:00:42 kurasige Exp $ 29 // ------------------------------------------- << 28 // GEANT4 tag $Name: geant4-09-02-patch-04 $ >> 29 // >> 30 // >> 31 // ------------------------------------------------------------ >> 32 // GEANT 4 class header file >> 33 // >> 34 // ------------------------------------------------------------ >> 35 // History >> 36 // first version 09 Jan 1998 by H.Kurashige >> 37 // Added SetEnergyRange 18 Jun 1998 by H.Kurashige >> 38 // Change for short lived particles 27 Jun 1998 by H.Kurashige >> 39 // G4BestUnit on output 12 nov 1998 by M.Maire >> 40 // Added RemoveProcessManager 9 Feb 1999 by H.Kurashige >> 41 // Fixed RemoveProcessManager 15 Apr 1999 by H.Kurashige >> 42 // Removed ConstructAllParticles() 15 Apr 1999 by H.Kurashige >> 43 // Modified for CUTS per REGION 10 Oct 2002 by H.Kurashige >> 44 // Check if particle IsShortLived 18 Jun 2003 by V.Ivanchenko >> 45 // Modify PreparePhysicsList 18 Jan 2006 by H.Kurashige >> 46 // ------------------------------------------------------------ 30 47 >> 48 #include "globals.hh" 31 #include "G4VUserPhysicsList.hh" 49 #include "G4VUserPhysicsList.hh" 32 << 33 #include "G4Material.hh" << 34 #include "G4MaterialCutsCouple.hh" << 35 #include "G4ParticleDefinition.hh" 50 #include "G4ParticleDefinition.hh" 36 #include "G4ParticleTable.hh" << 37 #include "G4PhysicsListHelper.hh" << 38 #include "G4ProcessManager.hh" 51 #include "G4ProcessManager.hh" 39 #include "G4ProductionCuts.hh" << 52 #include "G4ParticleTable.hh" 40 #include "G4ProductionCutsTable.hh" 53 #include "G4ProductionCutsTable.hh" 41 #include "G4Region.hh" << 54 #include "G4Material.hh" 42 #include "G4RegionStore.hh" << 55 #include "G4UserPhysicsListMessenger.hh" 43 #include "G4SystemOfUnits.hh" << 44 #include "G4UImanager.hh" 56 #include "G4UImanager.hh" 45 #include "G4UnitsTable.hh" 57 #include "G4UnitsTable.hh" 46 #include "G4UserPhysicsListMessenger.hh" << 58 #include "G4RegionStore.hh" 47 #include "G4VTrackingManager.hh" << 59 #include "G4Region.hh" 48 #include "G4ios.hh" << 60 #include "G4ProductionCutsTable.hh" 49 #include "globals.hh" << 61 #include "G4ProductionCuts.hh" >> 62 #include "G4MaterialCutsCouple.hh" 50 63 51 #include <fstream> << 64 #include "G4ios.hh" 52 #include <iomanip> 65 #include <iomanip> 53 #include <unordered_set> << 66 #include <fstream> 54 << 55 // This static member is thread local. For eac << 56 // size of G4VUPLData instances. << 57 // << 58 #define G4MT_theMessenger ((this->subInstanceM << 59 #define G4MT_thePLHelper ((this->subInstanceMa << 60 #define fIsPhysicsTableBuilt \ << 61 ((this->subInstanceManager.offset[this->g4vu << 62 #define fDisplayThreshold \ << 63 ((this->subInstanceManager.offset[this->g4vu << 64 #define theParticleIterator \ << 65 ((this->subInstanceManager.offset[this->g4vu << 66 << 67 // This field helps to use the class G4VUPLMan << 68 // << 69 G4VUPLManager G4VUserPhysicsList::subInstanceM << 70 << 71 // ------------------------------------------- << 72 void G4VUPLData::initialize() << 73 { << 74 _theParticleIterator = G4ParticleTable::GetP << 75 _theMessenger = nullptr; << 76 _thePLHelper = G4PhysicsListHelper::GetPhysi << 77 _fIsPhysicsTableBuilt = false; << 78 _fDisplayThreshold = 0; << 79 } << 80 67 81 // ------------------------------------------- << 68 //////////////////////////////////////////////////////// 82 G4VUserPhysicsList::G4VUserPhysicsList() 69 G4VUserPhysicsList::G4VUserPhysicsList() >> 70 :verboseLevel(1), >> 71 fRetrievePhysicsTable(false), >> 72 fStoredInAscii(true), >> 73 fIsCheckedForRetrievePhysicsTable(false), >> 74 fIsRestoredCutValues(false), >> 75 directoryPhysicsTable("."), >> 76 fDisplayThreshold(0), >> 77 useCoupledTransportation(false) 83 { 78 { 84 g4vuplInstanceID = subInstanceManager.Create << 85 // default cut value (1.0mm) 79 // default cut value (1.0mm) 86 defaultCutValue = 1.0 * mm; << 80 defaultCutValue = 1.0*mm; 87 81 88 // pointer to the particle table 82 // pointer to the particle table 89 theParticleTable = G4ParticleTable::GetParti 83 theParticleTable = G4ParticleTable::GetParticleTable(); >> 84 theParticleIterator = theParticleTable->GetIterator(); 90 85 91 // pointer to the cuts table 86 // pointer to the cuts table 92 fCutsTable = G4ProductionCutsTable::GetProdu << 87 fCutsTable = G4ProductionCutsTable::GetProductionCutsTable(); 93 88 94 // set energy range for SetCut calcuration 89 // set energy range for SetCut calcuration 95 fCutsTable->SetEnergyRange(0.99 * keV, 100 * << 90 fCutsTable->SetEnergyRange(0.99*keV, 100*TeV); 96 91 97 // UI Messenger 92 // UI Messenger 98 G4MT_theMessenger = new G4UserPhysicsListMes << 93 theMessenger = new G4UserPhysicsListMessenger(this); 99 << 100 // PhysicsListHelper << 101 G4MT_thePLHelper->SetVerboseLevel(verboseLev << 102 << 103 fIsPhysicsTableBuilt = false; << 104 fDisplayThreshold = 0; << 105 } 94 } 106 95 107 // ------------------------------------------- << 96 //////////////////////////////////////////////////////// 108 void G4VUserPhysicsList::InitializeWorker() << 109 { << 110 // Remember messengers are per-thread, so th << 111 // worker and due to the presence of "this" << 112 // G4VUPLData::initialize() << 113 G4MT_theMessenger = new G4UserPhysicsListMes << 114 } << 115 << 116 // ------------------------------------------- << 117 void G4VUserPhysicsList::TerminateWorker() << 118 { << 119 RemoveProcessManager(); << 120 RemoveTrackingManager(); << 121 delete G4MT_theMessenger; << 122 G4MT_theMessenger = nullptr; << 123 } << 124 << 125 // ------------------------------------------- << 126 G4VUserPhysicsList::~G4VUserPhysicsList() 97 G4VUserPhysicsList::~G4VUserPhysicsList() 127 { 98 { 128 delete G4MT_theMessenger; << 99 if (theMessenger != 0) { 129 G4MT_theMessenger = nullptr; << 100 delete theMessenger; 130 << 101 theMessenger = 0; >> 102 } 131 RemoveProcessManager(); 103 RemoveProcessManager(); 132 RemoveTrackingManager(); << 133 104 134 // invoke DeleteAllParticle 105 // invoke DeleteAllParticle 135 theParticleTable->DeleteAllParticles(); 106 theParticleTable->DeleteAllParticles(); 136 } << 137 << 138 // ------------------------------------------- << 139 G4VUserPhysicsList::G4VUserPhysicsList(const G << 140 : verboseLevel(right.verboseLevel), << 141 defaultCutValue(right.defaultCutValue), << 142 isSetDefaultCutValue(right.isSetDefaultCut << 143 fRetrievePhysicsTable(right.fRetrievePhysi << 144 fStoredInAscii(right.fStoredInAscii), << 145 fIsCheckedForRetrievePhysicsTable(right.fI << 146 fIsRestoredCutValues(right.fIsRestoredCutV << 147 directoryPhysicsTable(right.directoryPhysi << 148 fDisableCheckParticleList(right.fDisableCh << 149 { << 150 g4vuplInstanceID = subInstanceManager.Create << 151 // pointer to the particle table << 152 theParticleTable = G4ParticleTable::GetParti << 153 theParticleIterator = theParticleTable->GetI << 154 // pointer to the cuts table << 155 fCutsTable = G4ProductionCutsTable::GetProdu << 156 << 157 // UI Messenger << 158 G4MT_theMessenger = new G4UserPhysicsListMes << 159 107 160 // PhysicsListHelper << 161 G4MT_thePLHelper = G4PhysicsListHelper::GetP << 162 G4MT_thePLHelper->SetVerboseLevel(verboseLev << 163 << 164 fIsPhysicsTableBuilt = << 165 right.GetSubInstanceManager().offset[right << 166 fDisplayThreshold = << 167 right.GetSubInstanceManager().offset[right << 168 } 108 } 169 109 170 // ------------------------------------------- << 110 //////////////////////////////////////////////////////// 171 G4VUserPhysicsList& G4VUserPhysicsList::operat << 111 void G4VUserPhysicsList::SetVerboseLevel(G4int value) 172 { 112 { 173 if (this != &right) { << 113 verboseLevel = value; 174 verboseLevel = right.verboseLevel; << 114 // set verboseLevel for G4ProductionCutsTable same as one for G4VUserPhysicsList: 175 defaultCutValue = right.defaultCutValue; << 115 fCutsTable->SetVerboseLevel(value); 176 isSetDefaultCutValue = right.isSetDefaultC << 116 177 fRetrievePhysicsTable = right.fRetrievePhy << 117 #ifdef G4VERBOSE 178 fStoredInAscii = right.fStoredInAscii; << 118 if (verboseLevel >1){ 179 fIsCheckedForRetrievePhysicsTable = right. << 119 G4cout << "G4VUserPhysicsList::SetVerboseLevel :"; 180 fIsRestoredCutValues = right.fIsRestoredCu << 120 G4cout << " Verbose level is set to " << verboseLevel << G4endl; 181 directoryPhysicsTable = right.directoryPhy << 182 fIsPhysicsTableBuilt = << 183 right.GetSubInstanceManager().offset[rig << 184 fDisplayThreshold = << 185 right.GetSubInstanceManager().offset[rig << 186 fDisableCheckParticleList = right.fDisable << 187 } 121 } 188 return *this; << 122 #endif 189 } 123 } 190 124 191 // ------------------------------------------- << 125 //////////////////////////////////////////////////////// 192 void G4VUserPhysicsList::AddProcessManager(G4P << 126 void G4VUserPhysicsList::AddProcessManager(G4ParticleDefinition* newParticle, >> 127 G4ProcessManager* newManager) 193 { 128 { 194 if (newParticle == nullptr) return; << 129 if (newParticle == 0) return; 195 G4Exception("G4VUserPhysicsList::AddProcessM << 130 if (newParticle->GetProcessManager() != 0) { 196 "This method is obsolete"); << 197 } << 198 << 199 // ------------------------------------------- << 200 void G4VUserPhysicsList::InitializeProcessMana << 201 { << 202 // Request lock for particle table access. S << 203 // this critical region. << 204 #ifdef G4MULTITHREADED << 205 G4MUTEXLOCK(&G4ParticleTable::particleTableM << 206 G4ParticleTable::lockCount()++; << 207 #endif << 208 G4ParticleDefinition* gion = G4ParticleTable << 209 << 210 // loop over all particles in G4ParticleTabl << 211 theParticleIterator->reset(); << 212 while ((*theParticleIterator)()) { << 213 G4ParticleDefinition* particle = thePartic << 214 G4ProcessManager* pmanager = particle->Get << 215 << 216 if (pmanager == nullptr) { << 217 // create process manager if the particl << 218 pmanager = new G4ProcessManager(particle << 219 particle->SetProcessManager(pmanager); << 220 if (particle->GetMasterProcessManager() << 221 particle->SetMasterProcessManager(pman << 222 #ifdef G4VERBOSE 131 #ifdef G4VERBOSE 223 if (verboseLevel > 2) { << 132 if (verboseLevel >1){ 224 G4cout << "G4VUserPhysicsList::Initial << 133 G4cout << "G4VUserPhysicsList::AddProcessManager: "; 225 "ProcessManager to " << 134 G4cout << newParticle->GetParticleName(); 226 << particle->GetParticleName() << 135 G4cout << " already has ProcessManager " << G4endl; 227 } << 228 #endif << 229 } 136 } >> 137 #endif >> 138 return; 230 } 139 } 231 140 232 if (gion != nullptr) { << 141 // create new process manager if newManager == 0 233 G4ProcessManager* gionPM = gion->GetProces << 142 if (newManager == 0){ 234 // loop over all particles once again (thi << 143 // Add ProcessManager 235 theParticleIterator->reset(false); << 144 if (newParticle->GetParticleType() == "nucleus") { 236 while ((*theParticleIterator)()) { << 145 // Create a copy of the process manager of "GenericIon" in case of "nucleus" 237 G4ParticleDefinition* particle = thePart << 146 G4ParticleDefinition* genericIon = 238 if (particle->IsGeneralIon()) { << 147 (G4ParticleTable::GetParticleTable())->FindParticle("GenericIon"); 239 particle->SetProcessManager(gionPM); << 148 240 #ifdef G4VERBOSE << 149 if (genericIon != 0) { 241 if (verboseLevel > 2) { << 150 G4ProcessManager* ionMan = genericIon->GetProcessManager(); 242 G4cout << "G4VUserPhysicsList::Initi << 151 if (ionMan != 0) { 243 "ProcessManager to " << 152 newManager = new G4ProcessManager(*ionMan); 244 << particle->GetParticleName( << 153 } else { 245 } << 154 // no process manager has been registered yet 246 #endif << 155 newManager = new G4ProcessManager(newParticle); >> 156 } >> 157 } else { >> 158 // "GenericIon" does not exist >> 159 newManager = new G4ProcessManager(newParticle); 247 } 160 } >> 161 >> 162 } else { >> 163 // create process manager for particles other than "nucleus" >> 164 newManager = new G4ProcessManager(newParticle); 248 } 165 } 249 } 166 } 250 167 251 // release lock for particle table access << 168 // set particle type 252 #ifdef G4MULTITHREADED << 169 newManager->SetParticleType(newParticle); 253 G4MUTEXUNLOCK(&G4ParticleTable::particleTabl << 170 >> 171 // add the process manager >> 172 newParticle->SetProcessManager(newManager); >> 173 >> 174 #ifdef G4VERBOSE >> 175 if (verboseLevel >2){ >> 176 G4cout << "G4VUserPhysicsList::AddProcessManager: "; >> 177 G4cout << "adds ProcessManager to "; >> 178 G4cout << newParticle->GetParticleName() << G4endl; >> 179 newManager->DumpInfo(); >> 180 } 254 #endif 181 #endif >> 182 if (newParticle->GetParticleType() == "nucleus") { >> 183 PreparePhysicsTable(newParticle); >> 184 BuildPhysicsTable(newParticle); >> 185 } 255 } 186 } 256 187 257 // ------------------------------------------- << 258 void G4VUserPhysicsList::RemoveProcessManager( << 259 { << 260 // Request lock for particle table access. S << 261 // this critical region. << 262 #ifdef G4MULTITHREADED << 263 G4MUTEXLOCK(&G4ParticleTable::particleTableM << 264 G4ParticleTable::lockCount()++; << 265 #endif << 266 188 >> 189 //////////////////////////////////////////////////////// >> 190 void G4VUserPhysicsList::InitializeProcessManager() >> 191 { 267 // loop over all particles in G4ParticleTabl 192 // loop over all particles in G4ParticleTable 268 theParticleIterator->reset(); 193 theParticleIterator->reset(); 269 while ((*theParticleIterator)()) { << 194 while( (*theParticleIterator)() ){ 270 G4ParticleDefinition* particle = thePartic 195 G4ParticleDefinition* particle = theParticleIterator->value(); 271 if (particle->GetInstanceID() < G4Particle << 196 G4ProcessManager* pmanager = particle->GetProcessManager(); 272 if (particle->GetParticleSubType() != "g << 197 if (pmanager==0) { 273 || particle->GetParticleName() == "G << 198 // create process manager if the particle has no its one 274 { << 199 pmanager = new G4ProcessManager(particle); 275 G4ProcessManager* pmanager = particle- << 200 particle->SetProcessManager(pmanager); 276 << 277 delete pmanager; << 278 #ifdef G4VERBOSE << 279 if (verboseLevel > 2) { << 280 G4cout << "G4VUserPhysicsList::Remov << 281 G4cout << "remove ProcessManager fro << 282 G4cout << particle->GetParticleName( << 283 } << 284 #endif << 285 } << 286 particle->SetProcessManager(nullptr); << 287 } 201 } 288 } 202 } 289 << 290 // release lock for particle table access << 291 #ifdef G4MULTITHREADED << 292 G4MUTEXUNLOCK(&G4ParticleTable::particleTabl << 293 #endif << 294 } 203 } 295 204 296 // ------------------------------------------- << 205 //////////////////////////////////////////////////////// 297 void G4VUserPhysicsList::RemoveTrackingManager << 206 void G4VUserPhysicsList::RemoveProcessManager() 298 { 207 { 299 // One tracking manager may be registered fo << 300 // to delete every object only once. << 301 std::unordered_set<G4VTrackingManager*> trac << 302 << 303 // loop over all particles in G4ParticleTabl 208 // loop over all particles in G4ParticleTable 304 theParticleIterator->reset(); 209 theParticleIterator->reset(); 305 while ((*theParticleIterator)()) { << 210 while( (*theParticleIterator)() ){ 306 G4ParticleDefinition* particle = thePartic 211 G4ParticleDefinition* particle = theParticleIterator->value(); 307 if (auto* trackingManager = particle->GetT << 212 G4ProcessManager* pmanager = particle->GetProcessManager(); >> 213 if (pmanager!=0) delete pmanager; >> 214 particle->SetProcessManager(0); 308 #ifdef G4VERBOSE 215 #ifdef G4VERBOSE 309 if (verboseLevel > 2) { << 216 if (verboseLevel >2){ 310 G4cout << "G4VUserPhysicsList::RemoveT << 217 G4cout << "G4VUserPhysicsList::RemoveProcessManager: "; 311 G4cout << "remove TrackingManager from << 218 G4cout << "remove ProcessManager from "; 312 G4cout << particle->GetParticleName() << 219 G4cout << particle->GetParticleName() << G4endl; 313 } << 314 #endif << 315 trackingManagers.insert(trackingManager) << 316 particle->SetTrackingManager(nullptr); << 317 } 220 } 318 } << 221 #endif 319 << 320 for (G4VTrackingManager* tm : trackingManage << 321 delete tm; << 322 } 222 } 323 } 223 } 324 224 325 // ------------------------------------------- << 326 void G4VUserPhysicsList::SetCuts() << 327 { << 328 if (!isSetDefaultCutValue) { << 329 SetDefaultCutValue(defaultCutValue); << 330 } << 331 << 332 #ifdef G4VERBOSE << 333 if (verboseLevel > 1) { << 334 G4cout << "G4VUserPhysicsList::SetCuts: << 335 G4cout << "Cut for gamma: " << GetCutValue << 336 G4cout << "Cut for e-: " << GetCutValue(" << 337 G4cout << "Cut for e+: " << GetCutValue(" << 338 G4cout << "Cut for proton: " << GetCutVal << 339 } << 340 #endif << 341 225 342 // dump Cut values if verboseLevel==3 << 226 //////////////////////////////////////////////////////// 343 if (verboseLevel > 2) { << 227 #include "G4Transportation.hh" 344 DumpCutValuesTable(); << 228 #include "G4CoupledTransportation.hh" 345 } << 229 #include "G4RunManagerKernel.hh" 346 } << 230 #include "G4ScoringManager.hh" 347 231 348 // ------------------------------------------- << 232 void G4VUserPhysicsList::AddTransportation() 349 void G4VUserPhysicsList::SetDefaultCutValue(G4 << 350 { 233 { 351 if (value < 0.0) { << 234 G4int verboseLevelTransport = 0; >> 235 G4VProcess* theTransportationProcess = 0; >> 236 G4int nParaWorld = G4RunManagerKernel::GetRunManagerKernel()->GetNumberOfParallelWorld(); >> 237 >> 238 if(nParaWorld || useCoupledTransportation || G4ScoringManager::GetScoringManagerIfExist()) >> 239 { >> 240 theTransportationProcess = new G4CoupledTransportation(verboseLevelTransport); >> 241 G4cout << "#############################################################################" << G4endl >> 242 << " G4VUserPhysicsList::AddTransportation() --- G4CoupledTransportation is used " << G4endl >> 243 << "#############################################################################" << G4endl; >> 244 } >> 245 else >> 246 { theTransportationProcess = new G4Transportation(verboseLevelTransport); } >> 247 352 #ifdef G4VERBOSE 248 #ifdef G4VERBOSE 353 if (verboseLevel > 0) { << 249 if (verboseLevel >2){ 354 G4cout << "G4VUserPhysicsList::SetDefaul << 250 G4cout << "G4VUserPhysicsList::AddTransportation() "<< G4endl; 355 << " :" << value / mm << "[mm]" << 356 } 251 } 357 #endif 252 #endif 358 return; << 359 } << 360 253 361 defaultCutValue = value; << 254 // loop over all particles in G4ParticleTable 362 isSetDefaultCutValue = true; << 255 theParticleIterator->reset(); 363 << 256 while( (*theParticleIterator)() ){ 364 // set cut values for gamma at first and for << 257 G4ParticleDefinition* particle = theParticleIterator->value(); 365 SetCutValue(defaultCutValue, "gamma"); << 258 G4ProcessManager* pmanager = particle->GetProcessManager(); 366 SetCutValue(defaultCutValue, "e-"); << 259 if (!particle->IsShortLived()) { 367 SetCutValue(defaultCutValue, "e+"); << 260 // Add transportation process for all particles other than "shortlived" 368 SetCutValue(defaultCutValue, "proton"); << 261 if ( pmanager == 0) { >> 262 // Error !! no process manager >> 263 G4String particleName = particle->GetParticleName(); >> 264 G4Exception("G4VUserPhysicsList::AddTransportation","No process manager", >> 265 RunMustBeAborted, particleName ); >> 266 } else { >> 267 // add transportation with ordering = ( -1, "first", "first" ) >> 268 pmanager ->AddProcess(theTransportationProcess); >> 269 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep); >> 270 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep); >> 271 } >> 272 } else { >> 273 // shortlived particle case >> 274 // Add transportation process for all particles other than "shortlived" >> 275 if ( pmanager == 0) { >> 276 // Error !! no process manager >> 277 G4String particleName = particle->GetParticleName(); >> 278 G4Exception("G4VUserPhysicsList::AddTransportation","No process manager", >> 279 RunMustBeAborted, particleName ); >> 280 } else { >> 281 // add transportation with ordering = ( -1, "first", "first" ) >> 282 pmanager ->AddProcess(theTransportationProcess); >> 283 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep); >> 284 pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep); >> 285 } 369 286 370 #ifdef G4VERBOSE << 287 } 371 if (verboseLevel > 1) { << 372 G4cout << "G4VUserPhysicsList::SetDefaultC << 373 << "default cut value is changed to << 374 } 288 } 375 #endif << 376 } 289 } 377 290 378 // ------------------------------------------- << 291 379 G4double G4VUserPhysicsList::GetCutValue(const << 292 //////////////////////////////////////////////////////// >> 293 void G4VUserPhysicsList::SetDefaultCutValue(G4double value) 380 { 294 { 381 std::size_t nReg = (G4RegionStore::GetInstan << 295 if (value<=0.0) { 382 if (nReg == 0) { << 383 #ifdef G4VERBOSE 296 #ifdef G4VERBOSE 384 if (verboseLevel > 0) { << 297 if (verboseLevel >0){ 385 G4cout << "G4VUserPhysicsList::GetCutVal << 298 G4cout << "G4VUserPhysicsList::SetDefaultCutValue: negative cut values"; 386 << " : No Default Region " << G4e << 299 G4cout << " :" << value/mm << "[mm]" << G4endl; 387 } << 300 } 388 #endif 301 #endif 389 G4Exception("G4VUserPhysicsList::GetCutVal << 302 } else { 390 return -1. * mm; << 303 #ifdef G4VERBOSE 391 } << 304 if (verboseLevel >1){ 392 G4Region* region = G4RegionStore::GetInstanc << 305 G4cout << "G4VUserPhysicsList::SetDefaultCutValue:"; 393 return region->GetProductionCuts()->GetProdu << 306 G4cout << "default cut value is changed to :" ; >> 307 G4cout << value/mm << "[mm]" << G4endl; >> 308 } >> 309 #endif >> 310 defaultCutValue = value; >> 311 >> 312 } 394 } 313 } 395 314 396 // ------------------------------------------- << 315 >> 316 //////////////////////////////////////////////////////// 397 void G4VUserPhysicsList::SetCutValue(G4double 317 void G4VUserPhysicsList::SetCutValue(G4double aCut, const G4String& name) 398 { 318 { 399 SetParticleCuts(aCut, name); << 319 G4ParticleDefinition* particle = theParticleTable->FindParticle(name); >> 320 if (particle != 0){ >> 321 if (!particle->IsShortLived()) { >> 322 //set cut value >> 323 SetParticleCuts( aCut ,particle ); >> 324 } >> 325 } 400 } 326 } 401 327 402 // ------------------------------------------- << 328 //////////////////////////////////////////////////////// 403 void G4VUserPhysicsList::SetCutValue(G4double << 329 void G4VUserPhysicsList::SetCutValue >> 330 (G4double aCut, const G4String& pname, const G4String& rname) 404 { 331 { >> 332 G4ParticleDefinition* particle = theParticleTable->FindParticle(pname); 405 G4Region* region = G4RegionStore::GetInstanc 333 G4Region* region = G4RegionStore::GetInstance()->GetRegion(rname); 406 if (region != nullptr) { << 334 if (particle != 0 && region != 0){ 407 // set cut value << 335 if (!particle->IsShortLived()) { 408 SetParticleCuts(aCut, pname, region); << 336 //set cut value 409 } << 337 SetParticleCuts( aCut ,particle, region ); 410 else { << 411 #ifdef G4VERBOSE << 412 if (verboseLevel > 0) { << 413 G4cout << "G4VUserPhysicsList::SetCutVal << 414 << " : No Region of " << rname << << 415 } 338 } 416 #endif << 417 } 339 } 418 } 340 } 419 341 420 // ------------------------------------------- << 342 >> 343 >> 344 //////////////////////////////////////////////////////// 421 void G4VUserPhysicsList::SetCutsWithDefault() 345 void G4VUserPhysicsList::SetCutsWithDefault() 422 { 346 { 423 SetDefaultCutValue(defaultCutValue); << 347 // default cut value 424 G4VUserPhysicsList::SetCuts(); << 348 G4double cut = defaultCutValue; >> 349 >> 350 #ifdef G4VERBOSE >> 351 if (verboseLevel >1){ >> 352 G4cout << "G4VUserPhysicsList::SetCutsWithDefault:"; >> 353 G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl; >> 354 } >> 355 #endif >> 356 >> 357 // set cut values for gamma at first and for e- and e+ >> 358 SetCutValue(cut, "gamma"); >> 359 SetCutValue(cut, "e-"); >> 360 SetCutValue(cut, "e+"); >> 361 >> 362 // dump Cut values if verboseLevel==3 >> 363 if (verboseLevel>2) { >> 364 DumpCutValuesTable(); >> 365 } 425 } 366 } 426 367 427 // ------------------------------------------- << 368 >> 369 //////////////////////////////////////////////////////// 428 void G4VUserPhysicsList::SetCutsForRegion(G4do 370 void G4VUserPhysicsList::SetCutsForRegion(G4double aCut, const G4String& rname) 429 { 371 { 430 // set cut values for gamma at first and for 372 // set cut values for gamma at first and for e- and e+ 431 SetCutValue(aCut, "gamma", rname); 373 SetCutValue(aCut, "gamma", rname); 432 SetCutValue(aCut, "e-", rname); 374 SetCutValue(aCut, "e-", rname); 433 SetCutValue(aCut, "e+", rname); 375 SetCutValue(aCut, "e+", rname); 434 SetCutValue(aCut, "proton", rname); << 435 } 376 } 436 377 437 // ------------------------------------------- << 438 void G4VUserPhysicsList::SetParticleCuts(G4dou << 439 G4Reg << 440 { << 441 SetParticleCuts(cut, particle->GetParticleNa << 442 } << 443 378 444 // ------------------------------------------- << 445 void G4VUserPhysicsList::SetParticleCuts(G4dou << 446 G4Reg << 447 { << 448 if (cut < 0.0) { << 449 #ifdef G4VERBOSE << 450 if (verboseLevel > 0) { << 451 G4cout << "G4VUserPhysicsList::SetPartic << 452 << " :" << cut / mm << "[mm]" << 453 << " for " << particleName << G4e << 454 } << 455 #endif << 456 return; << 457 } << 458 << 459 G4Region* world_region = << 460 G4RegionStore::GetInstance()->GetRegion("D << 461 if (region == nullptr) { << 462 std::size_t nReg = G4RegionStore::GetInsta << 463 if (nReg == 0) { << 464 #ifdef G4VERBOSE << 465 if (verboseLevel > 0) { << 466 G4cout << "G4VUserPhysicsList::SetPart << 467 << " : No Default Region " << G << 468 } << 469 #endif << 470 G4Exception("G4VUserPhysicsList::SetPart << 471 "No Default Region"); << 472 return; << 473 } << 474 region = world_region; << 475 } << 476 << 477 if (!isSetDefaultCutValue) { << 478 SetDefaultCutValue(defaultCutValue); << 479 } << 480 379 >> 380 //////////////////////////////////////////////////////// >> 381 //////////////////////////////////////////////////////// >> 382 void G4VUserPhysicsList::SetParticleCuts( G4double cut, G4ParticleDefinition* particle, G4Region* region) >> 383 { >> 384 if(!region) region = (*(G4RegionStore::GetInstance()))[0]; 481 G4ProductionCuts* pcuts = region->GetProduct 385 G4ProductionCuts* pcuts = region->GetProductionCuts(); 482 if (region != world_region << 386 pcuts->SetProductionCut(cut,particle); 483 && pcuts == G4ProductionCutsTable::GetPr << 484 { // This region had no unique cuts yet but << 485 // Need to create a new object before set << 486 pcuts = new G4ProductionCuts( << 487 *(G4ProductionCutsTable::GetProductionCu << 488 region->SetProductionCuts(pcuts); << 489 } << 490 pcuts->SetProductionCut(cut, particleName); << 491 #ifdef G4VERBOSE << 492 if (verboseLevel > 2) { << 493 G4cout << "G4VUserPhysicsList::SetParticle << 494 << " :" << cut / mm << "[mm]" << 495 << " for " << particleName << G4end << 496 } << 497 #endif << 498 } 387 } 499 388 500 // ------------------------------------------- << 389 /////////////////////////////////////////////////////////////// 501 void G4VUserPhysicsList::BuildPhysicsTable() 390 void G4VUserPhysicsList::BuildPhysicsTable() 502 { 391 { 503 // Prepare Physics table for all particles << 392 //Prepare Physics table for all particles 504 theParticleIterator->reset(); 393 theParticleIterator->reset(); 505 while ((*theParticleIterator)()) { << 394 while( (*theParticleIterator)() ){ 506 G4ParticleDefinition* particle = thePartic 395 G4ParticleDefinition* particle = theParticleIterator->value(); 507 PreparePhysicsTable(particle); << 396 PreparePhysicsTable(particle); 508 } 397 } 509 398 510 // ask processes to prepare physics table << 399 // ask processes to prepare physics table 511 if (fRetrievePhysicsTable) { 400 if (fRetrievePhysicsTable) { 512 fIsRestoredCutValues = fCutsTable->Retriev 401 fIsRestoredCutValues = fCutsTable->RetrieveCutsTable(directoryPhysicsTable, fStoredInAscii); 513 // check if retrieve Cut Table successfull 402 // check if retrieve Cut Table successfully 514 if (!fIsRestoredCutValues) { 403 if (!fIsRestoredCutValues) { 515 #ifdef G4VERBOSE 404 #ifdef G4VERBOSE 516 if (verboseLevel > 0) { << 405 if (verboseLevel>0){ 517 G4cout << "G4VUserPhysicsList::BuildPh << 406 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"; 518 << " Retrieve Cut Table failed << 407 G4cout << " Retrieve Cut Table failed !!" << G4endl; 519 } << 408 } 520 #endif << 409 #endif 521 G4Exception("G4VUserPhysicsList::BuildPh << 410 G4Exception("G4VUserPhysicsList::BuildPhysicsTable","Fail to Retreive", 522 "Fail to retrieve Production << 411 RunMustBeAborted,"Production Cut Table can not be retreived"); 523 } << 412 } else { 524 else { << 413 #ifdef G4VERBOSE 525 #ifdef G4VERBOSE << 414 if (verboseLevel>2){ 526 if (verboseLevel > 2) { << 415 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"; 527 G4cout << "G4VUserPhysicsList::BuildPh << 416 G4cout << " Retrieve Cut Table successfully " << G4endl; 528 << " Retrieve Cut Table succes << 417 } 529 } << 418 #endif 530 #endif << 419 } 531 } << 420 } else { 532 } << 421 #ifdef G4VERBOSE 533 else { << 422 if (verboseLevel>2){ 534 #ifdef G4VERBOSE << 423 G4cout << "G4VUserPhysicsList::BuildPhysicsTable"; 535 if (verboseLevel > 2) { << 424 G4cout << " does not retrieve Cut Table but calculate " << G4endl; 536 G4cout << "G4VUserPhysicsList::BuildPhys << 425 } 537 << " does not retrieve Cut Table << 426 #endif 538 } << 539 #endif << 540 } 427 } 541 428 542 // Sets a value to particle 429 // Sets a value to particle 543 // set cut values for gamma at first and for 430 // set cut values for gamma at first and for e- and e+ 544 G4String particleName; 431 G4String particleName; 545 G4ParticleDefinition* GammaP = theParticleTa 432 G4ParticleDefinition* GammaP = theParticleTable->FindParticle("gamma"); 546 if (GammaP != nullptr) BuildPhysicsTable(Gam << 433 if(GammaP) BuildPhysicsTable(GammaP); 547 G4ParticleDefinition* EMinusP = theParticleT 434 G4ParticleDefinition* EMinusP = theParticleTable->FindParticle("e-"); 548 if (EMinusP != nullptr) BuildPhysicsTable(EM << 435 if(EMinusP) BuildPhysicsTable(EMinusP); 549 G4ParticleDefinition* EPlusP = theParticleTa 436 G4ParticleDefinition* EPlusP = theParticleTable->FindParticle("e+"); 550 if (EPlusP != nullptr) BuildPhysicsTable(EPl << 437 if(EPlusP) BuildPhysicsTable(EPlusP); 551 G4ParticleDefinition* ProtonP = theParticleT 438 G4ParticleDefinition* ProtonP = theParticleTable->FindParticle("proton"); 552 if (ProtonP != nullptr) BuildPhysicsTable(Pr << 439 if(ProtonP) BuildPhysicsTable(ProtonP); >> 440 553 441 554 theParticleIterator->reset(); 442 theParticleIterator->reset(); 555 while ((*theParticleIterator)()) { << 443 while( (*theParticleIterator)() ){ 556 G4ParticleDefinition* particle = thePartic 444 G4ParticleDefinition* particle = theParticleIterator->value(); 557 if (particle != GammaP && particle != EMin << 445 if( particle!=GammaP && 558 BuildPhysicsTable(particle); << 446 particle!=EMinusP && >> 447 particle!=EPlusP && >> 448 particle!=ProtonP ){ >> 449 BuildPhysicsTable(particle); 559 } 450 } 560 } 451 } 561 << 562 // Set flag << 563 fIsPhysicsTableBuilt = true; << 564 } 452 } 565 << 453 /////////////////////////////////////////////////////////////// 566 // ------------------------------------------- << 567 void G4VUserPhysicsList::BuildPhysicsTable(G4P 454 void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle) 568 { 455 { 569 if (auto* trackingManager = particle->GetTra << 570 #ifdef G4VERBOSE << 571 if (verboseLevel > 2) { << 572 G4cout << "G4VUserPhysicsList::BuildPhys << 573 << "Calculate Physics Table for " << 574 << " via custom TrackingManager" << 575 } << 576 #endif << 577 trackingManager->BuildPhysicsTable(*partic << 578 return; << 579 } << 580 << 581 // Change in order to share physics tables f << 582 << 583 if (particle->GetMasterProcessManager() == n << 584 #ifdef G4VERBOSE << 585 if (verboseLevel > 0) { << 586 G4cout << "#### G4VUserPhysicsList::Buil << 587 << particle->GetParticleName() << << 588 } << 589 #endif << 590 return; << 591 } << 592 if (fRetrievePhysicsTable) { 456 if (fRetrievePhysicsTable) { 593 if (!fIsRestoredCutValues) { << 457 if ( !fIsRestoredCutValues){ 594 // fail to retrieve cut tables << 458 // fail to retreive cut tables 595 #ifdef G4VERBOSE 459 #ifdef G4VERBOSE 596 if (verboseLevel > 0) { << 460 if (verboseLevel>0){ 597 G4cout << "G4VUserPhysicsList::BuildPh << 461 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "; 598 << "Physics table can not be re << 462 G4cout << "Physics table can not be retreived and will be calculated "<< G4endl; 599 } 463 } 600 #endif 464 #endif 601 fRetrievePhysicsTable = false; << 465 fRetrievePhysicsTable = false; 602 } << 466 603 else { << 467 } else { 604 #ifdef G4VERBOSE 468 #ifdef G4VERBOSE 605 if (verboseLevel > 2) { << 469 if (verboseLevel>2){ 606 G4cout << "G4VUserPhysicsList::BuildPh << 470 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "; 607 << " Retrieve Physics Table for << 471 G4cout << " Retrieve Physics Table for "; >> 472 G4cout << particle->GetParticleName() << G4endl; 608 } 473 } 609 #endif 474 #endif 610 // Retrieve PhysicsTable from files for 475 // Retrieve PhysicsTable from files for proccesses 611 RetrievePhysicsTable(particle, directory 476 RetrievePhysicsTable(particle, directoryPhysicsTable, fStoredInAscii); 612 } 477 } 613 } 478 } 614 479 615 #ifdef G4VERBOSE 480 #ifdef G4VERBOSE 616 if (verboseLevel > 2) { << 481 if (verboseLevel>2){ 617 G4cout << "G4VUserPhysicsList::BuildPhysic << 482 G4cout << "G4VUserPhysicsList::BuildPhysicsTable "; 618 << "Calculate Physics Table for " < << 483 G4cout << "Calculate Physics Table for " << particle->GetParticleName() << G4endl; 619 } 484 } 620 #endif 485 #endif 621 // Rebuild the physics tables for every proc 486 // Rebuild the physics tables for every process for this particle type 622 // if particle is not ShortLived 487 // if particle is not ShortLived 623 if (!particle->IsShortLived()) { << 488 if(!particle->IsShortLived()) { 624 G4ProcessManager* pManager = particle->Get << 489 G4ProcessVector* pVector = particle->GetProcessManager()->GetProcessList(); 625 if (pManager == nullptr) { << 490 for (G4int j=0; j < pVector->size(); ++j) { 626 #ifdef G4VERBOSE << 491 (*pVector)[j]->BuildPhysicsTable(*particle); 627 if (verboseLevel > 0) { << 628 G4cout << "G4VUserPhysicsList::BuildPh << 629 << " : No Process Manager for " << 630 G4cout << particle->GetParticleName() << 631 } << 632 #endif << 633 G4Exception("G4VUserPhysicsList::BuildPh << 634 "No process manager"); << 635 return; << 636 } << 637 << 638 // Get processes from master thread; << 639 G4ProcessManager* pManagerShadow = particl << 640 << 641 G4ProcessVector* pVector = pManager->GetPr << 642 if (pVector == nullptr) { << 643 #ifdef G4VERBOSE << 644 if (verboseLevel > 0) { << 645 G4cout << "G4VUserPhysicsList::BuildPh << 646 << " : No Process Vector for " << 647 } << 648 #endif << 649 G4Exception("G4VUserPhysicsList::BuildPh << 650 "No process Vector"); << 651 return; << 652 } << 653 #ifdef G4VERBOSE << 654 if (verboseLevel > 2) { << 655 G4cout << "G4VUserPhysicsList::BuildPhys << 656 << G4endl; << 657 G4cout << " ProcessManager : " << pManag << 658 << G4endl; << 659 for (G4int iv1 = 0; iv1 < (G4int)pVector << 660 G4cout << " " << iv1 << " - " << (*pV << 661 } << 662 G4cout << "----------------------------- << 663 G4ProcessVector* pVectorShadow = pManage << 664 << 665 for (G4int iv2 = 0; iv2 < (G4int)pVector << 666 G4cout << " " << iv2 << " - " << (*pV << 667 } << 668 } 492 } 669 #endif << 493 } 670 for (G4int j = 0; j < (G4int)pVector->size << 671 // Andrea July 16th 2013 : migration to << 672 // Infer if we are in a worker thread or << 673 // Master thread is the one in which the << 674 // and process manager shadow pointers a << 675 if (pManagerShadow == pManager) { << 676 (*pVector)[j]->BuildPhysicsTable(*part << 677 } << 678 else { << 679 (*pVector)[j]->BuildWorkerPhysicsTable << 680 } << 681 << 682 } // End loop on processes vector << 683 } // End if short-lived << 684 } 494 } 685 495 686 // ------------------------------------------- << 496 /////////////////////////////////////////////////////////////// 687 void G4VUserPhysicsList::PreparePhysicsTable(G 497 void G4VUserPhysicsList::PreparePhysicsTable(G4ParticleDefinition* particle) 688 { 498 { 689 if (auto* trackingManager = particle->GetTra << 690 trackingManager->PreparePhysicsTable(*part << 691 return; << 692 } << 693 << 694 if ((particle->GetMasterProcessManager()) == << 695 return; << 696 } << 697 // Prepare the physics tables for every proc 499 // Prepare the physics tables for every process for this particle type 698 // if particle is not ShortLived 500 // if particle is not ShortLived 699 if (!particle->IsShortLived()) { << 501 if(!particle->IsShortLived()) { 700 G4ProcessManager* pManager = particle->Get << 502 G4ProcessManager* pManager = particle->GetProcessManager(); 701 if (pManager == nullptr) { << 503 if (!pManager) { 702 #ifdef G4VERBOSE << 504 G4cerr << "G4VUserPhysicsList::PreparePhysicsTable : No Process Manager for " 703 if (verboseLevel > 0) { << 505 << particle->GetParticleName() <<G4endl; 704 G4cout << "G4VUserPhysicsList::Prepare << 506 G4cerr << particle->GetParticleName() << " should be created in your PhysicsList" <<G4endl; 705 << ": No Process Manager for " << 507 G4Exception("G4VUserPhysicsList::PreparePhysicsTable","No process manager", 706 G4cout << particle->GetParticleName() << 508 RunMustBeAborted, particle->GetParticleName() ); 707 } << 708 #endif << 709 G4Exception("G4VUserPhysicsList::Prepare << 710 "No process manager"); << 711 return; << 712 } 509 } 713 510 714 // Get processes from master thread << 715 G4ProcessManager* pManagerShadow = particl << 716 << 717 G4ProcessVector* pVector = pManager->GetPr 511 G4ProcessVector* pVector = pManager->GetProcessList(); 718 if (pVector == nullptr) { << 512 for (G4int j=0; j < pVector->size(); ++j) { 719 #ifdef G4VERBOSE << 513 (*pVector)[j]->PreparePhysicsTable(*particle); 720 if (verboseLevel > 0) { << 514 } 721 G4cout << "G4VUserPhysicsList::Prepare << 515 } 722 << ": No Process Vector for " < << 723 } << 724 #endif << 725 G4Exception("G4VUserPhysicsList::Prepare << 726 "No process Vector"); << 727 return; << 728 } << 729 for (G4int j = 0; j < (G4int)pVector->size << 730 // Andrea July 16th 2013 : migration to << 731 // Infer if we are in a worker thread or << 732 // Master thread is the one in which the << 733 // and process manager shadow pointers a << 734 if (pManagerShadow == pManager) { << 735 (*pVector)[j]->PreparePhysicsTable(*pa << 736 } << 737 else { << 738 (*pVector)[j]->PrepareWorkerPhysicsTab << 739 } << 740 } // End loop on processes vector << 741 } // End if pn ShortLived << 742 } 516 } 743 517 744 // ------------------------------------------- << 518 /////////////////////////////////////////////////////////////// 745 void G4VUserPhysicsList::BuildIntegralPhysicsT << 519 void G4VUserPhysicsList::BuildIntegralPhysicsTable(G4VProcess* process, 746 << 520 G4ParticleDefinition* particle) 747 { 521 { 748 // TODO Should we change this function? << 522 //********************************************************************* 749 //****************************************** << 523 // temporary addition to make the integral schema of electromagnetic 750 // Temporary addition to make the integral s << 751 // processes work. 524 // processes work. >> 525 // 752 526 753 if ((process->GetProcessName() == "Imsc") || << 527 if ( (process->GetProcessName() == "Imsc") || 754 || (process->GetProcessName() == "IeBrem << 528 (process->GetProcessName() == "IeIoni") || 755 || (process->GetProcessName() == "IhIoni << 529 (process->GetProcessName() == "IeBrems") || 756 || (process->GetProcessName() == "IMuBre << 530 (process->GetProcessName() == "Iannihil") || 757 { << 531 (process->GetProcessName() == "IhIoni") || 758 #ifdef G4VERBOSE << 532 (process->GetProcessName() == "IMuIoni") || 759 if (verboseLevel > 2) { << 533 (process->GetProcessName() == "IMuBrems") || 760 G4cout << "G4VUserPhysicsList::BuildInte << 534 (process->GetProcessName() == "IMuPairProd") ) { 761 << " BuildPhysicsTable is invoked << 535 #ifdef G4VERBOSE 762 << particle->GetParticleName() << << 536 if (verboseLevel>2){ >> 537 G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable "; >> 538 G4cout << " BuildPhysicsTable is invoked for "; >> 539 G4cout << process->GetProcessName(); >> 540 G4cout << "(" << particle->GetParticleName() << ")" << G4endl; 763 } 541 } 764 #endif 542 #endif 765 process->BuildPhysicsTable(*particle); 543 process->BuildPhysicsTable(*particle); 766 } 544 } 767 } 545 } 768 546 769 // ------------------------------------------- << 547 /////////////////////////////////////////////////////////////// 770 void G4VUserPhysicsList::DumpList() const 548 void G4VUserPhysicsList::DumpList() const 771 { 549 { 772 theParticleIterator->reset(); 550 theParticleIterator->reset(); 773 G4int idx = 0; 551 G4int idx = 0; 774 while ((*theParticleIterator)()) { << 552 while( (*theParticleIterator)() ){ 775 G4ParticleDefinition* particle = thePartic 553 G4ParticleDefinition* particle = theParticleIterator->value(); 776 G4cout << particle->GetParticleName(); 554 G4cout << particle->GetParticleName(); 777 if ((idx++ % 4) == 3) { 555 if ((idx++ % 4) == 3) { 778 G4cout << G4endl; 556 G4cout << G4endl; 779 } << 557 } else { 780 else { << 781 G4cout << ", "; 558 G4cout << ", "; 782 } << 559 } 783 } 560 } 784 G4cout << G4endl; 561 G4cout << G4endl; 785 } 562 } 786 563 787 // ------------------------------------------- << 564 788 void G4VUserPhysicsList::DumpCutValuesTable(G4 << 565 789 { << 566 /////////////////////////////////////////////////////////////// 790 fDisplayThreshold = flag; << 567 void G4VUserPhysicsList::DumpCutValuesTable(G4int nParticles) >> 568 { >> 569 fDisplayThreshold = nParticles; 791 } 570 } 792 571 793 // ------------------------------------------- << 572 /////////////////////////////////////////////////////////////// 794 void G4VUserPhysicsList::DumpCutValuesTableIfR 573 void G4VUserPhysicsList::DumpCutValuesTableIfRequested() 795 { 574 { 796 if (fDisplayThreshold == 0) return; << 575 if(fDisplayThreshold==0) return; 797 G4ProductionCutsTable::GetProductionCutsTabl 576 G4ProductionCutsTable::GetProductionCutsTable()->DumpCouples(); 798 fDisplayThreshold = 0; 577 fDisplayThreshold = 0; 799 } 578 } 800 579 801 // ------------------------------------------- << 580 >> 581 /////////////////////////////////////////////////////////////// >> 582 /////////////////////////////////////////////////////////////// 802 G4bool G4VUserPhysicsList::StorePhysicsTable(c 583 G4bool G4VUserPhysicsList::StorePhysicsTable(const G4String& directory) 803 { 584 { 804 G4bool ascii = fStoredInAscii; << 585 G4bool ascii = fStoredInAscii; 805 G4String dir = directory; << 586 G4String dir = directory; 806 if (dir.empty()) << 587 if (dir.isNull()) dir = directoryPhysicsTable; 807 dir = directoryPhysicsTable; << 588 else directoryPhysicsTable = dir; 808 else << 809 directoryPhysicsTable = dir; << 810 589 811 // store CutsTable info 590 // store CutsTable info 812 if (!fCutsTable->StoreCutsTable(dir, ascii)) 591 if (!fCutsTable->StoreCutsTable(dir, ascii)) { 813 G4Exception("G4VUserPhysicsList::StorePhys << 592 G4Exception("G4VUserPhysicsList::StorePhysicsTable","Faile to store ", 814 "Fail to store Cut Table"); << 593 JustWarning,"Cut Table can not be stored"); 815 return false; 594 return false; 816 } 595 } 817 #ifdef G4VERBOSE << 596 #ifdef G4VERBOSE 818 if (verboseLevel > 2) { << 597 if (verboseLevel>2){ 819 G4cout << "G4VUserPhysicsList::StorePhysic << 598 G4cout << "G4VUserPhysicsList::StorePhysicsTable "; 820 << " Store material and cut values << 599 G4cout << " Store material and cut values successfully" << G4endl; 821 } 600 } 822 #endif 601 #endif 823 602 824 G4bool success = true; << 603 G4bool success= true; 825 604 826 // loop over all particles in G4ParticleTabl << 605 // loop over all particles in G4ParticleTable 827 theParticleIterator->reset(); 606 theParticleIterator->reset(); 828 while ((*theParticleIterator)()) { << 607 while( (*theParticleIterator)() ){ 829 G4ParticleDefinition* particle = thePartic 608 G4ParticleDefinition* particle = theParticleIterator->value(); 830 // Store physics tables for every process 609 // Store physics tables for every process for this particle type 831 G4ProcessVector* pVector = (particle->GetP 610 G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList(); 832 for (G4int j = 0; j < (G4int)pVector->size << 611 G4int j; 833 if (!(*pVector)[j]->StorePhysicsTable(pa << 612 for ( j=0; j < pVector->size(); ++j) { 834 G4String comment = "Fail to store phys << 613 if (!(*pVector)[j]->StorePhysicsTable(particle,dir,ascii)){ 835 comment += (*pVector)[j]->GetProcessNa << 614 G4String comment = "Fail to store for " + (*pVector)[j]->GetProcessName(); 836 comment += "(" + particle->GetParticle << 615 comment += "(" + particle->GetParticleName() + ")"; 837 G4Exception("G4VUserPhysicsList::Store << 616 G4Exception("G4VUserPhysicsList::StorePhysicsTable","Faile to store ", 838 success = false; << 617 JustWarning,comment); >> 618 success = false; 839 } 619 } 840 } 620 } 841 // end loop over processes 621 // end loop over processes 842 } 622 } 843 // end loop over particles 623 // end loop over particles 844 return success; 624 return success; 845 } 625 } 846 626 847 // ------------------------------------------- << 627 848 void G4VUserPhysicsList::SetPhysicsTableRetrie << 628 >> 629 /////////////////////////////////////////////////////////////// >> 630 void G4VUserPhysicsList::SetPhysicsTableRetrieved(const G4String& directory) 849 { 631 { 850 fRetrievePhysicsTable = true; 632 fRetrievePhysicsTable = true; 851 if (!directory.empty()) { << 633 if(!directory.isNull()) { 852 directoryPhysicsTable = directory; 634 directoryPhysicsTable = directory; 853 } 635 } 854 fIsCheckedForRetrievePhysicsTable = false; << 636 fIsCheckedForRetrievePhysicsTable=false; 855 fIsRestoredCutValues = false; 637 fIsRestoredCutValues = false; 856 } 638 } 857 639 858 // ------------------------------------------- << 640 /////////////////////////////////////////////////////////////// 859 void G4VUserPhysicsList::RetrievePhysicsTable( << 641 void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle, 860 << 642 const G4String& directory, >> 643 G4bool ascii) 861 { 644 { 862 G4bool success[100]; << 645 G4int j; >> 646 G4bool success[100]; 863 // Retrieve physics tables for every process 647 // Retrieve physics tables for every process for this particle type 864 G4ProcessVector* pVector = (particle->GetPro 648 G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList(); 865 for (G4int j = 0; j < (G4int)pVector->size() << 649 for ( j=0; j < pVector->size(); ++j) { 866 success[j] = (*pVector)[j]->RetrievePhysic << 650 success[j] = >> 651 (*pVector)[j]->RetrievePhysicsTable(particle,directory,ascii); 867 652 868 if (!success[j]) { 653 if (!success[j]) { 869 #ifdef G4VERBOSE << 654 #ifdef G4VERBOSE 870 if (verboseLevel > 2) { << 655 if (verboseLevel>2){ 871 G4cout << "G4VUserPhysicsList::Retriev << 656 G4cout << "G4VUserPhysicsList::RetrievePhysicsTable "; 872 << " Fail to retrieve Physics T << 657 G4cout << " Fail to retrieve Physics Table for "; 873 << G4endl; << 658 G4cout << (*pVector)[j]->GetProcessName() << G4endl; 874 G4cout << "Calculate Physics Table for << 659 G4cout << "Calculate Physics Table for " << particle->GetParticleName() << G4endl; 875 } 660 } 876 #endif 661 #endif 877 (*pVector)[j]->BuildPhysicsTable(*partic 662 (*pVector)[j]->BuildPhysicsTable(*particle); 878 } 663 } 879 } 664 } 880 for (G4int j = 0; j < (G4int)pVector->size() << 665 for ( j=0; j < pVector->size(); ++j) { 881 // temporary addition to make the integral 666 // temporary addition to make the integral schema 882 if (!success[j]) BuildIntegralPhysicsTable << 667 if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle); 883 } 668 } 884 } 669 } 885 670 886 // ------------------------------------------- << 671 void G4VUserPhysicsList::ResetCuts() >> 672 { >> 673 #ifdef G4VERBOSE >> 674 if (verboseLevel>0){ >> 675 G4cout << "G4VUserPhysicsList::ResetCuts() is obsolete."; >> 676 G4cout << " This method gives no effect and you can remove it. "<< G4endl; >> 677 } >> 678 #endif >> 679 } >> 680 887 void G4VUserPhysicsList::SetApplyCuts(G4bool v 681 void G4VUserPhysicsList::SetApplyCuts(G4bool value, const G4String& name) 888 { 682 { 889 #ifdef G4VERBOSE << 683 #ifdef G4VERBOSE 890 if (verboseLevel > 2) { << 684 if (verboseLevel>2){ 891 G4cout << "G4VUserPhysicsList::SetApplyCut 685 G4cout << "G4VUserPhysicsList::SetApplyCuts for " << name << G4endl; 892 } 686 } 893 #endif 687 #endif 894 if (name == "all") { << 688 if(name=="all") { 895 theParticleTable->FindParticle("gamma")->S 689 theParticleTable->FindParticle("gamma")->SetApplyCutsFlag(value); 896 theParticleTable->FindParticle("e-")->SetA 690 theParticleTable->FindParticle("e-")->SetApplyCutsFlag(value); 897 theParticleTable->FindParticle("e+")->SetA 691 theParticleTable->FindParticle("e+")->SetApplyCutsFlag(value); 898 theParticleTable->FindParticle("proton")-> << 692 } else { 899 } << 900 else { << 901 theParticleTable->FindParticle(name)->SetA 693 theParticleTable->FindParticle(name)->SetApplyCutsFlag(value); 902 } 694 } 903 } 695 } 904 696 905 // ------------------------------------------- << 906 G4bool G4VUserPhysicsList::GetApplyCuts(const 697 G4bool G4VUserPhysicsList::GetApplyCuts(const G4String& name) const 907 { 698 { 908 return theParticleTable->FindParticle(name)- 699 return theParticleTable->FindParticle(name)->GetApplyCutsFlag(); 909 } 700 } 910 701 911 // ------------------------------------------- << 912 void G4VUserPhysicsList::CheckParticleList() << 913 { << 914 if (!fDisableCheckParticleList) { << 915 G4MT_thePLHelper->CheckParticleList(); << 916 } << 917 } << 918 702 919 // ------------------------------------------- << 920 void G4VUserPhysicsList::AddTransportation() << 921 { << 922 G4MT_thePLHelper->AddTransportation(); << 923 } << 924 703 925 // ------------------------------------------- << 926 void G4VUserPhysicsList::UseCoupledTransportat << 927 { << 928 G4MT_thePLHelper->UseCoupledTransportation(v << 929 } << 930 704 931 // ------------------------------------------- << 705 /// obsolete methods 932 G4bool G4VUserPhysicsList::RegisterProcess(G4V << 933 { << 934 return G4MT_thePLHelper->RegisterProcess(pro << 935 } << 936 706 937 // ------------------------------------------- << 707 938 G4ParticleTable::G4PTblDicIterator* G4VUserPhy << 708 void G4VUserPhysicsList::DumpCutValues(const G4String &particle_name) 939 { 709 { 940 return (subInstanceManager.offset[g4vuplInst << 710 G4cerr << "WARNING !" << G4endl; >> 711 G4cerr << " Obsolete DumpCutValues() method is invoked for " << particle_name << G4endl; >> 712 G4cerr << " Please use DumpCutValuesTable() instead." << G4endl; >> 713 G4cerr << " This dummy method implementation will be removed soon." << G4endl; >> 714 DumpCutValuesTable(); 941 } 715 } 942 716 943 // ------------------------------------------- << 717 void G4VUserPhysicsList::DumpCutValues(G4ParticleDefinition* ) 944 void G4VUserPhysicsList::SetVerboseLevel(G4int << 945 { 718 { 946 verboseLevel = value; << 719 G4cerr << "WARNING !" << G4endl; 947 // set verboseLevel for G4ProductionCutsTabl << 720 G4cerr << " DumpCutValues() became obsolete." << G4endl; 948 // G4VUserPhysicsList: << 721 G4cerr << " Please use DumpCutValuesTable() instead." << G4endl; 949 fCutsTable->SetVerboseLevel(verboseLevel); << 722 G4cerr << " This dummy method implementation will be removed soon." << G4endl; 950 << 723 DumpCutValuesTable(); 951 G4MT_thePLHelper->SetVerboseLevel(verboseLev << 952 << 953 #ifdef G4VERBOSE << 954 if (verboseLevel > 1) { << 955 G4cout << "G4VUserPhysicsList::SetVerboseL << 956 << " Verbose level is set to " << v << 957 } << 958 #endif << 959 } 724 } 960 725