Skip to content

Commit bc5ed44

Browse files
sawenzelclaude
andcommitted
Resolve TPC digitizer calibration objects once per sector
This moves the calibration lookups of the TPC DigitContainer out of the flush loop. - fillOutputContainer fetched the ion-tail and common-mode pad parameters, the dead channel map and the FEE config from the CDBInterface on every flush, the FEE config even once per time bin. - getDeadChannelMap() rebuilds the dead channel map from the pad flags on every call. - updateCalibrations() now fetches them once per sector from Digitizer::init(), with a fallback on the first flush for callers that do not call init(). - SAMPAProcessing picks up its pointers after this update, because a FEE parameter file reload replaces the objects it points to. https://its.cern.ch/jira/browse/O2-7309 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a8a2a45 commit bc5ed44

4 files changed

Lines changed: 54 additions & 34 deletions

File tree

‎Detectors/TPC/simulation/include/TPCSimulation/DigitContainer.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "TPCBase/CRU.h"
2222
#include "DataFormatsTPC/Defs.h"
2323
#include "TPCSimulation/DigitTime.h"
24+
#include "TPCBase/CalDet.h"
2425
#include "CommonUtils/DebugStreamer.h"
2526
#include "TPCBase/ParameterDetector.h"
2627
#include "TPCBase/ParameterElectronics.h"
@@ -78,6 +79,10 @@ class DigitContainer
7879
/// Get the size of the container for one event
7980
size_t size() const { return mTimeBins.size(); }
8081

82+
/// Fetch the calibration objects used by fillOutputContainer from the CDBInterface
83+
/// Must be called after the CDBInterface is configured; fillOutputContainer calls it lazily otherwise
84+
void updateCalibrations();
85+
8186
private:
8287
TimeBin mFirstTimeBin = 0; ///< First time bin to consider
8388
TimeBin mEffectiveTimeBin = 0; ///< Effective time bin of that digit
@@ -86,6 +91,10 @@ class DigitContainer
8691
std::deque<DigitTime*> mTimeBins; ///< Time bin Container for the ADC value
8792
std::unique_ptr<DigitTime::PrevDigitInfoArray> mPrevDigArr; ///< Keep track of ToT and ion tail cumul from last time bin
8893
o2::utils::DebugStreamer mStreamer; ///< Debug streamer
94+
const CalPad* mPadParams[3] = {nullptr, nullptr, nullptr}; //!< Ion tail fraction, ion tail slope and common mode k-values per pad
95+
const CalDet<bool>* mDeadMap = nullptr; //!< Dead channel map
96+
bool mCMCEnabled = false; //!< Common mode correction enabled in the FEE config (DigiMode Auto)
97+
bool mCalibrationsUpdated = false; //!< Whether updateCalibrations was called
8998

9099
void reportSettings();
91100
};

‎Detectors/TPC/simulation/include/TPCSimulation/DigitTime.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class DigitTime
7979
void fillOutputContainer(std::vector<Digit>& output, dataformats::MCTruthContainer<MCCompLabel>& mcTruth,
8080
std::vector<CommonMode>& commonModeOutput, const Sector& sector, TimeBin timeBin,
8181
PrevDigitInfoArray* prevTime = nullptr, Streamer* debugStream = nullptr,
82-
const CalPad* itParams[2] = nullptr, const CalDet<bool>* deadMap = nullptr);
82+
const CalPad* padParams[3] = nullptr, const CalDet<bool>* deadMap = nullptr);
8383

8484
private:
8585
std::array<float, GEMSTACKSPERSECTOR> mCommonMode; ///< Common mode container - 4 GEM ROCs per sector

‎Detectors/TPC/simulation/src/DigitContainer.cxx‎

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,9 @@ void DigitContainer::fillOutputContainer(std::vector<Digit>& output,
4343
// Without this we might get crashes in the clusterization step.
4444
static const int maxTimeBinForTimeFrame = o2::conf::DigiParams::Instance().maxOrbitsToDigitize != -1 ? ((o2::conf::DigiParams::Instance().maxOrbitsToDigitize * 3564 + 2 * 8 - 2) / 8) : -1;
4545

46-
auto& cdb = CDBInterface::instance();
47-
48-
// ion tail per pad parameters
49-
const CalPad* padParams[3] = {nullptr, nullptr, nullptr};
50-
51-
if (eleParam.doIonTailPerPad) {
52-
const auto& itSettings = IonTailSettings::Instance();
53-
if (itSettings.padITCorrFile.size()) {
54-
cdb.setFEEParamsFromFile(itSettings.padITCorrFile);
55-
}
56-
padParams[0] = &cdb.getITFraction();
57-
padParams[1] = &cdb.getITExpLambda();
58-
}
59-
if (eleParam.doCommonModePerPad) {
60-
padParams[2] = &cdb.getCMkValues();
46+
if (!mCalibrationsUpdated) {
47+
LOG(debug) << "TPC DigitContainer: calibrations not set up before the first flush, fetching them now";
48+
updateCalibrations();
6149
}
6250

6351
const bool needsPrevDigArray = eleParam.doIonTail || eleParam.doIonTailPerPad || eleParam.doSaturationTail;
@@ -68,17 +56,11 @@ void DigitContainer::fillOutputContainer(std::vector<Digit>& output,
6856
mPrevDigArr = std::make_unique<DigitTime::PrevDigitInfoArray>();
6957
}
7058

71-
// dead channel map
72-
const CalDet<bool>* deadMap = {nullptr};
73-
if (eleParam.applyDeadMap) {
74-
deadMap = &cdb.getDeadChannelMap();
75-
}
76-
7759
static bool reportedSettings = false;
7860
if (!reportedSettings) {
7961
reportSettings();
80-
if (deadMap) {
81-
LOGP(info, "Using dead map with {} masked pads", deadMap->getSum<int>());
62+
if (mDeadMap) {
63+
LOGP(info, "Using dead map with {} masked pads", mDeadMap->getSum<int>());
8264
}
8365
reportedSettings = true;
8466
}
@@ -109,35 +91,34 @@ void DigitContainer::fillOutputContainer(std::vector<Digit>& output,
10991
if (time) {
11092
switch (digitizationMode) {
11193
case DigitzationMode::FullMode: {
112-
time->fillOutputContainer<DigitzationMode::FullMode>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
94+
time->fillOutputContainer<DigitzationMode::FullMode>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
11395
break;
11496
}
11597
case DigitzationMode::ZeroSuppression: {
116-
time->fillOutputContainer<DigitzationMode::ZeroSuppression>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
98+
time->fillOutputContainer<DigitzationMode::ZeroSuppression>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
11799
break;
118100
}
119101
case DigitzationMode::ZeroSuppressionCMCorr: {
120-
time->fillOutputContainer<DigitzationMode::ZeroSuppressionCMCorr>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
102+
time->fillOutputContainer<DigitzationMode::ZeroSuppressionCMCorr>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
121103
break;
122104
}
123105
case DigitzationMode::SubtractPedestal: {
124-
time->fillOutputContainer<DigitzationMode::SubtractPedestal>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
106+
time->fillOutputContainer<DigitzationMode::SubtractPedestal>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
125107
break;
126108
}
127109
case DigitzationMode::NoSaturation: {
128-
time->fillOutputContainer<DigitzationMode::NoSaturation>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
110+
time->fillOutputContainer<DigitzationMode::NoSaturation>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
129111
break;
130112
}
131113
case DigitzationMode::PropagateADC: {
132-
time->fillOutputContainer<DigitzationMode::PropagateADC>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
114+
time->fillOutputContainer<DigitzationMode::PropagateADC>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
133115
break;
134116
}
135117
case DigitzationMode::Auto: {
136-
const auto& feeConfig = cdb.getFEEConfig();
137-
if (feeConfig.isCMCEnabled()) {
138-
time->fillOutputContainer<DigitzationMode::ZeroSuppressionCMCorr>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
118+
if (mCMCEnabled) {
119+
time->fillOutputContainer<DigitzationMode::ZeroSuppressionCMCorr>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
139120
} else {
140-
time->fillOutputContainer<DigitzationMode::ZeroSuppression>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, padParams, deadMap);
121+
time->fillOutputContainer<DigitzationMode::ZeroSuppression>(output, mcTruth, commonModeOutput, sector, timeBin, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
141122
}
142123
break;
143124
}
@@ -158,6 +139,34 @@ void DigitContainer::fillOutputContainer(std::vector<Digit>& output,
158139
}
159140
}
160141

142+
void DigitContainer::updateCalibrations()
143+
{
144+
const auto& eleParam = ParameterElectronics::Instance();
145+
auto& cdb = CDBInterface::instance();
146+
147+
// ion tail per pad parameters
148+
mPadParams[0] = mPadParams[1] = mPadParams[2] = nullptr;
149+
if (eleParam.doIonTailPerPad) {
150+
const auto& itSettings = IonTailSettings::Instance();
151+
if (itSettings.padITCorrFile.size()) {
152+
cdb.setFEEParamsFromFile(itSettings.padITCorrFile);
153+
}
154+
mPadParams[0] = &cdb.getITFraction();
155+
mPadParams[1] = &cdb.getITExpLambda();
156+
}
157+
if (eleParam.doCommonModePerPad) {
158+
mPadParams[2] = &cdb.getCMkValues();
159+
}
160+
161+
// dead channel map
162+
mDeadMap = eleParam.applyDeadMap ? &cdb.getDeadChannelMap() : nullptr;
163+
164+
// common mode correction in the FEE, needed to resolve DigiMode Auto
165+
mCMCEnabled = (eleParam.DigiMode == DigitzationMode::Auto) && cdb.getFEEConfig().isCMCEnabled();
166+
167+
mCalibrationsUpdated = true;
168+
}
169+
161170
void DigitContainer::reportSettings()
162171
{
163172
auto& cdb = CDBInterface::instance();

‎Detectors/TPC/simulation/src/Digitizer.cxx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ void Digitizer::init()
4646
auto& electronTransport = ElectronTransport::instance();
4747
electronTransport.updateParameters(mVDrift);
4848
auto& sampaProcessing = SAMPAProcessing::instance();
49+
// the calibration update may reload FEE parameters from file, so SAMPAProcessing picks up its pointers afterwards
50+
mDigitContainer.updateCalibrations();
4951
sampaProcessing.updateParameters(mVDrift);
5052
}
5153

0 commit comments

Comments
 (0)