feat: fee masking in tpc decoder#4227
Conversation
📝 WalkthroughWalkthroughThe changes implement a bad-FEE (Front-End Electronics) masking system for TPC data processing. TpcTimeFrameBuilder now reads bad-FEE calibration data from the conditions database, populates an internal mask, and skips processing of masked FEEs during time-frame construction. The system is initialized via a new fillBadFeeMap() method called during instantiation. Changes
Sequence Diagram(s)sequenceDiagram
participant STFI as SingleTpcTimeFrameInput
participant TTFB as TpcTimeFrameBuilder
participant CDB as CDBInterface
participant CAL as CDBTTree<br/>(Calibration)
STFI->>TTFB: new TpcTimeFrameBuilder(packet_id)
STFI->>TTFB: fillBadFeeMap()
activate TTFB
TTFB->>CDB: read URL for TPC_DECODER_BAD_FEE
CDB-->>TTFB: calibration file path
TTFB->>CAL: load CDBTTree calibration
CAL-->>TTFB: N_MASKED_FEES & EBDC→FEEID mappings
TTFB->>TTFB: populate m_maskedFEEs[packet_id_derived]
deactivate TTFB
Note over TTFB: During FEE processing:<br/>skip if FEE_ID in m_maskedFEEs
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
offline/framework/fun4allraw/SingleTpcTimeFrameInput.cc (1)
294-301:⚠️ Potential issue | 🟠 MajorReinitialize bad-FEE masks on run/file transitions, not only on first builder creation.
The call is currently one-time per builder. Since builders persist in
m_TpcTimeFrameBuilderMap, subsequent runs/files can reuse stale masking state and apply the wrong mask set.Proposed fix direction
if (RunNumber() == 0) { RunNumber(evt->getRunNumber()); + for (auto& [id, builder] : m_TpcTimeFrameBuilderMap) + { + builder->fillBadFeeMap(); + } if (Verbosity() >= 1) { std::cout << __PRETTY_FUNCTION__ << ": Fetching new file " << FileName()As per coding guidelines,
**/*.{cc,cpp,cxx,c}: “Prioritize correctness, memory safety, error handling, and thread-safety.”
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 80d1988d-20a8-4e2b-9550-da5a7b97fb9d
📒 Files selected for processing (5)
offline/framework/fun4allraw/Makefile.amoffline/framework/fun4allraw/SingleTpcTimeFrameInput.ccoffline/framework/fun4allraw/SingleTpcTimeFrameInput.hoffline/framework/fun4allraw/TpcTimeFrameBuilder.ccoffline/framework/fun4allraw/TpcTimeFrameBuilder.h
| void TpcTimeFrameBuilder::fillBadFeeMap() | ||
| { | ||
| const std::string filename = CDBInterface::instance()->getUrl("TPC_DECODER_BAD_FEE"); | ||
|
|
||
| if (filename.empty()) | ||
| { | ||
| if (m_verbosity > 0) | ||
| { | ||
| std::cout << "TpcTimeFrameBuilder::fillBadFeeMap - no file found for TPC_DECODER_BAD_FEE, not filling bad fee map" << std::endl; | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| CDBTTree cdbtree(filename); | ||
| cdbtree.LoadCalibrations(); | ||
|
|
||
| const int nentries = cdbtree.GetSingleIntValue("N_MASKED_FEES"); | ||
|
|
||
| for (int i = 0; i < nentries; i++) | ||
| { | ||
| m_maskedFEEs[cdbtree.GetIntValue(i, "EBDC")].insert(cdbtree.GetIntValue(i, "FEEID")); | ||
| } |
There was a problem hiding this comment.
Reset mask state before loading CDB data.
fillBadFeeMap() only inserts into m_maskedFEEs. If this method is called again (new run/file context), previous masks remain; and when no CDB file is found, old masks still stay active. That can incorrectly suppress good FEEs.
Proposed fix
void TpcTimeFrameBuilder::fillBadFeeMap()
{
+ // Never carry mask state across CDB refreshes.
+ m_maskedFEEs.clear();
+
const std::string filename = CDBInterface::instance()->getUrl("TPC_DECODER_BAD_FEE");
if (filename.empty())
{
if (m_verbosity > 0)
{
std::cout << "TpcTimeFrameBuilder::fillBadFeeMap - no file found for TPC_DECODER_BAD_FEE, not filling bad fee map" << std::endl;
}
return;
}As per coding guidelines, **/*.{cc,cpp,cxx,c}: “Prioritize correctness, memory safety, error handling, and thread-safety.”
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| void TpcTimeFrameBuilder::fillBadFeeMap() | |
| { | |
| const std::string filename = CDBInterface::instance()->getUrl("TPC_DECODER_BAD_FEE"); | |
| if (filename.empty()) | |
| { | |
| if (m_verbosity > 0) | |
| { | |
| std::cout << "TpcTimeFrameBuilder::fillBadFeeMap - no file found for TPC_DECODER_BAD_FEE, not filling bad fee map" << std::endl; | |
| } | |
| return; | |
| } | |
| CDBTTree cdbtree(filename); | |
| cdbtree.LoadCalibrations(); | |
| const int nentries = cdbtree.GetSingleIntValue("N_MASKED_FEES"); | |
| for (int i = 0; i < nentries; i++) | |
| { | |
| m_maskedFEEs[cdbtree.GetIntValue(i, "EBDC")].insert(cdbtree.GetIntValue(i, "FEEID")); | |
| } | |
| void TpcTimeFrameBuilder::fillBadFeeMap() | |
| { | |
| // Never carry mask state across CDB refreshes. | |
| m_maskedFEEs.clear(); | |
| const std::string filename = CDBInterface::instance()->getUrl("TPC_DECODER_BAD_FEE"); | |
| if (filename.empty()) | |
| { | |
| if (m_verbosity > 0) | |
| { | |
| std::cout << "TpcTimeFrameBuilder::fillBadFeeMap - no file found for TPC_DECODER_BAD_FEE, not filling bad fee map" << std::endl; | |
| } | |
| return; | |
| } | |
| CDBTTree cdbtree(filename); | |
| cdbtree.LoadCalibrations(); | |
| const int nentries = cdbtree.GetSingleIntValue("N_MASKED_FEES"); | |
| for (int i = 0; i < nentries; i++) | |
| { | |
| m_maskedFEEs[cdbtree.GetIntValue(i, "EBDC")].insert(cdbtree.GetIntValue(i, "FEEID")); | |
| } |
Build & test reportReport for commit cea59d00c328005edb502f46033076e322a69f82:
Automatically generated by sPHENIX Jenkins continuous integration |
|
This clang-tidy warning is not related to this PR |
7c6b32f
into
sPHENIX-Collaboration:master



This PR adds the ability to read from a CDB file responsible for masking bad FEEs on a run by run basis into the tpc decoder. The files need to be committed to the CDB, so in the meantime if no file is found the function does nothing.
Types of changes
What kind of change does this PR introduce? (Bug fix, feature, ...)
TODOs (if applicable)
Links to other PRs in macros and calibration repositories (if applicable)
FEE Masking in TPC Decoder
Motivation
This PR adds runtime capability to mask (skip processing of) Front-End Electronics (FEEs) identified as problematic on a run-by-run basis. The implementation reads FEE mask information from the Calibration Database (CDB) and applies these masks during TPC data decoding. If no CDB file is available (e.g., during development before calibration commits), the masking is a no-op, ensuring graceful fallback behavior.
Key Changes
libfun4allrawlibrary dependencies to includeffamodulesandcdbobjectslibraries (Makefile.am)fillBadFeeMap()public method to initialize bad-FEE mapping from CDB at runtimeTPC_DECODER_BAD_FEECDB URL and loads corresponding CDBTTree calibration datam_maskedFEEsmap (mapping packet_id to set of masked FEE IDs)fillBadFeeMap()immediately after creating each TpcTimeFrameBuilder instancePotential Risk Areas
Possible Future Improvements
Note: This summary is AI-generated and should be validated by domain experts familiar with the TPC decoder and CDB infrastructure. AI may have misinterpreted technical details or missed nuances in the implementation.