From d3b2b0f8b4bf6827a353090a5d71b58e37cf233d Mon Sep 17 00:00:00 2001 From: Joerg Stelzer <joerg.stelzer@cern.ch> Date: Wed, 2 Sep 2020 14:06:47 +0200 Subject: [PATCH] Fix HLT prescaling when run on preloaded data with HLTEventLoopMgr forcedSORTime --- .../TrigSteer/L1Decoder/src/PrescalingTool.cxx | 15 ++++++++++++++- Trigger/TrigSteer/L1Decoder/src/PrescalingTool.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx index 1666340c73bf..458ba6cb56d7 100644 --- a/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx +++ b/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx @@ -6,6 +6,7 @@ #include "GaudiKernel/IToolSvc.h" #include "CLHEP/Random/RandomEngine.h" #include "CLHEP/Random/Ranlux64Engine.h" +#include "xAODEventInfo/EventInfo.h" const std::function< CLHEP::HepRandomEngine*(void) > PSTRanluxFactory = [](void)->CLHEP::HepRandomEngine*{ return new CLHEP::Ranlux64Engine(); @@ -25,6 +26,8 @@ StatusCode PrescalingTool::initialize() { ATH_CHECK(m_hltPrescaleSetInputKey.initialize( ! m_hltPrescaleSetInputKey.key().empty() )); + ATH_CHECK( m_eventInfoKey.initialize() ); + if ( !m_monTool.empty() ) ATH_CHECK(m_monTool.retrieve()); return StatusCode::SUCCESS; @@ -68,7 +71,17 @@ StatusCode PrescalingTool::prescaleChains( const EventContext& ctx, remainActive.reserve( initiallyActive.size() ); // create the seed from the event time - size_t seed = ctx.eventID().time_stamp() ^ ctx.eventID().time_stamp_ns_offset(); + /** + Note: the event time needs to be taken from the EventInfo instead EventContext.eventID, which is commonly done! + This is due to the special case when the trigger is run in a partition with preloaded data and the parameter @c + HLTEventLoopMgr.forceStartOfRunTime is set >0. In that case the @c EventContext.EventID is forced to the be the + SOR time for each event. Using the @c EventContext.eventID would lead to a constant seed and a scewed prescaling. + */ + auto eventInfoHandle = SG::makeHandle( m_eventInfoKey, ctx ); + CHECK( eventInfoHandle.isValid() ); + size_t seed = eventInfoHandle->timeStamp() ^ eventInfoHandle->timeStampNSOffset(); + + CLHEP::HepRandomEngine* engine = m_RNGEngines.getEngine( ctx ); engine->setSeed( seed, 0 ); diff --git a/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.h b/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.h index 313d3763a7d3..a7f57c120450 100644 --- a/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.h +++ b/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.h @@ -59,6 +59,7 @@ class PrescalingTool : public extends<AthAlgTool, IPrescalingTool> { // input data SG::ReadCondHandleKey<TrigConf::HLTPrescalesSet> m_hltPrescaleSetInputKey{ this, "HLTPrescales", "HLTPrescales", "HLT prescales set"}; + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{ this, "EventInfo", "EventInfo", "Event Info Object Key"}; // properties Gaudi::Property<bool> m_keepUnknownChains{ this, "KeepUnknownChains", true, "If True then chains for which prescaling information is not set are kept" }; -- GitLab