From d20b9a332e92f667a617e0b0b771c4bcc0af4328 Mon Sep 17 00:00:00 2001 From: lynnt-uchicago Date: Tue, 25 Apr 2023 15:16:38 -0500 Subject: [PATCH 1/4] light calorimetry object, working version commit --- sbnobj/Common/Reco/LightCaloInfo.cc | 12 ++++++++++++ sbnobj/Common/Reco/LightCaloInfo.h | 29 +++++++++++++++++++++++++++++ sbnobj/Common/Reco/classes.h | 1 + sbnobj/Common/Reco/classes_def.xml | 11 +++++++++++ 4 files changed, 53 insertions(+) create mode 100644 sbnobj/Common/Reco/LightCaloInfo.cc create mode 100644 sbnobj/Common/Reco/LightCaloInfo.h diff --git a/sbnobj/Common/Reco/LightCaloInfo.cc b/sbnobj/Common/Reco/LightCaloInfo.cc new file mode 100644 index 00000000..250595a2 --- /dev/null +++ b/sbnobj/Common/Reco/LightCaloInfo.cc @@ -0,0 +1,12 @@ +#include "sbnobj/Common/Reco/LightCaloInfo.h" + +sbn::LightCalo::LightCalo(std::vector charge_v, std::vector light_v, + std::vector energy_v, std::vector plane_v, + double time) + : charge(charge_v) + , light(light_v) + , energy(energy_v) + , plane(plane_v) + , time(time) +{ +} \ No newline at end of file diff --git a/sbnobj/Common/Reco/LightCaloInfo.h b/sbnobj/Common/Reco/LightCaloInfo.h new file mode 100644 index 00000000..777e1c66 --- /dev/null +++ b/sbnobj/Common/Reco/LightCaloInfo.h @@ -0,0 +1,29 @@ +#ifndef sbnobj_LightCaloInfo_H +#define sbnobj_LightCaloInfo_H + +#include +#include "larcoreobj/SimpleTypesAndConstants/geo_types.h" + +namespace sbn +{ + class LightCalo + { + public: + + // note: not ordered as plane0, plane1, and plane2 necessarily. "best plane" is first + std::vector charge; // reconstructed charge (e-) + std::vector light; // reconstructed light (photons), set as the median of the light per channel + std::vector energy; // sum of charge and light + std::vector plane; // first plane is the best plane (most complete) + double time; // t0 associated with the flash match + + LightCalo(std::vector charge_v, + std::vector light_v, + std::vector energy_v, + std::vector plane_v, + double time); + LightCalo() {} + }; +} + +#endif diff --git a/sbnobj/Common/Reco/classes.h b/sbnobj/Common/Reco/classes.h index c28b166b..7f508b4f 100644 --- a/sbnobj/Common/Reco/classes.h +++ b/sbnobj/Common/Reco/classes.h @@ -24,6 +24,7 @@ #include "sbnobj/Common/Reco/VertexHit.h" #include "sbnobj/Common/Reco/MVAPID.h" #include "sbnobj/Common/Reco/CRUMBSResult.h" +#include "sbnobj/Common/Reco/LightCaloInfo.h" #include #include diff --git a/sbnobj/Common/Reco/classes_def.xml b/sbnobj/Common/Reco/classes_def.xml index 233f8721..cc139ac3 100644 --- a/sbnobj/Common/Reco/classes_def.xml +++ b/sbnobj/Common/Reco/classes_def.xml @@ -76,6 +76,17 @@ + + + + + + + + + + + From e39af6aff351cf93a973da87488cb571a783c7ea Mon Sep 17 00:00:00 2001 From: lynnt-uchicago Date: Tue, 16 May 2023 09:29:15 -0500 Subject: [PATCH 2/4] add helper functions --- sbnobj/Common/Reco/LightCaloInfo.cc | 17 +++++++++++++++++ sbnobj/Common/Reco/LightCaloInfo.h | 15 +++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/sbnobj/Common/Reco/LightCaloInfo.cc b/sbnobj/Common/Reco/LightCaloInfo.cc index 250595a2..12ab9092 100644 --- a/sbnobj/Common/Reco/LightCaloInfo.cc +++ b/sbnobj/Common/Reco/LightCaloInfo.cc @@ -1,5 +1,6 @@ #include "sbnobj/Common/Reco/LightCaloInfo.h" +// initializer sbn::LightCalo::LightCalo(std::vector charge_v, std::vector light_v, std::vector energy_v, std::vector plane_v, double time) @@ -9,4 +10,20 @@ sbn::LightCalo::LightCalo(std::vector charge_v, std::vector ligh , plane(plane_v) , time(time) { +} + +double sbn::LightCalo::bestCharge() const { + return charge.at(0); +} + +double sbn::LightCalo::bestLight() const { + return light.at(0); +} + +double sbn::LightCalo::bestEnergy() const { + return energy.at(0); +} + +int sbn::LightCalo::bestPlane() const { + return plane.at(0); } \ No newline at end of file diff --git a/sbnobj/Common/Reco/LightCaloInfo.h b/sbnobj/Common/Reco/LightCaloInfo.h index 777e1c66..cdc0f27c 100644 --- a/sbnobj/Common/Reco/LightCaloInfo.h +++ b/sbnobj/Common/Reco/LightCaloInfo.h @@ -11,10 +11,10 @@ namespace sbn public: // note: not ordered as plane0, plane1, and plane2 necessarily. "best plane" is first - std::vector charge; // reconstructed charge (e-) - std::vector light; // reconstructed light (photons), set as the median of the light per channel - std::vector energy; // sum of charge and light - std::vector plane; // first plane is the best plane (most complete) + std::vector charge = std::vector(3); // reconstructed charge (e-) + std::vector light = std::vector(3); // reconstructed light (photons), set as the median of the light per channel + std::vector energy = std::vector(3); // sum of charge and light + std::vector plane = std::vector(3); // first plane is the best plane (most complete) double time; // t0 associated with the flash match LightCalo(std::vector charge_v, @@ -23,6 +23,13 @@ namespace sbn std::vector plane_v, double time); LightCalo() {} + + /// Helper functions + double bestCharge() const; + double bestLight() const; + double bestEnergy() const; + int bestPlane() const; + }; } From e7249f6859ff101283ac146b97191a078500f0f9 Mon Sep 17 00:00:00 2001 From: lynnt20 Date: Mon, 17 Nov 2025 17:38:35 -0600 Subject: [PATCH 3/4] simplify the class for light calo objects --- sbnobj/Common/Reco/LightCaloInfo.cc | 30 +------------------- sbnobj/Common/Reco/LightCaloInfo.h | 43 ++++++++++++----------------- 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/sbnobj/Common/Reco/LightCaloInfo.cc b/sbnobj/Common/Reco/LightCaloInfo.cc index 12ab9092..f20e5161 100644 --- a/sbnobj/Common/Reco/LightCaloInfo.cc +++ b/sbnobj/Common/Reco/LightCaloInfo.cc @@ -1,29 +1 @@ -#include "sbnobj/Common/Reco/LightCaloInfo.h" - -// initializer -sbn::LightCalo::LightCalo(std::vector charge_v, std::vector light_v, - std::vector energy_v, std::vector plane_v, - double time) - : charge(charge_v) - , light(light_v) - , energy(energy_v) - , plane(plane_v) - , time(time) -{ -} - -double sbn::LightCalo::bestCharge() const { - return charge.at(0); -} - -double sbn::LightCalo::bestLight() const { - return light.at(0); -} - -double sbn::LightCalo::bestEnergy() const { - return energy.at(0); -} - -int sbn::LightCalo::bestPlane() const { - return plane.at(0); -} \ No newline at end of file +#include "sbnobj/Common/Reco/LightCaloInfo.h" \ No newline at end of file diff --git a/sbnobj/Common/Reco/LightCaloInfo.h b/sbnobj/Common/Reco/LightCaloInfo.h index cdc0f27c..4e8b4b7d 100644 --- a/sbnobj/Common/Reco/LightCaloInfo.h +++ b/sbnobj/Common/Reco/LightCaloInfo.h @@ -2,34 +2,27 @@ #define sbnobj_LightCaloInfo_H #include -#include "larcoreobj/SimpleTypesAndConstants/geo_types.h" +#include -namespace sbn -{ - class LightCalo - { - public: +namespace sbn{ + class LightCalo { + public: + static constexpr double nan = std::numeric_limits::signaling_NaN(); - // note: not ordered as plane0, plane1, and plane2 necessarily. "best plane" is first - std::vector charge = std::vector(3); // reconstructed charge (e-) - std::vector light = std::vector(3); // reconstructed light (photons), set as the median of the light per channel - std::vector energy = std::vector(3); // sum of charge and light - std::vector plane = std::vector(3); // first plane is the best plane (most complete) - double time; // t0 associated with the flash match - - LightCalo(std::vector charge_v, - std::vector light_v, - std::vector energy_v, - std::vector plane_v, - double time); - LightCalo() {} - - /// Helper functions - double bestCharge() const; - double bestLight() const; - double bestEnergy() const; - int bestPlane() const; + std::vector charge = std::vector(3, nan); + std::vector light = std::vector(3, nan); + std::vector energy = std::vector(3, nan); + int bestplane{ -1 }; + double time{ nan }; + LightCalo() = default; + LightCalo(std::vector charge, std::vector light, std::vector energy, int bestplane, double time) + : charge(charge) + , light(light) + , energy(energy) + , bestplane(bestplane) + , time(time) + {} }; } From 234ce58f8e028edc10152083c85f113d8355b234 Mon Sep 17 00:00:00 2001 From: lynnt20 Date: Wed, 10 Dec 2025 11:49:33 -0600 Subject: [PATCH 4/4] rename libraries, add comments --- sbnobj/Common/Reco/CMakeLists.txt | 1 + sbnobj/Common/Reco/LightCalo.cc | 1 + sbnobj/Common/Reco/LightCalo.h | 47 +++++++++++++++++++++++++++++ sbnobj/Common/Reco/LightCaloInfo.cc | 1 - sbnobj/Common/Reco/LightCaloInfo.h | 29 ------------------ sbnobj/Common/Reco/classes.h | 2 +- sbnobj/Common/Reco/classes_def.xml | 6 ++++ 7 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 sbnobj/Common/Reco/LightCalo.cc create mode 100644 sbnobj/Common/Reco/LightCalo.h delete mode 100644 sbnobj/Common/Reco/LightCaloInfo.cc delete mode 100644 sbnobj/Common/Reco/LightCaloInfo.h diff --git a/sbnobj/Common/Reco/CMakeLists.txt b/sbnobj/Common/Reco/CMakeLists.txt index bcdd52a1..50eebbfd 100644 --- a/sbnobj/Common/Reco/CMakeLists.txt +++ b/sbnobj/Common/Reco/CMakeLists.txt @@ -3,6 +3,7 @@ cet_make_library( CNNScore.cc CRUMBSResult.cc FlashTriggerPrimitive.cc + LightCalo.cc MVAPID.cc MergedTrackInfo.cc OpT0FinderResult.cc diff --git a/sbnobj/Common/Reco/LightCalo.cc b/sbnobj/Common/Reco/LightCalo.cc new file mode 100644 index 00000000..cf35a897 --- /dev/null +++ b/sbnobj/Common/Reco/LightCalo.cc @@ -0,0 +1 @@ +#include "sbnobj/Common/Reco/LightCalo.h" \ No newline at end of file diff --git a/sbnobj/Common/Reco/LightCalo.h b/sbnobj/Common/Reco/LightCalo.h new file mode 100644 index 00000000..75eb2efa --- /dev/null +++ b/sbnobj/Common/Reco/LightCalo.h @@ -0,0 +1,47 @@ +/** + * @file sbnobj/Common/Reco/LightCalo.h + * @brief Defines data structures for light calorimetry products. + * @author Lynn Tung + * @date December 2nd, 2025 + * + */ + +#ifndef sbnobj_LightCalo_H +#define sbnobj_LightCalo_H + +#include + +namespace sbn{ + + /** + * @brief A simple class to store reconstructed charge, light, and visible energy. + */ + + class LightCalo { + public: + + // NaN value to initialize data members + static constexpr double nan = std::numeric_limits::signaling_NaN(); + + /// @name Reconstructed charge, light, and visible energy data members. + /// @{ + double charge = nan; ///< Total charge in a reconstructed interaction (recob::Slice) [# of electrons] + double light = nan; ///< Total light in a reconstructed interaction (recob::Slice + recob::OpFlash) [# of photons] + double energy = nan; ///< Total visible energy (sum of charge+light) for a reconstructed interaction [GeV] + int bestplane = -1; ///< Plane that was used for the total charge + /// @} + + /** + * Default constructor. + */ + LightCalo() = default; + LightCalo(double charge, double light, double energy, int bestplane) + : charge(charge) + , light(light) + , energy(energy) + , bestplane(bestplane) + {} + }; +} + +#endif diff --git a/sbnobj/Common/Reco/LightCaloInfo.cc b/sbnobj/Common/Reco/LightCaloInfo.cc deleted file mode 100644 index f20e5161..00000000 --- a/sbnobj/Common/Reco/LightCaloInfo.cc +++ /dev/null @@ -1 +0,0 @@ -#include "sbnobj/Common/Reco/LightCaloInfo.h" \ No newline at end of file diff --git a/sbnobj/Common/Reco/LightCaloInfo.h b/sbnobj/Common/Reco/LightCaloInfo.h deleted file mode 100644 index 4e8b4b7d..00000000 --- a/sbnobj/Common/Reco/LightCaloInfo.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef sbnobj_LightCaloInfo_H -#define sbnobj_LightCaloInfo_H - -#include -#include - -namespace sbn{ - class LightCalo { - public: - static constexpr double nan = std::numeric_limits::signaling_NaN(); - - std::vector charge = std::vector(3, nan); - std::vector light = std::vector(3, nan); - std::vector energy = std::vector(3, nan); - int bestplane{ -1 }; - double time{ nan }; - - LightCalo() = default; - LightCalo(std::vector charge, std::vector light, std::vector energy, int bestplane, double time) - : charge(charge) - , light(light) - , energy(energy) - , bestplane(bestplane) - , time(time) - {} - }; -} - -#endif diff --git a/sbnobj/Common/Reco/classes.h b/sbnobj/Common/Reco/classes.h index adb069c8..ecd981af 100644 --- a/sbnobj/Common/Reco/classes.h +++ b/sbnobj/Common/Reco/classes.h @@ -28,7 +28,7 @@ #include "sbnobj/Common/Reco/VertexHit.h" #include "sbnobj/Common/Reco/MVAPID.h" #include "sbnobj/Common/Reco/CRUMBSResult.h" -#include "sbnobj/Common/Reco/LightCaloInfo.h" +#include "sbnobj/Common/Reco/LightCalo.h" #include "sbnobj/Common/Reco/OpT0FinderResult.h" #include "sbnobj/Common/Reco/CNNScore.h" #include "sbnobj/Common/Reco/TPCPMTBarycenterMatch.h" diff --git a/sbnobj/Common/Reco/classes_def.xml b/sbnobj/Common/Reco/classes_def.xml index 77248e6e..889a855d 100644 --- a/sbnobj/Common/Reco/classes_def.xml +++ b/sbnobj/Common/Reco/classes_def.xml @@ -88,6 +88,12 @@ + + + + + +