镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@

namespace o2::iotof
{
struct DigitKey {
ULong64_t high;
UInt_t low;

bool operator<(const DigitKey& other) const
{
if (high != other.high) {
return high < other.high;
}
return low < other.low;
}
};

class Digit : public o2::itsmft::Digit
{
public:
Expand All @@ -40,11 +53,14 @@ class Digit : public o2::itsmft::Digit
ULong64_t getBc() const { return mBc; }
Int_t getTdc() const { return mTdc; }

static ULong64_t getOrderingKey(ULong64_t bc, UShort_t row, UShort_t col)
static DigitKey getOrderingKey(ULong64_t bc, UInt_t tdc, uint16_t row, uint16_t col)
{
DigitKey key;
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);
key.high = (static_cast<ULong64_t>(orbit) << 32) | (static_cast<UInt_t>(bunch) << 16) | (static_cast<UInt_t>(tdc) & 0xFFFF);
key.low = (static_cast<UInt_t>(row) << 16) | (static_cast<UInt_t>(col) & 0xFFFF);
return key;
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Chip
/// @param option unused
void clear() { mDigits.clear(); }

std::map<ULong64_t, o2::iotof::LabeledDigit>& getDigits() { return mDigits; }
std::map<DigitKey, o2::iotof::LabeledDigit>& getDigits() { return mDigits; }
bool isEmpty() const { return mDigits.empty(); }

void setChipIndex(Int_t index) { mChipIndex = index; }
Expand All @@ -74,19 +74,24 @@ class Chip
Int_t getNumberOfDigits() const { return mDigits.size(); }

/// reset points container
o2::iotof::LabeledDigit* findDigit(ULong64_t key);
o2::iotof::LabeledDigit* findDigit(DigitKey key);

/// Resize the vector of tdc states
void resizeTDCStates(int const size) { mTDCStates.resize(size); }
std::vector<std::array<double, 2>>& getTDCStates() { return mTDCStates; }

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)
std::map<ULong64_t, o2::iotof::LabeledDigit> mDigits; ///< Map of fired digits, possibly in multiple frames
std::map<DigitKey, o2::iotof::LabeledDigit> mDigits; ///< Map of fired digits, possibly in multiple frames
std::vector<std::array<double, 2>> mTDCStates; ///< Vector of the last times the TDC pairs went busy

ClassDefNV(Chip, 1);
};

inline o2::iotof::LabeledDigit* Chip::findDigit(ULong64_t key)
inline o2::iotof::LabeledDigit* Chip::findDigit(DigitKey key)
{
// finds the digit corresponding to global key
auto digitentry = mDigits.find(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer
float energyToNElectrons = 1. / 3.6e-9; // conversion of eloss to Nelectrons
int responseMatrixSize = 1; ///< size of the response matrix (odd number)

int nColsPerGroup = 4; ///< number of pixel columns grouped into a readout column
double tdcBusyTime = 3000.; ///< tdc pair bsuy time (default 3 us)

std::string noiseFilePath{}; ///< optional noise masks file path. FIXME to be removed once switch to CCDBFetcher

// boilerplate stuff + make principal key
Expand Down
2 changes: 1 addition & 1 deletion Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Chip.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(bc, row, col);
DigitKey key = Digit::getOrderingKey(bc, tdc, row, col);
mDigits.emplace(std::make_pair(key, LabeledDigit(mChipIndex, row, col, charge, time, bc, tdc, label)));
}
38 changes: 32 additions & 6 deletions Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ void Digitizer::init()
{
const int numberOfChips = mGeometry->getSize();
mChips.resize(numberOfChips);

const auto& specsConfig = ChipSpecificsParam::Instance();
const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance();
const int nReadOutCols = specsConfig.NCols / digitizerParams.nColsPerGroup + 1;
for (int i = numberOfChips; i--;) {
mChips[i].setChipIndex(i);
/// Noise map to be implemented
Expand All @@ -53,9 +57,15 @@ void Digitizer::init()
/// mChips[i].disable(mDeadChanMap->isFullChipMasked(i));
/// mChips[i].setDeadChanMap(mDeadChanMap);
/// }

// initialize the vector of TDC states
mChips[i].resizeTDCStates(nReadOutCols);
for (auto& tdcStates : mChips[i].getTDCStates()) {
tdcStates[0] = -999.f;
tdcStates[1] = -999.f;
}
}

const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance();
if (!digitizerParams.efficiencyFilePath.empty()) {
loadEfficiencyMap(digitizerParams.efficiencyFilePath);
}
Expand Down Expand Up @@ -135,7 +145,6 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID)
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);

// Create the digit with time information
o2::MCCompLabel label(hit.GetTrackID(), evID, srcID, false);
Expand Down Expand Up @@ -168,6 +177,8 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, int evID, int srcID)
const int nElectronsSampled = gRandom->Poisson(electronsPerStep * nEleResp);
// Noise can be added here if needed

double smearedTime = smearTime(hitTimeWrtBC);

registerDigits(chip, roFrameAbs, smearedTime, nROF,
static_cast<uint16_t>(rowIS), static_cast<uint16_t>(colIS), nElectronsSampled, label);
}
Expand Down Expand Up @@ -195,7 +206,6 @@ void Digitizer::stepping(const o2::itsmft::Hit& hit, float**& respMatrix, float*
const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance();
auto stepVector = (xyzPositionEnd - xyzPositionStart) / digitizerParams.nSimSteps;
xyzPositionStart = xyzPositionStart + stepVector * 0.5f; // center the start position in the middle of the step
xyzPositionEnd = xyzPositionEnd - stepVector * 0.5f; // center the end position in the middle of the step

rowStart = -1;
colStart = -1;
Expand Down Expand Up @@ -404,12 +414,25 @@ void Digitizer::fillOutputContainer()
}

auto& chipDigits = chip.getDigits();
auto& tdcStates = chip.getTDCStates();

for (const auto& [key, digit] : chipDigits) {

if (digit.getCharge() < digitizerParams.chargeThreshold) {
continue; // skip digits below threshold
}

const int colInGroup = digit.getColumn() / digitizerParams.nColsPerGroup;
const double digitTime = digit.getTime();
if (digitTime - tdcStates[colInGroup][0] < digitizerParams.tdcBusyTime && digitTime - tdcStates[colInGroup][1] < digitizerParams.tdcBusyTime) {
// TODO: improve labels treatment if multiple hits cross the same pixel during
continue; // both tdc pairs are busy
} else if (digitTime - tdcStates[colInGroup][0] > digitizerParams.tdcBusyTime) {
tdcStates[colInGroup][0] = digitTime;
} else if (digitTime - tdcStates[colInGroup][1] > digitizerParams.tdcBusyTime) {
tdcStates[colInGroup][1] = digitTime;
}

int digitID = mDigits->size();
mDigits->emplace_back(digit.getChipIndex(), digit.getRow(), digit.getColumn(), digit.getCharge(), digit.getTime(), digit.getBc(), digit.getTdc());
if (mMCLabels) {
Expand Down Expand Up @@ -438,18 +461,21 @@ void Digitizer::fillOutputContainer()
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;
// (void)nROF;

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();

double absoluteTime = tdc * digitizerParams.tdcBin * 1.e-9 + nbc * o2::constants::lhc::LHCBunchSpacingNS;
double absoluteTime = tdc * digitizerParams.tdcBin + nbc * o2::constants::lhc::LHCBunchSpacingNS;

auto key = o2::iotof::Digit::getOrderingKey(nbc, row, col);
auto key = o2::iotof::Digit::getOrderingKey(nbc, tdc, row, col);
o2::iotof::LabeledDigit* existingDigit = chip.findDigit(key);

chip.addDigit(row, col, nElectrons, absoluteTime, nbc, tdc, label);

if (!existingDigit) {
// No existing digit, create a new one
chip.addDigit(row, col, nElectrons, absoluteTime, nbc, tdc, label);
Expand Down
Loading