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 <memory>
11 #include <map>
12 #include <string>
13 #include <queue>
14 #include <iterator>
15 #include <chrono>
16 #include <boost/property_tree/json_parser.hpp>
17 #include <boost/property_tree/ptree.hpp>
18 
19 namespace edm {
20 
22  public:
23  enum JsonType {
26  };
27 
28  struct LumiEntry {
29  bool loaded = false;
31 
32  int ls;
33  std::size_t n_events;
35 
36  static LumiEntry load_json(const std::string& filename, int lumiNumber,
37  JsonType type);
38  };
39 
40  struct EorEntry {
41  bool loaded = false;
43 
44  std::size_t n_events;
45  std::size_t n_lumi;
47 
48  static EorEntry load_json(const std::string& filename);
49  };
50 
51  enum State {
52  OPEN = 0,
53  EOR_CLOSING = 1, // EoR file found, but lumis are still pending
54  EOR = 2,
55  };
56 
57  DQMFileIterator(ParameterSet const& pset, JsonType t);
59  void initialise(int run, const std::string&, const std::string&);
60 
61  State state();
62 
63  /* methods to iterate the actual files */
64 
65  /* currentLumi_ is the first unprocessed lumi number
66  * lumiReady() returns if it is loadable
67  * front() a reference to the description (LumiEntry)
68  * pop() advances to the next lumi
69  */
70  bool lumiReady();
71  const LumiEntry& front();
72  void pop();
73  std::string make_path_data(const LumiEntry& lumi);
74 
75  /* control */
76  void reset();
77  void update_state();
78 
79  /* misc helpers for input sources */
80  void logFileAction(const std::string& msg,
81  const std::string& fileName = "") const;
82  void delay();
83  void updateWatchdog();
84  unsigned int runNumber();
85 
86  unsigned int lastLumiFound();
87  void advanceToLumi(unsigned int lumi);
88 
90 
91  private:
93 
94  unsigned int runNumber_;
97  unsigned long delayMillis_;
99 
101 
104 
105  unsigned int currentLumi_;
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 
119 } /* end of namespace */
120 #endif
type
Definition: HCALResponse.h:21
void initialise(int run, const std::string &, const std::string &)
std::string make_path_data(const LumiEntry &lumi)
static LumiEntry load_json(const std::string &filename, int lumiNumber, JsonType type)
tuple lumi
Definition: fjr2json.py:35
DQMFileIterator(ParameterSet const &pset, JsonType t)
void advanceToLumi(unsigned int lumi)
std::string runInputDir_
std::map< unsigned int, LumiEntry > lumiSeen_
const LumiEntry & front()
void logFileAction(const std::string &msg, const std::string &fileName="") const
static void fillDescription(ParameterSetDescription &d)
unsigned int runNumber()
unsigned int lastLumiFound()
std::chrono::high_resolution_clock::time_point lastLumiLoad_
std::chrono::high_resolution_clock::time_point runPathLastCollect_
unsigned long delayMillis_
std::string streamLabel_
static EorEntry load_json(const std::string &filename)
void collect(bool ignoreTimers)
unsigned int currentLumi_
unsigned int runNumber_