diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonDiTauEfficiencyTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonDiTauEfficiencyTool.cxx index 6ff38841f8739a51b2b53d5c91723ad1a31b49ca..99f69f94852924a8c9cd65df7826ac4faec5032d 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonDiTauEfficiencyTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonDiTauEfficiencyTool.cxx @@ -1,5 +1,5 @@ /** - * @copyright Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + * @copyright Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // Framework include(s): @@ -9,6 +9,7 @@ #include "TauAnalysisTools/CommonDiTauEfficiencyTool.h" #include "TauAnalysisTools/TauEfficiencyCorrectionsTool.h" #include "xAODTruth/TruthParticleContainer.h" +#include "AthContainers/Decorator.h" // ROOT include(s) #include "TH2F.h" @@ -155,7 +156,7 @@ CP::CorrectionCode CommonDiTauEfficiencyTool::getEfficiencyScaleFactor(const xAO e.g. if the variable was already decorated on a previous step (enured by the m_bSFIsAvailableCheckedDiTau check). - Technical note: cannot use `static SG::AuxElement::Decorator` as we will have + Technical note: cannot use `static SG::Decorator` as we will have multiple instances of this tool with different decoration names. */ //______________________________________________________________________________ @@ -164,9 +165,10 @@ CP::CorrectionCode CommonDiTauEfficiencyTool::applyEfficiencyScaleFactor(const x { double dSf = 0.; + SG::Decorator< double > decor (m_sVarName); if (!m_bSFIsAvailableCheckedDiTau) { - m_bSFIsAvailableDiTau = xDiTau.isAvailable< double >(m_sVarName); + m_bSFIsAvailableDiTau = decor.isAvailable(xDiTau); m_bSFIsAvailableCheckedDiTau = true; if (m_bSFIsAvailableDiTau) { @@ -177,10 +179,10 @@ CP::CorrectionCode CommonDiTauEfficiencyTool::applyEfficiencyScaleFactor(const x if (m_bSFIsAvailableDiTau) return CP::CorrectionCode::Ok; - // retreive scale factor + // retrieve scale factor CP::CorrectionCode tmpCorrectionCode = getEfficiencyScaleFactor(xDiTau, dSf, iRunNumber, iMu); // adding scale factor to tau as decoration - xDiTau.auxdecor<double>(m_sVarName) = dSf; + decor(xDiTau) = dSf; return tmpCorrectionCode; } @@ -324,7 +326,7 @@ CP::CorrectionCode CommonDiTauEfficiencyTool::getValue(const std::string& sHistN double TauAnalysisTools::TruthLeadPt(const xAOD::DiTauJet& xDiTau) { // return leading truth tau pt in GeV - static const SG::AuxElement::ConstAccessor< double > acc( "TruthVisLeadPt" ); + static const SG::ConstAccessor< double > acc( "TruthVisLeadPt" ); return acc( xDiTau ) * 0.001; } @@ -332,7 +334,7 @@ double TauAnalysisTools::TruthLeadPt(const xAOD::DiTauJet& xDiTau) double TauAnalysisTools::TruthSubleadPt(const xAOD::DiTauJet& xDiTau) { // return subleading truth tau pt in GeV - static const SG::AuxElement::ConstAccessor< double > acc( "TruthVisSubleadPt" ); + static const SG::ConstAccessor< double > acc( "TruthVisSubleadPt" ); return acc( xDiTau ) * 0.001; } @@ -340,6 +342,6 @@ double TauAnalysisTools::TruthSubleadPt(const xAOD::DiTauJet& xDiTau) double TauAnalysisTools::TruthDeltaR(const xAOD::DiTauJet& xDiTau) { // return truth taus distance delta R - static const SG::AuxElement::ConstAccessor< double > acc( "TruthVisDeltaR" ); + static const SG::ConstAccessor< double > acc( "TruthVisDeltaR" ); return acc( xDiTau ); } diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonEfficiencyTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonEfficiencyTool.cxx index 48b8813634ff88f1add7873ae2d589b039a48beb..c7ce70f0e38c077f5a5cf93763e83fd44c93cb96 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonEfficiencyTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonEfficiencyTool.cxx @@ -9,6 +9,7 @@ #include "TauAnalysisTools/CommonEfficiencyTool.h" #include "TauAnalysisTools/TauEfficiencyCorrectionsTool.h" #include "xAODTruth/TruthParticleContainer.h" +#include "AthContainers/Decorator.h" // ROOT include(s) #include "TF1.h" @@ -271,7 +272,7 @@ CP::CorrectionCode CommonEfficiencyTool::getEfficiencyScaleFactor(const xAOD::Ta e.g. if the variable was already decorated on a previous step (enured by the m_bSFIsAvailableChecked check). - Technical note: cannot use `static SG::AuxElement::Decorator` as we will have + Technical note: cannot use `static SG::Decorator` as we will have multiple instances of this tool with different decoration names. */ //______________________________________________________________________________ @@ -280,9 +281,10 @@ CP::CorrectionCode CommonEfficiencyTool::applyEfficiencyScaleFactor(const xAOD:: { double dSf = 0.; + SG::Decorator< double > decor (m_sVarName); if (!m_bSFIsAvailableChecked) { - m_bSFIsAvailable = xTau.isAvailable< double >(m_sVarName); + m_bSFIsAvailable = decor.isAvailable(xTau); m_bSFIsAvailableChecked = true; if (m_bSFIsAvailable) { @@ -296,7 +298,7 @@ CP::CorrectionCode CommonEfficiencyTool::applyEfficiencyScaleFactor(const xAOD:: // retrieve scale factor CP::CorrectionCode tmpCorrectionCode = getEfficiencyScaleFactor(xTau, dSf, iRunNumber, iMu); // adding scale factor to tau as decoration - xTau.auxdecor<double>(m_sVarName) = dSf; + decor(xTau) = dSf; return tmpCorrectionCode; } diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx index 18b35c940435a3171136d01622cdca1cc7dc0ba2..8deb51650d1b699a6d947a00a8ad9de17cdf40dc 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx @@ -1,9 +1,10 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // Framework include(s): #include "PathResolver/PathResolver.h" +#include "AthContainers/ConstAccessor.h" // local include(s) #include "TauAnalysisTools/CommonSmearingTool.h" @@ -153,8 +154,9 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) con // WARNING: overwriting ptFinalCalib would lead to irreproducibilities upon re-calibration (re-apply in-situ TES on already-calibrated PHYSLITE) if (m_bApplyMVATESQualityCheck) { - bool useCaloPt = false; - if(xTau.isAvailable<float>("ptTauEnergyScale")) { + bool useCaloPt = false; + static const SG::ConstAccessor<float> accPtTauEnergyScale ("ptTauEnergyScale"); + if(accPtTauEnergyScale.isAvailable(xTau)) { const auto combinedTEStool = dynamic_cast<const TauCombinedTES*>(m_tTauCombinedTES.get()); useCaloPt = combinedTEStool->getUseCaloPtFlag(xTau); if (useCaloPt) { @@ -164,7 +166,7 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) con xTau.setP4(xTau.ptTauEnergyScale(), xTau.eta(), xTau.phi(), xTau.m()); } } - static const SG::AuxElement::Accessor<char> accUseCaloPt("useCaloPt"); + static const SG::Accessor<char> accUseCaloPt("useCaloPt"); accUseCaloPt(xTau) = char(useCaloPt); } diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/DiTauTruthMatchingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/DiTauTruthMatchingTool.cxx index cbb74e9009c9d1c79128affc87e1216c0e2abda2..6f6f3d6788d84ae0b524dd86e4defa1795609d9a 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/DiTauTruthMatchingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/DiTauTruthMatchingTool.cxx @@ -13,6 +13,8 @@ // Core include(s): #include "AthLinks/ElementLink.h" #include "TruthUtils/HepMCHelpers.h" +#include "AthContainers/ConstAccessor.h" +#include "AthContainers/Decorator.h" // EDM include(s): #include "xAODEgamma/ElectronContainer.h" @@ -86,8 +88,8 @@ StatusCode DiTauTruthMatchingTool::findTruthTau(const xAOD::DiTauJet& xDiTau) { // check if decorations were already added to the first passed tau if (!m_bIsTruthMatchedAvailable.isValid()) { - bool avail = xDiTau.isAvailable<char>("IsTruthMatched"); - m_bIsTruthMatchedAvailable.set (avail); + static const SG::ConstAccessor<char> accIsTruthMatched("IsTruthMatched"); + m_bIsTruthMatchedAvailable.set (accIsTruthMatched.isAvailable(xDiTau)); } if (*m_bIsTruthMatchedAvailable.ptr()) return StatusCode::SUCCESS; @@ -106,12 +108,12 @@ StatusCode DiTauTruthMatchingTool::checkTruthMatch (const xAOD::DiTauJet& xDiTau xAOD::TruthParticleContainer xRemainingTruthTaus = xTruthTauContainer; - static const SG::AuxElement::Decorator<char> decIsTruthMatched("IsTruthMatched"); - static const SG::AuxElement::Decorator<char> decIsTruthHadronic("IsTruthHadronic"); - static const SG::AuxElement::Decorator<char> decIsTruthHadMu("IsTruthHadMu"); - static const SG::AuxElement::Decorator<char> decIsTruthHadEl("IsTruthHadEl"); - static const SG::AuxElement::ConstAccessor<int> accNSubjets("n_subjets"); - static const SG::AuxElement::ConstAccessor<char> accIsTruthHadronic("IsTruthHadronic"); + static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched"); + static const SG::Decorator<char> decIsTruthHadronic("IsTruthHadronic"); + static const SG::Decorator<char> decIsTruthHadMu("IsTruthHadMu"); + static const SG::Decorator<char> decIsTruthHadEl("IsTruthHadEl"); + static const SG::ConstAccessor<int> accNSubjets("n_subjets"); + static const SG::ConstAccessor<char> accIsTruthHadronic("IsTruthHadronic"); // set default values for each subjet for (int i = 0; i < accNSubjets(xDiTau); ++i) @@ -182,39 +184,42 @@ StatusCode DiTauTruthMatchingTool::checkTruthMatch (const xAOD::DiTauJet& xDiTau if (i == 0 || i == 1) bTruthMatched = false; } } - - xDiTau.auxdecor<std::vector<ElementLink<xAOD::TruthParticleContainer>>>("truthParticleLinks") = vTruthLinks; + + static const SG::Decorator<std::vector<ElementLink<xAOD::TruthParticleContainer>>> + decTruthParticleLinks ("truthParticleLinks"); + decTruthParticleLinks(xDiTau) = vTruthLinks; if (!m_bTruthTauAvailable) { - xDiTau.auxdecor<std::vector<ElementLink<xAOD::TruthParticleContainer>>>("TruthTaus") = vTruthLinks; + static const SG::Decorator<std::vector<ElementLink<xAOD::TruthParticleContainer>>> + decTruthTaus ("TruthTaus"); + decTruthTaus(xDiTau) = vTruthLinks; } ElementLink<xAOD::TruthParticleContainer> lTruthLeptonLink; - static const SG::AuxElement::Decorator<unsigned int> decClassifierParticleType("classifierParticleTypeTruthLepton"); - static const SG::AuxElement::Decorator<unsigned int> decClassifierParticleOrigin("classifierParticleOriginTruthLepton"); - static const SG::AuxElement::Decorator<ElementLink<xAOD::TruthParticleContainer>> decTruthLeptonLink("truthLeptonLink"); + static const SG::Decorator<unsigned int> decClassifierParticleType("classifierParticleTypeTruthLepton"); + static const SG::Decorator<unsigned int> decClassifierParticleOrigin("classifierParticleOriginTruthLepton"); + static const SG::Decorator<ElementLink<xAOD::TruthParticleContainer>> decTruthLeptonLink("truthLeptonLink"); int mcTruthType = MCTruthPartClassifier::ParticleType::Unknown; int mcTruthOrigin = MCTruthPartClassifier::ParticleOrigin::NonDefined; - static const SG::AuxElement::ConstAccessor<int> accTruthType("truthType"); - static const SG::AuxElement::ConstAccessor<int> accTruthOrigin("truthOrigin"); - if(xDiTau.isAvailable<ElementLink<xAOD::ElectronContainer>>("elLink") && - xDiTau.isAvailable<ElementLink<xAOD::MuonContainer>>("muonLink")) + static const SG::ConstAccessor<int> accTruthType("truthType"); + static const SG::ConstAccessor<int> accTruthOrigin("truthOrigin"); + static const SG::ConstAccessor<ElementLink<xAOD::ElectronContainer>> accElLink("elLink"); + static const SG::ConstAccessor<ElementLink<xAOD::MuonContainer>> accMuLink("muonLink"); + if(accElLink.isAvailable(xDiTau) && accMuLink.isAvailable(xDiTau)) ATH_MSG_ERROR("Links to reco electron and reco muon available for one ditau candidate."); - if(xDiTau.isAvailable<ElementLink<xAOD::ElectronContainer>>("elLink")){ - static const SG::AuxElement::ConstAccessor<ElementLink<xAOD::ElectronContainer>> accElLink("elLink"); + if(accElLink.isAvailable(xDiTau)){ const xAOD::Electron* pElectron = *accElLink(xDiTau); - if ((pElectron->isAvailable<int>("truthType") && pElectron->isAvailable<int>("truthOrigin"))) + if ((accTruthType.isAvailable(*pElectron) && accTruthOrigin.isAvailable(*pElectron))) { mcTruthType = accTruthType(*pElectron); mcTruthOrigin = accTruthOrigin(*pElectron); } lTruthLeptonLink = checkTruthLepton(pElectron); } - if(xDiTau.isAvailable<ElementLink<xAOD::MuonContainer>>("muonLink")){ - static const SG::AuxElement::ConstAccessor<ElementLink<xAOD::MuonContainer>> accMuLink("muonLink"); + if(accMuLink.isAvailable(xDiTau)){ const xAOD::Muon* pMuon = *accMuLink(xDiTau); - if (pMuon->isAvailable<int>("truthType") && pMuon->isAvailable<int>("truthOrigin")) + if (accTruthType.isAvailable(*pMuon) && accTruthOrigin.isAvailable(*pMuon)) { mcTruthType = accTruthType(*pMuon); mcTruthOrigin = accTruthOrigin(*pMuon); @@ -246,16 +251,16 @@ StatusCode DiTauTruthMatchingTool::checkTruthMatch (const xAOD::DiTauJet& xDiTau decIsTruthHadronic(xDiTau) = (char)false; - static const SG::AuxElement::Decorator<double> decTruthLeadPt("TruthVisLeadPt"); - static const SG::AuxElement::Decorator<double> decTruthLeadEta("TruthVisLeadEta"); - static const SG::AuxElement::Decorator<double> decTruthLeadPhi("TruthVisLeadPhi"); - static const SG::AuxElement::Decorator<double> decTruthLeadM("TruthVisLeadM"); - static const SG::AuxElement::Decorator<double> decTruthSubleadPt("TruthVisSubleadPt"); - static const SG::AuxElement::Decorator<double> decTruthSubleadEta("TruthVisSubleadEta"); - static const SG::AuxElement::Decorator<double> decTruthSubleadPhi("TruthVisSubleadPhi"); - static const SG::AuxElement::Decorator<double> decTruthSubleadM("TruthVisSubleadM"); - static const SG::AuxElement::Decorator<double> decTruthDeltaR("TruthVisDeltaR"); - static const SG::AuxElement::Decorator<double> decTruthMass("TruthVisMass"); + static const SG::Decorator<double> decTruthLeadPt("TruthVisLeadPt"); + static const SG::Decorator<double> decTruthLeadEta("TruthVisLeadEta"); + static const SG::Decorator<double> decTruthLeadPhi("TruthVisLeadPhi"); + static const SG::Decorator<double> decTruthLeadM("TruthVisLeadM"); + static const SG::Decorator<double> decTruthSubleadPt("TruthVisSubleadPt"); + static const SG::Decorator<double> decTruthSubleadEta("TruthVisSubleadEta"); + static const SG::Decorator<double> decTruthSubleadPhi("TruthVisSubleadPhi"); + static const SG::Decorator<double> decTruthSubleadM("TruthVisSubleadM"); + static const SG::Decorator<double> decTruthDeltaR("TruthVisDeltaR"); + static const SG::Decorator<double> decTruthMass("TruthVisMass"); if (accIsTruthHadronic(xDiTau)) { @@ -301,10 +306,10 @@ StatusCode DiTauTruthMatchingTool::checkTruthMatch (const xAOD::DiTauJet& xDiTau //______________________________________________________________________________ ElementLink<xAOD::TruthParticleContainer> DiTauTruthMatchingTool::checkTruthLepton(const xAOD::IParticle* pLepton) const { ElementLink<xAOD::TruthParticleContainer> truthParticleLink; - if(!pLepton->isAvailable<ElementLink<xAOD::TruthParticleContainer>>("truthParticleLink")){ + static const SG::ConstAccessor<ElementLink<xAOD::TruthParticleContainer>> accTruthParticleLink("truthParticleLink"); + if(!accTruthParticleLink.isAvailable(*pLepton)){ return truthParticleLink; } - static const SG::AuxElement::ConstAccessor<ElementLink<xAOD::TruthParticleContainer>> accTruthParticleLink("truthParticleLink"); truthParticleLink = accTruthParticleLink(*pLepton); return truthParticleLink; } @@ -324,7 +329,7 @@ StatusCode DiTauTruthMatchingTool::truthMatch(const TLorentzVector& vSubjetTLV, m_accMVis(*xTruthTauIt)); if (vSubjetTLV.DeltaR(vTruthVisTLV) <= m_dMaxDeltaR) { - static const SG::AuxElement::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); + static const SG::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); if ((bool)accIsHadronicTau(*xTruthTauIt)) eTruthMatchedParticleType = TruthHadronicTau; else diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx index 14823dc0591b3be86d43768b27e1ad5e73445798..53b0193de8b8f58670099a20a8bf728f37ec464d 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx @@ -7,6 +7,7 @@ // local include(s) #include "TauAnalysisTools/HelperFunctions.h" #include "TruthUtils/HepMCHelpers.h" +#include "AthContainers/ConstAccessor.h" #include "TF1.h" #ifdef ASGTOOL_ATHENA @@ -160,7 +161,8 @@ double TauAnalysisTools::truthTauPt(const xAOD::TauJet& xTau) const xAOD::TruthParticle* xTruthTau = getTruth(xTau); // if there is a truth tau return pT, otherwise return 0 (getTruth will print an error) - if (xTruthTau!=nullptr && xTruthTau->auxdata<char>("IsHadronicTau")) + static const SG::ConstAccessor<char> accIsHadronicTau ("IsHadronicTau"); + if (xTruthTau!=nullptr && accIsHadronicTau (*xTruthTau)) return xTruthTau->pt()/GeV; else return 0.; @@ -173,7 +175,8 @@ double TauAnalysisTools::truthTauAbsEta(const xAOD::TauJet& xTau) const xAOD::TruthParticle* xTruthTau = getTruth(xTau); // if there is a truth tau return absolute eta, otherwise return -5 (getTruth will print an error) - if (xTruthTau!=nullptr && xTruthTau->auxdata<char>("IsHadronicTau")) + static const SG::ConstAccessor<char> accIsHadronicTau ("IsHadronicTau"); + if (xTruthTau!=nullptr && accIsHadronicTau (*xTruthTau)) return std::abs(xTruthTau->eta()); else return -5.; @@ -191,12 +194,12 @@ double TauAnalysisTools::truthDecayMode(const xAOD::TauJet& xTau) const xAOD::TruthParticle* TauAnalysisTools::getTruth(const xAOD::TauJet& xTau) { typedef ElementLink< xAOD::TruthParticleContainer > Link_t; - if (!xTau.isAvailable< Link_t >("truthParticleLink")) + static const SG::ConstAccessor<Link_t> accTruthParticleLink("truthParticleLink"); + if (!accTruthParticleLink(xTau)) { Error("TauAnalysisTools::getTruth", "No truth match information available. Please run TauTruthMatchingTool first"); } - static const SG::AuxElement::ConstAccessor<Link_t> accTruthParticleLink("truthParticleLink"); const Link_t xTruthTauLink = accTruthParticleLink(xTau); const xAOD::TruthParticle* xTruthTau = xTruthTauLink.cachedElement(); @@ -209,7 +212,8 @@ xAOD::TauJetParameters::DecayMode TauAnalysisTools::getTruthDecayMode(const xAOD { const xAOD::TruthParticle* xTruthTau = getTruth(xTau); - if (xTruthTau!=nullptr && xTruthTau->auxdata<char>("IsHadronicTau")) + static const SG::ConstAccessor<char> accIsHadronicTau ("IsHadronicTau"); + if (xTruthTau!=nullptr && accIsHadronicTau(*xTruthTau)) return getTruthDecayMode(*xTruthTau); else return xAOD::TauJetParameters::Mode_Error; @@ -218,7 +222,8 @@ xAOD::TauJetParameters::DecayMode TauAnalysisTools::getTruthDecayMode(const xAOD //______________________________________________________________________________ xAOD::TauJetParameters::DecayMode TauAnalysisTools::getTruthDecayMode(const xAOD::TruthParticle& xTruthTau) { - if (!(xTruthTau.isAvailable<size_t>("numCharged"))) + static const SG::ConstAccessor<size_t> accNumCharged ("numCharged"); + if (!(accNumCharged.isAvailable(xTruthTau))) { // passed truth particle is not a truth tau return xAOD::TauJetParameters::Mode_Error; @@ -251,13 +256,13 @@ xAOD::TauJetParameters::DecayMode TauAnalysisTools::getTruthDecayMode(const xAOD int TauAnalysisTools::getNTauDecayParticles(const xAOD::TruthParticle& xTruthTau, int iPdgId, bool bCompareAbsoluteValues) { int iNum = 0; - if (!xTruthTau.isAvailable<std::vector<int>>("DecayModeVector")) + static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector"); + if (!accDecayModeVector.isAvailable(xTruthTau)) { Warning("TauAnalysisTools::getNTauDecayParticles", "passed truth particle is not a truth tau, return 0"); return 0; } - static const SG::AuxElement::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector"); for(auto iPdgId2 : accDecayModeVector(xTruthTau)) if (!bCompareAbsoluteValues) { @@ -545,16 +550,17 @@ void TauAnalysisTools::truthHadrons(const xAOD::TauJet* xTau, std::vector<const // check if reco tau is a truth hadronic tau typedef ElementLink< xAOD::TruthParticleContainer > Link_t; - if (!xTau->isAvailable< Link_t >("truthParticleLink")) + static const SG::ConstAccessor<Link_t> accTruthParticleLink("truthParticleLink"); + if (!accTruthParticleLink.isAvailable(*xTau)) { Error("TauAnalysisTools::truthHadrons", "No truth match information available. Please run TauTruthMatchingTool first"); } - static const SG::AuxElement::ConstAccessor<Link_t> accTruthParticleLink("truthParticleLink"); const Link_t xTruthTauLink = accTruthParticleLink(*xTau); const xAOD::TruthParticle* xTruthTau = xTruthTauLink.cachedElement(); - if (xTruthTau!=nullptr && xTruthTau->auxdata<char>("IsHadronicTau")) + static const SG::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); + if (xTruthTau!=nullptr && accIsHadronicTau(*xTruthTau)) { truthHadrons(xTruthTau, vChargedHadrons, vNeutralHadrons); } @@ -566,7 +572,8 @@ void TauAnalysisTools::truthHadrons(const xAOD::TauJet* xTau, std::vector<const TruthMatchedParticleType TauAnalysisTools::getTruthParticleType(const xAOD::TauJet& xTau) { typedef ElementLink< xAOD::TruthParticleContainer > Link_t; - if (!xTau.isAvailable< Link_t >("truthParticleLink")) + static const SG::ConstAccessor< Link_t > accTruthParticleLink("truthParticleLink"); + if (!accTruthParticleLink.isAvailable(xTau)) Error("TauAnalysisTools::getTruthParticleType", "No truth match information available. Please run TauTruthMatchingTool first."); const xAOD::TruthParticle* xTruthParticle = xAOD::TauHelpers::getTruthParticle(&xTau); @@ -574,7 +581,7 @@ TruthMatchedParticleType TauAnalysisTools::getTruthParticleType(const xAOD::TauJ { if (xTruthParticle->isTau()) { - static const SG::AuxElement::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); + static const SG::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); if ((bool)accIsHadronicTau(*xTruthParticle)) return TruthHadronicTau; else @@ -588,7 +595,7 @@ TruthMatchedParticleType TauAnalysisTools::getTruthParticleType(const xAOD::TauJ // TODO: use const xAOD::Jet* xTruthJet = xAOD::TauHelpers::getLink<xAOD::Jet>(&xTau, "truthJetLink"); // currently it is unavailable as templated class is not in icc file - static const SG::AuxElement::ConstAccessor< ElementLink< xAOD::JetContainer > > accTruthJetLink("truthJetLink"); + static const SG::ConstAccessor< ElementLink< xAOD::JetContainer > > accTruthJetLink("truthJetLink"); const ElementLink< xAOD::JetContainer > lTruthParticleLink = accTruthJetLink(xTau); if (lTruthParticleLink.isValid()) return TruthJet; @@ -598,9 +605,9 @@ TruthMatchedParticleType TauAnalysisTools::getTruthParticleType(const xAOD::TauJ TruthMatchedParticleType TauAnalysisTools::getTruthParticleType(const xAOD::DiTauJet& xDiTau) { - if (!xDiTau.isAvailable<char>("IsTruthHadronic")) + static const SG::ConstAccessor<char> accIsTruthHadronic("IsTruthHadronic"); + if (!accIsTruthHadronic.isAvailable(xDiTau)) Error("TauAnalysisTools::getTruthParticleType", "No truth match information available. Please run DiTauTruthMatchingTool first"); - static const SG::AuxElement::ConstAccessor<char> accIsTruthHadronic("IsTruthHadronic"); TruthMatchedParticleType eTruthMatchedParticleType = Unknown; diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSelectionCuts.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSelectionCuts.cxx index 3c3568c7014462b6c8a19f2b639ef1b5a57e8edf..523bbbc7e0e627b0b3289e769cfaad2425fdcc5d 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSelectionCuts.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSelectionCuts.cxx @@ -9,6 +9,7 @@ // framework include(s) #include "AsgDataHandles/ReadHandle.h" +#include "AthContainers/ConstAccessor.h" // EDM include(s) #include "xAODMuon/MuonContainer.h" @@ -366,22 +367,22 @@ bool TauSelectionCutJetIDWP::accept(const xAOD::TauJet& xTau, if (xTau.isTau(xAOD::TauJetParameters::JetRNNSigTight)) bPass = true; break; case JETIDGNTAUVERYLOOSE: - static const SG::AuxElement::ConstAccessor<char> acc_gnTauVeryLoose("GNTauVL_v0"); + static const SG::ConstAccessor<char> acc_gnTauVeryLoose("GNTauVL_v0"); if (!acc_gnTauVeryLoose.isAvailable(xTau)) m_tTST->msg() << MSG::WARNING << "GnTau VeryLoose WP not available" << endmsg; else bPass = acc_gnTauVeryLoose(xTau); break; case JETIDGNTAULOOSE: - static const SG::AuxElement::ConstAccessor<char> acc_gnTauLoose("GNTauL_v0"); + static const SG::ConstAccessor<char> acc_gnTauLoose("GNTauL_v0"); if (!acc_gnTauLoose.isAvailable(xTau)) m_tTST->msg() << MSG::WARNING << "GnTau Loose WP not available" << endmsg; else bPass = acc_gnTauLoose(xTau); break; case JETIDGNTAUMEDIUM: - static const SG::AuxElement::ConstAccessor<char> acc_gnTauMedium("GNTauM_v0"); + static const SG::ConstAccessor<char> acc_gnTauMedium("GNTauM_v0"); if (!acc_gnTauMedium.isAvailable(xTau)) m_tTST->msg() << MSG::WARNING << "GnTau Medium WP not available" << endmsg; else bPass = acc_gnTauMedium(xTau); break; case JETIDGNTAUTIGHT: - static const SG::AuxElement::ConstAccessor<char> acc_gnTauTight("GNTauT_v0"); + static const SG::ConstAccessor<char> acc_gnTauTight("GNTauT_v0"); if (!acc_gnTauTight.isAvailable(xTau)) m_tTST->msg() << MSG::WARNING << "GnTau Tight WP not available" << endmsg; else bPass = acc_gnTauTight(xTau); break; @@ -410,8 +411,9 @@ TauSelectionCutRNNEleScore::TauSelectionCutRNNEleScore(TauSelectionTool* tTST) //______________________________________________________________________________ void TauSelectionCutRNNEleScore::fillHistogram(const xAOD::TauJet& xTau, TH1F& hHist) const { + SG::ConstAccessor<float> acc ("RNNEleScoreSigTrans_v"+std::to_string(m_tTST->m_iEleIDVersion)); if(m_tTST->m_iEleIDVersion!=0){ - hHist.Fill(xTau.auxdataConst<float>("RNNEleScoreSigTrans_v"+std::to_string(m_tTST->m_iEleIDVersion))); + hHist.Fill(acc(xTau)); } else { hHist.Fill(xTau.discriminant(xAOD::TauJetParameters::RNNEleScoreSigTrans)); } @@ -427,9 +429,10 @@ void TauSelectionCutRNNEleScore::setAcceptInfo(asg::AcceptInfo& info) const bool TauSelectionCutRNNEleScore::accept(const xAOD::TauJet& xTau, asg::AcceptData& acceptData) { + SG::ConstAccessor<float> acc ("RNNEleScoreSigTrans_v"+std::to_string(m_tTST->m_iEleIDVersion)); double fEleRNNScore = 0.; if(m_tTST->m_iEleIDVersion!=0){ - fEleRNNScore = xTau.auxdataConst<float>("RNNEleScoreSigTrans_v"+std::to_string(m_tTST->m_iEleIDVersion)); + fEleRNNScore = acc(xTau); }else{ fEleRNNScore = xTau.discriminant(xAOD::TauJetParameters::RNNEleScoreSigTrans); } @@ -474,14 +477,17 @@ TauSelectionCutEleIDWP::TauSelectionCutEleIDWP(TauSelectionTool* tTST) void TauSelectionCutEleIDWP::fillHistogram(const xAOD::TauJet& xTau, TH1F& hHist) const { if (m_tTST->m_iEleIDVersion!=0){ - hHist.Fill((xTau.auxdataConst<char>("EleRNNLoose_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)); - hHist.Fill((xTau.auxdataConst<char>("EleRNNMedium_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)+2); - hHist.Fill((xTau.auxdataConst<char>("EleRNNTight_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)+4); + SG::ConstAccessor<char> accLoose ("EleRNNLoose_v"+std::to_string(m_tTST->m_iEleIDVersion)); + SG::ConstAccessor<char> accMedium ("EleRNNMedium_v"+std::to_string(m_tTST->m_iEleIDVersion)); + SG::ConstAccessor<char> accTight ("EleRNNTight_v"+std::to_string(m_tTST->m_iEleIDVersion)); + hHist.Fill((accLoose(xTau) == 1)); + hHist.Fill((accMedium(xTau) == 1)+2); + hHist.Fill((accTight(xTau) == 1)+4); } else{ - hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNLoose)); - hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNMedium)+2); - hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNTight)+4); + hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNLoose)); + hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNMedium)+2); + hHist.Fill(xTau.isTau(xAOD::TauJetParameters::EleRNNTight)+4); } } @@ -506,20 +512,23 @@ bool TauSelectionCutEleIDWP::accept(const xAOD::TauJet& xTau, bPass = true; break; case ELEIDRNNLOOSE: - if (m_tTST->m_iEleIDVersion!=0){ - if (xTau.auxdataConst<char>("EleRNNLoose_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)bPass = true; + if (m_tTST->m_iEleIDVersion!=0){ + SG::ConstAccessor<char> accLoose ("EleRNNLoose_v"+std::to_string(m_tTST->m_iEleIDVersion)); + if (accLoose(xTau) == 1)bPass = true; } else if (xTau.isTau(xAOD::TauJetParameters::EleRNNLoose)) bPass = true; break; case ELEIDRNNMEDIUM: if (m_tTST->m_iEleIDVersion!=0){ - if (xTau.auxdataConst<char>("EleRNNMedium_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)bPass = true; + SG::ConstAccessor<char> accMedium ("EleRNNMedium_v"+std::to_string(m_tTST->m_iEleIDVersion)); + if (accMedium(xTau) == 1)bPass = true; } else if (xTau.isTau(xAOD::TauJetParameters::EleRNNMedium)) bPass = true; break; case ELEIDRNNTIGHT: if (m_tTST->m_iEleIDVersion!=0){ - if (xTau.auxdataConst<char>("EleRNNTight_v"+std::to_string(m_tTST->m_iEleIDVersion)) == 1)bPass = true; + SG::ConstAccessor<char> accTight ("EleRNNTight_v"+std::to_string(m_tTST->m_iEleIDVersion)); + if (accTight(xTau) == 1)bPass = true; } else if (xTau.isTau(xAOD::TauJetParameters::EleRNNTight)) bPass = true; break; diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx index 00a26406397957d10876120437efae56e5f969d3..9fcb28a84a9f736a3dca2f70d210899287955f0d 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthMatchingTool.cxx @@ -9,6 +9,8 @@ // Core include(s): #include "AthLinks/ElementLink.h" #include "TruthUtils/HepMCHelpers.h" +#include "AthContainers/ConstAccessor.h" +#include "AthContainers/Decorator.h" // EDM include(s): #include "xAODTau/TauxAODHelpers.h" @@ -71,13 +73,13 @@ const xAOD::TruthParticle* TauTruthMatchingTool::getTruth(const xAOD::TauJet& xT if (findTruthTau(xTau, truthTausEvent).isFailure()) ATH_MSG_WARNING("There was a failure in finding the matched truth tau"); - static const SG::AuxElement::ConstAccessor<char> accIsTruthMatched("IsTruthMatched"); - static const SG::AuxElement::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > accTruthParticleLink("truthParticleLink"); + static const SG::ConstAccessor<char> accIsTruthMatched("IsTruthMatched"); + static const SG::ConstAccessor< ElementLink< xAOD::TruthParticleContainer > > accTruthParticleLink("truthParticleLink"); // derivations may drop IsTruthMatched, redecorate using truthParticleLink (this assumes links to truth leptons are preserved, i.e. TruthTaus, TruthElectron, TruthMuon) if ( !(*m_bIsTruthMatchedAvailable.ptr()) && (*m_bIsTruthParticleLinkAvailable.ptr())) { ATH_MSG_DEBUG("TauJetContainer has truthParticleLink available while IsTruthMatched not available. Re-evaluate IsTruthMatched"); - static const SG::AuxElement::Decorator<char> decIsTruthMatched("IsTruthMatched"); + static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched"); if (accTruthParticleLink(xTau)) { decIsTruthMatched(xTau) = (char)true; } else { @@ -138,7 +140,8 @@ TLorentzVector TauTruthMatchingTool::getTruthTauP4Vis(const xAOD::TauJet& xTau) TLorentzVector TauTruthMatchingTool::getTruthTauP4Vis(const xAOD::TruthParticle& xTruthTau) const { TLorentzVector vTLV; - if (!xTruthTau.isAvailable<double>("pt_vis")) + static const SG::ConstAccessor<double> acc ("pt_vis"); + if (!acc.isAvailable(xTruthTau)) return vTLV; vTLV.SetPtEtaPhiM( m_accPtVis(xTruthTau), @@ -159,10 +162,10 @@ TLorentzVector TauTruthMatchingTool::getTruthTauP4Invis(const xAOD::TauJet& xTau return vTLV; } - static const SG::AuxElement::ConstAccessor<double> accPtInvis("pt_invis"); - static const SG::AuxElement::ConstAccessor<double> accEtaInvis("eta_invis"); - static const SG::AuxElement::ConstAccessor<double> accPhiInvis("phi_invis"); - static const SG::AuxElement::ConstAccessor<double> accMInvis("m_invis"); + static const SG::ConstAccessor<double> accPtInvis("pt_invis"); + static const SG::ConstAccessor<double> accEtaInvis("eta_invis"); + static const SG::ConstAccessor<double> accPhiInvis("phi_invis"); + static const SG::ConstAccessor<double> accMInvis("m_invis"); vTLV.SetPtEtaPhiM( accPtInvis(*xTruthTau), accEtaInvis(*xTruthTau), @@ -175,13 +178,14 @@ TLorentzVector TauTruthMatchingTool::getTruthTauP4Invis(const xAOD::TauJet& xTau TLorentzVector TauTruthMatchingTool::getTruthTauP4Invis(const xAOD::TruthParticle& xTruthTau) const { TLorentzVector vTLV; - if (!xTruthTau.isAvailable<double>("pt_invis")) - return vTLV; - static const SG::AuxElement::ConstAccessor<double> accPtInvis("pt_invis"); - static const SG::AuxElement::ConstAccessor<double> accEtaInvis("eta_invis"); - static const SG::AuxElement::ConstAccessor<double> accPhiInvis("phi_invis"); - static const SG::AuxElement::ConstAccessor<double> accMInvis("m_invis"); + static const SG::ConstAccessor<double> accPtInvis("pt_invis"); + static const SG::ConstAccessor<double> accEtaInvis("eta_invis"); + static const SG::ConstAccessor<double> accPhiInvis("phi_invis"); + static const SG::ConstAccessor<double> accMInvis("m_invis"); + + if (!accPtInvis.isAvailable(xTruthTau)) + return vTLV; vTLV.SetPtEtaPhiM( accPtInvis(xTruthTau), accEtaInvis(xTruthTau), @@ -204,7 +208,8 @@ int TauTruthMatchingTool::getNTauDecayParticles(const xAOD::TauJet& xTau, int iP ATH_MSG_DEBUG("no truth particle was found, return 0"); return 0; } - if (!xTruthTau->isAvailable<std::vector<int>>("DecayModeVector")) + static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector"); + if (!accDecayModeVector.isAvailable(*xTruthTau)) { ATH_MSG_INFO("found truth particle is not a truth tau, return 0"); return 0; @@ -216,13 +221,13 @@ int TauTruthMatchingTool::getNTauDecayParticles(const xAOD::TauJet& xTau, int iP int TauTruthMatchingTool::getNTauDecayParticles(const xAOD::TruthParticle& xTruthTau, int iPdgId, bool bCompareAbsoluteValues) const { int iNum = 0; - if (!xTruthTau.isAvailable<std::vector<int>>("DecayModeVector")) + static const SG::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector"); + if (!accDecayModeVector.isAvailable(xTruthTau)) { ATH_MSG_WARNING("passed truth particle is not a truth tau, return 0"); return 0; } - static const SG::AuxElement::ConstAccessor<std::vector<int> > accDecayModeVector("DecayModeVector"); for(auto iPdgId2 : accDecayModeVector(xTruthTau)) if (!bCompareAbsoluteValues) { @@ -244,7 +249,8 @@ xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode(const xAOD: ATH_MSG_DEBUG("no truth particle was found, return Mode_Error"); return xAOD::TauJetParameters::Mode_Error; } - if (!xTruthTau->isAvailable<size_t>("numCharged")) + static const SG::ConstAccessor<size_t> accNumCharged("numCharged"); + if (!accNumCharged.isAvailable(*xTruthTau)) { ATH_MSG_INFO("found truth particle is not a truth tau, return Mode_Error"); return xAOD::TauJetParameters::Mode_Error; @@ -255,7 +261,8 @@ xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode(const xAOD: //______________________________________________________________________________ xAOD::TauJetParameters::DecayMode TauTruthMatchingTool::getDecayMode(const xAOD::TruthParticle& xTruthTau) const { - if (!(xTruthTau.isAvailable<size_t>("numCharged"))) + static const SG::ConstAccessor<size_t> accNumCharged("numCharged"); + if (!accNumCharged.isAvailable(xTruthTau)) { ATH_MSG_WARNING("passed truth particle is not a truth tau, return Mode_Error"); return xAOD::TauJetParameters::Mode_Error; @@ -294,13 +301,14 @@ 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") ; - m_bIsTruthMatchedAvailable.set (avail); + static const SG::ConstAccessor<char> accIsTruthMatched("IsTruthMatched"); + m_bIsTruthMatchedAvailable.set (accIsTruthMatched.isAvailable(xTau)); } // check if decorations were already added to the first passed tau if (!m_bIsTruthParticleLinkAvailable.isValid()) { - bool avail = xTau.isAvailable<ElementLink< xAOD::TruthParticleContainer >>("truthParticleLink"); - m_bIsTruthParticleLinkAvailable.set (avail); + static const SG::ConstAccessor<ElementLink< xAOD::TruthParticleContainer > > + accTruthParticleLink("truthParticleLink"); + m_bIsTruthParticleLinkAvailable.set (accTruthParticleLink.isAvailable(xTau)); } if (*m_bIsTruthMatchedAvailable.ptr() || *m_bIsTruthParticleLinkAvailable.ptr()) { @@ -323,8 +331,8 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons const xAOD::TruthParticle* xTruthMatch = nullptr; const xAOD::Jet* xTruthJetMatch = nullptr; TruthMatchedParticleType eTruthMatchedParticleType = Unknown; - static const SG::AuxElement::Decorator<char> decIsTruthMatched("IsTruthMatched"); - static const SG::AuxElement::Decorator< ElementLink< xAOD::JetContainer > > decTruthJetLink("truthJetLink"); + static const SG::Decorator<char> decIsTruthMatched("IsTruthMatched"); + static const SG::Decorator< ElementLink< xAOD::JetContainer > > decTruthJetLink("truthJetLink"); for (auto xTruthTauIt : xTruthTauContainer) { @@ -335,7 +343,7 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons m_accMVis(*xTruthTauIt)); if (xTau.p4().DeltaR(vTruthVisTLV) <= m_dMaxDeltaR) { - static const SG::AuxElement::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); + static const SG::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); if ((bool)accIsHadronicTau(*xTruthTauIt)) eTruthMatchedParticleType = TruthHadronicTau; else @@ -411,7 +419,7 @@ StatusCode TauTruthMatchingTool::checkTruthMatch (const xAOD::TauJet& xTau, cons } // create link to the original TruthParticle - static const SG::AuxElement::Decorator< ElementLink< xAOD::TruthParticleContainer > > decTruthParticleLink("truthParticleLink"); + static const SG::Decorator< ElementLink< xAOD::TruthParticleContainer > > decTruthParticleLink("truthParticleLink"); if (xTruthMatch) { diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthTrackMatchingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthTrackMatchingTool.cxx index 5682dcc2abeb354c017a59cce721de45384c3cda..9b618e66d6ba9483e31cc4303ab39a7e1836ed93 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthTrackMatchingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauTruthTrackMatchingTool.cxx @@ -8,6 +8,7 @@ #include "xAODTruth/TruthParticleContainer.h" #include "xAODTruth/TruthVertex.h" #include "TruthUtils/HepMCHelpers.h" +#include "AthContainers/ConstAccessor.h" using namespace TauAnalysisTools; @@ -35,7 +36,8 @@ StatusCode TauTruthTrackMatchingTool::classifyTrack(const xAOD::TauTrack& xTrack // don't classify tracks if this was already done if (!m_bIsHadronicTrackAvailable.isValid()) { - bool avail = xTrackParticle.isAvailable<char>("IsHadronicTrack"); + static const SG::ConstAccessor<char> accIsHadronicTrack("IsHadronicTrack"); + bool avail = accIsHadronicTrack.isAvailable(xTrackParticle); m_bIsHadronicTrackAvailable.set (avail); if (avail) { diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/src/TauAnalysisToolsExampleAthena.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/src/TauAnalysisToolsExampleAthena.cxx index 5ae0ebaa366ed16313e7ce92e10c3218476e7afd..c9f04223268b80150e337ce89e5c1de7effb2a24 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/src/TauAnalysisToolsExampleAthena.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/src/TauAnalysisToolsExampleAthena.cxx @@ -1,9 +1,10 @@ /* - Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ // EDM include(s): #include "xAODTau/TauJetContainer.h" +#include "AthContainers/ConstAccessor.h" // Local include(s): #include "TauAnalysisToolsExampleAthena.h" @@ -73,7 +74,8 @@ StatusCode TauAnalysisToolsExampleAthena::execute() ATH_CHECK (m_effTool->applyEfficiencyScaleFactor(*tau)); - ATH_MSG_INFO( " sf = " << tau->auxdata< double >( "TauScaleFactorJetID" ) ); + static const SG::ConstAccessor<double> accTauScaleFactorJetID ("TauScaleFactorJetID"); + ATH_MSG_INFO( " sf = " << accTauScaleFactorJetID (*tau) ); ATH_CHECK (m_smearTool->applyCorrection(*tau)); ATH_MSG_INFO( "Unsmeared tau pt " << tau->pt() << " Smeared tau pt: " << tau->p4().Pt()); diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx index 76c780e17c527c92295c9c39a09523e2da3b5ceb..7a7452fb44d5ce9d4a3a3ce855dfaa6666e5ccc3 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/test/ut_TauAnalysisTools_test.cxx @@ -25,6 +25,7 @@ // EDM include(s): #include "xAODTau/TauJetContainer.h" +#include "AthContainers/ConstAccessor.h" #include "CxxUtils/checker_macros.h" @@ -130,14 +131,18 @@ int main ATLAS_NOT_THREAD_SAFE ( int argc, char* argv[] ) << ", prong = " << int(xTau->nTracks()) << ", charge = " << int(xTau->charge())); - bool avail = xTau->isAvailable<char>("IsTruthMatched") ; + static const SG::ConstAccessor<char> accIsTruthMatched ("IsTruthMatched"); + bool avail = accIsTruthMatched.isAvailable(*xTau); if (avail && (xTruthTau != nullptr)) { if (xTruthTau->isTau()) { - if ((bool)xTruthTau->auxdata<char>("IsHadronicTau")) - ANA_MSG_INFO( "Tau was matched to a truth hadronic tau, which has " << int(xTruthTau->auxdata<size_t>("numCharged")) + static const SG::ConstAccessor<char> accIsHadronicTau ("IsHadronicTau"); + if ((bool)accIsHadronicTau(*xTruthTau)) { + static const SG::ConstAccessor<size_t> accNumCharged ("numCharged"); + ANA_MSG_INFO( "Tau was matched to a truth hadronic tau, which has " << int(accNumCharged(*xTruthTau)) << " prongs and a charge of " << int(xTruthTau->charge())); + } else ANA_MSG_INFO( "Tau was matched to a truth leptonic tau, which has a charge of " << int(xTruthTau->charge())); } @@ -150,12 +155,14 @@ int main ATLAS_NOT_THREAD_SAFE ( int argc, char* argv[] ) ANA_MSG_INFO( "Tau was not matched to truth" ); typedef ElementLink< xAOD::TruthParticleContainer > Link_t; - if (!xTau->isAvailable< Link_t >("truthParticleLink")) + static const SG::ConstAccessor< Link_t > accTruthParticleLink("truthParticleLink"); + if (!accTruthParticleLink.isAvailable(*xTau)) { ANA_MSG_WARNING("link truthParticleLink is not available"); continue; } - auto xTruthJetLink = xTau->auxdata< ElementLink< xAOD::JetContainer > >("truthJetLink"); + static const SG::ConstAccessor< ElementLink< xAOD::JetContainer > > accTruthJetLink("truthJetLink"); + auto xTruthJetLink = accTruthJetLink(*xTau); if (xTruthJetLink.isValid()) { const xAOD::Jet* xTruthJet = *xTruthJetLink;