Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDG4: add possibility to control verbosity for physics constructors #1352

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DDG4/include/DDG4/Geant4PhysicsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ namespace dd4hep {
std::string m_extends;
/// global range cut for secondary productions
double m_rangecut;
/// verbosity level for the physics list
int m_verbosity = 1;

public:
/// Standard constructor
Expand Down
1 change: 1 addition & 0 deletions DDG4/python/DDSim/DD4hepSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ def run(self):
# =================================================================================
# Now build the physics list:
_phys = self.physics.setupPhysics(kernel, name=self.physicsList)
_phys.verbosity = self.output.physics

# add the G4StepLimiterPhysics to activate the max step limits in volumes
ph = DDG4.PhysicsList(kernel, 'Geant4PhysicsList/Myphysics')
Expand Down
12 changes: 12 additions & 0 deletions DDG4/python/DDSim/Helper/Output.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def __init__(self):

self._geometry_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
self._geometry = outputLevel('DEBUG')

self._physics_EXTRA = {'choices': (0, 1, 2), 'type': outputLevelType}
self._physics = outputLevel(1)
self._closeProperties()

@property
Expand Down Expand Up @@ -98,3 +101,12 @@ def geometry(self):
@geometry.setter
def geometry(self, level):
self._geometry = outputLevel(level)

@property
def physics(self):
"""Output level for physics and physics constructors: 0 (silent), 1, 2"""
return self._physics

@physics.setter
def physics(self, level):
self._physics = int(level)
10 changes: 10 additions & 0 deletions DDG4/src/Geant4PhysicsList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <G4RunManager.hh>
#include <G4VProcess.hh>
#include <G4Decay.hh>
#include <G4EmParameters.hh>
#include <G4HadronicParameters.hh>

// C/C++ include files
#include <stdexcept>
Expand Down Expand Up @@ -319,6 +321,7 @@ Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence(Geant4Context*
declareProperty("extends", m_extends);
declareProperty("decays", m_decays);
declareProperty("rangecut", m_rangecut);
declareProperty("verbosity", m_verbosity);
m_needsControl = true;
InstanceCount::increment(this);
}
Expand Down Expand Up @@ -362,6 +365,12 @@ G4VUserPhysicsList* Geant4PhysicsListActionSequence::extensionList() {
// Ownership is transferred to the physics list.
// Do not delete this pointer afterwards....
physics->RegisterPhysics(new ParticlePhysics(this,physics));

//Setting verbosity for pieces of the physics
physics->SetVerboseLevel(m_verbosity);
G4EmParameters::Instance()->SetVerbose(m_verbosity);
G4HadronicParameters::Instance()->SetVerboseLevel(m_verbosity);

return physics;
}

Expand All @@ -377,6 +386,7 @@ void Geant4PhysicsListActionSequence::dump() {
printout(ALWAYS,name(),"+++ Transportation flag: %d",m_transportation);
printout(ALWAYS,name(),"+++ Program decays: %d",m_decays);
printout(ALWAYS,name(),"+++ RangeCut: %f",m_rangecut);
printout(ALWAYS,name(),"+++ Verbosity: %i",m_verbosity);
m_actors(&Geant4PhysicsList::dump);
}

Expand Down
Loading