ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PhysicsListSvc Class Reference

#include <PhysicsListSvc.h>

Inheritance diagram for PhysicsListSvc:
Collaboration diagram for PhysicsListSvc:

Public Member Functions

 PhysicsListSvc (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual ~PhysicsListSvc ()=default
 
virtual StatusCode initialize () override
 
virtual void CreatePhysicsList () override
 
virtual G4VUserPhysicsList * GetPhysicsList () override
 
virtual void SetPhysicsList () override
 
virtual void SetPhysicsOptions () override
 

Private Member Functions

void CommandLog (int returnCode, const std::string &commandString) const
 This command prints a message about a G4Command depending on its returnCode. More...
 

Private Attributes

ToolHandleArray< IPhysicsOptionToolm_phys_option {this, "PhysOption", {}, "Tool handle array of physics options" }
 
ToolHandleArray< IPhysicsOptionToolm_phys_decay {this, "PhysicsDecay", {}, "Tool handle array of physics decays"}
 
G4VModularPhysicsList * m_physicsList {}
 
Gaudi::Property< std::string > m_physicsListName {this, "PhysicsList", "FTFP_BERT", "Name for physics list"}
 !< Handle on the physics list More...
 
Gaudi::Property< double > m_neutronTimeCut {this, "NeutronTimeCut", 0, "Time cut for neutron killer"}
 !< Name for the physics list (property to be set in the tool) More...
 
Gaudi::Property< double > m_neutronEnergyCut {this, "NeutronEnergyCut", 0, "Energy cut for neutron killer"}
 !< Time cut for neutrons (in the neutron killer process) More...
 
Gaudi::Property< double > m_generalCut {this, "GeneralCut", 0, "General cut"}
 !< Energy cut for neutrons (in the neutron killer process) More...
 
Gaudi::Property< double > m_emMaxEnergy {this, "EMMaxEnergy", -1., "Maximum energy for EM tables"}
 !< A general cut - this isn't normally used in our simulation More...
 
Gaudi::Property< double > m_emMinEnergy {this, "EMMinEnergy", -1., "Minimum energy for EM tables"}
 !< Maximum energy of the pre-calculated EM cross-section tables More...
 
Gaudi::Property< int > m_emNumberOfBinsPerDecade {this, "EMNumberOfBinsPerDecade", -1, "Number of bins per Energy decade. Used for both DeDx and for the Lambda binning."}
 !< Minimum energy of the pre-calculated EM cross-section tables More...
 
Gaudi::Property< bool > m_applyEMCuts {this, "ApplyEMCuts", true, "Apply cuts EM flag in Geant4"}
 !< Number of bins per Energy decade. Used for both DeDx and for the Lambda binning. More...
 
Gaudi::Property< bool > m_quietMode {this, "QuietMode", false, ""}
 !< Switch for the G4 "apply cuts" EM physics flag More...
 
Gaudi::Property< bool > m_unstableAntiNeutrons {this, "UnstableAntiNeutrons",false,"Bugfix for ATLASSIM-6634 until we switch to using Geant4 11"}
 

Detailed Description

Definition at line 23 of file PhysicsListSvc.h.

Constructor & Destructor Documentation

◆ PhysicsListSvc()

PhysicsListSvc::PhysicsListSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 22 of file PhysicsListSvc.cxx.

23  : base_class(name,pSvcLocator)
24 {
25 }

◆ ~PhysicsListSvc()

virtual PhysicsListSvc::~PhysicsListSvc ( )
virtualdefault

Member Function Documentation

◆ CommandLog()

void PhysicsListSvc::CommandLog ( int  returnCode,
const std::string &  commandString 
) const
private

This command prints a message about a G4Command depending on its returnCode.

Definition at line 211 of file PhysicsListSvc.cxx.

212 {
213  switch(returnCode) {
214  case 0: { ATH_MSG_DEBUG("G4 Command: " << commandString << " - Command Succeeded"); } break;
215  case 100: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Command Not Found!"); } break;
216  case 200: {
217  auto* stateManager = G4StateManager::GetStateManager();
218  ATH_MSG_DEBUG("G4 Command: " << commandString << " - Illegal Application State (" <<
219  stateManager->GetStateString(stateManager->GetCurrentState()) << ")!");
220  } break;
221  case 300: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Range!"); } break;
222  case 400: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Unreadable!"); } break;
223  case 500: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Candidates!"); } break;
224  case 600: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Alias Not Found!"); } break;
225  default: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Unknown Status!"); } break;
226  }
227 
228 }

◆ CreatePhysicsList()

void PhysicsListSvc::CreatePhysicsList ( )
overridevirtual

Definition at line 47 of file PhysicsListSvc.cxx.

48 {
49  ATH_MSG_DEBUG("PhysicsListSvc::CreatePhysicsList()");
50  if (m_physicsListName.value() != ""){
51  G4PhysListFactory factory;
52  if (m_quietMode) { factory.SetVerbose(0); } // HACK
53  AtlasPhysListFactory Atlasfactory;
54  if (m_quietMode) {
55  Atlasfactory.SetVerbose(0); // HACK
56  G4HadronicProcessStore::Instance()->SetVerbose(0);
57  }
58  if (factory.IsReferencePhysList(m_physicsListName.value()))
59  {
60  ATH_MSG_INFO("Creating Geant4 PhysicsList: " << m_physicsListName.value());
61  m_physicsList = factory.GetReferencePhysList(m_physicsListName.value());
62  }
63  else if (Atlasfactory.IsReferencePhysList(m_physicsListName.value()))
64  {
65  ATH_MSG_INFO("Creating ATLAS PhysicsList: " << m_physicsListName.value());
67  }
68  }
69 
70  if (!m_physicsList)
71  {
72  ATH_MSG_ERROR("Unable to initialize physics List: " << m_physicsList);
73  throw "PhysicsListInitializationError";
74  }
75  // Call these as functions. As this could be used as a base class, having
76  // these as separate functions lets someone who is inheriting from this use
77  // them...
78 
79  // sort m_phys_option list
80  std::vector<IPhysicsOptionTool*> sortedPhysicsOptions;
81  sortedPhysicsOptions.reserve(m_phys_option.size());
82  // Manually sorting ToolHandleArray
83  {
84  // BSM Physics
85  for (auto& physOptTool: m_phys_option) {
86  if (physOptTool->GetOptionType() == G4AtlasPhysicsOption::Type::BSMPhysics) {
87  sortedPhysicsOptions.push_back(&*physOptTool);
88  }
89  }
90 
91  // Add particles from the PDG Table not currently known to Geant4
92  for (auto& physOptTool: m_phys_option) {
93  if (physOptTool->GetOptionType() == G4AtlasPhysicsOption::Type::QS_ExtraParticles) {
94  sortedPhysicsOptions.push_back(&*physOptTool);
95  }
96  }
97 
98  // Add MSC and Ionisation processes for specific particles (possibly merge with the next one?)
99  for (auto& physOptTool: m_phys_option) {
100  if (physOptTool->GetOptionType() == G4AtlasPhysicsOption::Type::QS_ExtraProc) {
101  sortedPhysicsOptions.push_back(&*physOptTool);
102  }
103  }
104 
105  // G4StepLimitation, LUCID Op Process, TRT XTR process
106  for (auto& physOptTool: m_phys_option) {
107  if (physOptTool->GetOptionType() == G4AtlasPhysicsOption::Type::GlobalProcesses) {
108  sortedPhysicsOptions.push_back(&*physOptTool);
109  }
110  }
111 
112  // Unknown
113  for (auto& physOptTool: m_phys_option) {
114  if (physOptTool->GetOptionType() == G4AtlasPhysicsOption::Type::UnknownType) {
115  ATH_MSG_ERROR(physOptTool->name() << "set as UnknownType. This tool will not be used to modify the physics list of this job.");
116  }
117  }
118  }
119 
120  //Register physics options to the G4VModularPhysicsList
121  for (auto& physOptTool: sortedPhysicsOptions)
122  {
123  ATH_MSG_DEBUG("Registering " << physOptTool->name());
124  m_physicsList->RegisterPhysics(physOptTool->GetPhysicsOption());
125  }
126  //Register decays to the G4VModularPhysicsList
127  for (auto& physDecayTool: m_phys_decay)
128  {
129  ATH_MSG_DEBUG("Registering " << physDecayTool->name());
130  m_physicsList->RegisterPhysics(physDecayTool->GetPhysicsOption());
131  }
132 
133  //ConstructProcess();
134  ATH_MSG_DEBUG("end of PhysicsListSvc::CreatePhysicsList()");
135 }

◆ GetPhysicsList()

G4VUserPhysicsList * PhysicsListSvc::GetPhysicsList ( )
overridevirtual

Definition at line 138 of file PhysicsListSvc.cxx.

139 {
140  if (!m_physicsList) {
141  this->CreatePhysicsList();
142  }
143  return m_physicsList;
144 }

◆ initialize()

StatusCode PhysicsListSvc::initialize ( )
overridevirtual

Definition at line 28 of file PhysicsListSvc.cxx.

29 {
30  ATH_MSG_DEBUG("PhysicsListSvc::initialize()");
31  if (m_phys_option.size())
32  {
33  ATH_MSG_INFO( "Initializing list of " << m_phys_option.size() << " physics options" );
34  CHECK( m_phys_option.retrieve() );
35  }
36 
37  if (m_phys_decay.size())
38  {
39  ATH_MSG_INFO( "Initializing list of " << m_phys_decay.size() << " Decays " );
40  CHECK( m_phys_decay.retrieve() );
41  }
42 
43  return StatusCode::SUCCESS;
44 }

◆ SetPhysicsList()

void PhysicsListSvc::SetPhysicsList ( )
overridevirtual

Definition at line 147 of file PhysicsListSvc.cxx.

148 {
149  if(!m_physicsList) {
150  this->CreatePhysicsList();
151  }
152  G4RunManager::GetRunManager()->SetUserInitialization(m_physicsList);
153 }

◆ SetPhysicsOptions()

void PhysicsListSvc::SetPhysicsOptions ( )
overridevirtual

Definition at line 156 of file PhysicsListSvc.cxx.

157 {
158  if (!m_physicsList)
159  {
160  ATH_MSG_WARNING("Physics list not initialized before calling ConstructProcess()");
161  return;
162  }
163 
164  if(m_generalCut.value() > 0. && std::abs(m_generalCut.value())>std::numeric_limits<double>::epsilon())
165  {
166  m_physicsList->SetDefaultCutValue(m_generalCut.value());
167  }
168 
169  std::vector<std::string> g4commands;
170  if (m_neutronTimeCut.value() > 0. && std::abs(m_neutronTimeCut.value())>std::numeric_limits<double>::epsilon())
171  {
172  std::ostringstream oss;
173  oss<<"/physics_engine/neutron/timeLimit "<<m_neutronTimeCut.value()<<" ns";
174  g4commands.push_back(oss.str());
175  }
176 
177  if (m_neutronEnergyCut.value() > 0. && std::abs(m_neutronEnergyCut.value())>std::numeric_limits<double>::epsilon())
178  {
179  std::ostringstream oss;
180  oss<<"/physics_engine/neutron/energyLimit "<<m_neutronEnergyCut.value()<<" MeV";
181  g4commands.push_back(oss.str());
182  }
183 
184  if(!g4commands.empty()) {
185  // Send UI commands
186  ATH_MSG_DEBUG("G4 Command: Trying in SetPhysicsOptions()");
187  G4UImanager* ui = G4UImanager::GetUIpointer();
188  for (const auto& g4command : g4commands) {
189  int returnCode = ui->ApplyCommand( g4command );
190  CommandLog(returnCode, g4command);
191  }
192  }
193 
194  G4EmParameters* emp = G4EmParameters::Instance();
195  if (m_emMaxEnergy.value()>=0) emp->SetMaxEnergy(m_emMaxEnergy.value());
196  if (m_emNumberOfBinsPerDecade.value()>=0) emp->SetNumberOfBinsPerDecade(m_emNumberOfBinsPerDecade.value());
197  if (m_emMinEnergy.value()>=0) emp->SetMinEnergy(m_emMinEnergy.value());
198  if (m_applyEMCuts.value())
199  {
200  emp->SetApplyCuts(true);
201  }
202 
204  G4AntiNeutron::Definition()->SetPDGStable(false);
205  }
206 
207  return;
208 }

Member Data Documentation

◆ m_applyEMCuts

Gaudi::Property<bool> PhysicsListSvc::m_applyEMCuts {this, "ApplyEMCuts", true, "Apply cuts EM flag in Geant4"}
private

!< Number of bins per Energy decade. Used for both DeDx and for the Lambda binning.

Definition at line 59 of file PhysicsListSvc.h.

◆ m_emMaxEnergy

Gaudi::Property<double> PhysicsListSvc::m_emMaxEnergy {this, "EMMaxEnergy", -1., "Maximum energy for EM tables"}
private

!< A general cut - this isn't normally used in our simulation

Definition at line 50 of file PhysicsListSvc.h.

◆ m_emMinEnergy

Gaudi::Property<double> PhysicsListSvc::m_emMinEnergy {this, "EMMinEnergy", -1., "Minimum energy for EM tables"}
private

!< Maximum energy of the pre-calculated EM cross-section tables

Definition at line 51 of file PhysicsListSvc.h.

◆ m_emNumberOfBinsPerDecade

Gaudi::Property<int> PhysicsListSvc::m_emNumberOfBinsPerDecade {this, "EMNumberOfBinsPerDecade", -1, "Number of bins per Energy decade. Used for both DeDx and for the Lambda binning."}
private

!< Minimum energy of the pre-calculated EM cross-section tables

Definition at line 58 of file PhysicsListSvc.h.

◆ m_generalCut

Gaudi::Property<double> PhysicsListSvc::m_generalCut {this, "GeneralCut", 0, "General cut"}
private

!< Energy cut for neutrons (in the neutron killer process)

Definition at line 49 of file PhysicsListSvc.h.

◆ m_neutronEnergyCut

Gaudi::Property<double> PhysicsListSvc::m_neutronEnergyCut {this, "NeutronEnergyCut", 0, "Energy cut for neutron killer"}
private

!< Time cut for neutrons (in the neutron killer process)

Definition at line 48 of file PhysicsListSvc.h.

◆ m_neutronTimeCut

Gaudi::Property<double> PhysicsListSvc::m_neutronTimeCut {this, "NeutronTimeCut", 0, "Time cut for neutron killer"}
private

!< Name for the physics list (property to be set in the tool)

Definition at line 47 of file PhysicsListSvc.h.

◆ m_phys_decay

ToolHandleArray<IPhysicsOptionTool> PhysicsListSvc::m_phys_decay {this, "PhysicsDecay", {}, "Tool handle array of physics decays"}
private

Definition at line 44 of file PhysicsListSvc.h.

◆ m_phys_option

ToolHandleArray<IPhysicsOptionTool> PhysicsListSvc::m_phys_option {this, "PhysOption", {}, "Tool handle array of physics options" }
private

Definition at line 43 of file PhysicsListSvc.h.

◆ m_physicsList

G4VModularPhysicsList* PhysicsListSvc::m_physicsList {}
private

Definition at line 45 of file PhysicsListSvc.h.

◆ m_physicsListName

Gaudi::Property<std::string> PhysicsListSvc::m_physicsListName {this, "PhysicsList", "FTFP_BERT", "Name for physics list"}
private

!< Handle on the physics list

Definition at line 46 of file PhysicsListSvc.h.

◆ m_quietMode

Gaudi::Property<bool> PhysicsListSvc::m_quietMode {this, "QuietMode", false, ""}
private

!< Switch for the G4 "apply cuts" EM physics flag

Definition at line 60 of file PhysicsListSvc.h.

◆ m_unstableAntiNeutrons

Gaudi::Property<bool> PhysicsListSvc::m_unstableAntiNeutrons {this, "UnstableAntiNeutrons",false,"Bugfix for ATLASSIM-6634 until we switch to using Geant4 11"}
private

Definition at line 61 of file PhysicsListSvc.h.


The documentation for this class was generated from the following files:
PhysicsListSvc::m_quietMode
Gaudi::Property< bool > m_quietMode
!< Switch for the G4 "apply cuts" EM physics flag
Definition: PhysicsListSvc.h:60
G4AtlasPhysicsOption::QS_ExtraProc
@ QS_ExtraProc
Definition: IPhysicsOptionTool.h:24
PhysicsListSvc::m_generalCut
Gaudi::Property< double > m_generalCut
!< Energy cut for neutrons (in the neutron killer process)
Definition: PhysicsListSvc.h:49
PhysicsListSvc::m_unstableAntiNeutrons
Gaudi::Property< bool > m_unstableAntiNeutrons
Definition: PhysicsListSvc.h:61
PhysicsListSvc::CreatePhysicsList
virtual void CreatePhysicsList() override
Definition: PhysicsListSvc.cxx:47
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AtlasPhysListFactory::IsReferencePhysList
G4bool IsReferencePhysList(const G4String &)
AtlasPhysListFactory
Definition: AtlasPhysListFactory.h:12
AtlasPhysListFactory::SetVerbose
void SetVerbose(G4int val)
Definition: AtlasPhysListFactory.h:31
PhysicsListSvc::m_physicsListName
Gaudi::Property< std::string > m_physicsListName
!< Handle on the physics list
Definition: PhysicsListSvc.h:46
PhysicsListSvc::m_emMaxEnergy
Gaudi::Property< double > m_emMaxEnergy
!< A general cut - this isn't normally used in our simulation
Definition: PhysicsListSvc.h:50
PhysicsListSvc::m_phys_option
ToolHandleArray< IPhysicsOptionTool > m_phys_option
Definition: PhysicsListSvc.h:43
PhysicsListSvc::m_emMinEnergy
Gaudi::Property< double > m_emMinEnergy
!< Maximum energy of the pre-calculated EM cross-section tables
Definition: PhysicsListSvc.h:51
PhysicsListSvc::m_phys_decay
ToolHandleArray< IPhysicsOptionTool > m_phys_decay
Definition: PhysicsListSvc.h:44
PhysicsListSvc::CommandLog
void CommandLog(int returnCode, const std::string &commandString) const
This command prints a message about a G4Command depending on its returnCode.
Definition: PhysicsListSvc.cxx:211
PhysicsListSvc::m_neutronTimeCut
Gaudi::Property< double > m_neutronTimeCut
!< Name for the physics list (property to be set in the tool)
Definition: PhysicsListSvc.h:47
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
PhysicsListSvc::m_neutronEnergyCut
Gaudi::Property< double > m_neutronEnergyCut
!< Time cut for neutrons (in the neutron killer process)
Definition: PhysicsListSvc.h:48
PhysicsListSvc::m_emNumberOfBinsPerDecade
Gaudi::Property< int > m_emNumberOfBinsPerDecade
!< Minimum energy of the pre-calculated EM cross-section tables
Definition: PhysicsListSvc.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
PhysicsListSvc::m_physicsList
G4VModularPhysicsList * m_physicsList
Definition: PhysicsListSvc.h:45
G4AtlasPhysicsOption::GlobalProcesses
@ GlobalProcesses
Definition: IPhysicsOptionTool.h:25
G4AtlasPhysicsOption::UnknownType
@ UnknownType
Definition: IPhysicsOptionTool.h:26
AtlasPhysListFactory::GetReferencePhysList
G4VModularPhysicsList * GetReferencePhysList(const G4String &)
PhysicsListSvc::m_applyEMCuts
Gaudi::Property< bool > m_applyEMCuts
!< Number of bins per Energy decade. Used for both DeDx and for the Lambda binning.
Definition: PhysicsListSvc.h:59
G4AtlasPhysicsOption::QS_ExtraParticles
@ QS_ExtraParticles
Definition: IPhysicsOptionTool.h:23
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
G4AtlasPhysicsOption::BSMPhysics
@ BSMPhysics
Definition: IPhysicsOptionTool.h:22