test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQWorker.h
Go to the documentation of this file.
1 #ifndef DQWorker_H
2 #define DQWorker_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
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 }
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();
51 
53 
54  virtual void beginRun(edm::Run const&, edm::EventSetup const&) {}
55  virtual void endRun(edm::Run const&, edm::EventSetup const&) {}
56 
59 
60  virtual void bookMEs(DQMStore::IBooker&);
61  virtual void releaseMEs();
62 
63  void setTime(time_t _t) { timestamp_.now = _t; }
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 
87  typedef DQWorker* (*WorkerFactory)();
88 
89  // to be instantiated after the implementation of each worker module
91  public:
92  template<typename Worker>
93  struct Registration {
94  Registration(std::string const& _name){ WorkerFactoryStore::singleton()->registerFactory(_name, []() -> DQWorker* { return new Worker(); }); }
95  };
96 
97  void registerFactory(std::string const& _name, WorkerFactory _f) { workerFactories_[_name] = _f; }
98  DQWorker* getWorker(std::string const&, int, edm::ParameterSet const&, edm::ParameterSet const&) const;
99 
100  static WorkerFactoryStore* singleton();
101 
102  private:
103  tbb::concurrent_unordered_map<std::string, WorkerFactory> workerFactories_;
104  };
105 
106 }
107 
108 #define DEFINE_ECALDQM_WORKER(TYPE) \
109  WorkerFactoryStore::Registration<TYPE> ecaldqm##TYPE##Registration(#TYPE)
110 
111 #endif
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:102
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:55
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
bool willConvertToEDM_
Definition: DQWorker.h:83
unsigned long long EventNumber_t
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:117
virtual void releaseMEs()
Definition: DQWorker.cc:77
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
Definition: Event.h:16
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:97
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:64
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:94
edm::RunNumber_t iRun
Definition: DQWorker.h:34
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:85
boost::ptr_map< std::string, MESet > MESetCollection
Definition: MESet.h:326
bool onlineMode() const
Definition: DQWorker.h:69
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:56
Timestamp timestamp_
Definition: DQWorker.h:78
void initialize(std::string const &_name, edm::ParameterSet const &)
Definition: DQWorker.cc:48
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:103
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:31
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
void setVerbosity(int _verbosity)
Definition: DQWorker.h:41
unsigned int RunNumber_t
virtual ~DQWorker()
Definition: DQWorker.cc:25
DQWorker *(* WorkerFactory)()
Definition: DQWorker.h:87
void setTime(time_t _t)
Definition: DQWorker.h:63
Registration(std::string const &_name)
Definition: DQWorker.h:94
std::string name_
Definition: DQWorker.h:74
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:45
Definition: Run.h:43