Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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<UInt_t>(chipindex) << 16) | (static_cast<UInt_t>(row) << 8) | static_cast<UInt_t>(col);
uint32_t orbit = bc / o2::constants::lhc::LHCMaxBunches;
uint16_t bunch = bc % o2::constants::lhc::LHCMaxBunches;
return (static_cast<ULong64_t>(orbit) << 32) | (static_cast<UInt_t>(bunch) << 16) | (static_cast<UInt_t>(row) << 8) | static_cast<UInt_t>(col);
}

private:
double mTime = 0.; ///< Measured time (ns)
ULong64_t mBc = 0; ///< BC
Int_t mTdc = 0; ///< tdc time
ClassDefNV(Digit, 1);
};

Expand All @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,4 +95,4 @@ inline o2::iotof::LabeledDigit* Chip::findDigit(ULong64_t key)

} // namespace o2::iotof

#endif /* defined(ALICEO2_IOTOF_CHIP_H_) */
#endif /* defined(ALICEO2_IOTOF_CHIP_H_) */
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer

double timeOffset = 0.; ///< time offset (in seconds!) to calculate ROFrame from hit time
float timeResolution = 0.020f; ///< time resolution sigma in ns (20 ps default)
float tdcBin = 0.010f; ///< TDC time bin (10 ps default)
float efficiency = 0.98f; ///< detection efficiency
int chargeThreshold = 100; ///< charge threshold in Nelectrons
int minChargeToAccount = 7; ///< minimum charge contribution to account
Expand Down
6 changes: 3 additions & 3 deletions Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Chip::Chip(Int_t index)
{
}
//_______________________________________________________________________
void Chip::addDigit(UShort_t row, UShort_t col, Int_t charge, double time, o2::MCCompLabel label)
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);
mDigits.emplace(std::make_pair(key, LabeledDigit(mChipIndex, row, col, charge, time, label)));
ULong64_t key = Digit::getOrderingKey(bc, row, col);
mDigits.emplace(std::make_pair(key, LabeledDigit(mChipIndex, row, col, charge, time, bc, tdc, label)));
}
23 changes: 16 additions & 7 deletions Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +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 absoluteTime = hitTime + eventTimeNS; // absolute time
double smearedTime = smearTime(absoluteTime); // 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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<uint64_t>(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();
Expand Down
Loading