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 <queue>
12 #include <chrono>
13 
14 #include "DQMMonitoringService.h"
15 
16 namespace dqmservices {
17 
19  public:
20  struct LumiEntry {
21  bool loaded = false;
23 
24  int ls;
25  std::size_t n_events;
27 
28  static LumiEntry load_json(const std::string& filename, int lumiNumber,
29  unsigned int datafn_position);
30  };
31 
32  struct EorEntry {
33  bool loaded = false;
35 
36  std::size_t n_events;
37  std::size_t n_lumi;
39 
40  static EorEntry load_json(const std::string& filename);
41  };
42 
43  enum State {
44  OPEN = 0,
45  EOR_CLOSING = 1, // EoR file found, but lumis are still pending
46  EOR = 2,
47  };
48 
51  void initialise(int run, const std::string&, const std::string&);
52 
53  State state();
54 
55  /* methods to iterate the actual files */
56 
57  /* currentLumi_ is the first unprocessed lumi number
58  * lumiReady() returns if it is loadable
59  * front() a reference to the description (LumiEntry)
60  * pop() advances to the next lumi
61  */
62  bool lumiReady();
63  const LumiEntry& front();
64  void pop();
65  std::string make_path_data(const LumiEntry& lumi);
66 
67  /* control */
68  void reset();
69  void update_state();
70 
71  /* misc helpers for input sources */
72  void logFileAction(const std::string& msg,
73  const std::string& fileName = "") const;
74  void delay();
75  void updateWatchdog();
76  unsigned int runNumber();
77 
78  unsigned int lastLumiFound();
79  void advanceToLumi(unsigned int lumi);
80 
82 
83  private:
84  unsigned int runNumber_;
87  unsigned long delayMillis_;
90 
91  // file name position in the json file
92  unsigned int datafnPosition_;
93 
95 
98 
99  unsigned int currentLumi_;
100  std::map<unsigned int, LumiEntry> lumiSeen_;
101 
102  /* this should be different,
103  * since time between hosts might be not in sync */
104  std::time_t runPathMTime_;
105  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
106 
107  /* this is for missing lumi files */
108  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
109 
110  void collect(bool ignoreTimers);
111 
112  /* this is for monitoring */
114 };
115 
116 } /* end of namespace */
117 
118 #endif
edm::Service< DQMMonitoringService > mon_
tuple lumi
Definition: fjr2json.py:35
void initialise(int run, const std::string &, const std::string &)
std::map< unsigned int, LumiEntry > lumiSeen_
void advanceToLumi(unsigned int lumi)
std::string make_path_data(const LumiEntry &lumi)
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, unsigned int datafn_position)
std::chrono::high_resolution_clock::time_point runPathLastCollect_
static void fillDescription(edm::ParameterSetDescription &d)
void collect(bool ignoreTimers)