diff --git a/Control/AthenaKernel/AthenaKernel/ICutFlowSvc.h b/Control/AthenaKernel/AthenaKernel/ICutFlowSvc.h index 3259e34f7f6cbbd18be4d2d27684114f1c610927..0d1e1ee31676fbcda7cd670a60a254c3b775a10a 100644 --- a/Control/AthenaKernel/AthenaKernel/ICutFlowSvc.h +++ b/Control/AthenaKernel/AthenaKernel/ICutFlowSvc.h @@ -59,6 +59,14 @@ public: const std::string& outputStream, bool nominalOnly ) = 0; + /// Register cut as child of a filter in the CutFlowSvc and returns the CutID + /// of the corresponding EventBookkeeper. This method should be used by + /// filters to register their internal cuts that are not the Algs themselves. + virtual CutIdentifier registerCut( const std::string& name, + const std::string& description, + CutIdentifier parentCutID, + bool nominalOnly ) = 0; + /// Set the description of an existing EventBookkeeper virtual void setFilterDescription( CutIdentifier cutID, const std::string& descr ) = 0; diff --git a/Event/EventBookkeeperTools/EventBookkeeperTools/CutFlowSvc.h b/Event/EventBookkeeperTools/EventBookkeeperTools/CutFlowSvc.h index f10b34efdd98ddc35f1745c3a84762e1b5faf97f..7004df94c64f6795cce0390333a2a1a54a22a396 100644 --- a/Event/EventBookkeeperTools/EventBookkeeperTools/CutFlowSvc.h +++ b/Event/EventBookkeeperTools/EventBookkeeperTools/CutFlowSvc.h @@ -81,6 +81,14 @@ public: const std::string& outputStream, bool nominalOnly) override final; + /// Register cut as child of a filter in the CutFlowSvc and returns the CutID + /// of the corresponding EventBookkeeper. This method should be used by + /// filters to register their internal cuts that are not the Algs themselves. + virtual CutIdentifier registerCut(const std::string& name, + const std::string& description, + CutIdentifier parentCutID, + bool nominalOnly) override final; + /// Set the description of an existing CutBookkeeper virtual void setFilterDescription(CutIdentifier cutID, const std::string& descr) override final; diff --git a/Event/EventBookkeeperTools/Root/CutFlowSvc.cxx b/Event/EventBookkeeperTools/Root/CutFlowSvc.cxx index 16ea582038673a74f1475cd982e6ea50295d15e1..3b366e8d7670b5b75d51cc7135dc094e2fa6995d 100644 --- a/Event/EventBookkeeperTools/Root/CutFlowSvc.cxx +++ b/Event/EventBookkeeperTools/Root/CutFlowSvc.cxx @@ -80,14 +80,14 @@ CutIdentifier CutFlowSvc::registerFilter( const std::string& name, for (xAOD::CutBookkeeper* cbk : *container) { if (newCbk->isEqualTo(cbk)) { ATH_MSG_DEBUG("The CutBookkeeper with name '" << name << "' already exists" - << " and has cutID " << cbk->uniqueIdentifier() << "... Not adding!" ); + << " and has CutID " << cbk->uniqueIdentifier() << "... Not adding!" ); // Return the existing cut ID return cbk->uniqueIdentifier(); } } // If it is a new CutBookkeeper, add it to the container - ATH_MSG_DEBUG("Declaring a new filter with name '" << name << "' and cutID " << cutID ); + ATH_MSG_DEBUG("Declaring a new filter with name '" << name << "' and CutID " << cutID ); container->push_back(std::move(newCbk)); if (nominalOnly) { @@ -114,7 +114,7 @@ CutIdentifier CutFlowSvc::registerTopFilter( const std::string& name, CutIdentifier cutID = registerFilter(name, description, nominalOnly); xAOD::CutBookkeeper* cbk = getCutBookkeeper(cutID, 0); if (cbk == nullptr) { - ATH_MSG_ERROR("registerTopFilter: Could not find CutBookkeeper with cutID " << cutID); + ATH_MSG_ERROR("Could not find CutBookkeeper with CutID " << cutID); return 0; } @@ -127,6 +127,37 @@ CutIdentifier CutFlowSvc::registerTopFilter( const std::string& name, } +CutIdentifier CutFlowSvc::registerCut( const std::string& name, + const std::string& description, + CutIdentifier parentCutID, + bool nominalOnly ) +{ + ATH_MSG_DEBUG("Registering cut with name '" << name << "', description '" << description + << "' and original CutID " << parentCutID); + + // Get the CutBookkeeper of the origin Filter Algorithm/Tool + xAOD::CutBookkeeper* parentCbk = getCutBookkeeper(parentCutID, 0); + if (parentCbk == nullptr) { + ATH_MSG_ERROR("Could not find parent CutBookkeeper with CutID " << parentCutID); + return 0; + } + + // Call the registerFilter method and get the correct CutBookkeeper + // from the returned cutID + CutIdentifier cutID = registerFilter(name, description, nominalOnly); + xAOD::CutBookkeeper* cbk = getCutBookkeeper(cutID, 0); + if (cbk == nullptr) { + ATH_MSG_ERROR("Could not find CutBookkeeper with CutID " << cutID); + return 0; + } + + // Add child to parent + parentCbk->addChild(cbk); + + return cutID; +} + + void CutFlowSvc::setFilterDescription( CutIdentifier cutID, const std::string& descr )