CMS 3D CMS Logo

HLTDQMHist.h
Go to the documentation of this file.
1 #ifndef DQMOnline_Trigger_HLTDQMHist_h
2 #define DQMOnline_Trigger_HLTDQMHist_h
3 
4 //********************************************************************************
5 //
6 // Description:
7 // A histogram 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 histograms in the group and passed
11 // by the calling function) and local (which are stored with the histogram
12 // and are specific to that histogram. Global selection cuts on the variable being
13 // plotted are ignored, for example Et cuts are removed for turn on plots
14 //
15 // Implimentation:
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 
27 
29 
30 #include <TH1.h>
31 #include <TH2.h>
32 
33 //our base class for our histograms
34 //takes an object, edm::Event,edm::EventSetup and fills the histogram
35 //with the predetermined variable (or varaibles)
36 template <typename ObjType>
37 class HLTDQMHist {
38 public:
39  HLTDQMHist() = default;
40  virtual ~HLTDQMHist() = default;
41  virtual void fill(const ObjType& objType,
42  const edm::Event& event,
43  const edm::EventSetup& setup,
45 };
46 
47 //this class is a specific implimentation of a HLTDQMHist
48 //it has the value with which to fill the histogram
49 //and the histogram itself
50 //we do not own the histogram
51 template <typename ObjType, typename ValType>
52 class HLTDQMHist1D : public HLTDQMHist<ObjType> {
53 public:
55  std::string varName,
56  std::function<ValType(const ObjType&)> func,
59 
60  void fill(const ObjType& obj,
61  const edm::Event& event,
62  const edm::EventSetup& setup,
63  const VarRangeCutColl<ObjType>& globalRangeCuts) override {
64  //local range cuts are specific to a histogram so dont ignore variables
65  //like global ones (all local cuts should be approprate to the histogram in question
66  if (globalRangeCuts(obj, varName_) && localRangeCuts_(obj)) {
67  hist_->Fill(var_(obj));
68  }
69  }
70 
71 private:
72  std::function<ValType(const ObjType&)> var_;
75  TH1* hist_; //we do not own this
76 };
77 
78 template <typename ObjType, typename XValType, typename YValType = XValType>
79 class HLTDQMHist2D : public HLTDQMHist<ObjType> {
80 public:
82  std::string xVarName,
83  std::string yVarName,
84  std::function<XValType(const ObjType&)> xFunc,
85  std::function<YValType(const ObjType&)> yFunc,
87  : xVar_(std::move(xFunc)),
88  yVar_(std::move(yFunc)),
89  xVarName_(std::move(xVarName)),
90  yVarName_(std::move(yVarName)),
92  hist_(hist) {}
93 
94  void fill(const ObjType& obj,
95  const edm::Event& event,
96  const edm::EventSetup& setup,
97  const VarRangeCutColl<ObjType>& globalRangeCuts) override {
98  //local range cuts are specific to a histogram so dont ignore variables
99  //like global ones (all local cuts should be approprate to the histogram in question
100  if (globalRangeCuts(obj, std::vector<std::string>{xVarName_, yVarName_}) && localRangeCuts_(obj)) {
101  hist_->Fill(xVar_(obj), yVar_(obj));
102  }
103  }
104 
105 private:
106  std::function<XValType(const ObjType&)> xVar_;
107  std::function<YValType(const ObjType&)> yVar_;
111  TH2* hist_; //we do not own this
112 };
113 
114 #endif
HLTDQMHist::HLTDQMHist
HLTDQMHist()=default
HLTDQMHist2D::yVar_
std::function< YValType(const ObjType &)> yVar_
Definition: HLTDQMHist.h:107
HLTDQMHist2D::hist_
TH2 * hist_
Definition: HLTDQMHist.h:111
VarRangeCutColl
Definition: VarRangeCutColl.h:25
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
HLTDQMHist2D
Definition: HLTDQMHist.h:79
HLTDQMHist1D::varName_
std::string varName_
Definition: HLTDQMHist.h:73
HLTDQMHist::~HLTDQMHist
virtual ~HLTDQMHist()=default
HLTDQMHist1D::HLTDQMHist1D
HLTDQMHist1D(TH1 *hist, std::string varName, std::function< ValType(const ObjType &)> func, VarRangeCutColl< ObjType > rangeCuts)
Definition: HLTDQMHist.h:54
FunctionDefs.h
VarRangeCutColl.h
HLTDQMHist2D::localRangeCuts_
VarRangeCutColl< ObjType > localRangeCuts_
Definition: HLTDQMHist.h:110
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
electrons_cff.objType
objType
Definition: electrons_cff.py:519
Event.h
HLTDQMHist
Definition: HLTDQMHist.h:37
gpuVertexFinder::hist
__shared__ Hist hist
Definition: gpuClusterTracksDBSCAN.h:48
HLTDQMHist2D::yVarName_
std::string yVarName_
Definition: HLTDQMHist.h:109
HLTDQMHist1D::hist_
TH1 * hist_
Definition: HLTDQMHist.h:75
edm::EventSetup
Definition: EventSetup.h:58
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
HLTDQMHist2D::fill
void fill(const ObjType &obj, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &globalRangeCuts) override
Definition: HLTDQMHist.h:94
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTDQMHist1D::fill
void fill(const ObjType &obj, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &globalRangeCuts) override
Definition: HLTDQMHist.h:60
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTDQMHist2D::HLTDQMHist2D
HLTDQMHist2D(TH2 *hist, std::string xVarName, std::string yVarName, std::function< XValType(const ObjType &)> xFunc, std::function< YValType(const ObjType &)> yFunc, VarRangeCutColl< ObjType > rangeCuts)
Definition: HLTDQMHist.h:81
std
Definition: JetResolutionObject.h:76
HLTDQMHist1D
Definition: HLTDQMHist.h:52
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
B2GTnPMonitor_cfi.rangeCuts
rangeCuts
Definition: B2GTnPMonitor_cfi.py:64
HLTDQMHist1D::localRangeCuts_
VarRangeCutColl< ObjType > localRangeCuts_
Definition: HLTDQMHist.h:74
HLTDQMHist::fill
virtual void fill(const ObjType &objType, const edm::Event &event, const edm::EventSetup &setup, const VarRangeCutColl< ObjType > &rangeCuts)=0
HLTDQMHist2D::xVarName_
std::string xVarName_
Definition: HLTDQMHist.h:108
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
HLTDQMHist2D::xVar_
std::function< XValType(const ObjType &)> xVar_
Definition: HLTDQMHist.h:106
HLTDQMHist1D::var_
std::function< ValType(const ObjType &)> var_
Definition: HLTDQMHist.h:72