diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EffiCollection.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EffiCollection.h index d583ff0cc359bddfbbaa34d2add4133beea29628..45438ca29f678895fc6c492aed83ec680b05ecb6 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EffiCollection.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EffiCollection.h @@ -167,7 +167,7 @@ namespace CP { bool isNominal() const; bool isUpVariation() const; - bool seperateBinSyst() const; + bool separateBinSyst() const; private: std::map<std::string, std::pair<unsigned int, unsigned int>> findPeriods(const MuonEfficiencyScaleFactors& ref_tool) const; diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EfficiencyScaleFactor.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EfficiencyScaleFactor.h index 1d1d6387c91d73188cd9fed514fc44c65b98ca03..11a572c7649e902d623c3755d47a84d5d1bb7278 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EfficiencyScaleFactor.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/EfficiencyScaleFactor.h @@ -88,7 +88,7 @@ namespace CP { /// bin by bin bool SetSystematicBin(int bin); - bool SeperateSystBins() const; + bool separateBinSyst() const; bool IsUpVariation() const; @@ -174,7 +174,7 @@ namespace CP { /// steers the pt dependent systematics bool m_respond_to_kineDepSyst; /// Can the systematic be decorrelated - bool m_seperateBinSyst; + bool m_separateBinSyst; /// the histograms needed to run std::unique_ptr<HistHandler> m_sf; std::unique_ptr<HistHandler> m_eff; diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/HistHandler.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/HistHandler.h index c560816f4361ca8afe6c369701655411ed63e333..01f06c8a01f4d0c206c2c261d2cdc2f19bf5154d 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/HistHandler.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/HistHandler.h @@ -15,7 +15,6 @@ #include <TH2Poly.h> #include "PATInterfaces/CorrectionCode.h" -#include "AsgMessaging/MessageCheck.h" // further ROOT includes #include <TFile.h> #include <TDirectory.h> @@ -28,8 +27,6 @@ #include <memory> #include <cmath> -ANA_MSG_HEADER (msgMuonEfficiency) - namespace CP { ///Forward declarations @@ -196,91 +193,47 @@ namespace CP { class PtAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - value = mu.pt() / 1000.; - return CorrectionCode::Ok; - } + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~PtAxisHandler() = default; - }; class ChargeAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - value = mu.charge(); - return CorrectionCode::Ok; - } + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~ChargeAxisHandler() = default; - }; class EtaAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - value = mu.eta(); - return CorrectionCode::Ok; - } + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~EtaAxisHandler() = default; - }; class AbsEtaAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - value = std::abs(mu.eta()); - return CorrectionCode::Ok; - } + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~AbsEtaAxisHandler() = default; - }; class PhiAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - value = mu.phi(); - return CorrectionCode::Ok; - } + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~PhiAxisHandler() = default; - }; class dRJetAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override { - static const SG::AuxElement::ConstAccessor<float> dRJet("dRJet"); - static const SG::AuxElement::ConstAccessor<float> dRJet_DxAOD("DFCommonJetDr"); - using namespace msgMuonEfficiency; - if( dRJet_DxAOD.isAvailable(mu) ) { - // decoration available in DxAOD - value = dRJet_DxAOD(mu); - ANA_MSG_VERBOSE("Taking #Delta R(jet,#mu) decoration from MuonsAuxDyn.DFCommonJetDr for retrieving the muon isolation scale factors."); - } else if( dRJet.isAvailable(mu) ) { - // decoration manually provided by analyzers - value = dRJet.isAvailable(mu); - ANA_MSG_INFO("MuonsAuxDyn.DFCommonJetDr is not available in this DxAOD, but you've decorated the muon with dRJet. Using it for retrieving the isolation scale factors."); - } else { - // decoration not available - value = -2.; - // We want these warnings to be printed few times per job, so that they're visible, then stop before log file's size blows up - static std::atomic<unsigned int> warned = {0}; - if (warned<5){ - ANA_MSG_WARNING("The dRJet decoration has not been found for the Muon. Isolation scale-factors are now also binned in #Delta R(jet,#mu)"); - ANA_MSG_WARNING("using the closest calibrated AntiKt4EMTopo jet with p_{T}>20~GeV and surving the standard OR criteria."); - ANA_MSG_WARNING("You should decorate your muon appropiately before passing to the tool, and use dRJet = -1 in case there is no jet in an event."); - ANA_MSG_WARNING("For the time being the inclusive scale-factor is going to be returned."); - ANA_MSG_WARNING("In future derivations, muons will also be decorated centrally with dRJet, for your benefit."); - warned++; - } - } - return CorrectionCode::Ok; - } + dRJetAxisHandler(); + + CorrectionCode GetBinningParameter(const xAOD::Muon & mu, float & value) const override; virtual ~dRJetAxisHandler() = default; - + static void set_close_jet_decorator(const std::string& decor_name); + + private: + static std::string m_close_jet_decor; + SG::AuxElement::ConstAccessor<float> m_acc; }; class UndefinedAxisHandler: public AxisHandler { public: - CorrectionCode GetBinningParameter(const xAOD::Muon &, float &) const override { - return CorrectionCode::Error; - } + CorrectionCode GetBinningParameter(const xAOD::Muon &, float &) const override; virtual ~UndefinedAxisHandler() = default; - }; } // namespace CP diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h index 30dce714741f9b726ea2db0e2dc0a287b500c061..fef0330e8126a6c7ef18dc6e15f5eb693ec14cde 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h @@ -25,7 +25,7 @@ namespace CP { public: MuonEfficiencyScaleFactors(const std::string& name); - virtual ~MuonEfficiencyScaleFactors(); + virtual ~MuonEfficiencyScaleFactors() = default; //Proper constructor for Athena ASG_TOOL_CLASS2( MuonEfficiencyScaleFactors, CP::IMuonEfficiencyScaleFactors, CP::ISystematicsTool ) @@ -135,6 +135,14 @@ namespace CP { /// Returns the number of EffiCollections stored in this class size_t getNCollections() const; + /// Returns a boolean whether the uncorrelation of systematics has been switched on + bool uncorrelate_sys() const; + + /// Returns the string telling the tool in which + /// float AuxElement the information of the separation + /// to the closest jet is stored + std::string close_by_jet_decoration() const; + private: /// utility method to 'dress' a filename using the path resolver @@ -165,10 +173,12 @@ namespace CP { /// subfolder to load from the calibration db std::string m_calibration_version; + /// threshold below which low-pt SF (i.e. from JPsi) should be used float m_lowpt_threshold; - + /// Name of the decoration to catch up the close by jets + std::string m_iso_jet_dR; CP::SystematicSet m_affectingSys; /// It turned out that the code spends a large time in the look up of /// the systematics. This map tries to mitigate this issue. diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonSFTestHelper.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonSFTestHelper.h index ec1693410b0951266e6c8399df22e95177cae586..f673ce1c378558585ad1f728fc668b60161fa354 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonSFTestHelper.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/MuonEfficiencyCorrections/MuonSFTestHelper.h @@ -35,7 +35,7 @@ namespace TestMuonSF { class SFBranches { public: SFBranches(TTree* tree); - virtual ~SFBranches(); + virtual ~SFBranches()= default; virtual std::string name() const =0; virtual bool init()=0; protected: @@ -62,7 +62,7 @@ namespace TestMuonSF { class TriggerSFBranches: public SFBranches { public: TriggerSFBranches(TTree* tree, const ToolHandle<CP::IMuonTriggerScaleFactors>& Handle, const std::string& Trigger); - virtual ~TriggerSFBranches(); + virtual ~TriggerSFBranches() = default; CP::CorrectionCode fill(const xAOD::MuonContainer* Muons); virtual bool init(); virtual std::string name() const; @@ -86,7 +86,7 @@ namespace TestMuonSF { public: MuonEffiBranches(TTree* tree); virtual CP::CorrectionCode fill(const xAOD::Muon& muon)=0; - virtual ~MuonEffiBranches(); + ~MuonEffiBranches() = default; }; typedef std::unique_ptr<MuonEffiBranches> EffiBranch_Ptr; @@ -96,13 +96,14 @@ namespace TestMuonSF { //################################################################### class MuonSFBranches: public MuonEffiBranches { public: - MuonSFBranches(TTree* tree, const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle, const std::string& rel_name = ""); - virtual CP::CorrectionCode fill(const xAOD::Muon& muon); - - virtual bool init(); - virtual std::string name() const; + MuonSFBranches(TTree* tree, const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle, const std::string& rel_name = ""); + CP::CorrectionCode fill(const xAOD::Muon& muon) override; + virtual ~MuonSFBranches() = default; + bool init() override; + std::string name() const override; private: ToolHandle<CP::IMuonEfficiencyScaleFactors> m_handle; + bool m_uncorrelate_sys; std::string m_release; //SF's @@ -114,6 +115,8 @@ namespace TestMuonSF { float mc_eff; float data_eff; }; + + CP::CorrectionCode fill_systematic(const xAOD::Muon muon, std::pair<const CP::SystematicSet, MuonSFBranches::SFSet>& set); bool AddToTree(const CP::SystematicSet& syst, MuonSFBranches::SFSet& ScaleFactor); std::map<CP::SystematicSet, SFSet> m_SFs; @@ -126,10 +129,10 @@ namespace TestMuonSF { class MuonReplicaBranches: public MuonEffiBranches { public: MuonReplicaBranches(TTree* tree, const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle, const std::string& rel_name = ""); - virtual CP::CorrectionCode fill(const xAOD::Muon& muon); + CP::CorrectionCode fill(const xAOD::Muon& muon) override; - virtual bool init(); - virtual std::string name() const; + bool init() override; + std::string name() const override; private: ToolHandle<CP::IMuonEfficiencyScaleFactors> m_handle; std::string m_release; @@ -143,10 +146,10 @@ namespace TestMuonSF { class MuonInfoBranches: public MuonEffiBranches { public: MuonInfoBranches(TTree* tree, const ToolHandle<CP::IMuonSelectionTool>& sel_tool); - virtual ~MuonInfoBranches(); - virtual bool init(); - virtual std::string name() const; - virtual CP::CorrectionCode fill(const xAOD::Muon& muon); + virtual ~MuonInfoBranches() = default; + bool init() override; + std::string name() const override; + CP::CorrectionCode fill(const xAOD::Muon& muon) override; private: const ToolHandle<CP::IMuonSelectionTool>& m_selection_tool; @@ -170,7 +173,7 @@ namespace TestMuonSF { MuonSFTestHelper(std::shared_ptr<TTree> Tree, const std::string& release_name = ""); MuonSFTestHelper(TTree*Tree, const std::string& release_name = ""); - ~MuonSFTestHelper(); + ~MuonSFTestHelper() = default; //Initialize the tool bool init(); diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EffiCollection.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EffiCollection.cxx index 44f21eda53e18bc9b33024a31ad667d57c9f8e63..31bae725abd6a1e1d9eff1557eff24f0c137b6a8 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EffiCollection.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EffiCollection.cxx @@ -8,8 +8,12 @@ #include <MuonEfficiencyCorrections/UtilFunctions.h> #include <TTree.h> namespace CP { - const std::vector<std::string> ToRemove { "GeV", "MeV", "[", "]", "{", "}", "(", ")", "#", " " }; - const std::vector<std::string> ToReplace { "-", "." }; + namespace { + static const std::vector<std::string> ToRemove { "GeV", "MeV", "[", "]", "{", "}", "(", ")", "#", " " }; + typedef std::pair<std::string,std::string> stringpair; + static const std::vector<stringpair> ToReplace { stringpair("-","minus"), stringpair(".","p")}; + + } EffiCollection::EffiCollection(const MuonEfficiencyScaleFactors& ref_tool) : m_ref_tool(ref_tool), m_central_eff(), @@ -100,16 +104,17 @@ namespace CP { /// bin numbers unsigned int n = m_central_eff->nBins(); std::function<void (CollectionContainer*)> assign_mapping = [this, &n](CollectionContainer* container){ - if (container != m_central_eff.get()){ + if (container != m_central_eff.get() && container->separateBinSyst()){ container->SetGlobalOffSet(n); - n += container->nBins(); + n += container->nBins(); }; }; assign_mapping(m_calo_eff.get()); assign_mapping(m_calo_eff.get()); - assign_mapping(m_forward_eff.get()); assign_mapping(m_lowpt_central_eff.get()); assign_mapping(m_lowpt_calo_eff.get()); + + assign_mapping(m_forward_eff.get()); /// Systematic constructor has been called. We can now assemble /// the systematic variations @@ -125,9 +130,9 @@ namespace CP { std::shared_ptr<CollectionContainer> container = retrieveContainer(file_type); if (container->isNominal()) continue; - if (container->seperateBinSyst()){ + if (container->separateBinSyst()){ /// Let the world implode... Yeaha register foreach bin - /// a systematic variation + /// a systematic variation for (unsigned int b = container->nBins() - 1; b > 0 ; --b){ unsigned int bin = b + container->globalOffSet(); if (container->isOverFlowBin(bin)) continue; @@ -222,8 +227,8 @@ namespace CP { for (const std::string& R : ToRemove) { BinName = ReplaceExpInString(BinName, R, ""); } - for (const std::string& R : ToReplace) { - BinName = ReplaceExpInString(BinName, R, "_"); + for (const stringpair& R : ToReplace) { + BinName = ReplaceExpInString(BinName, R.first, R.second); } return BinName; } @@ -404,9 +409,9 @@ namespace CP { if (m_SF.empty()) return false; return (*m_SF.begin())->IsUpVariation(); } - bool CollectionContainer::seperateBinSyst() const { + bool CollectionContainer::separateBinSyst() const { if (m_SF.empty()) return false; - return (*m_SF.begin())->SeperateSystBins(); + return (*m_SF.begin())->separateBinSyst(); } std::string CollectionContainer::sysname() const{ if (m_SF.empty()) return "UNKNOWN SYST"; diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EfficiencyScaleFactor.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EfficiencyScaleFactor.cxx index 3cc105aac3668dc441276b61b1998ee4410dd7ec..0ccd5fc5415e31fc297ee3ab5449d20ea37fbf8c 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EfficiencyScaleFactor.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/EfficiencyScaleFactor.cxx @@ -20,7 +20,7 @@ namespace CP { m_is_up(syst_type_bitmap & EffiCollection::UpVariation), m_is_lowpt(syst_type_bitmap & EffiCollection::JPsiAnalysis), m_respond_to_kineDepSyst(syst_type_bitmap & EffiCollection::PtDependent), - m_seperateBinSyst(syst_type_bitmap & EffiCollection::UnCorrelated), + m_separateBinSyst(syst_type_bitmap & EffiCollection::UnCorrelated), m_sf(), m_eff(), m_mc_eff(), @@ -44,7 +44,9 @@ namespace CP { m_firstRun(1), m_lastRun(999999){ - + if (ref_tool.measurement() == CP::MuonEfficiencyType::Iso){ + dRJetAxisHandler::set_close_jet_decorator(ref_tool.close_by_jet_decoration()); + } // open the file std::unique_ptr<TFile> f (TFile::Open(file.c_str(), "READ")); if (!f || !f->IsOpen()) { @@ -175,8 +177,8 @@ namespace CP { std::string EfficiencyScaleFactor::sysname(bool with_direction) const { return m_syst_name.empty() ? "" : EfficiencyTypeName(m_measurement) + "_" + m_syst_name +(m_is_lowpt ? "_LOWPT" : "") + (with_direction ? (m_is_up ?"__1UP" : "__1DN") :""); } - bool EfficiencyScaleFactor::SeperateSystBins() const { - return m_seperateBinSyst; + bool EfficiencyScaleFactor::separateBinSyst() const { + return m_separateBinSyst; } bool EfficiencyScaleFactor::IsUpVariation() const{ return m_is_up; @@ -286,7 +288,7 @@ namespace CP { return m_sf ? m_sf->isOverFlowBin(b) : true; } CorrectionCode EfficiencyScaleFactor::ScaleFactor(const xAOD::Muon& mu, float & SF) const { - if (m_seperateBinSyst && m_NominalFallBack) { + if (m_separateBinSyst && m_NominalFallBack) { int bin = -1; CorrectionCode cc = m_sf->FindBin(mu, bin); if (cc == CP::CorrectionCode::Error) { @@ -302,7 +304,7 @@ namespace CP { } CorrectionCode EfficiencyScaleFactor::DataEfficiency(const xAOD::Muon& mu, float & Eff) const { - if (m_seperateBinSyst && m_NominalFallBack && m_eff) { + if (m_separateBinSyst && m_NominalFallBack && m_eff) { int bin = -1; CorrectionCode cc = m_eff->FindBin(mu, bin); if (cc == CP::CorrectionCode::Error) { @@ -317,7 +319,7 @@ namespace CP { return cc; } CorrectionCode EfficiencyScaleFactor::MCEfficiency(const xAOD::Muon& mu, float & Eff) const { - if (m_seperateBinSyst && m_NominalFallBack && m_mc_eff) { + if (m_separateBinSyst && m_NominalFallBack && m_mc_eff) { int bin = -1; CorrectionCode cc = m_mc_eff->FindBin(mu, bin); if (cc == CP::CorrectionCode::Error) { @@ -459,7 +461,7 @@ namespace CP { Error("EfficiencyScaleFactor::SetSystematicBin()", "No fallback has been given for %s", sysname().c_str()); return false; } - if (!m_seperateBinSyst || bin < 1 || bin > nBins()) { + if (!m_separateBinSyst || bin < 1 || bin > nBins()) { Error("EfficiencyScaleFactor::SetSystematicBin()", "The current bin %i is out of the maximum range %u ", bin, nBins()); return false; } diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/HistHandler.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/HistHandler.cxx index 0bd3f9df1746d4186b280ed362791b95497ecedc..648cb410fab2aa16ff85b1b18f27ef92692562f7 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/HistHandler.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/HistHandler.cxx @@ -2,8 +2,9 @@ Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ -#include "MuonEfficiencyCorrections/HistHandler.h" +#include <MuonEfficiencyCorrections/HistHandler.h> #include <MuonEfficiencyCorrections/UtilFunctions.h> + #include <iostream> #include <cmath> #include <cstdint> @@ -12,9 +13,7 @@ #include <TH1.h> #include <TH2Poly.h> -ANA_MSG_SOURCE (msgMuonEfficiency, "MuonEfficiency") namespace CP { - using namespace msgMuonEfficiency; //########################################################################################################### // AxisHandlerProvider //########################################################################################################### @@ -45,6 +44,68 @@ namespace CP { } return std::make_unique<UndefinedAxisHandler>(); } + + + CorrectionCode PtAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + value = mu.pt() / 1000.; + return CorrectionCode::Ok; + } + CorrectionCode ChargeAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + value = mu.charge(); + return CorrectionCode::Ok; + } + CorrectionCode EtaAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + value = mu.eta(); + return CorrectionCode::Ok; + } + CorrectionCode AbsEtaAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + value = std::abs(mu.eta()); + return CorrectionCode::Ok; + } + CorrectionCode PhiAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + value = mu.phi(); + return CorrectionCode::Ok; + } + void dRJetAxisHandler::set_close_jet_decorator(const std::string& decor_name){ + m_close_jet_decor = decor_name; + } + + std::string dRJetAxisHandler::m_close_jet_decor = "dRJet"; + dRJetAxisHandler::dRJetAxisHandler(): + m_acc(m_close_jet_decor){} + + CorrectionCode dRJetAxisHandler::GetBinningParameter(const xAOD::Muon & mu, float & value) const { + static std::atomic<unsigned int> warned = {0}; + static const SG::AuxElement::ConstAccessor<float> acc_dR_deriv("DFCommonJetDr"); + if (acc_dR_deriv.isAvailable(mu)){ + value = m_acc(mu); + }else if( m_acc.isAvailable(mu) ) { + // decoration available in DxAOD + value = m_acc(mu); + if (warned < 5){ + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "The DFCommonJetDr jet decoration is not available in the derivaiton will fall back to %s",m_close_jet_decor.c_str()); + ++warned; + } + } else { + // decoration not available + value = -2.; + // We want these warnings to be printed few times per job, so that they're visible, then stop before log file's size blows up + if (warned<5){ + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "The %s decoration has not been found for the Muon. Isolation scale-factors are now also binned in #Delta R(jet,#mu)", m_close_jet_decor.c_str()); + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "using the closest calibrated AntiKt4EMTopo jet with p_{T}>20~GeV and surving the standard OR criteria."); + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "You should decorate your muon appropiately before passing to the tool, and use dRJet = -1 in case there is no jet in an event."); + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "For the time being the inclusive scale-factor is going to be returned."); + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "In future derivations, muons will also be decorated centrally with DFCommonJetDr, for your benefit."); + Warning("MuonEfficiencyCorrections::dRJetAxisHandler()", "You can define custom jet decorations via the 'CloseJetDRDecorator' property of the MuonEfficiencyCorrections tool"); + ++warned; + } + } + return CorrectionCode::Ok; + } + + CorrectionCode UndefinedAxisHandler::GetBinningParameter(const xAOD::Muon &, float &) const { + return CorrectionCode::Error; + } //########################################################################################################### // HistHandler //########################################################################################################### @@ -104,7 +165,7 @@ namespace CP { bool HistHandler_TH1::isOverFlowBin(int b) const { return b == 0 || b >= nBins() -1; } std::string HistHandler_TH1::GetBinName(unsigned int bin) const { TAxis* xAx = GetHist()->GetXaxis(); - return Form("%s_%.2f-%.2f", xAx->GetTitle(), xAx->GetBinLowEdge(bin), xAx->GetBinUpEdge(bin)); + return Form("%s_%.2f_to_%.2f", xAx->GetTitle(), xAx->GetBinLowEdge(bin), xAx->GetBinUpEdge(bin)); } CorrectionCode HistHandler_TH1::FindBin(const xAOD::Muon & muon, int & bin) const { if (!GetHist()) { @@ -179,7 +240,7 @@ namespace CP { GetHist()->GetBinXYZ(bin, x, y, z); TAxis* xAx = GetHist()->GetXaxis(); TAxis* yAx = GetHist()->GetYaxis(); - return Form("%s_%.2f-%.2f--%s_%.2f-%.2f", + return Form("%s_%.2f_to_%.2f_times_%s_%.2f_to_%.2f", //xAxis xAx->GetTitle(), xAx->GetBinLowEdge(x), xAx->GetBinUpEdge(x), //yAxis @@ -254,7 +315,7 @@ namespace CP { TAxis* xAx = GetHist()->GetXaxis(); TAxis* yAx = GetHist()->GetYaxis(); TAxis* zAx = GetHist()->GetZaxis(); - return Form("%s_%.2f-%.2f--%s_%.2f-%.2f--%s_%.2f-%.2f", + return Form("%s_%.2f_to_%.2f_times_%s_%.2f_to_%.2f_times_%s_%.2f_to_%.2f", //xAxis xAx->GetTitle(), xAx->GetBinLowEdge(x), xAx->GetBinUpEdge(x), //yAxis @@ -322,10 +383,8 @@ namespace CP { GetHist()->GetBinXYZ(bin, x, y, z); TAxis* xAx = GetHist()->GetXaxis(); TAxis* yAx = GetHist()->GetYaxis(); - return Form("%s_%.2f-%.2f--%s_%.2f-%.2f", - //xAxis + return Form("%s_%.2f_to_%.2f__times_%s_%.2f_to_%.2f", xAx->GetTitle(), xAx->GetBinLowEdge(x), xAx->GetBinUpEdge(x), - //yAxis yAx->GetTitle(), yAx->GetBinLowEdge(y), yAx->GetBinUpEdge(y)); } } // namespace CP diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonEfficiencyScaleFactors.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonEfficiencyScaleFactors.cxx index a0734953d393a65a271c76a52777bdae51f6dbb2..42d441877c3deb7c80816d6197ee1070eb7e838c 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonEfficiencyScaleFactors.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonEfficiencyScaleFactors.cxx @@ -33,6 +33,7 @@ namespace CP { m_sf_decoration_name(), m_calibration_version("200513_Precision_r21"), m_lowpt_threshold(15.e3), + m_iso_jet_dR("dRJet"), m_affectingSys(), m_filtered_sys_sets(), m_init(false), @@ -66,13 +67,17 @@ namespace CP { declareProperty("LowPtThreshold", m_lowpt_threshold); declareProperty("UncorrelateSystematics", m_seperateSystBins); declareProperty("BreakDownSystematics", m_breakDownSyst); + /// Name of the decorator carrying the information the distance to the + /// next what ever jet (AntiKt4EMTopo,....) + declareProperty("CloseJetDRDecorator", m_iso_jet_dR); } - - MuonEfficiencyScaleFactors::~MuonEfficiencyScaleFactors() { + std::string MuonEfficiencyScaleFactors::close_by_jet_decoration() const{ + return m_iso_jet_dR; } float MuonEfficiencyScaleFactors::lowPtTransition() const{ return m_lowpt_threshold; } + bool MuonEfficiencyScaleFactors::uncorrelate_sys() const { return m_seperateSystBins; } CP::MuonEfficiencyType MuonEfficiencyScaleFactors::measurement() const{ return m_Type; } @@ -134,6 +139,7 @@ namespace CP { } else { ATH_MSG_INFO("JPsi based low pt SF will start to rock below " << m_lowpt_threshold / 1000. << " GeV!"); } + std::set<std::string> decorations{ sf_decoration() , data_effi_decoration(), @@ -533,7 +539,7 @@ namespace CP { m_current_sf = itr->second; if (m_seperateSystBins && !itr->first.name().empty()){ - for (std::set<SystematicVariation>::iterator t = mySysConf.begin(); t != mySysConf.end(); ++t) { + for (std::set<SystematicVariation>::const_iterator t = mySysConf.begin(); t != mySysConf.end(); ++t) { if ((*t).isToyVariation()) { // First entry corresponds to the bin number and // the second entry to the position in which the map is ordered @@ -551,7 +557,7 @@ namespace CP { } std::string MuonEfficiencyScaleFactors::getUncorrelatedSysBinName(unsigned int Bin) const { if (!m_current_sf){ - throw std::runtime_error("No systematic has been loaded. Cannot return any syst-bin") ; + throw std::runtime_error("No systematic has been loaded. Cannot return any syst-bin") ; ATH_MSG_FATAL("No systematic has been loaded. Cannot return any syst-bin"); } diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonSFTestHelper.cxx b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonSFTestHelper.cxx index decd092d7e7da6143eda4dd3789aff756f7f467c..a27b3722164eb7a0defcdeeeaa85a8890ea176d7 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonSFTestHelper.cxx +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/Root/MuonSFTestHelper.cxx @@ -4,6 +4,8 @@ #include "MuonEfficiencyCorrections/MuonSFTestHelper.h" #include "MuonEfficiencyCorrections/UtilFunctions.h" +#include "MuonEfficiencyCorrections/MuonEfficiencyScaleFactors.h" + #include "PATInterfaces/SystematicsUtil.h" #include <TH1D.h> @@ -29,8 +31,6 @@ namespace TestMuonSF { SFBranches::SFBranches(TTree* tree) : m_tree(tree) { } - SFBranches::~SFBranches() { - } //############################################################ // TriggerSFBranches //############################################################ @@ -44,8 +44,6 @@ namespace TestMuonSF { m_sys_up_SF(1.), m_sys_down_SF(1.) { } - TriggerSFBranches::~TriggerSFBranches() { - } CP::CorrectionCode TriggerSFBranches::fill(const xAOD::MuonContainer* muons) { if (getSF(muons, m_nominal_SF, CP::SystematicVariation("", 0)) == CP::CorrectionCode::Error) return CP::CorrectionCode::Error; if (getSF(muons, m_stat_up_SF, CP::SystematicVariation("MUON_EFF_TrigStatUncertainty", +1)) == CP::CorrectionCode::Error) return CP::CorrectionCode::Error; @@ -82,48 +80,87 @@ namespace TestMuonSF { MuonEffiBranches::MuonEffiBranches(TTree* tree) : SFBranches(tree) { } - MuonEffiBranches::~MuonEffiBranches() { - } //############################################################ // MuonSFBranches //############################################################ MuonSFBranches::MuonSFBranches(TTree* tree, const ToolHandle<CP::IMuonEfficiencyScaleFactors> &handle, const std::string& rel_name) : MuonEffiBranches(tree), m_handle(handle), + m_uncorrelate_sys(dynamic_cast<const CP::MuonEfficiencyScaleFactors*>(handle.operator->())->uncorrelate_sys()), m_release(rel_name), m_SFs() { } CP::CorrectionCode MuonSFBranches::fill(const xAOD::Muon& muon) { - for (auto& Syst_SF : m_SFs) { - if (m_handle->applySystematicVariation(Syst_SF.first) != CP::SystematicCode::Ok) { - Error("MuonSFBranches()", "Failed to apply variation %s for %s", Syst_SF.first.name().c_str(), name().c_str()); - return CP::CorrectionCode::Error; - } - CP::CorrectionCode cc = m_handle->getEfficiencyScaleFactor(muon, Syst_SF.second.scale_factor); - if (cc == CP::CorrectionCode::Error) { - Error("MuonSFBranches()", "Failed to retrieve %s scale-factor for variation %s", name().c_str(), Syst_SF.first.name().c_str()); - return CP::CorrectionCode::Error; - } - - /// No data-mc efficiencies provided for eta beyond 2.5 - if (std::abs(muon.eta()) > 2.5) { - Syst_SF.second.data_eff = -1; - Syst_SF.second.mc_eff = -1; - continue; - } - cc = m_handle->getDataEfficiency(muon, Syst_SF.second.data_eff); - if (cc == CP::CorrectionCode::Error) { - Error("MuonSFBranches()", "Failed to retrieve %s data efficiency for variation %s", name().c_str(), Syst_SF.first.name().c_str()); - return CP::CorrectionCode::Error; - } - cc = m_handle->getMCEfficiency(muon, Syst_SF.second.mc_eff); - if (cc == CP::CorrectionCode::Error) { - Error("MuonSFBranches()", "Failed to retrieve %s mc efficiency for variation %s", name().c_str(), Syst_SF.first.name().c_str()); - return CP::CorrectionCode::Error; + /// Only the raw systematic sets have been activated + /// We can loop over each set and fill it properly + if (!m_uncorrelate_sys){ + for (auto& Syst_SF : m_SFs) { + CP::CorrectionCode cc = fill_systematic(muon,Syst_SF); + if (cc == CP::CorrectionCode::Error) return cc; } - } + } else { + int bin = m_handle->getUnCorrelatedSystBin(muon); + if (bin < 0){ + Warning("MuonSFBranches()", "Did not find a valid bin for muon with pT: %.2f GeV, eta: %.2f, phi: %2.f", + muon.pt(), muon.eta(),muon.phi()); + return CP::CorrectionCode::OutOfValidityRange; + } + for (auto& Syst_SF: m_SFs){ + /// Only process the nominal set or the set matching the syst bin + bool process = false; + if (Syst_SF.first.name().empty()) process =true; + else { + for (std::set<CP::SystematicVariation>::const_iterator t = Syst_SF.first.begin(); t != Syst_SF.first.end(); ++t) { + if ((*t).isToyVariation()) { + std::pair<unsigned, float> pair = (*t).getToyVariation(); + if (pair.first == (unsigned) bin){ + process = true; + break; + } + } + } + } + if (process) { + CP::CorrectionCode cc = fill_systematic(muon, Syst_SF); + if (cc == CP::CorrectionCode::Error) return cc; + } else { + /// Assign a dummy value + Syst_SF.second.scale_factor = Syst_SF.second.mc_eff = Syst_SF.second.data_eff = -1.; + } + } + } return CP::CorrectionCode::Ok; } + CP::CorrectionCode MuonSFBranches::fill_systematic(const xAOD::Muon muon, std::pair<const CP::SystematicSet, MuonSFBranches::SFSet>& Syst_SF){ + if (m_handle->applySystematicVariation(Syst_SF.first) != CP::SystematicCode::Ok) { + Error("MuonSFBranches()", "Failed to apply variation %s for %s", Syst_SF.first.name().c_str(), name().c_str()); + return CP::CorrectionCode::Error; + } + CP::CorrectionCode cc = m_handle->getEfficiencyScaleFactor(muon, Syst_SF.second.scale_factor); + if (cc == CP::CorrectionCode::Error) { + Error("MuonSFBranches()", "Failed to retrieve %s scale-factor for variation %s", name().c_str(), Syst_SF.first.name().c_str()); + return CP::CorrectionCode::Error; + } + + /// No data-mc efficiencies provided for eta beyond 2.5 + if (std::fabs(muon.eta()) > 2.5) { + Syst_SF.second.data_eff = -1; + Syst_SF.second.mc_eff = -1; + return CP::CorrectionCode::Ok; + } + cc = m_handle->getDataEfficiency(muon, Syst_SF.second.data_eff); + if (cc == CP::CorrectionCode::Error) { + Error("MuonSFBranches()", "Failed to retrieve %s data efficiency for variation %s", name().c_str(), Syst_SF.first.name().c_str()); + return CP::CorrectionCode::Error; + } + cc = m_handle->getMCEfficiency(muon, Syst_SF.second.mc_eff); + if (cc == CP::CorrectionCode::Error) { + Error("MuonSFBranches()", "Failed to retrieve %s mc efficiency for variation %s", name().c_str(), Syst_SF.first.name().c_str()); + return CP::CorrectionCode::Error; + } + return CP::CorrectionCode::Ok; + } + std::string MuonSFBranches::name() const { return m_release + (m_release.empty() ? "" : "_") + getProperty<std::string>(m_handle.operator->(), "WorkingPoint"); } @@ -195,8 +232,6 @@ namespace TestMuonSF { m_passHighPt(false), m_precLayers(0){ } - MuonInfoBranches::~MuonInfoBranches() { - } bool MuonInfoBranches::init() { if (!initBranch(m_pt, "pt")) return false; if (!initBranch(m_eta, "eta")) return false; @@ -242,7 +277,7 @@ namespace TestMuonSF { m_Branches(), m_sel_tool(){ if (release_name.find("/") != std::string::npos) m_name = "c" + release_name.substr(release_name.rfind("/") + 1, m_name.size()); // branches cannot start with number - m_Branches.push_back(EffiBranch_Ptr(new MuonInfoBranches(tree(),m_sel_tool))); + m_Branches.push_back(std::make_unique<TestMuonSF::MuonInfoBranches>(tree(),m_sel_tool)); if (HasOwnerShip) m_tree = std::shared_ptr < TTree > (m_tree_raw_ptr); } MuonSFTestHelper::MuonSFTestHelper(std::shared_ptr<TTree> tree, const std::string& release_name) : @@ -261,19 +296,17 @@ namespace TestMuonSF { m_sel_tool(){ if (release_name.find("/") != std::string::npos) m_name = "c" + release_name.substr(release_name.rfind("/") + 1, m_name.size()); // branches cannot start with number } - MuonSFTestHelper::~MuonSFTestHelper() { - } void MuonSFTestHelper::addTool(const asg::AnaToolHandle<CP::IMuonEfficiencyScaleFactors> &handle) { addTool(handle.getHandle()); } void MuonSFTestHelper::addTool(const ToolHandle<CP::IMuonEfficiencyScaleFactors>& handle) { - m_Branches.push_back(EffiBranch_Ptr(new MuonSFBranches(tree(), handle, m_name))); + m_Branches.push_back(std::make_unique<TestMuonSF::MuonSFBranches>(tree(), handle, m_name)); } void MuonSFTestHelper::addReplicaTool(const asg::AnaToolHandle<CP::IMuonEfficiencyScaleFactors> &handle) { addReplicaTool(handle.getHandle()); } void MuonSFTestHelper::addReplicaTool(const ToolHandle<CP::IMuonEfficiencyScaleFactors>& handle) { - m_Branches.push_back(EffiBranch_Ptr(new MuonReplicaBranches(tree(), handle, m_name))); + m_Branches.push_back(std::make_unique<TestMuonSF::MuonReplicaBranches>(tree(), handle, m_name)); } void MuonSFTestHelper::setSelectionTool(const asg::AnaToolHandle<CP::IMuonSelectionTool> & sel_tool){ setSelectionTool(sel_tool.getHandle()); diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/macros/CheckAppliedSFs.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/macros/CheckAppliedSFs.py index 12a6a852e140d899294d47b6ae61f9591195c108..789f9d80407cda57cf00b3433b1e5c65f26a518f 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/macros/CheckAppliedSFs.py +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/macros/CheckAppliedSFs.py @@ -23,11 +23,19 @@ class ReleaseComparer(object): ### Direct access to the branch which are going to be compared self.__old_branch = test_tree.GetLeaf(branch_old) self.__new_branch = test_tree.GetLeaf(branch_new) - + if not self.__old_branch: + raise NameError("Could not find "+branch_old+" in the Tree") + + if not self.__new_branch: + raise NameError("Could not find "+branch_new+" in the Tree") ### Weights as a function of the muon kinematics self.__old_weight = 1. if not weight_old else test_tree.GetLeaf(weight_old) self.__new_weight = 1. if not weight_new else test_tree.GetLeaf(weight_new) - + if weight_old and not self.__old_weight: + raise NameError("Could not find "+weight_old+" in the Tree") + if weight_new and not self.__new_weight: + raise NameError("Could not find "+weight_new+" in the Tree") + self.__quality_branch = test_tree.GetLeaf("Muon_quality") if branch_old.find("HighPt") != -1 : self.__quality_branch = test_tree.GetLeaf("Muon_isHighPt") if branch_old.find("LowPt") != -1 : self.__quality_branch = test_tree.GetLeaf("Muon_isLowPt") @@ -112,6 +120,11 @@ class SystematicComparer(ReleaseComparer): log_binning = True) self.__sys_old = test_tree.GetLeaf(branch_sys_old) self.__sys_new = test_tree.GetLeaf(branch_sys_new) + if not self.__sys_old: + raise NameError("Failed to retrieve "+branch_sys_old) + if not self.__sys_new: + raise NameError("Failed to retrieve "+branch_sys_new) + def fill(self): self.get_old_histo().fill(value = math.fabs(self.get_old_var().GetValue() - self.__sys_old.GetValue()) / (self.get_old_var().GetValue() if self.get_old_var().GetValue() != 0. else 1.) , @@ -125,8 +138,11 @@ KnownWPs = { "Loose" : "RECO", "Medium" : "RECO", "Tight" : "RECO", + "HightPt3Layers":"RECO", "HighPt" : "RECO", "LowPt" : "RECO", + "LowPtMVA" : "RECO", + "TTVA" : "TTVA", "FCLooseIso": "ISO", "FCTight_FixedRadIso": "ISO", @@ -146,12 +162,6 @@ def getArgParser(): parser.add_argument('-o', '--outDir', help='Specify a destination directory', default="Plots") parser.add_argument('-l', '--label', help='Specify the dataset you used with MuonEfficiencyCorrectionsSFFilesTest', default="Internal") parser.add_argument('-w', '--WP', help='Specify a WP to plot', nargs='+', default=[]) - parser.add_argument('--varType', help='Specify a variation type', nargs='+', default=["", - "MUON_EFF_RECO_SYS_LOWPT__1down", - "MUON_EFF_RECO_STAT_LOWPT__1down", - "MUON_EFF_RECO_SYS__1down", - "MUON_EFF_RECO_STAT__1down" - ]) parser.add_argument('-c', '--SFConstituent', help='Specify if you want to plot nominal value, sys or stat error', nargs='+', default=["SF","DataEff","MCEff"]) parser.add_argument('--bonusname', help='Specify a bonus name for the filename', default="") parser.add_argument('--bonuslabel', help='Specify a bonus label printed in the histogram', default="") @@ -165,19 +175,25 @@ def getCalibReleasesAndWP(tree): allWPs = set([wp for wp in KnownWPs.iterkeys() ]) WPs = [] for i in branchesInFile: + print i if not i.endswith("SF"): continue if not i.startswith("c"): continue calibCand = i[1:-3] - beststr = "" - for wp in allWPs: - wpstr = "_"+wp - if not wpstr in calibCand: continue - if calibCand.rfind(wpstr) < calibCand.rfind(beststr): beststr = wpstr - if len(beststr) > 0: - if not beststr[1:] in WPs: WPs.append(beststr[1:]) - if not calibCand.replace(beststr,"") in calibReleases: calibReleases.append(calibCand.replace(beststr,"")) + + wp_str = i[ : i.rfind("_")] + beststr = wp_str[wp_str.rfind("_")+1 : ] + if beststr in allWPs: + if not beststr in WPs: WPs.append(beststr) + if not calibCand[ : calibCand.find(beststr)-1] in calibReleases: calibReleases.append(calibCand[ : calibCand.find(beststr)-1]) print "INFO: Found the following working points: %s"%(", ".join(WPs)) return calibReleases, WPs + +def getSystematics(tree, wp, calib_release): + search_str = "c%s_%s_SF"%(calib_release, wp) + syst_names = [key.GetName()[len(search_str) + 2:] for key in tree.GetListOfBranches() if key.GetName().startswith(search_str) and key.GetName() != search_str] + print syst_names + return syst_names + if __name__ == "__main__": Options = getArgParser().parse_args() @@ -212,12 +228,13 @@ if __name__ == "__main__": Histos = [] for wp in WPs: + systematics = getSystematics(tree,wp, calibReleases[0])+[""] for t in Options.SFConstituent: corrType = "Scale Factor" if t == "DataEff": corrType = "Data efficiency" elif t == "MCEff": corrType = "MC efficiency" - for var in Options.varType: + for var in systematics: if len(var) == 0: Histos += [ ReleaseComparer( @@ -237,8 +254,8 @@ if __name__ == "__main__": test_tree = tree, branch_old = "c%s_%s_%s"%(calibReleases[0],wp,t), branch_new = "c%s_%s_%s"%(calibReleases[1],wp,t), - branch_sys_old = "c%s_%s_%s__%s"%(calibReleases[0],wp,t,var.replace("RECO",KnownWPs[wp])), - branch_sys_new = "c%s_%s_%s__%s"%(calibReleases[1],wp,t,var.replace("RECO",KnownWPs[wp])), + branch_sys_old = "c%s_%s_%s__%s"%(calibReleases[0],wp,t,var), + branch_sys_new = "c%s_%s_%s__%s"%(calibReleases[1],wp,t,var), )] continue diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/share/MuonEfficiencyCorrections_xAOD_Testing_jobOptions.py b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/share/MuonEfficiencyCorrections_xAOD_Testing_jobOptions.py index bf85ce524b8e931e6ab8ddc7158b4a829e5a85a7..ef51eebeeb36f3d5ada3c6d7d256259a5ff9dcb3 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/share/MuonEfficiencyCorrections_xAOD_Testing_jobOptions.py +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/share/MuonEfficiencyCorrections_xAOD_Testing_jobOptions.py @@ -29,55 +29,53 @@ theJob += CP__MuonCloseJetDecorationAlg("JetDecorationAlg", alg = CP__MuonEfficiencyCorrections_TestAlg("EffiTestAlg") alg.PileupReweightingTool = GetPRWTool() alg.MuonSelectionTool = GetSelectionTool() -alg.DefaultRelease="cFeb_2019" -alg.ValidationRelease="cJan_2020" +alg.DefaultRelease="cJan_2020" +alg.ValidationRelease="cApr_2020" alg.SGKey = "CalibratedMuons" ## Select 30 GeV muons for the high-pt WP only alg.MinPt = 3.e3 alg.MaxEta = 2.5 WPs = [ - # reconstruction WPs + # reconstruction WPs "LowPt", "Loose", "Medium", "Tight", - #"HighPt", - #"CaloTag", - # track-to-vertex-association WPs - #"TTVA", - # BadMuon veto SFs - "BadMuonVeto_HighPt", - # isolation WPs - "FCLooseIso", + "HighPt", + "CaloTag", + "HighPt3Layers", + "LowPtMVA", + # track-to-vertex-association WPs + "TTVA", + # BadMuon veto SFs + "BadMuonVeto_HighPt", + # isolation WPs + "FCLooseIso", + "FCTightIso", + "FCTightTrackOnlyIso", + "FCLoose_FixedRadIso", "FCTight_FixedRadIso", - "FCLoose_FixedRadIso", + "FCTightTrackOnly_FixedRadIso", + "FCTight_FixedRadIso", "FixedCutHighPtTrackOnlyIso", - "FCTightIso", - "FixedCutPflowLooseIso", - "FCTightTrackOnlyIso", + "FixedCutPflowLooseIso", "FixedCutPflowTightIso", - "FCTightTrackOnly_FixedRadIso", - ] + ] for WP in WPs: alg.EfficiencyTools += [GetMuonEfficiencyTool(WP, - Release="191111_Winter_PrecisionZ", - BreakDownSystematics=False, - UncorrelateSystematics=False)] + Release="200202_Precision_r21", + BreakDownSystematics=False, + UncorrelateSystematics=False)] alg.EfficiencyToolsForComparison += [GetMuonEfficiencyTool(WP, CustomInput = "/ptmp/mpp/junggjo9/Cluster/SFFiles/Feb_2020_iso/", BreakDownSystematics=False, UncorrelateSystematics=False)] - -#ToolSvc.MuonEfficiencyTool_CaloTag.ApplyKinematicSystematic = False -#ToolSvc.MuonEfficiencyTool_CaloTag_190530_r21.ApplyKinematicSystematic = False -### New working points -for WP in["HighPt3Layers", "LowPtMVA"]: - break - alg.EfficiencyTools += [GetMuonEfficiencyTool(WP, - CustomInput = "/eos/user/j/jojungge/AutumunRecommendations/to_copy/")] - alg.EfficiencyToolsForComparison += [GetMuonEfficiencyTool(WP, - CustomInput = "/eos/user/j/jojungge/AutumunRecommendations/to_copy/")] +try: ToolSvc.MuonEfficiencyTool_CaloTag.ApplyKinematicSystematic = False +except: pass +try: ToolSvc.MuonEfficiencyTool_CaloTag_200202_Precision_r21.ApplyKinematicSystematic = False +except: pass + theJob += alg # Do some additional tweaking: diff --git a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/src/MuonEfficiencyCorrections_TestAlg.h b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/src/MuonEfficiencyCorrections_TestAlg.h index 53f4a93483d780a359464e639ade08480d715808..e82c0569a6fc9a65fc86cccb6f0f9b355dbb9bd3 100644 --- a/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/src/MuonEfficiencyCorrections_TestAlg.h +++ b/PhysicsAnalysis/MuonID/MuonIDAnalysis/MuonEfficiencyCorrections/src/MuonEfficiencyCorrections_TestAlg.h @@ -32,11 +32,10 @@ namespace CP { MuonEfficiencyCorrections_TestAlg(const std::string& name, ISvcLocator* svcLoc); /// Function initialising the algorithm - virtual StatusCode initialize(); + StatusCode initialize() override; /// Function executing the algorithm - virtual StatusCode execute(); - virtual ~MuonEfficiencyCorrections_TestAlg() { - } + StatusCode execute() override; + virtual ~MuonEfficiencyCorrections_TestAlg() = default; private: SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};