CMS 3D CMS Logo

DQMFileIterator.h
Go to the documentation of this file.
1 #ifndef IOPool_DQMStreamer_DQMFilerIterator_h
2 #define IOPool_DQMStreamer_DQMFilerIterator_h
3 
7 
8 #include "boost/filesystem.hpp"
9 
10 #include <map>
11 #include <unordered_set>
12 #include <chrono>
13 
14 #include "DQMMonitoringService.h"
15 
16 namespace dqmservices {
17 
19  public:
20  struct LumiEntry {
23 
24  unsigned int file_ls;
25  std::size_t n_events_processed;
26  std::size_t n_events_accepted;
28 
30  const std::string& filename,
31  int lumiNumber,
32  int datafn_position);
33 
34  std::string get_data_path() const;
35  std::string get_json_path() const;
37  };
38 
39  struct EorEntry {
40  bool loaded = false;
43 
44  std::size_t n_events;
45  std::size_t n_lumi;
46 
48  };
49 
50  enum State {
51  OPEN = 0,
52  EOR_CLOSING = 1, // EoR file found, but lumis are still pending
53  EOR = 2,
54  };
55 
58  void initialise(int run, const std::string&, const std::string&);
59 
60  State state();
61 
62  /* methods to iterate the actual files */
63 
64  /* nextLumiNumber_ is the first unprocessed lumi number
65  * lumiReady() returns if the next lumi is ready to be loaded
66  * open() opens a file and advances the pointer to the next lumi
67  *
68  * front() a reference to the description (LumiEntry)
69  * pop() advances to the next lumi
70  */
71  bool lumiReady();
72  LumiEntry open();
73 
74  void pop();
75 
76  /* control */
77  void reset();
78  void update_state();
79 
80  /* misc helpers for input sources */
81  void logFileAction(const std::string& msg, const std::string& fileName = "") const;
82  void logLumiState(const LumiEntry& lumi, const std::string& msg);
83 
84  void delay();
85 
86  unsigned int runNumber();
87  unsigned int lastLumiFound();
88  void advanceToLumi(unsigned int lumi, std::string reason);
89 
91 
92  private:
93  unsigned int runNumber_;
96  unsigned long delayMillis_;
100 
101  // file name position in the json file
102  unsigned int datafnPosition_;
103  std::vector<std::string> runPath_;
104 
107 
108  unsigned int nextLumiNumber_;
109  std::map<unsigned int, LumiEntry> lumiSeen_;
110  std::unordered_set<std::string> filesSeen_;
111 
112  /* this should be different,
113  * since time between hosts might be not in sync */
114  std::time_t runPathMTime_;
115  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
116 
117  /* this is for missing lumi files */
118  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
119 
120  std::time_t mtimeHash() const;
121  void collect(bool ignoreTimers);
122  void monUpdateLumi(const LumiEntry& lumi);
123 
124  /* this is for monitoring */
126  };
127 
128 } // namespace dqmservices
129 
130 #endif
ConfigurationDescriptions.h
dqmservices::DQMFileIterator::runNumber_
unsigned int runNumber_
Definition: DQMFileIterator.h:93
dqmservices::DQMFileIterator::pop
void pop()
dqmservices::DQMFileIterator::EorEntry::n_events
std::size_t n_events
Definition: DQMFileIterator.h:44
dqmservices::DQMFileIterator::EorEntry
Definition: DQMFileIterator.h:39
dqmservices::DQMFileIterator::runNumber
unsigned int runNumber()
Definition: DQMFileIterator.cc:137
dqmservices::DQMFileIterator::state_
State state_
Definition: DQMFileIterator.h:106
dqmservices::DQMFileIterator::EorEntry::load_json
static EorEntry load_json(const std::string &run_path, const std::string &filename)
Definition: DQMFileIterator.cc:57
dqmservices::DQMFileIterator::logFileAction
void logFileAction(const std::string &msg, const std::string &fileName="") const
Definition: DQMFileIterator.cc:373
dqmservices::DQMFileIterator::reset
void reset()
Definition: DQMFileIterator.cc:91
dqmservices::DQMFileIterator::LumiEntry::n_events_processed
std::size_t n_events_processed
Definition: DQMFileIterator.h:25
dqmservices
Definition: DQMFileIterator.cc:18
dqmservices::DQMFileIterator::lumiSeen_
std::map< unsigned int, LumiEntry > lumiSeen_
Definition: DQMFileIterator.h:109
dqmservices::DQMFileIterator::collect
void collect(bool ignoreTimers)
Definition: DQMFileIterator.cc:195
dqmservices::DQMFileIterator::EOR_CLOSING
Definition: DQMFileIterator.h:52
dqmservices::DQMFileIterator::LumiEntry::state
std::string state
Definition: DQMFileIterator.h:36
dqmservices::DQMFileIterator::LumiEntry::load_json
static LumiEntry load_json(const std::string &run_path, const std::string &filename, int lumiNumber, int datafn_position)
Definition: DQMFileIterator.cc:20
dqmservices::DQMFileIterator::OPEN
Definition: DQMFileIterator.h:51
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqmservices::DQMFileIterator::delayMillis_
unsigned long delayMillis_
Definition: DQMFileIterator.h:96
dqmservices::DQMFileIterator::filesSeen_
std::unordered_set< std::string > filesSeen_
Definition: DQMFileIterator.h:110
dqmservices::DQMFileIterator::open
LumiEntry open()
Definition: DQMFileIterator.cc:123
dqmservices::DQMFileIterator::flagScanOnce_
bool flagScanOnce_
Definition: DQMFileIterator.h:99
dqmservices::DQMFileIterator::EOR
Definition: DQMFileIterator.h:53
mps_check.msg
tuple msg
Definition: mps_check.py:285
dqmservices::DQMFileIterator::streamLabel_
std::string streamLabel_
Definition: DQMFileIterator.h:95
dqmservices::DQMFileIterator::mtimeHash
std::time_t mtimeHash() const
Definition: DQMFileIterator.cc:182
dqmservices::DQMFileIterator::runPathLastCollect_
std::chrono::high_resolution_clock::time_point runPathLastCollect_
Definition: DQMFileIterator.h:115
dqmservices::DQMFileIterator::delay
void delay()
Definition: DQMFileIterator.cc:388
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
dqmservices::DQMFileIterator::datafnPosition_
unsigned int datafnPosition_
Definition: DQMFileIterator.h:102
dqmservices::DQMFileIterator::LumiEntry
Definition: DQMFileIterator.h:20
dqmservices::DQMFileIterator::nextLumiNumber_
unsigned int nextLumiNumber_
Definition: DQMFileIterator.h:108
dqmservices::DQMFileIterator::EorEntry::run_path
std::string run_path
Definition: DQMFileIterator.h:42
dqmservices::DQMFileIterator::fillDescription
static void fillDescription(edm::ParameterSetDescription &d)
Definition: DQMFileIterator.cc:395
dqmservices::DQMFileIterator::LumiEntry::get_json_path
std::string get_json_path() const
Definition: DQMFileIterator.cc:53
dqmservices::DQMFileIterator::mon_
edm::Service< DQMMonitoringService > mon_
Definition: DQMFileIterator.h:125
Service.h
dqmservices::DQMFileIterator::DQMFileIterator
DQMFileIterator(edm::ParameterSet const &pset)
Definition: DQMFileIterator.cc:74
dqmservices::DQMFileIterator::initialise
void initialise(int run, const std::string &, const std::string &)
dqmservices::DQMFileIterator::runPathMTime_
std::time_t runPathMTime_
Definition: DQMFileIterator.h:114
ParameterSetDescription.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqmservices::DQMFileIterator::LumiEntry::datafn
std::string datafn
Definition: DQMFileIterator.h:27
dqmservices::DQMFileIterator::LumiEntry::get_data_path
std::string get_data_path() const
Definition: DQMFileIterator.cc:44
edm::ParameterSet
Definition: ParameterSet.h:36
dqmservices::DQMFileIterator::state
State state()
Definition: DQMFileIterator.cc:121
State
State
Definition: RPixErrorChecker.h:15
edm::Service
Definition: Service.h:30
dqmservices::DQMFileIterator::lumiReady
bool lumiReady()
Definition: DQMFileIterator.cc:129
dqmservices::DQMFileIterator::LumiEntry::file_ls
unsigned int file_ls
Definition: DQMFileIterator.h:24
dqmservices::DQMFileIterator
Definition: DQMFileIterator.h:18
dqmservices::DQMFileIterator::eor_
EorEntry eor_
Definition: DQMFileIterator.h:105
PixelMapPlotter.reason
reason
Definition: PixelMapPlotter.py:509
dqmservices::DQMFileIterator::advanceToLumi
void advanceToLumi(unsigned int lumi, std::string reason)
Definition: DQMFileIterator.cc:147
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqmservices::DQMFileIterator::runInputDir_
std::string runInputDir_
Definition: DQMFileIterator.h:94
dqmservices::DQMFileIterator::EorEntry::filename
std::string filename
Definition: DQMFileIterator.h:41
dqmservices::DQMFileIterator::update_state
void update_state()
Definition: DQMFileIterator.cc:314
ztail.d
d
Definition: ztail.py:151
dqmservices::DQMFileIterator::nextLumiTimeoutMillis_
long nextLumiTimeoutMillis_
Definition: DQMFileIterator.h:97
dqmservices::DQMFileIterator::monUpdateLumi
void monUpdateLumi(const LumiEntry &lumi)
Definition: DQMFileIterator.cc:173
dqmservices::DQMFileIterator::LumiEntry::n_events_accepted
std::size_t n_events_accepted
Definition: DQMFileIterator.h:26
dqmservices::DQMFileIterator::runPath_
std::vector< std::string > runPath_
Definition: DQMFileIterator.h:103
dqmservices::DQMFileIterator::LumiEntry::run_path
std::string run_path
Definition: DQMFileIterator.h:22
dqmservices::DQMFileIterator::EorEntry::loaded
bool loaded
Definition: DQMFileIterator.h:40
dqmservices::DQMFileIterator::forceFileCheckTimeoutMillis_
long forceFileCheckTimeoutMillis_
Definition: DQMFileIterator.h:98
dqmservices::DQMFileIterator::EorEntry::n_lumi
std::size_t n_lumi
Definition: DQMFileIterator.h:45
dqmservices::DQMFileIterator::LumiEntry::filename
std::string filename
Definition: DQMFileIterator.h:21
lumi
Definition: LumiSectionData.h:20
dqmservices::DQMFileIterator::logLumiState
void logLumiState(const LumiEntry &lumi, const std::string &msg)
Definition: DQMFileIterator.cc:378
dqmservices::DQMFileIterator::lastLumiFound
unsigned int lastLumiFound()
Definition: DQMFileIterator.cc:139
dqmservices::DQMFileIterator::State
State
Definition: DQMFileIterator.h:50
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqmservices::DQMFileIterator::~DQMFileIterator
~DQMFileIterator()
Definition: DQMFileIterator.cc:89
DQMMonitoringService.h
dqmservices::DQMFileIterator::lastLumiLoad_
std::chrono::high_resolution_clock::time_point lastLumiLoad_
Definition: DQMFileIterator.h:118