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 
11 
12 namespace edm{
13  class Run;
14  class LuminosityBlock;
15  class Event;
16  class EventSetup;
17 }
18 class DQMStore;
19 
20 namespace ecaldqm{
21 
22  class DQWorker {
23  public :
25  virtual ~DQWorker();
26 
27  virtual void beginRun(const edm::Run &, const edm::EventSetup &){};
28  virtual void endRun(const edm::Run &, const edm::EventSetup &){};
29 
30  virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &){};
31  virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &){};
32 
33  virtual void bookMEs();
34 
35  virtual void reset();
36  virtual std::string const& getName() { return name_; }
37  virtual bool isInitialized() { return initialized_; }
38  virtual void setInitialized(bool _init) { initialized_ = _init; }
39  virtual void setVerbosity(int _verbosity) { verbosity_ = _verbosity; }
40 
41  const std::vector<MESet*>& getMEs() { return MEs_; }
42 
43  enum MESets {
45  };
46 
47  static std::map<std::string, std::vector<MEData> > meData;
48  // needs to be declared in each derived class
49  static void setMEData(std::vector<MEData>&);
50 
51  protected :
52  void meSet_(unsigned, edm::ParameterSet const&);
53  MESet* createMESet_(std::string const&, MEData const&, bool _readOnly = false) const;
54 
56  std::vector<MESet*> MEs_; // [nMESets]
58 
60  };
61 
62 
63 
64  typedef DQWorker* (*WorkerFactory)(const edm::ParameterSet&, const edm::ParameterSet&);
65 
66  // template of WorkerFactory instance
67  template<class W>
68  DQWorker*
69  workerFactory(const edm::ParameterSet& _params, const edm::ParameterSet& _paths)
70  {
71  W* worker(new W(_params, _paths));
72  return worker;
73  }
74 
75  // to be instantiated after the implementation of each worker module
76  class SetWorker {
77  public:
78  template <class W> SetWorker(const std::string& _name, W*){
79  workerFactories_[_name] = workerFactory<W>;
80 
81  std::vector<MEData>& data(DQWorker::meData[_name]);
82  data.clear();
83  data.resize(W::nMESets);
84  W::setMEData(data);
85  }
86  static WorkerFactory findFactory(const std::string&);
87  private:
88  static std::map<std::string, WorkerFactory> workerFactories_;
89  };
90 
91 }
92 
93 #define DEFINE_ECALDQM_WORKER(TYPE) \
94  TYPE *p##TYPE(0); SetWorker TYPE##Instance(#TYPE, p##TYPE)
95 
96 #endif
SetWorker(const std::string &_name, W *)
Definition: DQWorker.h:78
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: DQWorker.h:27
static void setMEData(std::vector< MEData > &)
Definition: DQWorker.cc:65
virtual void setVerbosity(int _verbosity)
Definition: DQWorker.h:39
static std::map< std::string, WorkerFactory > workerFactories_
Definition: DQWorker.h:88
virtual void setInitialized(bool _init)
Definition: DQWorker.h:38
virtual void reset()
Definition: DQWorker.cc:55
virtual std::string const & getName()
Definition: DQWorker.h:36
virtual bool isInitialized()
Definition: DQWorker.h:37
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
Definition: DQWorker.h:30
DQWorker(const edm::ParameterSet &, const edm::ParameterSet &, std::string const &)
Definition: DQWorker.cc:18
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
Definition: DQWorker.h:31
DQWorker *(* WorkerFactory)(const edm::ParameterSet &, const edm::ParameterSet &)
Definition: DQWorker.h:64
DQWorker * workerFactory(const edm::ParameterSet &_params, const edm::ParameterSet &_paths)
Definition: DQWorker.h:69
static WorkerFactory findFactory(const std::string &)
Definition: DQWorker.cc:131
virtual void endRun(const edm::Run &, const edm::EventSetup &)
Definition: DQWorker.h:28
virtual void bookMEs()
Definition: DQWorker.cc:48
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
MESet * createMESet_(std::string const &, MEData const &, bool _readOnly=false) const
Definition: DQWorker.cc:70
virtual ~DQWorker()
Definition: DQWorker.cc:41
void meSet_(unsigned, edm::ParameterSet const &)
std::string name_
Definition: DQWorker.h:55
Definition: Run.h:41
static std::map< std::string, std::vector< MEData > > meData
Definition: DQWorker.h:47
const std::vector< MESet * > & getMEs()
Definition: DQWorker.h:41