diff --git a/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx b/Trigger/TrigSteer/L1Decoder/src/PrescalingTool.cxx index 1666340c73bf6184f79585d8571fa7aaeb530277..458ba6cb56d746418bfbe21591063ed662acc00b 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 313d3763a7d352f91c61a5c69a2f187d3680a088..a7f57c120450ab9b98992dc79236e7397c2c34e4 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" };