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 <filesystem>
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  unsigned 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  unsigned 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
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
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)