CMS 3D CMS Logo

HLTDQMHist.h
Go to the documentation of this file.
1 #ifndef DQMOffline_Trigger_HLTDQMHist_h
2 #define DQMOffline_Trigger_HLTDQMHist_h
3 
4 //********************************************************************************
5 //
6 // Description:
7 // A MonitorElement together with the necessary information to fill it when pass an
8 // object and minimal selection cuts. These selection cuts are intended to be
9 // simple selections on kinematic variables. There are two levels of these
10 // selection cuts, global (which apply to all MonitorElements in the group and passed
11 // by the calling function) and local (which are stored with the MonitorElement
12 // and are specific to that MonitorElement). Global selection cuts on the variable being
13 // plotted are ignored, for example Et cuts are removed for turn on plots
14 //
15 // Implementation:
16 // std::function holds the function which generates the vs variable
17 // the name of the vs variable is also stored so we can determine if we should not apply
18 // a given selection cut
19 // selection is done by VarRangeCutColl
20 //
21 // Author : Sam Harper , RAL, May 2017
22 //
23 //***********************************************************************************
24 
29 
30 //our base class for our MonitorElements
31 //takes an object, edm::Event,edm::EventSetup and fills the MonitorElement
32 //with the predetermined variable (or variables)
33 template <typename ObjType>
34 class HLTDQMHist {
35 public:
36  HLTDQMHist() = default;
37  virtual ~HLTDQMHist() = default;
38  virtual void fill(const ObjType& objType,
39  const edm::Event& event,
40  const edm::EventSetup& setup,
42 };
43 
44 //this class is a specific implimentation of a HLTDQMHist
45 //it has the value with which to fill the MonitorElement
46 //and the MonitorElement itself
47 //we do not own the MonitorElement
48 template <typename ObjType, typename ValType>
49 class HLTDQMHist1D : public HLTDQMHist<ObjType> {
50 public:
52 
54  std::string varName,
55  std::function<ValType(const ObjType&)> func,
57  : var_(std::move(func)), varName_(std::move(varName)), localRangeCuts_(std::move(rangeCuts)), me_ptr_(me_ptr) {}
58 
59  void fill(const ObjType& obj,
60  const edm::Event& event,
61  const edm::EventSetup& setup,
62  const VarRangeCutColl<ObjType>& globalRangeCuts) override {
63  if (me_ptr_ == nullptr)
64  return;
65  //local range cuts are specific to a MonitorElement so dont ignore variables
66  //like global ones (all local cuts should be appropriate to the MonitorElement in question
67  if (globalRangeCuts(obj, varName_) && localRangeCuts_(obj)) {
68  me_ptr_->Fill(var_(obj));
69  }
70  }
71 
72 private:
73  std::function<ValType(const ObjType&)> var_;
76  MonitorElement* const me_ptr_; // we do not own this
77 };
78 
79 template <typename ObjType, typename XValType, typename YValType = XValType>
80 class HLTDQMHist2D : public HLTDQMHist<ObjType> {
81 public:
83 
85  std::string xVarName,
86  std::string yVarName,
87  std::function<XValType(const ObjType&)> xFunc,
88  std::function<YValType(const ObjType&)> yFunc,
90  : xVar_(std::move(xFunc)),
91  yVar_(std::move(yFunc)),
92  xVarName_(std::move(xVarName)),
93  yVarName_(std::move(yVarName)),
95  me_ptr_(me_ptr) {}
96 
97  void fill(const ObjType& obj,
98  const edm::Event& event,
99  const edm::EventSetup& setup,
100  const VarRangeCutColl<ObjType>& globalRangeCuts) override {
101  if (me_ptr_ == nullptr)
102  return;
103  //local range cuts are specific to a MonitorElement so dont ignore variables
104  //like global ones (all local cuts should be appropriate to the MonitorElement in question
105  if (globalRangeCuts(obj, std::vector<std::string>{xVarName_, yVarName_}) && localRangeCuts_(obj)) {
106  me_ptr_->Fill(xVar_(obj), yVar_(obj));
107  }
108  }
109 
110 private:
111  std::function<XValType(const ObjType&)> xVar_;
112  std::function<YValType(const ObjType&)> yVar_;
116  MonitorElement* const me_ptr_; // we do not own this
117 };
118 
119 #endif // DQMOffline_Trigger_HLTDQMHist_h
virtual void fill(const ObjType &objType, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &rangeCuts)=0
std::string yVarName_
Definition: HLTDQMHist.h:114
HLTDQMHist1D(MonitorElement *me_ptr, std::string varName, std::function< ValType(const ObjType &)> func, VarRangeCutColl< ObjType > rangeCuts)
Definition: HLTDQMHist.h:53
virtual ~HLTDQMHist()=default
std::function< XValType(const ObjType &)> xVar_
Definition: HLTDQMHist.h:111
void Fill(long long x)
std::function< ValType(const ObjType &)> var_
Definition: HLTDQMHist.h:73
MonitorElement *const me_ptr_
Definition: HLTDQMHist.h:76
VarRangeCutColl< ObjType > localRangeCuts_
Definition: HLTDQMHist.h:75
void fill(const ObjType &obj, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &globalRangeCuts) override
Definition: HLTDQMHist.h:59
std::string varName_
Definition: HLTDQMHist.h:74
HLTDQMHist()=default
MonitorElement *const me_ptr_
Definition: HLTDQMHist.h:116
dqm::legacy::MonitorElement MonitorElement
Definition: HLTDQMHist.h:82
void fill(const ObjType &obj, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &globalRangeCuts) override
Definition: HLTDQMHist.h:97
std::string xVarName_
Definition: HLTDQMHist.h:113
std::function< YValType(const ObjType &)> yVar_
Definition: HLTDQMHist.h:112
HLTDQMHist2D(MonitorElement *me_ptr, std::string xVarName, std::string yVarName, std::function< XValType(const ObjType &)> xFunc, std::function< YValType(const ObjType &)> yFunc, VarRangeCutColl< ObjType > rangeCuts)
Definition: HLTDQMHist.h:84
VarRangeCutColl< ObjType > localRangeCuts_
Definition: HLTDQMHist.h:115
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
dqm::legacy::MonitorElement MonitorElement
Definition: HLTDQMHist.h:51