From 431fd5cec4cedfee1ba68def75a8067a15b1a74b Mon Sep 17 00:00:00 2001
From: cranshaw <Jack.Cranshaw@cern.ch>
Date: Tue, 14 Aug 2018 11:22:05 -0500
Subject: [PATCH] Migrate BookkeeperTool to use GenericMetadataTool base class.

Former-commit-id: 73e606ad1de063bebcb710eefba2d8d076d3ef90
---
 .../AthenaKernel/GenericMetadataTool.h        |  69 ++--
 .../EventBookkeeperTools/BookkeeperTool.h     |  71 +---
 .../Root/BookkeeperTool.cxx                   | 372 +-----------------
 3 files changed, 41 insertions(+), 471 deletions(-)

diff --git a/Control/AthenaKernel/AthenaKernel/GenericMetadataTool.h b/Control/AthenaKernel/AthenaKernel/GenericMetadataTool.h
index 4acf9858e75..4148725bfd2 100644
--- a/Control/AthenaKernel/AthenaKernel/GenericMetadataTool.h
+++ b/Control/AthenaKernel/AthenaKernel/GenericMetadataTool.h
@@ -7,25 +7,19 @@
 
 /** @file GenericMetadataTool.h
  *  @brief This file contains the class definition for the GenericMetadataTool class.
- *  @author Peter van Gemmeren <gemmeren@anl.gov>
- *  $Id: GenericMetadataTool.h 663679 2015-04-29 08:31:54Z krasznaa $
+ *  @author Jack Cranshaw <cranshaw@anl.gov>
+ *  $Id: $
  **/
 
 #include "AthenaBaseComps/AthAlgTool.h"
-//#include "AsgTools/AsgMetadataTool.h"
 #include "AthenaKernel/IMetaDataTool.h"
 #include "GaudiKernel/IIncidentListener.h"
 #include "GaudiKernel/ServiceHandle.h"
-//#include "AthenaKernel/ICutFlowSvc.h"
-
-//#include "xAODCutFlow/CutBookkeeper.h"
-//#include "xAODCutFlow/CutBookkeeperContainer.h"
-//#include "xAODCutFlow/CutBookkeeperAuxContainer.h"
 
 #include <string>
 
 /** @class GenericMetadataTool
- *  @brief This class provides an example for reading with a ISelectorTool to veto events on AttributeList.
+ *  @brief This class provides the basic functionality for processing metadata in the athena framework. The derived class must simply implement merge functionality in the updateContainer method.
  **/
 
 template <typename T, typename U>
@@ -45,58 +39,55 @@ public:
    virtual StatusCode endInputFile(const SG::SourceID& sid = "Serial");
    virtual StatusCode initialize();
    virtual StatusCode finalize();
+
 protected:
    ServiceHandle<StoreGateSvc> inputMetaStore() const;
    ServiceHandle<StoreGateSvc> outputMetaStore() const;
 
-private:
-  
-  /// Helper class to update a container with information from another one
-  //StatusCode updateContainer( T* contToUpdate,
-  //                            const T* otherCont );
+   /// Helper class to update a container with information from another one
+   virtual StatusCode updateContainer( T* contToUpdate,
+                                 const T* otherCont ) = 0;
 
-  StatusCode initOutputContainer(const std::string& sgkey);
+   StatusCode initOutputContainer(const std::string& sgkey);
 
-  StatusCode buildAthenaInterface(const std::string& inputName,
-                                  const std::string& outputName,
-                                  const SG::SourceID& sid);
+   StatusCode buildAthenaInterface(const std::string& inputName,
+                                   const std::string& outputName,
+                                   const SG::SourceID& sid);
 
-  /// Fill Cutflow information
-  StatusCode addProcessMetadata();
+   /// Fill Cutflow information
+   StatusCode addProcessMetadata();
  
-  /// Pointer to cut flow svc 
-  ServiceHandle<StoreGateSvc> m_inputMetaStore;
-  ServiceHandle<StoreGateSvc> m_outputMetaStore;
-
-  /// The name of the output Container
-  std::string m_outputCollName;
-  
-  /// The name of the input Container
-  std::string  m_inputCollName;
+   /// Pointer to cut flow svc 
+   ServiceHandle<StoreGateSvc> m_inputMetaStore;
+   ServiceHandle<StoreGateSvc> m_outputMetaStore;
 
-  /// The name of the process Container
-  std::string m_procMetaName;
+   /// The name of the output Container
+   std::string m_outputCollName;
+   /// The name of the input Container
+   std::string  m_inputCollName;
+   /// The name of the process Container
+   std::string m_procMetaName;
 
-  bool m_processMetadataTaken;
-  bool m_markIncomplete;
+   bool m_processMetadataTaken;
+   bool m_markIncomplete;
 
-  /// List of source ids which have reached end file
-  std::set<SG::SourceID> m_fullreads;
-  std::set<SG::SourceID> m_read;
-  std::set<SG::SourceID> m_written;
+   /// List of source ids which have reached end file
+   std::set<SG::SourceID> m_fullreads;
+   std::set<SG::SourceID> m_read;
+   std::set<SG::SourceID> m_written;
 
 };
 
 template <typename T, typename U>
 inline ServiceHandle<StoreGateSvc> GenericMetadataTool<T,U>::inputMetaStore() const
 {
-  return m_inputMetaStore;
+   return m_inputMetaStore;
 }
 
 template <typename T, typename U>
 inline ServiceHandle<StoreGateSvc> GenericMetadataTool<T,U>::outputMetaStore() const
 {
-  return m_outputMetaStore;
+   return m_outputMetaStore;
 }
 
 #include "GenericMetadataTool.icc"
diff --git a/Event/EventBookkeeperTools/EventBookkeeperTools/BookkeeperTool.h b/Event/EventBookkeeperTools/EventBookkeeperTools/BookkeeperTool.h
index 6879e02f069..ebb5a272d71 100644
--- a/Event/EventBookkeeperTools/EventBookkeeperTools/BookkeeperTool.h
+++ b/Event/EventBookkeeperTools/EventBookkeeperTools/BookkeeperTool.h
@@ -7,16 +7,11 @@
 
 /** @file BookkeeperTool.h
  *  @brief This file contains the class definition for the BookkeeperTool class.
- *  @author Peter van Gemmeren <gemmeren@anl.gov>
- *  $Id: BookkeeperTool.h 663679 2015-04-29 08:31:54Z krasznaa $
+ *  @author Jack Cranshaw <cranshaw@anl.gov>
+ *  $Id: $
  **/
 
-#include "AthenaBaseComps/AthAlgTool.h"
-#include "AsgTools/AsgMetadataTool.h"
-#include "AthenaKernel/IMetaDataTool.h"
-#include "GaudiKernel/IIncidentListener.h"
-#include "GaudiKernel/ServiceHandle.h"
-#include "AthenaKernel/ICutFlowSvc.h"
+#include "AthenaKernel/GenericMetadataTool.h"
 
 #include "xAODCutFlow/CutBookkeeper.h"
 #include "xAODCutFlow/CutBookkeeperContainer.h"
@@ -29,10 +24,10 @@
  **/
 
 
-class BookkeeperTool : public AthAlgTool, public virtual ::IMetaDataTool
+class BookkeeperTool : public GenericMetadataTool <xAOD::CutBookkeeperContainer, xAOD::CutBookkeeperAuxContainer> 
 {
-   //ASG_TOOL_CLASS0(BookkeeperTool)
-public: // Constructor and Destructor
+public: 
+   // Constructor and Destructor
    /// Standard Service Constructor
    BookkeeperTool(const std::string& type, 
                   const std::string& name,
@@ -40,63 +35,13 @@ public: // Constructor and Destructor
    /// Destructor
    virtual ~BookkeeperTool();
 
-public:
-   virtual StatusCode metaDataStop(const SG::SourceID&);
-   virtual StatusCode beginInputFile(const SG::SourceID& sid = "Serial");
-   virtual StatusCode endInputFile(const SG::SourceID& sid = "Serial");
-   virtual StatusCode initialize();
-   virtual StatusCode finalize();
-protected:
-   ServiceHandle<StoreGateSvc> inputMetaStore() const;
-   ServiceHandle<StoreGateSvc> outputMetaStore() const;
-
 private:
   
   /// Helper class to update a container with information from another one
-  StatusCode updateContainer( xAOD::CutBookkeeperContainer* contToUpdate,
-                              const xAOD::CutBookkeeperContainer* otherCont );
-
-  StatusCode initOutputContainer(const std::string& sgkey);
-
-  StatusCode buildAthenaInterface(const std::string& inputName,
-                                  const std::string& outputName,
-                                  const SG::SourceID& sid);
-
-  /// Fill Cutflow information
-  StatusCode addCutFlow();
- 
-  /// Pointer to cut flow svc 
-  ServiceHandle<StoreGateSvc> m_inputMetaStore;
-  ServiceHandle<StoreGateSvc> m_outputMetaStore;
-
-  /// The name of the output CutBookkeeperContainer
-  std::string m_outputCollName;
-  
-  /// The name of the input CutBookkeeperContainer
-  std::string  m_inputCollName;
-
-  /// The name of the CutFlowSvc CutBookkeeperContainer
-  std::string m_cutflowCollName;
-
-  bool m_cutflowTaken;
-  bool m_markIncomplete;
-
-  /// List of source ids which have reached end file
-  std::set<SG::SourceID> m_fullreads;
-  std::set<SG::SourceID> m_read;
-  std::set<SG::SourceID> m_written;
+  virtual StatusCode updateContainer(xAOD::CutBookkeeperContainer* contToUpdate,
+                               const xAOD::CutBookkeeperContainer* otherCont );
 
 };
 
-inline ServiceHandle<StoreGateSvc> BookkeeperTool::inputMetaStore() const
-{
-  return m_inputMetaStore;
-}
-
-inline ServiceHandle<StoreGateSvc> BookkeeperTool::outputMetaStore() const
-{
-  return m_outputMetaStore;
-}
-
 #endif
 
diff --git a/Event/EventBookkeeperTools/Root/BookkeeperTool.cxx b/Event/EventBookkeeperTools/Root/BookkeeperTool.cxx
index c60cec16891..8bdabcef6f3 100644
--- a/Event/EventBookkeeperTools/Root/BookkeeperTool.cxx
+++ b/Event/EventBookkeeperTools/Root/BookkeeperTool.cxx
@@ -13,394 +13,28 @@
 // STL include
 #include <algorithm>
 
-// #include "FillEBCFromFlat.h"
-
-#ifdef ASGTOOL_ATHENA
-#include "GaudiKernel/Incident.h"
-#include "GaudiKernel/FileIncident.h"
-#include "GaudiKernel/IIncidentSvc.h"
 #include "AthenaKernel/MetaCont.h"
 #include "AthenaKernel/ClassID_traits.h"
 #include "AthenaKernel/errorcheck.h"
-#include "StoreGate/WriteMetaHandle.h"
+#include "AthenaKernel/GenericMetadataTool.h"
+#include "AthenaKernel/ICutFlowSvc.h"
 #include "AthenaBaseComps/AthCheckMacros.h"
 #include "AthContainersInterfaces/IConstAuxStoreMeta.h"
-#endif
 
 BookkeeperTool::BookkeeperTool(const std::string& type, 
                                const std::string& name,
                                const IInterface*  parent)
-  : AthAlgTool(type,name,parent),
-    m_inputMetaStore( "StoreGateSvc/InputMetaDataStore", name ),
-    m_outputMetaStore( "StoreGateSvc/MetaDataStore", name ),
-    m_cutflowTaken(false),
-    m_markIncomplete(true)
+  : GenericMetadataTool <xAOD::CutBookkeeperContainer, xAOD::CutBookkeeperAuxContainer>(type,name,parent)
 {
-  declareProperty("OutputCollName", m_outputCollName="CutBookkeepers",  
-    "The default name of the xAOD::CutBookkeeperContainer for output files");
-  declareProperty("InputCollName", m_inputCollName = "CutBookkeepers",
-    "The default name of the xAOD::CutBookkeeperContainer for input files");
-  declareProperty("CutFlowCollName", m_cutflowCollName = "CutBookkeepersFile",
-    "The default name of the xAOD::CutBookkeeperContainer for CutFlowSvc");
-  declareProperty("MarkIncomplete", m_markIncomplete = true, 
-    "Defaults to filling both complete and incomplete bookkeepers");
-#ifdef ASGTOOL_ATHENA
-  declareInterface< ::IMetaDataTool >( this );
-#endif // ASGTOOL_ATHENA
 }
 
-
-
 BookkeeperTool::~BookkeeperTool()
 {
 }
 
 
-
-StatusCode
-BookkeeperTool::initialize()
-{
-  ATH_MSG_DEBUG( "Initializing " << name() << " - package version " << PACKAGE_VERSION );
-
-  ATH_MSG_DEBUG("InputCollName = " << m_inputCollName);
-  ATH_MSG_DEBUG("OutputCollName = " << m_outputCollName);
-  ATH_MSG_DEBUG("CutFlowCollName = " << m_cutflowCollName);
-
-  return StatusCode::SUCCESS;
-}
-
-
-//__________________________________________________________________________
-/*
-StatusCode BookkeeperTool::beginInputFile()
-{
-  return this->beginInputFile("Serial");
-}
-*/
-
-#ifdef ASGTOOL_ATHENA
-StatusCode BookkeeperTool::beginInputFile(const SG::SourceID& sid)
-{
-  ATH_MSG_INFO("beginInputFile " << this->name() << "\n" << outputMetaStore()->dump());
-  //OPENING NEW INPUT FILE
-  //Things to do:
-  // 1) note that a file is currently opened
-  // 2) Load CutBookkeepers from input file
-  //    2a) if incomplete from input, directly propagate to output
-  //    2b) if complete from input, wait for EndInputFile to decide what to do in output
-
-  const std::string storename("MetaDataStore+");
-  if (m_inputCollName != "") {  // are there inputs
-    //  IF NO METACONT IN OUTPUT STORE YET
-    //     Initialize MetaCont for incomplete and tmp containers in output store
-    //
-    std::string tmp_name = storename+m_outputCollName+"tmp";
-    ATH_CHECK(buildAthenaInterface(m_inputCollName,tmp_name,sid));
-
-    // Do the following if we want incomplete processings marked
-    if (m_markIncomplete) {
-      std::string inc_name = storename+"Incomplete"+m_outputCollName; 
-      std::string input_inc_name = "Incomplete"+m_inputCollName;
-      ATH_CHECK(buildAthenaInterface(input_inc_name,inc_name,sid));
-    }
-  } // inputCollName if
-
-  // reset cutflow taken marker
-  m_cutflowTaken = false;
-
-  m_read.insert(sid);
-  
-  return StatusCode::SUCCESS;
-}
-#endif
-
-/*
-StatusCode BookkeeperTool::endInputFile()
-{
-  return this->endInputFile("Serial");
-}
-*/
-
-//#ifdef ASGTOOL_ATHENA
-StatusCode BookkeeperTool::endInputFile(const SG::SourceID& sid)
-{
-  // Add the sid to the list of complete sids
-  if (m_inputCollName != "") {  // are there inputs
-    m_fullreads.insert(sid);
-  }
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode BookkeeperTool::metaDataStop(const SG::SourceID&)
-{
-  const std::string storename("MetaDataStore+");
-  if (m_inputCollName != "") {  // are there inputs
-    //TERMINATING THE JOB (EndRun)
-    //Things to do:
-    // 1) Create new incomplete CutBookkeepers if relevant
-    // 2) Print cut flow summary
-    // 3) Write root file if requested
-    // Now retrieve pointers for the MetaConts
-    std::string tmp_name = storename+m_outputCollName+"tmpCont";
-    const MetaCont<xAOD::CutBookkeeperContainer>* tmp;
-    ATH_CHECK(outputMetaStore()->retrieve(tmp,tmp_name));
-    xAOD::CutBookkeeperContainer* outcom = new xAOD::CutBookkeeperContainer();
-    xAOD::CutBookkeeperAuxContainer* outcom_aux = new xAOD::CutBookkeeperAuxContainer();
-    outcom->setStore(outcom_aux);
-
-    if (m_markIncomplete) {
-      std::string inc_name = storename+"Incomplete"+m_outputCollName+"Cont"; 
-      // Build incomplete container to fill
-      xAOD::CutBookkeeperContainer* outinc = new xAOD::CutBookkeeperContainer();
-      xAOD::CutBookkeeperAuxContainer* outinc_aux = new xAOD::CutBookkeeperAuxContainer();
-      outinc->setStore(outinc_aux);
-      // Check if there were any incomplete inputs
-      const MetaCont<xAOD::CutBookkeeperContainer>* inc;
-      if(outputMetaStore()->retrieve(inc,inc_name).isSuccess()) {
-
-        // Incomplete inputs can just be merged
-        auto sids_inc = inc->sources();
-        xAOD::CutBookkeeperContainer* contptr(nullptr);
-        for (auto it = sids_inc.begin(); it != sids_inc.end(); ++it) {
-          if (!inc->find(*it,contptr)) {
-            ATH_MSG_ERROR("Container sid list did not match contents");
-          } else {
-            ATH_CHECK(updateContainer(outinc,contptr));
-          }
-          contptr = nullptr; 
-        }
-      } else {
-        ATH_MSG_INFO("Did not find MetaCont for " << inc_name << ", assuming input had no incomplete bookkeepers");
-      }
-
-      // Loop over containers and mark based on end files seen
-      auto sids_tmp = tmp->sources();
-      xAOD::CutBookkeeperContainer* contptr(nullptr);
-      for (auto it = sids_tmp.begin(); it != sids_tmp.end(); ++it) {
-        if (!tmp->find(*it,contptr)) {
-          ATH_MSG_ERROR("Container sid list did not match contents");
-        } else {
-          bool complete = std::find(m_fullreads.begin(),
-                       m_fullreads.end(),
-                       *it) != m_fullreads.end();
-          bool not_written = std::find(m_written.begin(),
-                          m_written.end(),
-                          *it) == m_written.end();
-          if (complete && not_written) {
-            ATH_CHECK(updateContainer(outcom,contptr));
-          } else {
-            ATH_CHECK(updateContainer(outinc,contptr));
-          }
-        }
-      }
-
-      std::string incout_name = "Incomplete"+m_outputCollName;
-      // Do any cleanup
-/*
-*/
-      if (outputMetaStore()->contains<xAOD::CutBookkeeperContainer>(incout_name) ) {
-        ATH_MSG_INFO("Cleaning up xAOD::CutBookkeeperContainer for " << incout_name);
-        const xAOD::CutBookkeeperContainer* tmpBook(nullptr);
-        if ( outputMetaStore()->retrieve(tmpBook,incout_name).isSuccess() ) {
-          const SG::IConstAuxStore* tmpBookAux = tmpBook->getConstStore();
-          //const xAOD::CutBookkeeperAuxContainer* tba = (const xAOD::CutBookkeeperAuxContainer*)tmpBookAux;
-          ATH_CHECK(outputMetaStore()->removeDataAndProxy(tmpBook));
-          ATH_CHECK(outputMetaStore()->removeDataAndProxy(tmpBookAux));
-        }
-        else ATH_MSG_ERROR("StoreGate failed retrieve after contains=true");
-      }
-      ATH_CHECK(outputMetaStore()->record(outinc,incout_name));
-      ATH_CHECK(outputMetaStore()->record(outinc_aux,incout_name+"Aux."));
-    }  // markIncomplete
-    else {
-      auto sids_tmp = tmp->sources();
-      xAOD::CutBookkeeperContainer* contptr(nullptr);
-      // just merge complete inputs into complete/output container
-      for (auto it = sids_tmp.begin(); it != sids_tmp.end(); ++it) {
-        if (!tmp->find(*it,contptr)) {
-          ATH_MSG_ERROR("Container sid list did not match contents");
-        } else {
-          // default to not worrying about marking
-          ATH_CHECK(updateContainer(outcom,contptr));
-        }
-      }
-    }
-
-    // Record container objects directly in store for output
-/*
-*/
-    if (outputMetaStore()->contains<xAOD::CutBookkeeperContainer>(m_outputCollName) ) {
-      ATH_MSG_INFO("Cleaning up xAOD::CutBookkeeperContainer for " << m_outputCollName);
-      const xAOD::CutBookkeeperContainer* tmpBook(nullptr);
-      if ( outputMetaStore()->retrieve(tmpBook,m_outputCollName).isSuccess() ) {
-        const SG::IConstAuxStore* tmpBookAux = tmpBook->getConstStore();
-        ATH_CHECK(outputMetaStore()->removeDataAndProxy(tmpBook));
-        ATH_CHECK(outputMetaStore()->removeDataAndProxy(tmpBookAux));
-      }
-      else ATH_MSG_ERROR("StoreGate failed retrieve after contains=true");
-    }
-    ATH_CHECK(outputMetaStore()->record(outcom,m_outputCollName));
-    ATH_CHECK(outputMetaStore()->record(outcom_aux,m_outputCollName+"Aux."));
-  } // inputCollName if
-
-  if (!m_cutflowTaken) {
-    if (addCutFlow().isFailure()) {
-      ATH_MSG_ERROR("Could not add CutFlow information");
-    }
-  }
-  else {
-    ATH_MSG_DEBUG("Cutflow information written into container before metaDataStop");
-  }
-
-  // Reset after metadata stop
-  m_cutflowTaken = false;
-
-  if (m_inputCollName != "") {  // are there inputs
-    // Copy read files into written files
-    //std::copy(m_read.begin(),m_read.end(),back_inserter(m_written));
-    for (auto it = m_read.begin(); it != m_read.end(); ++it) {
-      m_written.insert(*it);
-    }
-    // Remove completes from read
-    for (auto it = m_fullreads.begin(); it != m_fullreads.end(); ++it) {
-      m_read.erase(*it);
-      //std::remove(m_read.begin(); m_read.end(), *it);
-    }
-    m_fullreads.clear();
-  } // inputCollName if
-  
-  return StatusCode::SUCCESS;
-}
-//#endif
-
-/*
-StatusCode BookkeeperTool::metaDataStop()
-{
-  return this->metaDataStop("Serial");
-}
-*/
-
-StatusCode
-BookkeeperTool::finalize()
-{
-  ATH_MSG_DEBUG( "Finalizing " << name() << " - package version " << PACKAGE_VERSION );
-  return StatusCode::SUCCESS;
-}
-
-
-StatusCode BookkeeperTool::initOutputContainer( const std::string& sgkey)
-{
-  // Append datastore name to key
-  //std::string key = "MetaDataStore+"+sgkey;
-  std::string key = sgkey;
-  // Create the primary container
-  //xAOD::CutBookkeeperContainer* coll = new xAOD::CutBookkeeperContainer();
-  //xAOD::CutBookkeeperAuxContainer* auxcoll = new xAOD::CutBookkeeperAuxContainer();
-  //coll->setStore(auxcoll);
-  // Put it in a MetaCont
-  MetaCont<xAOD::CutBookkeeperContainer>* mcont = new MetaCont<xAOD::CutBookkeeperContainer>(DataObjID("xAOD::CutBookkeeperContainer",key));
-  // Do the same for the auxiliary container
-  std::string auxkey(key+"Aux.");
-  MetaCont<xAOD::CutBookkeeperAuxContainer>* acont = new MetaCont<xAOD::CutBookkeeperAuxContainer>(DataObjID("xAOD::CutBookkeeperAuxContainer",auxkey));
-  ATH_CHECK(outputMetaStore()->record(std::move(mcont),key));
-  ATH_CHECK(outputMetaStore()->record(std::move(acont),auxkey));
-  ATH_CHECK(outputMetaStore()->symLink
-          (
-            ClassID_traits<MetaCont<xAOD::CutBookkeeperAuxContainer> >::ID(),
-            auxkey,
-            ClassID_traits<xAOD::CutBookkeeperAuxContainer>::ID()
-          ));
-
-  return StatusCode::SUCCESS;
-}
-
-//--------------------------------------------------------//
-//  MetaConts are only needed when reading in Athena
-//  This builds them and populates them with bookeepers from the input store
-//--------------------------------------------------------//
-StatusCode BookkeeperTool::buildAthenaInterface(const std::string& inputName,
-                                                const std::string& outputName,
-                                                const SG::SourceID& sid)
-{
-  // Make sure the MetaCont is ready in the output store for outputName
-  //   If not, then create it
-  std::string name = outputName+"Cont"; 
-  if( !(outputMetaStore()->contains<MetaCont<xAOD::CutBookkeeperContainer> >(name)) ) {
-    ATH_CHECK(this->initOutputContainer(name));
-  }
-  else {
-    ATH_MSG_WARNING("incomplete collection already exists");
-  }
-
-  // Retrieve pointer for the MetaCont
-  MetaCont<xAOD::CutBookkeeperContainer>* mc;
-  ATH_CHECK(outputMetaStore()->retrieve(mc,name));
-
-  // Make sure sid does not already exist in the MetaCont
-  if ( std::find(mc->sources().begin(),mc->sources().end(),sid) 
-                                        != mc->sources().end() ) {
-    ATH_MSG_ERROR("Metadata already exists for sid " << sid);
-    return StatusCode::FAILURE;   // Fail if sid already exists
-  }
-
-  // Get the input bookkeeper of the input metadata store
-  const xAOD::CutBookkeeperContainer* cbc;
-  if (inputMetaStore()->contains<xAOD::CutBookkeeperContainer>(inputName) ) {
-    StatusCode ssc = inputMetaStore()->retrieve( cbc, inputName );
-    if (ssc.isSuccess()) {
-      // Insert input bookkeeper into MetaCont for this sid
-      xAOD::CutBookkeeperContainer* tostore = new xAOD::CutBookkeeperContainer(*cbc);
-      if ( !mc->insert(sid,tostore) ) {
-        ATH_MSG_ERROR("Unable to insert " << inputName << " for " << sid << " with key " << name);
-        return StatusCode::FAILURE;   // Fail if insert to mc fails
-      }
-    }
-    else {
-      ATH_MSG_ERROR("Could not retrieve CutBookkeeperContainer with name " << inputName << " in input store");
-      return StatusCode::FAILURE;   // Fail if store contains, but not retrieves
-    }
-  }
-  else {
-    ATH_MSG_WARNING("No " << inputName << " bookkeepers in this file ");
-  }
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode BookkeeperTool::addCutFlow()
-{
-  // Add the information from the current processing to the complete output
-  // --> same paradigm as original CutFlowSvc
-  // Get the complete bookkeeper collection of the output meta-data store
-  xAOD::CutBookkeeperContainer* completeBook(NULL); 
-  if( !(outputMetaStore()->retrieve( completeBook, m_outputCollName) ).isSuccess() ) {
-    ATH_MSG_ERROR( "Could not get complete CutBookkeepers from output MetaDataStore" );
-    return StatusCode::FAILURE;
-  }
-
-  // Get the bookkeeper from the current processing
-  const xAOD::CutBookkeeperContainer* fileCompleteBook(NULL);
-  if( outputMetaStore()->contains<xAOD::CutBookkeeperContainer>(m_cutflowCollName) ) {
-    if( !(outputMetaStore()->retrieve( fileCompleteBook, m_cutflowCollName) ).isSuccess() ) {
-      ATH_MSG_WARNING( "Could not get CutFlowSvc CutBookkeepers from output MetaDataStore" );
-    }
-    else {
-      // update the complete output with the complete input
-      ATH_CHECK(this->updateContainer(completeBook,fileCompleteBook));
-    }
-  }
-  else {
-    ATH_MSG_INFO("No cutflow container " << m_cutflowCollName);
-  }
-
-  return StatusCode::SUCCESS;
-}
-
-
 namespace {
 
-
 xAOD::CutBookkeeper*
 resolveLink (const xAOD::CutBookkeeper* old,
              xAOD::CutBookkeeperContainer& contToUpdate,
-- 
GitLab