Skip to content
Snippets Groups Projects
Commit 7d96de05 authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'master-ringerDecoratorsFix' into 'master'

fix dependency propagation for CaloRinger

See merge request atlas/athena!15935
parents ed558238 40cb68f0
No related branches found
No related tags found
No related merge requests found
......@@ -46,14 +46,7 @@ StatusCode CaloRingerAlgorithm::retrieveReaders()
ATH_MSG_INFO("Retrieving " << m_inputReaders.size() <<
" reader tools for " << name() );
for (const auto& tool : m_inputReaders)
{
if ( tool.retrieve().isFailure() )
{
ATH_MSG_FATAL( "Could not get tool: " << tool );
return StatusCode::FAILURE;
}
}
ATH_CHECK(m_inputReaders.retrieve());
return StatusCode::SUCCESS;
}
......
......@@ -222,14 +222,7 @@ StatusCode xAODRingSetConfWriter::retrieveCaloRingsBuilders()
ATH_MSG_INFO("Retrieving " << m_crBuilderTools.size() <<
" reader tools for " << name() );
for (const auto& tool : m_crBuilderTools )
{
if ( tool.retrieve().isFailure() )
{
ATH_MSG_FATAL( "Could not get tool: " << tool );
return StatusCode::FAILURE;
}
}
ATH_CHECK(m_crBuilderTools.retrieve());
return StatusCode::SUCCESS;
}
......
......@@ -40,20 +40,23 @@ StatusCode CaloRingerElectronsReader::initialize()
ATH_CHECK(m_inputElectronContainerKey.initialize());
m_selectorDecorHandleKeys.setContName(m_inputElectronContainerKey.key());
if ( m_selectorsAvailable ) {
ATH_CHECK( retrieveSelectors() );
}
// initialize the selectors
ATH_CHECK(m_selKeys.initialize());
ATH_CHECK(m_isEMKeys.initialize());
ATH_CHECK(m_lhoodKeys.initialize());
if ( m_builderAvailable ) {
// Initialize our fctor
m_clRingsBuilderElectronFctor =
new BuildCaloRingsFctor<xAOD::ElectronContainer>(
m_inputElectronContainerKey.key(),
m_crBuilder,
msg()
msg(),
this
);
ATH_CHECK( m_clRingsBuilderElectronFctor->initialize() );
}
......@@ -68,20 +71,27 @@ StatusCode CaloRingerElectronsReader::retrieveSelectors()
ATH_MSG_INFO("Retrieving " << m_ringerSelectors.size() <<
" reader tools for " << name() );
for (const auto& tool : m_ringerSelectors)
{
if ( tool.retrieve().isFailure() )
{
ATH_MSG_FATAL( "Could not get tool: " << tool );
return StatusCode::FAILURE;
}
ATH_CHECK(m_ringerSelectors.retrieve());
ATH_CHECK(m_selectorDecorHandleKeys.addSelector(tool->name()));
const std::string& contName = m_inputElectronContainerKey.key();
for (const auto& tool : m_ringerSelectors)
{
ATH_CHECK(addSelectorDeco(contName, tool->name()));
}
return StatusCode::SUCCESS;
}
// =============================================================================
StatusCode CaloRingerElectronsReader::addSelectorDeco(const std::string &contName,
const std::string &selName)
{
m_selKeys.emplace_back(contName + "." + selName);
m_isEMKeys.emplace_back(contName + "." + selName + "_isEM");
m_lhoodKeys.emplace_back(contName + "." + selName + "_output");
return StatusCode::SUCCESS;
}
// =============================================================================
StatusCode CaloRingerElectronsReader::finalize()
{
......@@ -115,7 +125,9 @@ StatusCode CaloRingerElectronsReader::execute()
StatusCode sc;
writeDecorHandles<xAOD::ElectronContainer> decoHandles(m_selectorDecorHandleKeys);
auto selHandles = m_selKeys.makeHandles();
auto isEMHandles = m_isEMKeys.makeHandles();
auto lhoodHandles = m_selKeys.makeHandles();
// Run selectors, if available:
for ( size_t i = 0; i < m_ringerSelectors.size(); i++ ) {
......@@ -142,10 +154,10 @@ StatusCode CaloRingerElectronsReader::execute()
<< std::noboolalpha << outputSpace);
// Save the bool result
decoHandles.sel(i)(*el) = static_cast<char>(accept);
selHandles[i](*el) = static_cast<char>(accept);
//// Save the resulting bitmask
decoHandles.isEM(i)(*el) = static_cast<unsigned int>(accept.getCutResultInverted());
isEMHandles[i](*el) = static_cast<unsigned int>(accept.getCutResultInverted());
// Check if output space is empty, if so, use error code
float outputToSave(std::numeric_limits<float>::min());
......@@ -154,7 +166,7 @@ StatusCode CaloRingerElectronsReader::execute()
}
// Save chain output
decoHandles.lhood(i)(*el) = outputToSave;
lhoodHandles[i](*el) = outputToSave;
}
}
......
......@@ -26,6 +26,7 @@
// StoreGate includes:
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteDecorHandleKeyArray.h"
namespace Ringer {
......@@ -76,6 +77,9 @@ class CaloRingerElectronsReader : public CaloRingerInputReader,
StatusCode retrieveSelectors();
/// @}
/** Add decorations for a given selector */
StatusCode addSelectorDeco(const std::string &contName, const std::string &selName);
/// Tool CaloRingerElectronsReader props (python configurables):
/// @{
/**
......@@ -94,8 +98,16 @@ class CaloRingerElectronsReader : public CaloRingerInputReader,
/// Tool CaloRingerElectronsReader props (non configurables):
/// @{
/// The writeDecorHandleKeys for the selectors
writeDecorHandleKeys<xAOD::ElectronContainer> m_selectorDecorHandleKeys;
/// The WriteDecorHandleKeyArrays for the selectors.
/// Need to be properties for dependency propagation.
SG::WriteDecorHandleKeyArray<xAOD::ElectronContainer, char> m_selKeys {this,
"DoNotSet_selKeys", {}, "dummy property"};
SG::WriteDecorHandleKeyArray<xAOD::ElectronContainer, unsigned int> m_isEMKeys {this,
"DoNotSet_isEMKeys", {}, "dummy property"};
SG::WriteDecorHandleKeyArray<xAOD::ElectronContainer, float> m_lhoodKeys {this,
"DoNotSet_lhoodKeys", {}, "dummy property"};
/// The CaloRings Builder functor:
BuildCaloRingsFctor<xAOD::ElectronContainer> *m_clRingsBuilderElectronFctor;
......
......@@ -13,8 +13,6 @@
#include "CaloRingerTools/ICaloRingerInputReader.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "StoreGate/WriteDecorHandleKey.h"
#include "StoreGate/WriteDecorHandle.h"
//CxxUtils for override final
#include "CxxUtils/final.h"
......@@ -82,68 +80,8 @@ class CaloRingerInputReader : public ::AthAlgTool,
"builderAvailable", false, "Whether builder tool is available."};
/// @}
template<class T> class writeDecorHandles;
/** @brief helper class to contain write docoration handle keys for selectors */
template<class T> class writeDecorHandleKeys {
public:
void setContName(const std::string &contName) {m_contName = contName;};
StatusCode addSelector(const std::string &selName);
friend class writeDecorHandles<T>;
private:
std::vector<SG::WriteDecorHandleKey<T> > m_selKeys;
std::vector<SG::WriteDecorHandleKey<T> > m_isEMKeys;
std::vector<SG::WriteDecorHandleKey<T> > m_lhoodKeys;
std::string m_contName;
};
/** @brief helper class to contain write decoration handles for selectors*/
template<class T> class writeDecorHandles {
public:
writeDecorHandles(const writeDecorHandleKeys<T>& keys); // constructor
SG::WriteDecorHandle<T, char>& sel(size_t i) {return m_sel[i];};
SG::WriteDecorHandle<T, unsigned int>& isEM(size_t i) {return m_isEM[i];};
SG::WriteDecorHandle<T, float>& lhood(size_t i) {return m_lhood[i];};
private:
std::vector<SG::WriteDecorHandle<T, char> > m_sel;
std::vector<SG::WriteDecorHandle<T, unsigned int> > m_isEM;
std::vector<SG::WriteDecorHandle<T, float> > m_lhood;
};
};
template<class T>
StatusCode
CaloRingerInputReader::writeDecorHandleKeys<T>::addSelector(const std::string &selName)
{
m_selKeys.emplace_back(m_contName + "." + selName);
ATH_CHECK(m_selKeys.back().initialize());
m_isEMKeys.emplace_back(m_contName + "." + selName + "_isEM");
ATH_CHECK(m_isEMKeys.back().initialize());
m_lhoodKeys.emplace_back(m_contName + "." + selName + "_output");
ATH_CHECK(m_lhoodKeys.back().initialize());
return StatusCode::SUCCESS;
}
template<class T>
CaloRingerInputReader::writeDecorHandles<T>::writeDecorHandles(const writeDecorHandleKeys<T>& keys)
{
for (size_t i = 0; i < keys.m_selKeys.size(); i++) {
m_sel.emplace_back(keys.m_selKeys[i]);
m_isEM.emplace_back(keys.m_isEMKeys[i]);
m_lhood.emplace_back(keys.m_lhoodKeys[i]);
}
}
} // namespace Ringer
#endif // CALORINGERTOOLS_CALORINGERINPUTREADER_H
......@@ -45,7 +45,8 @@ StatusCode CaloRingerPhotonsReader::initialize()
new BuildCaloRingsFctor<xAOD::PhotonContainer>(
m_inputPhotonContainerKey.key(),
m_crBuilder,
msg() );
msg(),
this);
ATH_CHECK( m_clRingsBuilderPhotonFctor->initialize() );
}
......
......@@ -13,6 +13,7 @@
// Athena framework include:
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/IDataHandleHolder.h"
#include "StoreGate/WriteDecorHandleKey.h"
#include "AthenaBaseComps/AthCheckMacros.h"
#include "AthContainers/DataVector.h"
......@@ -148,11 +149,13 @@ class BuildCaloRingsFctor : public BuildCaloRingsFctorBase
BuildCaloRingsFctor(
const std::string &decoContName,
ToolHandle<ICaloRingsBuilder> &builder,
MsgStream &msg)
MsgStream &msg,
IDataHandleHolder* owningAlg)
: BuildCaloRingsFctorBase(
builder,
msg),
m_decorKey( decoContName + "." + xAOD::caloRingsLinksDecorKey() ){;}
m_decorKey( decoContName + "." + xAOD::caloRingsLinksDecorKey() )
{ m_decorKey.setOwner(owningAlg);}
/// Methods
/// @{
......
......@@ -124,6 +124,7 @@ template<typename container_t>
StatusCode BuildCaloRingsFctor<container_t>::initialize()
{
ATH_CHECK( m_decorKey.initialize() );
m_decorKey.owner()->declare(m_decorKey);
return StatusCode::SUCCESS;
}
......
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