File indexing completed on 2021-07-30 02:33:00
0001 #ifndef TOPSINGLELEPTONDQM_MINIAOD
0002 #define TOPSINGLELEPTONDQM_MINIAOD
0003
0004 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0005 #include <string>
0006 #include <vector>
0007 #include "FWCore/Utilities/interface/EDGetToken.h"
0008
0009 #include "DataFormats/JetReco/interface/Jet.h"
0010 #include "DQM/Physics/interface/TopDQMHelpers.h"
0011 #include "DataFormats/Common/interface/ValueMap.h"
0012 #include "DataFormats/METReco/interface/CaloMET.h"
0013 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0014 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
0015 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0016 #include "DataFormats/VertexReco/interface/Vertex.h"
0017 #include "FWCore/Framework/interface/ConsumesCollector.h"
0018 #include "FWCore/Framework/interface/EDConsumerBase.h"
0019 #include "FWCore/Utilities/interface/EDGetToken.h"
0020
0021 #include "DataFormats/PatCandidates/interface/Muon.h"
0022 #include "DataFormats/PatCandidates/interface/Electron.h"
0023 #include "DataFormats/PatCandidates/interface/Jet.h"
0024 #include "DataFormats/PatCandidates/interface/MET.h"
0025
0026 namespace TopSingleLepton_miniAOD {
0027 using dqm::legacy::DQMStore;
0028 using dqm::legacy::MonitorElement;
0029
0030 class MonitorEnsemble {
0031 public:
0032
0033 enum Level { STANDARD, VERBOSE, DEBUG };
0034
0035 public:
0036
0037 MonitorEnsemble(const char* label, const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC);
0038
0039 ~MonitorEnsemble(){};
0040
0041
0042 void book(DQMStore::IBooker& ibooker);
0043
0044 void fill(const edm::Event& event, const edm::EventSetup& setup);
0045
0046 private:
0047
0048
0049 std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
0050
0051
0052 std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
0053
0054
0055 void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
0056
0057 void fill(const edm::Event& event,
0058 const edm::TriggerResults& triggerTable,
0059 std::string channel,
0060 const std::vector<std::string> labels) const;
0061
0062
0063 bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
0064
0065 void fill(const std::string histName, double value) const {
0066 if (booked(histName))
0067 hists_.find(histName)->second->Fill(value);
0068 };
0069
0070 void fill(const std::string histName, double xValue, double yValue) const {
0071 if (booked(histName))
0072 hists_.find(histName)->second->Fill(xValue, yValue);
0073 };
0074
0075 void fill(const std::string histName, double xValue, double yValue, double zValue) const {
0076 if (booked(histName))
0077 hists_.find(histName)->second->Fill(xValue, yValue, zValue);
0078 };
0079
0080 private:
0081
0082 Level verbosity_;
0083
0084 std::string label_;
0085
0086 std::vector<edm::EDGetTokenT<edm::View<pat::MET> > > mets_;
0087
0088 edm::EDGetTokenT<edm::View<pat::Jet> > jets_;
0089 edm::EDGetTokenT<edm::View<pat::Muon> > muons_;
0090 edm::EDGetTokenT<edm::View<pat::Electron> > elecs_;
0091 edm::EDGetTokenT<edm::View<reco::Vertex> > pvs_;
0092
0093 edm::EDGetTokenT<edm::TriggerResults> triggerTable_;
0094
0095
0096 std::vector<std::string> triggerPaths_;
0097
0098 edm::InputTag rhoTag;
0099
0100
0101 edm::EDGetTokenT<edm::ValueMap<float> > electronId_;
0102
0103 double eidCutValue_;
0104
0105 std::unique_ptr<StringCutObjectSelector<pat::Electron> > elecIso_;
0106
0107 std::unique_ptr<StringCutObjectSelector<pat::Electron> > elecSelect_;
0108
0109
0110
0111 std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
0112
0113
0114 std::unique_ptr<StringCutObjectSelector<pat::Muon> > muonIso_;
0115
0116
0117 std::unique_ptr<StringCutObjectSelector<pat::Muon> > muonSelect_;
0118
0119
0120 edm::ESGetToken<JetCorrector, JetCorrectionsRecord> jetCorrector_;
0121
0122 edm::EDGetTokenT<reco::JetIDValueMap> jetIDLabel_;
0123
0124 std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
0125
0126
0127 std::string jetSelect_;
0128 std::unique_ptr<StringCutObjectSelector<pat::Jet> > jetSelect;
0129
0130
0131 bool includeBTag_;
0132
0133 edm::EDGetTokenT<reco::JetTagCollection> btagEff_, btagPur_, btagVtx_, btagCSV_;
0134
0135 double btagEffWP_, btagPurWP_, btagVtxWP_, btagCSVWP_;
0136
0137 double lowerEdge_, upperEdge_;
0138
0139
0140 int logged_;
0141
0142
0143 std::map<std::string, MonitorElement*> hists_;
0144 edm::EDConsumerBase tmpConsumerBase;
0145 std::string directory_;
0146 };
0147
0148 inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
0149 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0150 hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
0151 hists_[channel + "Eff_"]->setBinLabel(
0152 idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
0153 }
0154 }
0155
0156 inline void MonitorEnsemble::fill(const edm::Event& event,
0157 const edm::TriggerResults& triggerTable,
0158 std::string channel,
0159 const std::vector<std::string> labels) const {
0160 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0161 if (accept(event, triggerTable, monitorPath(labels[idx]))) {
0162 fill(channel + "Mon_", idx + 0.5);
0163
0164 int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
0165 double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
0166 fill(
0167 channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
0168 }
0169 }
0170 }
0171 }
0172
0173 #include <utility>
0174
0175 #include "DQM/Physics/interface/TopDQMHelpers.h"
0176 #include "FWCore/Framework/interface/Frameworkfwd.h"
0177 #include "FWCore/ServiceRegistry/interface/Service.h"
0178 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0179
0180 #include "FWCore/Common/interface/TriggerNames.h"
0181 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0182 #include "DataFormats/VertexReco/interface/Vertex.h"
0183 #include "DataFormats/Common/interface/TriggerResults.h"
0184
0185 class TopSingleLeptonDQM_miniAOD : public DQMOneEDAnalyzer<> {
0186 public:
0187
0188 TopSingleLeptonDQM_miniAOD(const edm::ParameterSet& cfg);
0189
0190 ~TopSingleLeptonDQM_miniAOD() override{};
0191
0192
0193 void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
0194
0195 protected:
0196
0197 void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0198
0199 private:
0200
0201
0202 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
0203
0204
0205 std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
0206
0207 private:
0208
0209 edm::EDGetTokenT<edm::TriggerResults> triggerTable__;
0210
0211 std::vector<std::string> triggerPaths_;
0212
0213 std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
0214
0215
0216 edm::InputTag beamspot_;
0217 edm::EDGetTokenT<reco::BeamSpot> beamspot__;
0218
0219 std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
0220
0221
0222
0223 std::vector<std::string> selectionOrder_;
0224
0225
0226
0227
0228
0229 std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton_miniAOD::MonitorEnsemble> > >
0230 selection_;
0231 std::unique_ptr<SelectionStep<pat::Muon> > MuonStep;
0232 std::unique_ptr<SelectionStep<pat::Electron> > ElectronStep;
0233 std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
0234 std::unique_ptr<SelectionStep<pat::MET> > METStep;
0235 std::vector<std::unique_ptr<SelectionStep<pat::Jet> > > JetSteps;
0236
0237 std::vector<edm::ParameterSet> sel_;
0238 edm::ParameterSet setup_;
0239 };
0240
0241 #endif
0242
0243
0244
0245
0246