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;
26 
27  static LumiEntry load_json(const std::string& filename, int lumiNumber,
28  unsigned int datafn_position);
29 
31  };
32 
33  struct EorEntry {
34  bool loaded = false;
36 
37  std::size_t n_events;
38  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  /* nextLumiNumber_ is the first unprocessed lumi number
58  * lumiReady() returns if the next lumi is ready to be loaded
59  * open() opens a file and advances the pointer to the next lumi
60  *
61  * front() a reference to the description (LumiEntry)
62  * pop() advances to the next lumi
63  */
64  bool lumiReady();
65  LumiEntry open();
66 
67  void pop();
69 
70  /* control */
71  void reset();
72  void update_state();
73 
74  /* misc helpers for input sources */
75  void logFileAction(const std::string& msg,
76  const std::string& fileName = "") const;
77  void logLumiState(const LumiEntry& lumi, const std::string& msg);
78 
79  void delay();
80 
81  unsigned int runNumber();
82  unsigned int lastLumiFound();
83  void advanceToLumi(unsigned int lumi, std::string reason);
84 
86 
87  private:
88  unsigned int runNumber_;
91  unsigned long delayMillis_;
94 
95  // file name position in the json file
96  unsigned int datafnPosition_;
98 
101 
102  unsigned int nextLumiNumber_;
103  std::map<unsigned int, LumiEntry> lumiSeen_;
104  std::unordered_set<std::string> filesSeen_;
105 
106  /* this should be different,
107  * since time between hosts might be not in sync */
108  std::time_t runPathMTime_;
109  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
110 
111  /* this is for missing lumi files */
112  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
113 
114  void collect(bool ignoreTimers);
115  void monUpdateLumi(const LumiEntry& lumi);
116 
117  /* this is for monitoring */
119 };
120 
121 } /* end of namespace */
122 
123 #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, unsigned int datafn_position)
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)