Skip to content

Commit 7dd4f9e

Browse files
committed
DDG4: add possibility to control verbosity for physics constructors
1 parent 6c04cd7 commit 7dd4f9e

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

DDG4/include/DDG4/Geant4PhysicsList.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ namespace dd4hep {
244244
std::string m_extends;
245245
/// global range cut for secondary productions
246246
double m_rangecut;
247+
/// verbosity level for the physics list
248+
int m_verbosity = 1;
247249

248250
public:
249251
/// Standard constructor

DDG4/python/DDSim/DD4hepSimulation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ def run(self):
506506
# =================================================================================
507507
# Now build the physics list:
508508
_phys = self.physics.setupPhysics(kernel, name=self.physicsList)
509+
_phys.verbosity = self.output.physics
509510

510511
# add the G4StepLimiterPhysics to activate the max step limits in volumes
511512
ph = DDG4.PhysicsList(kernel, 'Geant4PhysicsList/Myphysics')

DDG4/python/DDSim/Helper/Output.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def __init__(self):
5252

5353
self._geometry_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
5454
self._geometry = outputLevel('DEBUG')
55+
56+
self._physics_EXTRA = {'choices': (0, 1, 2), 'type': outputLevelType}
57+
self._physics = outputLevel(1)
5558
self._closeProperties()
5659

5760
@property
@@ -98,3 +101,12 @@ def geometry(self):
98101
@geometry.setter
99102
def geometry(self, level):
100103
self._geometry = outputLevel(level)
104+
105+
@property
106+
def physics(self):
107+
"""Output level for physics and physics constructors: 0 (silent), 1, 2"""
108+
return self._physics
109+
110+
@physics.setter
111+
def physics(self, level):
112+
self._physics = int(level)

DDG4/src/Geant4PhysicsList.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <G4RunManager.hh>
2929
#include <G4VProcess.hh>
3030
#include <G4Decay.hh>
31+
#include <G4EmParameters.hh>
32+
#include <G4HadronicParameters.hh>
3133

3234
// C/C++ include files
3335
#include <stdexcept>
@@ -319,6 +321,7 @@ Geant4PhysicsListActionSequence::Geant4PhysicsListActionSequence(Geant4Context*
319321
declareProperty("extends", m_extends);
320322
declareProperty("decays", m_decays);
321323
declareProperty("rangecut", m_rangecut);
324+
declareProperty("verbosity", m_verbosity);
322325
m_needsControl = true;
323326
InstanceCount::increment(this);
324327
}
@@ -362,6 +365,12 @@ G4VUserPhysicsList* Geant4PhysicsListActionSequence::extensionList() {
362365
// Ownership is transferred to the physics list.
363366
// Do not delete this pointer afterwards....
364367
physics->RegisterPhysics(new ParticlePhysics(this,physics));
368+
369+
//Setting verbosity for pieces of the physics
370+
physics->SetVerboseLevel(m_verbosity);
371+
G4EmParameters::Instance()->SetVerbose(m_verbosity);
372+
G4HadronicParameters::Instance()->SetVerboseLevel(m_verbosity);
373+
365374
return physics;
366375
}
367376

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

0 commit comments

Comments
 (0)