92bool initOptionsAndParse(bpo::options_description& options,
int argc,
char* argv[], bpo::variables_map& vm)
94 options.add_options()(
95 "run,r", bpo::value<int>()->default_value(8),
"Run number to inspect")(
96 "enable-debug,d", bpo::value<bool>()->default_value(
false)->implicit_value(
true),
"Enable debug logs")(
97 "help,h",
"Produce help message.");
100 bpo::store(parse_command_line(argc, argv, options), vm);
103 if (vm.count(
"help")) {
104 std::cout << options << std::endl;
109 }
catch (
const bpo::error& e) {
110 std::cerr << e.what() <<
"\n\n";
111 std::cerr <<
"Error parsing command line arguments; Available options:\n";
113 std::cerr << options << std::endl;
119int main(
int argc,
char* argv[])
121 bpo::options_description options(
"Allowed options");
122 bpo::variables_map vm;
127 auto run = vm[
"run"].as<
int>();
128 auto debug = vm[
"enable-debug"].as<
bool>();
135 std::pair<uint64_t, uint64_t> run_times = ccdb_inst.getRunDuration(run);
136 long run_O2duration =
long(run_times.second - run_times.first);
138 int64_t tsSOR = run_times.first;
139 int64_t tsEOR = run_times.second;
140 LOGP(info,
"tsSOR = {} ms, tsEOR = {} ms", tsSOR, tsEOR);
143 LOGP(info,
"Getting B field");
144 std::map<std::string, std::string> metadata;
145 ccdb_inst.setFatalWhenNull(
true);
147 o2::units::Current_t magFieldL3Curr = magField->
getL3Current();
148 LOGP(info,
"run {}: B field = {}", run, magFieldL3Curr);
152 LOGP(info,
"Getting detector participating in the run");
153 std::map<std::string, std::string> metadataRun;
156 std::string dets =
"";
157 for (
int i = o2::detectors::DetID::First;
i < o2::detectors::DetID::nDetectors; ++
i) {
162 LOGP(info,
"run {}: detectors in readout = {}", run, dets);
165 LOGP(info,
"Checking IR and duration");
168 ccdb_inst.setFatalWhenNull(
false);
169 metadata[
"runNumber"] = Form(
"%d", run);
172 LOGP(info,
"CTP/Calib/Scalers object does not exist in production CCDB, trying test CCDB");
173 ccdb_inst.setURL(
"http://ccdb-test.cern.ch:8080");
176 LOGP(info,
"Cannot get IR for run {} neither from production nor test CCDB, writing -1.f", run);
177 LOGP(info,
"In addition, the duration for these runs is O2end - O2start: if the run was short, this might overestimate the duration");
188 int n = mScalerRecordO2.size();
190 std::int64_t totScalers = 0;
191 std::vector<int64_t> vOrbit;
192 std::vector<int64_t> vScaler;
194 for (
auto& record : mScalerRecordO2) {
196 record.printStream(std::cout);
198 std::vector<CTPScalerO2>& scalers = record.scalers;
200 vOrbit.push_back(intRecord.
orbit);
202 LOGP(info,
"{} orbit = {} scalers = {}",
i, intRecord.
orbit, scalers[0].lmBefore);
204 vScaler.push_back(scalers[0].lmBefore);
205 totScalers += scalers[0].lmBefore;
209 duration = std::round((vOrbit.back() - vOrbit.front()) *
orbitDuration * 1e-6);
210 ir = float(vScaler.back() - vScaler.front()) / duration;
211 LOGP(info,
"run {}: orbit.front = {} orbit.back = {} duration = {} s scalers = {} IR = {} Hz", run, vOrbit.front(), vOrbit.back(), duration, vScaler.back() - vScaler.front(),
ir);
215 LOGP(info,
"IR < 100 kHz");
217 LOGP(info,
"IR > 100 kHz");