File indexing completed on 2024-11-28 03:54:27
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::Muon>> muons_;
0112 edm::EDGetTokenT<edm::View<reco::GsfElectron>> elecs_;
0113 edm::EDGetTokenT<edm::View<reco::Vertex>> pvs_;
0114 edm::EDGetTokenT<std::vector<reco::PFJet>> jetToken_;
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
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 double eidCutValue_;
0138
0139
0140 edm::InputTag rhoTag;
0141
0142
0143
0144 std::unique_ptr<StringCutObjectSelector<reco::GsfElectron>> elecSelect_;
0145
0146
0147
0148 std::unique_ptr<StringCutObjectSelector<reco::Vertex>> pvSelect_;
0149
0150
0151 std::unique_ptr<StringCutObjectSelector<reco::Muon>> muonIso_;
0152
0153
0154 std::unique_ptr<StringCutObjectSelector<reco::Muon>> muonSelect_;
0155
0156
0157 edm::EDGetTokenT<reco::JetCorrector> jetCorrector_;
0158
0159
0160 edm::EDGetTokenT<reco::JetIDValueMap> jetIDLabel_;
0161
0162 std::unique_ptr<StringCutObjectSelector<reco::JetID>> jetIDSelect_;
0163
0164 std::string jetSelect_;
0165 std::unique_ptr<StringCutObjectSelector<reco::PFJet>> jetlooseSelection_;
0166 std::unique_ptr<StringCutObjectSelector<reco::PFJet>> jetSelection_;
0167
0168
0169 bool includeBTag_;
0170
0171 edm::EDGetTokenT<reco::JetTagCollection> btagEff_, btagPur_, btagVtx_, btagCSV_;
0172
0173 double btagEffWP_, btagPurWP_, btagVtxWP_, btagCSVWP_;
0174
0175 double lowerEdge_, upperEdge_;
0176
0177
0178 int logged_;
0179
0180
0181 std::map<std::string, MonitorElement*> hists_;
0182 edm::EDConsumerBase tmpConsumerBase;
0183
0184 std::string directory_;
0185 };
0186
0187 inline void MonitorEnsemble::triggerBinLabels(std::string channel, const std::vector<std::string> labels) {
0188 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0189 hists_[channel + "Mon_"]->setBinLabel(idx + 1, "[" + monitorPath(labels[idx]) + "]", 1);
0190 hists_[channel + "Eff_"]->setBinLabel(
0191 idx + 1, "[" + selectionPath(labels[idx]) + "]|[" + monitorPath(labels[idx]) + "]", 1);
0192 }
0193 }
0194
0195 inline void MonitorEnsemble::fill(const edm::Event& event,
0196 const edm::TriggerResults& triggerTable,
0197 std::string channel,
0198 const std::vector<std::string> labels) const {
0199 for (unsigned int idx = 0; idx < labels.size(); ++idx) {
0200 if (accept(event, triggerTable, monitorPath(labels[idx]))) {
0201 fill(channel + "Mon_", idx + 0.5);
0202
0203 int evts = hists_.find(channel + "Mon_")->second->getBinContent(idx + 1);
0204 double value = hists_.find(channel + "Eff_")->second->getBinContent(idx + 1);
0205 fill(
0206 channel + "Eff_", idx + 0.5, 1. / evts * (accept(event, triggerTable, selectionPath(labels[idx])) - value));
0207 }
0208 }
0209 }
0210 }
0211
0212 #include <utility>
0213
0214 #include "DQM/Physics/interface/TopDQMHelpers.h"
0215 #include "FWCore/Framework/interface/Frameworkfwd.h"
0216 #include "FWCore/ServiceRegistry/interface/Service.h"
0217 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0218
0219 #include "FWCore/Common/interface/TriggerNames.h"
0220 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0221 #include "DataFormats/VertexReco/interface/Vertex.h"
0222 #include "DataFormats/Common/interface/TriggerResults.h"
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
0265 class TopSingleLeptonDQM : public DQMOneEDAnalyzer<> {
0266 public:
0267
0268 TopSingleLeptonDQM(const edm::ParameterSet& cfg);
0269
0270 ~TopSingleLeptonDQM() override {}
0271
0272
0273 void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
0274
0275 protected:
0276
0277 void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0278
0279 private:
0280
0281
0282 std::string objectType(const std::string& label) { return label.substr(0, label.find(':')); };
0283
0284
0285 std::string selectionStep(const std::string& label) { return label.substr(label.find(':') + 1); };
0286
0287 private:
0288
0289 edm::EDGetTokenT<edm::TriggerResults> triggerTable__;
0290
0291 std::vector<std::string> triggerPaths_;
0292
0293 std::unique_ptr<StringCutObjectSelector<reco::Vertex>> vertexSelect_;
0294
0295
0296 edm::InputTag beamspot_;
0297 edm::EDGetTokenT<reco::BeamSpot> beamspot__;
0298
0299 std::unique_ptr<StringCutObjectSelector<reco::BeamSpot>> beamspotSelect_;
0300
0301
0302
0303 std::vector<std::string> selectionOrder_;
0304
0305
0306
0307
0308
0309 std::map<std::string, std::pair<edm::ParameterSet, std::unique_ptr<TopSingleLepton::MonitorEnsemble>>> selection_;
0310 std::unique_ptr<SelectionStep<reco::Muon>> MuonStep;
0311 std::unique_ptr<SelectionStep<reco::GsfElectron>> ElectronStep;
0312 std::unique_ptr<SelectionStep<reco::Vertex>> PvStep;
0313 std::unique_ptr<SelectionStep<reco::MET>> METStep;
0314 std::vector<std::unique_ptr<SelectionStep<reco::Jet>>> JetSteps;
0315 std::vector<std::unique_ptr<SelectionStep<reco::CaloJet>>> CaloJetSteps;
0316 std::vector<std::unique_ptr<SelectionStep<reco::PFJet>>> PFJetSteps;
0317
0318 std::vector<edm::ParameterSet> sel_;
0319 edm::ParameterSet setup_;
0320 };
0321
0322 #endif
0323
0324
0325
0326
0327