From ff528f37821429510845cdd226f03f99207e77e4 Mon Sep 17 00:00:00 2001
From: adanders <adam.campbell.anderson@cern.ch>
Date: Wed, 12 Jun 2024 14:32:52 +0200
Subject: [PATCH 1/4] updated RunConfig-bbll-btagging.yaml for btagging studies
 using GN2v01

---
 bbllAnalysis/share/RunConfig-bbll-btagging.yaml | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
index ff740a209..048e8f65d 100644
--- a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
+++ b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
@@ -6,18 +6,14 @@ Electron:
 # Toggles for reconstructed objects decorations
 small_R_jet:
   # btagging working points 
-  btag_wp: "GN2v01_FixedCutBEff_90"
+  btag_wp: "GN2v01_FixedCutBEff_85"
   amount: 2
   amount_bjet: 2
 
   # to use multiple btagging WPs
   btag_extra_wps:
-    - DL1dv01_FixedCutBEff_60
-    - DL1dv01_FixedCutBEff_70
-    - DL1dv01_FixedCutBEff_77
-    - DL1dv01_FixedCutBEff_85
-    - GN2v01_FixedCutBEff_65
-    - GN2v01_FixedCutBEff_70
-    - GN2v01_FixedCutBEff_77
-    - GN2v01_FixedCutBEff_85
+    - GN2v01_Continuous
+    - DL1dv01_Continuous
+  
+  variables_int_bjets: ["pcbt_GN2v01", "pcbt_DL1dv01"]
 
-- 
GitLab


From 99a6a4e21499c3afdd2a9dc1518ec1d5a1691331 Mon Sep 17 00:00:00 2001
From: adanders <adam.campbell.anderson@cern.ch>
Date: Thu, 20 Jun 2024 17:37:18 +0200
Subject: [PATCH 2/4] Added pcbt variables for continuous tagging into ntuples

---
 bbllAnalysis/python/bbll_config.py       |  4 ++++
 bbllAnalysis/src/BaselineVarsbbllAlg.cxx | 13 ++++++++++++-
 bbllAnalysis/src/BaselineVarsbbllAlg.h   |  4 ++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/bbllAnalysis/python/bbll_config.py b/bbllAnalysis/python/bbll_config.py
index d7a0a78b7..b9b6ab90d 100644
--- a/bbllAnalysis/python/bbll_config.py
+++ b/bbllAnalysis/python/bbll_config.py
@@ -92,6 +92,9 @@ def bbll_cfg(flags, smalljetkey, muonkey, electronkey,
             )
         )
 
+    btag_pcbt_wps \
+        = [wp for wp in flags.Analysis.small_R_jet.btag_extra_wps if "Continuous" in wp]
+
     # calculate final bbll vars
     cfg.addEventAlgo(
         CompFactory.HHBBLL.BaselineVarsbbllAlg(
@@ -100,6 +103,7 @@ def bbll_cfg(flags, smalljetkey, muonkey, electronkey,
             muonWP=MuonWPLabel,
             eleWP=ElectronWPLabel,
             bTagWPDecorName="ftag_select_" + flags.Analysis.small_R_jet.btag_wp,
+            PCBTDecorList=["ftag_quantile_" + pcbt_wp for pcbt_wp in btag_pcbt_wps],
             floatVariableList=float_variables,
             intVariableList=int_variables
         )
diff --git a/bbllAnalysis/src/BaselineVarsbbllAlg.cxx b/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
index 92eafee06..8e0c0f7b7 100644
--- a/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
+++ b/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
@@ -54,6 +54,12 @@ namespace HHBBLL
     if (!m_isBtag.empty()) {
       ATH_CHECK (m_isBtag.initialize(m_systematicsList, m_jetHandle));
     }
+    for (const std::string &var : m_PCBTnames) {
+      ATH_MSG_DEBUG("initializing PCBT: " << var);
+      CP::SysReadDecorHandle<int> rhandle{var, this};
+      m_PCBTs.emplace(var, rhandle);
+      ATH_CHECK (m_PCBTs.at(var).initialize(m_systematicsList, m_jetHandle));
+    };
 
     ATH_CHECK (m_met_sig.initialize(m_systematicsList, m_metHandle));
 
@@ -248,9 +254,14 @@ namespace HHBBLL
           int truthLabel = HadronConeExclTruthLabelID(*bjets->at(i));
           m_Ibranches.at(prefix+"_truthLabel").set(*event, truthLabel, sys);
         }
+        for (const auto& var: m_PCBTnames) {
+          std::string new_var = var;
+          new_var.erase(0, 14);
+          new_var.erase(new_var.length() - 11, new_var.length());
+          m_Ibranches.at(prefix+"_pcbt_"+new_var).set(*event, m_PCBTs.at(var).get(*bjets->at(i), sys), sys);
+        }
       }
 
-      if (bjets->size()>=2) {
         // build the H(bb) candidate
         bb = Leading_bjet + Subleading_bjet;
         m_Fbranches.at("mbb").set(*event, bb.M(), sys);
diff --git a/bbllAnalysis/src/BaselineVarsbbllAlg.h b/bbllAnalysis/src/BaselineVarsbbllAlg.h
index f2d0fe5af..150ab263a 100644
--- a/bbllAnalysis/src/BaselineVarsbbllAlg.h
+++ b/bbllAnalysis/src/BaselineVarsbbllAlg.h
@@ -71,6 +71,10 @@ private:
 
     CP::SysReadDecorHandle<char> 
     m_isBtag {this, "bTagWPDecorName", "", "Name of input dectorator for b-tagging"};
+    Gaudi::Property<std::vector<std::string>> m_PCBTnames
+          {this, "PCBTDecorList", {}, "Name list of pseudo-continuous b-tagging decorator"};
+    std::unordered_map<std::string, CP::SysReadDecorHandle<int>>
+        m_PCBTs;
 
     Gaudi::Property<std::vector<std::string>> m_floatVariables
           {this, "floatVariableList", {}, "Name list of floating variables"};
-- 
GitLab


From 047460eb1f67d3f30ff6660825d828b2854b9ebe Mon Sep 17 00:00:00 2001
From: adanders <adam.campbell.anderson@cern.ch>
Date: Tue, 9 Jul 2024 15:58:49 +0200
Subject: [PATCH 3/4] Updated bbll btagging config

---
 bbllAnalysis/share/RunConfig-bbll-btagging.yaml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
index 048e8f65d..1c0245ca7 100644
--- a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
+++ b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
@@ -6,12 +6,20 @@ Electron:
 # Toggles for reconstructed objects decorations
 small_R_jet:
   # btagging working points 
-  btag_wp: "GN2v01_FixedCutBEff_85"
+  btag_wp: "GN2v01_FixedCutBEff_90"
   amount: 2
   amount_bjet: 2
 
   # to use multiple btagging WPs
   btag_extra_wps:
+    - DL1dv01_FixedCutBEff_60
+    - DL1dv01_FixedCutBEff_70
+    - DL1dv01_FixedCutBEff_77
+    - DL1dv01_FixedCutBEff_85
+    - GN2v01_FixedCutBEff_65
+    - GN2v01_FixedCutBEff_70
+    - GN2v01_FixedCutBEff_77
+    - GN2v01_FixedCutBEff_85
     - GN2v01_Continuous
     - DL1dv01_Continuous
   
-- 
GitLab


From b3f65f0343e5acfdb11f369d0352b68bd97ce0c1 Mon Sep 17 00:00:00 2001
From: adanders <adam.campbell.anderson@cern.ch>
Date: Tue, 9 Jul 2024 18:22:42 +0200
Subject: [PATCH 4/4] Fixing rebased branch

---
 bbllAnalysis/share/RunConfig-bbll-btagging.yaml | 1 -
 bbllAnalysis/src/BaselineVarsbbllAlg.cxx        | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
index 1c0245ca7..f0011b13a 100644
--- a/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
+++ b/bbllAnalysis/share/RunConfig-bbll-btagging.yaml
@@ -18,7 +18,6 @@ small_R_jet:
     - DL1dv01_FixedCutBEff_85
     - GN2v01_FixedCutBEff_65
     - GN2v01_FixedCutBEff_70
-    - GN2v01_FixedCutBEff_77
     - GN2v01_FixedCutBEff_85
     - GN2v01_Continuous
     - DL1dv01_Continuous
diff --git a/bbllAnalysis/src/BaselineVarsbbllAlg.cxx b/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
index 8e0c0f7b7..1b2262f67 100644
--- a/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
+++ b/bbllAnalysis/src/BaselineVarsbbllAlg.cxx
@@ -262,6 +262,7 @@ namespace HHBBLL
         }
       }
 
+      if (bjets->size()>=2) {
         // build the H(bb) candidate
         bb = Leading_bjet + Subleading_bjet;
         m_Fbranches.at("mbb").set(*event, bb.M(), sys);
-- 
GitLab