diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx index 31444f17d5c0b6fc87d98548320a24ead9c8834a..9026acf04f44bbec94c01895dcf26d7960ec0796 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/CommonSmearingTool.cxx @@ -71,8 +71,8 @@ CommonSmearingTool::CommonSmearingTool(const std::string& sName) : asg::AsgMetadataTool( sName ) , m_mSF(0) , m_sSystematicSet(0) - , m_fX(&caloTauPt) - , m_fY(&caloTauEta) + , m_fX(&finalTauPt) + , m_fY(&finalTauEta) , m_bIsData(false) , m_bIsConfigured(false) , m_tMvaTESVariableDecorator("MvaTESVariableDecorator", this) @@ -80,17 +80,18 @@ CommonSmearingTool::CommonSmearingTool(const std::string& sName) , m_tCombinedP4FromRecoTaus("CombinedP4FromRecoTaus", this) , m_eCheckTruth(TauAnalysisTools::Unknown) , m_bNoMultiprong(false) - , m_bPtFinalCalibIsAvailable(false) - , m_bPtFinalCalibIsAvailableIsChecked(false) , m_bPtTauEtaCalibIsAvailable(false) , m_bPtTauEtaCalibIsAvailableIsChecked(false) { + m_mSystematics = {}; + declareProperty("InputFilePath", m_sInputFilePath = "" ); declareProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck = false ); declareProperty("ApplyFading", m_bApplyFading = true ); - declareProperty("ApplyMVATES", m_bApplyMVATES = false ); + declareProperty("ApplyMVATES", m_bApplyMVATES = true ); declareProperty("ApplyCombinedTES", m_bApplyCombinedTES = false ); declareProperty("ApplyMVATESQualityCheck", m_bApplyMVATESQualityCheck = true ); + declareProperty("ApplyInsituCorrection", m_bApplyInsituCorrection = true ); } /* @@ -141,21 +142,10 @@ StatusCode CommonSmearingTool::initialize() if (applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS ) return StatusCode::FAILURE; -#ifndef XAODTAU_VERSIONS_TAUJET_V3_H - if (m_bApplyMVATES) - { - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tMvaTESVariableDecorator, MvaTESVariableDecorator)); - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tMvaTESEvaluator, MvaTESEvaluator)); - ATH_CHECK(m_tMvaTESEvaluator.setProperty("WeightFileName", "MvaTES_20161015_pi0fix_BDTG.weights.xml")); - ATH_CHECK(m_tMvaTESVariableDecorator.initialize()); - ATH_CHECK(m_tMvaTESEvaluator.initialize()); - } -#endif - if (m_bApplyCombinedTES || m_bApplyMVATES) // CombinedTES has to be available for MVA fix { ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCombinedP4FromRecoTaus, CombinedP4FromRecoTaus)); - ATH_CHECK(m_tCombinedP4FromRecoTaus.setProperty("WeightFileName", "CalibLoopResult.root")); + ATH_CHECK(m_tCombinedP4FromRecoTaus.setProperty("WeightFileName", "CalibLoopResult_v04-04.root")); ATH_CHECK(m_tCombinedP4FromRecoTaus.initialize()); } @@ -187,35 +177,17 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) } if (m_bApplyMVATES) - { - if (not m_bPtFinalCalibIsAvailableIsChecked) - { - m_bPtFinalCalibIsAvailable = xTau.isAvailable<float>("ptFinalCalib"); - m_bPtFinalCalibIsAvailableIsChecked = true; - } - - if (not m_bPtFinalCalibIsAvailable) - { -#ifndef XAODTAU_VERSIONS_TAUJET_V3_H - // TODO: only call eventInitialize once per event, probably via migration to - // AsgMetadataTool - if (m_tMvaTESVariableDecorator->eventInitialize().isFailure()) - return CP::CorrectionCode::Error; - if (m_tMvaTESVariableDecorator->execute(xTau).isFailure()) - return CP::CorrectionCode::Error; - if (m_tMvaTESEvaluator->execute(xTau).isFailure()) - return CP::CorrectionCode::Error; -#else - ATH_MSG_ERROR("MVA TES decoration 'ptFinalCalib' is not available "); - return CP::CorrectionCode::Error; -#endif - } - + { // veto MVA TES for unreasonably low resolution values bool bVeto = dynamic_cast<CombinedP4FromRecoTaus*>(m_tCombinedP4FromRecoTaus.get())->getUseCaloPtFlag(xTau); if (xTau.nTracks() > 0 and xTau.nTracks() < 6) { + static SG::AuxElement::ConstAccessor<float> accPtFinalCalib("ptFinalCalib"); + static SG::AuxElement::ConstAccessor<float> accEtaFinalCalib("etaFinalCalib"); + static SG::AuxElement::ConstAccessor<float> accPhiFinalCalib("phiFinalCalib"); + static SG::AuxElement::ConstAccessor<float> accMFinalCalib("mFinalCalib"); + xTau.auxdecor<char>("MVATESQuality") = (char)bVeto; if (bVeto && m_bApplyMVATESQualityCheck) { @@ -227,10 +199,10 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) } else { - xTau.setP4(xTau.auxdata<float>("ptFinalCalib"), - xTau.auxdata<float>("etaFinalCalib"), - xTau.auxdata<float>("phiFinalCalib"), - xTau.auxdata<float>("mFinalCalib")); + xTau.setP4(accPtFinalCalib(xTau), + accEtaFinalCalib(xTau), + accPhiFinalCalib(xTau), + accMFinalCalib(xTau)); } } } @@ -258,7 +230,7 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) return CP::CorrectionCode::Ok; // check which true state is requestet - if (!m_bSkipTruthMatchCheck and checkTruthMatch(xTau) != m_eCheckTruth) + if (!m_bSkipTruthMatchCheck and getTruthParticleType(xTau) != m_eCheckTruth) { return CP::CorrectionCode::Ok; } @@ -267,13 +239,17 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) std::string sProng = ConvertProngToString(xTau.nTracks()); double dCorrection = 1.; - // get standard scale factor - CP::CorrectionCode tmpCorrectionCode = getValue("sf"+sProng, - xTau, - dCorrection); - // return correction code if histogram is not available - if (tmpCorrectionCode != CP::CorrectionCode::Ok) - return tmpCorrectionCode; + CP::CorrectionCode tmpCorrectionCode; + if (m_bApplyInsituCorrection) + { + // get standard scale factor + tmpCorrectionCode = getValue("sf"+sProng, + xTau, + dCorrection); + // return correction code if histogram is not available + if (tmpCorrectionCode != CP::CorrectionCode::Ok) + return tmpCorrectionCode; + } // skip further process if systematic set is empty if (m_sSystematicSet->size() > 0) @@ -291,7 +267,6 @@ CP::CorrectionCode CommonSmearingTool::applyCorrection( xAOD::TauJet& xTau ) tmpCorrectionCode = getValue(it->second+sProng, xTau, dUncertaintySyst); - // return correction code if histogram is not available if (tmpCorrectionCode != CP::CorrectionCode::Ok) return tmpCorrectionCode; @@ -471,8 +446,8 @@ template<class T> void CommonSmearingTool::ReadInputs(TFile* fFile, std::map<std::string, T>* mMap) { // initialize function pointer - m_fX = &caloTauPt; - m_fY = &caloTauEta; + m_fX = &finalTauPt; + m_fY = &finalTauEta; TKey *kKey; TIter itNext(fFile->GetListOfKeys()); @@ -485,18 +460,18 @@ void CommonSmearingTool::ReadInputs(TFile* fFile, std::map<std::string, T>* mMap std::string sKeyName = kKey->GetName(); if (sKeyName == "Xaxis") { - TNamed* tObj = (T)kKey->ReadObj(); + TNamed* tObj = (TNamed*)kKey->ReadObj(); std::string sTitle = tObj->GetTitle(); delete tObj; - if (sTitle == "P") + if (sTitle == "P" || sTitle == "PFinalCalib") { - m_fX = &caloTauP; + m_fX = &finalTauP; ATH_MSG_DEBUG("using full momentum for x-axis"); } } if (sKeyName == "Yaxis") { - TNamed* tObj = (T)kKey->ReadObj(); + TNamed* tObj = (TNamed*)kKey->ReadObj(); std::string sTitle = tObj->GetTitle(); delete tObj; if (sTitle == "track-eta") @@ -506,7 +481,7 @@ void CommonSmearingTool::ReadInputs(TFile* fFile, std::map<std::string, T>* mMap } else if (sTitle == "|eta|") { - m_fY = &caloTauAbsEta; + m_fY = &finalTauAbsEta; ATH_MSG_DEBUG("using absolute tau eta for y-axis"); } } @@ -543,8 +518,16 @@ void CommonSmearingTool::generateSystematicSets() // parse for nuisance parameter in histogram name std::vector<std::string> vSplitNP = {}; split(mSF.first,'_',vSplitNP); - std::string sNP = vSplitNP.at(0); - std::string sNPUppercase = vSplitNP.at(0); + std::string sNP; + std::string sNPUppercase; + if (vSplitNP.size() > 2) + { + sNP = vSplitNP.at(0)+'_'+vSplitNP.at(1); + sNPUppercase = vSplitNP.at(0)+'_'+vSplitNP.at(1); + } else { + sNP = vSplitNP.at(0); + sNPUppercase = vSplitNP.at(0); + } // skip nominal scale factors if (sNP == "sf") continue; @@ -580,7 +563,7 @@ CP::CorrectionCode CommonSmearingTool::getValue(const std::string& sHistName, const xAOD::TauJet& xTau, double& dEfficiencyScaleFactor) const { - TH1F* hHist = (*m_mSF)[sHistName]; + TH1* hHist = (*m_mSF)[sHistName]; if (!hHist) { ATH_MSG_ERROR("Histogram with name "<<sHistName<<" was not found in input file."); @@ -614,39 +597,3 @@ CP::CorrectionCode CommonSmearingTool::getValue(const std::string& sHistName, } return CP::CorrectionCode::Ok; } - -//______________________________________________________________________________ -e_TruthMatchedParticleType CommonSmearingTool::checkTruthMatch(const xAOD::TauJet& xTau) const -{ - // check if reco tau is a truth hadronic tau - typedef ElementLink< xAOD::TruthParticleContainer > Link_t; - if (!xTau.isAvailable< Link_t >("truthParticleLink")) - ATH_MSG_ERROR("No truth match information available. Please run TauTruthMatchingTool first."); - - static SG::AuxElement::Accessor<Link_t> accTruthParticleLink("truthParticleLink"); - const Link_t xTruthParticleLink = accTruthParticleLink(xTau); - - // if there is no link, then it is a truth jet - e_TruthMatchedParticleType eTruthMatchedParticleType = TauAnalysisTools::TruthJet; - - if (xTruthParticleLink.isValid()) - { - const xAOD::TruthParticle* xTruthParticle = *xTruthParticleLink; - if (xTruthParticle->isTau()) - { - static SG::AuxElement::ConstAccessor<char> accIsHadronicTau("IsHadronicTau"); - if ((bool)accIsHadronicTau(*xTruthParticle)) - { - eTruthMatchedParticleType = TruthHadronicTau; - } - } - else if (xTruthParticle->isElectron()) - eTruthMatchedParticleType = TruthElectron; - else if (xTruthParticle->isMuon()) - eTruthMatchedParticleType = TruthMuon; - } - else - ATH_MSG_VERBOSE("Truth particle link is not valid"); - - return eTruthMatchedParticleType; -} diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSmearingTool.cxx b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSmearingTool.cxx index 500275a6bf4697fa25fd353f47703801fe5cf120..cd5571488c10a056edaac62d22468173238e25ed 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSmearingTool.cxx +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/Root/TauSmearingTool.cxx @@ -1,29 +1,34 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // EDM include(s): #include "PATInterfaces/SystematicRegistry.h" +#include "xAODMetaData/FileMetaData.h" // Local include(s): #include "TauAnalysisTools/TauSmearingTool.h" #include "TauAnalysisTools/SharedFilesVersion.h" #include "TauAnalysisTools/TauSmearingRun1Tool.h" +#include <boost/algorithm/string.hpp> + namespace TauAnalysisTools { TauSmearingTool::TauSmearingTool( const std::string& sName ) - : asg::AsgTool( sName ) + : asg::AsgMetadataTool( sName ) , m_tCommonSmearingTool(sName+"_CommonSmearingTool", this) , m_sInputFilePath("") { - declareProperty( "RecommendationTag", m_sRecommendationTag = "2017-moriond" ); + declareProperty( "RecommendationTag", m_sRecommendationTag = "2019-summer" ); declareProperty( "SkipTruthMatchCheck", m_bSkipTruthMatchCheck = false ); declareProperty( "ApplyFading", m_bApplyFading = true); - declareProperty( "ApplyMVATES", m_bApplyMVATES = false); + declareProperty( "ApplyMVATES", m_bApplyMVATES = true); declareProperty( "ApplyCombinedTES", m_bApplyCombinedTES = false); declareProperty("ApplyMVATESQualityCheck", m_bApplyMVATESQualityCheck = true ); + declareProperty("ApplyInsituCorrection", m_bApplyInsituCorrection = true ); + declareProperty( "isAFII", m_sAFII = false ); // deprecated property declareProperty( "IsData", m_bIsData = false ); @@ -50,66 +55,23 @@ StatusCode TauSmearingTool::initialize() std::string sDirectory = "TauAnalysisTools/"+std::string(sSharedFilesVersion)+"/Smearing/"; - if (m_sRecommendationTag == "2017-moriond") + if (m_sRecommendationTag == "2019-summer") { if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"TES_TrueHadTau_2017-moriond.root"; + { + if (m_sAFII) m_sInputFilePath = sDirectory+"TES_TrueHadTau_2019-summer_AFII.root"; + else m_sInputFilePath = sDirectory+"TES_TrueHadTau_2019-summer.root"; + } ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::CommonSmearingTool)); ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); ATH_CHECK(m_tCommonSmearingTool.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck)); ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyFading", m_bApplyFading)); ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyMVATES", m_bApplyMVATES)); ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyMVATESQualityCheck", m_bApplyMVATESQualityCheck)); + ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyInsituCorrection", m_bApplyInsituCorrection)); ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyCombinedTES", m_bApplyCombinedTES)); ATH_CHECK(m_tCommonSmearingTool.setProperty("OutputLevel", this->msg().level())); } - else if (m_sRecommendationTag == "2016-ichep") - { - if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"TES_TrueHadTau_2016-ichep.root"; - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::CommonSmearingTool)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyFading", m_bApplyFading)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyMVATES", m_bApplyMVATES)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyCombinedTES", m_bApplyCombinedTES)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("OutputLevel", this->msg().level())); - } - else if (m_sRecommendationTag == "mc15-moriond") - { - if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"TES_TrueHadTau_mc15_moriond.root"; - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::CommonSmearingTool)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyFading", m_bApplyFading)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyMVATES", m_bApplyMVATES)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyCombinedTES", m_bApplyCombinedTES)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("OutputLevel", this->msg().level())); - } - else if (m_sRecommendationTag == "mc15-pre-recommendations") - { - if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"TES_TrueHadTau_mc15_prerec.root"; - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::CommonSmearingTool)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("ApplyFading", false)); // apply fading off by default - } - else if (m_sRecommendationTag == "mc12-final") - { - if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"mc12_p1344_medium.root"; - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::TauSmearingRun1Tool)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); - } - else if (m_sRecommendationTag == "mc11-final") - { - if (m_sInputFilePath.empty()) - m_sInputFilePath = sDirectory+"mc11.root"; - ATH_CHECK(ASG_MAKE_ANA_TOOL(m_tCommonSmearingTool, TauAnalysisTools::TauSmearingRun1Tool)); - ATH_CHECK(m_tCommonSmearingTool.setProperty("InputFilePath", m_sInputFilePath)); - } else { ATH_MSG_FATAL("unknown recommendation tag "<<m_sRecommendationTag); @@ -129,6 +91,27 @@ StatusCode TauSmearingTool::initialize() return StatusCode::SUCCESS; } +// auto detection of simulation flavour, used to cross check configuration of tool +//______________________________________________________________________________ +StatusCode TauSmearingTool::beginInputFile() +{ + if (m_sRecommendationTag == "2019-summer") + { + std::string simType(""); + if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) + { + const xAOD::FileMetaData* fmd = 0; + ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) ); + bool result = fmd->value( xAOD::FileMetaData::simFlavour , simType ); + // if no result -> no simFlavor metadata, so must be data + if(result) boost::to_upper(simType); + } + if (simType.find("ATLFASTII")!=std::string::npos && !m_sAFII) ATH_MSG_WARNING("Input file is fast simulation but you are _not_ using AFII corrections and uncertainties, you should set \"isAFII\" to \"true\""); + else if (simType.find("FULLG4")!=std::string::npos && m_sAFII) ATH_MSG_WARNING("Input file is full simulation but you are using AFII corrections and uncertainties, you should set \"isAFII\" to \"false\""); + } + return StatusCode::SUCCESS; +} + CP::CorrectionCode TauSmearingTool::applyCorrection( xAOD::TauJet& xTau ) { @@ -158,7 +141,7 @@ CP::SystematicSet TauSmearingTool::recommendedSystematics() const { return m_tCommonSmearingTool->recommendedSystematics(); } - + StatusCode TauSmearingTool::applySystematicVariation ( const CP::SystematicSet& sSystematicSet) { return m_tCommonSmearingTool->applySystematicVariation( sSystematicSet ); diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/CommonSmearingTool.h b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/CommonSmearingTool.h index 2e36e758fa6ee275c65ed8917ab6a87d4ad5c6ed..736a6ac64af621bdffb7432c99dc91a4a482cd05 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/CommonSmearingTool.h +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/CommonSmearingTool.h @@ -1,5 +1,7 @@ +// Dear emacs, this is -*- c++ -*- + /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TAUANALYSISTOOLS_COMMONSMEARINGTOOL_H @@ -35,7 +37,7 @@ #include "TROOT.h" #include "TClass.h" #include "TFile.h" -#include "TH1F.h" +#include "TH1.h" #include "TKey.h" @@ -83,12 +85,11 @@ public: /// ignored (unless they virtual StatusCode applySystematicVariation ( const CP::SystematicSet& sSystematicSet); - protected: std::string ConvertProngToString(const int& iProngness); - typedef std::map<std::string, TH1F*> SFMAP; + typedef std::map<std::string, TH1*> SFMAP; SFMAP* m_mSF; std::unordered_map < CP::SystematicSet, std::string > m_mSystematicSets; const CP::SystematicSet* m_sSystematicSet; @@ -104,7 +105,6 @@ protected: virtual CP::CorrectionCode getValue(const std::string& sHistName, const xAOD::TauJet& xTau, double& dEfficiencyScaleFactor) const; - e_TruthMatchedParticleType checkTruthMatch(const xAOD::TauJet& xTau) const; void generateSystematicSets(); std::string m_sInputFilePath; @@ -116,6 +116,7 @@ protected: bool m_bApplyMVATES; bool m_bApplyCombinedTES; bool m_bApplyMVATESQualityCheck; + bool m_bApplyInsituCorrection; asg::AnaToolHandle<ITauToolBase> m_tMvaTESVariableDecorator; asg::AnaToolHandle<ITauToolBase> m_tMvaTESEvaluator; diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauSmearingTool.h b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauSmearingTool.h index e2fb28d03ef1f8f45e23997b3814e98f2c12516b..6d9ff02be7023b305a84ef3065d98ca7858b2923 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauSmearingTool.h +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/TauAnalysisTools/TauSmearingTool.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef TAUANALYSISTOOLS_TAUSMEARINGTOOL_H @@ -20,6 +20,7 @@ // Framework include(s): #include "AsgTools/AsgTool.h" #include "AsgTools/AnaToolHandle.h" +#include "AsgTools/AsgMetadataTool.h" // Local include(s): #include "TauAnalysisTools/Enums.h" @@ -30,7 +31,7 @@ namespace TauAnalysisTools { class TauSmearingTool - : public asg::AsgTool + : public asg::AsgMetadataTool , public virtual ITauSmearingTool { /// Create a proper constructor for Athena @@ -44,7 +45,9 @@ public: /// Function initialising the tool virtual StatusCode initialize(); - + + virtual StatusCode beginInputFile(); + /// Apply the correction on a modifyable object virtual CP::CorrectionCode applyCorrection( xAOD::TauJet& xTau ); /// Create a corrected copy from a constant tau @@ -67,12 +70,14 @@ private: std::string m_sInputFilePath; std::string m_sRecommendationTag; bool m_bIsData; + bool m_sAFII; bool m_bSkipTruthMatchCheck; bool m_bApplyFading; bool m_bApplyMVATES; bool m_bApplyMVATESQualityCheck; bool m_bApplyCombinedTES; + bool m_bApplyInsituCorrection; }; // class TauSmearingTool diff --git a/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSmearingTool.rst b/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSmearingTool.rst index dc45bb385944ec8dbfcc08ced96a8dc20d48df75..f0320cd93c5a9ff4727914d5d3772c2f958c19d7 100644 --- a/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSmearingTool.rst +++ b/PhysicsAnalysis/TauID/TauAnalysisTools/doc/README-TauSmearingTool.rst @@ -74,19 +74,14 @@ The tool can be configured to use a specific set of systematic variations callin MVA TES and Combined TES ------------------------ -The MVA TES calibration can be applied as well with TauSmearingTool. In addition -to your standard configuration set the option:: +By default TauSmearingTool applies MVA TES. This is applied on data and simulation. +First a quality check is performed to veto unreasonably low resolution values. If this check, +was successful the tau 4-momentum values are overwritten with the values from MVA TES. - TauSmeTool.setProperty("ApplyMVATES", true ); +The MVA TES and the quality check can be disabled by the following options (meant only for testing purposes):: -The MVA calibration will be applied to your taus, replacing the default -four-momentum, when correcting your tau candidates via the standard -``applyCorrection(xTau)`` and ``correctedCopy(xTauOrig, xTauCopy)``. - -Note: You must have at least tauRecTools-00-00-12-09. This package is only -available in ABR since AnalysisBase-2.4.11. If you want to test the MVA -calibration please update to that release or checkout and compile the package on -your own. + TauSmeTool.setProperty("ApplyMVATES", false ); + TauSmeTool.setProperty("ApplyMVATESQualityCheck", false ); The combined TES can be applied with the following option:: @@ -130,7 +125,7 @@ The following table lists other properties for further configurations: * - ``ApplyMVATES`` - ``bool`` - - ``false`` + - ``true`` - apply new MVA based TES, see section `MVA TES and Combined TES`_ * - ``ApplyCombinedTES`` @@ -218,9 +213,7 @@ FAQ #. **Question:** I try to apply systematic variation running on derived samples, but I get an error like:: - TauAnalysisTools::CommonSmearingTool::checkTruthMatch(const TauJet&) const): No truth match information available. Please run TauTruthMatchingTool first. - terminate called after throwing an instance of 'SG::ExcBadAuxVar' - what(): SG::ExcBadAuxVar: Attempt to retrieve nonexistent aux data item `::truthParticleLink' (894). + TauAnalysisTools::getTruthParticleType: No truth match information available. Please run TauTruthMatchingTool first. **Answer:** Did you follow instructions for adding truth information in derivations as described in `TauPreRecommendations2015 TWiki @@ -238,9 +231,7 @@ FAQ #. **Question:** I try to apply systematic variation running on xAOD samples, but I get an error like:: - TauAnalysisTools::CommonSmearingTool::checkTruthMatch(const TauJet&) const): No truth match information available. Please run TauTruthMatchingTool first. - terminate called after throwing an instance of 'SG::ExcBadAuxVar' - what(): SG::ExcBadAuxVar: Attempt to retrieve nonexistent aux data item `::truthParticleLink' (894). + TauAnalysisTools::getTruthParticleType: No truth match information available. Please run TauTruthMatchingTool first. **Answer:** If you have full access to the TruthParticle container, you can create a TruthTau container and the link to the matched truth taus by setting