From f2e1849b24c676a1a5fe587e9b41e2a9b0461d21 Mon Sep 17 00:00:00 2001
From: Meirin Oan Evans <meirin.oan.evans@cern.ch>
Date: Wed, 9 Dec 2020 12:31:42 +0000
Subject: [PATCH] Fix compilation warning since the variable was only valid in
 the if condition

---
 .../TopEventSelectionTools/Root/JetFlavorPlots.cxx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopEventSelectionTools/Root/JetFlavorPlots.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopEventSelectionTools/Root/JetFlavorPlots.cxx
index c87a3379fb16..2417cd26f9d0 100644
--- a/PhysicsAnalysis/TopPhys/xAOD/TopEventSelectionTools/Root/JetFlavorPlots.cxx
+++ b/PhysicsAnalysis/TopPhys/xAOD/TopEventSelectionTools/Root/JetFlavorPlots.cxx
@@ -183,10 +183,10 @@ namespace top {
       else if (m_PMGTruthWeights->hasWeight("1009")) scaleWeight = m_PMGTruthWeights->getWeight("1009"); // for e.g. tZ 412063
       else if (m_PMGTruthWeights->hasWeight("muR=05,muF=05")) scaleWeight = m_PMGTruthWeights->getWeight("muR=05,muF=05"); // for some other generator setups
       else top::check(m_PMGTruthWeights->hasWeight(" muR = 0.5, muF = 0.5 "), "JetFlavorPlots::apply(): Weight \" muR = 0.5, muF = 0.5 \" not found. Please report this message!");
-      if (m_doRadHighNoVar3c) double eventWeight = scaleWeight; // don't take Var3 weight into account
-      else { // m_doRadHighNoVar3c is false
+      double eventWeight = scaleWeights;
+      if (!m_doRadHighNoVar3c) {
         top::check(m_PMGTruthWeights->hasWeight("Var3cUp"), "JetFlavorPlots::apply(): Weight \"Var3cUp\" not found. Please report this message!");
-        double eventWeight = scaleWeight * m_PMGTruthWeights->getWeight("Var3cUp") / nominalWeight;
+        eventWeight *= m_PMGTruthWeights->getWeight("Var3cUp") / nominalWeight;
       }
       if (event.m_isLoose) FillHistograms(m_hists_RadHigh_Loose, eventWeight, event);
       else FillHistograms(m_hists_RadHigh, eventWeight, event);
@@ -202,10 +202,10 @@ namespace top {
       else if (m_PMGTruthWeights->hasWeight("1005")) scaleWeight = m_PMGTruthWeights->getWeight("1005"); // for e.g. tZ 412063
       else if (m_PMGTruthWeights->hasWeight("muR=20,muF=20")) scaleWeight = m_PMGTruthWeights->getWeight("muR=20,muF=20"); // for some other generator setups
       else top::check(m_PMGTruthWeights->hasWeight(" muR = 2.0, muF = 2.0 "), "JetFlavorPlots::apply(): Weight \" muR = 2.0, muF = 2.0 \" not found. Please report this message!");
-      if (m_doRadLowNoVar3c) double eventWeight = scaleWeight; // don't take Var3 weight into account
-      else { // m_doRadLowNoVar3c is false
-      	top::check(m_PMGTruthWeights->hasWeight("Var3cDown"), "JetFlavorPlots::apply(): Weight \"Var3cDown\" not found. Please report this message!");
-        double eventWeight = scaleWeight * m_PMGTruthWeights->getWeight("Var3cDown") / nominalWeight;
+      double eventWeight = scaleWeights;
+      if (!m_doRadLowNoVar3c) {
+        top::check(m_PMGTruthWeights->hasWeight("Var3cDown"), "JetFlavorPlots::apply(): Weight \"Var3cDown\" not found. Please report this message!");
+        eventWeight *= m_PMGTruthWeights->getWeight("Var3cDown") / nominalWeight;
       }
       if (event.m_isLoose) FillHistograms(m_hists_RadLow_Loose, eventWeight, event);
       else FillHistograms(m_hists_RadLow, eventWeight, event);
-- 
GitLab