ATLAS Offline Software
Loading...
Searching...
No Matches
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
virtual void SetPhysicsListOptions () override
virtual void SetPhysicsProcessOptions () override

Private Member Functions

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

Private Attributes

ToolHandle< IPhysicsOptionToolm_fastSimulationConstructor {this, "FastSimConstructor", "", "Physics Constructor for fast simulation physics"}
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
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)
Gaudi::Property< double > m_neutronEnergyCut {this, "NeutronEnergyCut", 0, "Energy cut for neutron killer"}
 !< Time cut for neutrons (in the neutron killer process)
Gaudi::Property< double > m_generalCut {this, "GeneralCut", 0, "General cut"}
 !< Energy cut for neutrons (in the neutron killer process)
Gaudi::Property< double > m_emMaxEnergy {this, "EMMaxEnergy", -1., "Maximum energy for EM tables"}
 !< A general cut - this isn't normally used in our simulation
Gaudi::Property< double > m_emMinEnergy {this, "EMMinEnergy", -1., "Minimum energy for EM tables"}
 !< Maximum energy of the pre-calculated EM cross-section tables
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
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.
Gaudi::Property< bool > m_multipleStepsInMSCTransport {this, "MultipleStepsInMSCTransport", false, "Allow multiple MSC+transportation steps in G4HepEm, including the G4HepEm configuration used by AdePT"}
 !< Switch for the G4 "apply cuts" EM physics flag
Gaudi::Property< bool > m_quietMode {this, "QuietMode", false, ""}
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 265 of file PhysicsListSvc.cxx.

266{
267 switch(returnCode) {
268 case 0: { ATH_MSG_DEBUG("G4 Command: " << commandString << " - Command Succeeded"); } break;
269 case 100: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Command Not Found!"); } break;
270 case 200: {
271 auto* stateManager = G4StateManager::GetStateManager();
272 ATH_MSG_DEBUG("G4 Command: " << commandString << " - Illegal Application State (" <<
273 stateManager->GetStateString(stateManager->GetCurrentState()) << ")!");
274 } break;
275 case 300: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Range!"); } break;
276 case 400: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Unreadable!"); } break;
277 case 500: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Parameter Out of Candidates!"); } break;
278 case 600: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Alias Not Found!"); } break;
279 default: { ATH_MSG_ERROR("G4 Command: " << commandString << " - Unknown Status!"); } break;
280 }
281
282}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)

◆ CreatePhysicsList()

void PhysicsListSvc::CreatePhysicsList ( )
overridevirtual

Definition at line 49 of file PhysicsListSvc.cxx.

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

◆ GetPhysicsList()

G4VUserPhysicsList * PhysicsListSvc::GetPhysicsList ( )
overridevirtual

Definition at line 143 of file PhysicsListSvc.cxx.

144{
145 if (!m_physicsList) {
146 this->CreatePhysicsList();
147 }
148 return m_physicsList;
149}
virtual void CreatePhysicsList() override

◆ 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
44
45 return StatusCode::SUCCESS;
46}
#define CHECK(...)
Evaluate an expression and check for errors.

◆ SetAntiNeutronOptions()

void PhysicsListSvc::SetAntiNeutronOptions ( )
private

Definition at line 226 of file PhysicsListSvc.cxx.

227{
229 G4AntiNeutron::Definition()->SetPDGStable(false);
230 }
231}
Gaudi::Property< bool > m_unstableAntiNeutrons

◆ SetDefaultCut()

void PhysicsListSvc::SetDefaultCut ( )
private

Definition at line 203 of file PhysicsListSvc.cxx.

204{
205 if(m_generalCut.value() > 0. &&
206 std::abs(m_generalCut.value())>std::numeric_limits<double>::epsilon())
207 {
208 m_physicsList->SetDefaultCutValue(m_generalCut.value());
209 }
210}
Gaudi::Property< double > m_generalCut
!< Energy cut for neutrons (in the neutron killer process)

◆ SetEMParameters()

void PhysicsListSvc::SetEMParameters ( )
private

Definition at line 213 of file PhysicsListSvc.cxx.

214{
215 G4EmParameters* emp = G4EmParameters::Instance();
216 if (m_emMaxEnergy.value()>=0) emp->SetMaxEnergy(m_emMaxEnergy.value());
217 if (m_emNumberOfBinsPerDecade.value()>=0) emp->SetNumberOfBinsPerDecade(m_emNumberOfBinsPerDecade.value());
218 if (m_emMinEnergy.value()>=0) emp->SetMinEnergy(m_emMinEnergy.value());
219 if (m_applyEMCuts.value())
220 {
221 emp->SetApplyCuts(true);
222 }
223}
Gaudi::Property< double > m_emMaxEnergy
!< A general cut - this isn't normally used in our simulation
Gaudi::Property< double > m_emMinEnergy
!< Maximum energy of the pre-calculated EM cross-section tables
Gaudi::Property< bool > m_applyEMCuts
!< Number of bins per Energy decade. Used for both DeDx and for the Lambda binning.
Gaudi::Property< int > m_emNumberOfBinsPerDecade
!< Minimum energy of the pre-calculated EM cross-section tables

◆ SetNeutronKillerOptions()

void PhysicsListSvc::SetNeutronKillerOptions ( )
private

Definition at line 234 of file PhysicsListSvc.cxx.

235{
236 std::vector<std::string> g4commands;
237 if (m_neutronTimeCut.value() > 0. &&
238 std::abs(m_neutronTimeCut.value())>std::numeric_limits<double>::epsilon())
239 {
240 std::ostringstream oss;
241 oss<<"/physics_engine/neutron/timeLimit "<<m_neutronTimeCut.value()<<" ns";
242 g4commands.push_back(oss.str());
243 }
244
245 if (m_neutronEnergyCut.value() > 0. &&
246 std::abs(m_neutronEnergyCut.value())>std::numeric_limits<double>::epsilon())
247 {
248 std::ostringstream oss;
249 oss<<"/physics_engine/neutron/energyLimit "<<m_neutronEnergyCut.value()<<" MeV";
250 g4commands.push_back(oss.str());
251 }
252
253 if(!g4commands.empty()) {
254 // Send UI commands
255 ATH_MSG_DEBUG("G4 Command: Trying in SetPhysicsOptions()");
256 G4UImanager* ui = G4UImanager::GetUIpointer();
257 for (const auto& g4command : g4commands) {
258 int returnCode = ui->ApplyCommand( g4command );
259 CommandLog(returnCode, g4command);
260 }
261 }
262}
Gaudi::Property< double > m_neutronEnergyCut
!< Time cut for neutrons (in the neutron killer process)
Gaudi::Property< double > m_neutronTimeCut
!< Name for the physics list (property to be set in the tool)
void CommandLog(int returnCode, const std::string &commandString) const
This command prints a message about a G4Command depending on its returnCode.

◆ SetPhysicsList()

void PhysicsListSvc::SetPhysicsList ( )
overridevirtual

Definition at line 152 of file PhysicsListSvc.cxx.

153{
154 if(!m_physicsList) {
155 this->CreatePhysicsList();
156 }
157 G4RunManager::GetRunManager()->SetUserInitialization(m_physicsList);
158}

◆ SetPhysicsListOptions()

void PhysicsListSvc::SetPhysicsListOptions ( )
overridevirtual

Definition at line 177 of file PhysicsListSvc.cxx.

178{
179 if (!m_physicsList)
180 {
181 ATH_MSG_WARNING("Physics list not initialized before setting physics-list options");
182 return;
183 }
184
188}
#define ATH_MSG_WARNING(x)

◆ SetPhysicsOptions()

void PhysicsListSvc::SetPhysicsOptions ( )
overridevirtual

Definition at line 161 of file PhysicsListSvc.cxx.

162{
163 if (!m_physicsList)
164 {
165 ATH_MSG_WARNING("Physics list not initialized before calling ConstructProcess()");
166 return;
167 }
168
169 // Preserve the ordering used by the legacy run managers.
174}
void SetNeutronKillerOptions()

◆ SetPhysicsProcessOptions()

void PhysicsListSvc::SetPhysicsProcessOptions ( )
overridevirtual

Definition at line 191 of file PhysicsListSvc.cxx.

192{
193 if (!m_physicsList)
194 {
195 ATH_MSG_WARNING("Physics list not initialized before setting physics-process options");
196 return;
197 }
198
200}

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 68 of file PhysicsListSvc.h.

68{this, "ApplyEMCuts", true, "Apply cuts EM flag in Geant4"};

◆ 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 59 of file PhysicsListSvc.h.

59{this, "EMMaxEnergy", -1., "Maximum energy for EM tables"};

◆ 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 60 of file PhysicsListSvc.h.

60{this, "EMMinEnergy", -1., "Minimum energy for EM tables"};

◆ 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 67 of file PhysicsListSvc.h.

67{this, "EMNumberOfBinsPerDecade", -1, "Number of bins per Energy decade. Used for both DeDx and for the Lambda binning."};

◆ m_fastSimulationConstructor

ToolHandle<IPhysicsOptionTool> PhysicsListSvc::m_fastSimulationConstructor {this, "FastSimConstructor", "", "Physics Constructor for fast simulation physics"}
private

Definition at line 50 of file PhysicsListSvc.h.

50{this, "FastSimConstructor", "", "Physics Constructor for fast simulation physics"};

◆ 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 58 of file PhysicsListSvc.h.

58{this, "GeneralCut", 0, "General cut"};

◆ m_multipleStepsInMSCTransport

Gaudi::Property<bool> PhysicsListSvc::m_multipleStepsInMSCTransport {this, "MultipleStepsInMSCTransport", false, "Allow multiple MSC+transportation steps in G4HepEm, including the G4HepEm configuration used by AdePT"}
private

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

Definition at line 69 of file PhysicsListSvc.h.

69{this, "MultipleStepsInMSCTransport", false, "Allow multiple MSC+transportation steps in G4HepEm, including the G4HepEm configuration used by AdePT"};

◆ 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 57 of file PhysicsListSvc.h.

57{this, "NeutronEnergyCut", 0, "Energy cut for neutron killer"};

◆ 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 56 of file PhysicsListSvc.h.

56{this, "NeutronTimeCut", 0, "Time cut for neutron killer"};

◆ m_phys_decay

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

Definition at line 53 of file PhysicsListSvc.h.

53{this, "PhysicsDecay", {}, "Tool handle array of physics decays"};

◆ m_phys_option

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

Definition at line 52 of file PhysicsListSvc.h.

52{this, "PhysOption", {}, "Tool handle array of physics options" };

◆ m_physicsList

G4VModularPhysicsList* PhysicsListSvc::m_physicsList {}
private

Definition at line 54 of file PhysicsListSvc.h.

54{};

◆ 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 55 of file PhysicsListSvc.h.

55{this, "PhysicsList", "FTFP_BERT", "Name for physics list"};

◆ m_quietMode

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

Definition at line 70 of file PhysicsListSvc.h.

70{this, "QuietMode", false, ""};

◆ 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 71 of file PhysicsListSvc.h.

71{this, "UnstableAntiNeutrons",false,"Bugfix for ATLASSIM-6634 until we switch to using Geant4 11"};

The documentation for this class was generated from the following files: