CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
22 
23  unsigned int file_ls;
24  std::size_t n_events_processed;
25  std::size_t n_events_accepted;
27 
28  static LumiEntry load_json(const std::string& filename, int lumiNumber,
29  int datafn_position);
30 
32  };
33 
34  struct EorEntry {
35  bool loaded = false;
37 
38  std::size_t n_events;
39  std::size_t n_lumi;
40 
41  static EorEntry load_json(const std::string& filename);
42  };
43 
44  enum State {
45  OPEN = 0,
46  EOR_CLOSING = 1, // EoR file found, but lumis are still pending
47  EOR = 2,
48  };
49 
52  void initialise(int run, const std::string&, const std::string&);
53 
54  State state();
55 
56  /* methods to iterate the actual files */
57 
58  /* nextLumiNumber_ is the first unprocessed lumi number
59  * lumiReady() returns if the next lumi is ready to be loaded
60  * open() opens a file and advances the pointer to the next lumi
61  *
62  * front() a reference to the description (LumiEntry)
63  * pop() advances to the next lumi
64  */
65  bool lumiReady();
66  LumiEntry open();
67 
68  void pop();
70 
71  /* control */
72  void reset();
73  void update_state();
74 
75  /* misc helpers for input sources */
76  void logFileAction(const std::string& msg,
77  const std::string& fileName = "") const;
78  void logLumiState(const LumiEntry& lumi, const std::string& msg);
79 
80  void delay();
81 
82  unsigned int runNumber();
83  unsigned int lastLumiFound();
84  void advanceToLumi(unsigned int lumi, std::string reason);
85 
87 
88  private:
89  unsigned int runNumber_;
92  unsigned long delayMillis_;
95 
96  // file name position in the json file
97  unsigned int datafnPosition_;
99 
102 
103  unsigned int nextLumiNumber_;
104  std::map<unsigned int, LumiEntry> lumiSeen_;
105  std::unordered_set<std::string> filesSeen_;
106 
107  /* this should be different,
108  * since time between hosts might be not in sync */
109  std::time_t runPathMTime_;
110  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
111 
112  /* this is for missing lumi files */
113  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
114 
115  void collect(bool ignoreTimers);
116  void monUpdateLumi(const LumiEntry& lumi);
117 
118  /* this is for monitoring */
120 };
121 
122 } /* end of namespace */
123 
124 #endif
std::string make_path(const std::string &fn)
edm::Service< DQMMonitoringService > mon_
void logLumiState(const LumiEntry &lumi, const std::string &msg)
tuple lumi
Definition: fjr2json.py:35
void initialise(int run, const std::string &, const std::string &)
std::map< unsigned int, LumiEntry > lumiSeen_
tuple d
Definition: ztail.py:151
DQMFileIterator(edm::ParameterSet const &pset)
void logFileAction(const std::string &msg, const std::string &fileName="") const
static EorEntry load_json(const std::string &filename)
std::chrono::high_resolution_clock::time_point lastLumiLoad_
static LumiEntry load_json(const std::string &filename, int lumiNumber, int datafn_position)
void monUpdateLumi(const LumiEntry &lumi)
std::chrono::high_resolution_clock::time_point runPathLastCollect_
std::unordered_set< std::string > filesSeen_
State
Definition: hltDiff.cc:314
void advanceToLumi(unsigned int lumi, std::string reason)
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)