From 782dd4abadec0b446d4b49da30da4d4b1e481b1c Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 4 Apr 2017 10:48:19 +0200 Subject: [PATCH] add enableDetailedHitsAndParticleInfo to ParticleHandler - to activate run ddsim with: --part.enableDetailedHitsAndParticleInfo --- DDSim/DD4hepSimulation.py | 23 +++-------------------- DDSim/Helper/ParticleHandler.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/DDSim/DD4hepSimulation.py b/DDSim/DD4hepSimulation.py index 461886d9d..542f385dd 100644 --- a/DDSim/DD4hepSimulation.py +++ b/DDSim/DD4hepSimulation.py @@ -76,7 +76,6 @@ class DD4hepSimulation(object): self._errorMessages = [] self._dumpParameter = False self._dumpSteeringFile = False - self.enableDetailedHitsAndParticleInfo = False ## objects for extended configuration option self.output = Output() @@ -397,25 +396,9 @@ class DD4hepSimulation(object): part.enableUI() - if self.enableDetailedHitsAndParticleInfo: - #---- debug code from Markus for detailed dumps of hits and MC-truth assignement ------ - # Add the particle dumper to associate the MC truth - evt = DDG4.EventAction(kernel,"Geant4ParticleDumpAction/ParticleDump") - kernel.eventAction().adopt(evt) - evt.enableUI() - # Add the hit dumper BEFORE any hit truth is fixed - evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/RawDump") - kernel.eventAction().adopt(evt) - evt.enableUI() - # Add the hit dumper to the event action sequence - evt = DDG4.EventAction(kernel,"Geant4HitTruthHandler/HitTruth") - kernel.eventAction().adopt(evt) - evt.enableUI() - # Add the hit dumper AFTER any hit truth is fixed. We should see the reduced track references - evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/HitDump") - kernel.eventAction().adopt(evt) - evt.enableUI() - + if self.part.enableDetailedHitsAndParticleInfo: + self.part.setDumpDetailedParticleInfo( kernel, DDG4 ) + #---------------------------------- diff --git a/DDSim/Helper/ParticleHandler.py b/DDSim/Helper/ParticleHandler.py index 9b91c0521..bd3c72946 100644 --- a/DDSim/Helper/ParticleHandler.py +++ b/DDSim/Helper/ParticleHandler.py @@ -13,6 +13,18 @@ class ParticleHandler( ConfigHelper ): self._printEndTracking = False self._printStartTracking = False self._minDistToParentVertex = 2.2e-14*mm + self._enableDetailedHitsAndParticleInfo = False + self._enableDetailedHitsAndParticleInfo_HELP = "print out lots of info about MCHistory" + + @property + def enableDetailedHitsAndParticleInfo(self): + """Enamble lots of printout on simulated hits and MC-truth inforamation""" + return self._enableDetailedHitsAndParticleInfo + + @enableDetailedHitsAndParticleInfo.setter + def enableDetailedHitsAndParticleInfo( self, val ): + self._enableDetailedHitsAndParticleInfo = val + @property def minDistToParentVertex( self ): @@ -63,3 +75,22 @@ class ParticleHandler( ConfigHelper ): @printEndTracking.setter def printEndTracking( self, val ): self._printEndTracking = val + + def setDumpDetailedParticleInfo( self, kernel, DDG4 ): + #---- debug code from Markus for detailed dumps of hits and MC-truth assignement ------ + # Add the particle dumper to associate the MC truth + evt = DDG4.EventAction(kernel,"Geant4ParticleDumpAction/ParticleDump") + kernel.eventAction().adopt(evt) + evt.enableUI() + # Add the hit dumper BEFORE any hit truth is fixed + evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/RawDump") + kernel.eventAction().adopt(evt) + evt.enableUI() + # Add the hit dumper to the event action sequence + evt = DDG4.EventAction(kernel,"Geant4HitTruthHandler/HitTruth") + kernel.eventAction().adopt(evt) + evt.enableUI() + # Add the hit dumper AFTER any hit truth is fixed. We should see the reduced track references + evt = DDG4.EventAction(kernel,"Geant4HitDumpAction/HitDump") + kernel.eventAction().adopt(evt) + evt.enableUI() -- GitLab