From d0e3d65b89ef3f98b0f94a13defd22388b1417f6 Mon Sep 17 00:00:00 2001
From: scott snyder <scott.snyder@cern.ch>
Date: Mon, 28 Aug 2017 22:38:07 +0200
Subject: [PATCH] IOVSvc: Get conditionsRun from EventContext.

Changing to get conditionsRun from the EventContext rather than trying
to look it up in StoreGate.

Make this change in CondInputLoader.  Also, IOVSvcTool::handle needs
to pass the event context to signalBeginRun.
---
 Control/IOVSvc/src/CondInputLoader.cxx | 16 +++++++---------
 Control/IOVSvc/src/IOVSvcTool.cxx      |  4 +++-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Control/IOVSvc/src/CondInputLoader.cxx b/Control/IOVSvc/src/CondInputLoader.cxx
index 46ab639585d..2a818d560a8 100644
--- a/Control/IOVSvc/src/CondInputLoader.cxx
+++ b/Control/IOVSvc/src/CondInputLoader.cxx
@@ -244,15 +244,13 @@ CondInputLoader::execute()
   }
 
   // For a MC event, the run number we need to use to look up the conditions
-  // may be different from that of the event itself.  If we have
-  // a ConditionsRun attribute defined, use that to override
-  // the event number.
-  SG::ReadHandleKey<AthenaAttributeList> inputKey ("Input");
-  ATH_CHECK( inputKey.initialize() );
-  SG::ReadHandle<AthenaAttributeList> input (inputKey, getContext());
-  if (input.isValid()) {
-    if (input->exists ("ConditionsRun"))
-      now.set_run_number ((*input)["ConditionsRun"].data<unsigned int>());
+  // may be different from that of the event itself.  Override the run
+  // number with the conditions run number from the event context,
+  // if it is defined.
+  EventIDBase::number_type conditionsRun =
+    getContext().template getExtension<Atlas::ExtendedEventContext>()->conditionsRun();
+  if (conditionsRun != EventIDBase::UNDEFNUM) {
+    now.set_run_number (conditionsRun);
   }
 
   IOVTime t(now.run_number(), now.lumi_block(), now.time_stamp());
diff --git a/Control/IOVSvc/src/IOVSvcTool.cxx b/Control/IOVSvc/src/IOVSvcTool.cxx
index 865e0f1d5e0..7bc2b08938d 100644
--- a/Control/IOVSvc/src/IOVSvcTool.cxx
+++ b/Control/IOVSvc/src/IOVSvcTool.cxx
@@ -415,7 +415,9 @@ IOVSvcTool::handle(const Incident &inc) {
         m_log << MSG::DEBUG << "Unable to get the IOVDbSvc" << endmsg;
         return;
       }
-      if (StatusCode::SUCCESS != iovDB->signalBeginRun(m_curTime)) {
+      if (StatusCode::SUCCESS != iovDB->signalBeginRun(m_curTime,
+                                                       inc.context()))
+      {
         m_log << MSG::ERROR << "Unable to signal begin run to IOVDbSvc" << endmsg;
         return;
       }
-- 
GitLab