File indexing completed on 2024-04-06 12:32:41
0001 #ifndef Validation_HLTrigger_HLTGenValHist_h
0002 #define Validation_HLTrigger_HLTGenValHist_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "DQMOffline/Trigger/interface/FunctionDefs.h"
0017
0018 #include "DQMOffline/Trigger/interface/VarRangeCutColl.h"
0019
0020 #include "FWCore/Framework/interface/Event.h"
0021
0022 #include "Validation/HLTrigger/interface/HLTGenValObject.h"
0023
0024 #include <TH1.h>
0025 #include <TH2.h>
0026
0027
0028 class HLTGenValHist {
0029 public:
0030 HLTGenValHist() = default;
0031 virtual ~HLTGenValHist() = default;
0032 virtual void fill(const HLTGenValObject& objType) = 0;
0033 };
0034
0035
0036
0037
0038
0039
0040 class HLTGenValHist1D : public HLTGenValHist {
0041 public:
0042 HLTGenValHist1D(TH1* hist,
0043 std::string varName,
0044 std::function<float(const HLTGenValObject&)> func,
0045 VarRangeCutColl<HLTGenValObject> rangeCuts)
0046 : var_(std::move(func)), varName_(std::move(varName)), rangeCuts_(std::move(rangeCuts)), hist_(hist) {}
0047
0048 void fill(const HLTGenValObject& obj) override {
0049 if (rangeCuts_(obj))
0050 hist_->Fill(var_(obj));
0051 }
0052
0053 private:
0054 std::function<float(const HLTGenValObject&)> var_;
0055 std::string varName_;
0056 VarRangeCutColl<HLTGenValObject> rangeCuts_;
0057 TH1* hist_;
0058 };
0059
0060
0061
0062
0063
0064 class HLTGenValHist2D : public HLTGenValHist {
0065 public:
0066 HLTGenValHist2D(TH2* hist,
0067 std::string varNameX,
0068 std::string varNameY,
0069 std::function<float(const HLTGenValObject&)> funcX,
0070 std::function<float(const HLTGenValObject&)> funcY)
0071 : varX_(std::move(funcX)),
0072 varY_(std::move(funcY)),
0073 varNameX_(std::move(varNameX)),
0074 varNameY_(std::move(varNameY)),
0075 hist_(hist) {}
0076
0077 void fill(const HLTGenValObject& obj) override { hist_->Fill(varX_(obj), varY_(obj)); }
0078
0079 private:
0080 std::function<float(const HLTGenValObject&)> varX_;
0081 std::function<float(const HLTGenValObject&)> varY_;
0082 std::string varNameX_;
0083 std::string varNameY_;
0084 TH2* hist_;
0085 };
0086
0087 #endif