From 68546ffcee38d99761ecc197c781272b3885faeb Mon Sep 17 00:00:00 2001 From: Tadej Novak <tadej.novak@cern.ch> Date: Mon, 10 Dec 2018 14:19:38 +0100 Subject: [PATCH] Add support for custom pre-mixing output in MCTruthSimAlgs Former-commit-id: bd9924649110c4945ee77530baaacf1d6991503e --- Simulation/Digitization/python/DigiOutput.py | 4 ++-- .../python/MCTruthSimAlgsConfig.py | 15 ++++++++++++++- .../MCTruthSimAlgs/src/MergeMcEventCollTool.cxx | 17 +++++++++-------- .../MCTruthSimAlgs/src/MergeMcEventCollTool.h | 4 +++- .../src/MergeRecoTimingObjTool.cxx | 12 +++++++----- .../MCTruthSimAlgs/src/MergeRecoTimingObjTool.h | 3 ++- .../share/skeleton.HITtoRDO.py | 7 ++++++- .../digitization/postInclude.ReadFromEvgen.py | 5 ++--- 8 files changed, 45 insertions(+), 22 deletions(-) diff --git a/Simulation/Digitization/python/DigiOutput.py b/Simulation/Digitization/python/DigiOutput.py index 87c6dc6d3fe..0ccb6620743 100644 --- a/Simulation/Digitization/python/DigiOutput.py +++ b/Simulation/Digitization/python/DigiOutput.py @@ -206,8 +206,8 @@ def getStreamRDO_ItemList(log): if DetFlags.writeRDOPool.any_on(): ## TimingAlg - StreamRDO_ItemList +=["RecoTimingObj#EVNTtoHITS_timings"] - StreamRDO_ItemList +=["RecoTimingObj#HITStoRDO_timings"] + StreamRDO_ItemList +=["RecoTimingObj#*EVNTtoHITS_timings"] + StreamRDO_ItemList +=["RecoTimingObj#*HITStoRDO_timings"] if DetFlags.writeRDOPool.any_on(): # Pool Output diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/python/MCTruthSimAlgsConfig.py b/Simulation/G4Utilities/MCTruthSimAlgs/python/MCTruthSimAlgsConfig.py index 418193216c3..3a212e7483e 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/python/MCTruthSimAlgsConfig.py +++ b/Simulation/G4Utilities/MCTruthSimAlgs/python/MCTruthSimAlgsConfig.py @@ -6,7 +6,13 @@ from AthenaCommon import CfgMgr ############################################################################ def genericMergeMcEventCollTool(name="MergeMcEventCollTool", **kwargs): - kwargs.setdefault("TruthCollKey", "TruthEvent") + if 'OverlayMT' in digitizationFlags.experimentalDigi(): + from OverlayCommonAlgs.OverlayFlags import overlayFlags + kwargs.setdefault("TruthCollOutputKey", overlayFlags.bkgPrefix() + "TruthEvent") + else: + kwargs.setdefault("TruthCollOutputKey", "TruthEvent") + kwargs.setdefault("TruthCollInputKey", "TruthEvent") + kwargs.setdefault("LowTimeToKeep", -50.5) kwargs.setdefault("HighTimeToKeep", 50.5) kwargs.setdefault("KeepUnstable", False) @@ -197,6 +203,13 @@ def MergeRecoTimingObjTool(name="MergeRecoTimingObjTool", **kwargs): kwargs.setdefault("FirstXing", TimingObj_FirstXing() ) kwargs.setdefault("LastXing", TimingObj_LastXing() ) + kwargs.setdefault("RecoTimingObjInputKey", "EVNTtoHITS_timings") + if 'OverlayMT' in digitizationFlags.experimentalDigi(): + from OverlayCommonAlgs.OverlayFlags import overlayFlags + kwargs.setdefault("RecoTimingObjOutputKey", overlayFlags.bkgPrefix() + "EVNTtoHITS_timings") + else: + kwargs.setdefault("RecoTimingObjOutputKey", "EVNTtoHITS_timings") + return CfgMgr.MergeRecoTimingObjTool(name, **kwargs) diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx index 2f3150cfce8..88454c01922 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.cxx @@ -136,7 +136,8 @@ MergeMcEventCollTool::MergeMcEventCollTool(const std::string& type, m_addBackgroundCollisionVertices(true), m_signal_event_number(0) { - declareProperty("TruthCollKey", m_truthCollKey=std::string("TruthEvent")); + declareProperty("TruthCollInputKey", m_truthCollInputKey=std::string("TruthEvent")); + declareProperty("TruthCollOutputKey", m_truthCollOutputKey=std::string("TruthEvent")); declareProperty("KeepUnstable", m_keepUnstable=false, "do not cut unstable particles"); declareProperty("AbsEtaMax", m_absEtaMax=5.0); declareProperty("OutOfTimeAbsEtaMax", m_absEtaMax_outOfTime=3.0); @@ -188,7 +189,7 @@ StatusCode MergeMcEventCollTool::prepareEvent(unsigned int nInputEvents) { if (0 == m_nInputMcEventColls) { msg(MSG::ERROR) << "prepareEvent: TimedTruthList with key " - << m_truthCollKey.value() + << m_truthCollInputKey.value() << " is empty" << endmsg; return StatusCode::RECOVERABLE; } @@ -210,10 +211,10 @@ StatusCode MergeMcEventCollTool::processAllSubEvents() { //first get the list of McEventCollections typedef PileUpMergeSvc::TimedList<McEventCollection>::type TimedTruthList; TimedTruthList truthList; - if (!m_pMergeSvc->retrieveSubEvtsData(m_truthCollKey.value(), truthList).isSuccess() ) { + if (!m_pMergeSvc->retrieveSubEvtsData(m_truthCollInputKey.value(), truthList).isSuccess() ) { msg(MSG::ERROR) << "execute: Can not find TimedTruthList with key " - << m_truthCollKey.value() << endmsg; + << m_truthCollInputKey.value() << endmsg; return StatusCode::RECOVERABLE; } @@ -225,7 +226,7 @@ StatusCode MergeMcEventCollTool::processAllSubEvents() { if (0 == m_nInputMcEventColls) { msg(MSG::ERROR) << "execute: TimedTruthList with key " - << m_truthCollKey.value() + << m_truthCollInputKey.value() << " is empty" << endmsg; return StatusCode::RECOVERABLE; } @@ -281,9 +282,9 @@ StatusCode MergeMcEventCollTool::processBunchXing(int bunchXing, //loop over the McEventCollections (each one assumed to containing exactly one GenEvent) of the various input events while (iEvt != eSubEvents) { const McEventCollection *pMEC(NULL); - if (!m_pMergeSvc->retrieveSingleSubEvtData(m_truthCollKey.value(), pMEC, + if (!m_pMergeSvc->retrieveSingleSubEvtData(m_truthCollInputKey.value(), pMEC, bunchXing, iEvt).isSuccess()){ - ATH_MSG_ERROR("McEventCollection not found for event key " << m_truthCollKey.value()); + ATH_MSG_ERROR("McEventCollection not found for event key " << m_truthCollInputKey.value()); return StatusCode::FAILURE; } @@ -396,7 +397,7 @@ StatusCode MergeMcEventCollTool::processFirstSubEvent(const McEventCollection *p } m_startingIndexForBackground=currentMcEventCollectionIndex; m_nBkgEventsReadSoFar=0; //number of input events/eventcolls read so far. Used to build index of output GenEvent in ovrl McEvColl - sc = evtStore()->record(m_pOvrlMcEvColl, m_truthCollKey);//**BIG TEST**//sc=StatusCode::SUCCESS; + sc = evtStore()->record(m_pOvrlMcEvColl, m_truthCollOutputKey);//**BIG TEST**//sc=StatusCode::SUCCESS; ATH_MSG_DEBUG( "Starting loop on Background events ... " ); return sc; diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h index c919cb63046..feb2f44dd40 100755 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeMcEventCollTool.h @@ -72,7 +72,9 @@ private: //** New McEventCollection to be written out to file McEventCollection* m_pOvrlMcEvColl; //** Name of input McEventCollection - StringProperty m_truthCollKey; + StringProperty m_truthCollInputKey; + //** Name of output McEventCollection + StringProperty m_truthCollOutputKey; //** Should unstable particles should be kept? BooleanProperty m_keepUnstable; //** Eta cut-off for INTIME GenParticles diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx index 70781b11eff..4c14335f21f 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.cxx @@ -14,10 +14,12 @@ MergeRecoTimingObjTool::MergeRecoTimingObjTool(const std::string& type, const IInterface* parent) : PileUpToolBase(type, name, parent), m_pMergeSvc("PileUpMergeSvc", name), - m_recTimingObjKey("EVNTtoHITS_timings"), + m_recTimingObjInputKey("EVNTtoHITS_timings"), + m_recTimingObjOutputKey("EVNTtoHITS_timings"), m_firstSubEvent(true) { - declareProperty("RecoTimingObjKey", m_recTimingObjKey);//=std::string("EVNTtoHITS_timings")); + declareProperty("RecoTimingObjInputKey", m_recTimingObjInputKey); + declareProperty("RecoTimingObjOutputKey", m_recTimingObjOutputKey); } StatusCode MergeRecoTimingObjTool::prepareEvent(unsigned int nInputEvents) @@ -38,7 +40,7 @@ StatusCode MergeRecoTimingObjTool::processBunchXing(int bunchXing, if (bSubEvents != eSubEvents) { const RecoTimingObj *oldColl(0); - if (m_pMergeSvc->retrieveSingleSubEvtData(m_recTimingObjKey.value(), oldColl, + if (m_pMergeSvc->retrieveSingleSubEvtData(m_recTimingObjInputKey.value(), oldColl, bunchXing, bSubEvents).isSuccess()) { CHECK(processRecoTimingObj(oldColl)); @@ -79,7 +81,7 @@ StatusCode MergeRecoTimingObjTool::processAllSubEvents() } const RecoTimingObj *oldColl(NULL); - if( !m_pMergeSvc->retrieveOriginal(m_recTimingObjKey.value(), oldColl).isSuccess() || !oldColl) + if( !m_pMergeSvc->retrieveOriginal(m_recTimingObjInputKey.value(), oldColl).isSuccess() || !oldColl) { ATH_MSG_DEBUG ( "processAllSubEventss: Cannot find RecoTimingObj in input HITS file" ); return StatusCode::SUCCESS; @@ -91,7 +93,7 @@ StatusCode MergeRecoTimingObjTool::processAllSubEvents() StatusCode MergeRecoTimingObjTool::processRecoTimingObj(const RecoTimingObj* inputObj) { RecoTimingObj *outputRecoTimingObj = new RecoTimingObj(*inputObj); //CHECK copy constructor is OK!! - CHECK(evtStore()->record(outputRecoTimingObj, m_recTimingObjKey.value())); + CHECK(evtStore()->record(outputRecoTimingObj, m_recTimingObjOutputKey.value())); ATH_MSG_DEBUG( "processRecoTimingObj: copied original event RecoTimingObj" ); return StatusCode::SUCCESS; } diff --git a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h index 5b8172f69f6..d4d4671c9eb 100644 --- a/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h +++ b/Simulation/G4Utilities/MCTruthSimAlgs/src/MergeRecoTimingObjTool.h @@ -46,7 +46,8 @@ private: /// share code between two approaches virtual StatusCode processRecoTimingObj(const RecoTimingObj *inputObj); ServiceHandle<PileUpMergeSvc> m_pMergeSvc; - StringProperty m_recTimingObjKey; + StringProperty m_recTimingObjInputKey; + StringProperty m_recTimingObjOutputKey; bool m_firstSubEvent; }; #endif diff --git a/Simulation/SimuJobTransforms/share/skeleton.HITtoRDO.py b/Simulation/SimuJobTransforms/share/skeleton.HITtoRDO.py index d9818a640a8..e284c647663 100644 --- a/Simulation/SimuJobTransforms/share/skeleton.HITtoRDO.py +++ b/Simulation/SimuJobTransforms/share/skeleton.HITtoRDO.py @@ -401,8 +401,13 @@ topSeq = AlgSequence() topSeq.TimeOut = 43200 * Units.s try: + timingOutput = "HITStoRDO_timings" + if 'OverlayMT' in digitizationFlags.experimentalDigi(): + from OverlayCommonAlgs.OverlayFlags import overlayFlags + timingOutput = overlayFlags.bkgPrefix() + timingOutput + from RecAlgs.RecAlgsConf import TimingAlg - topSeq+=TimingAlg("DigiTimerBegin", TimingObjOutputName = "HITStoRDO_timings") + topSeq += TimingAlg("DigiTimerBegin", TimingObjOutputName = timingOutput) except: digilog.warning('Could not add TimingAlg, no timing info will be written out.') diff --git a/Simulation/SimulationJobOptions/share/digitization/postInclude.ReadFromEvgen.py b/Simulation/SimulationJobOptions/share/digitization/postInclude.ReadFromEvgen.py index d3a7f442742..171a91be2d0 100644 --- a/Simulation/SimulationJobOptions/share/digitization/postInclude.ReadFromEvgen.py +++ b/Simulation/SimulationJobOptions/share/digitization/postInclude.ReadFromEvgen.py @@ -35,7 +35,8 @@ PileUpEventLoopMgr.bkgCaches += [ minBiasCache ] MergeMcEventCollection = Algorithm( "MergeMcEventCollection" ) if hasattr(MergeMcEventCollection, 'MergeMcEventCollTool'): - MergeMcEventCollection.MergeMcEventCollTool.TruthCollKey = "GEN_EVENT" + MergeMcEventCollection.MergeMcEventCollTool.TruthCollInputKey = "GEN_EVENT" + MergeMcEventCollection.MergeMcEventCollTool.TruthCollOutputKey = "GEN_EVENT" else: MergeMcEventCollection.TruthCollKey = "GEN_EVENT" @@ -52,5 +53,3 @@ print 'ZLM container thingy:',itemlist itemlist += [ "IOVMetaDataContainer#_Digitization_Parameters" ] print StreamRDO.MetaDataItemList - - -- GitLab