From c228bd79864162aed70f4016c8e16e6125ef788f Mon Sep 17 00:00:00 2001 From: maciacco Date: Fri, 13 Nov 2026 23:43:55 +0100 Subject: [PATCH 1/4] recompute time from bc and tdc --- .../include/DataFormatsIOTOF/Cluster.h | 13 ++++++--- .../include/IOTOFReconstruction/Clusterer.h | 1 + .../IOTOF/reconstruction/src/Clusterer.cxx | 27 ++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h index b16a6e8bf2f39..a3b24a0c58a10 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h @@ -113,17 +113,19 @@ class Cluster static constexpr uint16_t InvalidPatternID = static_cast(ClusterInfo::MaskPattern); Cluster() = default; - Cluster(UShort_t row, UShort_t col, UShort_t rowSpan, UShort_t colSpan, UShort_t patt, UShort_t topo, UShort_t chipID = 0, time_t time = 0.0f) - : mChipID(chipID), mTime(time) + Cluster(UShort_t row, UShort_t col, UShort_t rowSpan, UShort_t colSpan, UShort_t patt, UShort_t topo, UShort_t chipID = 0, time_t time = 0.0f, uint64_t bc = 0, float timeWrtBc = 0.0f) + : mChipID(chipID), mTime(time), mBc(bc), mTimeWrtBc(timeWrtBc) { mClusterInfo.data = ClusterInfo::pack(row, col, rowSpan, colSpan, patt, topo); } - void set(UShort_t row, UShort_t col, UShort_t rowSpan, UShort_t colSpan, UShort_t patt, UShort_t topo, UShort_t chipID, time_t time) + void set(UShort_t row, UShort_t col, UShort_t rowSpan, UShort_t colSpan, UShort_t patt, UShort_t topo, UShort_t chipID, time_t time, uint64_t bc, float timeWrtBc) { mClusterInfo.data = ClusterInfo::pack(row, col, rowSpan, colSpan, patt, topo); mChipID = chipID; mTime = time; + mBc = bc; + mTimeWrtBc = timeWrtBc; } // Unpack Getters @@ -149,6 +151,9 @@ class Cluster uint32_t getChipID() const { return mChipID; } uint32_t getSensorID() const { return mChipID; } time_t getTime() const { return mTime; } + uint64_t getBc() const { return mBc; } + float gettimeWrtBc() const { return mTimeWrtBc; } + uint64_t getPackedData() const { return mClusterInfo.data; } // Setters @@ -174,6 +179,8 @@ class Cluster ClusterInfo mClusterInfo{}; ///< 64-bit packed structure containing geometry/topology UShort_t mChipID{0}; ///< Chip / Sensor ID float mTime{0.0f}; ///< Hit timing information + uint64_t mBc{0}; ///< Number of bunch crossing + float mTimeWrtBc{0.0f}; ///< Cluster time w.r.t. BC void sanityCheck(); diff --git a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/include/IOTOFReconstruction/Clusterer.h b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/include/IOTOFReconstruction/Clusterer.h index 9409339a02623..aae4ebac94e97 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/include/IOTOFReconstruction/Clusterer.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/include/IOTOFReconstruction/Clusterer.h @@ -24,6 +24,7 @@ #include "SimulationDataFormat/ConstMCTruthContainer.h" #include "SimulationDataFormat/MCCompLabel.h" #include "SimulationDataFormat/MCTruthContainer.h" +#include "CommonConstants/LHCConstants.h" #include #include #include diff --git a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx index 06e240bbbec27..42c732e854b04 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx @@ -170,11 +170,15 @@ void Clusterer::ClustererThread::findClustersSingleHit(gsl::span di const ConstDigitTruth* labelsDigPtr, ClusterTruth* labelsClusPtr) { + const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance(); const auto& digit = digits[digitIdx]; const uint16_t chipID = digit.getChipIndex(); const uint16_t row = digit.getRow(); const uint16_t col = digit.getColumn(); - const time_t time = digit.getTime(); + //const time_t time = digit.getTime(); + uint64_t nbc = digit.getBc(); + float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; + const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; if (labelsClusPtr) { int nStoredLabels = 0; @@ -192,7 +196,7 @@ void Clusterer::ClustererThread::findClustersSingleHit(gsl::span di constexpr uint16_t firedDigitsMask = (1U << 0); // 0x0001 (1) mClsTopoClassifier.getTopology(firedDigitsMask, minRow, rowSpan, minCol, colSpan, clsTopology); // Bit 0 corresponds to (rowOffset=0, colOffset=0) in row-major order - Cluster cluster(row, col, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, time); + Cluster cluster(row, col, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, time, nbc, timeWrtBc); LOG(debug) << "Pushing back cluster with row: " << row << ", col: " << col << ", rowSpan: " << static_cast(rowSpan) << ", colSpan: " << static_cast(colSpan) @@ -270,7 +274,10 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span const auto& digit = digits[precluster[0]]; const uint16_t row = digit.getRow(); const uint16_t col = digit.getColumn(); - const time_t time = digit.getTime(); + // const time_t time = digit.getTime(); + uint64_t nbc = digit.getBc(); + float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; + const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; if (labelsClusPtr) { int nMcLabels = 0; @@ -288,7 +295,7 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span constexpr uint16_t firedDigitsMask = (1U << 0); // 0x0001 (1) mClsTopoClassifier.getTopology(firedDigitsMask, minRow, rowSpan, minCol, colSpan, clsTopology); // Bit 0 corresponds to (rowOffset=0, colOffset=0) in row-major order - Cluster cluster(minRow, minCol, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, time); + Cluster cluster(minRow, minCol, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, time, nbc, timeWrtBc); LOG(debug) << "Pushing back cluster with row: " << row << ", col: " << col << ", rowSpan: " << static_cast(rowSpan) << ", colSpan: " << static_cast(colSpan) @@ -314,19 +321,25 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span minCol = std::min(minCol, digit.getColumn()); maxRow = std::max(maxRow, digit.getRow()); maxCol = std::max(maxCol, digit.getColumn()); - clsTime += digit.getTime(); + uint64_t nbc = digit.getBc(); + float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; + const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; + clsTime += time; fetchMCLabels(idx, labelsDigPtr, nMcLabels); } clsTime /= precluster.size(); const uint8_t rowSpan = maxRow - minRow + 1; const uint8_t colSpan = maxCol - minCol + 1; + uint64_t nbc = static_cast(clsTime / o2::constants::lhc::LHCBunchSpacingNS); + float timeWrtBc = clsTime - nbc * o2::constants::lhc::LHCBunchSpacingNS; + // Fired digits bitmask packed into a single 16-bit pattern variable uint16_t firedDigitsMask = 0; if (rowSpan * colSpan > maxFiredDigitsForCls) { // Overflow precluster: pass InvalidPatternID (or 0) and kHuge topology flag - Cluster cluster(minRow, minCol, rowSpan, colSpan, Cluster::InvalidPatternID, Topologies::kHuge, chipID, clsTime); + Cluster cluster(minRow, minCol, rowSpan, colSpan, Cluster::InvalidPatternID, Topologies::kHuge, chipID, clsTime, nbc, timeWrtBc); mClusters.emplace_back(cluster); mPatterns.emplace_back(Cluster::InvalidPatternID); continue; @@ -354,7 +367,7 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span for (int i = 0; i < nMcLabels; i++) { mLabels.addElement(nStoredCls, mLabelsBuff[i]); } - Cluster cluster(minRow, minCol, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, clsTime); + Cluster cluster(minRow, minCol, rowSpan, colSpan, firedDigitsMask, clsTopology, chipID, clsTime, nbc, timeWrtBc); LOG(debug) << "Pushing back cluster with row: " << minRow << ", col: " << minCol << ", rowSpan: " << static_cast(rowSpan) << ", colSpan: " << static_cast(colSpan) << ", pattern: " << firedDigitsMask << ", topology: " << static_cast(clsTopology) From c04dcbba23c5c020426a14e455900d1d2deae6e3 Mon Sep 17 00:00:00 2001 From: maciacco Date: Sat, 14 Nov 2026 00:30:10 +0100 Subject: [PATCH 2/4] add setters --- .../IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h index a3b24a0c58a10..6c36416bfc857 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Cluster.h @@ -152,7 +152,7 @@ class Cluster uint32_t getSensorID() const { return mChipID; } time_t getTime() const { return mTime; } uint64_t getBc() const { return mBc; } - float gettimeWrtBc() const { return mTimeWrtBc; } + float getTimeWrtBc() const { return mTimeWrtBc; } uint64_t getPackedData() const { return mClusterInfo.data; } @@ -165,6 +165,8 @@ class Cluster void setTopology(UShort_t t) { mClusterInfo.setTopology(t); } void setChipID(UShort_t c) { mChipID = c; } void setTime(time_t t) { mTime = t; } + void setBc(uint64_t bc) { mBc = bc; } + void setTimeWrtBc(float timeWrtBc) { mTimeWrtBc = timeWrtBc; } // Operators & Debugging bool operator==(const Cluster& cl) const From 43b6c879c59392a867e3a4218397acc298b192b4 Mon Sep 17 00:00:00 2001 From: maciacco Date: Sat, 14 Nov 2026 00:34:24 +0100 Subject: [PATCH 3/4] add const + simplify --- .../IOTOF/reconstruction/src/Clusterer.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx index 42c732e854b04..000da2c8505ff 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx @@ -176,8 +176,8 @@ void Clusterer::ClustererThread::findClustersSingleHit(gsl::span di const uint16_t row = digit.getRow(); const uint16_t col = digit.getColumn(); //const time_t time = digit.getTime(); - uint64_t nbc = digit.getBc(); - float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; + const uint64_t nbc = digit.getBc(); + const float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; if (labelsClusPtr) { @@ -275,8 +275,8 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span const uint16_t row = digit.getRow(); const uint16_t col = digit.getColumn(); // const time_t time = digit.getTime(); - uint64_t nbc = digit.getBc(); - float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; + const uint64_t nbc = digit.getBc(); + const float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; if (labelsClusPtr) { @@ -321,9 +321,7 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span minCol = std::min(minCol, digit.getColumn()); maxRow = std::max(maxRow, digit.getRow()); maxCol = std::max(maxCol, digit.getColumn()); - uint64_t nbc = digit.getBc(); - float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; - const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS; + const time_t time = digit.getTdc() * digitizerParams.tdcBin + digit.getBc() * o2::constants::lhc::LHCBunchSpacingNS; clsTime += time; fetchMCLabels(idx, labelsDigPtr, nMcLabels); } @@ -331,8 +329,8 @@ void Clusterer::ClustererThread::findClustersMultipleHits(gsl::span const uint8_t rowSpan = maxRow - minRow + 1; const uint8_t colSpan = maxCol - minCol + 1; - uint64_t nbc = static_cast(clsTime / o2::constants::lhc::LHCBunchSpacingNS); - float timeWrtBc = clsTime - nbc * o2::constants::lhc::LHCBunchSpacingNS; + const uint64_t nbc = static_cast(clsTime / o2::constants::lhc::LHCBunchSpacingNS); + const float timeWrtBc = clsTime - nbc * o2::constants::lhc::LHCBunchSpacingNS; // Fired digits bitmask packed into a single 16-bit pattern variable uint16_t firedDigitsMask = 0; From 50911a5724366a0f3b615d693883467c347b1119 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 13 Nov 2026 23:36:26 +0000 Subject: [PATCH 4/4] Please consider the following formatting changes --- .../Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx index 000da2c8505ff..af5837ccc8c0a 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/reconstruction/src/Clusterer.cxx @@ -175,7 +175,7 @@ void Clusterer::ClustererThread::findClustersSingleHit(gsl::span di const uint16_t chipID = digit.getChipIndex(); const uint16_t row = digit.getRow(); const uint16_t col = digit.getColumn(); - //const time_t time = digit.getTime(); + // const time_t time = digit.getTime(); const uint64_t nbc = digit.getBc(); const float timeWrtBc = digit.getTdc() * digitizerParams.tdcBin; const time_t time = timeWrtBc + nbc * o2::constants::lhc::LHCBunchSpacingNS;