diff --git a/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h b/Detectors/Upgrades/ALICE3/IOTOF/DataFormatsIOTOF/include/DataFormatsIOTOF/Digit.h index 5dbe98839302d..f1e31b57c6f54 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" @@ -28,22 +29,28 @@ 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) + 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: double mTime = 0.; ///< Measured time (ns) + ULong64_t mBc = 0; ///< BC + Int_t mTdc = 0; ///< tdc time ClassDefNV(Digit, 1); }; @@ -59,9 +66,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..8e2f2915a2ec5 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Chip.h @@ -76,7 +76,7 @@ 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 @@ -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::ConfigurableParamHelper= mGeometry->getSize() || mGeometry->getSize() < 1) { LOG(debug) << "Invalid detector ID: " << chipID << ", geometry size: " << mGeometry->getSize(); @@ -316,7 +316,7 @@ void Digitizer::fillOutputContainer() } int digitID = mDigits->size(); - 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); } @@ -345,11 +345,20 @@ void Digitizer::registerDigits(Chip& chip, uint32_t roFrame, double time, int nR { (void)nROF; - auto key = o2::iotof::Digit::getOrderingKey(chip.getChipIndex(), row, col); + 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) / digitizerParams.tdcBin); + 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(nbc, row, col); 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, absoluteTime, nbc, tdc, label); } else { // Digit already exists, update charge and labels const int storedCharge = existingDigit->getCharge();