diff --git a/Control/CalypsoExample/TruthEventDumper/CMakeLists.txt b/Control/CalypsoExample/TruthEventDumper/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ceea9c78f5a8d088b1d17d9f3c6af2d325758f9c --- /dev/null +++ b/Control/CalypsoExample/TruthEventDumper/CMakeLists.txt @@ -0,0 +1,11 @@ +################################################################################ +# Package: TruthEventDumper +################################################################################ + +# Declare the package name: +atlas_subdir( TruthEventDumper ) + +# Install files from the package: +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} ) + +atlas_install_joboptions( share/*.py ) \ No newline at end of file diff --git a/Control/CalypsoExample/TruthEventDumper/python/TruthEventDumperAlg.py b/Control/CalypsoExample/TruthEventDumper/python/TruthEventDumperAlg.py new file mode 100644 index 0000000000000000000000000000000000000000..934433e2f375d6f0883a5a66e66dba70f1515427 --- /dev/null +++ b/Control/CalypsoExample/TruthEventDumper/python/TruthEventDumperAlg.py @@ -0,0 +1,39 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + +import AthenaPython.PyAthena as PyAthena +from AthenaPython.PyAthena import StatusCode, McEventCollection, HepMC, CLHEP +import McParticleEvent.Pythonizations + +__author__ = "Dave Caser <dcasper@uci.edu>" + +class TruthEventDumperAlg(PyAthena.Alg): + def __init__(self, name="TruthEventDumper", MCEventKey="TruthEvent"): + super(TruthEventDumperAlg,self).__init__(name=name) + self.MCEventKey = MCEventKey + return + + def initialize(self): + # self.maxLow = 0 + # self.maxMid = 0 + # self.maxHi = 0 + return StatusCode.Success + + + def execute(self): + evtCollection = self.evtStore[self.MCEventKey] + for mcEvt in evtCollection: + mcEvt.print() + # for mcParticle in mcEvt.particles: + # barCode = mcParticle.barcode() + # self.maxLow = max(self.maxLow, barCode%200000) + # if barCode%1000000 > 200000: + # self.maxMid = max(self.maxMid, barCode%1000000 - 200000) + # self.maxHi = max(self.maxHi, barCode//1000000) + return StatusCode.Success + + def finalize(self): + # print("Low part: ", self.maxLow, " out of 200000 (",100*self.maxLow/200000,"% of overflow)") + # print("Mid part: ", self.maxMid, " out of ", 1000000 - 200000, " (",100*self.maxMid/(1000000-200000),"% of overflow") + # print("Hi part: ", self.maxHi, " out of ", (1<<31)//1000000, " (", 100*self.maxHi/((1<<31)//1000000),"% of overflow") + + return StatusCode.Success \ No newline at end of file diff --git a/Control/CalypsoExample/TruthEventDumper/python/__init__.py b/Control/CalypsoExample/TruthEventDumper/python/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d13ae164caa4e93bf2899cea4e67d0ec515784a2 --- /dev/null +++ b/Control/CalypsoExample/TruthEventDumper/python/__init__.py @@ -0,0 +1 @@ +# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration diff --git a/Control/CalypsoExample/TruthEventDumper/share/TruthEventDumper_jobOptions.py b/Control/CalypsoExample/TruthEventDumper/share/TruthEventDumper_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..303f4b8d26db18b0cf96f30e500548ecc1a84208 --- /dev/null +++ b/Control/CalypsoExample/TruthEventDumper/share/TruthEventDumper_jobOptions.py @@ -0,0 +1,41 @@ +# +# Usage: athena.py -c'INPUT=["faser.1.gfaser.root","faser.2.gfaser.root"]; COLLECTION="TruthEvent"; MAXEVT=-1; SKIPEVT=0' TruthEventDumper/TruthEventDumper_jobOptions.py >& TruthEventDumper.log +# +# INPUT is mandatory (INPUT can be a list, as shown above) +# COLLECTION would normally be either "TruthEvent" (Geant4 particles) or "BeamTruthEvent" (generator particles) +# MAXEVT and SKIPEVT are self-explanatory and optional +# + +if not 'INPUT' in dir(): + print("Missing INPUT parameter") + exit() + +if not 'MAXEVT' in dir(): + MAXEVT = -1 + +if not 'SKIPEVT' in dir(): + SKIPEVT = 0 + +if not 'COLLECTION' in dir(): + COLLECTION = "TruthEvent" + +if not isinstance(INPUT, (list,tuple)): + INPUT = [INPUT] + pass + +from AthenaCommon.GlobalFlags import globalflags + +globalflags.InputFormat.set_Value_and_Lock('pool') + +import AthenaPoolCnvSvc.ReadAthenaPool + +svcMgr.EventSelector.InputCollections = INPUT + +from TruthEventDumper.TruthEventDumperAlg import TruthEventDumperAlg + +from AthenaCommon.AlgSequence import AlgSequence +job = AlgSequence() +job += TruthEventDumperAlg(MCEventKey=COLLECTION) + +theApp.EvtMax = MAXEVT +theApp.SkipEvents = SKIPEVT diff --git a/Generators/FaserParticleGun/python/FaserParticleGunConfig.py b/Generators/FaserParticleGun/python/FaserParticleGunConfig.py index c303469f197e714cc383a98f85f84452c0f31847..28bb6147a3276b510f3b4c3de83ad281a2997af4 100644 --- a/Generators/FaserParticleGun/python/FaserParticleGunConfig.py +++ b/Generators/FaserParticleGun/python/FaserParticleGunConfig.py @@ -38,6 +38,7 @@ def FaserParticleGunSingleParticleCfg(ConfigFlags, **kwargs) : pg = cfg.getPrimary() + pg.sampler.n = kwargs.setdefault("n", 1) pg.sampler.pid = kwargs.setdefault("pid", -13) pg.sampler.mom = PG.EThetaMPhiSampler(energy = kwargs.setdefault("energy", 1*TeV), theta = kwargs.setdefault("theta", [0, pi/20]),