24#include <fairlogger/Logger.h>
39 : mDigits(useDigits), mCCDBRequest(req)
46 auto probT = ic.
options().
get<
float>(
"prob-threshold");
47 auto probTRelErr = ic.
options().
get<
float>(
"prob-rel-err");
48 LOGP(info,
"Setting the probability threshold to {} with relative error {}", probT, probTRelErr);
49 mStopMeOnly = ic.
options().
get<
bool>(
"stop-me-only");
50 mPath = ic.
options().
get<std::string>(
"path-CCDB");
51 mPathMerge = ic.
options().
get<std::string>(
"path-CCDB-merge");
57 mCalibrator = std::make_unique<CALIBRATOR>(probT, probTRelErr);
59 mPathDcs = ic.
options().
get<std::string>(
"path-DCS");
60 mOutputType = ic.
options().
get<std::string>(
"send-to-server");
61 mNoiseMapForDcs.clear();
62 api.
init(
"http://alice-ccdb.cern.ch");
67 updateTimeDependentParams(pc);
69 const auto digits = pc.
inputs().
get<gsl::span<o2::itsmft::Digit>>(
"digits");
70 const auto rofs = pc.
inputs().
get<gsl::span<o2::itsmft::ROFRecord>>(
"digitsROF");
71 const auto tfcounter = o2::header::get<o2::framework::DataProcessingHeader*>(pc.
inputs().
get(
"digitsROF").header)->startTime;
73 if (mCalibrator->processTimeFrame(tfcounter,
digits, rofs)) {
74 LOG(info) <<
"Minimum number of noise counts has been reached !";
75 if (mOutputType.compare(
"CCDB") == 0) {
76 LOG(info) <<
"Sending an object to Production-CCDB";
78 LOG(info) <<
"Sending an object to Production-CCDBMerge";
79 sendOutputCcdbMerge(pc.
outputs());
80 }
else if (mOutputType.compare(
"DCS") == 0) {
81 LOG(info) <<
"Sending an object to DCS-CCDB";
84 LOG(info) <<
"Sending an object to Production-CCDB and DCS-CCDB";
85 sendOutputCcdbDcs(pc.
outputs());
90 const auto compClusters = pc.
inputs().
get<gsl::span<o2::itsmft::CompClusterExt>>(
"compClusters");
91 gsl::span<const unsigned char> patterns = pc.
inputs().
get<gsl::span<unsigned char>>(
"patterns");
92 const auto rofs = pc.
inputs().
get<gsl::span<o2::itsmft::ROFRecord>>(
"ROframes");
93 const auto tfcounter = o2::header::get<o2::framework::DataProcessingHeader*>(pc.
inputs().
get(
"ROframes").header)->startTime;
95 if (mCalibrator->processTimeFrame(tfcounter, compClusters, patterns, rofs)) {
96 LOG(info) <<
"Minimum number of noise counts has been reached !";
97 if (mOutputType.compare(
"CCDB") == 0) {
98 LOG(info) <<
"Sending an object to Production-CCDB";
100 LOG(info) <<
"Sending an object to Production-CCDBMerge";
101 sendOutputCcdbMerge(pc.
outputs());
102 }
else if (mOutputType.compare(
"DCS") == 0) {
103 LOG(info) <<
"Sending an object to DCS-CCDB";
106 LOG(info) <<
"Sending an object to Production-CCDB and DCS-CCDB";
107 sendOutputCcdbDcs(pc.
outputs());
116 for (
int iChip = 0; iChip < 936; ++iChip) {
117 for (
int iRow = 0; iRow < 512; ++iRow) {
118 for (
int iCol = 0; iCol < 1024; ++iCol) {
120 if (!payload.
isNoisy(iChip, iRow, iCol)) {
123 std::array<int, 3> noise = {iChip, iRow, iCol};
124 mNoiseMapForDcs.emplace_back(noise);
133 LOG(info) <<
"CCDB-DCS mode";
135 static bool done =
false;
141 mCalibrator->finalize();
143 long tstart = mStart;
149 constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60;
153 std::map<std::string, std::string> meta;
154 auto toKeyValPairs = [&meta](std::vector<std::string>
const& tokens) {
155 for (
auto& token : tokens) {
157 if (keyval.size() != 2) {
158 LOG(error) <<
"Illegal command-line key/value string: " << token;
162 meta[keyval[0]] = keyval[1];
169 const auto& payload = mCalibrator->getNoiseMap();
175 info.setFileName(flName);
176 LOG(info) <<
"Sending object " << info.getPath() <<
"/" << info.getFileName()
177 <<
" of size " <<
image->size()
178 <<
" bytes, valid for " << info.getStartValidityTimestamp()
179 <<
" : " << info.getEndValidityTimestamp();
185 setOutputDcs(payload);
190 infoDcs.setFileName(flNameDcs);
191 LOG(info) <<
"Sending object " << infoDcs.getPath() <<
"/" << infoDcs.getFileName()
192 <<
" of size " << imageDcs->size()
193 <<
" bytes, valid for " << infoDcs.getStartValidityTimestamp()
194 <<
" : " << infoDcs.getEndValidityTimestamp();
197 output.snapshot(
Output{clbUtilsDcs::gDataOriginCDBPayload,
"MFT_NoiseMap", 1}, *imageDcs.get());
198 output.snapshot(
Output{clbUtilsDcs::gDataOriginCDBWrapper,
"MFT_NoiseMap", 1}, infoDcs);
204 LOG(info) <<
"CCDB mode";
206 static bool done =
false;
212 mCalibrator->finalize();
214 long tstart = mStart;
220 constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60;
224 std::map<std::string, std::string> meta;
225 auto toKeyValPairs = [&meta](std::vector<std::string>
const& tokens) {
226 for (
auto& token : tokens) {
228 if (keyval.size() != 2) {
229 LOG(error) <<
"Illegal command-line key/value string: " << token;
233 meta[keyval[0]] = keyval[1];
240 const auto& payload = mCalibrator->getNoiseMap();
246 info.setFileName(flName);
247 LOG(info) <<
"Sending object CCDB " << info.getPath() <<
"/" << info.getFileName()
248 <<
" of size " <<
image->size()
249 <<
" bytes, valid for " << info.getStartValidityTimestamp()
250 <<
" : " << info.getEndValidityTimestamp();
260 LOG(info) <<
"CCDB-Merge mode";
262 static bool done =
false;
268 mCalibrator->finalize();
270 long tstart = mStart;
276 constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60;
280 std::map<std::string, std::string> meta;
281 auto toKeyValPairs = [&meta](std::vector<std::string>
const& tokens) {
282 for (
auto& token : tokens) {
284 if (keyval.size() != 2) {
285 LOG(error) <<
"Illegal command-line key/value string: " << token;
289 meta[keyval[0]] = keyval[1];
296 auto payload = mCalibrator->getNoiseMap();
298 map<string, string> headers;
299 map<std::string, std::string>
filter;
301 long validtime = std::stol(headers[
"Valid-From"]);
302 auto mergedPL = payload;
304 validtime = validtime - 1;
306 auto bufferPL = payloadPrev2->
merge(payloadPrev1);
307 mergedPL = payload.
merge(&bufferPL);
312 info.setFileName(flName);
313 LOG(info) <<
"Sending object ccdb-merge " << info.getPath() <<
"/" << info.getFileName()
314 <<
" of size " <<
image->size()
315 <<
" bytes, valid for " << info.getStartValidityTimestamp()
316 <<
" : " << info.getEndValidityTimestamp();
326 LOG(info) <<
"DCS mode";
328 static bool done =
false;
334 mCalibrator->finalize();
336 long tstart = mStart;
342 constexpr long SECONDSPERYEAR = 365 * 24 * 60 * 60;
346 std::map<std::string, std::string> meta;
347 auto toKeyValPairs = [&meta](std::vector<std::string>
const& tokens) {
348 for (
auto& token : tokens) {
350 if (keyval.size() != 2) {
351 LOG(error) <<
"Illegal command-line key/value string: " << token;
355 meta[keyval[0]] = keyval[1];
362 const auto& payload = mCalibrator->getNoiseMap();
365 setOutputDcs(payload);
370 infoDcs.setFileName(flNameDcs);
371 LOG(info) <<
"Sending object " << infoDcs.getPath() <<
"/" << infoDcs.getFileName()
372 <<
" of size " << imageDcs->size()
373 <<
" bytes, valid for " << infoDcs.getStartValidityTimestamp()
374 <<
" : " << infoDcs.getEndValidityTimestamp();
377 output.snapshot(
Output{clbUtilsDcs::gDataOriginCDBPayload,
"MFT_NoiseMap", 0}, *imageDcs.get());
378 output.snapshot(
Output{clbUtilsDcs::gDataOriginCDBWrapper,
"MFT_NoiseMap", 0}, infoDcs);
383 if (mOutputType.compare(
"CCDB") == 0) {
384 LOG(info) <<
"Sending an object to Production-CCDB";
386 LOG(info) <<
"Sending an object to Production-CCDB-Merge";
387 sendOutputCcdbMerge(ec.
outputs());
388 }
else if (mOutputType.compare(
"DCS") == 0) {
389 LOG(info) <<
"Sending an object to DCS-CCDB";
392 LOG(info) <<
"Sending an object to Production-CCDB and DCS-CCDB";
393 sendOutputCcdbDcs(ec.
outputs());
394 sendOutputCcdbMerge(ec.
outputs());
412 LOG(info) <<
"cluster dictionary updated";
420 std::vector<InputSpec> inputs;
422 inputs.emplace_back(
"digits", detOrig,
"DIGITS", 0, Lifetime::Timeframe);
423 inputs.emplace_back(
"digitsROF", detOrig,
"DIGITSROF", 0, Lifetime::Timeframe);
425 inputs.emplace_back(
"compClusters", detOrig,
"COMPCLUSTERS", 0, Lifetime::Timeframe);
426 inputs.emplace_back(
"patterns", detOrig,
"PATTERNS", 0, Lifetime::Timeframe);
427 inputs.emplace_back(
"ROframes", detOrig,
"CLUSTERSROF", 0, Lifetime::Timeframe);
428 inputs.emplace_back(
"cldict",
"MFT",
"CLUSDICT", 0, Lifetime::Condition,
ccdbParamSpec(
"MFT/Calib/ClusterDictionary"));
430 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
false,
438 std::vector<OutputSpec> outputs;
443 "mft-noise-calibrator",
446 AlgorithmSpec{adaptFromTask<NoiseCalibratorSpec>(useDigits, ccdbRequest)},
448 {
"prob-threshold", VariantType::Float, 1.e-6f, {
"Probability threshold for noisy pixels"}},
449 {
"prob-rel-err", VariantType::Float, 0.2f, {
"Relative error on channel noise to apply the threshold"}},
450 {
"tstart", VariantType::Int64, -1ll, {
"Start of validity timestamp"}},
451 {
"tend", VariantType::Int64, -1ll, {
"End of validity timestamp"}},
452 {
"path-CCDB", VariantType::String,
"/MFT/Calib/NoiseMap", {
"Path to write to in CCDB"}},
453 {
"path-CCDB-merge", VariantType::String,
"/MFT/Calib/NoiseMapMerged", {
"Path to write merged file to in CCDB"}},
454 {
"path-DCS", VariantType::String,
"/MFT/Config/NoiseMap", {
"Path to write to in DCS"}},
455 {
"meta", VariantType::String,
"", {
"meta data to write in CCDB"}},
456 {
"send-to-server", VariantType::String,
"CCDB-DCS", {
"meta data to write in DCS-CCDB"}},
457 {
"stop-me-only", VariantType::Bool,
false, {
"At sufficient statistics stop only this device, otherwise whole workflow"}}}};
Definition of the ITS/MFT clusterer settings.
Definition of the ITSMFT compact cluster.
Definition of the Names Generator class.
Utils and constants for calibration and related workflows.
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string generateFileName(const std::string &inp)
void init(std::string const &hosts)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
std::enable_if<!std::is_base_of< o2::conf::ConfigurableParam, T >::value, T * >::type retrieveFromTFileAny(std::string const &path, std::map< std::string, std::string > const &metadata, long timestamp=-1, std::map< std::string, std::string > *headers=nullptr, std::string const &etag="", const std::string &createdNotAfter="", const std::string &createdNotBefore="") const
T get(const char *key) const
DataAllocator & outputs()
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
NoiseMap class for the ITS and MFT.
NoiseMap merge(const NoiseMap *prev)
bool isNoisy(int chip, int row, int col) const
NoiseCalibratorSpec(bool digits=false, std::shared_ptr< o2::base::GRPGeomRequest > req={})
void endOfStream(EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
void run(ProcessingContext &pc) final
void init(InitContext &ic) final
void finaliseCCDB(ConcreteDataMatcher &matcher, void *obj) final
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
constexpr o2::header::DataOrigin gDataOriginMFT
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
long getFutureTimestamp(int secondsInFuture)
returns the timestamp in long corresponding to "now + secondsInFuture"
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
DataProcessorSpec getNoiseCalibratorSpec(bool useDigits)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
static void trim(std::string &s)
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Digit > digits