11 #include <boost/algorithm/string.hpp> 12 #include <boost/algorithm/string/predicate.hpp> 13 #include <boost/property_tree/json_parser.hpp> 14 #include <boost/property_tree/ptree.hpp> 15 #include <boost/regex.hpp> 17 #include <fmt/printf.h> 24 int datafn_position) {
25 boost::property_tree::ptree
pt;
32 lumi.n_events_processed =
std::next(
pt.get_child(
"data").begin(), 0)->
second.get_value<std::size_t>();
36 lumi.file_ls = lumiNumber;
38 if (datafn_position >= 0) {
46 if (boost::starts_with(datafn,
"/"))
60 boost::property_tree::ptree
pt;
76 runNumber_ =
pset.getUntrackedParameter<
unsigned int>(
"runNumber");
93 std::vector<std::string> tokens;
96 for (
const auto&
token : tokens) {
111 if (
mon_.isAvailable()) {
112 boost::property_tree::ptree
doc;
148 auto iter =
lumiSeen_.lower_bound(currentLumi);
151 iter->second.state =
reason;
157 if (
mon_.isAvailable()) {
159 boost::property_tree::ptree
doc;
166 if (!
mon_.isAvailable())
169 boost::property_tree::ptree
doc;
170 doc.put(fmt::sprintf(
"extra.lumi_seen.lumi%06d",
lumi.file_ls),
lumi.state);
175 unsigned mtime_now = 0;
178 if (!std::filesystem::exists(
path))
181 auto write_time = std::filesystem::last_write_time(
path);
183 mtime_now ^ std::chrono::duration_cast<std::chrono::microseconds>(write_time.time_since_epoch()).
count();
197 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
214 using std::filesystem::directory_entry;
215 using std::filesystem::directory_iterator;
219 for (
const auto& runPath :
runPath_) {
220 if (!std::filesystem::exists(runPath)) {
226 directory_iterator dend;
227 for (directory_iterator di(runPath); di != dend; ++di) {
228 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
262 std::string msg(
"Found and skipped json file (stream label mismatch, ");
289 if (!fn_eor.empty()) {
309 using std::chrono::duration_cast;
310 using std::chrono::high_resolution_clock;
311 using std::chrono::milliseconds;
322 state_ = State::EOR_CLOSING;
331 auto elapsed_ms = duration_cast<milliseconds>(elapsed).
count();
344 if (
state_ == State::EOR_CLOSING) {
356 if (
state_ != old_state) {
360 boost::property_tree::ptree
doc;
378 logFileAction(
"Internal error: referenced lumi is not the map.");
383 if (
mon_.isAvailable())
390 desc.addUntracked<
unsigned int>(
"runNumber")->setComment(
"Run number passed via configuration file.");
392 desc.addUntracked<
unsigned int>(
"datafnPosition", 3)
394 "Data filename position in the positional arguments array 'data' in " 397 desc.addUntracked<
std::string>(
"streamLabel")->setComment(
"Stream label used in json discovery.");
399 desc.addUntracked<uint32_t>(
"delayMillis")->setComment(
"Number of milliseconds to wait between file checks.");
401 desc.addUntracked<int32_t>(
"nextLumiTimeoutMillis", -1)
403 "Number of milliseconds to wait before switching to the next lumi " 404 "section if the current is missing, -1 to disable.");
406 desc.addUntracked<
bool>(
"scanOnce",
false)
408 "Don't repeat file scans: use what was found during the initial scan. " 409 "EOR file is ignored and the state is set to 'past end of run'.");
411 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::map< unsigned int, LumiEntry > lumiSeen_
static LumiEntry load_json(const std::string &run_path, const std::string &filename, int lumiNumber, int datafn_position)
static std::string to_string(const XMLCh *ch)
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