From ad6d98b9571d031aa2a6d3f580b3d0b48e298506 Mon Sep 17 00:00:00 2001
From: schaffer <R.D.Schaffer@cern.ch>
Date: Sun, 2 Aug 2020 16:13:50 +0200
Subject: [PATCH] put back in logic for fillMetaData which has no incoming
 CondAttrListCollection which happens when no TagInfo is on the input. This is
 of course standard for the first job in a sequence

---
 Event/EventInfoMgt/src/TagInfoMgr.cxx | 69 +++++++++++++--------------
 Event/EventInfoMgt/src/TagInfoMgr.h   | 28 +++++------
 2 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/Event/EventInfoMgt/src/TagInfoMgr.cxx b/Event/EventInfoMgt/src/TagInfoMgr.cxx
index b8701500a35a..dc50fbc4fad9 100755
--- a/Event/EventInfoMgt/src/TagInfoMgr.cxx
+++ b/Event/EventInfoMgt/src/TagInfoMgr.cxx
@@ -48,15 +48,7 @@ long TagInfoMgr_StorageType = 0x50;
 // Constructor with parameters:
 TagInfoMgr::TagInfoMgr(const std::string &name, 
                        ISvcLocator *pSvcLocator) :
-        AthCnvSvc(name, pSvcLocator, TagInfoMgr_StorageType),    
-        m_storeGate("StoreGateSvc", name),
-        m_detStore("DetectorStore", name),
-        m_iovDbSvc("IOVDbSvc", name),
-        m_metaDataTool("IOVDbMetaDataTool"),
-        m_isFirstBeginRun(true),
-        m_conditionsRun(EventIDBase::UNDEFNUM),
-        m_newFileIncidentSeen(false),
-        m_lastIOVRange(IOVRange(IOVTime(),IOVTime()))
+    AthCnvSvc(name, pSvcLocator, TagInfoMgr_StorageType)
 {}
 
 TagInfoMgr::~TagInfoMgr() 
@@ -435,35 +427,42 @@ TagInfoMgr::fillMetaData   (const TagInfo* tagInfo, const CondAttrListCollection
     attrListColl->add(0, attrList);
     // Set IOV:
 
-    // set to the IOV of the incoming conditions
-    //  if run num is in previous IOV, set new IOV to be [runNum, lastStop)
-    IOVTime testTime(runNumber, 0);
-    IOVTime start = m_lastIOVRange.start();
-    IOVTime stop  = m_lastIOVRange.stop();
-    bool isFirstIOVCheck = false;
-    if (!start.isValid() || !stop.isValid()) {
-        // Start of job, set lastIOVRange to the incoming IOV
-        IOVRange minRange = tagInfoCond->minRange();
-        start = minRange.start();
-        stop  = minRange.stop();
+    if (tagInfoCond) {
+        // set to the IOV of the incoming conditions
+        //  if run num is in previous IOV, set new IOV to be [runNum, lastStop)
+        IOVTime testTime(runNumber, 0);
+        IOVTime start = m_lastIOVRange.start();
+        IOVTime stop  = m_lastIOVRange.stop();
+        bool isFirstIOVCheck = false;
+        if (!start.isValid() || !stop.isValid()) {
+            // Start of job, set lastIOVRange to the incoming IOV
+            IOVRange minRange = tagInfoCond->minRange();
+            start = minRange.start();
+            stop  = minRange.stop();
+            m_lastIOVRange = IOVRange(start, stop);
+            isFirstIOVCheck = true; // 
+        }
+        if (m_lastIOVRange.isInRange(testTime)) {
+            // set start to runNumber after the 
+            if (!isFirstIOVCheck) start = testTime; 
+            ATH_MSG_DEBUG( "fillMetaData: run number is in previous IOVRange: " << runNumber << " " << m_lastIOVRange);
+        }
+        else {
+            // Out of range
+            start = testTime;
+            stop  = IOVTime(runNumber + 1, 0);
+            ATH_MSG_DEBUG( "fillMetaData: run number is outside of previous IOVRange: " << runNumber << " " << m_lastIOVRange << ". Reset range to run number.");
+        }
+        attrListColl->addNewStart(start);
+        attrListColl->addNewStop (stop);
         m_lastIOVRange = IOVRange(start, stop);
-        isFirstIOVCheck = true; // 
-    }
-    if (m_lastIOVRange.isInRange(testTime)) {
-        // set start to runNumber after the 
-        if (!isFirstIOVCheck) start = testTime; 
-        ATH_MSG_DEBUG( "fillMetaData: run number is in previous IOVRange: " << runNumber << " " << m_lastIOVRange);
+        ATH_MSG_DEBUG( "fillMetaData: start, stop: " << start << " " << stop);
     }
     else {
-        // Out of range
-        start = testTime;
-        stop  = IOVTime(runNumber + 1, 0);
-        ATH_MSG_DEBUG( "fillMetaData: run number is outside of previous IOVRange: " << runNumber << " " << m_lastIOVRange << ". Reset range to run number.");
-    }
-    attrListColl->addNewStart(start);
-    attrListColl->addNewStop (stop);
-    m_lastIOVRange = IOVRange(start, stop);
-    ATH_MSG_DEBUG( "fillMetaData: start, stop: " << start << " " << stop);
+        // set to the IOV of this run to run+1
+        attrListColl->addNewStart(IOVTime(runNumber, 0));
+        attrListColl->addNewStop(IOVTime(runNumber + 1, 0));
+    }
     
     /// Register folder in the IOV Db MetaData
     if (StatusCode::SUCCESS != m_metaDataTool->registerFolder("/TagInfo")) {
diff --git a/Event/EventInfoMgt/src/TagInfoMgr.h b/Event/EventInfoMgt/src/TagInfoMgr.h
index 09a29d7c3125..32aab1c33327 100755
--- a/Event/EventInfoMgt/src/TagInfoMgr.h
+++ b/Event/EventInfoMgt/src/TagInfoMgr.h
@@ -28,17 +28,16 @@
 #include "GaudiKernel/IIncidentListener.h"
 #include "AthenaKernel/IAddressProvider.h"
 #include "AthenaKernel/IOVRange.h"
+#include "AthenaKernel/IIOVDbSvc.h"
 #include "GaudiKernel/MsgStream.h"
 #include "EventInfo/TagInfo.h"
+#include "IOVDbMetaDataTools/IIOVDbMetaDataTool.h"
 
 #include <map>
 
 //<<<<<< PUBLIC TYPES                                                   >>>>>>
 
 class StoreGateSvc;
-class TagInfo;
-class IIOVDbSvc;
-class IIOVDbMetaDataTool;
 class CondAttrListCollection;
 
 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
@@ -192,11 +191,11 @@ private:
 
     /// Flag to add override the tags from EventInfo from other
     /// sources 
-    Gaudi::Property<bool>   m_overrideEventInfoTags{this,"OverrideEventInfoTags",true,"Override tags yes/no"};
+    Gaudi::Property<bool>   m_overrideEventInfoTags { this, "OverrideEventInfoTags", true, "Override tags yes/no" };
 
     /// Extra tags/values pairs added in my jobOptions
     Gaudi::Property<std::map<std::string,std::string> >
-        m_extraTagValuePairs{this,"ExtraTagValuePairs",{},"key/value pairs to be added", "mapMergeNoReplace<T,T>"};
+        m_extraTagValuePairs { this, "ExtraTagValuePairs", {}, "key/value pairs to be added", "mapMergeNoReplace<T,T>" };
 
     /// Extra tags/values pairs added in via interface
     std::map<std::string,std::string> m_extraTagValuePairsViaInterface;
@@ -205,33 +204,30 @@ private:
     std::set<std::string>          m_tagsToBeRemoved;
 
     /// The StoreGate key for the TagInfo
-    Gaudi::Property<std::string>   m_tagInfoKey{this,"TagInfoKey","ProcessingTags","SG key for TagInfo"};
+    Gaudi::Property<std::string>   m_tagInfoKey{ this, "TagInfoKey", "ProcessingTags", "SG key for TagInfo" };
 
     std::string                    m_tagInfoKeyValue;
 
     /// The event store
-    ServiceHandle<StoreGateSvc>    m_storeGate;
+    ServiceHandle<StoreGateSvc>    m_storeGate { this, "StoreGateSvc", "StoreGateSvc" };
 
     /// The detector store
-    ServiceHandle<StoreGateSvc>    m_detStore;
+    ServiceHandle<StoreGateSvc>    m_detStore { this, "DetectorStore", "DetectorStore" };
 
     /// Access to IOVDbSvc interface - used to register callback
-    ServiceHandle<IIOVDbSvc>       m_iovDbSvc;
+    ServiceHandle<IIOVDbSvc>       m_iovDbSvc { this, "IOVDbSvc", "IOVDbSvc" };
 
     /// Access to iov meta data tool
-    ToolHandle<IIOVDbMetaDataTool> m_metaDataTool;
+    ToolHandle<IIOVDbMetaDataTool> m_metaDataTool { this, "IOVDbMetaDataTool", "IOVDbMetaDataTool" };
 
     /// Flag to identify the first BeginRun incident
-    bool                           m_isFirstBeginRun;
+    bool                           m_isFirstBeginRun { true };
 
     /// conditionsRun from the first BeginRun incident (HLT)
-    EventIDBase::number_type       m_conditionsRun;
-
-    /// Flag to identify a new file incident
-    bool                           m_newFileIncidentSeen;
+    EventIDBase::number_type       m_conditionsRun { EventIDBase::UNDEFNUM };
 
     /// IOVRange of last TagInfo added to the file meta data
-    IOVRange                       m_lastIOVRange;
+    IOVRange                       m_lastIOVRange { IOVRange(IOVTime(), IOVTime()) };
 
     /// Last TagInfo added to the detector store
     TagInfo                        m_lastTagInfo;
-- 
GitLab