Skip to content

Commit 6994ca6

Browse files
authored
[ALICE3] TRKFT3: first implementation to store Time of Arrival into digits (#16012)
1 parent f65ed96 commit 6994ca6

9 files changed

Lines changed: 131 additions & 30 deletions

File tree

‎DataFormats/Detectors/Upgrades/ALICE3/TRKFT3/common/include/DataFormatsTRKFT3/Digit.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ namespace o2::trkft3
2222
class Digit
2323
{
2424
public:
25-
Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0);
25+
Digit(UShort_t chipindex = 0, UShort_t row = 0, UShort_t col = 0, Int_t charge = 0, float toa = 0);
2626
~Digit() = default;
2727

2828
UShort_t getChipIndex() const { return mChipIndex; }
2929
UShort_t getColumn() const { return mCol; }
3030
UShort_t getRow() const { return mRow; }
3131
Int_t getCharge() const { return mCharge; }
32+
float getTimeOfArrival() const { return mToA; }
3233

3334
void setChipIndex(UShort_t index) { mChipIndex = index; }
3435
void setPixelIndex(UShort_t row, UShort_t col)
@@ -38,6 +39,7 @@ class Digit
3839
}
3940
void setCharge(Int_t charge) { mCharge = charge < USHRT_MAX ? charge : USHRT_MAX; }
4041
void addCharge(int charge) { setCharge(charge + int(mCharge)); }
42+
void setToA(float toa) { mToA = toa; }
4143

4244
std::ostream& print(std::ostream& output) const;
4345
friend std::ostream& operator<<(std::ostream& output, const Digit& digi)
@@ -51,8 +53,9 @@ class Digit
5153
UShort_t mRow = 0;
5254
UShort_t mCol = 0;
5355
UShort_t mCharge = 0;
56+
float mToA = 0; // TimeOfArrival, set to float at the moment. TODO: implement correctly the size https://indico.cern.ch/event/1724141/contributions/7252329/attachments/3336751/5980668/data_throughput_estimation.pdf
5457

55-
ClassDefNV(Digit, 1);
58+
ClassDefNV(Digit, 2);
5659
};
5760

5861
} // namespace o2::trkft3

‎DataFormats/Detectors/Upgrades/ALICE3/TRKFT3/common/src/Digit.cxx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ ClassImp(o2::trkft3::Digit);
1616

1717
using namespace o2::trkft3;
1818

19-
Digit::Digit(UShort_t chipindex, UShort_t row, UShort_t col, Int_t charge)
19+
Digit::Digit(UShort_t chipindex, UShort_t row, UShort_t col, Int_t charge, float toa)
2020
: mChipIndex(chipindex), mRow(row), mCol(col)
2121
{
2222
setCharge(charge);
23+
setToA(toa);
2324
}
2425

2526
std::ostream& Digit::print(std::ostream& output) const
2627
{
27-
output << "TRKFT3Digit chip [" << mChipIndex << "] R:" << mRow << " C:" << mCol << " Q: " << mCharge;
28+
output << "TRKFT3Digit chip [" << mChipIndex << "] R:" << mRow << " C:" << mCol << " Q: " << mCharge << " ToA: " << mToA;
2829
return output;
2930
}

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ o2_target_root_dictionary(TRKFT3Simulation
2828
include/TRKFT3Simulation/DigiParams.h
2929
include/TRKFT3Simulation/Digitizer.h
3030
include/TRKFT3Simulation/DPLDigitizerParam.h
31+
include/TRKFT3Simulation/PreDigit.h
3132
LINKDEF src/TRKFT3SimulationLinkDef.h)

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/include/TRKFT3Simulation/ChipDigitsContainer.h‎

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
#ifndef ALICEO2_TRK_CHIPDIGITSCONTAINER_
1313
#define ALICEO2_TRK_CHIPDIGITSCONTAINER_
1414

15-
#include "ITSMFTBase/SegmentationAlpide.h"
16-
#include "ITSMFTSimulation/ChipDigitsContainer.h"
15+
#include "TRKFT3Simulation/PreDigit.h"
16+
#include "SimulationDataFormat/MCCompLabel.h"
17+
#include "DataFormatsITSMFT/NoiseMap.h"
1718
#include "TRKBase/SegmentationChip.h"
1819
#include "TRKBase/Specs.h"
1920
#include "TRKFT3Simulation/DigiParams.h"
@@ -23,27 +24,64 @@
2324
namespace o2::trkft3
2425
{
2526

26-
class ChipDigitsContainer : public o2::itsmft::ChipDigitsContainer
27+
/// @class ChipDigitsContainer
28+
/// @brief Container for simulated points connected to a given chip
29+
30+
class ChipDigitsContainer
2731
{
2832
public:
33+
/// Default constructor
2934
explicit ChipDigitsContainer(UShort_t idx = 0);
3035

31-
using Segmentation = o2::trk::SegmentationChip;
36+
/// Destructor
37+
~ChipDigitsContainer() = default;
38+
39+
std::map<ULong64_t, o2::trkft3::PreDigit>& getPreDigits() { return mDigits; }
40+
bool isEmpty() const { return mDigits.empty(); }
41+
void setNoiseMap(const o2::itsmft::NoiseMap* mp) { mNoiseMap = mp; }
42+
void setDeadChanMap(const o2::itsmft::NoiseMap* mp) { mDeadChanMap = mp; }
43+
void setChipIndex(UShort_t ind) { mChipIndex = ind; }
44+
UShort_t getChipIndex() const { return mChipIndex; }
45+
46+
o2::trkft3::PreDigit* findDigit(ULong64_t key);
47+
void addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col, int charge, o2::MCCompLabel lbl, float toa = 0.f);
48+
template <int DetID>
49+
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer);
3250

3351
/// Get global ordering key made of readout frame, column and row
3452
static ULong64_t getOrderingKey(UInt_t roframe, UShort_t row, UShort_t col)
3553
{
3654
return (static_cast<ULong64_t>(roframe) << (8 * sizeof(UInt_t))) + (static_cast<ULong64_t>(col) << (8 * sizeof(Short_t))) + row;
3755
}
3856

39-
/// Adds noise digits, deleted the one using the itsmft::DigiParams interface
40-
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::itsmft::DigiParams* params, int maxRows = o2::itsmft::SegmentationAlpide::NRows, int maxCols = o2::itsmft::SegmentationAlpide::NCols) = delete;
41-
template <int DetID>
42-
void addNoise(UInt_t rofMin, UInt_t rofMax, const o2::trkft3::DigiParams<DetID>* params, int subDetID, int layer);
57+
bool isDisabled() const { return mDisabled; }
58+
void disable(bool v) { mDisabled = v; }
4359

44-
ClassDefNV(ChipDigitsContainer, 1);
60+
protected:
61+
UShort_t mChipIndex = 0; ///< chip index
62+
bool mDisabled = false;
63+
const o2::itsmft::NoiseMap* mNoiseMap = nullptr;
64+
const o2::itsmft::NoiseMap* mDeadChanMap = nullptr;
65+
std::map<ULong64_t, o2::trkft3::PreDigit> mDigits; ///< Map of fired pixels, possibly in multiple frames
66+
67+
ClassDefNV(ChipDigitsContainer, 2);
4568
};
4669

70+
//_______________________________________________________________________
71+
inline o2::trkft3::PreDigit* ChipDigitsContainer::findDigit(ULong64_t key)
72+
{
73+
// finds the digit corresponding to global key
74+
auto digitentry = mDigits.find(key);
75+
return digitentry != mDigits.end() ? &(digitentry->second) : nullptr;
76+
}
77+
78+
//_______________________________________________________________________
79+
inline void ChipDigitsContainer::addDigit(ULong64_t key, UInt_t roframe, UShort_t row, UShort_t col,
80+
int charge, o2::MCCompLabel lbl, float toa)
81+
{
82+
mDigits.emplace(key, o2::trkft3::PreDigit(roframe, row, col, charge, lbl, toa));
83+
}
84+
4785
} // namespace o2::trkft3
4886

4987
template <int DetID>
@@ -83,10 +121,10 @@ void o2::trkft3::ChipDigitsContainer::addNoise(UInt_t rofMin, UInt_t rofMax, con
83121
}
84122
auto key = getOrderingKey(rof, row, col);
85123
if (!findDigit(key)) {
86-
addDigit(key, rof, row, col, nel, o2::MCCompLabel(true));
124+
addDigit(key, rof, row, col, nel, o2::MCCompLabel(true), 0.f); /// TODO: find a better ToA for noise
87125
}
88126
}
89127
}
90128
}
91129

92-
#endif // ALICEO2_TRK_CHIPDIGITSCONTAINER_
130+
#endif /* defined(ALICEO2_TRK_CHIPDIGITSCONTAINER_) */

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/include/TRKFT3Simulation/Digitizer.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Digitizer
4444
{
4545
static_assert(DetID == o2::detectors::DetID::TRK || DetID == o2::detectors::DetID::FT3, "only TRK and FT3 digitizers are supported");
4646
using GeometryTGeo = std::conditional_t<DetID == o2::detectors::DetID::TRK, o2::trk::GeometryTGeo, o2::ft3::GeometryTGeo>;
47-
using ExtraDig = std::vector<itsmft::PreDigitLabelRef>; ///< container for extra contributions to PreDigits
47+
using ExtraDig = std::vector<trkft3::PreDigitLabelRef>; ///< container for extra contributions to PreDigits
4848

4949
public:
5050
void setDigits(std::vector<o2::trkft3::Digit>* dig) { mDigits = dig; }
@@ -94,7 +94,7 @@ class Digitizer
9494

9595
private:
9696
void processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, int evID, int srcID, int rofLayer);
97-
void registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float tInROF, int nROF,
97+
void registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float toaInROF, int nROF,
9898
uint16_t row, uint16_t col, int nEle, o2::MCCompLabel& lbl, int layer);
9999

100100
ExtraDig* getExtraDigBuffer(uint32_t roFrame)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file PreDigit.h
13+
/// \brief Definition of the digit contribution from single hit for TRK/FT3 (based on o2::itsmft::PreDigit, with time of arrival)
14+
#ifndef ALICEO2_TRKFT3_PREDIGIT_H
15+
#define ALICEO2_TRKFT3_PREDIGIT_H
16+
17+
#include "SimulationDataFormat/MCCompLabel.h"
18+
19+
namespace o2::trkft3
20+
{
21+
22+
// PreDigit is a contribution to the digit from a single hit which happen
23+
// to be registered 1st in given chip row/column/roframe
24+
// Eventual extra contributions will be registered as PreDigitExtra, pointed by
25+
// the "next" index
26+
27+
// PreDigitExtra registers additional contributions to the same row/column/roframe
28+
struct PreDigitLabelRef {
29+
o2::MCCompLabel label; ///< hit label
30+
int next = -1; ///< eventual next contribution to the same pixel
31+
PreDigitLabelRef(o2::MCCompLabel lbl = 0, int nxt = -1) : label(lbl), next(nxt) {}
32+
33+
ClassDefNV(PreDigitLabelRef, 1);
34+
};
35+
36+
struct PreDigit {
37+
UShort_t row = 0; ///< Pixel index in X
38+
UShort_t col = 0; ///< Pixel index in Z
39+
UInt_t roFrame = 0; ///< Readout frame
40+
int charge = 0; ///< N electrons
41+
float toa = 0.f; ///< Time of arrival in ns (earliest contribution)
42+
PreDigitLabelRef labelRef; ///< label and reference to the next one
43+
44+
PreDigit(UInt_t rf = 0, UShort_t rw = 0, UShort_t cl = 0, int nele = 0, o2::MCCompLabel lbl = 0, float t = 0.f)
45+
: row(rw), col(cl), roFrame(rf), charge(nele), toa(t), labelRef(lbl) {}
46+
47+
ClassDefNV(PreDigit, 1);
48+
};
49+
50+
} // namespace o2::trkft3
51+
52+
#endif /* ALICEO2_TRKFT3_PREDIGIT_H */

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/src/ChipDigitsContainer.cxx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313

1414
using namespace o2::trkft3;
1515

16-
ChipDigitsContainer::ChipDigitsContainer(UShort_t idx)
17-
: o2::itsmft::ChipDigitsContainer(idx) {}
16+
ChipDigitsContainer::ChipDigitsContainer(UShort_t idx) : mChipIndex(idx) {}

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/src/Digitizer.cxx‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ void Digitizer<DetID>::fillOutputContainer(uint32_t frameLast, int layer)
226226
auto& preDig = iter->second; // preDigit
227227
if (preDig.charge >= mParams.getChargeThreshold()) {
228228
int digID = mDigits->size();
229-
mDigits->emplace_back(chip.getChipIndex(), preDig.row, preDig.col, preDig.charge);
230-
LOG(debug) << "Adding digit ID: " << digID << " with chipID: " << chip.getChipIndex() << ", row: " << preDig.row << ", col: " << preDig.col << ", charge: " << preDig.charge;
229+
mDigits->emplace_back(chip.getChipIndex(), preDig.row, preDig.col, preDig.charge, preDig.toa);
230+
LOG(debug) << "Adding digit ID: " << digID << " with chipID: " << chip.getChipIndex() << ", row: " << preDig.row << ", col: " << preDig.col << ", charge: " << preDig.charge << ", ToA: " << preDig.toa;
231231
mMCLabels->addElement(digID, preDig.labelRef.label);
232232
auto& nextRef = preDig.labelRef; // extra contributors are in extra array
233233
while (nextRef.next >= 0) {
@@ -297,6 +297,9 @@ void Digitizer<DetID>::processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, i
297297
float tTot = mParams.getSignalShape().getMaxDuration();
298298
// frame of the hit signal start wrt event ROFrame
299299
int roFrameRel = int(timeInROF * mParams.getROFrameLengthInv(rofLayer));
300+
// Time of Arrival w.r.t. the start of the ROF where the signal starts (= w.r.t. roFrameAbs)
301+
float toaInROF = timeInROF - roFrameRel * mParams.getROFrameLength(rofLayer);
302+
300303
// frame of the hit signal end wrt event ROFrame: in the triggered mode we read just 1 frame
301304
uint32_t roFrameRelMax = (timeInROF + tTot) * mParams.getROFrameLengthInv(rofLayer);
302305
int nFrames = roFrameRelMax + 1 - roFrameRel;
@@ -493,24 +496,25 @@ void Digitizer<DetID>::processHit(const o2::trkft3::Hit& hit, uint32_t& maxFr, i
493496
if (mDeadChanMap && mDeadChanMap->isNoisy(chipID, rowIS, colIS)) {
494497
continue;
495498
}
496-
registerDigits(chip, roFrameAbs, timeInROF, nFrames, rowIS, colIS, nEle, lbl, rofLayer);
499+
registerDigits(chip, roFrameAbs, toaInROF, nFrames, rowIS, colIS, nEle, lbl, rofLayer);
497500
}
498501
}
499502
}
500503

501504
//________________________________________________________________________________
502505
template <int DetID>
503-
void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float tInROF, int nROF,
506+
void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uint32_t roFrame, float toaInROF, int nROF,
504507
uint16_t row, uint16_t col, int nEle, o2::MCCompLabel& lbl, int layer)
505508
{
506509
// Register digits for given pixel, accounting for the possible signal contribution to
507-
// multiple ROFrame. The signal starts at time tInROF wrt the start of provided roFrame
510+
// multiple ROFrame. The signal starts at time toaInROF wrt the start of provided roFrame
508511
// In every ROFrame we check the collected signal during strobe
509512
LOG(debug) << "Registering digits for chip " << chip.getChipIndex() << " at ROFrame " << roFrame
510-
<< " row " << row << " col " << col << " nEle " << nEle << " label " << lbl;
511-
float tStrobe = mParams.getStrobeDelay(layer) - tInROF; // strobe start wrt signal start
512-
for (int i = 0; i < nROF; i++) { // loop on all the ROFs occupied by the same signal to calculate the charge accumulated in that ROF
513+
<< " row " << row << " col " << col << " nEle " << nEle << " label " << lbl << " layer " << layer << " toa " << toaInROF;
514+
float tStrobe = mParams.getStrobeDelay(layer) - toaInROF; // strobe start wrt signal start
515+
for (int i = 0; i < nROF; i++) { // loop on all the ROFs occupied by the same signal to calculate the charge accumulated in that ROF
513516
uint32_t roFr = roFrame + i;
517+
float toaROF = toaInROF - i * mParams.getROFrameLength(layer); // ToA w.r.t. start of ROF
514518
int nEleROF = mParams.getSignalShape().getCollectedCharge(nEle, tStrobe, tStrobe + mParams.getStrobeLength(layer));
515519
tStrobe += mParams.getROFrameLength(layer); // for the next ROF
516520

@@ -525,14 +529,15 @@ void Digitizer<DetID>::registerDigits(o2::trkft3::ChipDigitsContainer& chip, uin
525529
mEventROFrameMin = roFr;
526530
}
527531
auto key = chip.getOrderingKey(roFr, row, col);
528-
o2::itsmft::PreDigit* pd = chip.findDigit(key);
532+
o2::trkft3::PreDigit* pd = chip.findDigit(key);
529533
if (!pd) {
530-
chip.addDigit(key, roFr, row, col, nEleROF, lbl);
534+
chip.addDigit(key, roFr, row, col, nEleROF, lbl, toaROF);
531535
LOG(debug) << "Added digit with key: " << key << " ROF: " << roFr << " row: " << row << " col: " << col << " charge: " << nEleROF;
532536
} else { // there is already a digit at this slot, account as PreDigitExtra contribution
533537
LOG(debug) << "Added to pre-digit with key: " << key << " ROF: " << roFr << " row: " << row << " col: " << col << " charge: " << nEleROF;
534538
pd->charge += nEleROF;
535-
if (pd->labelRef.label == lbl) { // don't store the same label twice
539+
pd->toa = std::min(pd->toa, toaROF); /// in case of two hits on the same digit in the same ROF, get the first ToA
540+
if (pd->labelRef.label == lbl) { // don't store the same label twice
536541
continue;
537542
}
538543
ExtraDig* extra = getExtraDigBuffer(roFr);

‎Detectors/Upgrades/ALICE3/TRKFT3/common/simulation/src/TRKFT3SimulationLinkDef.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::trkft3::DPLDigitizerParam < o2::detectors::DetID::TRK>> + ;
2424
#pragma link C++ class o2::trkft3::DPLDigitizerParam < o2::detectors::DetID::FT3> + ;
2525
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::trkft3::DPLDigitizerParam < o2::detectors::DetID::FT3>> + ;
26+
#pragma link C++ class o2::trkft3::PreDigit + ;
27+
#pragma link C++ class o2::trkft3::PreDigitLabelRef + ;
2628

2729
#endif

0 commit comments

Comments
 (0)