5 #include <boost/regex.hpp>
6 #include <boost/format.hpp>
7 #include <boost/range.hpp>
8 #include <boost/filesystem.hpp>
9 #include <boost/algorithm/string/predicate.hpp>
14 #include <boost/property_tree/json_parser.hpp>
15 #include <boost/property_tree/ptree.hpp>
17 namespace dqmservices {
21 boost::property_tree::ptree
pt;
22 read_json(filename, pt);
28 ->
second.get_value<std::size_t>();
31 ->
second.get_value<std::size_t>();
35 if (datafn_position >= 0) {
47 boost::property_tree::ptree
pt;
48 read_json(filename, pt);
55 ->
second.get_value<std::size_t>();
57 ->
second.get_value<std::size_t>();
95 if (
mon_.isAvailable()) {
97 doc.put(
"run", runNumber_);
99 doc.put(
"fi_state", std::to_string(
state_));
100 mon_->outputUpdate(doc);
131 using boost::property_tree::ptree;
139 auto iter =
lumiSeen_.lower_bound(currentLumi);
142 iter->second.state = reason;
148 if (
mon_.isAvailable()) {
152 mon_->outputUpdate(doc);
157 if (!
mon_.isAvailable())
return;
162 mon_->outputUpdate(doc);
166 if (boost::starts_with(fn,
"/"))
return fn;
178 auto last_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
182 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
187 std::time_t mtime_now = boost::filesystem::last_write_time(
runPath_);
200 using boost::filesystem::directory_iterator;
201 using boost::filesystem::directory_entry;
205 directory_iterator dend;
206 for (directory_iterator di(
runPath_); di != dend; ++di) {
207 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
217 if (boost::regex_match(filename, result, fn_re)) {
218 unsigned int run = std::stoi(result[1]);
219 unsigned int lumi = std::stoi(result[2]);
228 if ((lumi == 0) && (label ==
"EoR") && (!
eor_.
loaded)) {
240 std::string msg(
"Found and skipped json file (stream label mismatch, ");
241 msg += label +
" [files] != " +
streamLabel_ +
" [config]";
266 if (!fn_eor.empty()) {
286 using std::chrono::high_resolution_clock;
287 using std::chrono::duration_cast;
288 using std::chrono::milliseconds;
299 state_ = State::EOR_CLOSING;
308 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
313 std::to_string(iter->first - 1);
314 msg +=
", nextLumiNumber_ is now " + std::to_string(iter->first);
322 if (
state_ == State::EOR_CLOSING) {
334 if (
state_ != old_state) {
336 std::to_string(old_state) +
"->" + std::to_string(
state_));
340 doc.put(
"fi_state", std::to_string(
state_));
341 mon_->outputUpdate(doc);
360 logFileAction(
"Internal error: referenced lumi is not the map.");
365 if (
mon_.isAvailable())
mon_->keepAlive();
372 ->setComment(
"Run number passed via configuration file.");
376 "Data filename position in the positional arguments array 'data' in "
380 ->setComment(
"Stream label used in json discovery.");
383 ->setComment(
"Number of milliseconds to wait between file checks.");
387 "Number of milliseconds to wait before switching to the next lumi "
388 "section if the current is missing, -1 to disable.");
392 "Don't repeat file scans: use what was found during the initial scan. "
393 "EOR file is ignored and the state is set to 'past end of run'.");
396 ->setComment(
"Directory where the DQM files will appear.");
T getUntrackedParameter(std::string const &, T const &) const
unsigned long delayMillis_
std::string make_path(const std::string &fn)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
unsigned int lastLumiFound()
edm::Service< DQMMonitoringService > mon_
void logLumiState(const LumiEntry &lumi, const std::string &msg)
std::map< unsigned int, LumiEntry > lumiSeen_
string format
Some error handling for the usage.
std::size_t n_events_accepted
U second(std::pair< T, U > const &p)
DQMFileIterator(edm::ParameterSet const &pset)
std::size_t n_events_processed
long nextLumiTimeoutMillis_
void logFileAction(const std::string &msg, const std::string &fileName="") const
static EorEntry load_json(const std::string &filename)
std::chrono::high_resolution_clock::time_point lastLumiLoad_
static LumiEntry load_json(const std::string &filename, int lumiNumber, int datafn_position)
unsigned int nextLumiNumber_
unsigned int datafnPosition_
long forceFileCheckTimeoutMillis_
void monUpdateLumi(const LumiEntry &lumi)
std::chrono::high_resolution_clock::time_point runPathLastCollect_
std::unordered_set< std::string > filesSeen_
std::time_t runPathMTime_
void advanceToLumi(unsigned int lumi, std::string reason)
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)