SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
PhysicsListManager.cc
Go to the documentation of this file.
1 #include "PhysicsListManager.hh"
2 
3 // geant4
4 #include "G4RunManager.hh"
5 #include "G4VUserPhysicsList.hh"
6 #include "G4UserSpecialCuts.hh"
7 #include "G4StepLimiter.hh"
8 #include "G4PhysListFactory.hh"
9 
10 // slic
11 #include "LCOpticalPhysics.hh"
12 #include "HepPDTManager.hh"
13 #include "LCExtendedParticles.hh"
14 
15 namespace slic {
16 
17 // QGSP_BERT is the default physics list.
18 const std::string PhysicsListManager::m_defaultListName = std::string("QGSP_BERT");
19 
21  Module("PhysicsListManager"), m_currentList(0), m_isInitialized(false), m_isFromDefault(false), m_enableLimits(false), m_setupLimits(false), m_enableOptical(false) {
22  // Set the current list to the default.
24 
25  // Create the messenger class for the manager.
27 
28  // Create the list factory.
29  m_factory = new G4PhysListFactory();
30 }
31 
33 }
34 
35 void PhysicsListManager::setCurrentListName(const std::string& n) {
37  m_isFromDefault = false;
38 }
39 
41 
42 #ifdef SLIC_LOG
43  if ( m_isFromDefault ) {
44  log() << LOG::okay << "Using default physics list <" << m_defaultListName << ">." << LOG::done;
45  }
46 #endif
47 
48  // Create the physics list from the name argument.
49  m_currentList = m_factory->GetReferencePhysList(m_currentListName);
50 
51  // Enable optical processes.
52  if (enableOptical()) {
53  dynamic_cast<G4VModularPhysicsList*>(m_currentList)->RegisterPhysics(new LCOpticalPhysics("optical"));
54  }
55 
56  if (HepPDTManager::instance()->getParticleDataTable()) {
57  dynamic_cast<G4VModularPhysicsList*>(m_currentList)->RegisterPhysics(new LCExtendedParticles());
58  }
59 
60  return m_currentList;
61 }
62 
64 
65  G4ParticleTable* ptbl = G4ParticleTable::GetParticleTable();
66  G4ParticleTable::G4PTblDicIterator* piter = ptbl->GetIterator();
67  G4UserSpecialCuts* cuts = new G4UserSpecialCuts("UserSpecialCuts");
68  G4StepLimiter* slim = new G4StepLimiter("StepLimiter");
69 
70  piter->reset();
71  while ((*piter)()) {
72  G4ParticleDefinition* pdef = piter->value();
73  G4ProcessManager* pmgr = pdef->GetProcessManager();
74 
75  // Add user limit processes for steps and special cuts.
76  if (pmgr) {
77  pmgr->AddProcess(slim, -1, -1, 3);
78 
79  pmgr->AddProcess(cuts, -1, -1, 4);
80  } else {
81  G4Exception("", "", FatalException, "G4ProcessManager is null.");
82  }
83  }
84 }
85 
87  const std::vector<G4String>& lists = m_factory->AvailablePhysLists();
88  for (std::vector<G4String>::const_iterator it = lists.begin(); it != lists.end(); it++) {
89  log().always(*it);
90  }
91 }
92 }
Optical physics constructor.
static HepPDTManager * instance()
This class models the extended particle set from HepPDT.
LogStream & always()
Definition: LogStream.hh:278
Base class for slic code modules that provides common functionality, such as logging to an output str...
Definition: Module.hh:25
LogStream & log()
Definition: Module.hh:99
void setCurrentListName(const std::string &name)
static const std::string m_defaultListName
PhysicsMessenger * m_messenger
G4PhysListFactory * m_factory
G4VUserPhysicsList * m_currentList
G4VUserPhysicsList * createPhysicsList()
G4UImessenger for selection of physics list at runtime.
@ okay
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26