File indexing completed on 2024-04-06 12:08:08
0001 #include "DQM/Physics/src/SingleTopTChannelLeptonDQM_miniAOD.h"
0002 #include "DataFormats/BTauReco/interface/JetTag.h"
0003 #include "DataFormats/JetReco/interface/CaloJet.h"
0004 #include "DataFormats/JetReco/interface/PFJet.h"
0005 #include "DataFormats/Math/interface/deltaR.h"
0006 #include "JetMETCorrections/Objects/interface/JetCorrectionsRecord.h"
0007 #include <iostream>
0008 #include <memory>
0009
0010 #include "FWCore/Framework/interface/ConsumesCollector.h"
0011 #include "FWCore/Framework/interface/EDConsumerBase.h"
0012 #include "FWCore/Utilities/interface/EDGetToken.h"
0013
0014 #include "DataFormats/PatCandidates/interface/Muon.h"
0015 #include "DataFormats/PatCandidates/interface/Electron.h"
0016 #include "DataFormats/PatCandidates/interface/Jet.h"
0017 #include "DataFormats/PatCandidates/interface/MET.h"
0018
0019 using namespace std;
0020 namespace SingleTopTChannelLepton_miniAOD {
0021
0022
0023
0024 static const unsigned int MAXJETS = 4;
0025
0026
0027 static const double WMASS = 80.4;
0028
0029 MonitorEnsemble::MonitorEnsemble(const char* label, const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0030 : label_(label),
0031 elecIso_(nullptr),
0032 elecSelect_(nullptr),
0033 pvSelect_(nullptr),
0034 muonIso_(nullptr),
0035 muonSelect_(nullptr),
0036 jetIDSelect_(nullptr),
0037 jetSelect(nullptr),
0038 includeBTag_(false),
0039 lowerEdge_(-1.),
0040 upperEdge_(-1.),
0041 logged_(0) {
0042
0043 edm::ParameterSet sources = cfg.getParameter<edm::ParameterSet>("sources");
0044
0045
0046
0047 muons_ = iC.consumes<edm::View<pat::Muon>>(sources.getParameter<edm::InputTag>("muons"));
0048
0049 elecs_ = iC.consumes<edm::View<pat::Electron>>(sources.getParameter<edm::InputTag>("elecs"));
0050 pvs_ = iC.consumes<edm::View<reco::Vertex>>(sources.getParameter<edm::InputTag>("pvs"));
0051 jets_ = iC.consumes<edm::View<pat::Jet>>(sources.getParameter<edm::InputTag>("jets"));
0052 for (edm::InputTag const& tag : sources.getParameter<std::vector<edm::InputTag>>("mets"))
0053 mets_.push_back(iC.consumes<edm::View<pat::MET>>(tag));
0054
0055
0056 if (cfg.existsAs<edm::ParameterSet>("elecExtras")) {
0057 edm::ParameterSet elecExtras = cfg.getParameter<edm::ParameterSet>("elecExtras");
0058
0059
0060 if (elecExtras.existsAs<std::string>("select")) {
0061 elecSelect_ =
0062 std::make_unique<StringCutObjectSelector<pat::Electron>>(elecExtras.getParameter<std::string>("select"));
0063 }
0064
0065
0066 if (elecExtras.existsAs<std::string>("isolation")) {
0067 elecIso_ =
0068 std::make_unique<StringCutObjectSelector<pat::Electron>>(elecExtras.getParameter<std::string>("isolation"));
0069 }
0070
0071 if (elecExtras.existsAs<std::string>("rho")) {
0072 rhoTag = elecExtras.getParameter<edm::InputTag>("rho");
0073 }
0074
0075
0076 if (elecExtras.existsAs<edm::ParameterSet>("electronId")) {
0077 edm::ParameterSet elecId = elecExtras.getParameter<edm::ParameterSet>("electronId");
0078 electronId_ = iC.consumes<edm::ValueMap<float>>(elecId.getParameter<edm::InputTag>("src"));
0079 eidCutValue_ = elecId.getParameter<double>("cutValue");
0080 }
0081 }
0082
0083 if (cfg.existsAs<edm::ParameterSet>("pvExtras")) {
0084 edm::ParameterSet pvExtras = cfg.getParameter<edm::ParameterSet>("pvExtras");
0085
0086
0087 if (pvExtras.existsAs<std::string>("select")) {
0088 pvSelect_ =
0089 std::make_unique<StringCutObjectSelector<reco::Vertex>>(pvExtras.getParameter<std::string>("select"));
0090 }
0091 }
0092
0093 if (cfg.existsAs<edm::ParameterSet>("muonExtras")) {
0094 edm::ParameterSet muonExtras = cfg.getParameter<edm::ParameterSet>("muonExtras");
0095
0096
0097 if (muonExtras.existsAs<std::string>("select")) {
0098 muonSelect_ =
0099 std::make_unique<StringCutObjectSelector<pat::Muon>>(muonExtras.getParameter<std::string>("select"));
0100 }
0101
0102
0103 if (muonExtras.existsAs<std::string>("isolation")) {
0104 muonIso_ =
0105 std::make_unique<StringCutObjectSelector<pat::Muon>>(muonExtras.getParameter<std::string>("isolation"));
0106 }
0107 }
0108
0109
0110
0111 if (cfg.existsAs<edm::ParameterSet>("jetExtras")) {
0112 edm::ParameterSet jetExtras = cfg.getParameter<edm::ParameterSet>("jetExtras");
0113
0114 if (jetExtras.existsAs<edm::ParameterSet>("jetID")) {
0115 edm::ParameterSet jetID = jetExtras.getParameter<edm::ParameterSet>("jetID");
0116 jetIDLabel_ = iC.consumes<reco::JetIDValueMap>(jetID.getParameter<edm::InputTag>("label"));
0117 jetIDSelect_ =
0118 std::make_unique<StringCutObjectSelector<reco::JetID>>(jetID.getParameter<std::string>("select"));
0119 }
0120
0121
0122
0123 if (jetExtras.existsAs<std::string>("select")) {
0124 jetSelect_ = jetExtras.getParameter<std::string>("select");
0125 jetSelect = std::make_unique<StringCutObjectSelector<pat::Jet>>(jetSelect_);
0126 }
0127 }
0128
0129
0130 if (cfg.existsAs<edm::ParameterSet>("triggerExtras")) {
0131 edm::ParameterSet triggerExtras = cfg.getParameter<edm::ParameterSet>("triggerExtras");
0132 triggerTable_ = iC.consumes<edm::TriggerResults>(triggerExtras.getParameter<edm::InputTag>("src"));
0133 triggerPaths_ = triggerExtras.getParameter<std::vector<std::string>>("paths");
0134 }
0135
0136
0137
0138
0139 if (cfg.existsAs<edm::ParameterSet>("massExtras")) {
0140 edm::ParameterSet massExtras = cfg.getParameter<edm::ParameterSet>("massExtras");
0141 lowerEdge_ = massExtras.getParameter<double>("lowerEdge");
0142 upperEdge_ = massExtras.getParameter<double>("upperEdge");
0143 }
0144
0145
0146
0147
0148
0149 verbosity_ = STANDARD;
0150 if (cfg.existsAs<edm::ParameterSet>("monitoring")) {
0151 edm::ParameterSet monitoring = cfg.getParameter<edm::ParameterSet>("monitoring");
0152 if (monitoring.getParameter<std::string>("verbosity") == "DEBUG")
0153 verbosity_ = DEBUG;
0154 if (monitoring.getParameter<std::string>("verbosity") == "VERBOSE")
0155 verbosity_ = VERBOSE;
0156 if (monitoring.getParameter<std::string>("verbosity") == "STANDARD")
0157 verbosity_ = STANDARD;
0158 }
0159
0160 directory_ = cfg.getParameter<std::string>("directory");
0161
0162 }
0163
0164 void MonitorEnsemble::book(DQMStore::IBooker& ibooker) {
0165
0166 std::string current(directory_);
0167 current += label_;
0168 ibooker.setCurrentFolder(current);
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 hists_["pvMult_"] = ibooker.book1D("PvMult", "N_{good pvs}", 50, 0., 50.);
0180
0181 hists_["muonPt_"] = ibooker.book1D("MuonPt", "pt(#mu TightId, TightIso)", 40, 0., 200.);
0182
0183 hists_["muonMult_"] = ibooker.book1D("MuonMult", "N_{loose}(#mu)", 10, 0., 10.);
0184
0185
0186
0187
0188 hists_["muonMultTight_"] = ibooker.book1D("MuonMultTight", "N_{TightIso,TightId}(#mu)", 10, 0., 10.);
0189
0190
0191 hists_["elecPt_"] = ibooker.book1D("ElecPt", "pt(e TightId, TightIso)", 40, 0., 200.);
0192
0193
0194
0195
0196
0197 hists_["jetMult_"] = ibooker.book1D("JetMult", "N_{30}(jet)", 10, 0., 10.);
0198 hists_["jetLooseMult_"] = ibooker.book1D("JetLooseMult", "N_{30,loose}(jet)", 10, 0., 10.);
0199
0200
0201
0202
0203
0204
0205
0206
0207 hists_["slimmedMETs_"] = ibooker.book1D("slimmedMETs", "MET_{slimmed}", 40, 0., 200.);
0208
0209 hists_["massW_"] = ibooker.book1D("MassW", "M(W)", 60, 0., 300.);
0210
0211 hists_["massTop_"] = ibooker.book1D("MassTop", "M(Top)", 50, 0., 500.);
0212
0213
0214
0215
0216 hists_["MTWm_"] = ibooker.book1D("MTWm", "M_{T}^{W}(#mu)", 60, 0., 300.);
0217
0218 hists_["mMTT_"] = ibooker.book1D("mMTT", "M_{T}^{t}(#mu)", 50, 0., 500.);
0219
0220
0221 hists_["MTWe_"] = ibooker.book1D("MTWe", "M_{T}^{W}(e)", 60, 0., 300.);
0222
0223 hists_["eMTT_"] = ibooker.book1D("eMTT", "M_{T}^{t}(e)", 50, 0., 500.);
0224
0225
0226 triggerBinLabels(std::string("trigger"), triggerPaths_);
0227
0228 if (verbosity_ == STANDARD)
0229 return;
0230
0231
0232
0233 hists_["muonEta_"] = ibooker.book1D("MuonEta", "#eta(#mu TightId,TightIso)", 30, -3., 3.);
0234
0235 hists_["muonPhi_"] = ibooker.book1D("MuonPhi", "#phi(#mu TightId,TightIso)", 40, -4., 4.);
0236 hists_["muonRelIso_"] = ibooker.book1D("MuonRelIso", "Iso_{Rel}(#mu TightId) (#Delta#beta Corrected)", 50, 0., 1.);
0237
0238
0239 hists_["elecEta_"] = ibooker.book1D("ElecEta", "#eta(e TightId, TightIso)", 30, -3., 3.);
0240 hists_["elecPhi_"] = ibooker.book1D("ElecPhi", "#phi(e TightId, TightIso)", 40, -4., 4.);
0241
0242 hists_["elecRelIso_"] = ibooker.book1D("ElecRelIso", "Iso_{Rel}(e TightId)", 50, 0., 1.);
0243
0244 hists_["elecMultTight_"] = ibooker.book1D("ElecMultTight", "N_{TightIso,TightId}(e)", 10, 0., 10.);
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 hists_["jet1Eta_"] = ibooker.book1D("Jet1Eta", "#eta_{30,loose}(jet1)", 60, -3., 3.);
0256
0257 hists_["jet1Pt_"] = ibooker.book1D("Jet1Pt", "pt_{30,loose}(jet1)", 60, 0., 300.);
0258
0259 hists_["jet2Eta_"] = ibooker.book1D("Jet2Eta", "#eta_{30,loose}(jet2)", 60, -3., 3.);
0260
0261 hists_["jet2Pt_"] = ibooker.book1D("Jet2Pt", "pt_{30,loose}(jet2)", 60, 0., 300.);
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272 hists_["slimmedMETsPuppi_"] = ibooker.book1D("slimmedMETsPuppi", "MET_{slimmedPuppi}", 40, 0., 200.);
0273
0274 hists_["muonDelZ_"] = ibooker.book1D("MuonDelZ", "d_{z}(#mu)", 50, -25., 25.);
0275
0276 hists_["muonDelXY_"] = ibooker.book2D("MuonDelXY", "d_{xy}(#mu)", 50, -0.1, 0.1, 50, -0.1, 0.1);
0277
0278
0279 hists_["muonDelXY_"]->setAxisTitle("x [cm]", 1);
0280 hists_["muonDelXY_"]->setAxisTitle("y [cm]", 2);
0281
0282 if (verbosity_ == VERBOSE)
0283 return;
0284
0285
0286
0287
0288 hists_["muonChHadIso_"] = ibooker.book1D("MuonChHadIsoComp", "ChHad_{IsoComponent}(#mu TightId)", 50, 0., 5.);
0289
0290
0291 hists_["muonNeHadIso_"] = ibooker.book1D("MuonNeHadIsoComp", "NeHad_{IsoComponent}(#mu TightId)", 50, 0., 5.);
0292
0293
0294 hists_["muonPhIso_"] = ibooker.book1D("MuonPhIsoComp", "Photon_{IsoComponent}(#mu TightId)", 50, 0., 5.);
0295
0296
0297 hists_["elecChHadIso_"] = ibooker.book1D("ElectronChHadIsoComp", "ChHad_{IsoComponent}(e TightId)", 50, 0., 5.);
0298
0299
0300 hists_["elecNeHadIso_"] = ibooker.book1D("ElectronNeHadIsoComp", "NeHad_{IsoComponent}(e TightId)", 50, 0., 5.);
0301
0302
0303 hists_["elecPhIso_"] = ibooker.book1D("ElectronPhIsoComp", "Photon_{IsoComponent}(e TightId)", 50, 0., 5.);
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318 hists_["jetMultBDeepJetM_"] = ibooker.book1D("JetMultBDeepJetM", "N_{30}(DeepJetM)", 10, 0., 10.);
0319
0320 hists_["jetBDeepJet_"] = ibooker.book1D("JetDiscDeepJet", "BJet Disc_{DeepJet}(JET)", 100, -1., 2.);
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330 hists_["eventLogger_"] = ibooker.book2D("EventLogger", "Logged Events", 9, 0., 9., 10, 0., 10.);
0331
0332
0333 hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
0334 hists_["eventLogger_"]->setBinLabel(1, "Run", 1);
0335 hists_["eventLogger_"]->setBinLabel(2, "Block", 1);
0336 hists_["eventLogger_"]->setBinLabel(3, "Event", 1);
0337 hists_["eventLogger_"]->setBinLabel(4, "pt_{L2L3}(jet1)", 1);
0338 hists_["eventLogger_"]->setBinLabel(5, "pt_{L2L3}(jet2)", 1);
0339 hists_["eventLogger_"]->setBinLabel(6, "pt_{L2L3}(jet3)", 1);
0340 hists_["eventLogger_"]->setBinLabel(7, "pt_{L2L3}(jet4)", 1);
0341 hists_["eventLogger_"]->setBinLabel(8, "M_{W}", 1);
0342 hists_["eventLogger_"]->setBinLabel(9, "M_{Top}", 1);
0343 hists_["eventLogger_"]->setAxisTitle("logged evts", 2);
0344 return;
0345 }
0346
0347 void MonitorEnsemble::fill(const edm::Event& event, const edm::EventSetup& setup) {
0348
0349 edm::Handle<edm::TriggerResults> triggerTable;
0350
0351 if (!triggerTable_.isUninitialized()) {
0352 if (!event.getByToken(triggerTable_, triggerTable))
0353 return;
0354 }
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364 edm::Handle<edm::View<reco::Vertex>> pvs;
0365 if (!event.getByToken(pvs_, pvs))
0366 return;
0367 const reco::Vertex& pver = pvs->front();
0368
0369 unsigned int pvMult = 0;
0370 if (pvs.isValid()) {
0371 for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin(); pv != pvs->end(); ++pv) {
0372 bool isGood =
0373 (!(pv->isFake()) && (pv->ndof() > 4.0) && (abs(pv->z()) < 24.0) && (abs(pv->position().Rho()) < 2.0));
0374 if (!isGood)
0375 continue;
0376 pvMult++;
0377 }
0378
0379 }
0380
0381 fill("pvMult_", pvMult);
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408 edm::Handle<edm::View<pat::Electron>> elecs;
0409 if (!event.getByToken(elecs_, elecs))
0410 return;
0411
0412 edm::Handle<double> _rhoHandle;
0413 event.getByLabel(rhoTag, _rhoHandle);
0414
0415
0416
0417 edm::Handle<edm::ValueMap<float>> electronId;
0418 if (!electronId_.isUninitialized()) {
0419 if (!event.getByToken(electronId_, electronId))
0420 return;
0421 }
0422
0423
0424 unsigned int eMultIso = 0, eMult = 0;
0425 std::vector<const pat::Electron*> isoElecs;
0426
0427 pat::Electron e;
0428
0429 for (edm::View<pat::Electron>::const_iterator elec = elecs->begin(); elec != elecs->end(); ++elec) {
0430 if (true) {
0431 if (!elecSelect_ || (*elecSelect_)(*elec)) {
0432 double el_ChHadIso = elec->pfIsolationVariables().sumChargedHadronPt;
0433 double el_NeHadIso = elec->pfIsolationVariables().sumNeutralHadronEt;
0434 double el_PhIso = elec->pfIsolationVariables().sumPhotonEt;
0435
0436 double rho = _rhoHandle.isValid() ? (float)(*_rhoHandle) : 0;
0437 double absEta = abs(elec->superCluster()->eta());
0438 double eA = 0;
0439 if (absEta < 1.000)
0440 eA = 0.1703;
0441 else if (absEta < 1.479)
0442 eA = 0.1715;
0443 else if (absEta < 2.000)
0444 eA = 0.1213;
0445 else if (absEta < 2.200)
0446 eA = 0.1230;
0447 else if (absEta < 2.300)
0448 eA = 0.1635;
0449 else if (absEta < 2.400)
0450 eA = 0.1937;
0451 else if (absEta < 5.000)
0452 eA = 0.2393;
0453
0454 double el_pfRelIso = (el_ChHadIso + max(0., el_NeHadIso + el_PhIso - rho * eA)) / elec->pt();
0455
0456 ++eMult;
0457
0458 if (eMult == 1) {
0459 fill("elecRelIso_", el_pfRelIso);
0460 fill("elecChHadIso_", el_ChHadIso);
0461 fill("elecNeHadIso_", el_NeHadIso);
0462 fill("elecPhIso_", el_PhIso);
0463 }
0464
0465
0466
0467
0468 if (!((el_pfRelIso < 0.0588 && absEta < 1.479) || (el_pfRelIso < 0.0571 && absEta > 1.479)))
0469 continue;
0470 ++eMultIso;
0471
0472 if (eMultIso == 1) {
0473
0474 e = *elec;
0475
0476 fill("elecPt_", elec->pt());
0477 fill("elecEta_", elec->eta());
0478 fill("elecPhi_", elec->phi());
0479 }
0480 }
0481 }
0482 }
0483
0484 fill("elecMultTight_", eMultIso);
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495 unsigned int mMult = 0, mTight = 0;
0496
0497 edm::Handle<edm::View<pat::Muon>> muons;
0498
0499 pat::Muon mu;
0500
0501 edm::View<pat::Muon>::const_iterator muonit;
0502
0503 if (!event.getByToken(muons_, muons))
0504 return;
0505
0506 for (edm::View<pat::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
0507
0508 if (muon->isGlobalMuon()) {
0509 fill("muonDelZ_", muon->innerTrack()->vz());
0510 fill("muonDelXY_", muon->innerTrack()->vx(), muon->innerTrack()->vy());
0511
0512
0513 if (!muonSelect_ || (*muonSelect_)(*muon)) {
0514
0515 ++mMult;
0516
0517 double chHadPt = muon->pfIsolationR04().sumChargedHadronPt;
0518 double neHadEt = muon->pfIsolationR04().sumNeutralHadronEt;
0519 double phoEt = muon->pfIsolationR04().sumPhotonEt;
0520
0521 double pfRelIso = (chHadPt + max(0., neHadEt + phoEt - 0.5 * muon->pfIsolationR04().sumPUPt)) /
0522 muon->pt();
0523
0524 if (!(muon->isGlobalMuon() && muon->isPFMuon() && muon->globalTrack()->normalizedChi2() < 10. &&
0525 muon->globalTrack()->hitPattern().numberOfValidMuonHits() > 0 && muon->numberOfMatchedStations() > 1 &&
0526 fabs(muon->muonBestTrack()->dxy(pver.position())) < 0.2 &&
0527 fabs(muon->muonBestTrack()->dz(pver.position())) < 0.5 &&
0528 muon->innerTrack()->hitPattern().numberOfValidPixelHits() > 0 &&
0529 muon->innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5))
0530 continue;
0531
0532 if (mMult == 1) {
0533
0534 fill("muonRelIso_", pfRelIso);
0535 fill("muonChHadIso_", chHadPt);
0536 fill("muonNeHadIso_", neHadEt);
0537 fill("muonPhIso_", phoEt);
0538 fill("muonRelIso_", pfRelIso);
0539 }
0540
0541 if (!(pfRelIso < 0.15))
0542 continue;
0543
0544 ++mTight;
0545
0546
0547 if (mTight == 1) {
0548
0549 mu = *muon;
0550 fill("muonPt_", muon->pt());
0551 fill("muonEta_", muon->eta());
0552 fill("muonPhi_", muon->phi());
0553 }
0554 }
0555 }
0556 }
0557 fill("muonMult_", mMult);
0558 fill("muonMultTight_", mTight);
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569 std::vector<pat::Jet> correctedJets;
0570 std::vector<double> JetTagValues;
0571 pat::Jet TaggedJetCand;
0572 vector<double> bJetDiscVal;
0573
0574 unsigned int mult = 0, loosemult = 0, multBDeepJetM = 0;
0575
0576 edm::Handle<edm::View<pat::Jet>> jets;
0577 if (!event.getByToken(jets_, jets)) {
0578 return;
0579 }
0580
0581 for (edm::View<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
0582
0583
0584
0585 const pat::Jet& sel = *jet;
0586
0587 if (jetSelect == nullptr)
0588 jetSelect = std::make_unique<StringCutObjectSelector<pat::Jet>>(jetSelect_);
0589
0590 if (!(*jetSelect)(sel))
0591 continue;
0592
0593
0594
0595 const pat::Jet& monitorJet = *jet;
0596
0597 ++mult;
0598
0599 if (monitorJet.chargedHadronEnergyFraction() > 0 && monitorJet.chargedMultiplicity() > 0 &&
0600 monitorJet.chargedEmEnergyFraction() < 0.99 && monitorJet.neutralHadronEnergyFraction() < 0.99 &&
0601 monitorJet.neutralEmEnergyFraction() < 0.99 &&
0602 (monitorJet.chargedMultiplicity() + monitorJet.neutralMultiplicity()) > 1) {
0603 correctedJets.push_back(monitorJet);
0604 ++loosemult;
0605
0606 double discriminator = monitorJet.bDiscriminator("pfDeepFlavourJetTags:probb") +
0607 monitorJet.bDiscriminator("pfDeepFlavourJetTags:probbb") +
0608 monitorJet.bDiscriminator("pfDeepFlavourJetTags:problepb");
0609
0610 fill("jetBDeepJet_", discriminator);
0611 if (discriminator > 0.2435) {
0612 if (multBDeepJetM == 0) {
0613 TaggedJetCand = monitorJet;
0614 bJetDiscVal.push_back(discriminator);
0615 } else if (multBDeepJetM == 1) {
0616 bJetDiscVal.push_back(discriminator);
0617 if (bJetDiscVal[1] > bJetDiscVal[0])
0618 TaggedJetCand = monitorJet;
0619 }
0620
0621 ++multBDeepJetM;
0622 }
0623
0624
0625
0626 JetTagValues.push_back(discriminator);
0627
0628
0629 if (loosemult == 1) {
0630
0631
0632 fill("jet1Pt_", monitorJet.pt());
0633
0634 fill("jet1Eta_", monitorJet.eta());
0635 };
0636 if (loosemult == 2) {
0637 fill("jet2Pt_", monitorJet.pt());
0638
0639 fill("jet2Eta_", monitorJet.eta());
0640 }
0641 }
0642 }
0643 fill("jetMult_", mult);
0644 fill("jetLooseMult_", loosemult);
0645 fill("jetMultBDeepJetM_", multBDeepJetM);
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657 pat::MET mET;
0658
0659 for (std::vector<edm::EDGetTokenT<edm::View<pat::MET>>>::const_iterator met_ = mets_.begin(); met_ != mets_.end();
0660 ++met_) {
0661 edm::Handle<edm::View<pat::MET>> met;
0662 if (!event.getByToken(*met_, met))
0663 continue;
0664 if (met->begin() != met->end()) {
0665 unsigned int idx = met_ - mets_.begin();
0666 if (idx == 0)
0667 fill("slimmedMETs_", met->begin()->et());
0668 if (idx == 2)
0669 fill("slimmedMETsPuppi_", met->begin()->et());
0670 }
0671 }
0672
0673
0674
0675
0676
0677
0678
0679
0680
0681
0682
0683 Calculate_miniAOD eventKinematics(MAXJETS, WMASS);
0684 double wMass = eventKinematics.massWBoson(correctedJets);
0685 double topMass = eventKinematics.massTopQuark(correctedJets);
0686 if (wMass >= 0 && topMass >= 0) {
0687 fill("massW_", wMass);
0688 fill("massTop_", topMass);
0689 }
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701 if ((lowerEdge_ == -1. && upperEdge_ == -1.) || (lowerEdge_ < wMass && wMass < upperEdge_)) {
0702 if (!triggerTable_.isUninitialized())
0703 fill(event, *triggerTable, "trigger", triggerPaths_);
0704 if (logged_ <= hists_.find("eventLogger_")->second->getNbinsY()) {
0705
0706
0707 fill("eventLogger_", 0.5, logged_ + 0.5, event.eventAuxiliary().run());
0708 fill("eventLogger_", 1.5, logged_ + 0.5, event.eventAuxiliary().luminosityBlock());
0709 fill("eventLogger_", 2.5, logged_ + 0.5, event.eventAuxiliary().event());
0710 if (!correctedJets.empty())
0711 fill("eventLogger_", 3.5, logged_ + 0.5, correctedJets[0].pt());
0712 if (correctedJets.size() > 1)
0713 fill("eventLogger_", 4.5, logged_ + 0.5, correctedJets[1].pt());
0714 if (correctedJets.size() > 2)
0715 fill("eventLogger_", 5.5, logged_ + 0.5, correctedJets[2].pt());
0716 if (correctedJets.size() > 3)
0717 fill("eventLogger_", 6.5, logged_ + 0.5, correctedJets[3].pt());
0718
0719 fill("eventLogger_", 7.5, logged_ + 0.5, wMass);
0720 fill("eventLogger_", 8.5, logged_ + 0.5, topMass);
0721 ++logged_;
0722 }
0723 }
0724
0725 if (multBDeepJetM != 0 && mTight == 1) {
0726 double mtW = eventKinematics.tmassWBoson(&mu, mET, TaggedJetCand);
0727 fill("MTWm_", mtW);
0728 double MTT = eventKinematics.tmassTopQuark(&mu, mET, TaggedJetCand);
0729 fill("mMTT_", MTT);
0730 }
0731
0732 if (multBDeepJetM != 0 && eMultIso == 1) {
0733 double mtW = eventKinematics.tmassWBoson(&e, mET, TaggedJetCand);
0734 fill("MTWe_", mtW);
0735 double MTT = eventKinematics.tmassTopQuark(&e, mET, TaggedJetCand);
0736 fill("eMTT_", MTT);
0737 }
0738 }
0739 }
0740
0741 SingleTopTChannelLeptonDQM_miniAOD::SingleTopTChannelLeptonDQM_miniAOD(const edm::ParameterSet& cfg)
0742 : vertexSelect_(nullptr),
0743 beamspot_(""),
0744 beamspotSelect_(nullptr),
0745 MuonStep(nullptr),
0746 ElectronStep(nullptr),
0747 PvStep(nullptr),
0748 METStep(nullptr) {
0749 JetSteps.clear();
0750
0751
0752 edm::ParameterSet presel = cfg.getParameter<edm::ParameterSet>("preselection");
0753 if (presel.existsAs<edm::ParameterSet>("trigger")) {
0754 edm::ParameterSet trigger = presel.getParameter<edm::ParameterSet>("trigger");
0755 triggerTable__ = consumes<edm::TriggerResults>(trigger.getParameter<edm::InputTag>("src"));
0756 triggerPaths_ = trigger.getParameter<std::vector<std::string>>("select");
0757 }
0758 if (presel.existsAs<edm::ParameterSet>("beamspot")) {
0759 edm::ParameterSet beamspot = presel.getParameter<edm::ParameterSet>("beamspot");
0760 beamspot_ = beamspot.getParameter<edm::InputTag>("src");
0761 beamspot__ = consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
0762 beamspotSelect_ =
0763 std::make_unique<StringCutObjectSelector<reco::BeamSpot>>(beamspot.getParameter<std::string>("select"));
0764 }
0765
0766
0767 sel_ = cfg.getParameter<std::vector<edm::ParameterSet>>("selection");
0768 setup_ = cfg.getParameter<edm::ParameterSet>("setup");
0769 for (unsigned int i = 0; i < sel_.size(); ++i) {
0770 selectionOrder_.push_back(sel_.at(i).getParameter<std::string>("label"));
0771 selection_[selectionStep(selectionOrder_.back())] =
0772 std::make_pair(sel_.at(i),
0773 std::make_unique<SingleTopTChannelLepton_miniAOD::MonitorEnsemble>(
0774
0775 selectionStep(selectionOrder_.back()).c_str(), setup_, consumesCollector()));
0776 }
0777 for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin(); selIt != selectionOrder_.end();
0778 ++selIt) {
0779 std::string key = selectionStep(*selIt), type = objectType(*selIt);
0780 if (selection_.find(key) != selection_.end()) {
0781 if (type == "muons") {
0782 MuonStep = std::make_unique<SelectionStep<pat::Muon>>(selection_[key].first, consumesCollector());
0783 }
0784 if (type == "elecs") {
0785 ElectronStep = std::make_unique<SelectionStep<pat::Electron>>(selection_[key].first, consumesCollector());
0786 }
0787 if (type == "pvs") {
0788 PvStep = std::make_unique<SelectionStep<reco::Vertex>>(selection_[key].first, consumesCollector());
0789 }
0790 if (type == "jets") {
0791 JetSteps.push_back(std::make_unique<SelectionStep<pat::Jet>>(selection_[key].first, consumesCollector()));
0792 }
0793
0794 if (type == "met") {
0795 METStep = std::make_unique<SelectionStep<pat::MET>>(selection_[key].first, consumesCollector());
0796 }
0797 }
0798 }
0799 }
0800 void SingleTopTChannelLeptonDQM_miniAOD::bookHistograms(DQMStore::IBooker& ibooker,
0801 edm::Run const&,
0802 edm::EventSetup const&) {
0803 for (auto selIt = selection_.begin(); selIt != selection_.end(); ++selIt) {
0804 selIt->second.second->book(ibooker);
0805 }
0806 }
0807 void SingleTopTChannelLeptonDQM_miniAOD::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0808 if (!triggerTable__.isUninitialized()) {
0809 edm::Handle<edm::TriggerResults> triggerTable;
0810 if (!event.getByToken(triggerTable__, triggerTable))
0811 return;
0812 if (!accept(event, *triggerTable, triggerPaths_))
0813 return;
0814 }
0815 if (!beamspot__.isUninitialized()) {
0816 edm::Handle<reco::BeamSpot> beamspot;
0817 if (!event.getByToken(beamspot__, beamspot))
0818 return;
0819 if (!(*beamspotSelect_)(*beamspot))
0820 return;
0821 }
0822
0823 unsigned int nJetSteps = -1;
0824
0825 for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin(); selIt != selectionOrder_.end();
0826 ++selIt) {
0827 std::string key = selectionStep(*selIt), type = objectType(*selIt);
0828 if (selection_.find(key) != selection_.end()) {
0829 if (type == "empty") {
0830 selection_[key].second->fill(event, setup);
0831 }
0832 if (type == "muons" && MuonStep != nullptr) {
0833 if (MuonStep->select(event)) {
0834 selection_[key].second->fill(event, setup);
0835 } else
0836 break;
0837 }
0838
0839 if (type == "elecs" && ElectronStep != nullptr) {
0840 if (ElectronStep->select(event)) {
0841 selection_[key].second->fill(event, setup);
0842 } else
0843 break;
0844 }
0845
0846 if (type == "pvs" && PvStep != nullptr) {
0847 if (PvStep->selectVertex(event)) {
0848 selection_[key].second->fill(event, setup);
0849 } else
0850 break;
0851 }
0852
0853 if (type == "jets") {
0854 nJetSteps++;
0855 if (JetSteps[nJetSteps] != nullptr) {
0856 if (JetSteps[nJetSteps]->select(event, setup)) {
0857 selection_[key].second->fill(event, setup);
0858 } else
0859 break;
0860 }
0861 }
0862
0863 if (type == "met" && METStep != nullptr) {
0864 if (METStep->select(event)) {
0865 selection_[key].second->fill(event, setup);
0866 } else
0867 break;
0868 }
0869 }
0870 }
0871 }
0872
0873
0874
0875
0876