BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnConverterTools.cxx
Go to the documentation of this file.
1#include "BmnConverterTools.h"
2
3// STL
4#include <chrono>
5#include <regex>
6// ROOT
7#include <TPRegexp.h>
8// BmnRoot
9#include "BmnFunctionSet.h"
10#include "BmnMath.h"
12
13// using std::string;
14// using std::make_pair;
15using namespace std::chrono_literals;
16using namespace std::chrono;
17
19{
20 if (str.rfind("Comment", 0) == 0)
21 return T0Config::Comment;
22 if (str.rfind("Discriminators", 0) == 0)
23 return T0Config::Discriminators;
24 if (str.rfind("Delay lines", 0) == 0)
25 return T0Config::DelayLines;
26 if (str.rfind("Switches", 0) == 0)
27 return T0Config::Switches;
28 if (str.rfind("LV", 0) == 0)
29 return T0Config::LV;
30 if (str.rfind("BD_multiplicity", 0) == 0)
31 return T0Config::BDMult;
32 if (str.rfind("Extra delays mask", 0) == 0)
33 return T0Config::ExtraDelaysMask;
34 return T0Config::Undefined;
35}
36
37SysPoint BmnConverterTools::ParseTAI(json& jt, int32_t tai_utc_dif)
38{
39 uint32_t nans = static_cast<uint32_t>(jt["ns"]);
40 uint32_t sec = static_cast<uint32_t>(jt["sec"]) - tai_utc_dif;
41 bool valid = static_cast<uint32_t>(jt["valid"]);
42 return valid ? SysPoint{sec * 1s + nans * 1ns} : SysPoint::min();
43}
44
45BmnT0Raw* BmnConverterTools::Process_T0Raw(const uint32_t* d, uint32_t len, TClonesArray* t0raw)
46{
47 BmnT0Raw* lastT0 = nullptr;
48 if (t0raw)
49 lastT0 = new ((*t0raw)[t0raw->GetEntriesFast()]) BmnT0Raw(d);
50 else
51 lastT0 = new BmnT0Raw(d);
52 for (uint32_t i = 0; i < kT0_BIN_BLOCK_WORDS; i++) {
53 LOGF(debug2, "cntr[%3d]: %8u", i, d[i]);
54 }
55 const int32_t date_len = (kT0_BIN_BLOCK_WORDS - kT0_BIN_BLOCK_TIME_TXT) * kWORDSIZE; // 23.12.2022 14:17:46
56 string str(reinterpret_cast<const char*>(&d[kT0_BIN_BLOCK_TIME_TXT]), date_len);
57 // LOG(info) << str;
58 for (uint32_t i = 0; i < str.length(); i++) {
59 LOGF(debug2, "str[%3d]: 0x%02X", i, str[i]);
60 }
61 regex re_str_cfg_t0_h2d("\\D*(\\d{2})\\.(\\d{2})\\.(\\d{4})\\s(\\d{2}:\\d{2}:\\d{2})\\D*");
62 regex re_str_cfg_t0_h1d("\\D*(\\d{2})\\.(\\d{2})\\.(\\d{4})\\s(\\d{1}:\\d{2}:\\d{2})\\D*");
63 bool re_subst_ret = false;
64 string str_TDatime;
65 if (regex_match(str, re_str_cfg_t0_h2d)) {
66 str_TDatime = regex_replace(str, re_str_cfg_t0_h2d, "$3-$2-$1 $4");
67 re_subst_ret = true;
68 } else if (regex_match(str, re_str_cfg_t0_h1d)) {
69 str_TDatime = regex_replace(str, re_str_cfg_t0_h1d, "$3-$2-$1 0$4");
70 re_subst_ret = true;
71 }
72 // LOGF(info, "ts line return %d", re_subst_ret);
73 // LOG(info) << str_TDatime;
74 uint64_t t_2020_sec(d[kT0_BIN_BLOCK_2020_SEC]);
75 uint64_t t_unix_sec(d[kT0_BIN_BLOCK_UNIX_SEC]);
76 // LOGF(info, "unix v: %u", t_unix_sec);
77 // LOGF(info, "2020 v: %u", t_2020_sec);
78 TTimeStamp ts_unix_sec(t_unix_sec, 0);
79 TTimeStamp ts_2020_sec(t_2020_sec + TTimeStamp(2020, 1, 1, 0, 0, 0), 0);
80 LOGF(debug, "unix ts: %s", ts_unix_sec.AsString());
81 LOGF(debug, "2020 ts: %s", ts_2020_sec.AsString());
82 uint32_t trig_bit_conf(d[kT0_BIN_BLOCK_WORDS - 1]);
83 lastT0->SetTriggerMask(trig_bit_conf);
84 bitset<32> trig_bit_conf_bs(trig_bit_conf);
85 LOGF(debug, "trig bitset %u", trig_bit_conf);
86 LOGF(debug, "trig bitset %s", trig_bit_conf_bs.to_string());
87 uint32_t pos = kT0_BIN_BLOCK_BYTES; // + date_len;
88 string tcfg(reinterpret_cast<const char*>(d) + pos, len - pos);
89 // LOG(info) << tcfg;
91 if (t0raw) {
92 t0raw->Remove(lastT0);
93 return nullptr;
94 }
95 }
96 ts_unix_sec =
97 TTimeStamp(ts_unix_sec.GetSec() - 3 * 3600,
98 ts_unix_sec.GetNanoSec()); // crutch: shifting time zone from Moscow -> GMT for uniformity
99 if (t_unix_sec > 0)
100 lastT0->SetTS(ts_unix_sec);
101 else {
102 if (re_subst_ret > 0) {
103 // TDatime dt(str_TDatime.data());
104 // TTimeStamp ts_from_string(static_cast<uint32_t>(dt.GetDate()),
105 // static_cast<uint32_t>(dt.GetTime()), 0u); LOGF(info, "ts line: %s",
106 // ts_from_string.AsString()); ts_from_string = TTimeStamp(
107 // ts_from_string.GetSec() - 3 * 3600,
108 // ts_from_string.GetNanoSec()); // crutch: shifting time zone from Moscow
109 // -> GMT for uniformity
110 istringstream ss(str_TDatime);
111 std::tm tm = {};
112 ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S");
113 std::time_t time_t_time = std::mktime(&tm);
114 SysPoint time_point = SysClock::from_time_t(time_t_time);
115 time_point -= 3h; // crutch: shifting time zone from Moscow -> GMT for uniformity
116 LOG(debug) << "str ts : " << BmnFunctionSet::TimePoint2String(time_point);
117 lastT0->SetTime(time_point);
118 // lastT0->SetTS(ts_from_string);
119
120 } else {
121 if (t_2020_sec > 0) {
122 lastT0->SetTS(ts_2020_sec);
123 } else
124 LOGF(warning, "Unable to find raw T0 block timestamp!");
125 }
126 }
127 return lastT0;
128}
129
131{
133 try {
134 regex rempty("[\\s\r]*\n*");
135 regex re_cfg(".+\\.BMNCfg.*[\r\n]*");
136 istringstream iss(str);
137 string line;
138 bool cfg_found = false;
139 uint8_t empty_found = 0;
140 while (std::getline(iss, line)) {
141 if (regex_match(line, rempty)) {
142 ++empty_found;
143 if (empty_found > 2)
144 break;
145 } else {
146 if (regex_match(line, re_cfg)) {
147 cfg_found = true;
148 LOG(debug2) << "CFG found";
149 }
150 break;
151 }
152 }
153 if (!cfg_found) {
154 LOG(error) << "Error: Raw T0 header not found!";
155 return kBMNERROR;
156 }
157 std::getline(iss, line);
159 for (const auto& n : node.children) {
160 auto& ch = n.children;
161 switch (GetT0Cfg(n.value)) {
162 case T0Config::Comment: {
163 if (ch.size() > 0)
164 rt0dig->SetComment(ch[0].value);
165 break;
166 }
167 case T0Config::Discriminators: {
168 regex re("Discriminator(\\d+)\\r*");
169 for (const auto& node_par : ch) {
170 string snum = regex_replace(node_par.value, re, "$1");
171 uint32_t idis = std::stoul(snum.data());
172 auto& dvec = rt0dig->Discriminators();
173 auto& disc = dvec[idis];
174 for (const auto& node_chan : node_par.children) {
175 if (node_chan.value.rfind("Polarity", 0) == 0) {
176 if (node_chan.children.size() > 0) {
177 const auto& str_field = node_chan.children[0].value;
178 if (str_field.rfind("Positive", 0) == 0)
179 disc.polarity = 1;
180 else
181 disc.polarity = -1;
182 }
183 continue;
184 }
185 regex rthr("Threshold,\\s+(\\w+)\\r*");
186 if (regex_match(node_chan.value, rthr)) {
187 string unit = regex_replace(node_chan.value, rthr, "$1");
188 if (node_chan.children.size() > 0) {
189 const auto& str_field = node_chan.children[0].value;
190 disc.threshold = std::atoi(str_field.data());
191 disc.threshold_unit = move(unit);
192 }
193 continue;
194 }
195 }
196 // disc.print();
197 }
198 } break;
199 case T0Config::DelayLines: {
200 regex re("Delay(\\d+)\\r*");
201 for (const auto& node_par : ch) {
202 string snum = regex_replace(node_par.value, re, "$1");
203 uint32_t idis = std::stoul(snum.data());
204 auto& delvec = rt0dig->DelayLines();
205 if (node_par.children.size() > 0) {
206 const auto& str_field = node_par.children[0].value;
207 delvec[idis] = std::atoi(str_field.data());
208 }
209 }
210 } break;
211 case T0Config::Switches: {
212 regex re("Switch(\\d+)\\r*");
213 for (const auto& node_par : ch) {
214 string snum = regex_replace(node_par.value, re, "$1");
215 uint32_t idis = std::stoul(snum.data());
216 auto& swvec = rt0dig->Switches();
217 if (node_par.children.size() > 0) {
218 const auto& str_field = node_par.children[0].value;
219 swvec[idis] = (str_field.rfind("On", 0) == 0) ? true : false;
220 }
221 }
222 } break;
223 case T0Config::LV: {
224 regex re("Channel(\\d+)\\r*");
225 for (const auto& node_par : ch) {
226 string snum = regex_replace(node_par.value, re, "$1");
227 uint32_t idis = std::stoul(snum.data());
228 auto& dvec = rt0dig->LVChannelConfig();
229 auto& cfg = dvec[idis];
230 for (const auto& node_chan : node_par.children) {
231 if (node_chan.value.rfind("Active", 0) == 0) {
232 if (node_chan.children.size() > 0) {
233 const auto& str_field = node_chan.children[0].value;
234 cfg.active = (str_field.rfind("1", 0) == 0) ? true : false;
235 }
236 continue;
237 }
238 if (node_chan.value.rfind("Channel name", 0) == 0) {
239 if (node_chan.children.size() > 0)
240 cfg.name = node_chan.children[0].value;
241 continue;
242 }
243 if (node_chan.value.rfind("V_P1", 0) == 0) {
244 if (node_chan.children.size() > 0) {
245 const auto& str_field = node_chan.children[0].value;
246 cfg.V_P1 = std::atoi(str_field.data());
247 }
248 continue;
249 }
250 if (node_chan.value.rfind("V_P2", 0) == 0) {
251 if (node_chan.children.size() > 0) {
252 const auto& str_field = node_chan.children[0].value;
253 cfg.V_P2 = std::atoi(str_field.data());
254 }
255 continue;
256 }
257 if (node_chan.value.rfind("State", 0) == 0) {
258 if (node_chan.children.size() > 0) {
259 const auto& str_field = node_chan.children[0].value;
260 cfg.state = (str_field.rfind("On", 0) == 0) ? true : false;
261 }
262 continue;
263 }
264 }
265 // cfg.print();
266 }
267 } break;
268 case T0Config::BDMult: {
269 regex re("BDM_(\\w+)\\r*");
270 for (const auto& node_par : ch) {
271 string spar = regex_replace(node_par.value, re, "$1");
272 if (node_par.children.size() > 0) {
273 const auto& str_field = node_par.children[0].value;
274 uint32_t thr = std::atoi(str_field.data());
275 if (spar == "H")
276 rt0dig->SetBDMultH(thr);
277 if (spar == "L")
278 rt0dig->SetBDMultL(thr);
279 // LOGF(info, "BDMH %u BDML %u ", rt0dig->GetBDMultH(),
280 // rt0dig->GetBDMultL());
281 }
282 }
283 } break;
284 case T0Config::ExtraDelaysMask: {
285 regex re("\\$([0-9a-fA-F]+)\\r*");
286 for (const auto& node_par : ch) {
287 string snum = regex_replace(node_par.value, re, "$1");
288 uint32_t num = std::stoul(snum.data(), nullptr, 16);
289 // LOGF(info, " num %X", num);
290 rt0dig->SetExtraDelaysMask(num);
291 }
292 } break;
293 default:
294 break;
295 }
296 }
297 } catch (const std::exception& e) {
298 LOG(error) << "Error: " << e.what();
299 return kBMNERROR;
300 }
301 return kBMNSUCCESS;
302}
303
304SpillStatus BmnConverterTools::ParseJsonStatus(json& jv, int32_t tai_utc_dif)
305{
306 SpillStatus ss{};
307 auto& j_runtime = jv["runTime"];
308 auto& j_spill = j_runtime["spill"];
309 ss.phase = static_cast<uint32_t>(j_spill["phase"]);
310 ss.cur_spill_time_ms = static_cast<uint32_t>(j_spill["curSpillTimeMs"]);
311 ss.spill_cnt = static_cast<uint32_t>(j_spill["count"]);
312 auto j_device_time = j_runtime["time"];
313 ss.app_ts = SysClock::from_time_t(static_cast<uint32_t>(j_device_time["app"]));
314 auto j_device_time_WR = j_device_time["WR"];
315 ss.device_ts = ParseTAI(j_device_time_WR, tai_utc_dif);
316 auto j_spill_start = j_spill["spillStartTaiWrStat"];
317 ss.start_ts = ParseTAI(j_spill_start, tai_utc_dif);
318 auto j_spill_stop = j_spill["spillStopTaiWrStat"];
319 ss.stop_ts = ParseTAI(j_spill_stop, tai_utc_dif);
320 ss.CheckTimes();
321 auto& j_counters = j_runtime["counters"];
322 if (j_counters.contains("input_afterReduc")) {
323 {
324 auto& j_cnt_input = j_counters["input"];
325 uint32_t size_input = j_cnt_input.size();
326 ss.counters.cntr_input.resize(size_input);
327 size_t iInput = 0;
328 for (auto& [key, val] : j_cnt_input.items()) {
329 string name = static_cast<string>(key);
330 ss.counters.cntr_input[iInput].first = move(name);
331 size_t size = min(val.size(), SpillStatus::counters_cnt);
332 for (size_t i = 0; i < size; i++)
333 ss.counters.cntr_input[iInput].second[i] = static_cast<uint32_t>(val[i]);
334 iInput++;
335 }
336 }
337 {
338 auto& j_cnt_input = j_counters["input_afterReduc"];
339 uint32_t size_input = j_cnt_input.size();
340 ss.counters.cntr_input_after_red.resize(size_input);
341 size_t iInput = 0;
342 for (auto& [key, val] : j_cnt_input.items()) {
343 string name = static_cast<string>(key);
344 ss.counters.cntr_input_after_red[iInput].first = move(name);
345 size_t size = min(val.size(), SpillStatus::counters_cnt);
346 for (size_t i = 0; i < size; i++)
347 ss.counters.cntr_input_after_red[iInput].second[i] = static_cast<uint32_t>(val[i]);
348 iInput++;
349 }
350 }
351 } else { // crutch for runs before #7081
352 {
353 auto& j_cnt_input = j_counters["input"];
354 size_t size = min(j_cnt_input.size(), SpillStatus::counters_cnt);
355 ss.counters.cntr_input.resize(1);
356 ss.counters.cntr_input[0].first = "7: ~xOff & Run & Spill";
357 for (size_t i = 0; i < size; i++)
358 ss.counters.cntr_input[0].second[i] = static_cast<uint32_t>(j_cnt_input[i]);
359 }
360 {
361 auto& j_cnt_input = j_counters["after_reduc"];
362 size_t size = min(j_cnt_input.size(), SpillStatus::counters_cnt);
363 ss.counters.cntr_input_after_red.resize(1);
364 ss.counters.cntr_input_after_red[0].first = "7: ~xOff & Run & Spill";
365 for (size_t i = 0; i < size; i++)
366 ss.counters.cntr_input_after_red[0].second[i] = static_cast<uint32_t>(j_cnt_input[i]);
367 }
368 }
369 {
370 auto& j_cnt_ae = j_counters["after_err"];
371 size_t size = min(j_cnt_ae.size(), SpillStatus::counters_cnt);
372 for (size_t i = 0; i < size; i++)
373 ss.counters.cntr_after_err[i] = static_cast<uint32_t>(j_cnt_ae[i]);
374 }
375 {
376 auto& j_cnt_ae = j_counters["befor_err"];
377 size_t size = min(j_cnt_ae.size(), SpillStatus::counters_cnt);
378 for (size_t i = 0; i < size; i++)
379 ss.counters.cntr_befor_err[i] = static_cast<uint32_t>(j_cnt_ae[i]);
380 }
381 LOG(debug) << BmnFunctionSet::TimePoint2String(ss.start_ts) << " start";
382 LOG(debug) << BmnFunctionSet::TimePoint2String(ss.stop_ts) << " stop";
383 LOG(debug) << BmnFunctionSet::TimePoint2String(ss.device_ts) << " dev ts WR";
384 LOG(debug) << BmnFunctionSet::TimePoint2String(ss.app_ts) << " app ts";
385 return ss;
386}
387
389{
390 // Phys trig config
391 auto ph_trig_setups = j["programs"]["Trc#T0"]["knownSetups"];
392 if (ph_trig_setups.size()) {
393 auto ph_trig = ph_trig_setups.begin().value()["trc"]["phyTrig"];
394 uint32_t match_win = ph_trig["matchWin"];
395 uint32_t trig_delay = ph_trig["trigDelay"];
396 uint32_t read_chan_mask = ph_trig["readChMask"];
397 uint32_t start_chan_mask = ph_trig["startChMask"];
398 uint32_t calib_cnt = ph_trig["calibTrigger"]["count"];
399 uint32_t calib_en = (bool)ph_trig["calibTrigger"]["en"];
400 trig_conf.SetMatchWindow(match_win * TRC_CLOCK_NS);
401 trig_conf.SetTrigDelay(trig_delay * TRC_CLOCK_NS);
402 trig_conf.SetCalibCount(calib_cnt);
403 trig_conf.SetCalibEn(calib_en);
404 trig_conf.SetStartChannelMask(start_chan_mask);
405 trig_conf.SetReadChannelMask(read_chan_mask);
406 LOGF(debug, "start_chan_mask %u", start_chan_mask);
407 LOGF(debug, "read_chan_mask %u", read_chan_mask);
408 auto ch_conf = ph_trig["chCfg"];
409 unordered_map<string, BmnTrigChannelConfig>& tcc = trig_conf.TrigChannelConfig();
410 for (auto& trig_chan_conf : ch_conf) {
411 LOG(debug2) << trig_chan_conf.dump();
412 string name = trig_chan_conf["name"];
413 if (name.length() == 0)
414 continue;
416 tcc_el.after_protect_en = (bool)trig_chan_conf["reg"]["after_protect_en"].get<int>();
417 uint32_t ap_clocks = trig_chan_conf["reg"]["after_protect_time"];
418 tcc_el.after_protect_time = ap_clocks * TRC_CLOCK_NS;
419 tcc_el.before_protect_en = (bool)trig_chan_conf["reg"]["before_protect_en"].get<int>();
420 uint32_t bp_clocks = trig_chan_conf["reg"]["before_protect_time"];
421 tcc_el.before_protect_time = bp_clocks * TRC_CLOCK_NS;
422 tcc_el.delay = trig_chan_conf["reg"]["delay"];
423 tcc_el.reduction_en = (bool)trig_chan_conf["reg"]["reduction_en"].get<int>();
424 tcc_el.reduction_factor = trig_chan_conf["reg"]["reduction_factor"];
425 tcc.insert(make_pair(name, tcc_el));
426 }
427 return kBMNSUCCESS;
428 } else
429 return kBMNERROR;
430}
431
432BmnStatus BmnConverterTools::ParseComplexTLV(const uint32_t* d, uint32_t& len, uint32_t& runId)
433{
434 uint16_t iWord = 0;
435 while (iWord < len / kNBYTESINWORD) {
436 uint32_t word = d[iWord++];
437 uint32_t idLen = 0;
438 switch (word) {
440 idLen = d[iWord++];
441 if (idLen != kNBYTESINWORD) {
442 LOGF(error, "Wrong RunId length %u", idLen);
443 return kBMNERROR;
444 }
445 runId = d[iWord];
446 LOGF(info, "\tRun Id: %u", runId);
447 break;
448 case RECORD_EVENT_ORDER: {
449 idLen = d[iWord++];
450 if (idLen != kNBYTESINWORD) {
451 LOGF(error, "Wrong event order length %u", idLen);
452 return kBMNERROR;
453 }
454 uint32_t event_order = d[iWord];
455 LOGF(info, "\tEvent Order: %u", event_order);
456 break;
457 }
458 case RECORD_FILE_ID: {
459 idLen = d[iWord++];
460 if (idLen != kNBYTESINWORD) {
461 LOGF(error, "Wrong FileId length %u", idLen);
462 return kBMNERROR;
463 }
464 uint32_t file_id = d[iWord];
465 LOGF(info, "\tFile Id: %u", file_id);
466 break;
467 }
468 case RECORD_RUN_INDEX: {
469 idLen = d[iWord++];
470 if (idLen + iWord * kNBYTESINWORD > len) {
471 LOGF(error, "Wrong RunIndex length %u", idLen);
472 return kBMNERROR;
473 }
474 // printf("idLen %u\n", idLen);
475 TString runIndex(reinterpret_cast<const char*>(d + iWord), idLen);
476 LOGF(info, "\tRun Index: %s", runIndex.Data());
477 break;
478 }
479 default:
480 LOGF(warning, "Unknown record %08X", word);
481 break;
482 }
483 iWord += idLen * kNBYTESINWORD;
484 }
485 return kBMNSUCCESS;
486}
487
489{
490 TString str(name);
491 TPRegexp re_data(".+_(\\d+)([^/]*)\\.data");
492 TPRegexp re_raw(".+_(\\d+)([^/]*)_raw\\.root");
493 // TPRegexp re_data(".*\\w+_\\w+_\\w+_(\\d+)([^/]*)\\.data");
494 // TPRegexp re_raw(".*\\w+_run(\\d+)([^/]*)_raw\\.root");
495 if (re_data.MatchB(str))
496 re_data.Substitute(str, "$2");
497 else {
498 if (re_raw.MatchB(str))
499 re_raw.Substitute(str, "$2");
500 else
501 return "";
502 }
503 return str;
504}
505
507{
508 string ss(s.Data());
509 return ParseRawFileName(ss, prop);
510}
512{
513 int32_t lastSlash = path.rfind('/');
514 string name(path.substr(lastSlash + 1, path.length() - lastSlash));
515 LOGF(debug, "name: %s", name.data());
516 // regex re6("(\\w+)_(\\w+)_(\\w+)_(\\d+)_ev(\\d+)_p(\\d+)\\.(\\w+)\\r*");
517 // regex re5("(\\w+)_(\\w+)_(\\w+)_(\\d+)_ev(\\d+)(_p\\d+){0,1}\\.(\\w+)\\r*");
518 regex re6("(.+)_(\\d+)_ev(\\d+)_p(\\d+)\\.(\\w+)([\\.\\w]+)\\r*");
519 regex re5("(.+)_(\\d+)_ev(\\d+)(_p\\d+){0,1}\\.(\\w+)([\\.\\w]+)\\r*");
520 if (!regex_match(name, re5)) {
521 LOGF(error, "regex doesn't match: %s", name.data());
522 return kBMNERROR;
523 }
524 // string str_exp = regex_replace(name, re5, "$1");
525 // string str_run = regex_replace(name, re5, "$2");
526 // string str_run_in = regex_replace(name, re5, "$3");
527 // string str_run_id = regex_replace(name, re5, "$4");
528 // string str_ev_ord = regex_replace(name, re5, "$5");
529 string str_run_id = regex_replace(name, re5, "$2");
530 string str_ev_ord = regex_replace(name, re5, "$3");
531 uint32_t run_id = std::stoul(str_run_id.data());
532 uint32_t ev_ord = std::stoul(str_ev_ord.data());
533
534 prop.SetRunId(run_id);
535 prop.SetEventOrder(ev_ord);
536
537 uint32_t part_id = 0;
538 if (regex_match(name, re6)) {
539 string str_part = regex_replace(name, re6, "$4");
540 part_id = std::stoul(str_part.data());
541 }
542 prop.SetFileId(part_id);
543
544 string str_pre_id = regex_replace(name, re5, "$1");
545 regex re_names("((\\w+)_)*([^_]+)_(\\w+)");
546 if (regex_match(str_pre_id, re_names)) {
547 string str_exp = regex_replace(str_pre_id, re_names, "$2");
548 string str_run = regex_replace(str_pre_id, re_names, "$3");
549 string str_run_in = regex_replace(str_pre_id, re_names, "$4");
550 LOGF(debug, "exp %s", str_exp.data());
551 LOGF(debug, "run %s", str_run.data());
552 LOGF(debug, "run_in %s", str_run_in.data());
553 prop.SetRunIndex(str_run_in);
554 }
555 LOGF(debug, "run_id %d", prop.GetRunId());
556 LOGF(debug, "ev_ord %d", prop.GetEventOrder());
557 LOGF(debug, "part_id %d", prop.GetFileId());
558 return kBMNSUCCESS;
559}
int i
Definition P4_F32vec4.h:22
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
BmnStatus
Define status code.
Definition BmnEnums.h:93
@ kBMNERROR
Error.
Definition BmnEnums.h:95
@ kBMNSUCCESS
Success.
Definition BmnEnums.h:94
std::chrono::time_point< SysClock > SysPoint
const uint32_t RECORD_FILE_ID
Definition RawTypes.h:17
const uint32_t RECORD_RUN_NUMBER
Definition RawTypes.h:14
const uint32_t RECORD_EVENT_ORDER
Definition RawTypes.h:16
const uint32_t kT0_BIN_BLOCK_2020_SEC
Definition RawTypes.h:95
const uint32_t kT0_BIN_BLOCK_TIME_TXT
Definition RawTypes.h:97
const uint32_t kNBYTESINWORD
Definition RawTypes.h:19
const uint32_t kT0_BIN_BLOCK_UNIX_SEC
Definition RawTypes.h:96
const uint32_t kT0_BIN_BLOCK_BYTES
Definition RawTypes.h:94
const double TRC_CLOCK_NS
Definition RawTypes.h:100
const uint32_t RECORD_RUN_INDEX
Definition RawTypes.h:15
const uint32_t kT0_BIN_BLOCK_WORDS
Definition RawTypes.h:93
const size_t kWORDSIZE
Definition RawTypes.h:18
static BmnT0Raw * Process_T0Raw(const uint32_t *d, uint32_t len, TClonesArray *t0raw=nullptr)
static TString GetSubNameAfterRunId(TString name)
static BmnStatus ParseRawT0TextConfig(string &s, BmnT0Raw *rt0dig)
static T0Config GetT0Cfg(string str)
static BmnStatus ParseRawFileName(const TString &s, BmnFileProp &prop)
static SysPoint ParseTAI(json &j, Int_t tai_utc_dif=0)
static BmnStatus ParseJsonConfig(json &j, BmnTrigConfig &trig_conf)
static BmnStatus ParseComplexTLV(const uint32_t *buf, UInt_t &len, UInt_t &runId)
static SpillStatus ParseJsonStatus(json &j, Int_t tai_utc_dif=0)
uint32_t GetFileId() const
Definition BmnFileProp.h:25
void SetFileId(uint32_t fid)
Definition BmnFileProp.h:20
void SetRunIndex(string index)
Definition BmnFileProp.h:18
uint32_t GetRunId() const
Definition BmnFileProp.h:22
void SetEventOrder(uint32_t order)
Definition BmnFileProp.h:19
void SetRunId(uint32_t v)
Definition BmnFileProp.h:17
uint32_t GetEventOrder() const
Definition BmnFileProp.h:24
static std::string TimePoint2String(SysPoint p)
T0 module spill settings and counts.
Definition BmnT0Raw.h:70
map< uint32_t, Discriminator_Config > & Discriminators()
Definition BmnT0Raw.h:117
void SetBDMultH(uint32_t val)
Definition BmnT0Raw.h:127
void SetBDMultL(uint32_t val)
Definition BmnT0Raw.h:131
map< uint32_t, bool > & Switches()
Definition BmnT0Raw.h:121
void SetComment(string str)
Definition BmnT0Raw.h:123
map< uint32_t, LV_Channel_Config > & LVChannelConfig()
Definition BmnT0Raw.h:119
void SetTime(SysPoint point)
Definition BmnT0Raw.h:90
void SetTS(TTimeStamp ts)
Definition BmnT0Raw.h:94
void SetTriggerMask(uint32_t val)
Definition BmnT0Raw.h:139
map< uint32_t, int32_t > & DelayLines()
Definition BmnT0Raw.h:120
void SetExtraDelaysMask(uint32_t val)
Definition BmnT0Raw.h:135
Class BmnTrigConfig Trigger DAQ config.
void SetTrigDelay(uint32_t v)
void SetReadChannelMask(uint32_t v)
void SetStartChannelMask(uint32_t v)
void SetCalibCount(uint32_t v)
unordered_map< string, BmnTrigChannelConfig > & TrigChannelConfig()
void SetCalibEn(bool v)
void SetMatchWindow(uint32_t v)
TObject * Remove(TObject *obj) override
Int_t GetEntriesFast() const
Bool_t MatchB(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
Int_t Substitute(TString &s, const TString &replace, const TString &mods="", Int_t start=0, Int_t nMatchMax=10)
const char * Data() const
time_t GetSec() const
Int_t GetNanoSec() const
const char * AsString(const Option_t *option="") const
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
void ParseIStringStream(istringstream &iss, Node &root)
Class BmnTrigChannelConfig Trigger channel configuration (count reduction, time protection).
std::array< ULong64_t, counters_cnt > cntr_after_err
Definition SpillCntrs.h:11
std::vector< std::pair< std::string, std::array< ULong64_t, counters_cnt > > > cntr_input
Definition SpillCntrs.h:13
std::vector< std::pair< std::string, std::array< ULong64_t, counters_cnt > > > cntr_input_after_red
Definition SpillCntrs.h:14
std::array< ULong64_t, counters_cnt > cntr_befor_err
Definition SpillCntrs.h:12
Class SpillStatus raw spill status from JSON block.
Definition SpillStatus.h:20
SysPoint device_ts
Definition SpillStatus.h:41
SpillCntrs< counters_cnt > counters
Definition SpillStatus.h:47
UInt_t spill_cnt
Definition SpillStatus.h:44
static const size_t counters_cnt
Definition SpillStatus.h:38
SysPoint start_ts
Definition SpillStatus.h:39
bool CheckTimes()
Definition SpillStatus.h:32
SysPoint app_ts
Definition SpillStatus.h:42
SysPoint stop_ts
Definition SpillStatus.h:40
UInt_t cur_spill_time_ms
Definition SpillStatus.h:43
UInt_t phase
Definition SpillStatus.h:45