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 {
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;
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  const LumiEntry open();
67 
68  void pop();
69  std::string make_path_data(const LumiEntry& lumi);
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  void updateMonitoring();
82 
83  unsigned int runNumber();
84 
85  unsigned int lastLumiFound();
86  void advanceToLumi(unsigned int lumi);
87 
89 
90  private:
91  unsigned int runNumber_;
94  unsigned long delayMillis_;
97 
98  // file name position in the json file
99  unsigned int datafnPosition_;
101 
104 
105  unsigned int nextLumiNumber_;
106  std::map<unsigned int, LumiEntry> lumiSeen_;
107 
108  /* this should be different,
109  * since time between hosts might be not in sync */
110  std::time_t runPathMTime_;
111  std::chrono::high_resolution_clock::time_point runPathLastCollect_;
112 
113  /* this is for missing lumi files */
114  std::chrono::high_resolution_clock::time_point lastLumiLoad_;
115 
116  void collect(bool ignoreTimers);
117 
118  /* this is for monitoring */
120 };
121 
122 } /* end of namespace */
123 
124 #endif
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_
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)