12#ifndef O2_HMPID_DATAPROCESSOR_H
13#define O2_HMPID_DATAPROCESSOR_H
48using Duration = std::chrono::duration<double, std::ratio<1, 1>>;
62 mLocalTest = ic.options().get<
bool>(
"local-test");
65 mCheckRunStartStop =
false;
67 LOGP(info,
"Local test option = {} ", mLocalTest);
68 std::vector<DPID> vect;
70 bool useCCDBtoConfigure = ic.options().get<
bool>(
"use-ccdb-to-configure");
71 LOGP(info,
"useCCDBtoConfigure option = {} ", useCCDBtoConfigure);
72 if (useCCDBtoConfigure) {
73 LOG(info) <<
"Configuring via CCDB";
74 std::string ccdbpath = ic.options().get<std::string>(
"ccdb-path");
77 long ts = std::chrono::duration_cast<std::chrono::milliseconds>(
78 std::chrono::system_clock::now().time_since_epoch())
80 std::unordered_map<DPID, std::string>* dpid2DataDesc =
81 mgr.getForTimeStamp<std::unordered_map<DPID, std::string>>(
82 "HMP/Config/DCSDPconfig", ts);
83 for (
auto&
i : *dpid2DataDesc) {
84 vect.push_back(
i.first);
87 LOG(info) <<
"Configuring via hardcoded strings";
90 for (
const auto&
i : expaliases) {
97 LOG(info) <<
"Listing Data Points for HMPID:";
98 for (
auto&
i : vect) {
102 mProcessor = std::make_unique<o2::hmpid::HMPIDDCSProcessor>();
103 bool useVerboseMode = ic.options().get<
bool>(
"use-verbose-mode");
104 LOG(info) <<
" ************************* Verbose?" << useVerboseMode;
106 if (useVerboseMode) {
107 mProcessor->useVerboseMode();
109 mProcessor->init(vect);
110 mTimer = HighResClock::now();
118 auto timeNow = HighResClock::now();
120 if (dataTime == 0xffffffffffffffff) {
121 dataTime = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow.time_since_epoch()).count();
128 mProcessor->setStartValidity(dataTime);
131 if (mLocalTest ==
true) {
136 if (mCheckRunStartStop) {
137 const auto* grp = mRunChecker.
check();
139 static size_t runCount = 0;
140 const size_t logPrescale = 10;
142 if ((runCount % logPrescale) == 0) {
143 LOGP(info,
"No run with HMP is ongoing or finished");
151 LOG(error) <<
"GRPECS pointer is null";
155 mProcessor->setStartValidity(dataTime);
157 }
else if (mRunChecker.
getRunStatus() == RunStatus::ONGOING) {
158 if ((runCount % logPrescale) == 0) {
159 LOGP(info,
"Run {} is still ongoing", mRunChecker.
getFollowedRun());
161 }
else if (mRunChecker.
getRunStatus() == RunStatus::STOP) {
166 mProcessor->setRunNumberFromGRP(-2);
170 auto dps = pc.inputs().get<gsl::span<DPCOM>>(
"input");
171 mProcessor->process(dps);
174 if (mCheckRunStartStop && (mRunChecker.
getRunStatus() == RunStatus::STOP)) {
175 mProcessor->finalize();
177 mProcessor->setEndValidityRunSpecific(dataTime);
179 sendChargeThresOutput(pc.outputs());
180 sendRefIndexOutput(pc.outputs());
181 mProcessor->clearCCDBObjects();
182 mProcessor->resetStartValidity();
183 mProcessor->resetEndValidity();
194 auto timeNow = HighResClock::now();
197 long dataTime = testTimeStamp;
198 if (dataTime == 0xffffffffffffffff) {
199 dataTime = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow.time_since_epoch()).count();
202 mProcessor->setEndValidityRunIndependent(dataTime);
203 mProcessor->finalize();
205 sendChargeThresOutput(ec.outputs());
206 sendRefIndexOutput(ec.outputs());
208 mProcessor->clearCCDBObjects();
209 mProcessor->resetStartValidity();
210 mProcessor->resetEndValidity();
220 const auto& payload = mProcessor->getChargeCutObj();
221 auto& info = mProcessor->getHmpidChargeInfo();
224 LOG(info) <<
"Sending object " << info.getPath() <<
"/"
225 << info.getFileName() <<
" of size " <<
image->size()
226 <<
" bytes, valid for " << info.getStartValidityTimestamp()
227 <<
" : " << info.getEndValidityTimestamp();
240 const auto& payload = mProcessor->getRefIndexObj();
241 auto& info = mProcessor->getccdbRefInfo();
244 LOG(info) <<
"Sending object " << info.getPath() <<
"/"
245 << info.getFileName() <<
" of size " <<
image->size()
246 <<
" bytes, valid for " << info.getStartValidityTimestamp()
247 <<
" : " << info.getEndValidityTimestamp();
257 std::vector<std::string> aliases = {
259 "HMP_MP_[0..6]_GAS_PMWPC",
260 "HMP_MP_[0..6]_LIQ_LOOP_RAD_[0..2]_IN_TEMP",
261 "HMP_MP_[0..6]_LIQ_LOOP_RAD_[0..2]_OUT_TEMP",
262 "HMP_MP_[0..6]_SEC_[0..5]_HV_VMON",
263 "HMP_TRANPLANT_MEASURE_[0..29]_WAVELENGHT",
264 "HMP_TRANPLANT_MEASURE_[0..29]_ARGONREFERENCE",
265 "HMP_TRANPLANT_MEASURE_[0..29]_ARGONCELL",
266 "HMP_TRANPLANT_MEASURE_[0..29]_C6F14REFERENCE",
267 "HMP_TRANPLANT_MEASURE_[0..29]_C6F14CELL"};
270 bool isRunStarted =
false;
271 bool mLocalTest =
false;
272 bool mCheckRunStartStop =
true;
275 std::unique_ptr<HMPIDDCSProcessor> mProcessor;
276 HighResClock::time_point mTimer;
289 std::vector<OutputSpec> outputs;
290 outputs.emplace_back(
294 outputs.emplace_back(
299 outputs.emplace_back(
303 outputs.emplace_back(
309 "hmp-dcs-data-processor",
Inputs{{
"input",
"DCS",
"HMPDATAPOINTS"}},
310 outputs,
AlgorithmSpec{adaptFromTask<o2::hmpid::HMPIDDCSDataProcessor>()},
315 {
"use-ccdb-to-configure",
318 {
"Use CCDB to configure"}},
322 {
"Local installation test"}},
326 {
"Use verbose mode"}}}};
Utils and constants for calibration and related workflows.
Header of the AggregatedRunInfo struct.
static std::string getCCDBServer()
static BasicCCDBManager & instance()
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
static constexpr long INFINITE_TIMESTAMP
RunStatus getRunStatus() const
const o2::parameters::GRPECSObject * check(long ts=-1)
int getFollowedRun() const
static mask_t getMask(const std::string_view detList)
detector masks from any non-alpha-num delimiter-separated list (empty if NONE is supplied)
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) 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)
std::vector< std::string > expandAliases(const std::vector< std::string > &patternedAliases)
Defining PrimaryVertex explicitly as messageable.
std::vector< InputSpec > Inputs
std::chrono::high_resolution_clock HighResClock
std::chrono::duration< double, std::ratio< 1, 1 > > Duration
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"