Skip to content
Snippets Groups Projects
Commit f618f19d authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'master-TauOverlappingElectronLLHDecorator-DataHandle' into 'master'

TauOverlappingElectronLLHDecorator data handle migration

See merge request atlas/athena!16695

Former-commit-id: 093199e6
parents 132d6b76 e0a9d103
No related branches found
No related tags found
No related merge requests found
...@@ -23,8 +23,6 @@ using namespace TauAnalysisTools; ...@@ -23,8 +23,6 @@ using namespace TauAnalysisTools;
TauOverlappingElectronLLHDecorator::TauOverlappingElectronLLHDecorator( const std::string& name ) TauOverlappingElectronLLHDecorator::TauOverlappingElectronLLHDecorator( const std::string& name )
: asg::AsgMetadataTool( name ) : asg::AsgMetadataTool( name )
, m_tEMLHTool(0) , m_tEMLHTool(0)
, m_xElectronContainer(0)
, m_sElectronContainerName("Electrons")
, m_bElectonsAvailable(true) , m_bElectonsAvailable(true)
, m_hCutValues(0) , m_hCutValues(0)
, m_bEleOLRMatchAvailable(false) , m_bEleOLRMatchAvailable(false)
...@@ -40,7 +38,6 @@ TauOverlappingElectronLLHDecorator::TauOverlappingElectronLLHDecorator( const st ...@@ -40,7 +38,6 @@ TauOverlappingElectronLLHDecorator::TauOverlappingElectronLLHDecorator( const st
{ {
m_sEleOLRFilePath = "TauAnalysisTools/"+std::string(sSharedFilesVersion)+"/Selection/eveto_cutvals.root"; m_sEleOLRFilePath = "TauAnalysisTools/"+std::string(sSharedFilesVersion)+"/Selection/eveto_cutvals.root";
declareProperty( "ElectronContainerName", m_sElectronContainerName);
declareProperty( "EleOLRFilePath", m_sEleOLRFilePath); declareProperty( "EleOLRFilePath", m_sEleOLRFilePath);
} }
...@@ -55,6 +52,10 @@ TauOverlappingElectronLLHDecorator::~TauOverlappingElectronLLHDecorator() ...@@ -55,6 +52,10 @@ TauOverlappingElectronLLHDecorator::~TauOverlappingElectronLLHDecorator()
StatusCode TauOverlappingElectronLLHDecorator::initialize() StatusCode TauOverlappingElectronLLHDecorator::initialize()
{ {
ATH_MSG_INFO( "Initializing TauOverlappingElectronLLHDecorator" ); ATH_MSG_INFO( "Initializing TauOverlappingElectronLLHDecorator" );
// This will check that the properties were initialized properly
ATH_CHECK( m_sElectronContainerName.initialize() );
// create a EM LH tool // create a EM LH tool
m_tEMLHTool = new AsgElectronLikelihoodTool (name()+"_ELHTool"); m_tEMLHTool = new AsgElectronLikelihoodTool (name()+"_ELHTool");
ATH_CHECK(m_tEMLHTool->setProperty("OutputLevel", msg().level() )); ATH_CHECK(m_tEMLHTool->setProperty("OutputLevel", msg().level() ));
...@@ -103,7 +104,6 @@ StatusCode TauOverlappingElectronLLHDecorator::decorate(const xAOD::TauJet& xTau ...@@ -103,7 +104,6 @@ StatusCode TauOverlappingElectronLLHDecorator::decorate(const xAOD::TauJet& xTau
{ {
if (m_bNewEvent) if (m_bNewEvent)
{ {
ATH_CHECK(retrieveElectrons());
m_bNewEvent = false; m_bNewEvent = false;
m_bEleOLRMatchAvailable = (xTau.isAvailable<char>(m_sEleOlrPassDecorationName) || xTau.isAvailable<float>(m_sEleOlrLhScoreDecorationName)); m_bEleOLRMatchAvailable = (xTau.isAvailable<char>(m_sEleOlrPassDecorationName) || xTau.isAvailable<float>(m_sEleOlrLhScoreDecorationName));
...@@ -115,13 +115,18 @@ StatusCode TauOverlappingElectronLLHDecorator::decorate(const xAOD::TauJet& xTau ...@@ -115,13 +115,18 @@ StatusCode TauOverlappingElectronLLHDecorator::decorate(const xAOD::TauJet& xTau
if (m_bEleOLRMatchAvailable) if (m_bEleOLRMatchAvailable)
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
SG::ReadHandle<xAOD::ElectronContainer> h_ElectronContainer(m_sElectronContainerName);
if (!h_ElectronContainer.isValid()) {
ATH_MSG_FATAL("Electron container with name " << m_sElectronContainerName << " was not found in event store, but is needed for electron OLR. Ensure that it is there with the correct name");
return StatusCode::FAILURE;
}
const xAOD::Electron * xEleMatch = 0; const xAOD::Electron * xEleMatch = 0;
float fLHScore = -4.; // default if no match was found float fLHScore = -4.; // default if no match was found
float fEleMatchPt = -1.; float fEleMatchPt = -1.;
// find electron with pt>5GeV within 0.4 cone with largest pt // find electron with pt>5GeV within 0.4 cone with largest pt
for( auto xElectron : *(m_xElectronContainer) ) for( const auto& xElectron : *h_ElectronContainer )
{ {
if(xElectron->pt() < 5000.) continue; if(xElectron->pt() < 5000.) continue;
if(xElectron->p4().DeltaR( xTau.p4() ) > 0.4 ) continue; if(xElectron->p4().DeltaR( xTau.p4() ) > 0.4 ) continue;
...@@ -206,11 +211,3 @@ StatusCode TauOverlappingElectronLLHDecorator::beginEvent() ...@@ -206,11 +211,3 @@ StatusCode TauOverlappingElectronLLHDecorator::beginEvent()
} }
//______________________________________________________________________________ //______________________________________________________________________________
StatusCode TauOverlappingElectronLLHDecorator::retrieveElectrons() const
{
if (evtStore()->contains<xAOD::ElectronContainer>(m_sElectronContainerName))
if ( evtStore()->retrieve(m_xElectronContainer,m_sElectronContainerName).isSuccess() )
return StatusCode::SUCCESS;
ATH_MSG_FATAL("Electron container with name " << m_sElectronContainerName << " was not found in event store, but is needed for electron OLR. Ensure that it is there with the correct name");
return StatusCode::FAILURE;
}
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
// Local include(s): // Local include(s):
#include "TauAnalysisTools/ITauOverlappingElectronLLHDecorator.h" #include "TauAnalysisTools/ITauOverlappingElectronLLHDecorator.h"
#include "StoreGate/ReadHandleKey.h"
// ROOT include(s): // ROOT include(s):
#include "TH2D.h" #include "TH2D.h"
...@@ -64,15 +65,13 @@ public: ...@@ -64,15 +65,13 @@ public:
private: private:
AsgElectronLikelihoodTool* m_tEMLHTool; AsgElectronLikelihoodTool* m_tEMLHTool;
mutable const xAOD::ElectronContainer* m_xElectronContainer; SG::ReadHandleKey<xAOD::ElectronContainer> m_sElectronContainerName { this, "ElectronContainerName", "Electrons", "Input electron container"};
std::string m_sElectronContainerName;
bool m_bElectonsAvailable; bool m_bElectonsAvailable;
std::string m_sEleOLRFilePath; std::string m_sEleOLRFilePath;
TH2D* m_hCutValues; TH2D* m_hCutValues;
private: private:
float getCutVal(float fEta, float fPt) const; float getCutVal(float fEta, float fPt) const;
StatusCode retrieveElectrons() const;
virtual StatusCode beginEvent(); virtual StatusCode beginEvent();
private: private:
......
...@@ -162,7 +162,7 @@ namespace met { ...@@ -162,7 +162,7 @@ namespace met {
SG::ReadHandle<xAOD::ElectronContainer> Electrons(m_ElectronContainerKey); SG::ReadHandle<xAOD::ElectronContainer> Electrons(m_ElectronContainerKey);
if (!Electrons.isValid()) { if (!Electrons.isValid()) {
ATH_MSG_WARNING("Unable to retrieve ElectronContainer: " << Electrons.key()); ATH_MSG_WARNING("Unable to retrieve ElectronContainer: " << Electrons.key());
return StatusCode::SUCCESS; return StatusCode::FAILURE;
} }
/// Photons /// Photons
......
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