6 #include <boost/algorithm/string.hpp> 7 #include <boost/algorithm/string/predicate.hpp> 8 #include <boost/property_tree/json_parser.hpp> 9 #include <boost/property_tree/ptree.hpp> 10 #include <boost/range.hpp> 11 #include <boost/regex.hpp> 12 #include <fmt/printf.h> 23 int datafn_position) {
24 boost::property_tree::ptree
pt;
31 lumi.n_events_processed =
std::next(
pt.get_child(
"data").begin(), 0)->
second.get_value<std::size_t>();
35 lumi.file_ls = lumiNumber;
37 if (datafn_position >= 0) {
45 if (boost::starts_with(datafn,
"/"))
59 boost::property_tree::ptree
pt;
75 runNumber_ =
pset.getUntrackedParameter<
unsigned int>(
"runNumber");
94 std::vector<std::string> tokens;
97 for (
const auto&
token : tokens) {
112 if (
mon_.isAvailable()) {
149 using boost::property_tree::ptree;
156 auto iter =
lumiSeen_.lower_bound(currentLumi);
159 iter->second.state =
reason;
165 if (
mon_.isAvailable()) {
174 if (!
mon_.isAvailable())
178 doc.put(fmt::sprintf(
"extra.lumi_seen.lumi%06d",
lumi.file_ls),
lumi.state);
183 unsigned mtime_now = 0;
186 if (!std::filesystem::exists(
path))
189 auto write_time = std::filesystem::last_write_time(
path);
191 mtime_now ^ std::chrono::duration_cast<std::chrono::microseconds>(write_time.time_since_epoch()).
count();
205 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
222 using std::filesystem::directory_entry;
223 using std::filesystem::directory_iterator;
227 for (
const auto& runPath :
runPath_) {
228 if (!std::filesystem::exists(runPath)) {
234 directory_iterator dend;
235 for (directory_iterator di(runPath); di != dend; ++di) {
236 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
270 std::string msg(
"Found and skipped json file (stream label mismatch, ");
297 if (!fn_eor.empty()) {
317 using std::chrono::duration_cast;
318 using std::chrono::high_resolution_clock;
319 using std::chrono::milliseconds;
330 state_ = State::EOR_CLOSING;
339 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
352 if (
state_ == State::EOR_CLOSING) {
364 if (
state_ != old_state) {
386 logFileAction(
"Internal error: referenced lumi is not the map.");
391 if (
mon_.isAvailable())
398 desc.addUntracked<
unsigned int>(
"runNumber")->setComment(
"Run number passed via configuration file.");
400 desc.addUntracked<
unsigned int>(
"datafnPosition", 3)
402 "Data filename position in the positional arguments array 'data' in " 405 desc.addUntracked<
std::string>(
"streamLabel")->setComment(
"Stream label used in json discovery.");
407 desc.addUntracked<uint32_t>(
"delayMillis")->setComment(
"Number of milliseconds to wait between file checks.");
409 desc.addUntracked<int32_t>(
"nextLumiTimeoutMillis", -1)
411 "Number of milliseconds to wait before switching to the next lumi " 412 "section if the current is missing, -1 to disable.");
414 desc.addUntracked<
bool>(
"scanOnce",
false)
416 "Don't repeat file scans: use what was found during the initial scan. " 417 "EOR file is ignored and the state is set to 'past end of run'.");
419 desc.addUntracked<
std::string>(
"runInputDir")->setComment(
"Directory where the DQM files will appear.");
unsigned long delayMillis_
unsigned int lastLumiFound()
edm::Service< DQMMonitoringService > mon_
void logLumiState(const LumiEntry &lumi, const std::string &msg)
std::string to_string(const V &value)
std::map< unsigned int, LumiEntry > lumiSeen_
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)
long nextLumiTimeoutMillis_
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::vector< std::string > runPath_
unsigned mtimeHash() const
std::string get_data_path() const
std::chrono::high_resolution_clock::time_point lastLumiLoad_
def split(sequence, size)
void logFileAction(const std::string &msg, const std::string &fileName="") const
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_
Log< level::System, true > LogAbsolute
void advanceToLumi(unsigned int lumi, std::string reason)
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)
std::string get_json_path() const