From adc493be3697d5e650fae0ddafca07308e55fc1d Mon Sep 17 00:00:00 2001
From: Tadej Novak <tadej.novak@cern.ch>
Date: Sat, 31 Oct 2020 11:08:58 +0100
Subject: [PATCH] Remove unused SkimDecisionMultiFilter and FillEBCFromFlat

---
 Event/EventBookkeeperTools/CMakeLists.txt     |   5 +-
 .../src/FillEBCFromFlat.cxx                   |  92 -------
 .../src/FillEBCFromFlat.h                     |  54 -----
 .../src/SkimDecisionMultiFilter.cxx           | 229 ------------------
 .../src/SkimDecisionMultiFilter.h             | 104 --------
 .../EventBookkeeperTools_entries.cxx          |   2 -
 6 files changed, 2 insertions(+), 484 deletions(-)
 delete mode 100644 Event/EventBookkeeperTools/src/FillEBCFromFlat.cxx
 delete mode 100644 Event/EventBookkeeperTools/src/FillEBCFromFlat.h
 delete mode 100644 Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.cxx
 delete mode 100644 Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.h

diff --git a/Event/EventBookkeeperTools/CMakeLists.txt b/Event/EventBookkeeperTools/CMakeLists.txt
index 3878dd2fec8..74e9349837c 100644
--- a/Event/EventBookkeeperTools/CMakeLists.txt
+++ b/Event/EventBookkeeperTools/CMakeLists.txt
@@ -10,7 +10,7 @@ if( XAOD_STANDALONE )
    set( xaod_access_lib xAODRootAccess )
 # ... for AthAnalysisBase (Athena calls this POOLRootAccess)
 else()
-   set( extra_libs GaudiKernel AthenaKernel AthenaPoolUtilities EventInfo IOVDbDataModel )
+   set( extra_libs GaudiKernel AthenaKernel AthenaPoolUtilities EventInfo IOVDbDataModel StoreGateLib )
    set( xaod_access_lib POOLRootAccessLib )
 endif()
 
@@ -34,8 +34,7 @@ if( NOT XAOD_STANDALONE )
    atlas_add_component( EventBookkeeperTools
                         src/*.cxx
                         src/components/*.cxx
-                        LINK_LIBRARIES AthenaBaseComps AthenaKernel GaudiKernel EventBookkeeperToolsLib
-                                       SGTools StoreGateLib EventBookkeeperMetaData )
+                        LINK_LIBRARIES GaudiKernel AthenaKernel EventBookkeeperToolsLib)
 endif()
 
 atlas_add_executable( dump-cbk
diff --git a/Event/EventBookkeeperTools/src/FillEBCFromFlat.cxx b/Event/EventBookkeeperTools/src/FillEBCFromFlat.cxx
deleted file mode 100644
index 1c130f6c004..00000000000
--- a/Event/EventBookkeeperTools/src/FillEBCFromFlat.cxx
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include "FillEBCFromFlat.h"
-
-#include <iostream>
-
-FillEBCFromFlat::FillEBCFromFlat(StoreGateSvc_t &inputStore, EventBookkeeperCollection *coll, int wantIsComplete)
-  : m_inputStore(inputStore), m_coll(coll), m_wantIsComplete(wantIsComplete)
-{
-  if (m_wantIsComplete) {
-    m_offset = 0;
-  } else {
-    m_offset = *(m_inputStore->retrieve<int>("CutFlowTree/CutFlow_Nb"));
-  }
-  initialise();
-}
-
-void FillEBCFromFlat::initialise()
-{
-  //std::cout << "FillEBCFromFlat::initialise()" << std::endl;
-
-  m_name = m_inputStore->retrieve<std::vector<std::string> >("CutFlowTree/name");
-  m_inputstream = m_inputStore->retrieve<std::vector<std::string> >("CutFlowTree/inputstream");
-  m_outputstream = m_inputStore->retrieve<std::vector<std::string> >("CutFlowTree/outputstream");
-  m_description = m_inputStore->retrieve<std::vector<std::string> >("CutFlowTree/description");
-  m_logic = m_inputStore->retrieve<std::vector<std::string> >("CutFlowTree/logic");
-  m_nAcceptedEvents = m_inputStore->retrieve<std::vector<ULong_t> >("CutFlowTree/nAcceptedEvents");
-  m_nWeightedAcceptedEvents = m_inputStore->retrieve<std::vector<Double_t> >("CutFlowTree/nWeightedAcceptedEvents");
-  m_isComplete = m_inputStore->retrieve<std::vector<Int_t> >("CutFlowTree/isComplete");
-  m_cycle = m_inputStore->retrieve<std::vector<Int_t> >("CutFlowTree/cycle");
-  m_parentIndex = m_inputStore->retrieve<std::vector<Int_t> >("CutFlowTree/parentIndex");
-  m_nbChildren = m_inputStore->retrieve<std::vector<Int_t> >("CutFlowTree/nbChildren");
-  m_childrenIndices = m_inputStore->retrieve<std::vector< std::vector<UInt_t> > >("CutFlowTree/childrenIndices");
-}
-
-void FillEBCFromFlat::fill()
-{
-  //std::cout << "FillEBCFromFlat::fill()" << std::endl;
-
-  unsigned int nCuts = m_name->size();
-
-  for (unsigned int i = 0; i < nCuts; ++i) {
-    if (m_isComplete->at(i) != m_wantIsComplete) continue;
-    
-    // Only add top level EventBookkeepers here 
-    if (m_parentIndex->at(i) != -1) continue;
-
-    EventBookkeeper *eb = newEventBookkeeper(i);
-    m_coll->push_back(eb);
-
-    if (m_nbChildren->at(i) > 0) {
-      addChildren(eb, i);
-    }
-  }
-}
-
-EventBookkeeper *FillEBCFromFlat::newEventBookkeeper(unsigned int index) const
-{
-  //std::cout << "FillEBCFromFlat::newEventBookkeeper(" << index << ") - " << m_name->at(index) << std::endl;
-
-  EventBookkeeper *eb = new EventBookkeeper(m_name->at(index));
-  eb->setInputStream(m_inputstream->at(index));
-  eb->setOutputStream(m_outputstream->at(index));
-  eb->setDescription(m_description->at(index));
-  eb->setLogic(m_logic->at(index));
-  eb->setNAcceptedEvents(m_nAcceptedEvents->at(index));
-  eb->setNWeightedAcceptedEvents(m_nWeightedAcceptedEvents->at(index));
-  eb->setCycle(m_cycle->at(index));
-  return eb;
-}
-
-void FillEBCFromFlat::addChildren(EventBookkeeper *eb, unsigned int indexOfEb) const
-{
-  //std::cout << "FillEBCFromFlat::addChildren(@" << eb << ", " << indexOfEb <<")" << std::endl;
-
-  for (std::vector<UInt_t>::const_iterator childIndex = m_childrenIndices->at(indexOfEb).begin(); childIndex != m_childrenIndices->at(indexOfEb).end(); ++childIndex) {
-    unsigned int corrChildIndex = (*childIndex) + m_offset;
-    if (corrChildIndex == indexOfEb) {
-      std::cout << "FillEBCFromFlat::addChildren() WARNING - corrChildIndex == indexOfEb == " << indexOfEb << std::endl;
-      continue;
-    }
-
-    EventBookkeeper *ebChild = newEventBookkeeper(corrChildIndex);
-    if (m_nbChildren->at(corrChildIndex) > 0) {
-      addChildren(ebChild, corrChildIndex);
-    }
-    eb->AddChild(ebChild);
-  }
-}
-
diff --git a/Event/EventBookkeeperTools/src/FillEBCFromFlat.h b/Event/EventBookkeeperTools/src/FillEBCFromFlat.h
deleted file mode 100644
index 468a67c6379..00000000000
--- a/Event/EventBookkeeperTools/src/FillEBCFromFlat.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
-*/
-
-#ifndef FILL_EBC_FROM_FLAT_H
-#define FILL_EBC_FROM_FLAT_H
-
-#include "GaudiKernel/ServiceHandle.h"
-#include "StoreGate/StoreGateSvc.h"
-
-#include "SGTools/StlVectorClids.h"
-#include "SGTools/BuiltinsClids.h"
-
-#include <string>
-#include <vector>
-
-#include <TTree.h>
-
-#include "EventBookkeeperMetaData/EventBookkeeperCollection.h"
-
-class FillEBCFromFlat {
-  public:
-    typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
-
-    FillEBCFromFlat(StoreGateSvc_t &inputStore, EventBookkeeperCollection *coll, int wantIsComplete);
-    void fill();
-
-  private:
-    void initialise();
-    EventBookkeeper *newEventBookkeeper(unsigned int index) const;
-    void addChildren(EventBookkeeper *eb, unsigned int indexOfEb) const;
-
-  private:
-    StoreGateSvc_t m_inputStore;
-    EventBookkeeperCollection *m_coll;
-    int m_wantIsComplete;
-
-    unsigned int m_offset;
-
-    std::vector<std::string> *m_name;
-    std::vector<std::string> *m_inputstream;
-    std::vector<std::string> *m_outputstream;
-    std::vector<std::string> *m_description;
-    std::vector<std::string> *m_logic;
-    std::vector<ULong_t> *m_nAcceptedEvents;
-    std::vector<Double_t> *m_nWeightedAcceptedEvents;
-    std::vector<Int_t> *m_isComplete;
-    std::vector<Int_t> *m_cycle;
-    std::vector<Int_t> *m_parentIndex;
-    std::vector<Int_t> *m_nbChildren;
-    std::vector< std::vector<UInt_t> > *m_childrenIndices;
-};
-
-#endif // FILL_EBC_FROM_FLAT_H
diff --git a/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.cxx b/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.cxx
deleted file mode 100644
index f5a9fe805ea..00000000000
--- a/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.cxx
+++ /dev/null
@@ -1,229 +0,0 @@
-///////////////////////// -*- C++ -*- /////////////////////////////
-
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// SkimDecisionMultiFilter.cxx 
-// Implementation file for class SkimDecisionMultiFilter
-// Author: Karsten Koeneke <karsten.koeneke@cern.ch>
-// Description: This filter allows to make an event decision based
-//              on a list of SkimDecisions to ask.
-/////////////////////////////////////////////////////////////////// 
-
-// EventBookkeeperTools includes
-#include "SkimDecisionMultiFilter.h"
-
-// STL includes
-
-// FrameWork includes
-#include "Gaudi/Property.h"
-
-// Handy definitions for error checking
-#include "AthenaKernel/errorcheck.h"
-
-// Event includes
-#include "EventBookkeeperMetaData/SkimDecisionCollection.h"
-#include "EventBookkeeperMetaData/SkimDecision.h"
-
-
-
-/////////////////////////////////////////////////////////////////// 
-// Public methods: 
-/////////////////////////////////////////////////////////////////// 
-
-// Constructors
-////////////////
-SkimDecisionMultiFilter::SkimDecisionMultiFilter( const std::string& name, 
-                                                  ISvcLocator* pSvcLocator ) : 
-  ::AthFilterAlgorithm( name, pSvcLocator )
-{
-  //
-  // Property declaration
-  // 
-  declareProperty( "SkimDecisionCollection",      m_skimDecContName, "The name (key) of the SkimDecisionCollection to use" );
-  declareProperty( "AcceptSkimDecisionNameList",  m_accSkimDecNameList, "The list of SkimDecision names to accept (logical OR)" );
-  declareProperty( "RequireSkimDecisionNameList", m_reqSkimDecNameList, "The list of SkimDecision names to require (logical AND)" );
-  declareProperty( "VetoSkimDecisionNameList",    m_vetoSkimDecNameList, "The list of SkimDecision names to veto (logical NOT)" );
-
-}
-
-// Destructor
-///////////////
-SkimDecisionMultiFilter::~SkimDecisionMultiFilter()
-{}
-
-// Athena Algorithm's Hooks
-////////////////////////////
-StatusCode SkimDecisionMultiFilter::initialize()
-{
-  ATH_MSG_INFO ("Initializing " << name() << "...");
-  ATH_MSG_INFO (" using SkimDecisionCollection      = " << m_skimDecContName );
-  ATH_MSG_INFO (" using AcceptSkimDecisionNameList  = " << m_accSkimDecNameList );
-  ATH_MSG_INFO (" using RequireSkimDecisionNameList = " << m_reqSkimDecNameList );
-  ATH_MSG_INFO (" using VetoSkimDecisionNameList    = " << m_vetoSkimDecNameList );
-
-  // Initialize the index vectors to -1
-  for ( unsigned int i=0; i<m_accSkimDecNameList.size(); ++i )  m_accIdxList.push_back(-1);
-  for ( unsigned int i=0; i<m_reqSkimDecNameList.size(); ++i )  m_reqIdxList.push_back(-1);
-  for ( unsigned int i=0; i<m_vetoSkimDecNameList.size(); ++i ) m_vetoIdxList.push_back(-1);
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode SkimDecisionMultiFilter::finalize()
-{
-  ATH_MSG_INFO ("Finalizing " << name() << "...");
-
-  return StatusCode::SUCCESS;
-}
-
-StatusCode SkimDecisionMultiFilter::execute()
-{  
-  ATH_MSG_DEBUG ("Executing " << name() << "...");
-
-  // Get the SkimDecisionCollection
-  const SkimDecisionCollection* skimDecCont(NULL);
-  CHECK( evtStore()->retrieve( skimDecCont, m_skimDecContName ) );
-
-
-  // Run the accept determination
-  bool passAccept(false);
-  if ( m_accSkimDecNameList.size() == 0 ) passAccept = true;
-  for ( unsigned int i=0; i<m_accSkimDecNameList.size(); ++i )
-    {
-      if ( skimDecisionNameIsAccepted( skimDecCont, m_accSkimDecNameList[i], m_accIdxList, i ) )
-        {
-          ATH_MSG_DEBUG( "Found SkimDecision with name " << m_accSkimDecNameList[i]
-                         << " from AcceptSkimDecisionNameList in SkimDecisionCollection with key " << m_skimDecContName );
-          passAccept = true;
-          break;
-        }
-    } // End: loop over all accept requests
-
-
-  // Run the require determination
-  bool passRequire(true);
-  for ( unsigned int i=0; i<m_reqSkimDecNameList.size(); ++i )
-    {
-      passRequire = passRequire && skimDecisionNameIsAccepted( skimDecCont, m_reqSkimDecNameList[i], m_reqIdxList, i );
-      ATH_MSG_DEBUG( "Found SkimDecision with name " << m_reqSkimDecNameList[i]
-                     << " from RequireSkimDecisionNameList in SkimDecisionCollection with key " << m_skimDecContName );
-    } // End: loop over all require requests
-
-
-  // Run the veto determination
-  bool veto(false);
-  for ( unsigned int i=0; i<m_vetoSkimDecNameList.size(); ++i )
-    {
-      if ( skimDecisionNameIsAccepted( skimDecCont, m_vetoSkimDecNameList[i], m_vetoIdxList, i ) )
-        {
-          ATH_MSG_DEBUG( "Found SkimDecision with name " << m_vetoSkimDecNameList[i]
-                         << " from VetoSkimDecisionNameList in SkimDecisionCollection with key " << m_skimDecContName );
-          veto = true;
-          break;
-        }
-    } // End: loop over all veto requests
-  bool passVeto = !veto;
-
-
-  // Determine the global event passing decision
-  setFilterPassed( passAccept && passRequire && passVeto );
-
-
-  return StatusCode::SUCCESS;
-}
-
-
-
-
-// Private helper method to find the SkimDecision isAccepted() answer
-bool SkimDecisionMultiFilter::skimDecisionNameIsAccepted( const SkimDecisionCollection* skimDecCont,
-                                                          std::string& skimDecName,
-                                                          std::vector<int>& skimDecIdxList,
-                                                          unsigned int idx )
-{
-  // Pointer check
-  if ( !skimDecCont )
-    {
-      ATH_MSG_WARNING( "Got a zero pointer of type SkimDecisionCollection with key " << m_skimDecContName );
-      return false;
-    }
-
-  // Get the size of the SkimDecisionCollection
-  const unsigned int skimCollSize = skimDecCont->size();
-
-  // If we already have an index, choose the fast path 
-  if ( skimDecIdxList[idx] >= 0 && skimDecIdxList[idx] < (int)skimCollSize )
-    {
-      const SkimDecision* skimDec = skimDecCont->at(skimDecIdxList[idx]);
-      if ( !skimDec )
-        {
-          ATH_MSG_WARNING( "Couldn't find SkimDecision with name " << skimDecName
-                           << " in SkimDecisionCollection with key " << m_skimDecContName );
-          return false;
-        }
-
-      // If the name is correct for the given index
-      if ( skimDec->getName() == skimDecName )
-        {
-          return skimDec->isAccepted();
-        }
-      else // The index was wrong and we need to search for the name 
-        {
-          // Loop over all SkimDecisions in the SkimDecisionCollection
-          bool foundSkimDec(false);
-          for ( unsigned int i=0; i<skimCollSize; ++i )
-            {
-              // Get the current SkimDecision
-              const SkimDecision* skimDec = skimDecCont->at(i);
-              if ( !skimDec ) continue;
-
-              // Found the right skim decision
-              if ( skimDecName == skimDec->getName() )
-                {
-                  skimDecIdxList[idx] = (int)i; // Set the index to the found one
-                  foundSkimDec = true;
-                  return skimDec->isAccepted();
-                }
-            }
-          // If none of the SkimDecision names matched
-          if ( !foundSkimDec )
-            {
-              ATH_MSG_WARNING( "Couldn't find SkimDecision with name " << skimDecName
-                               << " in SkimDecisionCollection with key " << m_skimDecContName );
-              return false;
-            }
-        }
-    } // End: if we have a valid index
-  else // The index was wrong and we need to search for the name 
-    {
-      // Loop over all SkimDecisions in the SkimDecisionCollection
-      bool foundSkimDec(false);
-      for ( unsigned int i=0; i<skimCollSize; ++i )
-        {
-          // Get the current SkimDecision
-          const SkimDecision* skimDec = skimDecCont->at(i);
-          if ( !skimDec ) continue;
-          
-          // Found the right skim decision
-          if ( skimDecName == skimDec->getName() )
-            {
-              skimDecIdxList[idx] = (int)i; // Set the index to the found one
-              foundSkimDec = true;
-              return skimDec->isAccepted();
-            }
-        }
-      // If none of the SkimDecision names matched
-      if ( !foundSkimDec )
-        {
-          ATH_MSG_WARNING( "Couldn't find SkimDecision with name " << skimDecName
-                           << " in SkimDecisionCollection with key " << m_skimDecContName );
-          return false;
-        }
-    }
-  // If we got to here, something went wrong
-  ATH_MSG_WARNING( "We should have never reached this part of the code! Tried to search for SkimDecision with name " << skimDecName
-                   << " in SkimDecisionCollection with key " << m_skimDecContName );
-  return false;
-}
diff --git a/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.h b/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.h
deleted file mode 100644
index 2328beedb5b..00000000000
--- a/Event/EventBookkeeperTools/src/SkimDecisionMultiFilter.h
+++ /dev/null
@@ -1,104 +0,0 @@
-///////////////////////// -*- C++ -*- /////////////////////////////
-
-/*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
-*/
-
-// SkimDecisionMultiFilter.h 
-// Header file for class SkimDecisionMultiFilter
-// Author: Karsten Koeneke <karsten.koeneke@cern.ch>
-/////////////////////////////////////////////////////////////////// 
-#ifndef EVENTBOOKKEEPERTOOLS_SKIMDECISIONMULTIFILTER_H
-#define EVENTBOOKKEEPERTOOLS_SKIMDECISIONMULTIFILTER_H 1
-
-// STL includes
-#include <string>
-
-// FrameWork includes
-#include "AthenaBaseComps/AthFilterAlgorithm.h"
-
-// Forward declarations
-class SkimDecisionCollection;
-
-
-
-class SkimDecisionMultiFilter
-  : public ::AthFilterAlgorithm
-{ 
-
-  /////////////////////////////////////////////////////////////////// 
-  // Public methods: 
-  /////////////////////////////////////////////////////////////////// 
-public: 
-
-  // Copy constructor: 
-
-  /// Constructor with parameters: 
-  SkimDecisionMultiFilter( const std::string& name, ISvcLocator* pSvcLocator );
-
-  /// Destructor: 
-  virtual ~SkimDecisionMultiFilter(); 
-
-  // Athena algorithm's Hooks
-  virtual StatusCode  initialize();
-  virtual StatusCode  execute();
-  virtual StatusCode  finalize();
-
-  /////////////////////////////////////////////////////////////////// 
-  // Const methods: 
-  ///////////////////////////////////////////////////////////////////
-
-  /////////////////////////////////////////////////////////////////// 
-  // Non-const methods: 
-  /////////////////////////////////////////////////////////////////// 
-private:
-
-  /// Private method to determine the accept decission
-  bool skimDecisionNameIsAccepted( const SkimDecisionCollection* skimDecCont,
-                                   std::string& skimDecName,
-                                   std::vector<int>& skimDecIdxList,
-                                   unsigned int idx );
-
-
-  /////////////////////////////////////////////////////////////////// 
-  // Private data: 
-  /////////////////////////////////////////////////////////////////// 
-private: 
-
-  /// Default constructor: 
-  //SkimDecisionMultiFilter();
-
-  /// SkimDecisionCollection name
-  std::string m_skimDecContName;
-
-  /// The list of SkimDecision names to accept (logical OR)
-  std::vector< std::string > m_accSkimDecNameList;
-
-  /// The list of SkimDecision names to require (logical AND)
-  std::vector< std::string > m_reqSkimDecNameList;
-
-  /// The list of SkimDecision names to veto (logical NOT)
-  std::vector< std::string > m_vetoSkimDecNameList;
-
-
-  /// List of the indices where the correct SkimDecision is in the container for the accept (logical OR) method
-  std::vector<int> m_accIdxList;
-
-  /// List of the indices where the correct SkimDecision is in the container for the require (logical AND) method
-  std::vector<int> m_reqIdxList;
-
-  /// List of the indices where the correct SkimDecision is in the container for the veto (logical NOT) method
-  std::vector<int> m_vetoIdxList;
-
-
-}; 
-
-// I/O operators
-//////////////////////
-
-/////////////////////////////////////////////////////////////////// 
-// Inline methods: 
-/////////////////////////////////////////////////////////////////// 
-
-
-#endif //> !EVENTBOOKKEEPERTOOLS_SKIMDECISIONMULTIFILTER_H
diff --git a/Event/EventBookkeeperTools/src/components/EventBookkeeperTools_entries.cxx b/Event/EventBookkeeperTools/src/components/EventBookkeeperTools_entries.cxx
index ee4de188dab..464b2a0f96d 100644
--- a/Event/EventBookkeeperTools/src/components/EventBookkeeperTools_entries.cxx
+++ b/Event/EventBookkeeperTools/src/components/EventBookkeeperTools_entries.cxx
@@ -4,7 +4,6 @@
 
 #include "../AllExecutedEventsCounterAlg.h"
 #include "../EventCounterAlg.h"
-#include "../SkimDecisionMultiFilter.h"
 #include "../TestFilterReentrantAlg.h"
 
 DECLARE_COMPONENT( AllExecutedEventsCounterAlg )
@@ -12,5 +11,4 @@ DECLARE_COMPONENT( BookkeeperDumperTool )
 DECLARE_COMPONENT( BookkeeperTool )
 DECLARE_COMPONENT( CutFlowSvc )
 DECLARE_COMPONENT( EventCounterAlg )
-DECLARE_COMPONENT( SkimDecisionMultiFilter )
 DECLARE_COMPONENT( TestFilterReentrantAlg )
-- 
GitLab