19 #include <boost/regex.hpp> 20 #include <boost/format.hpp> 21 #include <boost/range.hpp> 22 #include <boost/filesystem.hpp> 23 #include <boost/algorithm/string/predicate.hpp> 26 namespace rdm {
struct Empty {}; }
36 std::shared_ptr<rdm::Empty>
44 void analyzeFile(
std::string fn,
unsigned int run,
unsigned int lumi,
46 double getRunTimestamp()
const;
63 mutable double global_start_ = 0.;
72 ps.getUntrackedParameter<std::vector<std::string> >(
"streamLabels")},
92 ib.
book1D(
"EventAccepted",
"# of accepted events per lumi", 4, 0., 4.);
94 "# of processed events per lumi", 4, 0., 4.);
97 "Observed delivery delay for the data file (mtime).", 4, 0., 4.);
100 "Observed delivery delay for the data file (ctime).", 4, 0., 4.);
127 if (::
stat(run_global.c_str(), &st) != 0) {
144 auto itStream =
streams_.find(label);
146 edm::LogPrint(
"RamdiskMonitor") <<
"Stream not monitored [" << label
154 LumiEntry lumi_jsn = LumiEntry::load_json(
runPath_, fn, lumi, -1);
160 if (::
stat(fn.c_str(), &st) != 0) {
168 if (start_offset <= 0)
return;
172 double mtime = st.st_mtime;
173 double ctime = st.st_ctime;
176 double start_offset_mtime = mtime - start_offset -
LUMI;
177 double start_offset_ctime = ctime - start_offset -
LUMI;
178 double lumi_offset = (lumi - 1) * LUMI;
181 double delay_mtime = start_offset_mtime - lumi_offset;
182 double delay_ctime = start_offset_ctime - lumi_offset;
188 std::shared_ptr<dqm::rdm::Empty>
192 using boost::filesystem::directory_iterator;
193 using boost::filesystem::directory_entry;
195 directory_iterator dend;
196 for (directory_iterator di(
runPath_); di != dend; ++di) {
197 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
207 if (boost::regex_match(filename, result, fn_re)) {
208 unsigned int run = std::stoi(result[1]);
209 unsigned int lumi = std::stoi(result[2]);
217 if ((lumi == 0) && (label ==
"EoR")) {
237 return std::shared_ptr<dqm::rdm::Empty>();
245 "Analyses file timestams in the /fff/ramdisk and creates monitor " 248 desc.
addUntracked<std::vector<std::string> >(
"streamLabels")
249 ->setComment(
"List of streams to monitor.");
252 ->setComment(
"Run number passed via configuration file.");
255 ->setComment(
"Directory where the DQM files will appear.");
257 d.
add(
"RamdiskMonitor", desc);
static const char runNumber_[]
void globalEndLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) final
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
std::map< std::string, StreamME > streams_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::shared_ptr< rdm::Empty > globalBeginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) const override
const std::string runPath_
void analyzeFile(std::string fn, unsigned int run, unsigned int lumi, std::string label) const
MonitorElement * eventsAccepted
MonitorElement * eventsProcessed
void setComment(std::string const &value)
MonitorElement * deliveryDelayCTime
#define DEFINE_FWK_MODULE(type)
void setCurrentFolder(std::string const &fullpath)
MonitorElement * book1D(Args &&...args)
~RamdiskMonitor() override
double getRunTimestamp() const
format
Some error handling for the usage.
const std::vector< std::string > streamLabels_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
MonitorElement * deliveryDelayMTime
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
RamdiskMonitor(const edm::ParameterSet &ps)
dqm::RamdiskMonitor RamdiskMonitor
const std::string runInputDir_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
std::set< std::string > filesSeen_
const unsigned int runNumber_