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