From 636ab22f851030b2a36aab36f04b068d17271a2a Mon Sep 17 00:00:00 2001
From: sahinsoy <merve.sahinsoy@cern.ch>
Date: Tue, 5 Oct 2021 23:32:08 +0200
Subject: [PATCH 1/3] additions for muon iso break down systematics

---
 .../TopAnalysis/Root/EventSaverFlatNtuple.cxx |  92 +++++++++++-
 .../TopAnalysis/EventSaverFlatNtuple.h        |  23 +++
 .../xAOD/TopCPTools/Root/TopMuonCPTools.cxx   |  34 ++---
 .../TopCPTools/TopCPTools/TopMuonCPTools.h    |   2 +-
 .../Root/MuonScaleFactorCalculator.cxx        | 137 ++++++++++++++++--
 .../Root/ScaleFactorRetriever.cxx             | 119 +++++++++++++++
 .../MuonScaleFactorCalculator.h               |  21 +++
 .../TopCorrections/ScaleFactorRetriever.h     |  11 ++
 8 files changed, 402 insertions(+), 37 deletions(-)

diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
index 79443b4bd19e..2b62b3bd7777 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
@@ -98,6 +98,17 @@ namespace top {
     m_weight_leptonSF_MU_SF_Isol_STAT_DOWN(0.),
     m_weight_leptonSF_MU_SF_Isol_SYST_UP(0.),
     m_weight_leptonSF_MU_SF_Isol_SYST_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_MC_XSEC_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_MC_XSEC_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN(0.),
+    //Muon TTVA SF systematics 
     m_weight_leptonSF_MU_SF_TTVA_STAT_UP(0.),
     m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN(0.),
     m_weight_leptonSF_MU_SF_TTVA_SYST_UP(0.),
@@ -667,10 +678,64 @@ namespace top {
                                              "weight_leptonSF_MU_SF_Isol_STAT_UP");
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_STAT_DOWN,
                                              "weight_leptonSF_MU_SF_Isol_STAT_DOWN");
+
+
+
+          if (m_config->muonBreakDownSystematics()) {
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP,
+                                                "weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP,
+                                                "weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_DOWN");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MC_XSEC_UP,
+                                                "weight_leptonSF_MU_SF_Isol_MC_XSEC_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MC_XSEC_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_MC_XSEC_DOWN");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_UP,
+                                                "weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP,
+                                                "weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN");
+
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP,
+                                                "weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN");
+
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP,
+                                                "weight_leptonSF_MU_SF_Isol_DRMUJ_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN");
+
+
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_PROBEQ_UP,
+                                                "weight_leptonSF_MU_SF_Isol_PROBEQ_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN");
+
+
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP,
+                                                "weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP");
+            systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN,
+                                                "weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN");
+
+
+
+          } else {
+
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SYST_UP,
                                              "weight_leptonSF_MU_SF_Isol_SYST_UP");
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SYST_DOWN,
                                              "weight_leptonSF_MU_SF_Isol_SYST_DOWN");
+          } 
+
+         // TTVA 
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_TTVA_STAT_UP,
                                              "weight_leptonSF_MU_SF_TTVA_STAT_UP");
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN,
@@ -2053,8 +2118,31 @@ namespace top {
         // Muon isolation SF systematics
         m_weight_leptonSF_MU_SF_Isol_STAT_UP = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_STAT_UP);
         m_weight_leptonSF_MU_SF_Isol_STAT_DOWN = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_STAT_DOWN);
-        m_weight_leptonSF_MU_SF_Isol_SYST_UP = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SYST_UP);
-        m_weight_leptonSF_MU_SF_Isol_SYST_DOWN = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SYST_DOWN);
+
+        if (m_config->muonBreakDownSystematics()) {
+          m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP =       m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_BKG_FRACTION_UP);
+          m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN =     m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_BKG_FRACTION_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP =        m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_LUMI_UNCERT_UP);
+          m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_DOWN =      m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_LUMI_UNCERT_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_MC_XSEC_UP =            m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_MC_XSEC_UP);
+          m_weight_leptonSF_MU_SF_Isol_MC_XSEC_DOWN =          m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_MC_XSEC_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_UP =       m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_QCD_TEMPLATE_UP);
+          m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN =     m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_QCD_TEMPLATE_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP =   m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SUPRESSION_SCALE_UP);
+          m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SUPRESSION_SCALE_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP =          m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_MLLWINDOW_UP);
+          m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN =        m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_MLLWINDOW_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP =              m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_DRMUJ_UP);
+          m_weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN =            m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_DRMUJ_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_PROBEQ_UP =             m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_PROBEQ_UP);
+          m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN =           m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_PROBEQ_DOWN);
+          m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP =      m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SHERPA_POWHEG_UP);
+          m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN =    m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SHERPA_POWHEG_DOWN);
+        } else {
+          m_weight_leptonSF_MU_SF_Isol_SYST_UP = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SYST_UP);
+          m_weight_leptonSF_MU_SF_Isol_SYST_DOWN = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_Isol_SYST_DOWN);
+        }   
+        //Muon TTVA SF systematics
         m_weight_leptonSF_MU_SF_TTVA_STAT_UP = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_TTVA_STAT_UP);
         m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN = m_sfRetriever->leptonSF(event, top::topSFSyst::MU_SF_TTVA_STAT_DOWN);
         if (m_config->muonBreakDownSystematics()) {
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
index 1f5a6b0c278f..fd71515c41ff 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
@@ -357,6 +357,29 @@ namespace top {
     float m_weight_leptonSF_MU_SF_Isol_STAT_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_SYST_UP;
     float m_weight_leptonSF_MU_SF_Isol_SYST_DOWN;
+
+    float m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP;
+    float m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP;
+    float m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_MC_XSEC_UP;
+    float m_weight_leptonSF_MU_SF_Isol_MC_XSEC_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_UP;
+    float m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP;
+    float m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN;
+
+    float m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP;
+    float m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP;
+    float m_weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_PROBEQ_UP;
+    float m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN;
+    float m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP;
+    float m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN;
+
+
+    //Muon TTVA SF systematics
     float m_weight_leptonSF_MU_SF_TTVA_STAT_UP;
     float m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN;
     float m_weight_leptonSF_MU_SF_TTVA_SYST_UP;
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx
index 8d03e0ab8456..093f67252e3f 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx
@@ -155,22 +155,22 @@ namespace top {
     if (m_config->muonQuality() == "LowPt" && m_config->muonUseMVALowPt()) muonQuality_name = "LowPtMVA";
     m_muonEfficiencyCorrectionsTool
       = setupMuonSFTool("CP::MuonEfficiencyScaleFactorsTool",
-                        muonQuality_name,
-                        false);
+                        muonQuality_name
+                        );
 
     std::string muonQualityLoose_name = m_config->muonQualityLoose();
     if (m_config->muonQualityLoose() == "HighPt" && !(m_config->muonUse2stationMuonsHighPtLoose()) ) muonQualityLoose_name = "HighPt3Layers";
     if (m_config->muonQualityLoose() == "LowPt" && m_config->muonUseMVALowPtLoose()) muonQualityLoose_name = "LowPtMVA";
     m_muonEfficiencyCorrectionsToolLoose
       = setupMuonSFTool("CP::MuonEfficiencyScaleFactorsToolLoose",
-                        muonQualityLoose_name,
-                        false);
+                        muonQualityLoose_name
+                        );
 
     if (m_config->muonQuality() == "HighPt" || m_config->muonQualityLoose() == "HighPt") {
       m_muonEfficiencyCorrectionsToolLoose
         = setupMuonSFTool("CP::MuonEfficiencyScaleFactorsToolBadMuonVeto",
-                          "BadMuonVeto_HighPt",
-                          false);
+                          "BadMuonVeto_HighPt"
+                          );
     }
 
     //now the soft muon part
@@ -179,8 +179,8 @@ namespace top {
     if (m_config->useSoftMuons()) {
       m_softmuonEfficiencyCorrectionsTool
         = setupMuonSFTool("CP::SoftMuonEfficiencyScaleFactorsTool",
-			                    softmuonQuality_name,
-                          false);
+			                    softmuonQuality_name
+                          );
     }
     
     /************************************************************
@@ -196,8 +196,8 @@ namespace top {
       std::string muon_isolation = m_config->muonIsolationSF() + "Iso";
       m_muonEfficiencyCorrectionsToolIso =
         setupMuonSFTool("CP::MuonEfficiencyScaleFactorsToolIso",
-                        muon_isolation,
-                        true);
+                        muon_isolation
+                        );
     }
 
     // Do we have isolation on our loose muons? If not no need for the tool...
@@ -206,8 +206,8 @@ namespace top {
       std::string muon_isolation = m_config->muonIsolationSFLoose() + "Iso";
       m_muonEfficiencyCorrectionsToolLooseIso =
         setupMuonSFTool("CP::MuonEfficiencyScaleFactorsToolLooseIso",
-                        muon_isolation,
-                        true);
+                        muon_isolation
+                        );
     }
 
     /************************************************************
@@ -218,8 +218,8 @@ namespace top {
     ************************************************************/
     m_muonEfficiencyCorrectionsToolTTVA
       = setupMuonSFTool("CP::MuonEfficiencyScaleFactorsToolTTVA",
-                        "TTVA",
-                        false);
+                        "TTVA"
+                        );
 
     // WARNING - The PromptLeptonIsolation scale factors are only derived with respect to the loose PID
     //         - Hence we need to fail if this has occured
@@ -289,7 +289,7 @@ namespace top {
   }
 
   CP::IMuonEfficiencyScaleFactors*
-  MuonCPTools::setupMuonSFTool(const std::string& name, const std::string& WP, const bool isIso) {
+  MuonCPTools::setupMuonSFTool(const std::string& name, const std::string& WP) {
     CP::IMuonEfficiencyScaleFactors* tool = nullptr;
     if (asg::ToolStore::contains<CP::IMuonEfficiencyScaleFactors>(name)) {
       tool = asg::ToolStore::get<CP::MuonEfficiencyScaleFactors>(name);
@@ -304,10 +304,8 @@ namespace top {
                    "Failed to set CustomInputFolder property for MuonEfficiencyScaleFactors tool");
       }
 
-      if (!isIso) {
-        top::check(asg::setProperty(tool, "BreakDownSystematics", m_config->muonBreakDownSystematics()), 
+      top::check(asg::setProperty(tool, "BreakDownSystematics", m_config->muonBreakDownSystematics()), 
                   "Failed to set BreakDownSystematics for " + name + " tool");
-      }
       top::check(tool->initialize(),
                  "Failed to set initialize " + name);
     }
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopMuonCPTools.h b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopMuonCPTools.h
index a85c0d9bc54a..42278a74c1c5 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopMuonCPTools.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopMuonCPTools.h
@@ -71,7 +71,7 @@ namespace top {
     setupMuonTrigSFTool(const std::string& name, const std::string& quality);
 
     CP::IMuonEfficiencyScaleFactors*
-    setupMuonSFTool(const std::string& name, const std::string& WP, const bool isIso);
+    setupMuonSFTool(const std::string& name, const std::string& WP);
 
     CP::IMuonCalibrationAndSmearingTool*
       setupMuonCalibrationAndSmearingTool(const std::string& name, const bool& doExtraSmearingHighPt, const bool& do2StationsHighPt);
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
index f2ae76cc4bf1..7add97f1be3c 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
@@ -87,6 +87,25 @@ namespace top {
     m_iso_syst_UP("MUON_EFF_ISO_SYS__1up"),
     m_iso_syst_DOWN("MUON_EFF_ISO_SYS__1down"),
 
+    m_iso_bkg_fraction_UP(      "MUON_EFF_ISO_BKGFRACTION__1up"),
+    m_iso_bkg_fraction_DOWN(    "MUON_EFF_ISO_BKGFRACTION__1down"),
+    m_iso_lumi_uncert_UP(       "MUON_EFF_ISO_LUMIUNCERT__1up"),
+    m_iso_lumi_uncert_DOWN(     "MUON_EFF_ISO_LUMIUNCERT__1down"),
+    m_iso_mc_xsec_UP(           "MUON_EFF_ISO_MCXSEC__1up"),
+    m_iso_mc_xsec_DOWN(         "MUON_EFF_ISO_MCXSEC__1down"),
+    m_iso_qcd_template_UP(      "MUON_EFF_ISO_QCDTEMPLATE__1up"),
+    m_iso_qcd_template_DOWN(    "MUON_EFF_ISO_QCDTEMPLATE__1down"),
+    m_iso_supression_scale_UP(  "MUON_EFF_ISO_SUPRESSIONSCALE__1up"),
+    m_iso_supression_scale_DOWN("MUON_EFF_ISO_SUPRESSIONSCALE__1down"), 
+    m_iso_mllwindow_UP(           "MUON_EFF_ISO_MLLWINDOW__1up"),
+    m_iso_mllwindow_DOWN(         "MUON_EFF_ISO_MLLWINDOW__1down"),
+    m_iso_drmuj_UP(           "MUON_EFF_ISO_DRMUJ__1up"),
+    m_iso_drmuj_DOWN(         "MUON_EFF_ISO_DRMUJ__1down"),
+    m_iso_probeq_UP(           "MUON_EFF_ISO_PROBEQ__1up"),
+    m_iso_probeq_DOWN(         "MUON_EFF_ISO_PROBEQ__1down"),
+    m_iso_sherpa_powheg_UP(           "MUON_EFF_ISO_SHERPA_POWHEG__1up"),
+    m_iso_sherpa_powheg_DOWN(         "MUON_EFF_ISO_SHERPA_POWHEG__1down"),
+
     m_TTVA_stat_UP("MUON_EFF_TTVA_STAT__1up"),
     m_TTVA_stat_DOWN("MUON_EFF_TTVA_STAT__1down"),
     m_TTVA_syst_UP("MUON_EFF_TTVA_SYS__1up"),
@@ -131,6 +150,16 @@ namespace top {
         "MUON_EFF_RECO_SYS",
         "MUON_EFF_RECO_TRUTH",
         "MUON_EFF_RECO_TRUTH_LOWPT",
+        "MUON_EFF_ISO_BKGFRACTION",
+        "MUON_EFF_ISO_LUMIUNCERT",
+        "MUON_EFF_ISO_MCXSEC",
+        "MUON_EFF_ISO_QCDTEMPLATE",
+        "MUON_EFF_ISO_STAT",
+        "MUON_EFF_ISO_MLLWINDOW",
+        "MUON_EFF_ISO_DRMUJ",
+        "MUON_EFF_ISO_PROBEQ",
+        "MUON_EFF_ISO_SHERPA_POWHEG",
+        "MUON_EFF_ISO_SUPRESSIONSCALE",
         "MUON_EFF_TTVA_BKGFRACTION",
         "MUON_EFF_TTVA_LUMIUNCERT",
         "MUON_EFF_TTVA_MCXSEC",
@@ -627,6 +656,28 @@ namespace top {
     static SG::AuxElement::Decorator<float> iso_sf_decor_syst_up(m_decor_isoSF + "_SYST_UP");
     static SG::AuxElement::Decorator<float> iso_sf_decor_syst_down(m_decor_isoSF + "_SYST_DOWN");
 
+
+    static SG::AuxElement::Decorator<float> iso_sf_decor_lumi_uncert_up(       m_decor_isoSF + "_LUMI_UNCERT_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_lumi_uncert_down(     m_decor_isoSF + "_LUMI_UNCERT_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_bkg_fraction_up(      m_decor_isoSF + "_BKG_FRACTION_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_bkg_fraction_down(    m_decor_isoSF + "_BKG_FRACTION_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mc_xsec_up(           m_decor_isoSF + "_MC_XSEC_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mc_xsec_down(         m_decor_isoSF + "_MC_XSEC_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_qcd_template_up(      m_decor_isoSF + "_QCD_TEMPLATE_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_qcd_template_down(    m_decor_isoSF + "_QCD_TEMPLATE_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_supression_scale_up(  m_decor_isoSF + "_SUPRESSION_SCALE_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_supression_scale_down(m_decor_isoSF + "_SUPRESSION_SCALE_DOWN");
+
+
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_up(           m_decor_isoSF + "_MLLWINDOW_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_down(         m_decor_isoSF + "_MLLWINDOW_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_up(           m_decor_isoSF + "_DRMUJ_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_down(         m_decor_isoSF + "_DRMUJ_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_up(           m_decor_isoSF + "_PROBEQ_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_down(         m_decor_isoSF + "_PROBEQ_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_up(           m_decor_isoSF + "_SHERPA_POWHEG_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_down(         m_decor_isoSF + "_SHERPA_POWHEG_DOWN");
+
     // Decorate 'loose' isolation SFs
     static SG::AuxElement::Decorator<float> iso_sf_loose_decor_stat_up(m_decor_isoSF_loose + "_STAT_UP");
     static SG::AuxElement::Decorator<float> iso_sf_loose_decor_stat_down(m_decor_isoSF_loose + "_STAT_DOWN");
@@ -634,22 +685,76 @@ namespace top {
     static SG::AuxElement::Decorator<float> iso_sf_loose_decor_syst_down(m_decor_isoSF_loose + "_SYST_DOWN");
 
     if (m_do_muon_isolation_SFs) {
-      ///-- Stat UP --///
-      this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
-                                 m_iso_stat_UP, muon,
-                                 iso_sf_decor_stat_up);
-      ///-- Stat DOWN --///
-      this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
-                                 m_iso_stat_DOWN, muon,
-                                 iso_sf_decor_stat_down);
-      ///-- Syst UP --///
-      this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
-                                 m_iso_syst_UP, muon,
-                                 iso_sf_decor_syst_up);
-      ///-- Syst DOWN --///
-      this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
-                                 m_iso_syst_DOWN, muon,
-                                 iso_sf_decor_syst_down);
+
+        if (m_config->muonBreakDownSystematics()) {
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_stat_UP, muon, iso_sf_decor_stat_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_stat_DOWN, muon, iso_sf_decor_stat_down);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_bkg_fraction_UP, muon, iso_sf_decor_bkg_fraction_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_bkg_fraction_DOWN, muon, iso_sf_decor_bkg_fraction_down);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_lumi_uncert_UP, muon, iso_sf_decor_lumi_uncert_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_lumi_uncert_DOWN, muon, iso_sf_decor_lumi_uncert_down);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_mc_xsec_UP, muon, iso_sf_decor_mc_xsec_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_mc_xsec_DOWN, muon, iso_sf_decor_mc_xsec_down);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_qcd_template_UP, muon, iso_sf_decor_qcd_template_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_qcd_template_DOWN, muon, iso_sf_decor_qcd_template_down);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_supression_scale_UP, muon, iso_sf_decor_supression_scale_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_supression_scale_DOWN, muon, iso_sf_decor_supression_scale_down);
+
+
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_mllwindow_UP, muon, iso_sf_decor_mllwindow_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_mllwindow_DOWN, muon, iso_sf_decor_mllwindow_down);
+
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_drmuj_UP, muon, iso_sf_decor_drmuj_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_drmuj_DOWN, muon, iso_sf_decor_drmuj_down);
+
+
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_probeq_UP, muon, iso_sf_decor_probeq_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_probeq_DOWN, muon, iso_sf_decor_probeq_down);
+
+
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_sherpa_powheg_UP, muon, iso_sf_decor_sherpa_powheg_up);
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_sherpa_powheg_DOWN, muon, iso_sf_decor_sherpa_powheg_down);
+
+
+        }else{
+           ///-- Stat UP --///
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_stat_UP, muon,
+                                      iso_sf_decor_stat_up);
+           ///-- Stat DOWN --///
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_stat_DOWN, muon,
+                                      iso_sf_decor_stat_down);
+           ///-- Syst UP --///
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_syst_UP, muon,
+                                      iso_sf_decor_syst_up);
+           ///-- Syst DOWN --///
+           this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
+                                      m_iso_syst_DOWN, muon,
+                                      iso_sf_decor_syst_down);
+
+       } 
     } else {
       // If we aren't using muon isolation then still
       // decorate with isolation SFs of 1.0
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
index 14a4701f2995..22ab379d3744 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
@@ -1115,6 +1115,125 @@ namespace top {
       }
     }
 
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_LUMI_UNCERT_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_LUMI_UNCERT_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_LUMI_UNCERT_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_LUMI_UNCERT_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_LUMI_UNCERT_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_LUMI_UNCERT_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_BKG_FRACTION_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_BKG_FRACTION_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_BKG_FRACTION_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_BKG_FRACTION_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_BKG_FRACTION_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_BKG_FRACTION_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_MC_XSEC_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_MC_XSEC_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_MC_XSEC_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_MC_XSEC_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_MC_XSEC_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_MC_XSEC_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_MLLWINDOW_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_MLLWINDOW_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_MLLWINDOW_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_MLLWINDOW_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_MLLWINDOW_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_MLLWINDOW_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_QCD_TEMPLATE_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_QCD_TEMPLATE_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_QCD_TEMPLATE_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_QCD_TEMPLATE_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_QCD_TEMPLATE_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_QCD_TEMPLATE_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_SUPRESSION_SCALE_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_SUPRESSION_SCALE_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_SUPRESSION_SCALE_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_SUPRESSION_SCALE_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_SUPRESSION_SCALE_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_SUPRESSION_SCALE_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_DRMUJ_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_DRMUJ_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_DRMUJ_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_DRMUJ_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_DRMUJ_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_DRMUJ_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_PROBEQ_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_PROBEQ_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_PROBEQ_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_PROBEQ_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_PROBEQ_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_PROBEQ_DOWN");
+      }
+    }
+
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_SHERPA_POWHEG_UP) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_SHERPA_POWHEG_UP")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_SHERPA_POWHEG_UP");
+      }
+    }
+
+    if (SFSyst == top::topSFSyst::MU_SF_Isol_SHERPA_POWHEG_DOWN) {
+      if (x.isAvailable<float>(prefix+"_SF_Isol_" + iso + "_SHERPA_POWHEG_DOWN")) {
+        sf = x.auxdataConst<float>(prefix+"_SF_Isol_" + iso + "_SHERPA_POWHEG_DOWN");
+      }
+    }
+
+
+
+
     return sf;
   }
 
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
index 3aaa0a3c2eeb..ef0f9915b45e 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
@@ -230,6 +230,27 @@ namespace top {
     CP::SystematicSet m_iso_syst_UP;
     CP::SystematicSet m_iso_syst_DOWN;
 
+    CP::SystematicSet m_iso_bkg_fraction_UP;
+    CP::SystematicSet m_iso_bkg_fraction_DOWN;
+    CP::SystematicSet m_iso_lumi_uncert_UP;
+    CP::SystematicSet m_iso_lumi_uncert_DOWN;
+    CP::SystematicSet m_iso_mc_xsec_UP;
+    CP::SystematicSet m_iso_mc_xsec_DOWN;
+    CP::SystematicSet m_iso_qcd_template_UP;
+    CP::SystematicSet m_iso_qcd_template_DOWN;
+    CP::SystematicSet m_iso_supression_scale_UP;
+    CP::SystematicSet m_iso_supression_scale_DOWN;
+
+    CP::SystematicSet m_iso_mllwindow_UP      ; 
+    CP::SystematicSet m_iso_mllwindow_DOWN    ; 
+    CP::SystematicSet m_iso_drmuj_UP          ; 
+    CP::SystematicSet m_iso_drmuj_DOWN        ; 
+    CP::SystematicSet m_iso_probeq_UP         ; 
+    CP::SystematicSet m_iso_probeq_DOWN       ; 
+    CP::SystematicSet m_iso_sherpa_powheg_UP  ; 
+    CP::SystematicSet m_iso_sherpa_powheg_DOWN; 
+
+
     CP::SystematicSet m_TTVA_stat_UP;
     CP::SystematicSet m_TTVA_stat_DOWN;
     CP::SystematicSet m_TTVA_syst_UP;
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
index f18cca2928cc..476527f83b9b 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
@@ -75,6 +75,17 @@ namespace top {
     MU_SF_TTVA_QCD_TEMPLATE_UP, MU_SF_TTVA_QCD_TEMPLATE_DOWN,
     MU_SF_TTVA_SUPRESSION_SCALE_UP, MU_SF_TTVA_SUPRESSION_SCALE_DOWN,
 
+    MU_SF_Isol_BKG_FRACTION_UP,     MU_SF_Isol_BKG_FRACTION_DOWN,
+    MU_SF_Isol_LUMI_UNCERT_UP,      MU_SF_Isol_LUMI_UNCERT_DOWN,
+    MU_SF_Isol_MC_XSEC_UP,          MU_SF_Isol_MC_XSEC_DOWN,
+    MU_SF_Isol_QCD_TEMPLATE_UP,     MU_SF_Isol_QCD_TEMPLATE_DOWN,
+    MU_SF_Isol_SUPRESSION_SCALE_UP, MU_SF_Isol_SUPRESSION_SCALE_DOWN,
+
+    MU_SF_Isol_MLLWINDOW_UP,          MU_SF_Isol_MLLWINDOW_DOWN,
+    MU_SF_Isol_DRMUJ_UP,          MU_SF_Isol_DRMUJ_DOWN,
+    MU_SF_Isol_PROBEQ_UP,          MU_SF_Isol_PROBEQ_DOWN,
+    MU_SF_Isol_SHERPA_POWHEG_UP,          MU_SF_Isol_SHERPA_POWHEG_DOWN,
+
     TAU_SF_NOMINAL,
     // Tau EleOLR SFs
     TAUS_TRUEHADTAU_EFF_ELEOLR_TOTAL__1up, TAUS_TRUEHADTAU_EFF_ELEOLR_TOTAL__1down,
-- 
GitLab


From 5e98e3b0d104c76800950838eb05e3aa3a364271 Mon Sep 17 00:00:00 2001
From: sahinsoy <merve.sahinsoy@cern.ch>
Date: Wed, 6 Oct 2021 10:53:12 +0200
Subject: [PATCH 2/3] fix spaces

---
 .../TopAnalysis/Root/EventSaverFlatNtuple.cxx | 13 ------
 .../TopAnalysis/EventSaverFlatNtuple.h        |  4 --
 .../Root/MuonScaleFactorCalculator.cxx        | 43 +++++++------------
 .../Root/ScaleFactorRetriever.cxx             |  3 --
 .../MuonScaleFactorCalculator.h               |  1 -
 .../TopCorrections/ScaleFactorRetriever.h     |  2 -
 6 files changed, 16 insertions(+), 50 deletions(-)

diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
index 2b62b3bd7777..c1ed4c78fe13 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
@@ -678,9 +678,6 @@ namespace top {
                                              "weight_leptonSF_MU_SF_Isol_STAT_UP");
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_STAT_DOWN,
                                              "weight_leptonSF_MU_SF_Isol_STAT_DOWN");
-
-
-
           if (m_config->muonBreakDownSystematics()) {
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP,
                                                 "weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP");
@@ -702,33 +699,23 @@ namespace top {
                                                 "weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP");
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN,
                                                 "weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN");
-
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP,
                                                 "weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP");
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN,
                                                 "weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN");
-
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP,
                                                 "weight_leptonSF_MU_SF_Isol_DRMUJ_UP");
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN,
                                                 "weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN");
-
-
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_PROBEQ_UP,
                                                 "weight_leptonSF_MU_SF_Isol_PROBEQ_UP");
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN,
                                                 "weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN");
-
-
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP,
                                                 "weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP");
             systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN,
                                                 "weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN");
-
-
-
           } else {
-
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SYST_UP,
                                              "weight_leptonSF_MU_SF_Isol_SYST_UP");
           systematicTree->makeOutputVariable(m_weight_leptonSF_MU_SF_Isol_SYST_DOWN,
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
index fd71515c41ff..190d912abe2c 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h
@@ -357,7 +357,6 @@ namespace top {
     float m_weight_leptonSF_MU_SF_Isol_STAT_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_SYST_UP;
     float m_weight_leptonSF_MU_SF_Isol_SYST_DOWN;
-
     float m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_UP;
     float m_weight_leptonSF_MU_SF_Isol_BKG_FRACTION_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_LUMI_UNCERT_UP;
@@ -368,7 +367,6 @@ namespace top {
     float m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP;
     float m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN;
-
     float m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP;
     float m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP;
@@ -377,8 +375,6 @@ namespace top {
     float m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN;
     float m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP;
     float m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN;
-
-
     //Muon TTVA SF systematics
     float m_weight_leptonSF_MU_SF_TTVA_STAT_UP;
     float m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN;
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
index 7add97f1be3c..582a1c81b152 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx
@@ -97,14 +97,14 @@ namespace top {
     m_iso_qcd_template_DOWN(    "MUON_EFF_ISO_QCDTEMPLATE__1down"),
     m_iso_supression_scale_UP(  "MUON_EFF_ISO_SUPRESSIONSCALE__1up"),
     m_iso_supression_scale_DOWN("MUON_EFF_ISO_SUPRESSIONSCALE__1down"), 
-    m_iso_mllwindow_UP(           "MUON_EFF_ISO_MLLWINDOW__1up"),
-    m_iso_mllwindow_DOWN(         "MUON_EFF_ISO_MLLWINDOW__1down"),
-    m_iso_drmuj_UP(           "MUON_EFF_ISO_DRMUJ__1up"),
-    m_iso_drmuj_DOWN(         "MUON_EFF_ISO_DRMUJ__1down"),
-    m_iso_probeq_UP(           "MUON_EFF_ISO_PROBEQ__1up"),
-    m_iso_probeq_DOWN(         "MUON_EFF_ISO_PROBEQ__1down"),
-    m_iso_sherpa_powheg_UP(           "MUON_EFF_ISO_SHERPA_POWHEG__1up"),
-    m_iso_sherpa_powheg_DOWN(         "MUON_EFF_ISO_SHERPA_POWHEG__1down"),
+    m_iso_mllwindow_UP(         "MUON_EFF_ISO_MLLWINDOW__1up"),
+    m_iso_mllwindow_DOWN(       "MUON_EFF_ISO_MLLWINDOW__1down"),
+    m_iso_drmuj_UP(             "MUON_EFF_ISO_DRMUJ__1up"),
+    m_iso_drmuj_DOWN(           "MUON_EFF_ISO_DRMUJ__1down"),
+    m_iso_probeq_UP(            "MUON_EFF_ISO_PROBEQ__1up"),
+    m_iso_probeq_DOWN(          "MUON_EFF_ISO_PROBEQ__1down"),
+    m_iso_sherpa_powheg_UP(     "MUON_EFF_ISO_SHERPA_POWHEG__1up"),
+    m_iso_sherpa_powheg_DOWN(   "MUON_EFF_ISO_SHERPA_POWHEG__1down"),
 
     m_TTVA_stat_UP("MUON_EFF_TTVA_STAT__1up"),
     m_TTVA_stat_DOWN("MUON_EFF_TTVA_STAT__1down"),
@@ -667,16 +667,14 @@ namespace top {
     static SG::AuxElement::Decorator<float> iso_sf_decor_qcd_template_down(    m_decor_isoSF + "_QCD_TEMPLATE_DOWN");
     static SG::AuxElement::Decorator<float> iso_sf_decor_supression_scale_up(  m_decor_isoSF + "_SUPRESSION_SCALE_UP");
     static SG::AuxElement::Decorator<float> iso_sf_decor_supression_scale_down(m_decor_isoSF + "_SUPRESSION_SCALE_DOWN");
-
-
-    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_up(           m_decor_isoSF + "_MLLWINDOW_UP");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_down(         m_decor_isoSF + "_MLLWINDOW_DOWN");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_up(           m_decor_isoSF + "_DRMUJ_UP");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_down(         m_decor_isoSF + "_DRMUJ_DOWN");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_up(           m_decor_isoSF + "_PROBEQ_UP");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_down(         m_decor_isoSF + "_PROBEQ_DOWN");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_up(           m_decor_isoSF + "_SHERPA_POWHEG_UP");
-    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_down(         m_decor_isoSF + "_SHERPA_POWHEG_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_up(         m_decor_isoSF + "_MLLWINDOW_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_mllwindow_down(       m_decor_isoSF + "_MLLWINDOW_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_up(             m_decor_isoSF + "_DRMUJ_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_drmuj_down(           m_decor_isoSF + "_DRMUJ_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_up(            m_decor_isoSF + "_PROBEQ_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_probeq_down(          m_decor_isoSF + "_PROBEQ_DOWN");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_up(     m_decor_isoSF + "_SHERPA_POWHEG_UP");
+    static SG::AuxElement::Decorator<float> iso_sf_decor_sherpa_powheg_down(   m_decor_isoSF + "_SHERPA_POWHEG_DOWN");
 
     // Decorate 'loose' isolation SFs
     static SG::AuxElement::Decorator<float> iso_sf_loose_decor_stat_up(m_decor_isoSF_loose + "_STAT_UP");
@@ -711,31 +709,22 @@ namespace top {
                                       m_iso_supression_scale_UP, muon, iso_sf_decor_supression_scale_up);
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_supression_scale_DOWN, muon, iso_sf_decor_supression_scale_down);
-
-
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_mllwindow_UP, muon, iso_sf_decor_mllwindow_up);
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_mllwindow_DOWN, muon, iso_sf_decor_mllwindow_down);
-
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_drmuj_UP, muon, iso_sf_decor_drmuj_up);
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_drmuj_DOWN, muon, iso_sf_decor_drmuj_down);
-
-
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_probeq_UP, muon, iso_sf_decor_probeq_up);
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_probeq_DOWN, muon, iso_sf_decor_probeq_down);
-
-
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_sherpa_powheg_UP, muon, iso_sf_decor_sherpa_powheg_up);
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
                                       m_iso_sherpa_powheg_DOWN, muon, iso_sf_decor_sherpa_powheg_down);
-
-
         }else{
            ///-- Stat UP --///
            this->decorateEfficiencySF(m_muonEfficiencyCorrectionsToolIso,
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
index 22ab379d3744..6bb554a63c94 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/ScaleFactorRetriever.cxx
@@ -1231,9 +1231,6 @@ namespace top {
       }
     }
 
-
-
-
     return sf;
   }
 
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
index ef0f9915b45e..4ba212ec5f29 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/MuonScaleFactorCalculator.h
@@ -240,7 +240,6 @@ namespace top {
     CP::SystematicSet m_iso_qcd_template_DOWN;
     CP::SystematicSet m_iso_supression_scale_UP;
     CP::SystematicSet m_iso_supression_scale_DOWN;
-
     CP::SystematicSet m_iso_mllwindow_UP      ; 
     CP::SystematicSet m_iso_mllwindow_DOWN    ; 
     CP::SystematicSet m_iso_drmuj_UP          ; 
diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
index 476527f83b9b..e76c7f87f847 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/TopCorrections/ScaleFactorRetriever.h
@@ -74,13 +74,11 @@ namespace top {
     MU_SF_TTVA_MC_XSEC_UP, MU_SF_TTVA_MC_XSEC_DOWN,
     MU_SF_TTVA_QCD_TEMPLATE_UP, MU_SF_TTVA_QCD_TEMPLATE_DOWN,
     MU_SF_TTVA_SUPRESSION_SCALE_UP, MU_SF_TTVA_SUPRESSION_SCALE_DOWN,
-
     MU_SF_Isol_BKG_FRACTION_UP,     MU_SF_Isol_BKG_FRACTION_DOWN,
     MU_SF_Isol_LUMI_UNCERT_UP,      MU_SF_Isol_LUMI_UNCERT_DOWN,
     MU_SF_Isol_MC_XSEC_UP,          MU_SF_Isol_MC_XSEC_DOWN,
     MU_SF_Isol_QCD_TEMPLATE_UP,     MU_SF_Isol_QCD_TEMPLATE_DOWN,
     MU_SF_Isol_SUPRESSION_SCALE_UP, MU_SF_Isol_SUPRESSION_SCALE_DOWN,
-
     MU_SF_Isol_MLLWINDOW_UP,          MU_SF_Isol_MLLWINDOW_DOWN,
     MU_SF_Isol_DRMUJ_UP,          MU_SF_Isol_DRMUJ_DOWN,
     MU_SF_Isol_PROBEQ_UP,          MU_SF_Isol_PROBEQ_DOWN,
-- 
GitLab


From 93d041a429f95f59df0dbb516246b0ed2e6b976d Mon Sep 17 00:00:00 2001
From: sahinsoy <merve.sahinsoy@cern.ch>
Date: Wed, 6 Oct 2021 12:13:39 +0200
Subject: [PATCH 3/3] adding the initialization of variables

---
 .../xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx        | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
index c1ed4c78fe13..9f00ea896c4a 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx
@@ -108,6 +108,14 @@ namespace top {
     m_weight_leptonSF_MU_SF_Isol_QCD_TEMPLATE_DOWN(0.),
     m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_UP(0.),
     m_weight_leptonSF_MU_SF_Isol_SUPRESSION_SCALE_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_MLLWINDOW_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_DRMUJ_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_DRMUJ_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_PROBEQ_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_PROBEQ_DOWN(0.),
+    m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_UP(0.),
+    m_weight_leptonSF_MU_SF_Isol_SHERPA_POWHEG_DOWN(0.),
     //Muon TTVA SF systematics 
     m_weight_leptonSF_MU_SF_TTVA_STAT_UP(0.),
     m_weight_leptonSF_MU_SF_TTVA_STAT_DOWN(0.),
-- 
GitLab