Project
Loading...
Searching...
No Matches
DigitContainer.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
17#include <atomic>
18#include <memory>
19#include <type_traits>
20#include <fairlogger/Logger.h>
21#include "TPCBase/Mapper.h"
26
27using namespace o2::tpc;
28
30 dataformats::MCTruthContainer<MCCompLabel>& mcTruth, std::vector<CommonMode>& commonModeOutput, const Sector& sector, TimeBin eventTimeBin, bool isContinuous, bool finalFlush)
31{
32 using Streamer = o2::utils::DebugStreamer;
33 Streamer* debugStream = nullptr;
34 if (Streamer::checkStream(o2::utils::StreamFlags::streamDigitFolding) || Streamer::checkStream(o2::utils::StreamFlags::streamDigits)) {
35 mStreamer.setStreamer("debug_digits", "UPDATE");
36 debugStream = &mStreamer;
37 }
38
39 const auto& eleParam = ParameterElectronics::Instance();
40 const auto digitizationMode = eleParam.DigiMode;
41 int nProcessedTimeBins = 0;
42 TimeBin timeBin = (isContinuous) ? mFirstTimeBin : 0;
43
44 // Set the TPC timebin limit, after which digits should be truncated.
45 // Without this we might get crashes in the clusterization step.
46 static const int maxTimeBinForTimeFrame = o2::conf::DigiParams::Instance().maxOrbitsToDigitize != -1 ? ((o2::conf::DigiParams::Instance().maxOrbitsToDigitize * 3564 + 2 * 8 - 2) / 8) : -1;
47
48 if (!mCalibrationsUpdated) {
49 LOG(debug) << "TPC DigitContainer: calibrations not set up before the first flush, fetching them now";
51 }
52
53 // after updateCalibrations, which may reload the FEE parameters that SAMPAProcessing picks up
54 auto& sampaProcessing = mSAMPAProcessing ? *mSAMPAProcessing : SAMPAProcessing::instance();
55
56 const bool needsPrevDigArray = eleParam.doIonTail || eleParam.doIonTailPerPad || eleParam.doSaturationTail;
57 const bool needsEmptyTimeBins = needsPrevDigArray || eleParam.doNoiseEmptyPads;
58
59 // TODO: make creation conditional
60 if (needsPrevDigArray && !mPrevDigArr) {
61 mPrevDigArr = std::make_unique<DigitTime::PrevDigitInfoArray>();
62 }
63
64 for (auto& time : mTimeBins) {
67 if (!((nProcessedTimeBins + mFirstTimeBin < eventTimeBin) || !isContinuous || finalFlush)) {
68 break;
69 }
70
71 if (!isContinuous && timeBin > mTmaxTriggered) {
72 continue;
73 }
74
75 // fill also time bins without signal to get noise, ion tail and saturated signals
76 if (needsEmptyTimeBins && !time) {
77 time = new DigitTime;
78 }
79
80 if (maxTimeBinForTimeFrame != -1 && timeBin >= maxTimeBinForTimeFrame) {
81 LOG(warn) << "Timebin going beyond timeframe limit .. truncating flush " << timeBin;
82 break;
83 }
84
85 // fmt::print("Processing secotor: {}, time bin: {}, mFirstTimeBin: {}, dgitTime: {}\n", sector.getSector(), timeBin, mFirstTimeBin, (void*)time);
86
87 if (time) {
88 // the digitization mode is a template parameter of fillOutputContainer
89 auto fill = [&](auto mode) {
90 time->fillOutputContainer<decltype(mode)::value>(output, mcTruth, commonModeOutput, sector, timeBin, sampaProcessing, mLabelCollector, mPrevDigArr.get(), debugStream, mPadParams, mDeadMap);
91 };
92 using M = DigitzationMode;
93 switch (digitizationMode) {
94 case M::FullMode:
95 fill(std::integral_constant<M, M::FullMode>{});
96 break;
97 case M::ZeroSuppression:
98 fill(std::integral_constant<M, M::ZeroSuppression>{});
99 break;
100 case M::ZeroSuppressionCMCorr:
101 fill(std::integral_constant<M, M::ZeroSuppressionCMCorr>{});
102 break;
103 case M::SubtractPedestal:
104 fill(std::integral_constant<M, M::SubtractPedestal>{});
105 break;
106 case M::NoSaturation:
107 fill(std::integral_constant<M, M::NoSaturation>{});
108 break;
109 case M::PropagateADC:
110 fill(std::integral_constant<M, M::PropagateADC>{});
111 break;
112 case M::Auto:
113 if (mCMCEnabled) {
114 fill(std::integral_constant<M, M::ZeroSuppressionCMCorr>{});
115 } else {
116 fill(std::integral_constant<M, M::ZeroSuppression>{});
117 }
118 break;
119 }
120 }
121
122 ++nProcessedTimeBins;
123 ++timeBin;
124 }
125
126 if (nProcessedTimeBins > 0) {
127 mFirstTimeBin += nProcessedTimeBins;
128 while (nProcessedTimeBins--) {
129 auto popped = mTimeBins.front();
130 mTimeBins.pop_front();
131 delete popped;
132 }
133 }
134}
135
137{
138 const auto& eleParam = ParameterElectronics::Instance();
139 auto& cdb = CDBInterface::instance();
140
141 // ion tail per pad parameters
142 mPadParams[0] = mPadParams[1] = mPadParams[2] = nullptr;
143 if (eleParam.doIonTailPerPad) {
144 const auto& itSettings = IonTailSettings::Instance();
145 if (itSettings.padITCorrFile.size()) {
146 cdb.setFEEParamsFromFile(itSettings.padITCorrFile);
147 }
148 mPadParams[0] = &cdb.getITFraction();
149 mPadParams[1] = &cdb.getITExpLambda();
150 }
151 if (eleParam.doCommonModePerPad) {
152 mPadParams[2] = &cdb.getCMkValues();
153 }
154
155 // dead channel map
156 mDeadMap = nullptr;
157 mDeadMapCopy.reset();
158 if (eleParam.applyDeadMap) {
159 mDeadMapCopy = std::make_unique<CalDet<bool>>(cdb.getDeadChannelMap());
160 mDeadMap = mDeadMapCopy.get();
161 }
162
163 // common mode correction in the FEE, needed to resolve DigiMode Auto
164 mCMCEnabled = (eleParam.DigiMode == DigitzationMode::Auto) && cdb.getFEEConfig().isCMCEnabled();
165
166 mCalibrationsUpdated = true;
167
168 static std::atomic<bool> reportedSettings{false};
169 if (!reportedSettings.exchange(true)) {
170 reportSettings();
171 if (mDeadMap) {
172 LOGP(info, "Using dead map with {} masked pads", mDeadMap->getSum<int>());
173 }
174 }
175}
176
177void DigitContainer::reportSettings()
178{
179 auto& cdb = CDBInterface::instance();
180 const auto& eleParam = ParameterElectronics::Instance();
181 const auto& feeConfig = cdb.getFEEConfig();
182 LOGP(info, "ParameterElectronics: doIonTail={}, doIonTailPerPad={}, doCommonModePerPad={}, doSaturationTail={}, doNoiseEmptyPads={}, applyDeadMap={}, commonModeCoupling={}, DigiMode={}",
183 eleParam.doIonTail, eleParam.doIonTailPerPad, eleParam.doCommonModePerPad, eleParam.doSaturationTail, eleParam.doNoiseEmptyPads, eleParam.applyDeadMap, eleParam.commonModeCoupling, (int)eleParam.DigiMode);
184 feeConfig.printShort();
185}
Simple interface to the CDB manager.
Definition of the Digit Container.
std::ostringstream debug
int16_t time
Definition RawEventData.h:4
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the parameter class for the detector electronics.
static CDBInterface & instance()
U getSum() const
Definition CalDet.h:132
void fillOutputContainer(std::vector< Digit > &output, dataformats::MCTruthContainer< MCCompLabel > &mcTruth, std::vector< CommonMode > &commonModeOutput, const Sector &sector, TimeBin eventTimeBin=0, bool isContinuous=true, bool finalFlush=false)
static SAMPAProcessing & instance()
class to enable streaming debug information to root files
GLenum mode
Definition glcorearb.h:266
GLsizei const GLfloat * value
Definition glcorearb.h:819
Global TPC definitions and constants.
@ Auto
Automatically decide based on DCS settings in CCDB.
@ streamDigits
stream digit information
@ streamDigitFolding
stream ion tail and saturatio information
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"