From 88b394159b2566aefe0526cdde11138792ffda82 Mon Sep 17 00:00:00 2001 From: maciacco Date: Tue, 1 Sep 2026 17:24:01 +0200 Subject: [PATCH 1/6] compute bc and tdc time from hit and event time --- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx index 5de01639312c4..b0fb878be2667 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx @@ -125,7 +125,9 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID) // Hit time is in seconds, convert to ns and add event time double hitTime = hit.GetTime() * sec2ns; // convert to ns double eventTimeNS = mEventTime.getTimeNS(); // event time since orbit 0 - double absoluteTime = hitTime + eventTimeNS; // absolute time + double eventTimeInBC = mEventTime.getTimeOffsetWrtBC(); +// double absoluteTime = hitTime + eventTimeNS; // absolute time + double absoluteTime = hitTime + eventTimeInBC; // absolute time double smearedTime = smearTime(absoluteTime); // apply detector resolution if (chipID < 0 || chipID >= mGeometry->getSize() || mGeometry->getSize() < 1) { @@ -340,11 +342,19 @@ void Digitizer::fillOutputContainer() // mExtraLabelBuffer.pop_front(); } +// have a addDigit funtion? + void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nROF, uint16_t row, uint16_t col, int nElectrons, o2::MCCompLabel& label) { (void)nROF; + uint64_t nbc = static_cast(time / o2::constants::lhc::LHCBunchSpacingNS); + int tdc = int((time - nbc * o2::constants::lhc::LHCBunchSpacingNS) / .01); + nbc += mEventTime.toLong(); + + LOG(debug) << nbc << "\t" << tdc; + auto key = o2::iotof::Digit::getOrderingKey(chip.getChipIndex(), row, col); o2::iotof::LabeledDigit* existingDigit = chip.findDigit(key); if (!existingDigit) { From 7dc8fdb60247e0b05880e6fd32e64ca9feacb118 Mon Sep 17 00:00:00 2001 From: maciacco Date: Thu, 3 Sep 2026 18:44:23 +0200 Subject: [PATCH 2/6] save bc and tdc in digit --- .../include/DataFormatsIOTOF/Digit.h | 12 ++++++++---- .../IOTOF/simulation/include/IOTOFSimulation/Chip.h | 8 ++++---- .../include/IOTOFSimulation/DPLDigitizerParam.h | 1 + .../Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx | 4 ++-- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 10 ++++++---- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h index 5dbe98839302d..20a01f730194a 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h @@ -28,14 +28,16 @@ class Digit : public o2::itsmft::Digit { public: ~Digit() = default; - Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0.) - : o2::itsmft::Digit(chipindex, row, col, charge), mTime(time) {}; + Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0., ULong64_t bc = 0, Int_t tdc = 0) + : o2::itsmft::Digit(chipindex, row, col, charge), mTime(time), mBc(bc), mTdc(tdc) {}; // Setters void setTime(double time) { mTime = time; } // Getters double getTime() const { return mTime; } + ULong64_t getBc() const { return mBc; } + Int_t getTdc() const { return mTdc; } static UInt_t getOrderingKey(UShort_t chipindex, UShort_t row, UShort_t col) { @@ -44,6 +46,8 @@ class Digit : public o2::itsmft::Digit private: double mTime = 0.; ///< Measured time (ns) + ULong64_t mBc = 0; ///< BC + Int_t mTdc = 0; ///< tdc time ClassDefNV(Digit, 1); }; @@ -59,9 +63,9 @@ struct McLabelRef { class LabeledDigit : public Digit { public: - LabeledDigit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0., + LabeledDigit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, double time = 0., ULong64_t bc = 0, Int_t tdc = 0, o2::MCCompLabel label = 0) - : Digit(chipindex, row, col, charge, time), mLabel(label) {} + : Digit(chipindex, row, col, charge, time, bc, tdc), mLabel(label) {} void setLabel(McLabelRef label) { mLabel = label; } McLabelRef getLabel() const { return mLabel; } diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h index ccd9f02fb32aa..1a1067869d26e 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h @@ -76,11 +76,11 @@ class Chip /// reset points container o2::iotof::LabeledDigit* findDigit(ULong64_t key); - void addDigit(UShort_t row, UShort_t col, Int_t charge, double time, o2::MCCompLabel label); + void addDigit(UShort_t row, UShort_t col, Int_t charge, double time, ULong64_t bc, Int_t tdc, o2::MCCompLabel label); protected: - Int_t mChipIndex = -1; ///< Chip ID - bool mDisabled = false; ///< Flag to indicate if the chip is disabled (e.g. due to dead channels) + Int_t mChipIndex = -1; ///< Chip ID + bool mDisabled = false; ///< Flag to indicate if the chip is disabled (e.g. due to dead channels) std::map mDigits; ///< Map of fired digits, possibly in multiple frames ClassDefNV(Chip, 1); @@ -95,4 +95,4 @@ inline o2::iotof::LabeledDigit* Chip::findDigit(ULong64_t key) } // namespace o2::iotof -#endif /* defined(ALICEO2_IOTOF_CHIP_H_) */ \ No newline at end of file +#endif /* defined(ALICEO2_IOTOF_CHIP_H_) */ diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h index 784071701eef7..c1cb7d2db6133 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h @@ -28,6 +28,7 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelpersize(); - mDigits->emplace_back(digit.getChipIndex(), digit.getRow(), digit.getColumn(), digit.getCharge(), digit.getTime()); + mDigits->emplace_back(digit.getChipIndex(), digit.getRow(), digit.getColumn(), digit.getCharge(), digit.getTime(), digit.getBc(), digit.getTdc()); if (mMCLabels) { mMCLabels->addElement(digitID, digit.getLabel().mLabel); } @@ -342,15 +342,17 @@ void Digitizer::fillOutputContainer() // mExtraLabelBuffer.pop_front(); } -// have a addDigit funtion? +// have a addDigit function? void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nROF, uint16_t row, uint16_t col, int nElectrons, o2::MCCompLabel& label) { (void)nROF; + const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance(); + uint64_t nbc = static_cast(time / o2::constants::lhc::LHCBunchSpacingNS); - int tdc = int((time - nbc * o2::constants::lhc::LHCBunchSpacingNS) / .01); + int tdc = int((time - nbc * o2::constants::lhc::LHCBunchSpacingNS) / digitizerParams.tdcBin); nbc += mEventTime.toLong(); LOG(debug) << nbc << "\t" << tdc; @@ -359,7 +361,7 @@ void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nR o2::iotof::LabeledDigit* existingDigit = chip.findDigit(key); if (!existingDigit) { // No existing digit, create a new one - chip.addDigit(row, col, nElectrons, time, label); + chip.addDigit(row, col, nElectrons, time, nbc, tdc, label); } else { // Digit already exists, update charge and labels const int storedCharge = existingDigit->getCharge(); From 70dafa09deb2605c729c9a61594f50ef83ad3296 Mon Sep 17 00:00:00 2001 From: maciacco Date: Fri, 4 Sep 2026 14:31:48 +0200 Subject: [PATCH 3/6] save absolute time in digit --- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx index fd2e40f6b67ec..e1f0d6b7ed315 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx @@ -123,12 +123,11 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID) // Get hit time and apply smearing // Hit time is in seconds, convert to ns and add event time - double hitTime = hit.GetTime() * sec2ns; // convert to ns - double eventTimeNS = mEventTime.getTimeNS(); // event time since orbit 0 + double hitTime = hit.GetTime() * sec2ns; // convert to ns + double eventTimeNS = mEventTime.getTimeNS(); // event time since orbit 0 double eventTimeInBC = mEventTime.getTimeOffsetWrtBC(); -// double absoluteTime = hitTime + eventTimeNS; // absolute time - double absoluteTime = hitTime + eventTimeInBC; // absolute time - double smearedTime = smearTime(absoluteTime); // apply detector resolution + double hitTimeWrtBC = hitTime + eventTimeInBC; // absolute time + double smearedTime = smearTime(hitTimeWrtBC); // apply detector resolution if (chipID < 0 || chipID >= mGeometry->getSize() || mGeometry->getSize() < 1) { LOG(debug) << "Invalid detector ID: " << chipID << ", geometry size: " << mGeometry->getSize(); @@ -356,12 +355,13 @@ void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nR nbc += mEventTime.toLong(); LOG(debug) << nbc << "\t" << tdc; + double absoluteTime = tdc * digitizerParams.tdcBin * 1.e-9 + nbc * o2::constants::lhc::LHCBunchSpacingNS; auto key = o2::iotof::Digit::getOrderingKey(chip.getChipIndex(), row, col); o2::iotof::LabeledDigit* existingDigit = chip.findDigit(key); if (!existingDigit) { // No existing digit, create a new one - chip.addDigit(row, col, nElectrons, time, nbc, tdc, label); + chip.addDigit(row, col, nElectrons, absoluteTime, nbc, tdc, label); } else { // Digit already exists, update charge and labels const int storedCharge = existingDigit->getCharge(); From abab0f5641be6916ee99d64ca7d134471778cc3d Mon Sep 17 00:00:00 2001 From: maciacco Date: Tue, 8 Sep 2026 13:46:57 +0200 Subject: [PATCH 4/6] use bc timing in digit ordering key --- .../DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h | 7 +++++-- Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx | 2 +- .../Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h index 20a01f730194a..e37a9a73b3cab 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h @@ -19,6 +19,7 @@ #ifndef ALICEO2_IOTOF_DIGIT_H #define ALICEO2_IOTOF_DIGIT_H +#include "CommonConstants/LHCConstants.h" #include "SimulationDataFormat/MCCompLabel.h" #include "DataFormatsITSMFT/Digit.h" @@ -39,9 +40,11 @@ class Digit : public o2::itsmft::Digit ULong64_t getBc() const { return mBc; } Int_t getTdc() const { return mTdc; } - static UInt_t getOrderingKey(UShort_t chipindex, UShort_t row, UShort_t col) + static ULong64_t getOrderingKey(ULong64_t bc, UShort_t row, UShort_t col) { - return (static_cast(chipindex) << 16) | (static_cast(row) << 8) | static_cast(col); + uint32_t orbit = bc / o2::constants::lhc::LHCMaxBunches; + uint16_t bunch = bc % o2::constants::lhc::LHCMaxBunches; + return (static_cast(orbit) << 32) | (static_cast(bunch) << 16) | (static_cast(row) << 8) | static_cast(col); } private: diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx index 371169fcd4806..c33d865e51654 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx @@ -34,6 +34,6 @@ Chip::Chip(Int_t index) //_______________________________________________________________________ void Chip::addDigit(UShort_t row, UShort_t col, Int_t charge, double time, ULong64_t bc, Int_t tdc, o2::MCCompLabel label) { - ULong64_t key = Digit::getOrderingKey(mChipIndex, row, col); + ULong64_t key = Digit::getOrderingKey(bc, row, col); mDigits.emplace(std::make_pair(key, LabeledDigit(mChipIndex, row, col, charge, time, bc, tdc, label))); } diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx index e1f0d6b7ed315..6300ff11e2041 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx @@ -357,7 +357,7 @@ void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nR LOG(debug) << nbc << "\t" << tdc; double absoluteTime = tdc * digitizerParams.tdcBin * 1.e-9 + nbc * o2::constants::lhc::LHCBunchSpacingNS; - auto key = o2::iotof::Digit::getOrderingKey(chip.getChipIndex(), row, col); + auto key = o2::iotof::Digit::getOrderingKey(nbc, row, col); o2::iotof::LabeledDigit* existingDigit = chip.findDigit(key); if (!existingDigit) { // No existing digit, create a new one From cf090039a37738100f8e0a5aff63b65b47b15401 Mon Sep 17 00:00:00 2001 From: maciacco Date: Tue, 8 Sep 2026 13:57:17 +0200 Subject: [PATCH 5/6] remove unused variable + remove unwanted comments --- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx index 6300ff11e2041..9ad46da8268ee 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx @@ -123,11 +123,10 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID) // Get hit time and apply smearing // Hit time is in seconds, convert to ns and add event time - double hitTime = hit.GetTime() * sec2ns; // convert to ns - double eventTimeNS = mEventTime.getTimeNS(); // event time since orbit 0 - double eventTimeInBC = mEventTime.getTimeOffsetWrtBC(); - double hitTimeWrtBC = hitTime + eventTimeInBC; // absolute time - double smearedTime = smearTime(hitTimeWrtBC); // apply detector resolution + double hitTime = hit.GetTime() * sec2ns; // convert to ns + double eventTimeInBC = mEventTime.getTimeOffsetWrtBC(); // event time wrt bc + double hitTimeWrtBC = hitTime + eventTimeInBC; // hit time wrt bc + double smearedTime = smearTime(hitTimeWrtBC); // apply detector resolution if (chipID < 0 || chipID >= mGeometry->getSize() || mGeometry->getSize() < 1) { LOG(debug) << "Invalid detector ID: " << chipID << ", geometry size: " << mGeometry->getSize(); @@ -341,8 +340,6 @@ void Digitizer::fillOutputContainer() // mExtraLabelBuffer.pop_front(); } -// have a addDigit function? - void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nROF, uint16_t row, uint16_t col, int nElectrons, o2::MCCompLabel& label) { From 2574ab152914f868956e7d3fea2f0dba1c701f2e Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 8 Sep 2026 11:59:32 +0000 Subject: [PATCH 6/6] Please consider the following formatting changes --- .../IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h | 2 +- .../ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h index e37a9a73b3cab..f1e31b57c6f54 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h @@ -49,7 +49,7 @@ class Digit : public o2::itsmft::Digit private: double mTime = 0.; ///< Measured time (ns) - ULong64_t mBc = 0; ///< BC + ULong64_t mBc = 0; ///< BC Int_t mTdc = 0; ///< tdc time ClassDefNV(Digit, 1); }; diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h index 1a1067869d26e..8e2f2915a2ec5 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h @@ -79,8 +79,8 @@ class Chip void addDigit(UShort_t row, UShort_t col, Int_t charge, double time, ULong64_t bc, Int_t tdc, o2::MCCompLabel label); protected: - Int_t mChipIndex = -1; ///< Chip ID - bool mDisabled = false; ///< Flag to indicate if the chip is disabled (e.g. due to dead channels) + Int_t mChipIndex = -1; ///< Chip ID + bool mDisabled = false; ///< Flag to indicate if the chip is disabled (e.g. due to dead channels) std::map mDigits; ///< Map of fired digits, possibly in multiple frames ClassDefNV(Chip, 1);