CbmRoot
Loading...
Searching...
No Matches
CbmRunDatabase.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#include "CbmRunDatabase.h"
11
12#include <Logger.h>
13
14#include <type_traits>
15
17
18// ---------------------------------------------------------------------------------------------------------------------
19//
20bool RunDatabase::LoadRun(uint32_t runId)
21{
22 bool success{true};
23
24 // Load common contents
25 try {
27 auto GetEntry = [&success, runId](const auto& mapped) -> auto
28 {
29 auto res = std::prev(mapped.upper_bound(runId))->second;
30 if constexpr (std::is_same_v<std::string, decltype(res)>) {
31 if (res.empty()) {
32 success = false;
33 }
34 }
35 return res;
36 };
37
38 fBmonCalibrationTag = GetEntry(common.calibration.bmon);
39 fTofCalibrationTag = GetEntry(common.calibration.tof);
40 fAlignmentTag = GetEntry(common.alignment);
41 fGeoSetupTag = GetEntry(common.common.geoSetup);
42 fRecoParTag = GetEntry(common.recoPar);
43 if (!success) {
44 LOG(error) << "Matching range for run " << runId << " not found for at least one field in run DB at "
46 }
47 }
48 catch (YAML::BadFile&) {
49 LOG(error) << "General run database not found at " << fPathCommonDb;
50 success = false;
51 }
52
53
54 // Load mCBM run start-time (data only with UTC seconds precision for historical reasons)
55 try {
57 try {
58 // Store as UTC nanoseconds rounded to seconds
59 fRunStartTimeNs = startdb.runStartTime.at(runId) * 1000000000;
60 }
61 catch (const std::out_of_range&) {
62 LOG(error) << "Start time for run " << runId << " not found in mCBM table at " << fPathRunStartTimeDb
63 << " => Setting it to 0";
65 }
66 }
67 catch (YAML::BadFile&) {
68 LOG(error) << "mCBM Runs Start time table not found at " << fPathRunStartTimeDb << " => Setting start time to 0";
70 }
71
72 if (success) {
73 fRunId = runId;
74 }
75 return success;
76}
77
78
79// ---------------------------------------------------------------------------------------------------------------------
80//
81std::string RunDatabase::ToString() const
82{
83 std::stringstream msg;
84 msg << "====== CBM Run #" << fRunId;
85 msg << "\n\tSetup geometry tag: " << fGeoSetupTag;
86 msg << "\n\tBMON calibration tag: " << fBmonCalibrationTag;
87 msg << "\n\tTOF calibration tag: " << fTofCalibrationTag;
88 msg << "\n\tAlignment tag: " << fTofCalibrationTag;
89 msg << "\n\tReconstruction parameter tag: " << fRecoParTag;
90 msg << "\n\tRun starttime [ns]: " << fRunStartTimeNs;
91 return msg.str();
92}
bool LoadRun(uint32_t runId)
Loads the information for the run from the file.
The main calibration data base class for CBM.
uint32_t fRunId
Current run ID.
std::string fGeoSetupTag
Geometry setup tag for a given run ID.
std::string fTofCalibrationTag
TOF calibration tag for a given run ID.
std::string fRecoParTag
Tag for reconstruction parameters for a given run ID.
std::string fPathRunStartTimeDb
Path to the runtime data-base.
uint64_t fRunStartTimeNs
Run start time since the epoch [ns].
std::string ToString() const
String representation of the class contents.
std::string fAlignmentTag
Tag for alignment matrices.
std::string fPathCommonDb
Path to the common data-base.
std::string fBmonCalibrationTag
BMON calibration tag for a given run ID.
T ReadFromFile(fs::path path)
Definition CbmYaml.h:66