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 
55  static void fillDescriptions(edm::ParameterSetDescription &_desc);
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; }
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
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
funct::false
false
Definition: Factorize.h:29
ecaldqm
Definition: DQWorker.h:24
ecaldqm::WorkerFactoryStore::workerFactories_
tbb::concurrent_unordered_map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:107
ecaldqm::DQWorker::name_
std::string name_
Definition: DQWorker.h:77
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
ecaldqm::DQWorker::setLumiNumber
void setLumiNumber(edm::LuminosityBlockNumber_t _l)
Definition: DQWorker.h:68
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
MESet.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
ecaldqm::DQWorker::bookMEs
virtual void bookMEs(DQMStore::IBooker &)
Definition: DQWorker.cc:66
ecaldqm::WorkerFactoryStore::getWorker
DQWorker * getWorker(std::string const &, int, edm::ParameterSet const &, edm::ParameterSet const &) const
Definition: DQWorker.cc:79
ecaldqm::DQWorker::print_
void print_(std::string const &, int=0) const
Definition: DQWorker.cc:74
ecaldqm::DQWorker::booked_
bool booked_
Definition: DQWorker.h:79
watchdog.const
const
Definition: watchdog.py:83
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
ecaldqm::DQWorker::releaseMEs
virtual void releaseMEs()
Definition: DQWorker.cc:60
ecaldqm::DQWorker
Definition: DQWorker.h:28
ecaldqm::DQWorker::setEventNumber
void setEventNumber(edm::EventNumber_t _e)
Definition: DQWorker.h:69
ecaldqm::WorkerFactoryStore::Registration
Definition: DQWorker.h:95
dqm::legacy::DQMStore
Definition: DQMStore.h:727
ecaldqm::DQWorker::MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: DQWorker.h:42
EventID.h
ecaldqm::DQWorker::onlineMode
bool onlineMode() const
Definition: DQWorker.h:72
LuminosityBlock
Event
ecaldqm::DQWorker::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &_desc)
Definition: DQWorker.cc:19
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
ecaldqm::DQWorker::beginLuminosityBlock
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:60
ecaldqm::WorkerFactory
DQWorker *(* WorkerFactory)()
Definition: DQWorker.h:89
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ecaldqm::WorkerFactoryStore
Definition: DQWorker.h:92
ecaldqm::DQWorker::onlineMode_
bool onlineMode_
Definition: DQWorker.h:85
ecaldqm::DQWorker::setVerbosity
void setVerbosity(int _verbosity)
Definition: DQWorker.h:44
ecaldqm::DQWorker::setParams
virtual void setParams(edm::ParameterSet const &)
Definition: DQWorker.h:49
ecaldqm::DQWorker::setRunNumber
void setRunNumber(edm::RunNumber_t _r)
Definition: DQWorker.h:67
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
ecaldqm::MESetCollection
Definition: MESet.h:343
ecaldqm::DQWorker::initialize
void initialize(std::string const &_name, edm::ParameterSet const &)
Definition: DQWorker.cc:35
edm::EventSetup
Definition: EventSetup.h:57
ecaldqm::DQWorker::Timestamp::iRun
edm::RunNumber_t iRun
Definition: DQWorker.h:34
ecaldqm::WorkerFactoryStore::registerFactory
void registerFactory(std::string const &_name, WorkerFactory _f)
Definition: DQWorker.h:101
ecaldqm::DQWorker::willConvertToEDM_
bool willConvertToEDM_
Definition: DQWorker.h:86
ecaldqm::DQWorker::Timestamp::Timestamp
Timestamp()
Definition: DQWorker.h:37
ecaldqm::DQWorker::setME
virtual void setME(edm::ParameterSet const &)
Definition: DQWorker.cc:41
ecaldqm::DQWorker::Timestamp::iLumi
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
ecaldqm::DQWorker::beginRun
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:57
ecaldqm::DQWorker::getName
const std::string & getName() const
Definition: DQWorker.h:71
ecaldqm::DQWorker::~DQWorker
virtual ~DQWorker() noexcept(false)
Definition: DQWorker.cc:16
ecaldqm::DQWorker::endLuminosityBlock
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQWorker.h:61
ecaldqm::DQWorker::Timestamp
Definition: DQWorker.h:32
ecaldqm::DQWorker::timestamp_
Timestamp timestamp_
Definition: DQWorker.h:81
ParameterSetDescription
ecaldqm::DQWorker::verbosity_
int verbosity_
Definition: DQWorker.h:82
dqm::implementation::IBooker
Definition: DQMStore.h:43
ecaldqm::WorkerFactoryStore::singleton
static WorkerFactoryStore * singleton()
Definition: DQWorker.cc:95
ecaldqm::WorkerFactoryStore::Registration::Registration
Registration(std::string const &_name)
Definition: DQWorker.h:96
ecaldqm::DQWorker::Timestamp::iEvt
edm::EventNumber_t iEvt
Definition: DQWorker.h:36
EventSetup
ecaldqm::DQWorker::setTime
void setTime(time_t _t)
Definition: DQWorker.h:66
ecaldqm::DQWorker::setSource
virtual void setSource(edm::ParameterSet const &)
Definition: DQWorker.h:48
ecaldqm::DQWorker::Timestamp::now
time_t now
Definition: DQWorker.h:33
ecaldqm::DQWorker::endRun
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: DQWorker.h:58
RunID.h
ecaldqm::DQWorker::DQWorker
DQWorker()
Definition: DQWorker.cc:13
ecaldqm::DQWorker::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: DQWorker.h:41
Run