diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx index 8de567057700fdaeb175621923d3ad86e4305a43..f7a8c104d090de6cc3bd4786736c612e93f51d61 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 a4f0a384c00445eb92a221c179933e10f0039d46..eb65cc8ee14b26cf428560ad8d2c87c5b4d298e2 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()) {