Skip to content

Commit 2918894

Browse files
mfasDacterrevo
andauthored
[EMCAL-526] Convert online to offline mapping (#756)
* [EMCAL-526] Convert online to offline mapping Raw row/col IDs in the DCAL are different in the online and offline scheme. As the cell index mapping is using the offline scheme, using the online scheme will lead to a crash when receiving data from SM 19 (DCAL 1/3) due to invalid cell ID. Local co and row need to be shifted back to offline index scheme using the corresponding wrapper function in the geometry. In addition refactor jfecID -> supermoduleID for readability. * [EMCAL-526] fix reading of FECid * [EMCAL-526] Use input record walker in order to scan all links Old style iteration (copied from DAQ task) was only processing the first link. Code is taked from the Raw-to-cell converter. * [EMCAL-526] Fix labels for calib and physics trigger Labels were swapped with respect to the event type used in the histograms. Co-authored-by: Cristina Terrevoli <cristina.terrevoli@cern.ch>
1 parent 65318a4 commit 2918894

1 file changed

Lines changed: 38 additions & 36 deletions

File tree

Modules/EMCAL/src/RawTask.cxx

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "EMCALReconstruction/AltroDecoder.h"
3030
#include "EMCALReconstruction/RawReaderMemory.h"
3131
#include "EMCALReconstruction/RawHeaderStream.h"
32+
#include <Framework/InputRecordWalker.h>
3233
#include <Framework/InputRecord.h>
3334
#include <CommonConstants/Triggers.h>
3435

@@ -226,7 +227,7 @@ void RawTask::initialize(o2::framework::InitContext& /*ctx*/)
226227

227228
//histos per SM and Trigger
228229
EventType triggers[2] = { EventType::CAL_EVENT, EventType::PHYS_EVENT };
229-
TString histoStr[2] = { "PHYS", "CAL" };
230+
TString histoStr[2] = { "CAL", "PHYS" };
230231
for (auto trg = 0; trg < 2; trg++) {
231232

232233
TProfile2D* histosRawAmplRms; //Filling EMCAL/DCAL
@@ -362,10 +363,10 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
362363
for (Int_t i = 0; i < NFEESM; i++)
363364
nchannels[i] = 0;
364365

365-
for (auto&& input : ctx.inputs()) {
366+
for (const auto& rawData : framework::InputRecordWalker(ctx.inputs())) {
366367
// get message header
367-
if (input.header != nullptr && input.payload != nullptr) {
368-
const auto* header = header::get<header::DataHeader*>(input.header);
368+
if (rawData.header != nullptr && rawData.payload != nullptr) {
369+
const auto* header = header::get<header::DataHeader*>(rawData.header);
369370
// get payload of a specific input, which is a char array.
370371
QcInfoLogger::GetInstance() << QcInfoLogger::Debug << "Processing superpage " << mNumberOfSuperpages << AliceO2::InfoLogger::InfoLogger::endm;
371372
mNumberOfSuperpages++;
@@ -378,13 +379,13 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
378379
mTotalDataVolume->Fill(1., header->payloadSize); //for expert
379380

380381
// Skip SOX headers
381-
auto rdhblock = reinterpret_cast<const o2::header::RDHAny*>(input.payload);
382+
auto rdhblock = reinterpret_cast<const o2::header::RDHAny*>(rawData.payload);
382383
if (o2::raw::RDHUtils::getHeaderSize(rdhblock) == static_cast<int>(header->payloadSize)) {
383384
continue;
384385
}
385386

386387
// try decoding payload
387-
o2::emcal::RawReaderMemory rawreader(gsl::span(input.payload, header->payloadSize));
388+
o2::emcal::RawReaderMemory rawreader(gsl::span(rawData.payload, header->payloadSize));
388389

389390
while (rawreader.hasNext()) {
390391

@@ -489,21 +490,22 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
489490
mErrorTypeAltro->Fill(feeID, errornum); //for shifter
490491
continue;
491492
}
492-
int jfeeID = feeID / 2; //SM id
493+
int supermoduleID = feeID / 2; //SM id
493494
auto& mapping = mMappings->getMappingForDDL(feeID);
494-
int col;
495-
int row;
496495

497-
//auto fecIndex = 0.;
498-
//auto branchIndex = 0.;
499-
//auto fecID = 0.;
496+
auto fecIndex = 0;
497+
auto branchIndex = 0;
498+
auto fecID = 0;
500499

501500
for (auto& chan : decoder.getChannels()) {
502-
col = mapping.getColumn(chan.getHardwareAddress());
503-
row = mapping.getRow(chan.getHardwareAddress());
504-
auto [phimod, etamod, mod] = mGeometry->GetModuleIndexesFromCellIndexesInSModule(jfeeID, row, col);
501+
// Row and column in online format, must be remapped to offline indexing,
502+
// otherwise it leads to invalid cell IDs
503+
auto colOnline = mapping.getColumn(chan.getHardwareAddress());
504+
auto rowOnline = mapping.getRow(chan.getHardwareAddress());
505+
auto [row, col] = mGeometry->ShiftOnlineToOfflineCellIndexes(supermoduleID, rowOnline, colOnline);
506+
auto [phimod, etamod, mod] = mGeometry->GetModuleIndexesFromCellIndexesInSModule(supermoduleID, row, col);
505507
//tower absolute ID
506-
auto cellID = mGeometry->GetAbsCellId(jfeeID, mod, phimod, etamod);
508+
auto cellID = mGeometry->GetAbsCellId(supermoduleID, mod, phimod, etamod);
507509
//position in the EMCAL
508510
auto [globRow, globCol] = mGeometry->GlobalRowColFromIndex(cellID);
509511

@@ -512,10 +514,10 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
512514
if (chType == CHTYP::LEDMON || chType == CHTYP::TRU)
513515
continue;
514516

515-
//fecIndex = chan.getFECIndex();
516-
//branchIndex = chan.getBranchIndex();
517-
//fecID = mMappings->getFEEForChannelInDDL(jfeeID, fecIndex, branchIndex);
518-
nchannels[jfeeID]++;
517+
fecIndex = chan.getFECIndex();
518+
branchIndex = chan.getBranchIndex();
519+
fecID = mMappings->getFEEForChannelInDDL(supermoduleID, fecIndex, branchIndex);
520+
nchannels[fecID]++;
519521

520522
Short_t maxADC = 0;
521523
Short_t minADC = SHRT_MAX;
@@ -528,7 +530,7 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
528530
auto maxADCbunch = *max_element(adcs.begin(), adcs.end());
529531
if (maxADCbunch > maxADC)
530532
maxADC = maxADCbunch;
531-
mRawAmplMaxEMCAL[evtype][jfeeID]->Fill(maxADCbunch); //max for each cell --> for for expert only
533+
mRawAmplMaxEMCAL[evtype][supermoduleID]->Fill(maxADCbunch); //max for each cell --> for for expert only
532534

533535
if (maxADCSMEvent == maxADCSM.end()) { //max for each event
534536
std::array<int, NUMBERSM> maxadc;
@@ -539,28 +541,28 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
539541
auto minADCbunch = *min_element(adcs.begin(), adcs.end());
540542
if (minADCbunch < minADC)
541543
minADC = minADCbunch;
542-
mRawAmplMinEMCAL[evtype][jfeeID]->Fill(minADCbunch); // min for each cell --> for for expert only
544+
mRawAmplMinEMCAL[evtype][supermoduleID]->Fill(minADCbunch); // min for each cell --> for for expert only
543545

544546
meanADC = TMath::Mean(adcs.begin(), adcs.end());
545547
rmsADC = TMath::RMS(adcs.begin(), adcs.end());
546548

547-
mRMS[evtype]->Fill(globCol, globRow, rmsADC); //for shifter
548-
mRMSperSM[evtype][jfeeID]->Fill(col, row, rmsADC); // no shifter
549+
mRMS[evtype]->Fill(globCol, globRow, rmsADC); //for shifter
550+
mRMSperSM[evtype][supermoduleID]->Fill(col, row, rmsADC); // no shifter
549551

550-
mMEAN[evtype]->Fill(globCol, globRow, meanADC); //for shifter
551-
mMEANperSM[evtype][jfeeID]->Fill(col, row, meanADC); // no shifter
552+
mMEAN[evtype]->Fill(globCol, globRow, meanADC); //for shifter
553+
mMEANperSM[evtype][supermoduleID]->Fill(col, row, meanADC); // no shifter
552554
}
553-
if (maxADC > maxADCSMEvent->second[jfeeID])
554-
maxADCSMEvent->second[jfeeID] = maxADC;
555+
if (maxADC > maxADCSMEvent->second[supermoduleID])
556+
maxADCSMEvent->second[supermoduleID] = maxADC;
555557

556-
mMAXperSM[evtype][jfeeID]->Fill(col, row, maxADC); //max col,row, per SM
557-
mMAX[evtype]->Fill(globCol, globRow, maxADC); //for shifter
558+
mMAXperSM[evtype][supermoduleID]->Fill(col, row, maxADC); //max col,row, per SM
559+
mMAX[evtype]->Fill(globCol, globRow, maxADC); //for shifter
558560

559-
if (minADC < minADCSMEvent->second[jfeeID])
560-
minADCSMEvent->second[jfeeID] = minADC;
561-
mMINperSM[evtype][jfeeID]->Fill(col, row, minADC); //min col,row, per SM
562-
mMIN[evtype]->Fill(globCol, globRow, minADC); //for shifter
563-
} //channels
561+
if (minADC < minADCSMEvent->second[supermoduleID])
562+
minADCSMEvent->second[supermoduleID] = minADC;
563+
mMINperSM[evtype][supermoduleID]->Fill(col, row, minADC); //min col,row, per SM
564+
mMIN[evtype]->Fill(globCol, globRow, minADC); //for shifter
565+
} //channels
564566
//check on trigger type
565567
//meaningless for CALIB trigger since the whole detector is illuminated
566568
int channelID = -1, maxCount = -1;
@@ -570,7 +572,7 @@ void RawTask::monitorData(o2::framework::ProcessingContext& ctx)
570572
channelID = i;
571573
}
572574
}
573-
auto& currentmaxchannelSM = fecMaxChannelsEvent->second[jfeeID];
575+
auto& currentmaxchannelSM = fecMaxChannelsEvent->second[supermoduleID];
574576
if (maxCount > currentmaxchannelSM.second) {
575577
// new slowest channel found
576578
currentmaxchannelSM.first = channelID;

0 commit comments

Comments
 (0)