6 #include <fmt/printf.h>
7 #include <boost/algorithm/string/predicate.hpp>
8 #include <boost/filesystem.hpp>
9 #include <boost/range.hpp>
10 #include <boost/regex.hpp>
59 static constexpr
double LUMI = 23.310893056;
64 runInputDir_{ps.getUntrackedParameter<
std::string>(
"runInputDir")},
65 streamLabels_{ps.getUntrackedParameter<std::vector<std::string>>(
"streamLabels")},
66 runPath_{fmt::sprintf(
"%s/run%06d", runInputDir_,
runNumber_)}
81 m.eventsAccepted =
ib.book1D(
"EventAccepted",
"# of accepted events per lumi", 4, 0., 4.);
82 m.eventsProcessed =
ib.book1D(
"EventProcessed",
"# of processed events per lumi", 4, 0., 4.);
83 m.deliveryDelayMTime =
84 ib.book1D(
"DeliveryDelayMTime",
"Observed delivery delay for the data file (mtime).", 4, 0., 4.);
85 m.deliveryDelayCTime =
86 ib.book1D(
"DeliveryDelayCTime",
"Observed delivery delay for the data file (ctime).", 4, 0., 4.);
88 m.eventsAccepted->getTH1F()->SetCanExtend(TH1::kXaxis);
89 m.eventsProcessed->getTH1F()->SetCanExtend(TH1::kXaxis);
90 m.deliveryDelayMTime->getTH1F()->SetCanExtend(TH1::kXaxis);
91 m.deliveryDelayCTime->getTH1F()->SetCanExtend(TH1::kXaxis);
93 m.eventsAccepted->setAxisTitle(
"Luminosity Section", 1);
94 m.eventsProcessed->setAxisTitle(
"Luminosity Section", 1);
95 m.deliveryDelayMTime->setAxisTitle(
"Luminosity Section", 1);
96 m.deliveryDelayCTime->setAxisTitle(
"Luminosity Section", 1);
98 m.eventsAccepted->setAxisTitle(
"Number of events", 2);
99 m.eventsProcessed->setAxisTitle(
"Number of events", 2);
100 m.deliveryDelayMTime->setAxisTitle(
"Delay (s.)", 2);
101 m.deliveryDelayCTime->setAxisTitle(
"Delay (s.)", 2);
113 if (::
stat(run_global.c_str(), &st) != 0) {
139 LumiEntry lumi_jsn = LumiEntry::load_json(
runPath_,
fn,
lumi, -1);
140 m.eventsAccepted->setBinContent(
lumi, lumi_jsn.n_events_accepted);
141 m.eventsProcessed->setBinContent(
lumi, lumi_jsn.n_events_processed);
145 if (::
stat(
fn.c_str(), &st) != 0) {
153 if (start_offset <= 0)
158 double mtime = st.st_mtime;
159 double ctime = st.st_ctime;
162 double start_offset_mtime = mtime - start_offset -
LUMI;
163 double start_offset_ctime = ctime - start_offset -
LUMI;
164 double lumi_offset = (
lumi - 1) *
LUMI;
167 double delay_mtime = start_offset_mtime - lumi_offset;
168 double delay_ctime = start_offset_ctime - lumi_offset;
170 m.deliveryDelayMTime->setBinContent(
lumi, delay_mtime);
171 m.deliveryDelayCTime->setBinContent(
lumi, delay_ctime);
177 using std::filesystem::directory_entry;
178 using std::filesystem::directory_iterator;
180 directory_iterator dend;
181 for (directory_iterator di(
runPath_); di != dend; ++di) {
182 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
223 return std::shared_ptr<dqm::rdm::Empty>();
230 "Analyses file timestams in the /fff/ramdisk and creates monitor "
233 desc.addUntracked<std::vector<std::string>>(
"streamLabels")->setComment(
"List of streams to monitor.");
235 desc.addUntracked<
unsigned int>(
"runNumber")->setComment(
"Run number passed via configuration file.");
237 desc.addUntracked<
std::string>(
"runInputDir")->setComment(
"Directory where the DQM files will appear.");
239 d.add(
"RamdiskMonitor",
desc);