Skip to content

Commit d15f4bd

Browse files
committed
ITS: staggered STF decoder
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 03d5582 commit d15f4bd

File tree

11 files changed

+317
-172
lines changed

11 files changed

+317
-172
lines changed

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/ChipMappingITS.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ class ChipMappingITS
310310

311311
std::vector<Overlaps> getOverlapsInfo() const;
312312

313+
///< Collect all FEEIDs for one layer (lr>=0) or all (lr==-1)
314+
std::vector<uint16_t> getLayer2FEEIDs(int lr);
315+
313316
// sub-barrel types, their number, N layers, Max N GBT Links per RU
314317
static constexpr int IB = 0, MB = 1, OB = 2, NSubB = 3, NLayers = 7, NLinks = 3;
315318

@@ -395,7 +398,7 @@ class ChipMappingITS
395398
std::vector<uint8_t> mCablePos[NSubB]; ///< table of cables positions in the ActiveLanes mask for each RU type (sequential numbering)
396399
std::vector<uint8_t> mCableHWFirstChip[NSubB]; ///< 1st chip of module (relative to the 1st chip of the stave) served by each cable
397400

398-
std::array<int, NSubB> mCablesOnStaveSB = {0}; ///< pattern of cables per stave of sub-barrel
401+
std::array<int, NSubB> mCablesOnStaveSB = {0}; ///< pattern of cables per stave of sub-barrel
399402
std::array<std::array<uint8_t, 15>, MaxHWCableID[MB] + 1> HWCableHWChip2ChipOnRU_MB; // mapping from HW cable ID / HW chip ID to Chip on RU, 255 means NA
400403
std::array<std::array<uint8_t, 15>, MaxHWCableID[OB] + 1> HWCableHWChip2ChipOnRU_OB; // mapping from HW cable ID / HW chip ID to Chip on RU, 255 means NA
401404

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/ChipMappingMFT.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ class ChipMappingMFT
266266

267267
const auto& getModuleMappingData() const { return ModuleMappingData; }
268268

269+
///< Collect all FEEIDs for one layer (lr>=0) or all (lr==-1)
270+
std::vector<uint16_t> getLayer2FEEIDs(int lr);
271+
269272
void print() const;
270273

271274
///< LayerID of each MFT chip

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelReader.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ class PixelReader
5050
{
5151
return nullptr;
5252
}
53-
const o2::InteractionRecord& getInteractionRecordHB() const
54-
{
55-
return mInteractionRecordHB;
56-
}
57-
5853
const o2::InteractionRecord& getInteractionRecord() const
5954
{
6055
return mInteractionRecord;
@@ -70,8 +65,7 @@ class PixelReader
7065
//
7166
protected:
7267
//
73-
o2::InteractionRecord mInteractionRecord = {}; // interation record for the trigger
74-
o2::InteractionRecord mInteractionRecordHB = {}; // interation record for the HB
68+
o2::InteractionRecord mInteractionRecord = {}; // interation record for the trigger
7569
uint32_t mTrigger = 0;
7670
bool mDecodeNextAuto = true; // try to fetch/decode next trigger when getNextChipData does not see any decoded data
7771

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/RawPixelDecoder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <array>
1818
#include <TStopwatch.h>
1919
#include "Framework/Logger.h"
20+
#include "Framework/InputSpec.h"
2021
#include "ITSMFTReconstruction/ChipMappingITS.h"
2122
#include "ITSMFTReconstruction/ChipMappingMFT.h"
2223
#include "DetectorsRaw/HBFUtils.h"
@@ -56,7 +57,7 @@ class RawPixelDecoder final : public PixelReader
5657
bool getNextChipData(ChipPixelData& chipData) final;
5758
ChipPixelData* getNextChipData(std::vector<ChipPixelData>& chipDataVec) final;
5859
void ensureChipOrdering() {}
59-
void startNewTF(o2::framework::InputRecord& inputs);
60+
void startNewTF(o2::framework::InputRecord& inputs, const std::vector<o2::framework::InputSpec>& filter);
6061
void collectROFCableData(int iru);
6162
int decodeNextTrigger() final;
6263

@@ -138,7 +139,7 @@ class RawPixelDecoder final : public PixelReader
138139
void reset();
139140

140141
private:
141-
void setupLinks(o2::framework::InputRecord& inputs);
142+
void setupLinks(o2::framework::InputRecord& inputsm, const std::vector<o2::framework::InputSpec>& filter);
142143
int getRUEntrySW(int ruSW) const { return mRUEntry[ruSW]; }
143144
RUDecodeData* getRUDecode(int ruSW) { return &mRUDecodeVec[mRUEntry[ruSW]]; }
144145
GBTLink* getGBTLink(int i) { return i < 0 ? nullptr : &mGBTLinks[i]; }

Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/RawPixelReader.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ namespace o2
5353
namespace itsmft
5454
{
5555

56-
constexpr int MaxGBTPacketBytes = 8 * 1024; // Max size of GBT packet in bytes (8KB)
57-
constexpr int NCRUPagesPerSuperpage = 256; // Expected max number of CRU pages per superpage
56+
constexpr int MaxGBTPacketBytes = 8 * 1024; // Max size of GBT packet in bytes (8KB)
57+
constexpr int NCRUPagesPerSuperpage = 256; // Expected max number of CRU pages per superpage
5858
using RDHUtils = o2::raw::RDHUtils;
5959

6060
struct RawDecodingStat {
@@ -633,7 +633,6 @@ class RawPixelReader : public PixelReader
633633
const auto rdh = reinterpret_cast<const o2::header::RAWDataHeader*>(link->data.getPtr());
634634
mInteractionRecord = RDHUtils::getTriggerIR(rdh);
635635
mTrigger = RDHUtils::getTriggerType(rdh);
636-
mInteractionRecordHB = RDHUtils::getHeartBeatIR(rdh);
637636
break;
638637
}
639638
}
@@ -674,7 +673,7 @@ class RawPixelReader : public PixelReader
674673
}
675674
}
676675
if (ruDecData.ruInfo->nCables) { // there are cables with data to decode
677-
decodeAlpideData(ruDecData); // decode Alpide data from the compressed RU Data
676+
decodeAlpideData(ruDecData); // decode Alpide data from the compressed RU Data
678677
}
679678
return res;
680679
}

Detectors/ITSMFT/common/reconstruction/src/ChipMappingITS.cxx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ ChipMappingITS::ChipMappingITS()
7878
cInfo.moduleSW = 0;
7979
cInfo.chipOnModuleSW = i;
8080
cInfo.chipOnModuleHW = i;
81-
cInfo.cableHW = i; //1-to-1 mapping
82-
cInfo.cableHWPos = i; //1-to-1 mapping
83-
cInfo.cableSW = i; //1-to-1 mapping
84-
cInfo.chipOnCable = 0; // every chip is master
81+
cInfo.cableHW = i; // 1-to-1 mapping
82+
cInfo.cableHWPos = i; // 1-to-1 mapping
83+
cInfo.cableSW = i; // 1-to-1 mapping
84+
cInfo.chipOnCable = 0; // every chip is master
8585
mCableHW2SW[IB][cInfo.cableHW] = cInfo.cableSW;
8686
mCableHW2Pos[IB][cInfo.cableHW] = cInfo.cableHWPos;
8787
mCablesOnStaveSB[IB] |= 0x1 << cInfo.cableHWPos; // account in lanes pattern
88-
mCableHWFirstChip[IB][i] = 0; // stave and module are the same
88+
mCableHWFirstChip[IB][i] = 0; // stave and module are the same
8989
}
9090

9191
// [i][j] gives lane id for lowest(i=0) and highest(i=1) 7 chips of HW module (j+1) (1-4 for ML, 1-7 for OL)
@@ -289,3 +289,17 @@ std::vector<ChipMappingITS::Overlaps> ChipMappingITS::getOverlapsInfo() const
289289
}
290290
return v;
291291
}
292+
293+
//_____________________________________________________________________________
294+
std::vector<uint16_t> ChipMappingITS::getLayer2FEEIDs(int lr)
295+
{
296+
std::vector<uint16_t> feeIDs;
297+
for (int ilr = (lr >= 0 ? lr : 0); ilr < (lr >= 0 ? lr + 1 : NLayers); ++ilr) {
298+
for (int ist = 0; ist < NStavesOnLr[ilr]; ++ist) {
299+
for (int lnk = 0; lnk < NLinks; ++lnk) {
300+
feeIDs.push_back(composeFEEId(ilr, ist, lnk));
301+
}
302+
}
303+
}
304+
return feeIDs;
305+
}

Detectors/ITSMFT/common/reconstruction/src/ChipMappingMFT.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,3 +1753,17 @@ void ChipMappingMFT::print() const
17531753
ChipMappingData[iChip].chipOnRU);
17541754
}
17551755
}
1756+
1757+
//_____________________________________________________________________________
1758+
std::vector<uint16_t> ChipMappingMFT::getLayer2FEEIDs(int lr)
1759+
{
1760+
std::vector<uint16_t> feeIDs;
1761+
for (int ilr = (lr >= 0 ? lr : 0); ilr < (lr >= 0 ? lr + 1 : NLayers); ++ilr) {
1762+
for (int iz = 0; iz < NZonesPerLayer; ++iz) {
1763+
for (int lnk = 0; lnk < NLinks; ++lnk) {
1764+
feeIDs.push_back(composeFEEId(ilr, iz, lnk));
1765+
}
1766+
}
1767+
}
1768+
return feeIDs;
1769+
}

Detectors/ITSMFT/common/reconstruction/src/GBTLink.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ GBTLink::GBTLink(uint16_t _cru, uint16_t _fee, uint8_t _ep, uint8_t _idInCru, ui
4141
/// create string describing the link
4242
std::string GBTLink::describe() const
4343
{
44-
std::string ss = fmt::format("link cruID:{:#06x}/lID{} feeID:{:#06x}", cruID, int(idInCRU), feeID);
44+
std::string ss = fmt::format("link cruID:{:#06x}/lID{:02} feeID:{:#06x}", cruID, int(idInCRU), feeID);
4545
if (lanes) {
4646
ss += fmt::format(" lanes {}", std::bitset<28>(lanes).to_string());
4747
}

Detectors/ITSMFT/common/reconstruction/src/RawPixelDecoder.cxx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int RawPixelDecoder<Mapping>::decodeNextTrigger()
136136
///______________________________________________________________
137137
/// prepare for new TF
138138
template <class Mapping>
139-
void RawPixelDecoder<Mapping>::startNewTF(InputRecord& inputs)
139+
void RawPixelDecoder<Mapping>::startNewTF(InputRecord& inputs, const std::vector<InputSpec>& filter)
140140
{
141141
mTimerTFStart.Start(false);
142142
for (auto& link : mGBTLinks) {
@@ -149,7 +149,7 @@ void RawPixelDecoder<Mapping>::startNewTF(InputRecord& inputs)
149149
ru.linkHBFToDump.clear();
150150
ru.nLinksDone = 0;
151151
}
152-
setupLinks(inputs);
152+
setupLinks(inputs, filter);
153153
mNLinksDone = 0;
154154
mExtTriggers.clear();
155155
mTimerTFStart.Stop();
@@ -186,6 +186,9 @@ bool RawPixelDecoder<Mapping>::doIRMajorityPoll()
186186
if (link.statusInTF == GBTLink::DataSeen) {
187187
if (link.status == GBTLink::DataSeen || link.status == GBTLink::CachedDataExist) {
188188
mIRPoll[link.ir]++;
189+
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
190+
LOGP(info, "doIRMajorityPoll: {} contributes to poll {}", link.describe(), link.ir.asString());
191+
}
189192
} else if (link.status == GBTLink::StoppedOnEndOfData || link.status == GBTLink::AbortedOnError) {
190193
link.statusInTF = GBTLink::StoppedOnEndOfData;
191194
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
@@ -195,31 +198,35 @@ bool RawPixelDecoder<Mapping>::doIRMajorityPoll()
195198
}
196199
}
197200
}
201+
if (mNLinksDone == mNLinksInTF) {
202+
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
203+
LOGP(info, "doIRMajorityPoll: All {} links registered in TF are done", mNLinksInTF);
204+
}
205+
return false;
206+
}
198207
int majIR = -1;
199208
for (const auto& entIR : mIRPoll) {
200209
if (entIR.second > majIR) {
201210
majIR = entIR.second;
202211
mInteractionRecord = entIR.first;
203212
}
204213
}
205-
mInteractionRecordHB = mInteractionRecord;
206214
if (mInteractionRecord.isDummy()) {
207215
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
208216
LOG(info) << "doIRMajorityPoll: did not find any valid IR";
209217
}
210218
return false;
211219
}
212-
mInteractionRecordHB.bc = 0;
213220
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
214-
LOG(info) << "doIRMajorityPoll: " << mInteractionRecordHB.asString() << " majority = " << majIR << " for " << mNLinksInTF << " links seen, LinksDone = " << mNLinksDone;
221+
LOG(info) << "doIRMajorityPoll: " << mInteractionRecord.asString() << " majority = " << majIR << " for " << mNLinksInTF << " links seen, LinksDone = " << mNLinksDone;
215222
}
216223
return true;
217224
}
218225

219226
///______________________________________________________________
220227
/// Setup links checking the very RDH of every input
221228
template <class Mapping>
222-
void RawPixelDecoder<Mapping>::setupLinks(InputRecord& inputs)
229+
void RawPixelDecoder<Mapping>::setupLinks(InputRecord& inputs, const std::vector<InputSpec>& filter)
223230
{
224231
constexpr uint32_t ROF_RAMP_FLAG = 0x1 << 4;
225232
constexpr uint32_t LINK_RECOVERY_FLAG = 0x1 << 5;
@@ -228,7 +235,6 @@ void RawPixelDecoder<Mapping>::setupLinks(InputRecord& inputs)
228235
auto nLinks = mGBTLinks.size();
229236
auto origin = (mUserDataOrigin == o2::header::gDataOriginInvalid) ? mMAP.getOrigin() : mUserDataOrigin;
230237
auto datadesc = (mUserDataDescription == o2::header::gDataDescriptionInvalid) ? o2::header::gDataDescriptionRawData : mUserDataDescription;
231-
std::vector<InputSpec> filter{InputSpec{"filter", ConcreteDataTypeMatcher{origin, datadesc}}};
232238

233239
// if we see requested data type input with 0xDEADBEEF subspec and 0 payload this means that the "delayed message"
234240
// mechanism created it in absence of real data from upstream. Processor should send empty output to not block the workflow
@@ -258,21 +264,24 @@ void RawPixelDecoder<Mapping>::setupLinks(InputRecord& inputs)
258264

259265
uint32_t currSSpec = 0xffffffff; // dummy starting subspec
260266
int linksAdded = 0;
267+
uint16_t lr, dummy; // extraxted info from FEEId
261268
for (auto it = parser.begin(); it != parser.end(); ++it) {
262269
auto const* dh = it.o2DataHeader();
263270
auto& lnkref = mSubsSpec2LinkID[dh->subSpecification];
264271
const auto& rdh = *reinterpret_cast<const header::RDHAny*>(it.raw()); // RSTODO this is a hack in absence of generic header getter
272+
const auto feeID = RDHUtils::getFEEID(rdh);
273+
mMAP.expandFEEId(feeID, lr, dummy, dummy);
265274

266275
if (lnkref.entry == -1) { // new link needs to be added
267276
lnkref.entry = int(mGBTLinks.size());
268-
auto& lnk = mGBTLinks.emplace_back(RDHUtils::getCRUID(rdh), RDHUtils::getFEEID(rdh), RDHUtils::getEndPointID(rdh), RDHUtils::getLinkID(rdh), lnkref.entry);
277+
auto& lnk = mGBTLinks.emplace_back(RDHUtils::getCRUID(rdh), feeID, RDHUtils::getEndPointID(rdh), RDHUtils::getLinkID(rdh), lnkref.entry);
269278
lnk.subSpec = dh->subSpecification;
270279
lnk.wordLength = (lnk.expectPadding = (RDHUtils::getDataFormat(rdh) == 0)) ? o2::itsmft::GBTPaddedWordLength : o2::itsmft::GBTWordLength;
271-
getCreateRUDecode(mMAP.FEEId2RUSW(RDHUtils::getFEEID(rdh))); // make sure there is a RU for this link
280+
getCreateRUDecode(mMAP.FEEId2RUSW(feeID)); // make sure there is a RU for this link
272281
lnk.verbosity = GBTLink::Verbosity(mVerbosity);
273282
lnk.alwaysParseTrigger = mAlwaysParseTrigger;
274283
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
275-
LOG(info) << mSelfName << " registered new link " << lnk.describe() << " RUSW=" << int(mMAP.FEEId2RUSW(lnk.feeID));
284+
LOG(info) << mSelfName << " registered new " << lnk.describe() << " RUSW=" << int(mMAP.FEEId2RUSW(lnk.feeID));
276285
}
277286
linksAdded++;
278287
}
@@ -330,7 +339,7 @@ void RawPixelDecoder<Mapping>::setupLinks(InputRecord& inputs)
330339
mMAP.expandFEEId(link.feeID, lr, ruOnLr, linkInRU);
331340
if (newLinkAdded) {
332341
if (mVerbosity >= GBTLink::Verbosity::VerboseHeaders) {
333-
LOG(info) << mSelfName << " Attaching " << link.describe() << " to RU#" << int(mMAP.FEEId2RUSW(link.feeID)) << " (stave " << ruOnLr << " of layer " << lr << ')';
342+
LOGP(info, "{} Attaching {} to RU#{:02} (stave {:02} of layer {})", mSelfName, link.describe(), int(mMAP.FEEId2RUSW(link.feeID)), ruOnLr, lr);
334343
}
335344
}
336345
link.idInRU = linkInRU;

Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/STFDecoderSpec.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
#ifndef O2_ITSMFT_STFDECODER_
1717
#define O2_ITSMFT_STFDECODER_
1818

19+
#include <memory>
20+
#include <string>
21+
#include <array>
1922
#include <TStopwatch.h>
2023
#include "Framework/DataProcessorSpec.h"
2124
#include "Framework/Task.h"
22-
#include <memory>
23-
#include <string>
24-
#include <string_view>
25+
#include "ITSMFTBase/DPLAlpideParam.h"
26+
#include "DataFormatsITSMFT/ROFRecord.h"
2527
#include "ITSMFTReconstruction/ChipMappingITS.h"
2628
#include "ITSMFTReconstruction/ChipMappingMFT.h"
2729
#include "ITSMFTReconstruction/RawPixelDecoder.h"
@@ -55,6 +57,9 @@ struct STFDecoderInp {
5557
template <class Mapping>
5658
class STFDecoder : public Task
5759
{
60+
using AlpideParam = DPLAlpideParam<Mapping::getDetID()>;
61+
static constexpr int NLayers{AlpideParam::supportsStaggering() ? AlpideParam::getNLayers() : 1};
62+
5863
public:
5964
STFDecoder(const STFDecoderInp& inp, std::shared_ptr<o2::base::GRPGeomRequest> gr);
6065
STFDecoder() = default;
@@ -70,6 +75,8 @@ class STFDecoder : public Task
7075
void finalize();
7176
void reset();
7277
std::unique_ptr<o2::itsmft::Clusterer> setupClusterer(const std::string& dictName);
78+
void ensureContinuousROF(const std::vector<ROFRecord>& in, std::vector<ROFRecord>& out, int lr, int nROFsTF, const char* name);
79+
7380
TStopwatch mTimer;
7481
bool mDoClusters = false;
7582
bool mDoPatterns = false;
@@ -87,18 +94,20 @@ class STFDecoder : public Task
8794
int mVerbosity = 0;
8895
long mROFErrRepIntervalMS = 0;
8996
size_t mTFCounter = 0;
90-
size_t mEstNDig = 0;
91-
size_t mEstNClus = 0;
92-
size_t mEstNClusPatt = 0;
93-
size_t mEstNCalib = 0;
94-
size_t mEstNROF = 0;
97+
uint32_t mFirstTFOrbit = 0;
98+
o2::InteractionRecord mFirstIR;
99+
std::array<size_t, NLayers> mEstNDig{0};
100+
std::array<size_t, NLayers> mEstNClus{0};
101+
std::array<size_t, NLayers> mEstNClusPatt{0};
102+
std::array<size_t, NLayers> mEstNCalib{0};
95103
size_t mMaxRawDumpsSize = 0;
96104
size_t mRawDumpedSize = 0;
97105
std::string mInputSpec;
98106
std::string mSelfName;
99-
std::unique_ptr<RawPixelDecoder<Mapping>> mDecoder;
107+
std::array<std::unique_ptr<RawPixelDecoder<Mapping>>, NLayers> mDecoder;
100108
std::unique_ptr<Clusterer> mClusterer;
101109
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
110+
std::array<std::vector<InputSpec>, NLayers> mRawFilter;
102111
};
103112

104113
using STFDecoderITS = STFDecoder<ChipMappingITS>;

0 commit comments

Comments
 (0)