CMS 3D CMS Logo

EgHLTMonElemManager.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMMANAGER
2 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMMANAGER
3 
4 //class: MonElemManager, short for MonitorElementManager (note not MonEleManager as Ele might be confused for electron
5 //
6 //author: Sam Harper (June 2008)
7 //
8 //WARNING: interface is NOT final, please dont use this class for now without clearing it with me
9 // as I will change it and possibly break all your code
10 //
11 //aim: to make MonitorElement objects "fire and forget"
12 // specifically it allows to you just add the MonitorElement to a vector containing all
13 // your monitor elements to be filled at a certain location so it will be automatically filled
14 // at that location and read out
15 // it does this by allowing you to specify the function pointer to the member variable you wish to fill at
16 // at the time of declaration
17 //
18 //implimentation: currently experimental and limited to 1D histograms but will expand later
19 // each object, Photon, GsfElectron, is a seperate (templated) class which means
20 // that seperate vectors of MonElemManagers are needed for each type
21 // however each type has a base class which the various types (int,float,double)
22 // of variable inherit from so dont need seperate vectors
23 
25 
27 
28 namespace egHLT {
31 
32  template <class T>
34  public:
35  MonElemManagerBase() = default;
36  virtual ~MonElemManagerBase() = default;
37 
38  virtual void fill(const T& obj, float weight) = 0;
39  };
40 
41  //this was the orginal base class but then I made a change where I wanted multiple MonElems wraped into a single Manager (ie endcap barrel) so a new base class was designed with interface only
42  template <class T>
44  private:
45  MonitorElement* monElem_; //we own this (or do we, currently I have decided we dont) FIXME
46 
47  //disabling copying and assignment as I havnt figured out how I want them to work yet
48  //incidently we cant copy a MonitorElement anyway at the moment (and we prob dont want to)
49  private:
51  MonElemManagerHist& operator=(const MonElemManagerHist& rhs) { return *this; }
52 
53  public:
55  DQMStore::IBooker& iBooker, std::string name, std::string title, int nrBins, double xMin, double xMax);
59  int nrBinsX,
60  double xMin,
61  double xMax,
62  int nrBinsY,
63  double yMin,
64  double yMax);
65  ~MonElemManagerHist() override;
66 
68  const MonitorElement* monElem() const { return monElem_; }
69 
70  void fill(const T& obj, float weight) override = 0;
71  };
72 
73  template <class T>
75  DQMStore::IBooker& iBooker, std::string name, std::string title, int nrBins, double xMin, double xMax)
76  : monElem_(nullptr) {
77  monElem_ = iBooker.book1D(name, title, nrBins, xMin, xMax);
78  }
79 
80  template <class T>
84  int nrBinsX,
85  double xMin,
86  double xMax,
87  int nrBinsY,
88  double yMin,
89  double yMax)
90  : monElem_(nullptr) {
91  monElem_ = iBooker.book2D(name, title, nrBinsX, xMin, xMax, nrBinsY, yMin, yMax);
92  }
93 
94  template <class T>
96  // delete monElem_;
97  }
98 
99  //fills the MonitorElement with a member function of class T returning type varType
100  template <class T, typename varType>
101  class MonElemManager : public MonElemManagerHist<T> {
102  private:
103  varType (T::*varFunc_)() const;
104 
105  //disabling copying and assignment as I havnt figured out how I want them to work yet
106  private:
108  MonElemManager& operator=(const MonElemManager& rhs) { return *this; }
109 
110  public:
114  int nrBins,
115  double xMin,
116  double xMax,
117  varType (T::*varFunc)() const)
118  : MonElemManagerHist<T>(iBooker, name, title, nrBins, xMin, xMax), varFunc_(varFunc) {}
119  ~MonElemManager() override;
120 
121  void fill(const T& obj, float weight) override;
122  };
123 
124  template <class T, typename varType>
126  MonElemManagerHist<T>::monElem()->Fill((obj.*varFunc_)(), weight);
127  }
128 
129  template <class T, typename varType>
131 
132  //fills a 2D monitor element with member functions of T returning varType1 and varType2
133  template <class T, typename varTypeX, typename varTypeY = varTypeX>
135  private:
136  varTypeX (T::*varFuncX_)() const;
137  varTypeY (T::*varFuncY_)() const;
138 
139  //disabling copying and assignment as I havnt figured out how I want them to work yet
140  private:
142  MonElemManager2D& operator=(const MonElemManager2D& rhs) { return *this; }
143 
144  public:
148  int nrBinsX,
149  double xMin,
150  double xMax,
151  int nrBinsY,
152  double yMin,
153  double yMax,
154  varTypeX (T::*varFuncX)() const,
155  varTypeY (T::*varFuncY)() const)
156  : MonElemManagerHist<T>(iBooker, name, title, nrBinsX, xMin, xMax, nrBinsY, yMin, yMax),
157  varFuncX_(varFuncX),
158  varFuncY_(varFuncY) {}
159  ~MonElemManager2D() override;
160 
161  void fill(const T& obj, float weight) override;
162  };
163 
164  template <class T, typename varTypeX, typename varTypeY>
166  MonElemManagerHist<T>::monElem()->Fill((obj.*varFuncX_)(), (obj.*varFuncY_)(), weight);
167  }
168 
169  template <class T, typename varTypeX, typename varTypeY>
171 } // namespace egHLT
172 
173 #endif
egHLT::MonElemManager2D::varFuncY_
varTypeY(T::* varFuncY_)() const
Definition: EgHLTMonElemManager.h:137
egHLT::MonElemManager::MonElemManager
MonElemManager(DQMStore::IBooker &iBooker, std::string name, std::string title, int nrBins, double xMin, double xMax, varType(T::*varFunc)() const)
Definition: EgHLTMonElemManager.h:111
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
egHLT::MonElemManagerHist::fill
void fill(const T &obj, float weight) override=0
egHLT::MonElemManagerHist::MonElemManagerHist
MonElemManagerHist(const MonElemManagerHist &rhs)
Definition: EgHLTMonElemManager.h:50
egHLT::MonElemManagerHist::operator=
MonElemManagerHist & operator=(const MonElemManagerHist &rhs)
Definition: EgHLTMonElemManager.h:51
egHLT::MonElemManagerHist::monElem_
MonitorElement * monElem_
Definition: EgHLTMonElemManager.h:45
egHLT::MonElemManagerHist::monElem
MonitorElement * monElem()
Definition: EgHLTMonElemManager.h:67
DQMStore.h
egHLT::MonElemManager::~MonElemManager
~MonElemManager() override
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
photonAnalyzer_cfi.yMin
yMin
Definition: photonAnalyzer_cfi.py:86
egHLT::MonElemManager::MonElemManager
MonElemManager(const MonElemManager &rhs)
Definition: EgHLTMonElemManager.h:107
photonAnalyzer_cfi.xMin
xMin
Definition: photonAnalyzer_cfi.py:82
egHLT::MonElemManager
Definition: EgHLTMonElemManager.h:101
Service.h
egHLT::MonElemManagerBase
Definition: EgHLTMonElemManager.h:33
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
multiplicitycorr_cfi.yMax
yMax
Definition: multiplicitycorr_cfi.py:6
dumpRecoGeometry_cfg.varType
varType
Definition: dumpRecoGeometry_cfg.py:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
egHLT::MonElemManagerHist::monElem
const MonitorElement * monElem() const
Definition: EgHLTMonElemManager.h:68
egHLT::MonElemManager2D::varFuncX_
varTypeX(T::* varFuncX_)() const
Definition: EgHLTMonElemManager.h:136
egHLT::MonElemManager::varFunc_
varType(T::* varFunc_)() const
Definition: EgHLTMonElemManager.h:103
egHLT::MonElemManager2D
Definition: EgHLTMonElemManager.h:134
egHLT::MonElemManager2D::fill
void fill(const T &obj, float weight) override
Definition: EgHLTMonElemManager.h:165
egHLT::MonElemManager::fill
void fill(const T &obj, float weight) override
Definition: EgHLTMonElemManager.h:125
egHLT::MonElemManager2D::operator=
MonElemManager2D & operator=(const MonElemManager2D &rhs)
Definition: EgHLTMonElemManager.h:142
egHLT::MonElemManagerHist
Definition: EgHLTMonElemManager.h:43
egHLT::MonElemManager::operator=
MonElemManager & operator=(const MonElemManager &rhs)
Definition: EgHLTMonElemManager.h:108
egHLT::MonElemManager2D::MonElemManager2D
MonElemManager2D(DQMStore::IBooker &iBooker, std::string name, std::string title, int nrBinsX, double xMin, double xMax, int nrBinsY, double yMin, double yMax, varTypeX(T::*varFuncX)() const, varTypeY(T::*varFuncY)() const)
Definition: EgHLTMonElemManager.h:145
T
long double T
Definition: Basic3DVectorLD.h:48
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
egHLT::MonElemManager2D::MonElemManager2D
MonElemManager2D(const MonElemManager2D &rhs)
Definition: EgHLTMonElemManager.h:141
phase2tkutil::DQMStore
dqm::reco::DQMStore DQMStore
Definition: TrackerPhase2DQMUtil.h:16
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
multiplicitycorr_cfi.xMax
xMax
Definition: multiplicitycorr_cfi.py:5
MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: SiPixelSCurveCalibrationAnalysis.h:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
egHLT::MonElemManagerBase::~MonElemManagerBase
virtual ~MonElemManagerBase()=default
egHLT
Definition: EgHLTBinData.h:10
egHLT::MonElemManager2D::~MonElemManager2D
~MonElemManager2D() override
egHLT::MonElemManagerBase::fill
virtual void fill(const T &obj, float weight)=0
weight
Definition: weight.py:1
egHLT::MonElemManagerBase::MonElemManagerBase
MonElemManagerBase()=default
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
egHLT::MonElemManagerHist::~MonElemManagerHist
~MonElemManagerHist() override
Definition: EgHLTMonElemManager.h:95