CMS 3D CMS Logo

DQMFileIterator.h
Go to the documentation of this file.
1 #ifndef DQMServices_StreamerIO_DQMFileIterator_h
2 #define DQMServices_StreamerIO_DQMFileIterator_h
3 
4 #include <chrono>
5 #include <map>
6 #include <string>
7 #include <unordered_set>
8 #include <vector>
9 
11 
12 namespace edm {
13  class ParameterSet;
15 } // namespace edm
16 
17 namespace dqmservices {
18 
20 
22  public:
23  struct LumiEntry {
26 
27  unsigned int file_ls;
28  std::size_t n_events_processed;
29  std::size_t n_events_accepted;
31 
33  const std::string& filename,
34  int lumiNumber,
35  int datafn_position);
36 
37  std::string get_data_path() const;
38  std::string get_json_path() const;
40  };
41 
42  struct EorEntry {
43  bool loaded = false;
46 
47  std::size_t n_events;
48  std::size_t n_lumi;
49 
51  };
52 
53  enum State {
54  OPEN = 0,
55  EOR_CLOSING = 1, // EoR file found, but lumis are still pending
56  EOR = 2,
57  };
58 
60  ~DQMFileIterator() = default;
61  void initialise(int run, const std::string&, const std::string&);
62 
63  State state() const { return state_; }
64 
65  /* methods to iterate the actual files */
66 
67  /* nextLumiNumber_ is the first unprocessed lumi number
68  * lumiReady() returns if the next lumi is ready to be loaded
69  * open() opens a file and advances the pointer to the next lumi
70  *
71  * front() a reference to the description (LumiEntry)
72  * pop() advances to the next lumi
73  */
74  bool lumiReady();
75  LumiEntry open();
76 
77  void pop();
78 
79  /* control */
80  void reset();
81  void update_state();
82 
83  /* misc helpers for input sources */
84  void logFileAction(const std::string& msg, const std::string& fileName = "") const;
85  void logLumiState(const LumiEntry& lumi, const std::string& msg);
86 
87  void delay();
88 
89  unsigned int runNumber() const { return runNumber_; }
90  unsigned int lastLumiFound();
91  void advanceToLumi(unsigned int lumi, std::string reason);
92 
94 
95  private:
96  unsigned int runNumber_;
99  unsigned long delayMillis_;
103 
104  // file name position in the json file
105  unsigned int datafnPosition_;
106  std::vector<std::string> runPath_;
107 
110 
111  unsigned int nextLumiNumber_;
112  std::map<unsigned int, LumiEntry> lumiSeen_;
113  std::unordered_set<std::string> filesSeen_;
114 
115  /* this should be different,
116  * since time between hosts might be not in sync */
117  unsigned runPathMTime_;
118  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
119 
120  /* this is for missing lumi files */
121  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
122 
123  unsigned mtimeHash() const;
124  void collect(bool ignoreTimers);
125  void monUpdateLumi(const LumiEntry& lumi);
126 
127  /* this is for monitoring */
129  };
130 
131 } // namespace dqmservices
132 
133 #endif // DQMServices_StreamerIO_DQMFileIterator_h
unsigned int runNumber() const
edm::Service< DQMMonitoringService > mon_
void logLumiState(const LumiEntry &lumi, const std::string &msg)
void initialise(int run, const std::string &, const std::string &)
std::map< unsigned int, LumiEntry > lumiSeen_
static LumiEntry load_json(const std::string &run_path, const std::string &filename, int lumiNumber, int datafn_position)
DQMFileIterator(edm::ParameterSet const &pset)
std::vector< std::string > runPath_
d
Definition: ztail.py:151
std::chrono::high_resolution_clock::time_point lastLumiLoad_
void logFileAction(const std::string &msg, const std::string &fileName="") const
static EorEntry load_json(const std::string &run_path, const std::string &filename)
tuple msg
Definition: mps_check.py:286
HLT enums.
void monUpdateLumi(const LumiEntry &lumi)
std::chrono::high_resolution_clock::time_point runPathLastCollect_
std::unordered_set< std::string > filesSeen_
void advanceToLumi(unsigned int lumi, std::string reason)
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)