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:
41  void setVerbosity(int _verbosity) { verbosity_ = _verbosity; }
42  void initialize(std::string const &_name, edm::ParameterSet const &);
43 
44  virtual void setME(edm::ParameterSet const &);
45  virtual void setSource(edm::ParameterSet const &) {} // for clients
46  virtual void setParams(edm::ParameterSet const &) {}
47 
48  public:
49  DQWorker();
50  virtual ~DQWorker() noexcept(false);
51 
53 
54  virtual void beginRun(edm::Run const &, edm::EventSetup const &) {}
55  virtual void endRun(edm::Run const &, edm::EventSetup const &) {}
56 
57  virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) {}
58  virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) {}
59 
60  virtual void bookMEs(DQMStore::IBooker &);
61  virtual void releaseMEs();
62 
63  void setTime(time_t _t) { timestamp_.now = _t; }
64  void setRunNumber(edm::RunNumber_t _r) { timestamp_.iRun = _r; }
65  void setLumiNumber(edm::LuminosityBlockNumber_t _l) { timestamp_.iLumi = _l; }
66  void setEventNumber(edm::EventNumber_t _e) { timestamp_.iEvt = _e; }
67 
68  std::string const &getName() const { return name_; }
69  bool onlineMode() const { return onlineMode_; }
70 
71  protected:
72  void print_(std::string const &, int = 0) const;
73 
76  bool booked_;
77 
80 
81  // common parameters
84  };
85 
86  typedef DQWorker *(*WorkerFactory)();
87 
88  // to be instantiated after the implementation of each worker module
90  public:
91  template <typename Worker>
92  struct Registration {
93  Registration(std::string const &_name) {
94  WorkerFactoryStore::singleton()->registerFactory(_name, []() -> DQWorker * { return new Worker(); });
95  }
96  };
97 
98  void registerFactory(std::string const &_name, WorkerFactory _f) { workerFactories_[_name] = _f; }
99  DQWorker *getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const;
100 
101  static WorkerFactoryStore *singleton();
102 
103  private:
104  tbb::concurrent_unordered_map<std::string, WorkerFactory> workerFactories_;
105  };
106 
107 } // namespace ecaldqm
108 
109 #define DEFINE_ECALDQM_WORKER(TYPE) WorkerFactoryStore::Registration<TYPE> ecaldqm##TYPE##Registration(#TYPE)
110 
111 #endif
static AlgebraicMatrix initialize()
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:55
std::ostream & print_(std::ostream &os, value_type const &hash)
Definition: Hash.cc:106
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
bool willConvertToEDM_
Definition: DQWorker.h:83
unsigned long long EventNumber_t
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:54
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:57
unsigned int LuminosityBlockNumber_t
void setLumiNumber(edm::LuminosityBlockNumber_t _l)
Definition: DQWorker.h:65
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:58
void setEventNumber(edm::EventNumber_t _e)
Definition: DQWorker.h:66
void registerFactory(std::string const &_name, WorkerFactory _f)
Definition: DQWorker.h:98
DQWorker *(* WorkerFactory)()
Definition: DQWorker.h:86
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:64
edm::RunNumber_t iRun
Definition: DQWorker.h:34
boost::ptr_map< std::string, MESet > MESetCollection
Definition: MESet.h:350
bool onlineMode() const
Definition: DQWorker.h:69
#define noexcept
Timestamp timestamp_
Definition: DQWorker.h:78
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:104
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EventNumber_t iEvt
Definition: DQWorker.h:36
MESetCollection MEs_
Definition: DQWorker.h:75
std::string const & getName() const
Definition: DQWorker.h:68
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:46
HLT enums.
void setVerbosity(int _verbosity)
Definition: DQWorker.h:41
unsigned int RunNumber_t
void setTime(time_t _t)
Definition: DQWorker.h:63
Registration(std::string const &_name)
Definition: DQWorker.h:93
std::string name_
Definition: DQWorker.h:74
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:45
Definition: Run.h:45