Project
Loading...
Searching...
No Matches
EMCALChannelCalibratorSpec.h
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
17
18#ifndef O2_CALIBRATION_EMCALCHANNEL_CALIBRATOR_H
19#define O2_CALIBRATION_EMCALCHANNEL_CALIBRATOR_H
20
27#include "Framework/Task.h"
31#include "CCDB/CcdbApi.h"
32#include "CCDB/CcdbObjectInfo.h"
38
39// for time measurements
40#include <chrono>
41#include <random>
42#include <optional>
43
44using namespace o2::framework;
45
46namespace o2
47{
48namespace calibration
49{
50
52{
53 public:
54 CalibInputDownsampler() { initSeed(); }
56
57 void setSamplingFraction(float samplingFraction) { mSamplingFraction = samplingFraction; }
59 {
60 auto rnr = mSampler(mRandomGenerator);
61 return rnr < mSamplingFraction;
62 }
63
64 private:
65 void initSeed()
66 {
67 auto now = std::chrono::system_clock::now().time_since_epoch().count();
68 std::seed_seq randomseed{uint32_t(now & 0xffffffff), uint32_t(now >> 32)};
69 mRandomGenerator.seed(randomseed);
70 }
71 std::mt19937_64 mRandomGenerator;
72 std::uniform_real_distribution<float> mSampler{0, 1};
73 float mSamplingFraction = 1;
74};
75
77{
78
80
81 public:
82 EMCALChannelCalibDevice(std::shared_ptr<o2::base::GRPGeomRequest> req, bool params, std::string calibType, bool rejCalibTrg, bool rejL0Trig, bool applyGainCalib) : mCCDBRequest(req), mLoadCalibParamsFromCCDB(params), mCalibType(calibType), mRejectCalibTriggers(rejCalibTrg), mRejectL0Triggers(rejL0Trig), mApplyGainCalib(applyGainCalib) {}
83
85 {
87
88 mCalibExtractor = std::make_shared<o2::emcal::EMCALCalibExtractor>();
89
90 if (mCalibType.find("time") != std::string::npos) { // time calibration
91 isBadChannelCalib = false;
92 if (!mTimeCalibrator) {
93 mTimeCalibrator = std::make_unique<o2::emcal::EMCALChannelCalibrator<o2::emcal::EMCALTimeCalibData, o2::emcal::TimeCalibrationParams>>();
94 }
95 mTimeCalibrator->SetCalibExtractor(mCalibExtractor);
96 mTimeCalibrator->setSavedSlotAllowed(EMCALCalibParams::Instance().setSavedSlotAllowed_EMC);
97 mTimeCalibrator->setLoadAtSOR(EMCALCalibParams::Instance().setSavedSlotAllowedSOR_EMC);
98 mTimeCalibrator->setSaveFileName("emc-time-calib.root");
99 } else { // bad cell calibration
100 isBadChannelCalib = true;
101 if (!mBadChannelCalibrator) {
102 mBadChannelCalibrator = std::make_unique<o2::emcal::EMCALChannelCalibrator<o2::emcal::EMCALChannelData, o2::emcal::BadChannelMap>>();
103 }
104 mBadChannelCalibrator->SetCalibExtractor(mCalibExtractor);
105 mBadChannelCalibrator->setSavedSlotAllowed(EMCALCalibParams::Instance().setSavedSlotAllowed_EMC);
106 mBadChannelCalibrator->setLoadAtSOR(EMCALCalibParams::Instance().setSavedSlotAllowedSOR_EMC);
107 mBadChannelCalibrator->setSaveFileName("emc-channel-calib.root");
108 }
109 }
110
111 //_________________________________________________________________
112 void finaliseCCDB(o2::framework::ConcreteDataMatcher& matcher, void* obj) final
113 {
115 // check if calib params need to be updated
116 if (matcher == ConcreteDataMatcher("EMC", "EMCALCALIBPARAM", 0)) {
117 LOG(info) << "EMCal CalibParams updated";
119 }
120 if (matcher == ConcreteDataMatcher("EMC", "SCALEFACTORS", 0)) {
121 if (mBadChannelCalibrator && EMCALCalibParams::Instance().useScaledHisto_bc) {
122 LOG(info) << "Configuring scale factors for bad channel map";
123 mBadChannelCalibrator->getCalibExtractor()->setBCMScaleFactors(reinterpret_cast<o2::emcal::EMCALChannelScaleFactors*>(obj));
124 mScaleFactorsInitialized = true;
125 }
126 }
127 if (mApplyGainCalib && matcher == ConcreteDataMatcher("EMC", "EMCGAINCALIB", 0)) {
128 if (mBadChannelCalibrator) {
129 LOG(info) << "Configuring gain calib factors for bad channel";
130 if (mBadChannelCalibrator->setGainCalibrationFactors(reinterpret_cast<o2::emcal::GainCalibrationFactors*>(obj))) {
131 mGainCalibFactorsInitialized = true;
132 }
133 }
134 if (mTimeCalibrator) {
135 LOG(info) << "Configuring gain calib factors for time calib";
136 if (mTimeCalibrator->setGainCalibrationFactors(reinterpret_cast<o2::emcal::GainCalibrationFactors*>(obj))) {
137 mGainCalibFactorsInitialized = true;
138 }
139 }
140 }
141 if (mRejectL0Triggers && matcher == ConcreteDataMatcher("CTP", "CTPCONFIG", 0)) {
142 // clear current class mask and prepare to fill in the updated values
143 // The trigger names are seperated by a ":" in one string in the calib params
144 mSelectedClassMasks.clear();
145 std::string strSelClassMasks = EMCALCalibParams::Instance().selectedClassMasks;
146 std::string delimiter = ":";
147 size_t pos = 0;
148 std::vector<std::string> vSelMasks;
149 while ((pos = strSelClassMasks.find(delimiter)) != std::string::npos) {
150 vSelMasks.push_back(strSelClassMasks.substr(0, pos));
151 strSelClassMasks.erase(0, pos + delimiter.length());
152 }
153 vSelMasks.push_back(strSelClassMasks);
154
155 auto ctpconf = reinterpret_cast<o2::ctp::CTPConfiguration*>(obj);
156
157 for (auto& cls : ctpconf->getCTPClasses()) {
158 LOG(debug) << "CTP class: " << cls.name << "\t " << cls.classMask;
159
160 if (std::find(vSelMasks.begin(), vSelMasks.end(), cls.name) != vSelMasks.end()) {
161 mSelectedClassMasks.push_back(cls.classMask);
162 LOG(info) << "Setting selected class mask " << cls.name << " to bit " << cls.classMask;
163 }
164 }
165 }
166 }
167
168 //_________________________________________________________________
170 {
171 if (EMCALCalibParams::Instance().enableTimeProfiling) {
172 timeMeas[0] = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
173 }
174
175 const auto& tinfo = pc.services().get<o2::framework::TimingInfo>();
176 if (tinfo.globalRunNumberChanged) { // new run is starting
177 mRunStopRequested = false;
178 }
179 if (mRunStopRequested) {
180 return;
181 }
182
184 if (mTimeCalibrator) {
185 o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mTimeCalibrator->getCurrentTFInfo());
186 } else if (mBadChannelCalibrator) {
187 o2::base::TFIDInfoHelper::fillTFIDInfo(pc, mBadChannelCalibrator->getCurrentTFInfo());
188 }
189
190 if (mLoadCalibParamsFromCCDB) {
191 // for reading the calib objects from the CCDB
192 pc.inputs().get<o2::emcal::EMCALCalibParams*>("EMC_CalibParam");
193 }
194
195 if (mBadChannelCalibrator && EMCALCalibParams::Instance().useScaledHisto_bc && !mScaleFactorsInitialized) {
196 // Trigger reading the scale factors from the CCDB (Bad channel calib only)
197 pc.inputs().get<o2::emcal::EMCALChannelScaleFactors*>("EMC_Scalefactors");
198 }
199
200 // prepare CTPConfiguration such that it can be loaded in finalise ccdb
201 if (mRejectL0Triggers) {
203 }
204
205 if (!mIsConfigured) {
206 // configure calibrators (after calib params are loaded from the CCDB)
207 // long tsMS = o2::base::GRPGeomHelper::instance().getOrbitResetTimeMS() + pc.services().get<o2::framework::TimingInfo>().firstTForbit * o2::constants::lhc::LHCOrbitMUS / 1000; // this reads the ts from the data.
208 long tsMS = o2::ccdb::getCurrentTimestamp();
209 configureCalibrators(tsMS);
210 mIsConfigured = true;
211 }
212
213 if (mApplyGainCalib && !mGainCalibFactorsInitialized) {
214 // process dummy data with no cells to create a slot
215 std::vector<o2::emcal::Cell> cellDummyData(0);
216 if (isBadChannelCalib) {
217 mBadChannelCalibrator->process(cellDummyData);
218 } else {
219 mTimeCalibrator->process(cellDummyData);
220 }
221 // for reading the calib objects from the CCDB
223 }
224
225 float samplingFraction = isBadChannelCalib ? EMCALCalibParams::Instance().fractionEvents_bc : EMCALCalibParams::Instance().fractionEvents_tc;
226 if (samplingFraction < 1) {
227 if (!mDownsampler) {
228 mDownsampler = std::make_unique<CalibInputDownsampler>();
229 }
230 mDownsampler->setSamplingFraction(samplingFraction);
231 }
232
233 using ctpDigitsType = std::decay_t<decltype(pc.inputs().get<gsl::span<o2::ctp::CTPDigit>>(getCTPDigitsBinding()))>;
234 std::optional<ctpDigitsType> ctpDigits;
235 if (mRejectL0Triggers) {
236 ctpDigits = pc.inputs().get<gsl::span<o2::ctp::CTPDigit>>(getCTPDigitsBinding());
237 }
238
239 // reset EOR behaviour
240 if (mTimeCalibrator) {
241 if (mTimeCalibrator->getSaveAtEOR())
242 mTimeCalibrator->setSaveAtEOR(false);
243 } else if (mBadChannelCalibrator) {
244 if (mBadChannelCalibrator->getSaveAtEOR())
245 mBadChannelCalibrator->setSaveAtEOR(false);
246 }
247
248 // prepare CTP information to reject EMCal triggers
249 uint64_t classMaskCTP = 0;
250 std::unordered_set<int64_t> numBCAccepted;
251 if (mRejectL0Triggers) {
252 for (auto& ctpDigit : *ctpDigits) {
253 // obtain trigger mask that belongs to the selected bc
254 classMaskCTP = ctpDigit.CTPClassMask.to_ulong();
255 // now check if min bias trigger is not in mask
256 for (const uint64_t& selectedClassMask : mSelectedClassMasks) {
257 if ((classMaskCTP & selectedClassMask) != 0) {
258 LOG(debug) << "classmask " << selectedClassMask << " added for the bc " << ctpDigit.intRecord.toLong() + EMCALCalibParams::Instance().bcShiftCTP;
259 numBCAccepted.insert(ctpDigit.intRecord.toLong() + EMCALCalibParams::Instance().bcShiftCTP);
260 }
261 }
262 }
263 }
264
265 auto tfcounter = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get(getCellBinding()).header)->startTime;
266
267 auto data = pc.inputs().get<gsl::span<o2::emcal::Cell>>(getCellBinding());
268
269 auto InputTriggerRecord = pc.inputs().get<gsl::span<o2::emcal::TriggerRecord>>(getCellTriggerRecordBinding());
270 LOG(debug) << "[EMCALCalibrator - run] Received " << InputTriggerRecord.size() << " Trigger Records, running calibration ...";
271
272 LOG(debug) << "Processing TF " << tfcounter << " with " << data.size() << " cells";
273
274 // call process for every event in the trigger record to ensure correct event counting for the calibration.
275 for (const auto& trg : InputTriggerRecord) {
276 if (!trg.getNumberOfObjects()) {
277 continue;
278 }
279 // reject calibration trigger from the calibration
280 if (mRejectCalibTriggers) {
281 LOG(debug) << "Trigger: " << trg.getTriggerBits() << " o2::trigger::Cal " << o2::trigger::Cal;
282 if (trg.getTriggerBits() & o2::trigger::Cal) {
283 LOG(debug) << "skipping triggered events due to wrong trigger (no Physics trigger)";
284 continue;
285 }
286 }
287
288 // reject all triggers that are not included in the classMask (typically only EMC min. bias should be accepted)
289 if (mRejectL0Triggers) {
290 if (numBCAccepted.find(trg.getBCData().toLong()) == numBCAccepted.end()) {
291 LOG(debug) << "correct trigger not found, rejecting event";
292 continue;
293 }
294 }
295
296 if (mDownsampler && !mDownsampler->acceptEvent()) {
297 continue;
298 }
299 gsl::span<const o2::emcal::Cell> eventData(data.data() + trg.getFirstEntry(), trg.getNumberOfObjects());
300
301 // fast calibration
302 if (EMCALCalibParams::Instance().enableFastCalib) {
303 LOG(debug) << "fast calib not yet available!";
304 // normal calibration procedure
305 } else {
306 if (isBadChannelCalib) {
307 mBadChannelCalibrator->process(eventData);
308 } else {
309 mTimeCalibrator->process(eventData);
310 }
311 }
312 }
313 static bool firstCall = true;
314 if (firstCall) {
315 firstCall = false;
316 if (mTimeCalibrator) {
317 mTimeCalibrator->loadSavedSlot();
318 } else if (mBadChannelCalibrator) {
319 mBadChannelCalibrator->loadSavedSlot();
320 }
321 }
322
323 if (pc.transitionState() == TransitionHandlingState::Requested) {
324 LOG(debug) << "Run stop requested, finalizing";
325 mRunStopRequested = true;
326 if (isBadChannelCalib) {
327 mBadChannelCalibrator->setSaveAtEOR(true);
328 mBadChannelCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF);
329 } else {
330 mTimeCalibrator->setSaveAtEOR(true);
331 mTimeCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF);
332 }
333 }
334
335 if (isBadChannelCalib) {
336 sendOutput<o2::emcal::BadChannelMap>(pc.outputs());
337 } else {
338 sendOutput<o2::emcal::TimeCalibrationParams>(pc.outputs());
339 }
340 if (EMCALCalibParams::Instance().enableTimeProfiling) {
341 timeMeas[1] = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
342 LOG(info) << "end of run function. Time: " << timeMeas[1] - timeMeas[0] << " [ns] for " << InputTriggerRecord.size() << " events";
343 }
344 }
345
347 {
348 if (mRunStopRequested) {
349 return;
350 }
351 if (isBadChannelCalib) {
352 mBadChannelCalibrator->setSaveAtEOR(true);
353 mBadChannelCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF);
354 sendOutput<o2::emcal::BadChannelMap>(ec.outputs());
355 } else {
356 mTimeCalibrator->setSaveAtEOR(true);
357 mTimeCalibrator->checkSlotsToFinalize(o2::calibration::INFINITE_TF);
358 sendOutput<o2::emcal::TimeCalibrationParams>(ec.outputs());
359 }
360 mRunStopRequested = true;
361 }
362
363 static const char* getCellBinding() { return "EMCCells"; }
364 static const char* getCellTriggerRecordBinding() { return "EMCCellsTrgR"; }
365 static const char* getCTPDigitsBinding() { return "CTPDigits"; }
366 static const char* getCTPConfigBinding() { return "CTPConfig"; }
367 static const char* getGainCalibBinding() { return "EMCGainCalib"; }
368
369 private:
370 std::unique_ptr<o2::emcal::EMCALChannelCalibrator<o2::emcal::EMCALChannelData, o2::emcal::BadChannelMap>> mBadChannelCalibrator;
371 std::unique_ptr<o2::emcal::EMCALChannelCalibrator<o2::emcal::EMCALTimeCalibData, o2::emcal::TimeCalibrationParams>> mTimeCalibrator;
372 std::shared_ptr<o2::emcal::EMCALCalibExtractor> mCalibExtractor;
373 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
374 std::string mCalibType;
375 bool mIsConfigured = false;
376 bool mScaleFactorsInitialized = false;
377 bool isBadChannelCalib = true;
378 bool mLoadCalibParamsFromCCDB = true;
379 bool mRejectCalibTriggers = true;
380 bool mRejectL0Triggers = true;
381 bool mApplyGainCalib = true;
382 bool mGainCalibFactorsInitialized = false;
383 bool mRunStopRequested = false;
384 std::array<double, 2> timeMeas;
385 std::vector<uint64_t> mSelectedClassMasks = {};
386 std::unique_ptr<CalibInputDownsampler> mDownsampler;
387
388 //________________________________________________________________
389 template <typename DataOutput>
390 void sendOutput(DataAllocator& output)
391 {
392 // extract CCDB infos and calibration objects, convert it to TMemFile and send them to the output
393 // TODO in principle, this routine is generic, can be moved to Utils.h
395
396 // we need this to be a vector of bad channel maps or time params, we will probably need to create this?
397 std::vector<DataOutput> payloadVec;
398 std::vector<o2::ccdb::CcdbObjectInfo> infoVec;
399 if constexpr (std::is_same<DataOutput, o2::emcal::TimeCalibrationParams>::value) {
400 payloadVec = mTimeCalibrator->getOutputVector();
401 infoVec = mTimeCalibrator->getInfoVector();
402 } else {
403 payloadVec = mBadChannelCalibrator->getOutputVector();
404 infoVec = mBadChannelCalibrator->getInfoVector();
405 }
406 // use non-const version as we update it
407 assert(payloadVec.size() == infoVec.size());
408 for (uint32_t i = 0; i < payloadVec.size(); i++) {
409 auto& w = infoVec[i];
410 auto image = o2::ccdb::CcdbApi::createObjectImage(&payloadVec[i], &w);
411 if constexpr (std::is_same<DataOutput, o2::emcal::TimeCalibrationParams>::value) {
412 LOG(info) << "Sending object " << w.getPath() << "/" << w.getFileName() << " of size " << image->size()
413 << " bytes, valid for " << w.getStartValidityTimestamp() << " : " << w.getEndValidityTimestamp();
414 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_TIMECALIB", i}, *image.get()); // vector<char>
415 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_TIMECALIB", i}, w); // root-serialized
416 } else {
417 LOG(info) << "Sending object " << w.getPath() << "/" << w.getFileName() << " of size " << image->size()
418 << " bytes, valid for " << w.getStartValidityTimestamp() << " : " << w.getEndValidityTimestamp();
419 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_BADCHANNELS", i}, *image.get()); // vector<char>
420 output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_BADCHANNELS", i}, w); // root-serialized
421 }
422 }
423 if (payloadVec.size()) {
424 if constexpr (std::is_same<DataOutput, o2::emcal::TimeCalibrationParams>::value) {
425 mTimeCalibrator->initOutput(); // reset the outputs once they are already sent
426 } else {
427 mBadChannelCalibrator->initOutput(); // reset the outputs once they are already sent
428 }
429 }
430 }
431
433 void configureCalibrators(long ts)
434 {
435 auto currFill = o2::base::GRPGeomHelper::instance().getGRPLHCIF()->getFillNumber();
436 auto runtype = o2::base::GRPGeomHelper::instance().getGRPECS()->getRunType();
437 LOG(debug) << "currFill " << currFill << " runtype " << runtype;
438
439 if (mTimeCalibrator) {
440 LOG(info) << "Configuring time calibrator";
441 mTimeCalibrator->setSlotLength(EMCALCalibParams::Instance().slotLength_tc);
442 if (EMCALCalibParams::Instance().slotLength_tc == 0) {
443 // for infinite slot length do not check if there is enough statistics after every TF
444 mTimeCalibrator->setCheckIntervalInfiniteSlot(1e5);
445 }
446 if (EMCALCalibParams::Instance().UpdateAtEndOfRunOnly_tc) {
447 mTimeCalibrator->setUpdateAtTheEndOfRunOnly();
448 }
449 mTimeCalibrator->setSaveFileName("emc-time-calib-" + std::to_string(runtype) + ".root");
450 mTimeCalibrator->setFillNr(currFill);
451 mTimeCalibrator->setRunType(runtype);
452 mTimeCalibrator->setCurrTSInHours(static_cast<int>(ts / o2::ccdb::CcdbObjectInfo::HOUR));
453 }
454 if (mBadChannelCalibrator) {
455 LOG(info) << "Configuring bad channel calibrator";
456 mBadChannelCalibrator->setSlotLength(EMCALCalibParams::Instance().slotLength_bc);
457 if (EMCALCalibParams::Instance().slotLength_bc == 0) {
458 // for infinite slot length do not check if there is enough statistics after every TF
459 mBadChannelCalibrator->setCheckIntervalInfiniteSlot(1e5);
460 }
461 if (EMCALCalibParams::Instance().UpdateAtEndOfRunOnly_bc) {
462 mBadChannelCalibrator->setUpdateAtTheEndOfRunOnly();
463 }
464 mBadChannelCalibrator->setIsTest(EMCALCalibParams::Instance().enableTestMode_bc);
465 mBadChannelCalibrator->setFillNr(currFill);
466 mBadChannelCalibrator->setRunType(runtype);
467 mBadChannelCalibrator->setSaveFileName("emc-channel-calib-" + std::to_string(runtype) + ".root");
468 mBadChannelCalibrator->setCurrTSInHours(static_cast<int>(ts / o2::ccdb::CcdbObjectInfo::HOUR));
469 }
470 }
471}; // namespace calibration
472
473} // namespace calibration
474
475namespace framework
476{
477
478DataProcessorSpec getEMCALChannelCalibDeviceSpec(const std::string calibType, const bool loadCalibParamsFromCCDB, const bool rejectCalibTrigger, const bool rejectL0Trigger, const bool ctpcfgperrun, const bool applyGainCalib)
479{
482 using EMCALCalibParams = o2::emcal::EMCALCalibParams;
483 using CalibDB = o2::emcal::CalibDB;
484
485 std::vector<OutputSpec> outputs;
486 std::string processorName;
487 if (calibType.find("time") != std::string::npos) { // time calibration
488 processorName = "calib-emcalchannel-time";
489 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_TIMECALIB"}, Lifetime::Sporadic); // This needs to match with the output!
490 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_TIMECALIB"}, Lifetime::Sporadic); // This needs to match with the output!
491 } else { // bad channel calibration
492 processorName = "calib-emcalchannel-badchannel";
493 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBPayload, "EMC_BADCHANNELS"}, Lifetime::Sporadic); // This needs to match with the output!
494 outputs.emplace_back(ConcreteDataTypeMatcher{o2::calibration::Utils::gDataOriginCDBWrapper, "EMC_BADCHANNELS"}, Lifetime::Sporadic); // This needs to match with the output!
495 }
496
497 std::vector<InputSpec> inputs;
498 inputs.emplace_back(device::getCellBinding(), o2::header::gDataOriginEMC, "CELLS", 0, o2::framework::Lifetime::Timeframe);
499 inputs.emplace_back(device::getCellTriggerRecordBinding(), o2::header::gDataOriginEMC, "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe);
500 // inputs.emplace_back("EMCTriggers", "EMC", "CELLSTRGR", 0, Lifetime::Timeframe)
501 // for loading the channelCalibParams from the ccdb
502 if (loadCalibParamsFromCCDB) {
503 inputs.emplace_back("EMC_CalibParam", o2::header::gDataOriginEMC, "EMCALCALIBPARAM", 0, Lifetime::Condition, ccdbParamSpec("EMC/Config/CalibParam"));
504 }
505 if (calibType.find("badchannel") != std::string::npos) {
506 inputs.emplace_back("EMC_Scalefactors", o2::header::gDataOriginEMC, "SCALEFACTORS", 0, Lifetime::Condition, ccdbParamSpec(CalibDB::getCDBPathChannelScaleFactors()));
507 }
508 if (applyGainCalib) {
509 inputs.emplace_back(device::getGainCalibBinding(), o2::header::gDataOriginEMC, "EMCGAINCALIB", 0, Lifetime::Condition, ccdbParamSpec("EMC/Calib/GainCalibFactors"));
510 }
511
512 // data request needed for rejection of EMCal trigger
513 if (rejectL0Trigger) {
514 inputs.emplace_back(device::getCTPConfigBinding(), "CTP", "CTPCONFIG", 0, Lifetime::Condition, ccdbParamSpec("CTP/Config/Config", ctpcfgperrun));
515 inputs.emplace_back(device::getCTPDigitsBinding(), "CTP", "DIGITS", 0, Lifetime::Timeframe);
516 }
517
518 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(true, // orbitResetTime
519 true, // GRPECS=true
520 true, // GRPLHCIF
521 false, // GRPMagField
522 false, // askMatLUT
524 inputs);
525
526 return DataProcessorSpec{
527 processorName,
528 inputs,
529 outputs,
530 AlgorithmSpec{adaptFromTask<device>(ccdbRequest, loadCalibParamsFromCCDB, calibType, rejectCalibTrigger, rejectL0Trigger, applyGainCalib)},
531 Options{}};
532}
533
534} // namespace framework
535} // namespace o2
536
537#endif
Definition of the 32 Central Trigger System (CTS) Trigger Types defined in https://twiki....
definition of CTPConfiguration and related CTP structures
Utils and constants for calibration and related workflows.
definition of CTPDigit, CTPInputDigit
std::ostringstream debug
unsigned int uint32_t
std::vector< std::string > header
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder Print launch bounds used for RTC code as debugging for exit after Allow RTC with slave GPUReconstruction instances with optConstexpr and optSpecialcode Maximum number of RTC cache files per backend in the cache the oldest are Prepend RTC compilation commands by this string Load a parameter object containing the launch bounds from a file h configStandalone Processing proc_param TPC Cluster Z Error Parameterization h configStandalone Processing settings for neural network proc_nn std::string Specify inference device(cpu(default), rocm, cuda)") AddOption(nnInferenceDeviceId
Helper for geometry and GRP related CCDB requests.
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
Definition of the Names Generator class.
uint16_t pos
Definition RawData.h:3
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
void init(o2::framework::InitContext &ic) final
void run(o2::framework::ProcessingContext &pc) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
EMCALChannelCalibDevice(std::shared_ptr< o2::base::GRPGeomRequest > req, bool params, std::string calibType, bool rejCalibTrg, bool rejL0Trig, bool applyGainCalib)
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
Definition CcdbApi.h:109
static constexpr long HOUR
void printKeyValues(bool showProv=true, bool useLogger=false, bool withPadding=true, bool showHash=true) const final
Interface to calibration data from CCDB for EMCAL.
Definition CalibDB.h:68
CCDB container for the gain calibration factors.
GLeglImageOES image
Definition glcorearb.h:4021
GLenum const GLfloat * params
Definition glcorearb.h:272
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
constexpr o2::header::DataOrigin gDataOriginEMC
Definition DataHeader.h:568
constexpr TFType INFINITE_TF
Definition TimeSlot.h:30
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
constexpr uint32_t Cal
Definition Triggers.h:32
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
Definition Utils.h:44
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
Definition Utils.h:43
std::string selectedClassMasks
name of EMCal min. bias trigger that is used for calibration
float fractionEvents_bc
fraction of events used in bad channel calibration
bool setSavedSlotAllowed_EMC
if true, saving and loading of calibrations from last run and for next run is enabled
bool setSavedSlotAllowedSOR_EMC
if true, stored calibrations from last run can be loaded in the next run (if false,...
float fractionEvents_tc
fraction of events used in time calibration
bool useScaledHisto_bc
use the scaled histogram for the bad channel map
int bcShiftCTP
bc shift of CTP digits to align them with EMC bc in case they are misaligned
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"