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>();
92 if (
mon_.isAvailable()) {
94 doc.put(
"run", runNumber_);
97 mon_->outputUpdate(doc);
128 using boost::property_tree::ptree;
136 auto iter =
lumiSeen_.lower_bound(currentLumi);
139 iter->second.state = reason;
145 if (
mon_.isAvailable()) {
149 mon_->outputUpdate(doc);
154 if (!
mon_.isAvailable())
return;
159 mon_->outputUpdate(doc);
163 if (boost::starts_with(fn,
"/"))
return fn;
175 auto last_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
179 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
184 std::time_t mtime_now = boost::filesystem::last_write_time(
runPath_);
197 using boost::filesystem::directory_iterator;
198 using boost::filesystem::directory_entry;
202 directory_iterator dend;
203 for (directory_iterator di(
runPath_); di != dend; ++di) {
204 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
214 if (boost::regex_match(filename, result, fn_re)) {
215 unsigned int run = std::stoi(result[1]);
216 unsigned int lumi = std::stoi(result[2]);
225 if ((lumi == 0) && (label ==
"EoR") && (!
eor_.
loaded)) {
237 std::string msg(
"Found and skipped json file (stream label mismatch, ");
238 msg += label +
" [files] != " +
streamLabel_ +
" [config]";
262 if (!fn_eor.empty()) {
281 using std::chrono::high_resolution_clock;
282 using std::chrono::duration_cast;
283 using std::chrono::milliseconds;
291 state_ = State::EOR_CLOSING;
300 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
314 if (
state_ == State::EOR_CLOSING) {
326 if (
state_ != old_state) {
333 mon_->outputUpdate(doc);
352 logFileAction(
"Internal error: referenced lumi is not the map.");
357 if (
mon_.isAvailable())
mon_->keepAlive();
364 ->setComment(
"Run number passed via configuration file.");
368 "Data filename position in the positional arguments array 'data' in "
372 ->setComment(
"Stream label used in json discovery.");
375 ->setComment(
"Number of milliseconds to wait between file checks.");
379 "Number of milliseconds to wait before switching to the next lumi "
380 "section if the current is missing, -1 to disable.");
383 ->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)
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)
std::string to_string(const T &t)
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)