From 4669b17e54c7953e45c2b325771f11caa3fd7a1a Mon Sep 17 00:00:00 2001
From: Carlo Schiavi <carlo.schiavi@cern.ch>
Date: Wed, 5 Mar 2025 16:44:10 +0000
Subject: [PATCH] Adding support for doubles and ulongs in TruthTauMatcher

---
 FTagDumper/python/blocks/TruthTauMatcher.py        | 14 ++++++++++++++
 FTagDumper/src/BTagJetWriterUtils.cxx              |  3 +++
 FTagDumper/src/JetDumperConfig.cxx                 |  1 +
 FTagDumper/src/TruthTauMatcherAlg.cxx              |  8 +++++++-
 FTagDumper/src/TruthTauMatcherAlg.h                |  2 ++
 FTagDumper/src/VariablesByType.cxx                 |  1 +
 FTagDumper/src/VariablesByType.hh                  |  1 +
 JetWriters/JetWriters/JetConstituentWriterConfig.h |  2 +-
 8 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/FTagDumper/python/blocks/TruthTauMatcher.py b/FTagDumper/python/blocks/TruthTauMatcher.py
index 3dcd337db..a395a09de 100644
--- a/FTagDumper/python/blocks/TruthTauMatcher.py
+++ b/FTagDumper/python/blocks/TruthTauMatcher.py
@@ -23,12 +23,18 @@ class TruthTauMatcher(BaseBlock):
     floats_to_copy : list[str], optional
         List of float variables to copy from the truth taus to the matched
         reco. jets. By default None
+    doubles_to_copy : list[str], optional
+        List of double variables to copy from the truth taus to the matched
+        reco. jets. By default None
     ints_to_copy : list[str], optional
         List of integer variables to copy from the truth taus to the matched
         reco. jets. By default None
     uints_to_copy : list[str], optional
         List of unsigned integer variables to copy from the truth taus to the
         matched reco. jets. By default None
+    ulongs_to_copy : list[str], optional
+        List of unsigned long variables to copy from the truth taus to the
+        matched reco. jets. By default None
     chars_to_copy : list[str], optional
         List of character variables to copy from the truth taus to the matched
         reco. jets. By default None
@@ -39,8 +45,10 @@ class TruthTauMatcher(BaseBlock):
     truth_tau_collection: str = "TruthTaus"
     reco_jet_collection: str = None
     floats_to_copy: list[str] = None
+    doubles_to_copy: list[str] = None
     ints_to_copy: list[str] = None
     uints_to_copy: list[str] = None
+    ulongs_to_copy: list[str] = None
     chars_to_copy: list[str] = None
     max_delta_R: float = 0.3
     min_truth_tau_pT: float = 0.0
@@ -56,10 +64,14 @@ class TruthTauMatcher(BaseBlock):
             self.reco_jet_collection = self.dumper_config["jet_collection"]
         if self.floats_to_copy is None:
             self.floats_to_copy = []
+        if self.doubles_to_copy is None:
+            self.doubles_to_copy = []
         if self.ints_to_copy is None:
             self.ints_to_copy = []
         if self.uints_to_copy is None:
             self.uints_to_copy = []
+        if self.ulongs_to_copy is None:
+            self.ulongs_to_copy = []
         if self.chars_to_copy is None:
             self.chars_to_copy = []
         if self.particle_link_name is None:
@@ -81,8 +93,10 @@ class TruthTauMatcher(BaseBlock):
                 recoJets=self.reco_jet_collection,
                 truthTaus=self.truth_tau_collection,
                 floatsToCopy={f: to(f) for f in self.floats_to_copy},
+                doublesToCopy={f: to(f) for f in self.doubles_to_copy},
                 intsToCopy={i: to(i) for i in self.ints_to_copy},
                 uintsToCopy={i: to(i) for i in self.uints_to_copy},
+                ulongsToCopy={i: to(i) for i in self.ulongs_to_copy},
                 charsToCopy={i: to(i) for i in self.chars_to_copy},
                 dR=dr_str,
                 dPt=dpt_str,
diff --git a/FTagDumper/src/BTagJetWriterUtils.cxx b/FTagDumper/src/BTagJetWriterUtils.cxx
index 953d5ad61..17bfd91c4 100644
--- a/FTagDumper/src/BTagJetWriterUtils.cxx
+++ b/FTagDumper/src/BTagJetWriterUtils.cxx
@@ -82,6 +82,7 @@ void add_jet_variables(JetConsumers& fillers,
                        const BTagJetWriterBaseConfig& cfg,
                        H5Utils::Compression h) {
   using uint = unsigned int;
+  using ulong = unsigned long;
   using uchar = unsigned char;
 
   H5Utils::Compression s = H5Utils::Compression::STANDARD;
@@ -96,6 +97,7 @@ void add_jet_variables(JetConsumers& fillers,
   add_btag_fillers<float>(fillers, btag.floats, m, NAN, l, s);
   add_btag_fillers<float>(fillers, btag.halves, m, NAN, l, h);
   add_btag_fillers<uint>(fillers, btag.uints, m, 0, l, s);
+  add_btag_fillers<ulong>(fillers, btag.ulongs, m, 0, l, s);
   add_btag_fillers<int>(fillers, btag.ints, m, -1, l, s);
   add_btag_fillers<uchar, uchar>(fillers, btag.uchars, m, 0, l, s);
   add_btag_fillers<char, char>(fillers, btag.chars, m, -1, l, s);
@@ -107,6 +109,7 @@ void add_jet_variables(JetConsumers& fillers,
   add_jet_fillers<double, float>(fillers, cfg.jet.doubles, NAN, s);
   add_jet_fillers<char>(fillers, cfg.jet.chars, 0, s);
   add_jet_fillers<uint, uint>(fillers, cfg.jet.uints, 0, s);
+  add_jet_fillers<ulong, ulong>(fillers, cfg.jet.ulongs, 0, s);
   add_jet_fillers<uchar, uchar>(fillers, cfg.jet.uchars, 0, s);
   add_jet_int_variables(fillers, cfg.jet.ints);
   add_jet_fillers<int, float>(
diff --git a/FTagDumper/src/JetDumperConfig.cxx b/FTagDumper/src/JetDumperConfig.cxx
index c8d5097c5..cccefcdff 100644
--- a/FTagDumper/src/JetDumperConfig.cxx
+++ b/FTagDumper/src/JetDumperConfig.cxx
@@ -101,6 +101,7 @@ namespace {
     fill("floats", Type::FLOAT);
     fill("customs", Type::CUSTOM);
     fill("uints", Type::UINT);
+    fill("ulongs", Type::ULONG);
     fill("half_precision_customs", Type::CUSTOM_HALF);
     cf::throw_if_any_keys_left(keys, "track variable types");
     return vars;
diff --git a/FTagDumper/src/TruthTauMatcherAlg.cxx b/FTagDumper/src/TruthTauMatcherAlg.cxx
index 28b5f1e8a..2473f76a6 100644
--- a/FTagDumper/src/TruthTauMatcherAlg.cxx
+++ b/FTagDumper/src/TruthTauMatcherAlg.cxx
@@ -11,8 +11,10 @@ TruthTauMatcherAlg::TruthTauMatcherAlg(const std::string& name, ISvcLocator* pSv
   AthReentrantAlgorithm(name, pSvcLocator)
 {
   declareProperty("floatsToCopy", m_floats.toCopy);
+  declareProperty("doublesToCopy", m_doubles.toCopy);
   declareProperty("intsToCopy", m_ints.toCopy);
   declareProperty("uintsToCopy", m_uints.toCopy);
+  declareProperty("ulongsToCopy", m_ulongs.toCopy);
   declareProperty("charsToCopy", m_chars.toCopy);
   declareProperty("iparticlesToCopy", m_iparticles.toCopy);
 }
@@ -35,8 +37,10 @@ StatusCode TruthTauMatcherAlg::initialize() {
   std::string recoJetsCollection = m_recoJets.key();
   // std::string truthTausCollection = m_truthTaus.key();
   ATH_CHECK(m_floats.initialize(this, truthTausCollection, recoJetsCollection));
+  ATH_CHECK(m_doubles.initialize(this, truthTausCollection, recoJetsCollection));
   ATH_CHECK(m_ints.initialize(this, truthTausCollection, recoJetsCollection));
   ATH_CHECK(m_uints.initialize(this, truthTausCollection, recoJetsCollection));
+  ATH_CHECK(m_ulongs.initialize(this, truthTausCollection, recoJetsCollection));
   ATH_CHECK(m_chars.initialize(this, truthTausCollection, recoJetsCollection));
   ATH_CHECK(m_iparticles.initialize(this, truthTausCollection, recoJetsCollection));
 
@@ -135,8 +139,10 @@ StatusCode TruthTauMatcherAlg::execute(const EventContext& cxt) const {
     }
   }
   m_floats.copy(matches, cxt);
+  m_doubles.copy(matches, cxt);
   m_ints.copy(matches, cxt);
   m_uints.copy(matches, cxt);
+  m_ulongs.copy(matches, cxt);
   m_chars.copy(matches, cxt);
   m_iparticles.copy(matches, cxt);
 
@@ -144,4 +150,4 @@ StatusCode TruthTauMatcherAlg::execute(const EventContext& cxt) const {
 }
 StatusCode TruthTauMatcherAlg::finalize () {
   return StatusCode::SUCCESS;
-}
\ No newline at end of file
+}
diff --git a/FTagDumper/src/TruthTauMatcherAlg.h b/FTagDumper/src/TruthTauMatcherAlg.h
index ba223e037..7fe291a44 100644
--- a/FTagDumper/src/TruthTauMatcherAlg.h
+++ b/FTagDumper/src/TruthTauMatcherAlg.h
@@ -27,8 +27,10 @@ private:
 
   // Variables to copy from truth taus to matched jets
   VariableMule<float,JC> m_floats{NAN};
+  VariableMule<double,JC> m_doubles{NAN};
   VariableMule<int,JC> m_ints{-1};
   VariableMule<uint,JC> m_uints{0};
+  VariableMule<ulong,JC> m_ulongs{0};
   VariableMule<char,JC> m_chars{-1};
   VariableMule<IPLV,JC> m_iparticles{{}};
 
diff --git a/FTagDumper/src/VariablesByType.cxx b/FTagDumper/src/VariablesByType.cxx
index e821f6678..e47ee6342 100644
--- a/FTagDumper/src/VariablesByType.cxx
+++ b/FTagDumper/src/VariablesByType.cxx
@@ -9,6 +9,7 @@ void from_json(const nlohmann::ordered_json& node, VariablesByType& out) {
   ADD(chars);
   ADD(ints);
   ADD(uints);
+  ADD(ulongs);
   ADD(halves);
   ADD(floats);
   ADD(doubles);
diff --git a/FTagDumper/src/VariablesByType.hh b/FTagDumper/src/VariablesByType.hh
index 6288e55d5..d588dad3a 100644
--- a/FTagDumper/src/VariablesByType.hh
+++ b/FTagDumper/src/VariablesByType.hh
@@ -12,6 +12,7 @@ struct VariablesByType
   list_t uchars;
   list_t chars;
   list_t uints;
+  list_t ulongs;
   list_t ints;
   list_t halves;
   list_t floats;
diff --git a/JetWriters/JetWriters/JetConstituentWriterConfig.h b/JetWriters/JetWriters/JetConstituentWriterConfig.h
index 302f3c7ef..5820fe07b 100644
--- a/JetWriters/JetWriters/JetConstituentWriterConfig.h
+++ b/JetWriters/JetWriters/JetConstituentWriterConfig.h
@@ -7,7 +7,7 @@
 
 struct JetConstituentWriterConfig
 {
-  enum class Type {CUSTOM, CUSTOM_HALF, UCHAR, CHAR, INT, FLOAT, HALF, UINT};
+  enum class Type {CUSTOM, CUSTOM_HALF, UCHAR, CHAR, INT, FLOAT, HALF, UINT, ULONG};
   struct Output {
     Type type = Type::CUSTOM;
     std::string name;
-- 
GitLab