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);
29 ->
second.get_value<std::size_t>();
42 boost::property_tree::ptree
pt;
43 read_json(filename, pt);
50 ->
second.get_value<std::size_t>();
52 ->
second.get_value<std::size_t>();
89 if (
mon_.isAvailable()) {
91 doc.put(
"run", runNumber_);
94 mon_->outputUpdate(doc);
126 using boost::property_tree::ptree;
134 auto iter =
lumiSeen_.lower_bound(currentLumi);
137 iter->second.state = reason;
143 if (
mon_.isAvailable()) {
147 mon_->outputUpdate(doc);
152 if (!
mon_.isAvailable())
157 mon_->outputUpdate(doc);
161 if (boost::starts_with(fn,
"/"))
return fn;
173 auto last_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
177 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
182 std::time_t mtime_now = boost::filesystem::last_write_time(
runPath_);
194 using boost::filesystem::directory_iterator;
195 using boost::filesystem::directory_entry;
199 directory_iterator dend;
200 for (directory_iterator di(
runPath_); di != dend; ++di) {
201 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
211 if (boost::regex_match(filename, result, fn_re)) {
212 unsigned int run = std::stoi(result[1]);
213 unsigned int lumi = std::stoi(result[2]);
222 if ((lumi == 0) && (label ==
"EoR") && (!
eor_.
loaded)) {
234 std::string msg(
"Found and skipped json file (stream label mismatch, ");
235 msg += label +
" [files] != " +
streamLabel_ +
" [config]";
259 if (!fn_eor.empty()) {
278 using std::chrono::high_resolution_clock;
279 using std::chrono::duration_cast;
280 using std::chrono::milliseconds;
288 state_ = State::EOR_CLOSING;
298 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
312 if (
state_ == State::EOR_CLOSING) {
324 if (
state_ != old_state) {
331 mon_->outputUpdate(doc);
349 logFileAction(
"Internal error: referenced lumi is not the map.");
354 if (
mon_.isAvailable())
363 ->setComment(
"Run number passed via configuration file.");
366 ->setComment(
"Data filename position in the positional arguments array 'data' in json file.");
369 ->setComment(
"Stream label used in json discovery.");
372 ->setComment(
"Number of milliseconds to wait between file checks.");
374 desc.
addUntracked<int32_t>(
"nextLumiTimeoutMillis", -1)->setComment(
375 "Number of milliseconds to wait before switching to the next lumi "
376 "section if the current is missing, -1 to disable.");
379 ->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.
U second(std::pair< T, U > const &p)
std::string to_string(const T &t)
DQMFileIterator(edm::ParameterSet const &pset)
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, unsigned 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)