File indexing completed on 2023-03-17 10:55:52
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 "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0014 #include "DataFormats/VertexReco/interface/Vertex.h"
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "FWCore/Framework/interface/EDConsumerBase.h"
0017 #include "FWCore/Utilities/interface/EDGetToken.h"
0018 #include "JetMETCorrections/JetCorrector/interface/JetCorrector.h"
0019
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 namespace TopSingleLepton {
0049 using dqm::legacy::DQMStore;
0050 using dqm::legacy::MonitorElement;
0051
0052 class MonitorEnsemble {
0053 public:
0054
0055 enum Level { STANDARD, VERBOSE, DEBUG };
0056
0057 public:
0058
0059 MonitorEnsemble(const char* label, const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC);
0060
0061 ~MonitorEnsemble(){};
0062
0063
0064 void book(DQMStore::IBooker& ibooker);
0065
0066 void fill(const edm::Event& event, const edm::EventSetup& setup);
0067
0068 private:
0069
0070
0071 std::string monitorPath(const std::string& label) const { return label.substr(label.find(':') + 1); };
0072
0073
0074 std::string selectionPath(const std::string& label) const { return label.substr(0, label.find(':')); };
0075
0076
0077 void triggerBinLabels(std::string channel, const std::vector<std::string> labels);
0078
0079 void fill(const edm::Event& event,
0080 const edm::TriggerResults& triggerTable,
0081 std::string channel,
0082 const std::vector<std::string> labels) const;
0083
0084
0085 bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
0086
0087 void fill(const std::string histName, double value) const {
0088 if (booked(histName))
0089 hists_.find(histName)->second->Fill(value);
0090 };
0091
0092 void fill(const std::string histName, double xValue, double yValue) const {
0093 if (booked(histName))
0094 hists_.find(histName)->second->Fill(xValue, yValue);
0095 };
0096
0097 void fill(const std::string histName, double xValue, double yValue, double zValue) const {
0098 if (booked(histName))
0099 hists_.find(histName)->second->Fill(xValue, yValue, zValue);
0100 };
0101
0102 private:
0103
0104 Level verbosity_;
0105
0106 std::string label_;
0107
0108 std::vector<edm::EDGetTokenT<edm::View<reco::MET> > > mets_;
0109
0110 edm::EDGetTokenT<edm::View<reco::Jet> > jets_;
0111 edm::EDGetTokenT<edm::View<reco::PFCandidate> > muons_;
0112 edm::EDGetTokenT<edm::View<reco::PFCandidate> > elecs_;
0113 edm::EDGetTokenT<edm::View<reco::Vertex> > pvs_;
0114
0115 edm::EDGetTokenT<edm::TriggerResults> triggerTable_;
0116
0117
0118 std::vector<std::string> triggerPaths_;
0119
0120
0121 edm::EDGetTokenT<edm::ValueMap<float> > electronId_;
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 double eidCutValue_;
0137
0138
0139 edm::InputTag rhoTag;
0140
0141
0142
0143 std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > elecSelect_;
0144
0145
0146
0147 std::unique_ptr<StringCutObjectSelector<reco::Vertex> > pvSelect_;
0148
0149
0150 std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonIso_;
0151
0152
0153 std::unique_ptr<StringCutObjectSelector<reco::PFCandidate> > muonSelect_;
0154
0155
0156 edm::EDGetTokenT<reco::JetCorrector> jetCorrector_;
0157
0158
0159 edm::EDGetTokenT<reco::JetIDValueMap> jetIDLabel_;
0160
0161 std::unique_ptr<StringCutObjectSelector<reco::JetID> > jetIDSelect_;
0162
0163 std::string jetSelect_;
0164 std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetlooseSelection_;
0165 std::unique_ptr<StringCutObjectSelector<reco::PFJet> > jetSelection_;
0166
0167
0168 bool includeBTag_;
0169
0170 edm::EDGetTokenT<reco::JetTagCollection> btagEff_, btagPur_, btagVtx_, btagCSV_;
0171
0172 double btagEffWP_, btagPurWP_, btagVtxWP_, btagCSVWP_;
0173
0174 double lowerEdge_, upperEdge_;
0175
0176
0177 int logged_;
0178
0179
0180 std::map<std::string, MonitorElement*> hists_;
0181 edm::EDConsumerBase tmpConsumerBase;
0182
0183 std::string directory_;
0184 };
0185
0186 inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
0187 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0188 hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
0189 hists_[channel + "Eff_"]->setBinLabel(
0190 idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
0191 }
0192 }
0193
0194 inline void MonitorEnsemble::fill(const edm::Event& event,
0195 const edm::TriggerResults& triggerTable,
0196 std::string channel,
0197 const std::vector<std::string> labels) const {
0198 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0199 if (accept(event, triggerTable, monitorPath(labels[idx]))) {
0200 fill(channel + "Mon_", idx + 0.5);
0201
0202 int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
0203 double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
0204 fill(
0205 channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
0206 }
0207 }
0208 }
0209 }
0210
0211 #include <utility>
0212
0213 #include "DQM/Physics/interface/TopDQMHelpers.h"
0214 #include "FWCore/Framework/interface/Frameworkfwd.h"
0215 #include "FWCore/ServiceRegistry/interface/Service.h"
0216 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0217
0218 #include "FWCore/Common/interface/TriggerNames.h"
0219 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0220 #include "DataFormats/VertexReco/interface/Vertex.h"
0221 #include "DataFormats/Common/interface/TriggerResults.h"
0222
0223
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 class TopSingleLeptonDQM : public DQMOneEDAnalyzer<> {
0265 public:
0266
0267 TopSingleLeptonDQM(const edm::ParameterSet& cfg);
0268
0269 ~TopSingleLeptonDQM() override{};
0270
0271
0272 void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
0273
0274 protected:
0275
0276 void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0277
0278 private:
0279
0280
0281 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
0282
0283
0284 std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
0285
0286 private:
0287
0288 edm::EDGetTokenT<edm::TriggerResults> triggerTable__;
0289
0290 std::vector<std::string> triggerPaths_;
0291
0292 std::unique_ptr<StringCutObjectSelector<reco::Vertex> > vertexSelect_;
0293
0294
0295 edm::InputTag beamspot_;
0296 edm::EDGetTokenT<reco::BeamSpot> beamspot__;
0297
0298 std::unique_ptr<StringCutObjectSelector<reco::BeamSpot> > beamspotSelect_;
0299
0300
0301
0302 std::vector<std::string> selectionOrder_;
0303
0304
0305
0306
0307
0308 std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton::MonitorEnsemble> > > selection_;
0309 std::unique_ptr<SelectionStep<reco::PFCandidate> > MuonStep;
0310 std::unique_ptr<SelectionStep<reco::PFCandidate> > ElectronStep;
0311 std::unique_ptr<SelectionStep<reco::Vertex> > PvStep;
0312 std::unique_ptr<SelectionStep<reco::MET> > METStep;
0313 std::vector<std::unique_ptr<SelectionStep<reco::Jet> > > JetSteps;
0314 std::vector<std::unique_ptr<SelectionStep<reco::CaloJet> > > CaloJetSteps;
0315 std::vector<std::unique_ptr<SelectionStep<reco::PFJet> > > PFJetSteps;
0316
0317 std::vector<edm::ParameterSet> sel_;
0318 edm::ParameterSet setup_;
0319 };
0320
0321 #endif
0322
0323
0324
0325
0326