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