91bool initOptionsAndParse(bpo::options_description& options,
int argc,
char* argv[], bpo::variables_map& vm)
93 options.add_options()(
94 "run,r", bpo::value<int>()->default_value(8),
"Run number to inspect")(
95 "enable-debug,d", bpo::value<bool>()->default_value(
false)->implicit_value(
true),
"Enable debug logs")(
96 "help,h",
"Produce help message.");
99 bpo::store(parse_command_line(argc, argv, options), vm);
102 if (vm.count(
"help")) {
103 std::cout << options << std::endl;
108 }
catch (
const bpo::error& e) {
109 std::cerr << e.what() <<
"\n\n";
110 std::cerr <<
"Error parsing command line arguments; Available options:\n";
112 std::cerr << options << std::endl;
118int main(
int argc,
char* argv[])
120 bpo::options_description options(
"Allowed options");
121 bpo::variables_map vm;
126 auto run = vm[
"run"].as<
int>();
127 auto debug = vm[
"enable-debug"].as<
bool>();
133 ccdb_inst.setURL(
"http://alice-ccdb.cern.ch");
134 std::pair<uint64_t, uint64_t> run_times = ccdb_inst.getRunDuration(run);
135 long run_O2duration =
long(run_times.second - run_times.first);
137 int64_t tsSOR = run_times.first;
138 int64_t tsEOR = run_times.second;
139 LOGP(info,
"tsSOR = {} ms, tsEOR = {} ms", tsSOR, tsEOR);
142 LOGP(info,
"Getting B field");
143 std::map<std::string, std::string> metadata;
144 ccdb_inst.setFatalWhenNull(
true);
146 o2::units::Current_t magFieldL3Curr = magField->
getL3Current();
147 LOGP(info,
"run {}: B field = {}", run, magFieldL3Curr);
151 LOGP(info,
"Getting detector participating in the run");
152 std::map<std::string, std::string> metadataRun;
155 std::string dets =
"";
161 LOGP(info,
"run {}: detectors in readout = {}", run, dets);
164 LOGP(info,
"Checking IR and duration");
167 ccdb_inst.setFatalWhenNull(
false);
168 metadata[
"runNumber"] = Form(
"%d", run);
171 LOGP(info,
"CTP/Calib/Scalers object does not exist in production CCDB, trying test CCDB");
172 ccdb_inst.setURL(
"http://ccdb-test.cern.ch:8080");
175 LOGP(info,
"Cannot get IR for run {} neither from production nor test CCDB, writing -1.f", run);
176 LOGP(info,
"In addition, the duration for these runs is O2end - O2start: if the run was short, this might overestimate the duration");
187 int n = mScalerRecordO2.size();
189 std::int64_t totScalers = 0;
190 std::vector<int64_t> vOrbit;
191 std::vector<int64_t> vScaler;
193 for (
auto& record : mScalerRecordO2) {
195 record.printStream(std::cout);
197 std::vector<CTPScalerO2>& scalers = record.scalers;
199 vOrbit.push_back(intRecord.
orbit);
201 LOGP(info,
"{} orbit = {} scalers = {}",
i, intRecord.
orbit, scalers[0].lmBefore);
203 vScaler.push_back(scalers[0].lmBefore);
204 totScalers += scalers[0].lmBefore;
208 duration = std::round((vOrbit.back() - vOrbit.front()) *
orbitDuration * 1e-6);
209 ir = float(vScaler.back() - vScaler.front()) / duration;
210 LOGP(info,
"run {}: orbit.front = {} orbit.back = {} duration = {} s scalers = {} IR = {} Hz", run, vOrbit.front(), vOrbit.back(), duration, vScaler.back() - vScaler.front(),
ir);
214 LOGP(info,
"IR < 100 kHz");
216 LOGP(info,
"IR > 100 kHz");