Project
Loading...
Searching...
No Matches
GPUWorkflowTPC.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
14
16#include "Headers/DataHeader.h"
17#include "Framework/WorkflowSpec.h" // o2::framework::mergeInputs
25#include "Framework/Logger.h"
39#include "TPCFastTransform.h"
46#include "TPCBase/RDHUtils.h"
48#include "GPUO2InterfaceQA.h"
49#include "GPUO2Interface.h"
50#include "GPUO2InterfaceUtils.h"
51#include "CalibdEdxContainer.h"
52#include "ORTRootSerializer.h"
53#include "GPUNewCalibValues.h"
54#include "TPCPadGainCalib.h"
55#include "TPCZSLinkMapping.h"
57#include "TPCBase/Sector.h"
58#include "TPCBase/Utils.h"
67#include "Algorithm/Parser.h"
72#include <filesystem>
73#include <memory> // for make_shared
74#include <vector>
75#include <iomanip>
76#include <stdexcept>
77#include <regex>
78#include <sys/types.h>
79#include <sys/stat.h>
80#include <fcntl.h>
81#include <chrono>
84#include <TStopwatch.h>
85#include <TObjArray.h>
86#include <TH1F.h>
87#include <TH2F.h>
88#include <TH1D.h>
89#include <TGraphAsymmErrors.h>
90
91using namespace o2::framework;
92using namespace o2::header;
93using namespace o2::gpu;
94using namespace o2::base;
95using namespace o2::dataformats;
96
97namespace o2::gpu
98{
99
100void GPURecoWorkflowSpec::initFunctionTPCCalib(InitContext& ic)
101{
102 mTPCDeadChannelMapCreator.reset(new o2::tpc::DeadChannelMapCreator());
103 const auto deadMapSource = (mSpecConfig.tpcDeadMapSources > -1) ? static_cast<tpc::SourcesDeadMap>(mSpecConfig.tpcDeadMapSources) : tpc::SourcesDeadMap::All;
104 mTPCDeadChannelMapCreator->init();
105 mTPCDeadChannelMapCreator->setSource(deadMapSource);
106
107 mCalibObjects.mdEdxCalibContainer.reset(new o2::tpc::CalibdEdxContainer());
108 mTPCVDriftHelper.reset(new o2::tpc::VDriftHelper());
109 mCalibObjects.mFastTransformHelper.reset(new o2::tpc::CorrectionMapsLoader());
110 mCalibObjects.mFastTransform = std::move(o2::tpc::TPCFastTransformHelperO2::instance()->create(0));
111 mCalibObjects.mFastTransformRef = std::move(o2::tpc::TPCFastTransformHelperO2::instance()->create(0));
112 mCalibObjects.mFastTransformMShape = std::move(o2::tpc::TPCFastTransformHelperO2::instance()->create(0));
113 mCalibObjects.mFastTransformHelper->setCorrMap(mCalibObjects.mFastTransform.get()); // just to reserve the space
114 mCalibObjects.mFastTransformHelper->setCorrMapRef(mCalibObjects.mFastTransformRef.get());
115 mCalibObjects.mFastTransformHelper->setLumiScaleType(mSpecConfig.lumiScaleType);
116 mCalibObjects.mFastTransformHelper->setCorrMapMShape(mCalibObjects.mFastTransformMShape.get());
117 mCalibObjects.mFastTransformHelper->setLumiScaleMode(mSpecConfig.lumiScaleMode);
118 mCalibObjects.mFastTransformHelper->setCheckCTPIDCConsistency(mSpecConfig.checkCTPIDCconsistency);
119 mCalibObjects.mFastTransformHelper->enableMShapeCorrection(mSpecConfig.enableMShape);
120 if (mSpecConfig.outputTracks) {
121 mCalibObjects.mFastTransformHelper->init(ic);
122 }
123 if (mConfParam->dEdxDisableTopologyPol) {
124 LOGP(info, "Disabling loading of track topology correction using polynomials from CCDB");
125 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalTopologyPol);
126 }
127
128 if (mConfParam->dEdxDisableThresholdMap) {
129 LOGP(info, "Disabling loading of threshold map from CCDB");
130 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalThresholdMap);
131 }
132
133 if (mConfParam->dEdxDisableGainMap) {
134 LOGP(info, "Disabling loading of gain map from CCDB");
135 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalGainMap);
136 }
137
138 if (mConfParam->dEdxDisableResidualGainMap) {
139 LOGP(info, "Disabling loading of residual gain map from CCDB");
140 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalResidualGainMap);
141 }
142
143 if (mConfParam->dEdxDisableResidualGain) {
144 LOGP(info, "Disabling loading of residual gain calibration from CCDB");
145 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalTimeGain);
146 }
147
148 if (mConfParam->dEdxUseFullGainMap) {
149 LOGP(info, "Using the full gain map for correcting the cluster charge during calculation of the dE/dx");
150 mCalibObjects.mdEdxCalibContainer->setUsageOfFullGainMap(true);
151 }
152
153 if (mConfParam->gainCalibDisableCCDB) {
154 LOGP(info, "Disabling loading the TPC pad gain calibration from the CCDB");
155 mUpdateGainMapCCDB = false;
156 }
157
158 // load from file
159 if (!mConfParam->dEdxPolTopologyCorrFile.empty() || !mConfParam->dEdxCorrFile.empty() || !mConfParam->dEdxSplineTopologyCorrFile.empty()) {
160 if (!mConfParam->dEdxPolTopologyCorrFile.empty()) {
161 LOGP(info, "Loading dE/dx polynomial track topology correction from file: {}", mConfParam->dEdxPolTopologyCorrFile);
162 mCalibObjects.mdEdxCalibContainer->loadPolTopologyCorrectionFromFile(mConfParam->dEdxPolTopologyCorrFile);
163
164 LOGP(info, "Disabling loading of track topology correction using polynomials from CCDB as it was already loaded from input file");
165 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalTopologyPol);
166
167 if (std::filesystem::exists(mConfParam->thresholdCalibFile)) {
168 LOG(info) << "Loading tpc zero supression map from file " << mConfParam->thresholdCalibFile;
169 const auto* thresholdMap = o2::tpc::utils::readCalPads(mConfParam->thresholdCalibFile, "ThresholdMap")[0];
170 mCalibObjects.mdEdxCalibContainer->setZeroSupresssionThreshold(*thresholdMap);
171
172 LOGP(info, "Disabling loading of threshold map from CCDB as it was already loaded from input file");
173 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalThresholdMap);
174 } else {
175 if (not mConfParam->thresholdCalibFile.empty()) {
176 LOG(warn) << "Couldn't find tpc zero supression file " << mConfParam->thresholdCalibFile << ". Not setting any zero supression.";
177 }
178 LOG(info) << "Setting default zero supression map";
179 mCalibObjects.mdEdxCalibContainer->setDefaultZeroSupresssionThreshold();
180 }
181 } else if (!mConfParam->dEdxSplineTopologyCorrFile.empty()) {
182 LOGP(info, "Loading dE/dx spline track topology correction from file: {}", mConfParam->dEdxSplineTopologyCorrFile);
183 mCalibObjects.mdEdxCalibContainer->loadSplineTopologyCorrectionFromFile(mConfParam->dEdxSplineTopologyCorrFile);
184
185 LOGP(info, "Disabling loading of track topology correction using polynomials from CCDB as splines were loaded from input file");
186 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalTopologyPol);
187 }
188 if (!mConfParam->dEdxCorrFile.empty()) {
189 LOGP(info, "Loading dEdx correction from file: {}", mConfParam->dEdxCorrFile);
190 mCalibObjects.mdEdxCalibContainer->loadResidualCorrectionFromFile(mConfParam->dEdxCorrFile);
191
192 LOGP(info, "Disabling loading of residual gain calibration from CCDB as it was already loaded from input file");
193 mCalibObjects.mdEdxCalibContainer->disableCorrectionCCDB(o2::tpc::CalibsdEdx::CalTimeGain);
194 }
195 }
196
197 if (mConfParam->dEdxPolTopologyCorrFile.empty() && mConfParam->dEdxSplineTopologyCorrFile.empty()) {
198 // setting default topology correction to allocate enough memory
199 LOG(info) << "Setting default dE/dx polynomial track topology correction to allocate enough memory";
200 mCalibObjects.mdEdxCalibContainer->setDefaultPolTopologyCorrection();
201 }
202
203 GPUO2InterfaceConfiguration& config = *mConfig.get();
204 mConfig->configCalib.dEdxCalibContainer = mCalibObjects.mdEdxCalibContainer.get();
205
206 if (std::filesystem::exists(mConfParam->gainCalibFile)) {
207 LOG(info) << "Loading tpc gain correction from file " << mConfParam->gainCalibFile;
208 const auto* gainMap = o2::tpc::utils::readCalPads(mConfParam->gainCalibFile, "GainMap")[0];
209 mCalibObjects.mTPCPadGainCalib = GPUO2InterfaceUtils::getPadGainCalib(*gainMap);
210
211 LOGP(info, "Disabling loading the TPC gain correction map from the CCDB as it was already loaded from input file");
212 mUpdateGainMapCCDB = false;
213 } else {
214 if (not mConfParam->gainCalibFile.empty()) {
215 LOG(warn) << "Couldn't find tpc gain correction file " << mConfParam->gainCalibFile << ". Not applying any gain correction.";
216 }
217 mCalibObjects.mTPCPadGainCalib = GPUO2InterfaceUtils::getPadGainCalibDefault();
218 mCalibObjects.mTPCPadGainCalib->getGainCorrection(30, 5, 5);
219 }
220 mConfig->configCalib.tpcPadGain = mCalibObjects.mTPCPadGainCalib.get();
221
222 mTPCZSLinkMapping.reset(new TPCZSLinkMapping{tpc::Mapper::instance()});
223 mConfig->configCalib.tpcZSLinkMapping = mTPCZSLinkMapping.get();
224}
225
226void GPURecoWorkflowSpec::finaliseCCDBTPC(ConcreteDataMatcher& matcher, void* obj)
227{
228 const o2::tpc::CalibdEdxContainer* dEdxCalibContainer = mCalibObjects.mdEdxCalibContainer.get();
229
230 auto copyCalibsToBuffer = [this, dEdxCalibContainer]() {
231 if (!(mdEdxCalibContainerBufferNew)) {
232 mdEdxCalibContainerBufferNew = std::make_unique<o2::tpc::CalibdEdxContainer>();
233 mdEdxCalibContainerBufferNew->cloneFromObject(*dEdxCalibContainer, nullptr);
234 }
235 };
236
237 if (matcher == ConcreteDataMatcher(gDataOriginTPC, "PADGAINFULL", 0)) {
238 LOGP(info, "Updating gain map from CCDB");
239 const auto* gainMap = static_cast<o2::tpc::CalDet<float>*>(obj);
240
241 if (dEdxCalibContainer->isCorrectionCCDB(o2::tpc::CalibsdEdx::CalGainMap) && mSpecConfig.outputTracks) {
242 copyCalibsToBuffer();
243 const float minGain = 0;
244 const float maxGain = 2;
245 mdEdxCalibContainerBufferNew.get()->setGainMap(*gainMap, minGain, maxGain);
246 }
247
248 if (mUpdateGainMapCCDB && mSpecConfig.caClusterer) {
249 mTPCPadGainCalibBufferNew = GPUO2InterfaceUtils::getPadGainCalib(*gainMap);
250 }
251
252 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "PADGAINRESIDUAL", 0)) {
253 LOGP(info, "Updating residual gain map from CCDB");
254 copyCalibsToBuffer();
255 const auto* gainMapResidual = static_cast<std::unordered_map<std::string, o2::tpc::CalDet<float>>*>(obj);
256 const float minResidualGain = 0.7f;
257 const float maxResidualGain = 1.3f;
258 mdEdxCalibContainerBufferNew.get()->setGainMapResidual(gainMapResidual->at("GainMap"), minResidualGain, maxResidualGain);
259 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "PADTHRESHOLD", 0)) {
260 LOGP(info, "Updating threshold map from CCDB");
261 copyCalibsToBuffer();
262 const auto* thresholdMap = static_cast<std::unordered_map<std::string, o2::tpc::CalDet<float>>*>(obj);
263 mdEdxCalibContainerBufferNew.get()->setZeroSupresssionThreshold(thresholdMap->at("ThresholdMap"));
264 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "TOPOLOGYGAIN", 0) && !(dEdxCalibContainer->isTopologyCorrectionSplinesSet())) {
265 LOGP(info, "Updating Q topology correction from CCDB");
266 copyCalibsToBuffer();
267 const auto* topologyCorr = static_cast<o2::tpc::CalibdEdxTrackTopologyPolContainer*>(obj);
268 o2::tpc::CalibdEdxTrackTopologyPol calibTrackTopology;
269 calibTrackTopology.setFromContainer(*topologyCorr);
270 mdEdxCalibContainerBufferNew->setPolTopologyCorrection(calibTrackTopology);
271 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "TIMEGAIN", 0)) {
272 LOGP(info, "Updating residual gain correction from CCDB");
273 copyCalibsToBuffer();
274 const auto* residualCorr = static_cast<o2::tpc::CalibdEdxCorrection*>(obj);
275 mdEdxCalibContainerBufferNew->setResidualCorrection(*residualCorr);
276 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "IDCPADFLAGS", 0)) {
277 copyCalibsToBuffer();
278 const auto* padFlags = static_cast<o2::tpc::CalDet<o2::tpc::PadFlags>*>(obj);
279 mTPCDeadChannelMapCreator->setDeadChannelMapIDCPadStatus(*padFlags);
280 mTPCDeadChannelMapCreator->finalizeDeadChannelMap();
281 mdEdxCalibContainerBufferNew.get()->setDeadChannelMap(mTPCDeadChannelMapCreator->getDeadChannelMap());
282 LOGP(info, "Updating dead channel map with IDC pad flags: {} / {} dead pads from pad flags / total",
283 mTPCDeadChannelMapCreator->getDeadChannelMapIDC().getSum<int32_t>(), mTPCDeadChannelMapCreator->getDeadChannelMap().getSum<int32_t>());
284 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "TPCRUNINFO", 0)) {
285 copyCalibsToBuffer();
286 const auto* fee = static_cast<o2::tpc::FEEConfig*>(obj);
287 mTPCDeadChannelMapCreator->setDeadChannelMapFEEConfig(*fee);
288 mTPCDeadChannelMapCreator->finalizeDeadChannelMap();
289 mdEdxCalibContainerBufferNew.get()->setDeadChannelMap(mTPCDeadChannelMapCreator->getDeadChannelMap());
290 LOGP(info,
291 "Updating dead channel map with the FEE info (tag {}) loaded via TPCRUNINFO"
292 " for creation time {}: {} / {} dead pads from FEE info / total, with",
293 std::underlying_type_t<o2::tpc::FEEConfig::Tags>(fee->tag), mCreationForCalib,
294 mTPCDeadChannelMapCreator->getDeadChannelMapFEE().getSum<int32_t>(), mTPCDeadChannelMapCreator->getDeadChannelMap().getSum<int32_t>());
295 } else if (mTPCVDriftHelper->accountCCDBInputs(matcher, obj)) {
296 } else if (mCalibObjects.mFastTransformHelper->accountCCDBInputs(matcher, obj)) {
297 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "NNCLUSTERIZER_C1", 0)) {
298 mConfig->configCalib.nnClusterizerNetworks[0] = static_cast<o2::tpc::ORTRootSerializer*>(obj);
299 LOG(info) << "(NN CLUS) " << (mConfig->configCalib.nnClusterizerNetworks[0])->getONNXModelSize() << " bytes loaded for NN clusterizer: classification_c1";
300 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "NNCLUSTERIZER_C2", 0)) {
301 mConfig->configCalib.nnClusterizerNetworks[0] = static_cast<o2::tpc::ORTRootSerializer*>(obj);
302 LOG(info) << "(NN CLUS) " << (mConfig->configCalib.nnClusterizerNetworks[0])->getONNXModelSize() << " bytes loaded for NN clusterizer: classification_c2";
303 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "NNCLUSTERIZER_R1", 0)) {
304 mConfig->configCalib.nnClusterizerNetworks[1] = static_cast<o2::tpc::ORTRootSerializer*>(obj);
305 LOG(info) << "(NN CLUS) " << (mConfig->configCalib.nnClusterizerNetworks[1])->getONNXModelSize() << " bytes loaded for NN clusterizer: regression_c1";
306 } else if (matcher == ConcreteDataMatcher(gDataOriginTPC, "NNCLUSTERIZER_R2", 0)) {
307 mConfig->configCalib.nnClusterizerNetworks[2] = static_cast<o2::tpc::ORTRootSerializer*>(obj);
308 LOG(info) << "(NN CLUS) " << (mConfig->configCalib.nnClusterizerNetworks[2])->getONNXModelSize() << " bytes loaded for NN clusterizer: regression_c2";
309 }
310}
311
312template <>
313bool GPURecoWorkflowSpec::fetchCalibsCCDBTPC<GPUCalibObjectsConst>(ProcessingContext& pc, GPUCalibObjectsConst& newCalibObjects, calibObjectStruct& oldCalibObjects)
314{
315 // update calibrations for clustering and tracking
316 mCreationForCalib = pc.services().get<o2::framework::TimingInfo>().creation;
317 bool mustUpdate = false;
318 if ((mSpecConfig.outputTracks || mSpecConfig.caClusterer) && !mConfParam->disableCalibUpdates) {
319 const o2::tpc::CalibdEdxContainer* dEdxCalibContainer = mCalibObjects.mdEdxCalibContainer.get();
320
321 // this calibration is defined for clustering and tracking
322 if (dEdxCalibContainer->isCorrectionCCDB(o2::tpc::CalibsdEdx::CalGainMap) || mUpdateGainMapCCDB) {
323 pc.inputs().get<o2::tpc::CalDet<float>*>("tpcgain");
324 }
325
326 if (mSpecConfig.outputTracks || mSpecConfig.caClusterer) {
327 mTPCCutAtTimeBin = mConfParam->overrideTPCTimeBinCur > 0 ? mConfParam->overrideTPCTimeBinCur : pc.inputs().get<o2::tpc::AltroSyncSignal*>("tpcaltrosync")->getTB2Cut(pc.services().get<o2::framework::TimingInfo>().tfCounter);
328 }
329
330 // these calibrations are only defined for the tracking
331 if (mSpecConfig.outputTracks) {
332 // update the calibration objects in case they changed in the CCDB
334 pc.inputs().get<std::unordered_map<std::string, o2::tpc::CalDet<float>>*>("tpcthreshold");
335 }
336
337 if (mTPCDeadChannelMapCreator->useSource(tpc::SourcesDeadMap::IDCPadStatus)) {
338 pc.inputs().get<o2::tpc::CalDet<tpc::PadFlags>*>("tpcidcpadflags");
339 }
340
341 if (mTPCDeadChannelMapCreator->useSource(tpc::SourcesDeadMap::FEEConfig)) {
342 pc.inputs().get<o2::tpc::FEEConfig*>("tpcruninfo");
343 }
344
346 pc.inputs().get<std::unordered_map<std::string, o2::tpc::CalDet<float>>*>("tpcgainresidual");
347 }
348
349 if (dEdxCalibContainer->isCorrectionCCDB(o2::tpc::CalibsdEdx::CalTopologyPol)) {
351 }
352
353 if (dEdxCalibContainer->isCorrectionCCDB(o2::tpc::CalibsdEdx::CalTimeGain)) {
354 pc.inputs().get<o2::tpc::CalibdEdxCorrection*>("tpctimegain");
355 }
356
357 if (mSpecConfig.outputTracks) {
358 mTPCVDriftHelper->extractCCDBInputs(pc);
359 mCalibObjects.mFastTransformHelper->extractCCDBInputs(pc);
360 }
361 if (mTPCVDriftHelper->isUpdated() || mCalibObjects.mFastTransformHelper->isUpdated()) {
362 const auto& vd = mTPCVDriftHelper->getVDriftObject();
363 LOGP(info, "Updating{}TPC fast transform map and/or VDrift factor of {} wrt reference {} and TDrift offset {} wrt reference {} from source {}",
364 mCalibObjects.mFastTransformHelper->isUpdated() ? " new " : " old ",
365 vd.corrFact, vd.refVDrift, vd.timeOffsetCorr, vd.refTimeOffset, mTPCVDriftHelper->getSourceName());
366
367 bool mustUpdateHelper = false;
368 if (mTPCVDriftHelper->isUpdated() || mCalibObjects.mFastTransformHelper->isUpdatedMap()) {
369 oldCalibObjects.mFastTransform = std::move(mCalibObjects.mFastTransform);
370 mCalibObjects.mFastTransform.reset(new TPCFastTransform);
371 mCalibObjects.mFastTransform->cloneFromObject(*mCalibObjects.mFastTransformHelper->getCorrMap(), nullptr);
372 o2::tpc::TPCFastTransformHelperO2::instance()->updateCalibration(*mCalibObjects.mFastTransform, 0, vd.corrFact, vd.refVDrift, vd.getTimeOffset());
373 newCalibObjects.fastTransform = mCalibObjects.mFastTransform.get();
374 mustUpdateHelper = true;
375 }
376 if (mTPCVDriftHelper->isUpdated() || mCalibObjects.mFastTransformHelper->isUpdatedMapRef()) {
377 oldCalibObjects.mFastTransformRef = std::move(mCalibObjects.mFastTransformRef);
378 mCalibObjects.mFastTransformRef.reset(new TPCFastTransform);
379 mCalibObjects.mFastTransformRef->cloneFromObject(*mCalibObjects.mFastTransformHelper->getCorrMapRef(), nullptr);
380 o2::tpc::TPCFastTransformHelperO2::instance()->updateCalibration(*mCalibObjects.mFastTransformRef, 0, vd.corrFact, vd.refVDrift, vd.getTimeOffset());
381 newCalibObjects.fastTransformRef = mCalibObjects.mFastTransformRef.get();
382 mustUpdateHelper = true;
383 }
384 if (mTPCVDriftHelper->isUpdated() || mCalibObjects.mFastTransformHelper->isUpdatedMapMShape()) {
385 oldCalibObjects.mFastTransformMShape = std::move(mCalibObjects.mFastTransformMShape);
386 mCalibObjects.mFastTransformMShape.reset(new TPCFastTransform);
387 mCalibObjects.mFastTransformMShape->cloneFromObject(*mCalibObjects.mFastTransformHelper->getCorrMapMShape(), nullptr);
388 o2::tpc::TPCFastTransformHelperO2::instance()->updateCalibration(*mCalibObjects.mFastTransformMShape, 0, vd.corrFact, vd.refVDrift, vd.getTimeOffset());
389 newCalibObjects.fastTransformMShape = mCalibObjects.mFastTransformMShape.get();
390 mustUpdateHelper = true;
391 }
392 if (mustUpdateHelper || mCalibObjects.mFastTransformHelper->isUpdatedLumi()) {
393 oldCalibObjects.mFastTransformHelper = std::move(mCalibObjects.mFastTransformHelper);
394 mCalibObjects.mFastTransformHelper.reset(new o2::tpc::CorrectionMapsLoader);
395 mCalibObjects.mFastTransformHelper->copySettings(*oldCalibObjects.mFastTransformHelper);
396 mCalibObjects.mFastTransformHelper->setCorrMap(mCalibObjects.mFastTransform.get());
397 mCalibObjects.mFastTransformHelper->setCorrMapRef(mCalibObjects.mFastTransformRef.get());
398 mCalibObjects.mFastTransformHelper->setCorrMapMShape(mCalibObjects.mFastTransformMShape.get());
399 mCalibObjects.mFastTransformHelper->acknowledgeUpdate();
400 newCalibObjects.fastTransformHelper = mCalibObjects.mFastTransformHelper.get();
401 }
402 mustUpdate = true;
403 mTPCVDriftHelper->acknowledgeUpdate();
404 mCalibObjects.mFastTransformHelper->acknowledgeUpdate();
405 }
406 }
407
408 if (mdEdxCalibContainerBufferNew) {
409 oldCalibObjects.mdEdxCalibContainer = std::move(mCalibObjects.mdEdxCalibContainer);
410 mCalibObjects.mdEdxCalibContainer = std::move(mdEdxCalibContainerBufferNew);
411 newCalibObjects.dEdxCalibContainer = mCalibObjects.mdEdxCalibContainer.get();
412 mustUpdate = true;
413 }
414
415 if (mTPCPadGainCalibBufferNew) {
416 oldCalibObjects.mTPCPadGainCalib = std::move(mCalibObjects.mTPCPadGainCalib);
417 mCalibObjects.mTPCPadGainCalib = std::move(mTPCPadGainCalibBufferNew);
418 newCalibObjects.tpcPadGain = mCalibObjects.mTPCPadGainCalib.get();
419 mustUpdate = true;
420 }
421
422 // NN clusterizer networks
423 if (mSpecConfig.nnLoadFromCCDB) {
424
425 if (mSpecConfig.nnEvalMode[0] == "c1") {
426 pc.inputs().get<o2::tpc::ORTRootSerializer*>("nn_classification_c1");
427 } else if (mSpecConfig.nnEvalMode[0] == "c2") {
428 pc.inputs().get<o2::tpc::ORTRootSerializer*>("nn_classification_c2");
429 }
430
431 pc.inputs().get<o2::tpc::ORTRootSerializer*>("nn_regression_c1");
432 if (mSpecConfig.nnEvalMode[1] == "r2") {
433 pc.inputs().get<o2::tpc::ORTRootSerializer*>("nn_regression_c2");
434 }
435 }
436 }
437 return mustUpdate;
438}
439
440void GPURecoWorkflowSpec::doTrackTuneTPC(GPUTrackingInOutPointers& ptrs, char* buffout)
441{
443 const auto& trackTune = TrackTunePar::Instance();
444 if (ptrs.nOutputTracksTPCO2 && trackTune.sourceLevelTPC &&
445 (trackTune.useTPCInnerCorr || trackTune.useTPCOuterCorr ||
446 trackTune.tpcCovInnerType != TrackTunePar::AddCovType::Disable || trackTune.tpcCovOuterType != TrackTunePar::AddCovType::Disable)) {
447 if (((const void*)ptrs.outputTracksTPCO2) != ((const void*)buffout)) {
448 throw std::runtime_error("Buffer does not match span");
449 }
450 o2::tpc::TrackTPC* tpcTracks = reinterpret_cast<o2::tpc::TrackTPC*>(buffout);
451 float scale = mCalibObjects.mFastTransformHelper->getInstLumiCTP();
452 if (scale < 0.f) {
453 scale = 0.f;
454 }
455 auto diagInner = trackTune.getCovInnerTotal(scale);
456 auto diagOuter = trackTune.getCovOuterTotal(scale);
457
458 for (uint32_t itr = 0; itr < ptrs.nOutputTracksTPCO2; itr++) {
459 auto& trc = tpcTracks[itr];
460 if (trackTune.useTPCInnerCorr) {
461 trc.updateParams(trackTune.tpcParInner);
462 }
463 if (trackTune.tpcCovInnerType != TrackTunePar::AddCovType::Disable) {
464 trc.updateCov(diagInner, trackTune.tpcCovInnerType == TrackTunePar::AddCovType::WithCorrelations);
465 }
466 if (trackTune.useTPCOuterCorr) {
467 trc.getParamOut().updateParams(trackTune.tpcParOuter);
468 }
469 if (trackTune.tpcCovOuterType != TrackTunePar::AddCovType::Disable) {
470 trc.getParamOut().updateCov(diagOuter, trackTune.tpcCovOuterType == TrackTunePar::AddCovType::WithCorrelations);
471 }
472 }
473 }
474}
475
476} // namespace o2::gpu
Definition of the timebin from which syncronization starts.
Simple interface to the CDB manager.
Definition of container class for dE/dx corrections.
Class of a TPC cluster in TPC-native coordinates (row, time)
Container to store compressed TPC cluster data.
A const (ready only) version of MCTruthContainer.
Helper class to access correction maps.
Helper class to access load maps from CCDB.
Wrapper container for different reconstructed object types.
Definition of the TPC Digit.
Helper class for memory management of TPC Data Formats, external from the actual data type classes to...
Definition of class for writing debug informations.
Definition of the GeometryManager class.
Helper for geometry and GRP related CCDB requests.
This file provides the structs for storing the factorized IDC values and fourier coefficients to be s...
A helper class to iteratate over all parts of all input routes.
Declarations for the wrapper for the set of cylindrical material layers.
Definition of the Names Generator class.
Class to serialize ONNX objects for ROOT snapshots of CCDB objects at runtime.
Utilities for parsing of data sequences.
Type wrappers for enfording a specific serialization method.
class to create TPC fast transformation
Definition of TPCFastTransform class.
Wrapper class for TPC CA Tracker algorithm.
Configurable params for tracks ad hoc tuning.
Helper class to extract VDrift from different sources.
Helper class to obtain TPC clusters / digits / labels from DPL.
Definitions of TPC Zero Suppression Data Headers.
decltype(auto) get(R binding, int part=0) const
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static std::unique_ptr< TPCPadGainCalib > getPadGainCalibDefault()
static std::unique_ptr< TPCPadGainCalib > getPadGainCalib(const o2::tpc::CalDet< float > &in)
bool isCorrectionCCDB(const CalibsdEdx calib) const
bool isTopologyCorrectionSplinesSet() const
returns status if the spline correction is set
calibration class for the track topology correction of the dE/dx using multvariate polynomials
void setFromContainer(const CalibdEdxTrackTopologyPolContainer &container)
static Mapper & instance(const std::string mappingDir="")
Definition Mapper.h:44
int updateCalibration(TPCFastTransform &transform, Long_t TimeStamp, float vDriftFactor=1.f, float vDriftRef=0.f, float driftTimeOffset=0.f)
Updates the transformation with the new time stamp.
static TPCFastTransformHelperO2 * instance()
Singleton.
Definition of a container to keep/associate and arbitrary number of labels associated to an index wit...
ConcreteParserVariants< PageSize, BOUNDS_CHECKS > create(T const *buffer, size_t size)
create a raw parser depending on version of RAWDataHeader found at beginning of data
Definition RawParser.h:378
Defining PrimaryVertex explicitly as messageable.
O2 data header classes and API, v0.1.
Definition DetID.h:49
std::vector< CalPad * > readCalPads(const std::string_view fileName, const std::vector< std::string > &calPadNames)
Definition Utils.cxx:190
@ CalTimeGain
flag for residual dE/dx time dependent gain correction
@ CalTopologyPol
flag for a topology correction using polynomials
@ CalResidualGainMap
flag for applying residual gain map
@ CalThresholdMap
flag for using threshold map
@ CalGainMap
flag for using the gain map to get the correct cluster charge
@ FEEConfig
use fee config
@ IDCPadStatus
use idc pad status map
S< o2::tpc::CalibdEdxContainer >::type * dEdxCalibContainer
S< TPCFastTransform >::type * fastTransform
S< TPCPadGainCalib >::type * tpcPadGain
S< CorrectionMapsHelper >::type * fastTransformHelper
S< TPCFastTransform >::type * fastTransformRef
S< TPCFastTransform >::type * fastTransformMShape
std::vector< std::string > nnEvalMode
const o2::tpc::TrackTPC * outputTracksTPCO2
simple struct to enable writing the MultivariatePolynomialCT to file
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"