Skip to content

Commit 0fe6814

Browse files
committed
Fix TOF digit fields to allow multiple TF processing
Since the TOF digit stores as BC the absolute bunch count from orbit 0, with int32 it will overflow after ~100 s. Change it uint64_t. Also fix the orbit/bc to uint32_t / uint16_t resp.
1 parent 8e764d1 commit 0fe6814

10 files changed

Lines changed: 57 additions & 58 deletions

File tree

Detectors/TOF/base/include/TOFBase/Digit.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class Digit
3030
public:
3131
Digit() = default;
3232

33-
Digit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t label = -1, Int_t triggerorbit = 0, Int_t triggerbunch = 0);
33+
Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = -1, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0);
3434
~Digit() = default;
3535

3636
/// Get global ordering key made of
37-
static ULong64_t getOrderingKey(Int_t channel, Int_t bc, Int_t /*tdc*/)
37+
static ULong64_t getOrderingKey(Int_t channel, uint64_t bc, Int_t /*tdc*/)
3838
{
3939
return ((static_cast<ULong64_t>(bc) << 18) + channel); // channel in the least significant bits; then shift by 18 bits (which cover the total number of channels) to write the BC number
4040
}
@@ -48,8 +48,8 @@ class Digit
4848
uint16_t getTOT() const { return mTOT; }
4949
void setTOT(uint16_t tot) { mTOT = tot; }
5050

51-
Int_t getBC() const { return mBC; }
52-
void setBC(Int_t bc) { mBC = bc; }
51+
uint64_t getBC() const { return mBC; }
52+
void setBC(uint64_t bc) { mBC = bc; }
5353

5454
Int_t getLabel() const { return mLabel; }
5555
void setLabel(Int_t label) { mLabel = label; }
@@ -78,10 +78,10 @@ class Digit
7878
void setIsProblematic(bool flag) { mIsProblematic = flag; }
7979
bool isProblematic() const { return mIsProblematic; }
8080

81-
void setTriggerOrbit(int value) { mTriggerOrbit = value; }
82-
int getTriggerOrbit() const { return mTriggerOrbit; }
83-
void setTriggerBunch(int value) { mTriggerBunch = value; }
84-
int getTriggerBunch() const { return mTriggerBunch; }
81+
void setTriggerOrbit(uint32_t value) { mTriggerOrbit = value; }
82+
uint32_t getTriggerOrbit() const { return mTriggerOrbit; }
83+
void setTriggerBunch(uint16_t value) { mTriggerBunch = value; }
84+
uint16_t getTriggerBunch() const { return mTriggerBunch; }
8585

8686
private:
8787
friend class boost::serialization::access;
@@ -90,15 +90,15 @@ class Digit
9090
Int_t mChannel; ///< TOF channel index
9191
uint16_t mTDC; ///< TDC bin number
9292
uint16_t mTOT; ///< TOT bin number
93-
Int_t mBC; ///< Bunch Crossing
93+
uint64_t mBC; ///< Bunch Crossing // RS: since it is used as absolute bunch counter from orbit 0, it has to be 64 bits
9494
Int_t mLabel; ///< Index of the corresponding entry in the MC label array
9595
Int_t mElectronIndex; //!/< index in electronic format
96-
uint16_t mTriggerOrbit = 0; //!< orbit id of trigger event
96+
uint32_t mTriggerOrbit = 0; //!< orbit id of trigger event // RS: orbit must be 32bits long
9797
uint16_t mTriggerBunch = 0; //!< bunch id of trigger event
9898
Bool_t mIsUsedInCluster; //!/< flag to declare that the digit was used to build a cluster
9999
Bool_t mIsProblematic = false; //!< flag to tell whether the channel of the digit was problemati; not persistent; default = ok
100100

101-
ClassDefNV(Digit, 2);
101+
ClassDefNV(Digit, 3);
102102
};
103103

104104
std::ostream& operator<<(std::ostream& stream, const Digit& dig);

Detectors/TOF/base/include/TOFBase/Strip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Strip
7979
/// reset points container
8080
o2::tof::Digit* findDigit(ULong64_t key);
8181

82-
Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t lbl = 0, int triggerorbit = 0, int triggerbunch = 0); // returns the MC label
82+
Int_t addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl = 0, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0); // returns the MC label
8383

8484
void fillOutputContainer(std::vector<o2::tof::Digit>& digits);
8585

Detectors/TOF/base/include/TOFBase/WindowFiller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ class WindowFiller
7878
// arrays with digit and MCLabels out of the current readout windows (stored to fill future readout window)
7979
std::vector<Digit> mFutureDigits;
8080

81-
void fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t triggerorbit = 0, Int_t triggerbunch = 0);
81+
void fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0);
8282
// void fillDigitsInStrip(std::vector<Strip>* strips, o2::dataformats::MCTruthContainer<o2::tof::MCLabel>* mcTruthContainer, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t trackID, Int_t eventID, Int_t sourceID);
8383

8484
void checkIfReuseFutureDigits();
8585
void checkIfReuseFutureDigitsRO();
8686

87-
void insertDigitInFuture(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t label = 0, Int_t triggerorbit = 0, Int_t triggerbunch = 0)
87+
void insertDigitInFuture(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label = 0, uint32_t triggerorbit = 0, uint16_t triggerbunch = 0)
8888
{
8989
mFutureDigits.emplace_back(channel, tdc, tot, bc, label, triggerorbit, triggerbunch);
9090
mFutureToBeSorted = true;

Detectors/TOF/base/src/Digit.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace o2::tof;
1616

1717
ClassImp(o2::tof::Digit);
1818

19-
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t label, Int_t triggerorbit, Int_t triggerbunch)
19+
Digit::Digit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t label, uint32_t triggerorbit, uint16_t triggerbunch)
2020
: mChannel(channel), mTDC(tdc), mTOT(tot), mBC(bc), mLabel(label), mTriggerOrbit(triggerorbit), mTriggerBunch(triggerbunch), mIsUsedInCluster(kFALSE)
2121
{
2222
}

Detectors/TOF/base/src/Strip.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Strip::Strip(Int_t index)
3333
{
3434
}
3535
//_______________________________________________________________________
36-
Int_t Strip::addDigit(Int_t channel, Int_t tdc, Int_t tot, Int_t bc, Int_t lbl, Int_t triggerorbit, Int_t triggerbunch)
36+
Int_t Strip::addDigit(Int_t channel, Int_t tdc, Int_t tot, uint64_t bc, Int_t lbl, uint32_t triggerorbit, uint16_t triggerbunch)
3737
{
3838

3939
// return the MC label. We pass it also as argument, but it can change in

Detectors/TOF/base/src/WindowFiller.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void WindowFiller::reset()
100100
mFirstBunch = 0;
101101
}
102102
//______________________________________________________________________
103-
void WindowFiller::fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, int nbc, UInt_t istrip, Int_t triggerorbit, Int_t triggerbunch)
103+
void WindowFiller::fillDigitsInStrip(std::vector<Strip>* strips, int channel, int tdc, int tot, uint64_t nbc, UInt_t istrip, uint32_t triggerorbit, uint16_t triggerbunch)
104104
{
105105
(*strips)[istrip].addDigit(channel, tdc, tot, nbc, 0, triggerorbit, triggerbunch);
106106
}

Detectors/TOF/reconstruction/include/TOFReconstruction/Decoder.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Decoder : public WindowFiller
4444
bool open(std::string name);
4545

4646
bool decode();
47-
void readTRM(int icru, int icrate, int orbit, int bunchid);
48-
void InsertDigit(int icrate, int itrm, int itdc, int ichain, int channel, int orbit, int bunchid, int time_ext, int tdc, int tot);
47+
void readTRM(int icru, int icrate, uint32_t orbit, uint16_t bunchid);
48+
void InsertDigit(int icrate, int itrm, int itdc, int ichain, int channel, uint32_t orbit, uint16_t bunchid, int time_ext, int tdc, int tot);
4949
void FillWindows();
5050
void clear();
5151

@@ -58,7 +58,16 @@ class Decoder : public WindowFiller
5858
void printCrateTrailerInfo(int icru) const;
5959
void printHitInfo(int icru) const;
6060

61-
static void fromRawHit2Digit(int icrate, int itrm, int itdc, int ichain, int channel, int orbit, int bunchid, int tdc, int tot, std::array<int, 6>& digitInfo); // convert raw info in digit info (channel, tdc, tot, bc), tdc = packetHit.time + (frameHeader.frameID << 13)
61+
struct DigitInfo {
62+
uint64_t bcAbs;
63+
int channel;
64+
int tdc;
65+
int tot;
66+
uint32_t orbit;
67+
uint16_t bc;
68+
};
69+
70+
static void fromRawHit2Digit(int icrate, int itrm, int itdc, int ichain, int channel, uint32_t orbit, uint16_t bunchid, int tdc, int tot, DigitInfo& dinfo); // convert raw info in digit info (channel, tdc, tot, bc), tdc = packetHit.time + (frameHeader.frameID << 13)
6271

6372
char* nextPage(void* current, int shift = 8192);
6473

Detectors/TOF/reconstruction/src/Decoder.cxx

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -112,41 +112,41 @@ void Decoder::clear()
112112
reset();
113113
}
114114

115-
void Decoder::InsertDigit(int icrate, int itrm, int itdc, int ichain, int channel, int orbit, int bunchid, int time_ext, int tdc, int tot)
115+
void Decoder::InsertDigit(int icrate, int itrm, int itdc, int ichain, int channel, uint32_t orbit, uint16_t bunchid, int time_ext, int tdc, int tot)
116116
{
117-
std::array<int, 6> digitInfo;
117+
DigitInfo digitInfo;
118118

119119
fromRawHit2Digit(icrate, itrm, itdc, ichain, channel, orbit, bunchid, time_ext + tdc, tot, digitInfo);
120120

121121
mHitDecoded++;
122122

123-
int isnext = digitInfo[3] * Geo::BC_IN_WINDOW_INV;
123+
uint64_t isnext = digitInfo.bcAbs * Geo::BC_IN_WINDOW_INV;
124124

125-
if (isnext >= MAXWINDOWS) { // accumulate all digits which are not in the first windows
126-
127-
insertDigitInFuture(digitInfo[0], digitInfo[1], digitInfo[2], digitInfo[3], 0, digitInfo[4], digitInfo[5]);
125+
if (isnext >= uint64_t(MAXWINDOWS)) { // accumulate all digits which are not in the first windows
126+
insertDigitInFuture(digitInfo.channel, digitInfo.tdc, digitInfo.tot, digitInfo.bcAbs, 0, digitInfo.orbit, digitInfo.bc);
128127
} else {
129128
std::vector<Strip>* cstrip = mStripsCurrent; // first window
130-
if (isnext)
129+
if (isnext) {
131130
cstrip = mStripsNext[isnext - 1]; // next window
132-
133-
UInt_t istrip = digitInfo[0] / Geo::NPADS;
131+
}
132+
UInt_t istrip = digitInfo.channel / Geo::NPADS;
134133

135134
// add digit
136-
fillDigitsInStrip(cstrip, digitInfo[0], digitInfo[1], digitInfo[2], digitInfo[3], istrip);
135+
fillDigitsInStrip(cstrip, digitInfo.channel, digitInfo.tdc, digitInfo.tot, digitInfo.bcAbs, istrip);
137136
}
138137
}
139138

140-
void Decoder::readTRM(int icru, int icrate, int orbit, int bunchid)
139+
void Decoder::readTRM(int icru, int icrate, uint32_t orbit, uint16_t bunchid)
141140
{
142141

143142
if (orbit < mFirstOrbit || (orbit == mFirstOrbit && bunchid < mFirstBunch)) {
144143
mFirstOrbit = orbit;
145144
mFirstBunch = bunchid;
146145
}
147146

148-
if (mVerbose)
147+
if (mVerbose) {
149148
printTRMInfo(icru);
149+
}
150150
int nhits = mUnion[icru]->frameHeader.numberOfHits;
151151
int time_ext = mUnion[icru]->frameHeader.frameID << 13;
152152
int itrm = mUnion[icru]->frameHeader.trmID;
@@ -157,59 +157,49 @@ void Decoder::readTRM(int icru, int icrate, int orbit, int bunchid)
157157
mUnion[icru]++;
158158
mIntegratedBytes[icru] += 4;
159159

160-
// read hits
161-
Int_t channel, echannel;
162-
Int_t tdc;
163-
Int_t tot;
164-
Int_t bc;
165-
Int_t time;
166-
167-
std::array<int, 6> digitInfo;
160+
DigitInfo digitInfo;
168161

169162
for (int i = 0; i < nhits; i++) {
170-
fromRawHit2Digit(icrate, itrm, mUnion[icru]->packedHit.tdcID, mUnion[icru]->packedHit.chain, mUnion[icru]->packedHit.channel, orbit, bunchid, time_ext + mUnion[icru]->packedHit.time, mUnion[icru]->packedHit.tot, digitInfo);
163+
fromRawHit2Digit(icrate, itrm, mUnion[icru]->packedHit.tdcID, mUnion[icru]->packedHit.chain, mUnion[icru]->packedHit.channel, orbit, bunchid,
164+
time_ext + mUnion[icru]->packedHit.time, mUnion[icru]->packedHit.tot, digitInfo);
171165

172166
mHitDecoded++;
173167

174168
if (mVerbose)
175169
printHitInfo(icru);
176170

177-
int isnext = digitInfo[3] * Geo::BC_IN_WINDOW_INV;
171+
uint64_t isnext = digitInfo.bcAbs * Geo::BC_IN_WINDOW_INV;
178172

179173
if (isnext >= MAXWINDOWS) { // accumulate all digits which are not in the first windows
180174

181-
insertDigitInFuture(digitInfo[0], digitInfo[1], digitInfo[2], digitInfo[3], 0, digitInfo[4], digitInfo[5]);
175+
insertDigitInFuture(digitInfo.channel, digitInfo.tdc, digitInfo.tot, digitInfo.bcAbs, 0, digitInfo.orbit, digitInfo.bc);
182176
} else {
183177
std::vector<Strip>* cstrip = mStripsCurrent; // first window
184178
if (isnext)
185179
cstrip = mStripsNext[isnext - 1]; // next window
186180

187-
UInt_t istrip = digitInfo[0] / Geo::NPADS;
181+
UInt_t istrip = digitInfo.channel / Geo::NPADS;
188182

189183
// add digit
190-
fillDigitsInStrip(cstrip, digitInfo[0], digitInfo[1], digitInfo[2], digitInfo[3], istrip);
184+
fillDigitsInStrip(cstrip, digitInfo.channel, digitInfo.tdc, digitInfo.tot, digitInfo.bcAbs, istrip);
191185
}
192186

193187
mUnion[icru]++;
194188
mIntegratedBytes[icru] += 4;
195189
}
196190
}
197191

198-
void Decoder::fromRawHit2Digit(int icrate, int itrm, int itdc, int ichain, int channel, int orbit, int bunchid, int tdc, int tot, std::array<int, 6>& digitInfo)
192+
void Decoder::fromRawHit2Digit(int icrate, int itrm, int itdc, int ichain, int channel, uint32_t orbit, uint16_t bunchid, int tdc, int tot, Decoder::DigitInfo& dinfo)
199193
{
200194
// convert raw info in digit info (channel, tdc, tot, bc)
201195
// tdc = packetHit.time + (frameHeader.frameID << 13)
202196
int echannel = Geo::getECHFromIndexes(icrate, itrm, ichain, itdc, channel);
203-
digitInfo[0] = Geo::getCHFromECH(echannel);
204-
digitInfo[2] = tot;
205-
206-
digitInfo[3] = int(orbit * o2::tof::Geo::BC_IN_ORBIT);
207-
digitInfo[3] += bunchid;
208-
digitInfo[3] += tdc / 1024;
209-
digitInfo[1] = tdc % 1024;
210-
211-
digitInfo[4] = orbit;
212-
digitInfo[5] = bunchid;
197+
dinfo.channel = Geo::getCHFromECH(echannel);
198+
dinfo.tot = tot;
199+
dinfo.bcAbs = uint64_t(orbit) * o2::tof::Geo::BC_IN_ORBIT + bunchid + tdc / 1024;
200+
dinfo.tdc = tdc % 1024;
201+
dinfo.orbit = orbit;
202+
dinfo.bc = bunchid;
213203
}
214204

215205
char* Decoder::nextPage(void* current, int shift)

Detectors/TOF/reconstruction/src/Encoder.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void Encoder::encodeTRM(const std::vector<Digit>& summary, Int_t icrate, Int_t i
179179

180180
if (hittimeTDC < 0) {
181181
LOG(ERROR) << "Negative hit encoded " << hittimeTDC << ", something went wrong in filling readout window";
182-
printf("%d %d %d\n", summary[istart].getBC(), mEventCounter * Geo::BC_IN_WINDOW, summary[istart].getTDC());
182+
printf("%llu %d %d\n", (unsigned long long)summary[istart].getBC(), mEventCounter * Geo::BC_IN_WINDOW, summary[istart].getTDC());
183183
}
184184
// leading time
185185
mUnion[icrate]->trmDataHit.time = hittimeTDC;

Detectors/TOF/workflow/include/TOFWorkflow/CompressedDecodingTask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class CompressedDecodingTask : public DecoderBase, public Task
5555
int mNCrateOpenTF = 0;
5656
int mNCrateCloseTF = 0;
5757
bool mHasToBePosted = false;
58-
int mInitOrbit = 0;
58+
uint32_t mInitOrbit = 0;
5959
TStopwatch mTimer;
6060
};
6161

0 commit comments

Comments
 (0)