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>
16 #include <boost/algorithm/string.hpp>
18 namespace dqmservices {
23 boost::property_tree::ptree
pt;
24 read_json(filename, pt);
31 ->
second.get_value<std::size_t>();
34 ->
second.get_value<std::size_t>();
38 if (datafn_position >= 0) {
47 if (boost::starts_with(datafn,
"/"))
return datafn;
63 boost::property_tree::ptree
pt;
64 read_json(filename, pt);
72 ->
second.get_value<std::size_t>();
74 ->
second.get_value<std::size_t>();
101 std::vector<std::string> tokens;
104 for (
auto token: tokens) {
119 if (
mon_.isAvailable()) {
123 doc.put(
"fi_state", std::to_string(
state_));
124 mon_->outputUpdate(doc);
155 using boost::property_tree::ptree;
163 auto iter =
lumiSeen_.lower_bound(currentLumi);
166 iter->second.state = reason;
172 if (
mon_.isAvailable()) {
176 mon_->outputUpdate(doc);
181 if (!
mon_.isAvailable())
return;
186 mon_->outputUpdate(doc);
190 std::time_t mtime_now = 0;
193 if (!boost::filesystem::exists(
path))
196 mtime_now = mtime_now ^ boost::filesystem::last_write_time(
path);
207 auto last_ms = std::chrono::duration_cast<std::chrono::milliseconds>(
211 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
229 using boost::filesystem::directory_iterator;
230 using boost::filesystem::directory_entry;
235 if (!boost::filesystem::exists(runPath)) {
241 directory_iterator dend;
242 for (directory_iterator di(runPath); di != dend; ++di) {
243 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
253 if (boost::regex_match(filename, result, fn_re)) {
254 unsigned int run = std::stoi(result[1]);
255 unsigned int lumi = std::stoi(result[2]);
264 if ((lumi == 0) && (label ==
"EoR") && (!
eor_.
loaded)) {
276 std::string msg(
"Found and skipped json file (stream label mismatch, ");
277 msg += label +
" [files] != " +
streamLabel_ +
" [config]";
303 if (!fn_eor.empty()) {
323 using std::chrono::high_resolution_clock;
324 using std::chrono::duration_cast;
325 using std::chrono::milliseconds;
336 state_ = State::EOR_CLOSING;
345 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
350 std::to_string(iter->first - 1);
351 msg +=
", nextLumiNumber_ is now " + std::to_string(iter->first);
359 if (
state_ == State::EOR_CLOSING) {
371 if (
state_ != old_state) {
373 std::to_string(old_state) +
"->" + std::to_string(
state_));
377 doc.put(
"fi_state", std::to_string(
state_));
378 mon_->outputUpdate(doc);
397 logFileAction(
"Internal error: referenced lumi is not the map.");
402 if (
mon_.isAvailable())
mon_->keepAlive();
409 ->setComment(
"Run number passed via configuration file.");
413 "Data filename position in the positional arguments array 'data' in "
417 ->setComment(
"Stream label used in json discovery.");
420 ->setComment(
"Number of milliseconds to wait between file checks.");
424 "Number of milliseconds to wait before switching to the next lumi "
425 "section if the current is missing, -1 to disable.");
429 "Don't repeat file scans: use what was found during the initial scan. "
430 "EOR file is ignored and the state is set to 'past end of run'.");
433 ->setComment(
"Directory where the DQM files will appear.");
T getUntrackedParameter(std::string const &, T const &) const
unsigned long delayMillis_
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_
std::string get_json_path() const
string format
Some error handling for the usage.
std::size_t n_events_accepted
static LumiEntry load_json(const std::string &run_path, const std::string &filename, int lumiNumber, int datafn_position)
U second(std::pair< T, U > const &p)
DQMFileIterator(edm::ParameterSet const &pset)
std::size_t n_events_processed
long nextLumiTimeoutMillis_
std::string get_data_path() const
std::vector< std::string > runPath_
void logFileAction(const std::string &msg, const std::string &fileName="") const
std::chrono::high_resolution_clock::time_point lastLumiLoad_
static EorEntry load_json(const std::string &run_path, const std::string &filename)
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_
std::time_t mtimeHash() const
void advanceToLumi(unsigned int lumi, std::string reason)
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)