Skip to content
Snippets Groups Projects
Commit 25d9bb20 authored by Dan Guest's avatar Dan Guest
Browse files

remove AthAlgorithm

parent 453f13c5
No related branches found
No related tags found
No related merge requests found
Pipeline #11056914 failed
......@@ -11,7 +11,7 @@ find_package( Boost COMPONENTS json)
atlas_add_library(CutBookkeeperUtilsLib
Root/OriginalAodCounts.cxx
LINK_LIBRARIES
AnaAlgorithmLib
GaudiKernel AthenaBaseComps
AsgServicesLib
PATInterfaces
PMGAnalysisInterfacesLib
......
......@@ -65,12 +65,19 @@ namespace {
}
SumWeightAlg::SumWeightAlg(
const std::string& name,
ISvcLocator* pSvcLocator):
AthAlgorithm(name, pSvcLocator),
m_inputMetaStore("StoreGateSvc/InputMetaDataStore", name)
{
}
StatusCode SumWeightAlg::initialize ()
StatusCode SumWeightAlg::initialize()
{
ANA_CHECK (requestFileExecute());
ANA_CHECK (m_truthWeightTool.retrieve());
// ANA_CHECK (requestFileExecute());
CHECK (m_truthWeightTool.retrieve());
if (!m_output_svc.empty()) {
ATH_CHECK(m_output_svc.retrieve());
......@@ -79,23 +86,31 @@ StatusCode SumWeightAlg::initialize ()
return StatusCode::SUCCESS;
}
StatusCode SumWeightAlg::execute()
{
return StatusCode::SUCCESS;
}
StatusCode SumWeightAlg ::
fileExecute ()
void SumWeightAlg::handle(const Incident& inc)
{
ANA_MSG_DEBUG ("Updating CutBookkeeper information");
std::cout << "handling incident" << std::endl;
// skip all incidents beyond the start of input files
if (inc.type() != IncidentType::BeginInputFile) return;
// ANA_MSG_DEBUG ("Updating CutBookkeeper information");
// Retrieve complete CutBookkeeperContainer
const xAOD::CutBookkeeperContainer *completeCBC{};
ANA_CHECK (inputMetaStore()->retrieve(completeCBC, "CutBookkeepers"));
auto rc = m_inputMetaStore->retrieve(completeCBC, "CutBookkeepers");
if (!rc.isSuccess()) throw std::runtime_error(
"could not retrieve CutBookkeepers");
// Find the max cycle
int maxCycle{-1};
const xAOD::CutBookkeeper *allEvents{};
for (const xAOD::CutBookkeeper *cbk : *completeCBC)
{
ANA_MSG_DEBUG ("Complete cbk name: " << cbk->name() << " - stream: " << cbk->inputStream());
// ANA_MSG_DEBUG ("Complete cbk name: " << cbk->name() << " - stream: " << cbk->inputStream());
if (cbk->cycle() > maxCycle && isGoodBook(*cbk))
{
......@@ -106,8 +121,9 @@ fileExecute ()
if (allEvents == nullptr)
{
ANA_MSG_ERROR ("Could not find AllExecutedEvents CutBookkeeper information.");
return StatusCode::FAILURE;
std::string error(
"Could not find AllExecutedEvents CutBookkeeper information.");
throw std::runtime_error(error);
}
for (const xAOD::CutBookkeeper *cbk : *completeCBC)
......@@ -130,13 +146,15 @@ fileExecute ()
for (size_t index{1}; index < m_truthWeightTool->getWeightNames().size(); ++index)
{
std::string cbkName = "CutBookkeepers_weight_" + std::to_string(index);
if (!inputMetaStore()->contains<xAOD::CutBookkeeperContainer>(cbkName))
if (!m_inputMetaStore->contains<xAOD::CutBookkeeperContainer>(cbkName))
{
ANA_MSG_VERBOSE("No container named " << cbkName << "available");
// ANA_MSG_VERBOSE("No container named " << cbkName << "available");
continue;
}
ANA_CHECK(inputMetaStore()->retrieve(completeCBC, cbkName));
if (!m_inputMetaStore->retrieve(completeCBC, cbkName).isSuccess()) {
throw std::runtime_error("could not retrieve " + cbkName);
}
for (const xAOD::CutBookkeeper *cbk : *completeCBC)
{
if (cbk->cycle() == maxCycle && isGoodBook(*cbk))
......@@ -145,8 +163,6 @@ fileExecute ()
}
}
}
return StatusCode::SUCCESS;
}
......@@ -159,7 +175,7 @@ finalize ()
for (const CP::SystematicVariation &variation : m_truthWeightTool->affectingSystematics())
{
auto set = CP::SystematicSet({variation});
ANA_MSG_DEBUG("using systematic " << set.name());
// ANA_MSG_DEBUG("using systematic " << set.name());
systematics.emplace_back(set);
}
......
......@@ -5,7 +5,8 @@
#ifndef SUM_EVENT_WEIGHT_WRITER_H
#define SUM_EVENT_WEIGHT_WRITER_H
#include <AnaAlgorithm/AnaAlgorithm.h>
#include "AthenaBaseComps/AthAlgorithm.h"
#include <GaudiKernel/IIncidentListener.h>
#include <AsgServices/ServiceHandle.h>
#include <PATInterfaces/SystematicSet.h>
#include <PMGAnalysisInterfaces/IPMGTruthWeightTool.h>
......@@ -16,16 +17,22 @@
#include "HDF5Utils/IH5GroupSvc.h"
class SumWeightAlg final : public EL::AnaAlgorithm
class SumWeightAlg final :
public AthAlgorithm,
public IIncidentListener
{
public:
using EL::AnaAlgorithm::AnaAlgorithm;
SumWeightAlg(const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize () override;
StatusCode fileExecute () override;
StatusCode finalize () override;
StatusCode initialize() override;
StatusCode execute() override;
StatusCode finalize() override;
// hook to call this alg on each new input file
void handle(const Incident&) override;
private:
ServiceHandle< StoreGateSvc > m_inputMetaStore;
ToolHandle<PMGTools::IPMGTruthWeightTool> m_truthWeightTool {
this, "truthWeightTool", "PMGTools::PMGTruthWeightTool",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment