Skip to content

Commit 97a27cc

Browse files
committed
[EMCAL-834] Checking active links per trigger
For each trigger checking from which DDLs the reconstruction received pages. If we don't receive pages from all active links the page is discarded. The link checker can be disabled via a corresponding config option and is by default disabled in case of running on simulated data.
1 parent 8ed9ac9 commit 97a27cc

4 files changed

Lines changed: 74 additions & 15 deletions

File tree

DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/ErrorTypeFEE.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ErrorTypeFEE
5757
FIT_ERROR, ///< Raw fit failed
5858
GEOMETRY_ERROR, ///< Decoded position outside EMCAL
5959
GAIN_ERROR, ///< Error due to gain type
60+
LINK_ERROR, ///< Error due to missing DDL links
6061
STU_ERROR, ///< Error from STU data
6162
UNDEFINED ///< Error source undefined
6263
};
@@ -98,6 +99,10 @@ class ErrorTypeFEE
9899
/// \param gainError Error code of the gain type error
99100
void setGainErrorType(int gainError) { setError(ErrorSource_t::GAIN_ERROR, gainError); }
100101

102+
/// \brief Set the error type as link error and store the error code
103+
/// \param linkError Error code of the link error
104+
void setLinkErrorTYpe(int linkError) { setError(ErrorSource_t::LINK_ERROR, linkError); }
105+
101106
/// \brief Set the error as STU decoder error and store the error code
102107
/// \param gainError Error code of the STU decoder error
103108
void setSTUDecoderErrorType(int gainError) { setError(ErrorSource_t::STU_ERROR, gainError); }
@@ -162,6 +167,10 @@ class ErrorTypeFEE
162167
/// \return Error code (-1 in case the object is not a gain type error)
163168
int getGainTypeErrorType() const { return getRawErrorForType(ErrorSource_t::GAIN_ERROR); }
164169

170+
/// \brief Get the error code of the obect in case the object is a link error
171+
/// \return Error code (-1 in case the object is not a gain type error)
172+
int getLinkErrorType() const { return getRawErrorForType(ErrorSource_t::LINK_ERROR); }
173+
165174
/// \brief Get the error code of the obect in case the object is a STU decoder error
166175
/// \return Error code (-1 in case the object is not a STU decoder error)
167176
int getSTUDecoderErrorType() const { return getRawErrorForType(ErrorSource_t::STU_ERROR); }

Detectors/EMCAL/workflow/include/EMCALWorkflow/RawToCellConverterSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class RawToCellConverterSpec : public framework::Task
239239
int mErrorMessagesSuppressed = 0; ///< Counter of suppressed error messages
240240
int mMaxErrorMessages = 100; ///< Max. number of error messages
241241
bool mMergeLGHG = true; ///< Merge low and high gain cells
242+
bool mActiveLinkCheck = true; ///< Run check for active links
242243
bool mPrintTrailer = false; ///< Print RCU trailer
243244
bool mDisablePedestalEvaluation = false; ///< Disable pedestal evaluation independent of settings in the RCU trailer
244245
bool mCreateRawDataErrors = false; ///< Create raw data error objects for monitoring

Detectors/EMCAL/workflow/src/RawToCellConverterSpec.cxx

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "DetectorsRaw/RDHUtils.h"
3232
#include "EMCALBase/Geometry.h"
3333
#include "EMCALBase/Mapper.h"
34+
#include "EMCALCalib/FeeDCS.h"
3435
#include "EMCALReconstruction/CaloFitResults.h"
3536
#include "EMCALReconstruction/Bunch.h"
3637
#include "EMCALReconstruction/CaloRawFitterStandard.h"
@@ -93,8 +94,11 @@ void RawToCellConverterSpec::init(framework::InitContext& ctx)
9394

9495
mMergeLGHG = !ctx.options().get<bool>("no-mergeHGLG");
9596
mDisablePedestalEvaluation = ctx.options().get<bool>("no-evalpedestal");
97+
mActiveLinkCheck = !ctx.options().get<bool>("no-checkactivelinks");
9698

9799
LOG(info) << "Running gain merging mode: " << (mMergeLGHG ? "yes" : "no");
100+
LOG(info) << "Checking for active links: " << (mActiveLinkCheck ? "yes" : "no");
101+
LOG(info) << "Calculate pedestals: " << (mDisablePedestalEvaluation ? "no" : "yes");
98102
LOG(info) << "Using L0LM delay: " << o2::ctp::TriggerOffsetsParam::Instance().LM_L0 << " BCs";
99103

100104
mRawFitter->setAmpCut(mNoiseThreshold);
@@ -107,6 +111,9 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
107111
mCalibHandler->checkUpdates(ctx);
108112
updateCalibrationObjects();
109113

114+
// container with BCid and feeID
115+
std::unordered_map<int64_t, std::bitset<46>> bcFreq;
116+
110117
double timeshift = RecoParam::Instance().getCellTimeShiftNanoSec(); // subtract offset in ns in order to center the time peak around the nominal delay
111118
constexpr auto originEMC = o2::header::gDataOriginEMC;
112119
constexpr auto descRaw = o2::header::gDataDescriptionRawData;
@@ -181,6 +188,9 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
181188
continue;
182189
}
183190
}
191+
192+
bcFreq[currentIR.toLong()].set(feeID, true);
193+
184194
// Correct the cell time for the bc mod 4 (LHC: 40 MHz clock - ALTRO: 10 MHz clock)
185195
// Convention: All times shifted with respect to BC % 4 = 0 for trigger BC
186196
// Attention: Correction only works for the permutation (0 1 2 3) of the BC % 4, if the permutation is
@@ -315,6 +325,43 @@ void RawToCellConverterSpec::run(framework::ProcessingContext& ctx)
315325
}
316326
}
317327

328+
if (mActiveLinkCheck) {
329+
// build expected active mask from DCS
330+
FeeDCS* feedcs = mCalibHandler->getFEEDCS();
331+
auto list0 = feedcs->getDDLlist0();
332+
auto list1 = feedcs->getDDLlist1();
333+
// links 21 and 39 do not exist, but they are set active in DCS
334+
list0.set(21, false);
335+
list1.set(7, false);
336+
// must be 0x307FFFDFFFFF if all links are active
337+
std::bitset<46> bitSetActiveLinks((list1.to_ullong() << 32) + list0.to_ullong());
338+
339+
// Check if we have received pages from all active links
340+
// If not we cannot trust the timeframe and must send
341+
// empty containers
342+
bool hasMissingLinks = false;
343+
for (const auto& [globalBC, activelinks] : bcFreq) {
344+
if (activelinks != bitSetActiveLinks) {
345+
hasMissingLinks = true;
346+
LOG(error) << "Not all EMC active links contributed in global BCid=" << globalBC << ": mask=" << (activelinks ^ bitSetActiveLinks);
347+
if (mCreateRawDataErrors) {
348+
for (std::size_t ilink = 0; ilink < bitSetActiveLinks.size(); ilink++) {
349+
if (!bitSetActiveLinks.test(ilink)) {
350+
continue;
351+
}
352+
if (!activelinks.test(ilink)) {
353+
mOutputDecoderErrors.emplace_back(ilink, ErrorTypeFEE::ErrorSource_t::LINK_ERROR, 0, -1, -1);
354+
}
355+
}
356+
}
357+
}
358+
}
359+
if (hasMissingLinks) {
360+
sendData(ctx, mOutputCells, mOutputTriggerRecords, mOutputDecoderErrors);
361+
return;
362+
}
363+
}
364+
318365
// Loop over BCs, sort cells with increasing tower ID and write to output containers
319366
RecoContainerReader eventIterator(mCellHandler);
320367
while (eventIterator.hasNext()) {
@@ -355,9 +402,9 @@ void RawToCellConverterSpec::updateCalibrationObjects()
355402
LOG(info) << "RecoParams updated";
356403
o2::emcal::RecoParam::Instance().printKeyValues(true, true);
357404
}
358-
// if (mCalibHandler->hasUpdateFEEDCS()) {
359-
// LOG(info) << "DCS params updated";
360-
// }
405+
if (mCalibHandler->hasUpdateFEEDCS()) {
406+
LOG(info) << "DCS params updated";
407+
}
361408
}
362409

363410
bool RawToCellConverterSpec::isLostTimeframe(framework::ProcessingContext& ctx) const
@@ -677,17 +724,19 @@ o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getRawToCellConverter
677724
// CCDB objects
678725
auto calibhandler = std::make_shared<o2::emcal::CalibLoader>();
679726
calibhandler->enableRecoParams(true);
680-
// calibhandler->enableFEEDCS(true);
727+
calibhandler->enableFEEDCS(true);
681728
calibhandler->defineInputSpecs(inputs);
682729

683-
return o2::framework::DataProcessorSpec{"EMCALRawToCellConverterSpec",
684-
inputs,
685-
outputs,
686-
o2::framework::adaptFromTask<o2::emcal::reco_workflow::RawToCellConverterSpec>(subspecification, !disableDecodingErrors, calibhandler),
687-
o2::framework::Options{
688-
{"fitmethod", o2::framework::VariantType::String, "gamma2", {"Fit method (standard or gamma2)"}},
689-
{"maxmessage", o2::framework::VariantType::Int, 100, {"Max. amout of error messages to be displayed"}},
690-
{"printtrailer", o2::framework::VariantType::Bool, false, {"Print RCU trailer (for debugging)"}},
691-
{"no-mergeHGLG", o2::framework::VariantType::Bool, false, {"Do not merge HG and LG channels for same tower"}},
692-
{"no-evalpedestal", o2::framework::VariantType::Bool, false, {"Disable pedestal evaluation"}}}};
730+
return o2::framework::DataProcessorSpec{
731+
"EMCALRawToCellConverterSpec",
732+
inputs,
733+
outputs,
734+
o2::framework::adaptFromTask<o2::emcal::reco_workflow::RawToCellConverterSpec>(subspecification, !disableDecodingErrors, calibhandler),
735+
o2::framework::Options{
736+
{"fitmethod", o2::framework::VariantType::String, "gamma2", {"Fit method (standard or gamma2)"}},
737+
{"maxmessage", o2::framework::VariantType::Int, 100, {"Max. amout of error messages to be displayed"}},
738+
{"printtrailer", o2::framework::VariantType::Bool, false, {"Print RCU trailer (for debugging)"}},
739+
{"no-mergeHGLG", o2::framework::VariantType::Bool, false, {"Do not merge HG and LG channels for same tower"}},
740+
{"no-checkactivelinks", o2::framework::VariantType::Bool, false, {"Do not check for active links per BC"}},
741+
{"no-evalpedestal", o2::framework::VariantType::Bool, false, {"Disable pedestal evaluation"}}}};
693742
}

prodtests/full-system-test/dpl-workflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ fi
258258
( workflow_has_parameter AOD || [[ -z "$DISABLE_ROOT_OUTPUT" ]] || needs_root_output o2-emcal-cell-writer-workflow ) && has_detector EMC && RAW_EMC_SUBSPEC=" --subspecification 1 "
259259
has_detector_reco MID && has_detector_matching MCHMID && MFTMCHConf="FwdMatching.useMIDMatch=true;" || MFTMCHConf="FwdMatching.useMIDMatch=false;"
260260

261-
[[ $IS_SIMULATED_DATA == "1" ]] && EMCRAW2C_CONFIG+=" --no-mergeHGLG"
261+
[[ $IS_SIMULATED_DATA == "1" ]] && EMCRAW2C_CONFIG+=" --no-mergeHGLG --no-checkactivelinks"
262262

263263
# ---------------------------------------------------------------------------------------------------------------------
264264
# Temporary extra options

0 commit comments

Comments
 (0)