CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EgHLTMonElemWithCut.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
2 #define DQMOFFLINE_TRIGGER_EGHLTMONELEMWITHCUT
3 
4 //class: MonElemWithCut, short for MonitorElementWithCut (note not MonEleWith Cut as Ele might be confused for electron
5 //
6 //author: Sam Harper (Aug 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 improve the fire and forget nature of MonElemManger
12 // allows some arbitary selection to be placed on objects used to fill the monitoring element
13 // examples include it having to be associated with a specific trigger filter
14 
15 //implimentation: uses a MonElemManager to handle the Monitor Element and EgHLTDQMCut descide whether to fill it or not
16 // it was debated adding this capacity directly to MonElemManager
17 // this may happen in a future itteration of the code when things have stabilised
18 
22 namespace egHLT {
23  template <class T>
25  private:
26  MonElemWithCutBase(const MonElemWithCutBase& rhs) = default;
27  MonElemWithCutBase& operator=(const MonElemWithCutBase& rhs) { return *this; }
28 
29  public:
30  MonElemWithCutBase() = default;
31  virtual ~MonElemWithCutBase() = default;
32 
33  virtual void fill(const T& obj, const OffEvt& evt, float weight) = 0;
34  };
35 
36  template <class T, typename varTypeX, typename varTypeY = varTypeX>
37  class MonElemWithCut : public MonElemWithCutBase<T> {
38  private:
40  const EgHLTDQMCut<T>* cut_; //we also own this
41 
42  private:
44  MonElemWithCut& operator=(const MonElemWithCut& rhs) { return *this; }
45 
46  public:
48  const std::string& name,
49  const std::string& title,
50  int nrBins,
51  double xMin,
52  double xMax,
53  varTypeX (T::*varFunc)() const,
54  const EgHLTDQMCut<T>* cut = NULL)
55  : monElemMgr_(new MonElemManager<T, varTypeX>(iBooker, name, title, nrBins, xMin, xMax, varFunc)), cut_(cut) {}
56 
58  const std::string& name,
59  const std::string& title,
60  int nrBinsX,
61  double xMin,
62  double xMax,
63  int nrBinsY,
64  double yMin,
65  double yMax,
66  varTypeX (T::*varFuncX)() const,
67  varTypeY (T::*varFuncY)() const,
68  const EgHLTDQMCut<T>* cut = NULL)
69  : monElemMgr_(new MonElemManager2D<T, varTypeX, varTypeY>(
70  iBooker, name, title, nrBinsX, xMin, xMax, nrBinsY, yMin, yMax, varFuncX, varFuncY)),
71  cut_(cut) {}
72  ~MonElemWithCut() override;
73 
74  void fill(const T& obj, const OffEvt& evt, float weight) override;
75  };
76 
77  template <class T, typename varTypeX, typename varTypeY>
79  if (cut_)
80  delete cut_;
81  if (monElemMgr_)
82  delete monElemMgr_;
83  }
84 
85  template <class T, typename varTypeX, typename varTypeY>
87  if (cut_ == nullptr || cut_->pass(obj, evt))
88  monElemMgr_->fill(obj, weight);
89  }
90 
91 } // namespace egHLT
92 
93 #endif
MonElemWithCut & operator=(const MonElemWithCut &rhs)
const EgHLTDQMCut< T > * cut_
MonElemManagerBase< T > * monElemMgr_
void fill(const T &obj, const OffEvt &evt, float weight) override
#define NULL
Definition: scimark2.h:8
MonElemWithCut(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, int nrBinsX, double xMin, double xMax, int nrBinsY, double yMin, double yMax, varTypeX(T::*varFuncX)() const, varTypeY(T::*varFuncY)() const, const EgHLTDQMCut< T > *cut=NULL)
MonElemWithCut(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, int nrBins, double xMin, double xMax, varTypeX(T::*varFunc)() const, const EgHLTDQMCut< T > *cut=NULL)
virtual void fill(const T &obj, const OffEvt &evt, float weight)=0
MonElemWithCutBase & operator=(const MonElemWithCutBase &rhs)
MonElemWithCut(const MonElemWithCut &rhs)
int weight
Definition: histoStyle.py:51
long double T
virtual ~MonElemWithCutBase()=default