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;
137 iter->second.state = reason;
143 if (
mon_.isAvailable()) {
147 mon_->outputUpdate(doc);
152 if (!
mon_.isAvailable())
156 lumi_doc.put(
"filename", lumi.
filename);
157 lumi_doc.put(
"file_ls", lumi.
file_ls);
158 lumi_doc.put(
"state", lumi.
state);
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_);
199 using boost::filesystem::directory_iterator;
200 using boost::filesystem::directory_entry;
204 directory_iterator dend;
205 for (directory_iterator di(
runPath_); di != dend; ++di) {
206 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
216 if (boost::regex_match(filename, result, fn_re)) {
217 unsigned int run = std::stoi(result[1]);
218 unsigned int lumi = std::stoi(result[2]);
227 if ((lumi == 0) && (label ==
"EoR") && (!
eor_.
loaded)) {
239 std::string msg(
"Found and skipped json file (stream label mismatch, ");
240 msg += label +
" [files] != " +
streamLabel_ +
" [config]";
264 if (!fn_eor.empty()) {
283 using std::chrono::high_resolution_clock;
284 using std::chrono::duration_cast;
285 using std::chrono::milliseconds;
293 state_ = State::EOR_CLOSING;
303 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
317 if (
state_ == State::EOR_CLOSING) {
329 if (
state_ != old_state) {
336 mon_->outputUpdate(doc);
354 logFileAction(
"Internal error: referenced lumi is not the map.");
359 if (
mon_.isAvailable())
368 ->setComment(
"Run number passed via configuration file.");
371 ->setComment(
"Data filename position in the positional arguments array 'data' in json file.");
374 ->setComment(
"Stream label used in json discovery.");
377 ->setComment(
"Number of milliseconds to wait between file checks.");
379 desc.
addUntracked<int32_t>(
"nextLumiTimeoutMillis", -1)->setComment(
380 "Number of milliseconds to wait before switching to the next lumi "
381 "section if the current is missing, -1 to disable.");
384 ->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)
tuple path
else: Piece not in the list, fine.
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)