Skip to content
Snippets Groups Projects
Commit 4e8fd6e7 authored by Tadej Novak's avatar Tadej Novak
Browse files

Merge branch 'master-TauTruthMatchingWrapper_RWDHandles' into 'master'

Read/Write/Decor handles for TauTruthMatchingWrapper

See merge request !60651
parents d1e8a811 c6ece695
No related branches found
No related tags found
1 merge request!60651Read/Write/Decor handles for TauTruthMatchingWrapper
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -16,6 +16,8 @@
#include "DerivationFrameworkInterfaces/IAugmentationTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "TauAnalysisTools/ITauTruthMatchingTool.h"
#include "StoreGate/ReadHandleKey.h"
#include "xAODTau/TauJetContainer.h"
/**
* wrapper tool for tau truth matching
......@@ -32,11 +34,13 @@ namespace DerivationFramework {
virtual StatusCode addBranches() const;
private:
std::string m_tauContainerName;
SG::ReadHandleKey<xAOD::TauJetContainer> m_tauKey
{this, "TauContainerName", "TauJets", "ReadHandleKey for input TauJetContainer"};
ToolHandle < TauAnalysisTools::ITauTruthMatchingTool > m_tTauTruthMatchingTool;
};
}
#endif // DERIVATIONFRAMEWORK_TAUPVTRKSELECTIONTOOL_H
#endif
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -11,21 +11,23 @@
#include "xAODTracking/Vertex.h"
#include "TauAnalysisTools/ITauTruthMatchingTool.h"
#include "xAODTau/TauJetContainer.h"
#include "StoreGate/ReadHandle.h"
namespace DerivationFramework {
TauTruthMatchingWrapper::TauTruthMatchingWrapper(const std::string& t, const std::string& n, const IInterface* p) :
AthAlgTool(t,n,p),
m_tauContainerName("TauJets"),
m_tauKey("TauJets"),
m_tTauTruthMatchingTool("TauAnalysisTools::TauTruthMatchingTool")
{
declareInterface<DerivationFramework::IAugmentationTool>(this);
declareProperty("TauContainerName", m_tauContainerName);
declareProperty("TauContainerName", m_tauKey);
declareProperty("TauTruthMatchingTool", m_tTauTruthMatchingTool);
}
StatusCode TauTruthMatchingWrapper::initialize()
{
ATH_CHECK(m_tauKey.initialize());
CHECK( m_tTauTruthMatchingTool.retrieve() );
return StatusCode::SUCCESS;
}
......@@ -37,13 +39,17 @@ namespace DerivationFramework {
StatusCode TauTruthMatchingWrapper::addBranches() const
{
// retrieve container
const xAOD::TauJetContainer* xTauContainer = evtStore()->retrieve< const xAOD::TauJetContainer >( m_tauContainerName );
if( ! xTauContainer ) {
ATH_MSG_ERROR ("Couldn't retrieve tau container with key: " << m_tauContainerName );
return StatusCode::FAILURE;
// Event context
const EventContext& ctx = Gaudi::Hive::currentContext();
// Read handle
SG::ReadHandle<xAOD::TauJetContainer> xTauContainer(m_tauKey,ctx);
if (!xTauContainer.isValid()) {
ATH_MSG_ERROR("Couldn't retrieve TauJetContainer with name " << m_tauKey);
return StatusCode::FAILURE;
}
// Loop over taus
std::unique_ptr<TauAnalysisTools::ITauTruthMatchingTool::ITruthTausEvent>
truthTausEvent = m_tTauTruthMatchingTool->getEvent();
for(auto xTau : *xTauContainer)
......
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