12#ifndef O2_MFT_DATAPROCESSOR_H
13#define O2_MFT_DATAPROCESSOR_H
20#include <TStopwatch.h>
52using Duration = std::chrono::duration<double, std::ratio<1, 1>>;
60 std::vector<DPID> vect;
61 mDPsUpdateInterval = ic.options().get<int64_t>(
"DPs-update-interval");
62 if (mDPsUpdateInterval == 0) {
63 LOG(error) <<
"MFT DPs update interval set to zero seconds --> changed to 60";
64 mDPsUpdateInterval = 60;
66 LOG(info) <<
"mDPsUpdateInterval " << mDPsUpdateInterval <<
"[sec.]";
68 bool useCCDBtoConfigure = ic.options().get<
bool>(
"use-ccdb-to-configure");
70 mStart = ic.options().get<int64_t>(
"tstart");
71 mEnd = ic.options().get<int64_t>(
"tend");
73 mThreBBCurrent = ic.options().get<
float>(
"thre-bb-current");
74 mThreAnalogCurrent = ic.options().get<
float>(
"thre-analog-current");
75 mThreDigitCurrent = ic.options().get<
float>(
"thre-digit-current");
76 mThreBBValtage = ic.options().get<
float>(
"thre-bb-voltage");
77 mThreRULV = ic.options().get<
float>(
"thre-ru-low-voltage");
79 LOG(info) <<
"mThreBBCurrent" << mThreBBCurrent;
80 LOG(info) <<
"mThreAnalogCurrent" << mThreAnalogCurrent;
81 LOG(info) <<
"mThreDigitCurrent" << mThreDigitCurrent;
82 LOG(info) <<
"mThreBBValtage" << mThreBBValtage;
83 LOG(info) <<
"mThreRULV" << mThreRULV;
85 if (useCCDBtoConfigure) {
86 LOG(info) <<
"Configuring via CCDB";
90 long ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
91 std::unordered_map<DPID, std::string>* dpid2DataDesc = mgr.getForTimeStamp<std::unordered_map<DPID, std::string>>(
"MFT/Config/DCSDPconfig", ts);
92 for (
auto&
i : *dpid2DataDesc) {
93 vect.push_back(
i.first);
98 LOG(info) <<
"Configuring via hardcoded strings";
99 std::vector<std::string> aliases = {
"MFT_PSU_ZONE/H[0..1]/D[0..4]/F[0..1]/Z[0..3]/Current/Analog",
100 "MFT_PSU_ZONE/H[0..1]/D[0..4]/F[0..1]/Z[0..3]/Current/BackBias",
101 "MFT_PSU_ZONE/H[0..1]/D[0..4]/F[0..1]/Z[0..3]/Current/Digital",
102 "MFT_PSU_ZONE/H[0..1]/D[0..4]/F[0..1]/Z[0..3]/Voltage/BackBias",
103 "MFT_RU_LV/H0/D0/F0/Z[0..3]/iMon",
104 "MFT_RU_LV/H0/D1/F0/Z[0..3]/iMon",
105 "MFT_RU_LV/H0/D2/F0/Z[0..3]/iMon",
106 "MFT_RU_LV/H0/D3/F0/Z[0..3]/iMon",
107 "MFT_RU_LV/H0/D4/F0/Z[0..3]/iMon",
108 "MFT_RU_LV/H0/D0/F1/Z[0..3]/iMon",
109 "MFT_RU_LV/H0/D1/F1/Z[0..3]/iMon",
110 "MFT_RU_LV/H0/D2/F1/Z[0..3]/iMon",
111 "MFT_RU_LV/H0/D3/F1/Z[0..3]/iMon",
112 "MFT_RU_LV/H0/D4/F1/Z[0..3]/iMon",
113 "MFT_RU_LV/H1/D0/F0/Z[0..3]/iMon",
114 "MFT_RU_LV/H1/D1/F0/Z[0..3]/iMon",
115 "MFT_RU_LV/H1/D2/F0/Z[0..3]/iMon",
116 "MFT_RU_LV/H1/D3/F0/Z[0..3]/iMon",
117 "MFT_RU_LV/H1/D4/F0/Z[0..3]/iMon",
118 "MFT_RU_LV/H1/D0/F1/Z[0..3]/iMon",
119 "MFT_RU_LV/H1/D1/F1/Z[0..3]/iMon",
120 "MFT_RU_LV/H1/D2/F1/Z[0..3]/iMon",
121 "MFT_RU_LV/H1/D3/F1/Z[0..3]/iMon",
122 "MFT_RU_LV/H1/D4/F1/Z[0..3]/iMon"};
125 for (
const auto&
i : expaliases) {
130 LOG(info) <<
"Listing Data Points for MFT:";
131 for (
auto&
i : vect) {
135 mProcessor = std::make_unique<o2::mft::MFTDCSProcessor>();
136 bool useVerboseMode = ic.options().get<
bool>(
"use-verbose-mode");
137 LOG(info) <<
" ************************* Verbose?" << useVerboseMode;
139 if (useVerboseMode) {
140 mProcessor->useVerboseMode();
142 mProcessor->init(vect);
144 mTimer = HighResClock::now();
145 mReportTiming = ic.options().get<
bool>(
"report-timing") || useVerboseMode;
152 auto tfid = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get(
"input").header)->startTime;
153 auto dps = pc.inputs().get<gsl::span<DPCOM>>(
"input");
155 mProcessor->setThreBackBiasCurrent(mThreBBCurrent);
156 mProcessor->setThreAnalogCurrent(mThreAnalogCurrent);
157 mProcessor->setThreDigitCurrent(mThreDigitCurrent);
158 mProcessor->setThreBackBiasVoltage(mThreBBValtage);
159 mProcessor->setThreRULV(mThreRULV);
160 mProcessor->setTF(tfid);
161 mProcessor->process(dps);
163 auto timeNow = HighResClock::now();
164 Duration elapsedTime = timeNow - mTimer;
165 if (elapsedTime.count() >= mDPsUpdateInterval || mProcessor->sendDPsCCDB()) {
166 sendDPsoutput(pc.outputs());
178 sendDPsoutput(ec.outputs());
182 bool mReportTiming =
false;
183 std::unique_ptr<MFTDCSProcessor> mProcessor;
184 HighResClock::time_point mTimer;
185 int64_t mDPsUpdateInterval;
189 float mThreBBCurrent;
190 float mThreAnalogCurrent;
191 float mThreDigitCurrent;
192 float mThreBBValtage;
199 mProcessor->updateDPsCCDB();
200 const auto& payload = mProcessor->getMFTDPsInfo();
201 auto& info = mProcessor->getccdbDPsInfo();
203 long tstart = mStart;
214 info.setStartValidityTimestamp(tstart);
215 info.setEndValidityTimestamp(tend);
218 LOG(info) <<
"Sending object " << info.getPath() <<
"/" << info.getFileName() <<
" of size " <<
image->size()
219 <<
" bytes, valid for " << info.getStartValidityTimestamp() <<
" : " << info.getEndValidityTimestamp();
222 mProcessor->clearDPsinfo();
236 std::vector<OutputSpec> outputs;
242 "mft-dcs-data-processor",
243 Inputs{{
"input",
"DCS",
"MFTDATAPOINTS"}},
245 AlgorithmSpec{adaptFromTask<o2::mft::MFTDCSDataProcessor>()},
252 {
"thre-analog-current",
VariantType::Float, 999.f, {
"Threshold for Analog Currect to send to CCDB"}},
253 {
"thre-digit-current",
VariantType::Float, 999.f, {
"Threshold for Digital Currect to send to CCDB"}},
254 {
"thre-bb-current",
VariantType::Float, 999.f, {
"Threshold for BackBias Currect to send to CCDB"}},
255 {
"thre-bb-voltage",
VariantType::Float, 999.f, {
"Threshold for BackBias Voltage to send to CCDB"}},
256 {
"thre-ru-low-voltage",
VariantType::Float, 999.f, {
"Threshold for RU LV to send to CCDB"}},
257 {
"DPs-update-interval",
VariantType::Int64, 600ll, {
"Interval (in s) after which to update the DPs CCDB entry"}}}};
Utils and constants for calibration and related workflows.
static std::string getCCDBServer()
static BasicCCDBManager & instance()
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
static constexpr long MONTH
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.
information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
std::vector< std::string > expandAliases(const std::vector< std::string > &patternedAliases)
Defining PrimaryVertex explicitly as messageable.
std::vector< InputSpec > Inputs
std::chrono::duration< double, std::ratio< 1, 1 > > Duration
std::chrono::high_resolution_clock HighResClock
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
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"