CMS 3D CMS Logo

DQWorker.h
Go to the documentation of this file.
1 #ifndef DQWorker_H
2 #define DQWorker_H
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 
9 
12 
13 #include "tbb/concurrent_unordered_map.h"
14 
15 namespace edm {
16  class Run;
17  class LuminosityBlock;
18  class Event;
19  class EventSetup;
20  class ParameterSet;
22 } // namespace edm
23 
24 namespace ecaldqm {
25 
26  class WorkerFactoryStore;
27 
28  class DQWorker {
29  friend class WorkerFactoryStore;
30 
31  private:
32  struct Timestamp {
33  time_t now;
37  Timestamp() : now(0), iRun(0), iLumi(0), iEvt(0) {}
38  };
39 
40  protected:
43 
44  void setVerbosity(int _verbosity) { verbosity_ = _verbosity; }
45  void initialize(std::string const &_name, edm::ParameterSet const &);
46 
47  virtual void setME(edm::ParameterSet const &);
48  virtual void setSource(edm::ParameterSet const &) {} // for clients
49  virtual void setParams(edm::ParameterSet const &) {}
50 
51  public:
52  DQWorker();
53  virtual ~DQWorker() noexcept(false);
54 
56 
57  virtual void beginRun(edm::Run const &, edm::EventSetup const &) {}
58  virtual void endRun(edm::Run const &, edm::EventSetup const &) {}
59 
60  virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) {}
61  virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) {}
62 
63  virtual void bookMEs(DQMStore::IBooker &);
64  virtual void releaseMEs();
65 
66  void setTime(time_t _t) { timestamp_.now = _t; }
67  void setRunNumber(edm::RunNumber_t _r) { timestamp_.iRun = _r; }
68  void setLumiNumber(edm::LuminosityBlockNumber_t _l) { timestamp_.iLumi = _l; }
69  void setEventNumber(edm::EventNumber_t _e) { timestamp_.iEvt = _e; }
70 
71  std::string const &getName() const { return name_; }
72  bool onlineMode() const { return onlineMode_; }
73 
74  protected:
75  void print_(std::string const &, int = 0) const;
76 
79  bool booked_;
80 
83 
84  // common parameters
87  };
88 
89  typedef DQWorker *(*WorkerFactory)();
90 
91  // to be instantiated after the implementation of each worker module
93  public:
94  template <typename Worker>
95  struct Registration {
96  Registration(std::string const &_name) {
97  WorkerFactoryStore::singleton()->registerFactory(_name, []() -> DQWorker * { return new Worker(); });
98  }
99  };
100 
101  void registerFactory(std::string const &_name, WorkerFactory _f) { workerFactories_[_name] = _f; }
102  DQWorker *getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const;
103 
104  static WorkerFactoryStore *singleton();
105 
106  private:
107  tbb::concurrent_unordered_map<std::string, WorkerFactory> workerFactories_;
108  };
109 
110 } // namespace ecaldqm
111 
112 #define DEFINE_ECALDQM_WORKER(TYPE) WorkerFactoryStore::Registration<TYPE> ecaldqm##TYPE##Registration(#TYPE)
113 
114 #endif
static AlgebraicMatrix initialize()
dqm::legacy::DQMStore DQMStore
Definition: DQWorker.h:41
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:58
std::ostream & print_(std::ostream &os, value_type const &hash)
Definition: Hash.cc:92
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
bool willConvertToEDM_
Definition: DQWorker.h:86
unsigned long long EventNumber_t
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:57
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:60
unsigned int LuminosityBlockNumber_t
void setLumiNumber(edm::LuminosityBlockNumber_t _l)
Definition: DQWorker.h:68
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:61
void setEventNumber(edm::EventNumber_t _e)
Definition: DQWorker.h:69
void registerFactory(std::string const &_name, WorkerFactory _f)
Definition: DQWorker.h:101
DQWorker *(* WorkerFactory)()
Definition: DQWorker.h:89
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:67
edm::RunNumber_t iRun
Definition: DQWorker.h:34
boost::ptr_map< std::string, MESet > MESetCollection
Definition: MESet.h:349
bool onlineMode() const
Definition: DQWorker.h:72
#define noexcept
Timestamp timestamp_
Definition: DQWorker.h:81
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:107
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EventNumber_t iEvt
Definition: DQWorker.h:36
MESetCollection MEs_
Definition: DQWorker.h:78
std::string const & getName() const
Definition: DQWorker.h:71
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:49
HLT enums.
void setVerbosity(int _verbosity)
Definition: DQWorker.h:44
unsigned int RunNumber_t
dqm::legacy::MonitorElement MonitorElement
Definition: DQWorker.h:42
void setTime(time_t _t)
Definition: DQWorker.h:66
Registration(std::string const &_name)
Definition: DQWorker.h:96
std::string name_
Definition: DQWorker.h:77
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:48
Definition: Run.h:45