File indexing completed on 2023-05-26 22:38:15
0001
0002
0003
0004
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/Utilities/interface/TypeID.h"
0009
0010 #include "CommonTools/Utils/interface/PtComparator.h"
0011 #include "DataFormats/Math/interface/LorentzVector.h"
0012 #include "HLTriggerOffline/Exotica/interface/HLTExoticaSubAnalysis.h"
0013 #include "HLTriggerOffline/Exotica/src/EVTColContainer.cc"
0014
0015 #include "TPRegexp.h"
0016 #include "TString.h"
0017
0018 #include "DataFormats/Common/interface/TriggerResults.h"
0019 #include "FWCore/Common/interface/TriggerNames.h"
0020
0021 #include <algorithm>
0022 #include <set>
0023
0024 static constexpr int verbose = 0;
0025
0026
0027 HLTExoticaSubAnalysis::HLTExoticaSubAnalysis(const edm::ParameterSet &pset,
0028 const std::string &analysisname,
0029 edm::ConsumesCollector &&consCollector)
0030 : _pset(pset),
0031 _analysisname(analysisname),
0032 _minCandidates(0),
0033 _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
0034 _genParticleLabel(pset.getParameter<std::string>("genParticleLabel")),
0035 _trigResultsLabel("TriggerResults", "", _hltProcessName),
0036 _beamSpotLabel(pset.getParameter<std::string>("beamSpotLabel")),
0037 _parametersEta(pset.getParameter<std::vector<double>>("parametersEta")),
0038 _parametersPhi(pset.getParameter<std::vector<double>>("parametersPhi")),
0039 _parametersTurnOn(pset.getParameter<std::vector<double>>("parametersTurnOn")),
0040 _parametersTurnOnSumEt(pset.getParameter<std::vector<double>>("parametersTurnOnSumEt")),
0041 _parametersDxy(pset.getParameter<std::vector<double>>("parametersDxy")),
0042 _drop_pt2(false),
0043 _drop_pt3(false),
0044 _recMuonSelector(nullptr),
0045 _recMuonTrkSelector(nullptr),
0046 _recTrackSelector(nullptr),
0047 _recElecSelector(nullptr),
0048 _recMETSelector(nullptr),
0049 _recPFMETSelector(nullptr),
0050 _recPFMHTSelector(nullptr),
0051 _genMETSelector(nullptr),
0052 _recCaloMETSelector(nullptr),
0053 _recCaloMHTSelector(nullptr),
0054 _recPFTauSelector(nullptr),
0055 _recPhotonSelector(nullptr),
0056 _recPFJetSelector(nullptr),
0057 _recCaloJetSelector(nullptr) {
0058 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::constructor()";
0059
0060
0061 edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
0062
0063
0064
0065
0066
0067 if (anpset.exists("parametersTurnOn")) {
0068 _parametersTurnOn = anpset.getParameter<std::vector<double>>("parametersTurnOn");
0069 _pset.insert(true, "parametersTurnOn", anpset.retrieve("parametersTurnOn"));
0070 }
0071 if (anpset.exists("parametersEta")) {
0072 _parametersEta = anpset.getParameter<std::vector<double>>("parametersEta");
0073 _pset.insert(true, "parametersEta", anpset.retrieve("parametersEta"));
0074 }
0075 if (anpset.exists("parametersPhi")) {
0076 _parametersPhi = anpset.getParameter<std::vector<double>>("parametersPhi");
0077 _pset.insert(true, "parametersPhi", anpset.retrieve("parametersPhi"));
0078 }
0079 if (anpset.exists("parametersDxy")) {
0080 _parametersDxy = anpset.getParameter<std::vector<double>>("parametersDxy");
0081 _pset.insert(true, "parametersDxy", anpset.retrieve("parametersDxy"));
0082 }
0083 if (anpset.exists("parametersTurnOnSumEt")) {
0084 _parametersTurnOnSumEt = anpset.getParameter<std::vector<double>>("parametersTurnOnSumEt");
0085 _pset.insert(true, "parametersTurnOnSumEt", anpset.retrieve("parametersTurnOnSumEt"));
0086 }
0087 if (anpset.exists("dropPt2")) {
0088 _drop_pt2 = anpset.getParameter<bool>("dropPt2");
0089 _pset.insert(true, "dropPt2", anpset.retrieve("dropPt2"));
0090 }
0091 if (anpset.exists("dropPt3")) {
0092 _drop_pt3 = anpset.getParameter<bool>("dropPt3");
0093 _pset.insert(true, "dropPt3", anpset.retrieve("dropPt3"));
0094 }
0095
0096
0097
0098 this->getNamesOfObjects(anpset);
0099
0100
0101
0102 this->registerConsumes(consCollector);
0103
0104
0105 for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0106 const std::string objStr = EVTColContainer::getTypeString(it->first);
0107 _genCut[it->first] = pset.getParameter<std::string>(objStr + "_genCut");
0108 _recCut[it->first] = pset.getParameter<std::string>(objStr + "_recCut");
0109 auto const genCutParam = objStr + "_genCut_leading";
0110 if (pset.exists(genCutParam)) {
0111 _genCut_leading[it->first] = pset.getParameter<std::string>(genCutParam);
0112 } else {
0113 _genCut_leading[it->first] = "pt>0";
0114 }
0115 auto const recCutParam = objStr + "_recCut_leading";
0116 if (pset.exists(recCutParam)) {
0117 _recCut_leading[it->first] = pset.getParameter<std::string>(recCutParam);
0118 } else {
0119 _recCut_leading[it->first] = "pt>0";
0120 }
0121 }
0122
0123
0124
0125 for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0126 const std::string objStr = EVTColContainer::getTypeString(it->first);
0127
0128 auto const genCutParam = objStr + "_genCut";
0129 if (anpset.existsAs<std::string>(genCutParam, false)) {
0130 _genCut[it->first] = anpset.getUntrackedParameter<std::string>(genCutParam);
0131 }
0132
0133 auto const recCutParam = objStr + "_recCut";
0134 if (anpset.existsAs<std::string>(recCutParam, false)) {
0135 _recCut[it->first] = anpset.getUntrackedParameter<std::string>(recCutParam);
0136 }
0137 }
0138
0139
0140 _hltPathsToCheck = anpset.getParameter<std::vector<std::string>>("hltPathsToCheck");
0141
0142 _minCandidates = anpset.getParameter<unsigned int>("minCandidates");
0143
0144 }
0145
0146 HLTExoticaSubAnalysis::~HLTExoticaSubAnalysis() {
0147 for (std::map<unsigned int, StringCutObjectSelector<reco::GenParticle> *>::iterator it = _genSelectorMap.begin();
0148 it != _genSelectorMap.end();
0149 ++it) {
0150 delete it->second;
0151 it->second = nullptr;
0152 }
0153 delete _recMuonSelector;
0154 _recMuonSelector = nullptr;
0155 delete _recMuonTrkSelector;
0156 _recMuonTrkSelector = nullptr;
0157 delete _recTrackSelector;
0158 _recTrackSelector = nullptr;
0159 delete _recElecSelector;
0160 _recElecSelector = nullptr;
0161 delete _recPhotonSelector;
0162 _recPhotonSelector = nullptr;
0163 delete _recMETSelector;
0164 _recMETSelector = nullptr;
0165 delete _recPFMETSelector;
0166 _recPFMETSelector = nullptr;
0167 delete _recPFMHTSelector;
0168 _recPFMHTSelector = nullptr;
0169 delete _genMETSelector;
0170 _genMETSelector = nullptr;
0171 delete _recCaloMETSelector;
0172 _recCaloMETSelector = nullptr;
0173 delete _recCaloMHTSelector;
0174 _recCaloMHTSelector = nullptr;
0175 delete _recPFTauSelector;
0176 _recPFTauSelector = nullptr;
0177 delete _recPFJetSelector;
0178 _recPFJetSelector = nullptr;
0179 delete _recCaloJetSelector;
0180 _recCaloJetSelector = nullptr;
0181 }
0182
0183 void HLTExoticaSubAnalysis::beginJob() {}
0184
0185
0186
0187
0188
0189
0190
0191 void HLTExoticaSubAnalysis::subAnalysisBookHistos(DQMStore::IBooker &iBooker,
0192 const edm::Run &iRun,
0193 const edm::EventSetup &iSetup) {
0194 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::subAnalysisBookHistos()";
0195
0196
0197 std::string baseDir = "HLT/Exotica/" + _analysisname + "/";
0198 iBooker.setCurrentFolder(baseDir);
0199
0200
0201 for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0202 const std::string objStr = EVTColContainer::getTypeString(it->first);
0203 std::vector<std::string> sources(2);
0204 sources[0] = "gen";
0205 sources[1] = "rec";
0206
0207 for (size_t i = 0; i < sources.size(); i++) {
0208 std::string source = sources[i];
0209
0210 if (source == "gen") {
0211 if (TString(objStr).Contains("MET") || TString(objStr).Contains("MHT") || TString(objStr).Contains("Jet")) {
0212 continue;
0213 } else {
0214 bookHist(iBooker, source, objStr, "MaxPt1");
0215 if (!_drop_pt2)
0216 bookHist(iBooker, source, objStr, "MaxPt2");
0217 if (!_drop_pt3)
0218 bookHist(iBooker, source, objStr, "MaxPt3");
0219 bookHist(iBooker, source, objStr, "Eta");
0220 bookHist(iBooker, source, objStr, "Phi");
0221
0222
0223
0224 if (it->first == EVTColContainer::ELEC || it->first == EVTColContainer::MUON ||
0225 it->first == EVTColContainer::MUTRK) {
0226 bookHist(iBooker, source, objStr, "Dxy");
0227 }
0228 }
0229 } else {
0230 if (TString(objStr).Contains("MET") || TString(objStr).Contains("MHT")) {
0231 bookHist(iBooker, source, objStr, "MaxPt1");
0232 bookHist(iBooker, source, objStr, "SumEt");
0233 } else {
0234 bookHist(iBooker, source, objStr, "MaxPt1");
0235 if (!_drop_pt2)
0236 bookHist(iBooker, source, objStr, "MaxPt2");
0237 if (!_drop_pt3)
0238 bookHist(iBooker, source, objStr, "MaxPt3");
0239 bookHist(iBooker, source, objStr, "Eta");
0240 bookHist(iBooker, source, objStr, "Phi");
0241
0242
0243
0244 if (it->first == EVTColContainer::ELEC || it->first == EVTColContainer::MUON ||
0245 it->first == EVTColContainer::MUTRK) {
0246 bookHist(iBooker, source, objStr, "Dxy");
0247 }
0248 }
0249 }
0250 }
0251 }
0252
0253
0254
0255 LogDebug("ExoticaValidation") << " number of plotters = " << _plotters.size();
0256 for (std::vector<HLTExoticaPlotter>::iterator it = _plotters.begin(); it != _plotters.end(); ++it) {
0257 it->plotterBookHistos(iBooker, iRun, iSetup);
0258 }
0259 }
0260
0261 void HLTExoticaSubAnalysis::beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
0262 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::beginRun()";
0263
0264
0265
0266
0267
0268 bool changedConfig(true);
0269 if (!_hltConfig.init(iRun, iSetup, _hltProcessName, changedConfig)) {
0270 edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): "
0271 << "Initialization of HLTConfigProvider failed!";
0272 }
0273
0274
0275
0276 _hltPaths.clear();
0277 for (size_t i = 0; i < _hltPathsToCheck.size(); ++i) {
0278 bool found = false;
0279 TPRegexp pattern(_hltPathsToCheck[i]);
0280
0281
0282 for (size_t j = 0; j < _hltConfig.triggerNames().size(); ++j) {
0283 std::string thetriggername = _hltConfig.triggerNames()[j];
0284 if (TString(thetriggername).Contains(pattern)) {
0285 _hltPaths.insert(thetriggername);
0286 found = true;
0287 }
0288 if (verbose > 2 && i == 0)
0289 LogDebug("ExoticaValidation") << "--- TRIGGER PATH : " << thetriggername;
0290 }
0291
0292
0293 if (!found && verbose > 2) {
0294 edm::LogWarning("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): In " << _analysisname
0295 << " subfolder NOT found the path: '" << _hltPathsToCheck[i] << "*'";
0296 }
0297 }
0298
0299
0300
0301 LogTrace("ExoticaValidation") << "SubAnalysis: " << _analysisname << "\nHLT Trigger Paths found >>>";
0302 for (std::set<std::string>::const_iterator iter = _hltPaths.begin(); iter != _hltPaths.end(); ++iter) {
0303 LogTrace("ExoticaValidation") << (*iter) << "\n";
0304 }
0305
0306
0307 _plotters.clear();
0308 for (std::set<std::string>::iterator iPath = _hltPaths.begin(); iPath != _hltPaths.end(); ++iPath) {
0309
0310 const std::string &path = *iPath;
0311 std::string shortpath = path;
0312 if (path.rfind("_v") < path.length()) {
0313 shortpath = path.substr(0, path.rfind("_v"));
0314 }
0315 _shortpath2long[shortpath] = path;
0316
0317
0318
0319
0320
0321
0322 std::vector<unsigned int> objsNeedHLT;
0323 for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0324 objsNeedHLT.push_back(it->first);
0325 }
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355 LogTrace("ExoticaValidation") << " --- " << shortpath;
0356
0357
0358
0359 HLTExoticaPlotter analyzer(_pset, shortpath, objsNeedHLT);
0360 _plotters.push_back(analyzer);
0361
0362 _triggerCounter.insert(std::map<std::string, int>::value_type(shortpath, 0));
0363 }
0364 }
0365
0366 void HLTExoticaSubAnalysis::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup, EVTColContainer *cols) {
0367 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::analyze()";
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381 this->getHandlesToObjects(iEvent, cols);
0382
0383
0384
0385
0386
0387
0388
0389
0390 std::vector<reco::LeafCandidate> matchesGen;
0391 matchesGen.clear();
0392 std::vector<reco::LeafCandidate> matchesReco;
0393 matchesReco.clear();
0394 std::map<int, double> theSumEt;
0395 std::map<int, std::vector<const reco::Track *>> trkObjs;
0396
0397
0398
0399
0400
0401
0402 for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0403
0404
0405
0406
0407
0408
0409
0410 if (!_genSelectorMap[it->first]) {
0411 _genSelectorMap[it->first] = new StringCutObjectSelector<reco::GenParticle>(_genCut[it->first]);
0412 }
0413
0414 const std::string objTypeStr = EVTColContainer::getTypeString(it->first);
0415
0416 if (TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ||
0417 TString(objTypeStr).Contains("Jet"))
0418 continue;
0419
0420
0421
0422
0423 for (size_t i = 0; i < cols->genParticles->size(); ++i) {
0424
0425
0426 if (_genSelectorMap[it->first]->operator()(cols->genParticles->at(i))) {
0427 const reco::Candidate *cand = &(cols->genParticles->at(i));
0428
0429
0430
0431
0432
0433 reco::LeafCandidate v(0, cand->p4(), cand->vertex(), it->first, 0, true);
0434
0435 matchesGen.push_back(v);
0436 }
0437 }
0438 }
0439
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451 if (verbose > 0)
0452 LogDebug("ExoticaValidation") << "-- enter loop over recLabels";
0453 for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0454
0455
0456
0457
0458
0459
0460 this->initSelector(it->first);
0461
0462 this->insertCandidates(it->first, cols, &matchesReco, theSumEt, trkObjs);
0463 if (verbose > 0)
0464 LogDebug("ExoticaValidation") << "--- " << EVTColContainer::getTypeString(it->first)
0465 << " sumEt=" << theSumEt[it->first];
0466 }
0467
0468
0469
0470
0471
0472
0473 const edm::TriggerNames &trigNames = iEvent.triggerNames(*(cols->triggerResults));
0474
0475
0476 for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
0477 const std::string hltPath = _shortpath2long[an->gethltpath()];
0478 const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
0479 if (ispassTrigger)
0480 _triggerCounter.find(an->gethltpath())->second++;
0481 }
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496
0497 if (matchesGen.size() >= _minCandidates) {
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510 std::map<unsigned int, int> countobjects;
0511 for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin(); co != _recLabels.end(); ++co) {
0512
0513 countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
0514 }
0515
0516 int counttotal = 0;
0517
0518
0519 int totalobjectssize = 1;
0520 if (!_drop_pt2)
0521 totalobjectssize++;
0522 if (!_drop_pt3)
0523 totalobjectssize++;
0524 totalobjectssize *= countobjects.size();
0525
0526 bool isPassedLeadingCut = true;
0527
0528 for (size_t j = 0; j != matchesGen.size(); ++j) {
0529 const unsigned int objType = matchesGen[j].pdgId();
0530
0531 StringCutObjectSelector<reco::LeafCandidate> select(_genCut_leading[objType]);
0532 if (!select(matchesGen[j])) {
0533 isPassedLeadingCut = false;
0534 matchesGen.clear();
0535 break;
0536 }
0537 }
0538
0539 std::vector<float> dxys;
0540 dxys.clear();
0541
0542 for (size_t j = 0; (j != matchesGen.size()) && isPassedLeadingCut; ++j) {
0543 const unsigned int objType = matchesGen[j].pdgId();
0544
0545 const std::string objTypeStr = EVTColContainer::getTypeString(objType);
0546
0547 float pt = matchesGen[j].pt();
0548
0549 if (countobjects[objType] == 0) {
0550 this->fillHist("gen", objTypeStr, "MaxPt1", pt);
0551 ++(countobjects[objType]);
0552 ++counttotal;
0553 } else if (countobjects[objType] == 1 && !_drop_pt2) {
0554 this->fillHist("gen", objTypeStr, "MaxPt2", pt);
0555 ++(countobjects[objType]);
0556 ++counttotal;
0557 } else if (countobjects[objType] == 2 && !_drop_pt3) {
0558 this->fillHist("gen", objTypeStr, "MaxPt3", pt);
0559 ++(countobjects[objType]);
0560 ++counttotal;
0561 } else {
0562
0563 if (counttotal == totalobjectssize) {
0564 size_t max_size = matchesGen.size();
0565 for (size_t jj = j; jj < max_size; jj++) {
0566 matchesGen.erase(matchesGen.end());
0567 }
0568 break;
0569 }
0570 }
0571
0572 float eta = matchesGen[j].eta();
0573 float phi = matchesGen[j].phi();
0574
0575 this->fillHist("gen", objTypeStr, "Eta", eta);
0576 this->fillHist("gen", objTypeStr, "Phi", phi);
0577
0578
0579
0580 if (objType == EVTColContainer::MUON || objType == EVTColContainer::MUTRK || objType == EVTColContainer::ELEC) {
0581 const math::XYZPoint &vtx = matchesGen[j].vertex();
0582 float momphi = matchesGen[j].momentum().phi();
0583 float dxyGen = (-(vtx.x() - cols->bs->x0()) * sin(momphi) + (vtx.y() - cols->bs->y0()) * cos(momphi));
0584 dxys.push_back(dxyGen);
0585 this->fillHist("gen", objTypeStr, "Dxy", dxyGen);
0586 }
0587
0588 }
0589
0590
0591
0592
0593 for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
0594 const std::string hltPath = _shortpath2long[an->gethltpath()];
0595 const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
0596 LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
0597 an->analyze(ispassTrigger, "gen", matchesGen, theSumEt, dxys);
0598 LogDebug("ExoticaValidation") << " called the plotter";
0599 }
0600 }
0601
0602
0603
0604
0605
0606 {
0607 if (matchesReco.size() < _minCandidates)
0608 return;
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623 std::map<unsigned int, int> countobjects;
0624 for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin(); co != _recLabels.end(); ++co) {
0625 countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
0626 }
0627
0628 int counttotal = 0;
0629
0630
0631 int totalobjectssize = 1;
0632 if (!_drop_pt2)
0633 totalobjectssize++;
0634 if (!_drop_pt3)
0635 totalobjectssize++;
0636 totalobjectssize *= countobjects.size();
0637
0638
0639
0640
0641
0642 std::vector<float> dxys;
0643 dxys.clear();
0644
0645 bool isPassedLeadingCut = true;
0646
0647 for (size_t j = 0; j != matchesReco.size(); ++j) {
0648 const unsigned int objType = matchesReco[j].pdgId();
0649
0650 StringCutObjectSelector<reco::LeafCandidate> select(_recCut_leading[objType]);
0651 if (!select(matchesReco[j])) {
0652 isPassedLeadingCut = false;
0653 matchesReco.clear();
0654 break;
0655 }
0656 }
0657
0658 int jel = 0;
0659 int jmu = 0;
0660 int jmutrk = 0;
0661
0662
0663
0664
0665
0666 for (size_t j = 0; (j != matchesReco.size()) && isPassedLeadingCut; ++j) {
0667 const unsigned int objType = matchesReco[j].pdgId();
0668
0669
0670 const std::string objTypeStr = EVTColContainer::getTypeString(objType);
0671
0672 float pt = matchesReco[j].pt();
0673
0674 if (countobjects[objType] == 0) {
0675 this->fillHist("rec", objTypeStr, "MaxPt1", pt);
0676 ++(countobjects[objType]);
0677 ++counttotal;
0678 } else if (countobjects[objType] == 1 && !_drop_pt2) {
0679 if (!(TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT"))) {
0680 this->fillHist("rec", objTypeStr, "MaxPt2", pt);
0681 }
0682 ++(countobjects[objType]);
0683 ++counttotal;
0684 } else if (countobjects[objType] == 2 && !_drop_pt3) {
0685 if (!(TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT"))) {
0686 this->fillHist("rec", objTypeStr, "MaxPt3", pt);
0687 }
0688 ++(countobjects[objType]);
0689 ++counttotal;
0690 } else {
0691
0692 if (counttotal == totalobjectssize) {
0693 size_t max_size = matchesReco.size();
0694 for (size_t jj = j; jj < max_size; jj++) {
0695 matchesReco.erase(matchesReco.end());
0696 }
0697 break;
0698 }
0699 }
0700
0701 float eta = matchesReco[j].eta();
0702 float phi = matchesReco[j].phi();
0703
0704 if (!(TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT"))) {
0705 this->fillHist("rec", objTypeStr, "Eta", eta);
0706 this->fillHist("rec", objTypeStr, "Phi", phi);
0707 } else {
0708 this->fillHist("rec", objTypeStr, "SumEt", theSumEt[objType]);
0709 }
0710
0711 if (objType == 11) {
0712 float dxyRec = trkObjs[objType].at(jel)->dxy(cols->bs->position());
0713 this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
0714 dxys.push_back(dxyRec);
0715 ++jel;
0716 }
0717
0718 if (objType == 13) {
0719 float dxyRec = trkObjs[objType].at(jmu)->dxy(cols->bs->position());
0720 this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
0721 dxys.push_back(dxyRec);
0722 ++jmu;
0723 }
0724
0725 if (objType == 130) {
0726 float dxyRec = trkObjs[objType].at(jmutrk)->dxy(cols->bs->position());
0727 this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
0728 dxys.push_back(dxyRec);
0729 ++jmutrk;
0730 }
0731
0732 }
0733
0734
0735
0736
0737
0738
0739
0740 for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
0741 const std::string hltPath = _shortpath2long[an->gethltpath()];
0742 const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
0743 LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
0744 an->analyze(ispassTrigger, "rec", matchesReco, theSumEt, dxys);
0745 LogDebug("ExoticaValidation") << " called the plotter";
0746 }
0747 }
0748
0749 }
0750
0751
0752 const std::vector<unsigned int> HLTExoticaSubAnalysis::getObjectsType(const std::string &hltPath) const {
0753 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getObjectsType()";
0754
0755 static const unsigned int objSize = 15;
0756 static const unsigned int objtriggernames[] = {EVTColContainer::MUON,
0757 EVTColContainer::MUTRK,
0758 EVTColContainer::TRACK,
0759 EVTColContainer::ELEC,
0760 EVTColContainer::PHOTON,
0761 EVTColContainer::MET,
0762 EVTColContainer::PFMET,
0763 EVTColContainer::PFMHT,
0764 EVTColContainer::GENMET,
0765 EVTColContainer::CALOMET,
0766 EVTColContainer::CALOMHT,
0767 EVTColContainer::PFTAU,
0768 EVTColContainer::PFJET,
0769 EVTColContainer::CALOJET};
0770
0771 std::set<unsigned int> objsType;
0772
0773 for (unsigned int i = 0; i < objSize; ++i) {
0774
0775 std::string objTypeStr = EVTColContainer::getTypeString(objtriggernames[i]);
0776
0777 if (!TString(hltPath).Contains(objTypeStr)) {
0778 continue;
0779 }
0780
0781 objsType.insert(objtriggernames[i]);
0782 }
0783
0784 return std::vector<unsigned int>(objsType.begin(), objsType.end());
0785 }
0786
0787
0788 void HLTExoticaSubAnalysis::getNamesOfObjects(const edm::ParameterSet &anpset) {
0789 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getNamesOfObjects()";
0790
0791 if (anpset.exists("recMuonLabel")) {
0792 _recLabels[EVTColContainer::MUON] = anpset.getParameter<edm::InputTag>("recMuonLabel");
0793 _genSelectorMap[EVTColContainer::MUON] = nullptr;
0794 }
0795 if (anpset.exists("recMuonTrkLabel")) {
0796 _recLabels[EVTColContainer::MUTRK] = anpset.getParameter<edm::InputTag>("recMuonTrkLabel");
0797 _genSelectorMap[EVTColContainer::MUTRK] = nullptr;
0798 }
0799 if (anpset.exists("recTrackLabel")) {
0800 _recLabels[EVTColContainer::TRACK] = anpset.getParameter<edm::InputTag>("recTrackLabel");
0801 _genSelectorMap[EVTColContainer::TRACK] = nullptr;
0802 }
0803 if (anpset.exists("recElecLabel")) {
0804 _recLabels[EVTColContainer::ELEC] = anpset.getParameter<edm::InputTag>("recElecLabel");
0805 _genSelectorMap[EVTColContainer::ELEC] = nullptr;
0806 }
0807 if (anpset.exists("recPhotonLabel")) {
0808 _recLabels[EVTColContainer::PHOTON] = anpset.getParameter<edm::InputTag>("recPhotonLabel");
0809 _genSelectorMap[EVTColContainer::PHOTON] = nullptr;
0810 }
0811 if (anpset.exists("recMETLabel")) {
0812 _recLabels[EVTColContainer::MET] = anpset.getParameter<edm::InputTag>("recMETLabel");
0813 _genSelectorMap[EVTColContainer::MET] = nullptr;
0814 }
0815 if (anpset.exists("recPFMETLabel")) {
0816 _recLabels[EVTColContainer::PFMET] = anpset.getParameter<edm::InputTag>("recPFMETLabel");
0817 _genSelectorMap[EVTColContainer::PFMET] = nullptr;
0818 }
0819 if (anpset.exists("recPFMHTLabel")) {
0820 _recLabels[EVTColContainer::PFMHT] = anpset.getParameter<edm::InputTag>("recPFMHTLabel");
0821 _genSelectorMap[EVTColContainer::PFMHT] = nullptr;
0822 }
0823 if (anpset.exists("genMETLabel")) {
0824 _recLabels[EVTColContainer::GENMET] = anpset.getParameter<edm::InputTag>("genMETLabel");
0825 _genSelectorMap[EVTColContainer::GENMET] = nullptr;
0826 }
0827 if (anpset.exists("recCaloMETLabel")) {
0828 _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<edm::InputTag>("recCaloMETLabel");
0829 _genSelectorMap[EVTColContainer::CALOMET] = nullptr;
0830 }
0831 if (anpset.exists("recCaloMHTLabel")) {
0832 _recLabels[EVTColContainer::CALOMHT] = anpset.getParameter<edm::InputTag>("recCaloMHTLabel");
0833 _genSelectorMap[EVTColContainer::CALOMHT] = nullptr;
0834 }
0835 if (anpset.exists("hltMETLabel")) {
0836 _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<edm::InputTag>("hltMETLabel");
0837 _genSelectorMap[EVTColContainer::CALOMET] = nullptr;
0838 }
0839 if (anpset.exists("recPFTauLabel")) {
0840 _recLabels[EVTColContainer::PFTAU] = anpset.getParameter<edm::InputTag>("recPFTauLabel");
0841 _genSelectorMap[EVTColContainer::PFTAU] = nullptr;
0842 }
0843 if (anpset.exists("recPFJetLabel")) {
0844 _recLabels[EVTColContainer::PFJET] = anpset.getParameter<edm::InputTag>("recPFJetLabel");
0845 _genSelectorMap[EVTColContainer::PFJET] = nullptr;
0846 }
0847 if (anpset.exists("recCaloJetLabel")) {
0848 _recLabels[EVTColContainer::CALOJET] = anpset.getParameter<edm::InputTag>("recCaloJetLabel");
0849 _genSelectorMap[EVTColContainer::CALOJET] = nullptr;
0850 }
0851
0852 if (_recLabels.empty()) {
0853 edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getNamesOfObjects, "
0854 << "Not included any object (recMuonLabel, recElecLabel, ...) "
0855 << "in the analysis " << _analysisname;
0856 return;
0857 }
0858 }
0859
0860
0861
0862 void HLTExoticaSubAnalysis::registerConsumes(edm::ConsumesCollector &iC) {
0863
0864 _genParticleToken = iC.consumes<reco::GenParticleCollection>(_genParticleLabel);
0865
0866
0867 _trigResultsToken = iC.consumes<edm::TriggerResults>(_trigResultsLabel);
0868
0869
0870 _bsToken = iC.consumes<reco::BeamSpot>(_beamSpotLabel);
0871
0872
0873
0874
0875
0876 LogDebug("ExoticaValidation") << "We have got " << _recLabels.size() << "recLabels";
0877 for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
0878 if (it->first == EVTColContainer::MUON) {
0879 edm::EDGetTokenT<reco::MuonCollection> particularToken = iC.consumes<reco::MuonCollection>(it->second);
0880 edm::EDGetToken token(particularToken);
0881 _tokens[it->first] = token;
0882 } else if (it->first == EVTColContainer::MUTRK) {
0883 edm::EDGetTokenT<reco::TrackCollection> particularToken = iC.consumes<reco::TrackCollection>(it->second);
0884 edm::EDGetToken token(particularToken);
0885 _tokens[it->first] = token;
0886 } else if (it->first == EVTColContainer::TRACK) {
0887 edm::EDGetTokenT<reco::TrackCollection> particularToken = iC.consumes<reco::TrackCollection>(it->second);
0888 edm::EDGetToken token(particularToken);
0889 _tokens[it->first] = token;
0890 } else if (it->first == EVTColContainer::ELEC) {
0891 edm::EDGetTokenT<reco::GsfElectronCollection> particularToken =
0892 iC.consumes<reco::GsfElectronCollection>(it->second);
0893 edm::EDGetToken token(particularToken);
0894 _tokens[it->first] = token;
0895 } else if (it->first == EVTColContainer::PHOTON) {
0896 edm::EDGetTokenT<reco::PhotonCollection> particularToken = iC.consumes<reco::PhotonCollection>(it->second);
0897 edm::EDGetToken token(particularToken);
0898 _tokens[it->first] = token;
0899 } else if (it->first == EVTColContainer::MET) {
0900 edm::EDGetTokenT<reco::METCollection> particularToken = iC.consumes<reco::METCollection>(it->second);
0901 edm::EDGetToken token(particularToken);
0902 _tokens[it->first] = token;
0903 } else if (it->first == EVTColContainer::PFMET) {
0904 edm::EDGetTokenT<reco::PFMETCollection> particularToken = iC.consumes<reco::PFMETCollection>(it->second);
0905 edm::EDGetToken token(particularToken);
0906 _tokens[it->first] = token;
0907 } else if (it->first == EVTColContainer::PFMHT) {
0908 edm::EDGetTokenT<reco::PFMETCollection> particularToken = iC.consumes<reco::PFMETCollection>(it->second);
0909 edm::EDGetToken token(particularToken);
0910 _tokens[it->first] = token;
0911 } else if (it->first == EVTColContainer::GENMET) {
0912 edm::EDGetTokenT<reco::GenMETCollection> particularToken = iC.consumes<reco::GenMETCollection>(it->second);
0913 edm::EDGetToken token(particularToken);
0914 _tokens[it->first] = token;
0915 } else if (it->first == EVTColContainer::CALOMET) {
0916 edm::EDGetTokenT<reco::CaloMETCollection> particularToken = iC.consumes<reco::CaloMETCollection>(it->second);
0917 edm::EDGetToken token(particularToken);
0918 _tokens[it->first] = token;
0919 } else if (it->first == EVTColContainer::CALOMHT) {
0920 edm::EDGetTokenT<reco::CaloMETCollection> particularToken = iC.consumes<reco::CaloMETCollection>(it->second);
0921 edm::EDGetToken token(particularToken);
0922 _tokens[it->first] = token;
0923 } else if (it->first == EVTColContainer::PFTAU) {
0924 edm::EDGetTokenT<reco::PFTauCollection> particularToken = iC.consumes<reco::PFTauCollection>(it->second);
0925 edm::EDGetToken token(particularToken);
0926 _tokens[it->first] = token;
0927 } else if (it->first == EVTColContainer::PFJET) {
0928 edm::EDGetTokenT<reco::PFJetCollection> particularToken = iC.consumes<reco::PFJetCollection>(it->second);
0929 edm::EDGetToken token(particularToken);
0930 _tokens[it->first] = token;
0931 } else if (it->first == EVTColContainer::CALOJET) {
0932 edm::EDGetTokenT<reco::CaloJetCollection> particularToken = iC.consumes<reco::CaloJetCollection>(it->second);
0933 edm::EDGetToken token(particularToken);
0934 _tokens[it->first] = token;
0935 } else {
0936 edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::registerConsumes"
0937 << " NOT IMPLEMENTED (yet) ERROR: '" << it->second.label() << "'";
0938 }
0939 }
0940 }
0941
0942
0943 void HLTExoticaSubAnalysis::getHandlesToObjects(const edm::Event &iEvent, EVTColContainer *col) {
0944 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getHandlesToObjects()";
0945
0946 if (!col->isCommonInit()) {
0947
0948 edm::Handle<edm::TriggerResults> trigResults;
0949 iEvent.getByToken(_trigResultsToken, trigResults);
0950 if (trigResults.isValid()) {
0951 col->triggerResults = trigResults.product();
0952 LogDebug("ExoticaValidation") << "Added handle to triggerResults";
0953 }
0954
0955
0956 edm::Handle<reco::GenParticleCollection> genPart;
0957 iEvent.getByToken(_genParticleToken, genPart);
0958 if (genPart.isValid()) {
0959 col->genParticles = genPart.product();
0960 LogDebug("ExoticaValidation") << "Added handle to genParticles";
0961 }
0962
0963
0964 edm::Handle<reco::BeamSpot> bsHandle;
0965 iEvent.getByToken(_bsToken, bsHandle);
0966 if (bsHandle.isValid()) {
0967 col->bs = bsHandle.product();
0968 }
0969 }
0970
0971
0972 LogDebug("ExoticaValidation") << "We have got " << _tokens.size() << "tokens";
0973 for (std::map<unsigned int, edm::EDGetToken>::iterator it = _tokens.begin(); it != _tokens.end(); ++it) {
0974 if (it->first == EVTColContainer::MUON) {
0975 edm::Handle<reco::MuonCollection> theHandle;
0976 iEvent.getByToken(it->second, theHandle);
0977 if (theHandle.isValid())
0978 col->set(theHandle.product());
0979 } else if (it->first == EVTColContainer::MUTRK) {
0980 edm::Handle<reco::TrackCollection> theHandle;
0981 iEvent.getByToken(it->second, theHandle);
0982 if (theHandle.isValid())
0983 col->set(theHandle.product());
0984 } else if (it->first == EVTColContainer::TRACK) {
0985 edm::Handle<reco::TrackCollection> theHandle;
0986 iEvent.getByToken(it->second, theHandle);
0987 if (theHandle.isValid())
0988 col->set(theHandle.product());
0989 } else if (it->first == EVTColContainer::ELEC) {
0990 edm::Handle<reco::GsfElectronCollection> theHandle;
0991 iEvent.getByToken(it->second, theHandle);
0992 if (theHandle.isValid())
0993 col->set(theHandle.product());
0994 } else if (it->first == EVTColContainer::PHOTON) {
0995 edm::Handle<reco::PhotonCollection> theHandle;
0996 iEvent.getByToken(it->second, theHandle);
0997 if (theHandle.isValid())
0998 col->set(theHandle.product());
0999 } else if (it->first == EVTColContainer::MET) {
1000 edm::Handle<reco::METCollection> theHandle;
1001 iEvent.getByToken(it->second, theHandle);
1002 if (theHandle.isValid())
1003 col->set(theHandle.product());
1004 } else if (it->first == EVTColContainer::PFMET) {
1005 edm::Handle<reco::PFMETCollection> theHandle;
1006 iEvent.getByToken(it->second, theHandle);
1007 if (theHandle.isValid())
1008 col->set(theHandle.product());
1009 } else if (it->first == EVTColContainer::PFMHT) {
1010 edm::Handle<reco::PFMETCollection> theHandle;
1011 iEvent.getByToken(it->second, theHandle);
1012 if (theHandle.isValid())
1013 col->setPFMHT(theHandle.product());
1014 } else if (it->first == EVTColContainer::GENMET) {
1015 edm::Handle<reco::GenMETCollection> theHandle;
1016 iEvent.getByToken(it->second, theHandle);
1017 if (theHandle.isValid())
1018 col->set(theHandle.product());
1019 } else if (it->first == EVTColContainer::CALOMET) {
1020 edm::Handle<reco::CaloMETCollection> theHandle;
1021 iEvent.getByToken(it->second, theHandle);
1022 if (theHandle.isValid())
1023 col->set(theHandle.product());
1024 } else if (it->first == EVTColContainer::CALOMHT) {
1025 edm::Handle<reco::CaloMETCollection> theHandle;
1026 iEvent.getByToken(it->second, theHandle);
1027 if (theHandle.isValid())
1028 col->setCaloMHT(theHandle.product());
1029 } else if (it->first == EVTColContainer::PFTAU) {
1030 edm::Handle<reco::PFTauCollection> theHandle;
1031 iEvent.getByToken(it->second, theHandle);
1032 if (theHandle.isValid())
1033 col->set(theHandle.product());
1034 } else if (it->first == EVTColContainer::PFJET) {
1035 edm::Handle<reco::PFJetCollection> theHandle;
1036 iEvent.getByToken(it->second, theHandle);
1037 if (theHandle.isValid())
1038 col->set(theHandle.product());
1039 } else if (it->first == EVTColContainer::CALOJET) {
1040 edm::Handle<reco::CaloJetCollection> theHandle;
1041 iEvent.getByToken(it->second, theHandle);
1042 if (theHandle.isValid())
1043 col->set(theHandle.product());
1044 } else {
1045 edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getHandlesToObjects "
1046 << " NOT IMPLEMENTED (yet) ERROR: '" << it->first << "'";
1047 }
1048 }
1049 }
1050
1051
1052 void HLTExoticaSubAnalysis::bookHist(DQMStore::IBooker &iBooker,
1053 const std::string &source,
1054 const std::string &objType,
1055 const std::string &variable) {
1056 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::bookHist()";
1057 std::string sourceUpper = source;
1058 sourceUpper[0] = std::toupper(sourceUpper[0]);
1059 std::string name = source + objType + variable;
1060 TH1F *h = nullptr;
1061
1062 if (variable.find("SumEt") != std::string::npos) {
1063 std::string title = "Sum ET of " + sourceUpper + " " + objType;
1064 const size_t nBins = _parametersTurnOnSumEt.size() - 1;
1065 float *edges = new float[nBins + 1];
1066 for (size_t i = 0; i < nBins + 1; i++) {
1067 edges[i] = _parametersTurnOnSumEt[i];
1068 }
1069 h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1070 delete[] edges;
1071 }
1072
1073 else if (variable.find("Dxy") != std::string::npos) {
1074 std::string title = "Dxy " + sourceUpper + " " + objType;
1075 int nBins = _parametersDxy[0];
1076 double min = _parametersDxy[1];
1077 double max = _parametersDxy[2];
1078 h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1079 }
1080
1081 else if (variable.find("MaxPt") != std::string::npos) {
1082 std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
1083 std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
1084 const size_t nBins = _parametersTurnOn.size() - 1;
1085 float *edges = new float[nBins + 1];
1086 for (size_t i = 0; i < nBins + 1; i++) {
1087 edges[i] = _parametersTurnOn[i];
1088 }
1089 h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1090 delete[] edges;
1091 }
1092
1093 else {
1094 std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
1095 std::string title = symbol + " of " + sourceUpper + " " + objType;
1096 std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
1097 int nBins = (int)params[0];
1098 double min = params[1];
1099 double max = params[2];
1100 h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1101 }
1102
1103 h->Sumw2();
1104
1105
1106
1107
1108 if (source == "gen") {
1109 if (objType != "refittedStandAloneMuons") {
1110 _elements[name] = iBooker.book1D(name, h);
1111 }
1112 } else {
1113 _elements[name] = iBooker.book1D(name, h);
1114 }
1115
1116 delete h;
1117 }
1118
1119
1120 void HLTExoticaSubAnalysis::fillHist(const std::string &source,
1121 const std::string &objType,
1122 const std::string &variable,
1123 const float &value) {
1124 std::string sourceUpper = source;
1125 sourceUpper[0] = toupper(sourceUpper[0]);
1126 std::string name = source + objType + variable;
1127
1128 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " " << value;
1129
1130 if (source == "gen") {
1131 if (objType != "refittedStandAloneMuons") {
1132 _elements[name]->Fill(value);
1133 }
1134 } else {
1135 _elements[name]->Fill(value);
1136 }
1137
1138 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " worked";
1139 }
1140
1141
1142 void HLTExoticaSubAnalysis::initSelector(const unsigned int &objtype) {
1143 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::initSelector()";
1144
1145 if (objtype == EVTColContainer::MUON && _recMuonSelector == nullptr) {
1146 _recMuonSelector = new StringCutObjectSelector<reco::Muon>(_recCut[objtype]);
1147 } else if (objtype == EVTColContainer::MUTRK && _recMuonTrkSelector == nullptr) {
1148 _recMuonTrkSelector = new StringCutObjectSelector<reco::Track>(_recCut[objtype]);
1149 } else if (objtype == EVTColContainer::TRACK && _recTrackSelector == nullptr) {
1150 _recTrackSelector = new StringCutObjectSelector<reco::Track>(_recCut[objtype]);
1151 } else if (objtype == EVTColContainer::ELEC && _recElecSelector == nullptr) {
1152 _recElecSelector = new StringCutObjectSelector<reco::GsfElectron>(_recCut[objtype]);
1153 } else if (objtype == EVTColContainer::PHOTON && _recPhotonSelector == nullptr) {
1154 _recPhotonSelector = new StringCutObjectSelector<reco::Photon>(_recCut[objtype]);
1155 } else if (objtype == EVTColContainer::MET && _recMETSelector == nullptr) {
1156 _recMETSelector = new StringCutObjectSelector<reco::MET>(_recCut[objtype]);
1157 } else if (objtype == EVTColContainer::PFMET && _recPFMETSelector == nullptr) {
1158 _recPFMETSelector = new StringCutObjectSelector<reco::PFMET>(_recCut[objtype]);
1159 } else if (objtype == EVTColContainer::PFMHT && _recPFMHTSelector == nullptr) {
1160 _recPFMHTSelector = new StringCutObjectSelector<reco::PFMET>(_recCut[objtype]);
1161 } else if (objtype == EVTColContainer::GENMET && _genMETSelector == nullptr) {
1162 _genMETSelector = new StringCutObjectSelector<reco::GenMET>(_recCut[objtype]);
1163 } else if (objtype == EVTColContainer::CALOMET && _recCaloMETSelector == nullptr) {
1164 _recCaloMETSelector = new StringCutObjectSelector<reco::CaloMET>(_recCut[objtype]);
1165 } else if (objtype == EVTColContainer::CALOMHT && _recCaloMHTSelector == nullptr) {
1166 _recCaloMHTSelector = new StringCutObjectSelector<reco::CaloMET>(_recCut[objtype]);
1167 } else if (objtype == EVTColContainer::PFTAU && _recPFTauSelector == nullptr) {
1168 _recPFTauSelector = new StringCutObjectSelector<reco::PFTau>(_recCut[objtype]);
1169 } else if (objtype == EVTColContainer::PFJET && _recPFJetSelector == nullptr) {
1170 _recPFJetSelector = new StringCutObjectSelector<reco::PFJet>(_recCut[objtype]);
1171 } else if (objtype == EVTColContainer::CALOJET && _recCaloJetSelector == nullptr) {
1172 _recCaloJetSelector = new StringCutObjectSelector<reco::CaloJet>(_recCut[objtype]);
1173 }
1174
1175
1176
1177
1178 }
1179
1180
1181 void HLTExoticaSubAnalysis::insertCandidates(const unsigned int &objType,
1182 const EVTColContainer *cols,
1183 std::vector<reco::LeafCandidate> *matches,
1184 std::map<int, double> &theSumEt,
1185 std::map<int, std::vector<const reco::Track *>> &trkObjs) {
1186 LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::insertCandidates()";
1187
1188 theSumEt[objType] = -1;
1189
1190 if (objType == EVTColContainer::MUON) {
1191 for (size_t i = 0; i < cols->muons->size(); i++) {
1192 LogDebug("ExoticaValidation") << "Inserting muon " << i;
1193 if (_recMuonSelector->operator()(cols->muons->at(i))) {
1194 reco::LeafCandidate m(0, cols->muons->at(i).p4(), cols->muons->at(i).vertex(), objType, 0, true);
1195 matches->push_back(m);
1196
1197
1198 trkObjs[objType].push_back(cols->muons->at(i).bestTrack());
1199 }
1200 }
1201 } else if (objType == EVTColContainer::MUTRK) {
1202 for (size_t i = 0; i < cols->tracks->size(); i++) {
1203 LogDebug("ExoticaValidation") << "Inserting muonTrack " << i;
1204 if (_recMuonTrkSelector->operator()(cols->tracks->at(i))) {
1205 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1206 ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1207 mom4.SetXYZT(mom3.x(), mom3.y(), mom3.z(), mom3.r());
1208 reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1209 matches->push_back(m);
1210
1211
1212 trkObjs[objType].push_back(&cols->tracks->at(i));
1213 }
1214 }
1215 } else if (objType == EVTColContainer::TRACK) {
1216 for (size_t i = 0; i < cols->tracks->size(); i++) {
1217 LogDebug("ExoticaValidation") << "Inserting Track " << i;
1218 if (_recTrackSelector->operator()(cols->tracks->at(i))) {
1219 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1220 ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1221 mom4.SetXYZT(mom3.x(), mom3.y(), mom3.z(), mom3.r());
1222 reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1223 matches->push_back(m);
1224 }
1225 }
1226 } else if (objType == EVTColContainer::ELEC) {
1227 for (size_t i = 0; i < cols->electrons->size(); i++) {
1228 LogDebug("ExoticaValidation") << "Inserting electron " << i;
1229 if (_recElecSelector->operator()(cols->electrons->at(i))) {
1230 reco::LeafCandidate m(0, cols->electrons->at(i).p4(), cols->electrons->at(i).vertex(), objType, 0, true);
1231 matches->push_back(m);
1232
1233
1234 trkObjs[objType].push_back(cols->electrons->at(i).bestTrack());
1235 }
1236 }
1237 } else if (objType == EVTColContainer::PHOTON) {
1238 for (size_t i = 0; i < cols->photons->size(); i++) {
1239 LogDebug("ExoticaValidation") << "Inserting photon " << i;
1240 if (_recPhotonSelector->operator()(cols->photons->at(i))) {
1241 reco::LeafCandidate m(0, cols->photons->at(i).p4(), cols->photons->at(i).vertex(), objType, 0, true);
1242 matches->push_back(m);
1243 }
1244 }
1245 } else if (objType == EVTColContainer::PFMET) {
1246
1247
1248
1249 for (size_t i = 0; i < cols->pfMETs->size(); i++) {
1250 LogDebug("ExoticaValidation") << "Inserting PFMET " << i;
1251 if (_recPFMETSelector->operator()(cols->pfMETs->at(i))) {
1252 reco::LeafCandidate m(0, cols->pfMETs->at(i).p4(), cols->pfMETs->at(i).vertex(), objType, 0, true);
1253 matches->push_back(m);
1254 if (i == 0)
1255 theSumEt[objType] = cols->pfMETs->at(i).sumEt();
1256 }
1257 }
1258 } else if (objType == EVTColContainer::PFMHT) {
1259 for (size_t i = 0; i < cols->pfMHTs->size(); i++) {
1260 LogDebug("ExoticaValidation") << "Inserting PFMHT " << i;
1261 if (_recPFMHTSelector->operator()(cols->pfMHTs->at(i))) {
1262 reco::LeafCandidate m(0, cols->pfMHTs->at(i).p4(), cols->pfMHTs->at(i).vertex(), objType, 0, true);
1263 matches->push_back(m);
1264 if (i == 0)
1265 theSumEt[objType] = cols->pfMHTs->at(i).sumEt();
1266 }
1267 }
1268 } else if (objType == EVTColContainer::GENMET) {
1269 for (size_t i = 0; i < cols->genMETs->size(); i++) {
1270 LogDebug("ExoticaValidation") << "Inserting GENMET " << i;
1271 if (_genMETSelector->operator()(cols->genMETs->at(i))) {
1272 reco::LeafCandidate m(0, cols->genMETs->at(i).p4(), cols->genMETs->at(i).vertex(), objType, 0, true);
1273 matches->push_back(m);
1274 if (i == 0)
1275 theSumEt[objType] = cols->genMETs->at(i).sumEt();
1276 }
1277 }
1278 } else if (objType == EVTColContainer::CALOMET) {
1279 for (size_t i = 0; i < cols->caloMETs->size(); i++) {
1280 LogDebug("ExoticaValidation") << "Inserting CALOMET " << i;
1281 if (_recCaloMETSelector->operator()(cols->caloMETs->at(i))) {
1282 reco::LeafCandidate m(0, cols->caloMETs->at(i).p4(), cols->caloMETs->at(i).vertex(), objType, 0, true);
1283 matches->push_back(m);
1284 if (i == 0)
1285 theSumEt[objType] = cols->caloMETs->at(i).sumEt();
1286 }
1287 }
1288 } else if (objType == EVTColContainer::CALOMHT) {
1289 for (size_t i = 0; i < cols->caloMHTs->size(); i++) {
1290 LogDebug("ExoticaValidation") << "Inserting CaloMHT " << i;
1291 if (_recCaloMHTSelector->operator()(cols->caloMHTs->at(i))) {
1292 reco::LeafCandidate m(0, cols->caloMHTs->at(i).p4(), cols->caloMHTs->at(i).vertex(), objType, 0, true);
1293 matches->push_back(m);
1294 if (i == 0)
1295 theSumEt[objType] = cols->caloMHTs->at(i).sumEt();
1296 }
1297 }
1298 } else if (objType == EVTColContainer::PFTAU) {
1299 for (size_t i = 0; i < cols->pfTaus->size(); i++) {
1300 LogDebug("ExoticaValidation") << "Inserting PFtau " << i;
1301 if (_recPFTauSelector->operator()(cols->pfTaus->at(i))) {
1302 reco::LeafCandidate m(0, cols->pfTaus->at(i).p4(), cols->pfTaus->at(i).vertex(), objType, 0, true);
1303 matches->push_back(m);
1304 }
1305 }
1306 } else if (objType == EVTColContainer::PFJET) {
1307 for (size_t i = 0; i < cols->pfJets->size(); i++) {
1308 LogDebug("ExoticaValidation") << "Inserting jet " << i;
1309 if (_recPFJetSelector->operator()(cols->pfJets->at(i))) {
1310 reco::LeafCandidate m(0, cols->pfJets->at(i).p4(), cols->pfJets->at(i).vertex(), objType, 0, true);
1311 matches->push_back(m);
1312 }
1313 }
1314 } else if (objType == EVTColContainer::CALOJET) {
1315 for (size_t i = 0; i < cols->caloJets->size(); i++) {
1316 LogDebug("ExoticaValidation") << "Inserting jet " << i;
1317 if (_recCaloJetSelector->operator()(cols->caloJets->at(i))) {
1318 reco::LeafCandidate m(0, cols->caloJets->at(i).p4(), cols->caloJets->at(i).vertex(), objType, 0, true);
1319 matches->push_back(m);
1320 }
1321 }
1322 }
1323
1324
1325
1326
1327
1328 }
1329
1330 void HLTExoticaSubAnalysis::endRun() {
1331
1332 std::stringstream log;
1333 log << std::endl;
1334 log << "====================================================================="
1335 "======"
1336 << std::endl;
1337 log << " Trigger Results ( " << _analysisname << " ) " << std::endl;
1338 log << "====================================================================="
1339 "======"
1340 << std::endl;
1341 log << std::setw(18) << "# of passed events : HLT path names" << std::endl;
1342 log << "-------------------:-------------------------------------------------"
1343 "------"
1344 << std::endl;
1345 for (std::map<std::string, int>::iterator it = _triggerCounter.begin(); it != _triggerCounter.end(); ++it) {
1346 log << std::setw(18) << it->second << " : " << it->first << std::endl;
1347 }
1348 log << "====================================================================="
1349 "======"
1350 << std::endl;
1351 LogDebug("ExoticaValidation") << log.str().data();
1352 }