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>
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 (
auto token : tokens) {
112 if (
mon_.isAvailable()) {
116 doc.put(
"fi_state", std::to_string(
state_));
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())
183 std::time_t mtime_now = 0;
186 if (!boost::filesystem::exists(
path))
189 mtime_now = mtime_now ^ boost::filesystem::last_write_time(
path);
203 if ((!ignoreTimers) && (last_ms >= 0) && (last_ms < 100)) {
220 using boost::filesystem::directory_entry;
221 using boost::filesystem::directory_iterator;
226 if (!boost::filesystem::exists(runPath)) {
232 directory_iterator dend;
233 for (directory_iterator di(runPath); di != dend; ++di) {
234 const boost::regex fn_re(
"run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
268 std::string msg(
"Found and skipped json file (stream label mismatch, ");
295 if (!fn_eor.empty()) {
315 using std::chrono::duration_cast;
316 using std::chrono::high_resolution_clock;
317 using std::chrono::milliseconds;
328 state_ = State::EOR_CLOSING;
337 auto elapsed_ms = duration_cast<milliseconds>(elapsed).count();
342 msg +=
", nextLumiNumber_ is now " + std::to_string(iter->first);
350 if (
state_ == State::EOR_CLOSING) {
362 if (
state_ != old_state) {
363 logFileAction(
"Streamer state changed: ", std::to_string(old_state) +
"->" + std::to_string(
state_));
367 doc.put(
"fi_state", std::to_string(
state_));
384 logFileAction(
"Internal error: referenced lumi is not the map.");
389 if (
mon_.isAvailable())
396 desc.
addUntracked<
unsigned int>(
"runNumber")->setComment(
"Run number passed via configuration file.");
400 "Data filename position in the positional arguments array 'data' in "
405 desc.
addUntracked<uint32_t>(
"delayMillis")->setComment(
"Number of milliseconds to wait between file checks.");
409 "Number of milliseconds to wait before switching to the next lumi "
410 "section if the current is missing, -1 to disable.");
414 "Don't repeat file scans: use what was found during the initial scan. "
415 "EOR file is ignored and the state is set to 'past end of run'.");