From 47f80dd9af70326973b24de27749cf321adc02e3 Mon Sep 17 00:00:00 2001 From: Tadej Novak <tadej.novak@cern.ch> Date: Tue, 5 Jan 2021 12:43:47 +0100 Subject: [PATCH] Adapt TauTruthMatchingTool for DAOD_PHYS --- .../TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx | 6 +++--- .../TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx index 8de56705770..f7a8c104d09 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx @@ -75,11 +75,11 @@ TauTruthMatchingTool::getTruth(const xAOD::TauJet& xTau, // if matched to a truth tau return its pointer, else return a null pointer static SG::AuxElement::ConstAccessor<char> accIsTruthMatched("IsTruthMatched"); - if ((bool)accIsTruthMatched(xTau)) + static SG::AuxElement::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > accTruthTau("truthParticleLink"); + if ((accIsTruthMatched.isAvailable(xTau) && accIsTruthMatched(xTau)) || accTruthTau.isAvailable(xTau)) { if (m_bWriteTruthTaus or m_bTruthTauAvailable) { - static SG::AuxElement::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > accTruthTau("truthParticleLink"); if (accTruthTau(xTau).isValid()) { return *accTruthTau(xTau); @@ -340,7 +340,7 @@ StatusCode TauTruthMatchingTool::findTruthTau(const xAOD::TauJet& xTau, { // check if decorations were already added to the first passed tau if (!m_bIsTruthMatchedAvailable.isValid()) { - bool avail = xTau.isAvailable<char>("IsTruthMatched"); + bool avail = xTau.isAvailable<char>("IsTruthMatched") || xTau.isAvailable<ElementLink< xAOD::TruthParticleContainer >>("truthParticleLink"); m_bIsTruthMatchedAvailable.set (avail); } if (*m_bIsTruthMatchedAvailable.ptr()) diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx index a4f0a384c00..eb65cc8ee14 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx @@ -76,6 +76,7 @@ int main( int argc, char* argv[] ) // =========================================================================== ToolHandle<TauAnalysisTools::ITauTruthMatchingTool> T2MT( "TauAnalysisTools::TauTruthMatchingTool/TauTruthMatchingTool"); ANA_CHECK(AthAnalysisHelper::setProperty(T2MT, "WriteTruthTaus", true)); + ANA_CHECK(AthAnalysisHelper::setProperty(T2MT, "TruthJetContainerName", "AntiKt4TruthDressedWZJets")); ANA_CHECK(T2MT.retrieve()); // =========================================================================== @@ -117,7 +118,8 @@ int main( int argc, char* argv[] ) << ", prong = " << int(xTau->nTracks()) << ", charge = " << int(xTau->charge())); - if ((bool)xTau->auxdata<char>("IsTruthMatched") && (xTruthTau != nullptr)) + bool avail = xTau->isAvailable<char>("IsTruthMatched") || xTau->isAvailable<ElementLink< xAOD::TruthParticleContainer >>("truthParticleLink"); + if (avail && (xTruthTau != nullptr)) { if (xTruthTau->isTau()) { -- GitLab