CMS 3D CMS Logo

HLTHiggsSubAnalysis.cc
Go to the documentation of this file.
1 
6 
8 
9 #include "HLTHiggsSubAnalysis.h"
10 #include "EVTColContainer.h"
11 #include "MatchStruct.h"
12 
14 
15 #include "TPRegexp.h"
16 #include "TString.h"
17 
20 
21 #include "TPRegexp.h"
22 #include "TRegexp.h"
23 #include "TString.h"
24 
25 #include <set>
26 #include <algorithm>
27 
29  const std::string& analysisname,
31  : _pset(pset),
32  _analysisname(analysisname),
33  _minCandidates(0),
34  _HtJetPtMin(0),
35  _HtJetEtaMax(0),
36  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
37  _histDirectory(pset.getParameter<std::string>("histDirectory")),
38  _genParticleLabel(iC.consumes<reco::GenParticleCollection>(pset.getParameter<std::string>("genParticleLabel"))),
39  _genJetLabel(iC.consumes<reco::GenJetCollection>(pset.getParameter<std::string>("genJetLabel"))),
40  _recoHtJetLabel(iC.consumes<reco::PFJetCollection>(
41  pset.getUntrackedParameter<std::string>("recoHtJetLabel", "ak4PFJetsCHS"))),
42  _parametersEta(pset.getParameter<std::vector<double>>("parametersEta")),
43  _parametersPhi(pset.getParameter<std::vector<double>>("parametersPhi")),
44  _parametersPu(pset.getParameter<std::vector<double>>("parametersPu")),
45  _parametersHt(0),
46  _parametersTurnOn(pset.getParameter<std::vector<double>>("parametersTurnOn")),
47  _trigResultsTag(iC.consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", _hltProcessName))),
48  _genJetSelector(nullptr),
49  _recMuonSelector(nullptr),
50  _recElecSelector(nullptr),
51  _recCaloMETSelector(nullptr),
52  _recPFMETSelector(nullptr),
53  _recPFTauSelector(nullptr),
54  _recPhotonSelector(nullptr),
55  _recPFJetSelector(nullptr),
56  _recTrackSelector(nullptr),
57  _NminOneCuts(0),
58  _useNminOneCuts(false) {
59  // Specific parameters for this analysis
60  edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
61  // Collections labels (but genparticles already initialized)
62  // initializing _recLabels data member)
63  if (anpset.exists("parametersTurnOn")) {
64  _parametersTurnOn = anpset.getParameter<std::vector<double>>("parametersTurnOn");
65  _pset.addParameter("parametersTurnOn", _parametersTurnOn);
66  }
67  this->bookobjects(anpset, iC);
68  // Generic objects: Initialization of cuts
69  for (std::map<unsigned int, std::string>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
70  const std::string objStr = EVTColContainer::getTypeString(it->first);
71  _genCut[it->first] = pset.getParameter<std::string>(objStr + "_genCut");
72  _recCut[it->first] = pset.getParameter<std::string>(objStr + "_recCut");
73  _cutMinPt[it->first] = pset.getParameter<double>(objStr + "_cutMinPt");
74  _cutMaxEta[it->first] = pset.getParameter<double>(objStr + "_cutMaxEta");
75  }
76  //--- Updating parameters if has to be modified for this particular specific analysis
77  for (std::map<unsigned int, std::string>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
78  const std::string objStr = EVTColContainer::getTypeString(it->first);
79  if (anpset.existsAs<std::string>(objStr + "_genCut", false)) {
80  _genCut[it->first] = anpset.getUntrackedParameter<std::string>(objStr + "_genCut");
81  }
82  if (anpset.existsAs<std::string>(objStr + "_recCut", false)) {
83  _recCut[it->first] = anpset.getUntrackedParameter<std::string>(objStr + "_recCut");
84  }
85  if (anpset.existsAs<double>(objStr + "_cutMinPt", false)) {
86  _cutMinPt[it->first] = anpset.getUntrackedParameter<double>(objStr + "_cutMinPt");
87  }
88  if (anpset.existsAs<double>(objStr + "_cutMaxEta", false)) {
89  _cutMaxEta[it->first] = anpset.getUntrackedParameter<double>(objStr + "_cutMaxEta");
90  }
91  }
92  _hltPathsToCheck = anpset.getParameter<std::vector<std::string>>("hltPathsToCheck");
93  _minCandidates = anpset.getParameter<unsigned int>("minCandidates");
94 
95  std::vector<double> default_parametersHt;
96  default_parametersHt.push_back(100);
97  default_parametersHt.push_back(0);
98  default_parametersHt.push_back(1000);
99  _parametersHt = pset.getUntrackedParameter<std::vector<double>>("parametersHt", default_parametersHt);
100 
101  _HtJetPtMin = anpset.getUntrackedParameter<double>("HtJetPtMin", -1);
102  _HtJetEtaMax = anpset.getUntrackedParameter<double>("HtJetEtaMax", -1);
103 
104  if (_HtJetPtMin > 0 && _HtJetEtaMax > 0)
105  _bookHtPlots = true;
106  else
107  _bookHtPlots = false;
108 
109  if (pset.exists("pileUpInfoLabel")) {
110  _puSummaryInfo = iC.consumes<std::vector<PileupSummaryInfo>>(pset.getParameter<std::string>("pileUpInfoLabel"));
111  }
112 
113  if (anpset.existsAs<std::vector<double>>("NminOneCuts", false)) {
114  _NminOneCuts = anpset.getUntrackedParameter<std::vector<double>>("NminOneCuts");
115  if (_NminOneCuts.size() < 9 + _minCandidates) {
116  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
117  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
118  << _analysisname << "' has a vector NminOneCuts with size "
119  << _NminOneCuts.size() << ", while it needs to be at least of size "
120  << (9 + _minCandidates) << ".";
121  exit(-1);
122  }
123  if ((_NminOneCuts[0] || _NminOneCuts[1]) && _minCandidates < 4) {
124  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
125  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
126  << _analysisname
127  << "' has a vector NminOneCuts with a dEtaqq of mqq cut on the least b-tagged "
128  "jets of the first 4 jets while only requiring "
129  << _minCandidates << " jets.";
130  exit(-1);
131  }
132  if (_NminOneCuts[5] && _minCandidates < 3) {
133  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
134  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
135  << _analysisname
136  << "' has a vector NminOneCuts with a CSV3 cut while only requiring "
137  << _minCandidates << " jets.";
138  exit(-1);
139  }
140  if ((_NminOneCuts[2] || _NminOneCuts[4]) && _minCandidates < 2) {
141  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::HLTHiggsSubAnalysis, "
142  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
143  << _analysisname
144  << "' has a vector NminOneCuts with a dPhibb or CSV2 cut using the second most "
145  "b-tagged jet while only requiring "
146  << _minCandidates << " jet.";
147  exit(-1);
148  }
149  for (std::vector<double>::const_iterator it = _NminOneCuts.begin(); it != _NminOneCuts.end(); ++it) {
150  if (*it) {
151  _useNminOneCuts = true;
152  break;
153  }
154  }
155  }
156  // NptPlots = ( _useNminOneCuts ? _minCandidates : 2 );
158 }
159 
161  for (std::map<unsigned int, StringCutObjectSelector<reco::GenParticle>*>::iterator it = _genSelectorMap.begin();
162  it != _genSelectorMap.end();
163  ++it) {
164  delete it->second;
165  it->second = nullptr;
166  }
167  delete _genJetSelector;
168  _genJetSelector = nullptr;
169  delete _recMuonSelector;
170  _recMuonSelector = nullptr;
171  delete _recElecSelector;
172  _recElecSelector = nullptr;
173  delete _recPhotonSelector;
174  _recPhotonSelector = nullptr;
175  delete _recCaloMETSelector;
176  _recCaloMETSelector = nullptr;
177  delete _recPFMETSelector;
178  _recPFMETSelector = nullptr;
179  delete _recPFTauSelector;
180  _recPFTauSelector = nullptr;
181  delete _recPFJetSelector;
182  _recPFJetSelector = nullptr;
183  delete _recTrackSelector;
184  _recTrackSelector = nullptr;
185 }
186 
188 
189 void HLTHiggsSubAnalysis::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
190  // Initialize the confighlt
191  bool changedConfig;
192  if (!_hltConfig.init(iRun, iSetup, _hltProcessName, changedConfig)) {
193  edm::LogError("HiggsValidations") << "HLTHiggsSubAnalysis::beginRun: "
194  << "Initializtion of HLTConfigProvider failed!!";
195  }
196 
197  // Parse the input paths to get them if there are in the table
198  // and associate them the last filter of the path (in order to extract the
199  _hltPaths.clear();
200  for (size_t i = 0; i < _hltPathsToCheck.size(); ++i) {
201  bool found = false;
202  TPRegexp pattern(_hltPathsToCheck[i]);
203  for (size_t j = 0; j < _hltConfig.triggerNames().size(); ++j) {
204  std::string thetriggername = _hltConfig.triggerNames()[j];
205  if (TString(thetriggername).Contains(pattern)) {
206  _hltPaths.insert(thetriggername);
207  found = true;
208  }
209  }
210  if (!found) {
211  LogDebug("HiggsValidations") << "HLTHiggsSubAnalysis::beginRun, In " << _analysisname
212  << " subfolder NOT found the path: '" << _hltPathsToCheck[i] << "*'";
213  }
214  }
215 
216  LogTrace("HiggsValidation") << "SubAnalysis: " << _analysisname << "\nHLT Trigger Paths found >>>";
217  // Initialize the plotters (analysers for each trigger path)
218  _analyzers.clear();
219  for (std::set<std::string>::iterator iPath = _hltPaths.begin(); iPath != _hltPaths.end(); ++iPath) {
220  // Avoiding the dependence of the version number for
221  // the trigger paths
222  const std::string& path = *iPath;
223  std::string shortpath = path;
224  if (path.rfind("_v") < path.length()) {
225  shortpath = path.substr(0, path.rfind("_v"));
226  }
227  _shortpath2long[shortpath] = path;
228 
229  // Objects needed by the HLT path
230  const std::vector<unsigned int> objsNeedHLT = this->getObjectsType(shortpath);
231  // Sanity check: the object needed by a trigger path should be
232  // introduced by the user via config python (_recLabels datamember)
233  std::vector<unsigned int> userInstantiate;
234  for (std::map<unsigned int, std::string>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
235  userInstantiate.push_back(it->first);
236  }
237  for (std::vector<unsigned int>::const_iterator it = objsNeedHLT.begin(); it != objsNeedHLT.end(); ++it) {
238  if (std::find(userInstantiate.begin(), userInstantiate.end(), *it) == userInstantiate.end()) {
239  edm::LogError("HiggsValidation") << "In HLTHiggsSubAnalysis::beginRun, "
240  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
241  << _analysisname << "' has been asked to evaluate the trigger path '"
242  << shortpath << "' (found it in 'hltPathsToCheck') BUT this path"
243  << " needs a '" << EVTColContainer::getTypeString(*it)
244  << "' which has not been instantiate ('recVariableLabels'"
245  << ")";
246  exit(-1);
247  }
248  }
249  LogTrace("HiggsValidation") << " --- " << shortpath;
250 
251  // the hlt path, the objects (elec,muons,photons,...)
252  // needed to evaluate the path are the argumens of the plotter
253  HLTHiggsPlotter analyzer(_pset, shortpath, objsNeedHLT, NptPlots, _NminOneCuts);
254  _analyzers.push_back(analyzer);
255  }
256 }
257 
260  ibooker.setCurrentFolder(baseDir);
261  // Book the gen/reco analysis-dependent histograms (denominators)
262  std::vector<std::string> sources(2);
263  sources[0] = "gen";
264  sources[1] = "rec";
265 
266  for (std::map<unsigned int, std::string>::const_iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
267  const std::string objStr = EVTColContainer::getTypeString(it->first);
268  TString maxPt;
269 
270  for (size_t i = 0; i < sources.size(); i++) {
272  if (_useNminOneCuts && it->first == EVTColContainer::PFJET) {
273  if (source == "gen")
274  continue;
275  else {
276  // N-1 jet plots (dEtaqq, mqq, dPhibb, CSV1, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4)
277  if (_NminOneCuts[0])
278  bookHist(source, objStr, "dEtaqq", ibooker);
279  if (_NminOneCuts[1])
280  bookHist(source, objStr, "mqq", ibooker);
281  if (_NminOneCuts[2])
282  bookHist(source, objStr, "dPhibb", ibooker);
283  if (_NminOneCuts[3]) {
284  if (_NminOneCuts[6])
285  bookHist(source, objStr, "maxCSV", ibooker);
286  else
287  bookHist(source, objStr, "CSV1", ibooker);
288  }
289  if (_NminOneCuts[4])
290  bookHist(source, objStr, "CSV2", ibooker);
291  if (_NminOneCuts[5])
292  bookHist(source, objStr, "CSV3", ibooker);
293  }
294  }
295 
296  bookHist(source, objStr, "Eta", ibooker);
297  bookHist(source, objStr, "Phi", ibooker);
298  for (unsigned int i = 0; i < NptPlots; i++) {
299  maxPt = "MaxPt";
300  maxPt += i + 1;
301  bookHist(source, objStr, maxPt.Data(), ibooker);
302  }
303  }
304  }
305 
306  // Call the bookHistograms (which books all the path dependent histograms)
307  for (std::vector<HLTHiggsPlotter>::iterator it = _analyzers.begin(); it != _analyzers.end(); ++it) {
308  it->bookHistograms(ibooker, _useNminOneCuts);
309  }
310  //booking the histograms for overall trigger efficiencies
311  for (size_t i = 0; i < sources.size(); i++) {
312  std::string nameGlobalEfficiency = "SummaryPaths_" + _analysisname + "_" + sources[i];
313 
314  _elements[nameGlobalEfficiency] = ibooker.book1D(
315  nameGlobalEfficiency.c_str(), nameGlobalEfficiency.c_str(), _hltPathsToCheck.size(), 0, _hltPathsToCheck.size());
316 
317  std::string nameGlobalEfficiencyPassing = nameGlobalEfficiency + "_passingHLT";
318  _elements[nameGlobalEfficiencyPassing] = ibooker.book1D(nameGlobalEfficiencyPassing.c_str(),
319  nameGlobalEfficiencyPassing.c_str(),
320  _hltPathsToCheck.size(),
321  0,
322  _hltPathsToCheck.size());
323 
324  std::string titlePu = "nb of interations in the event";
325  std::string nameVtxPlot = "trueVtxDist_" + _analysisname + "_" + sources[i];
326  std::vector<double> paramsPu = _parametersPu;
327  int nBinsPu = (int)paramsPu[0];
328  double minPu = paramsPu[1];
329  double maxPu = paramsPu[2];
330 
331  std::string titleHt = "sum of jet pT in the event";
332  std::string nameHtPlot = "HtDist_" + _analysisname + "_" + sources[i];
333  std::vector<double> paramsHt = _parametersHt;
334  int nBinsHt = (int)paramsHt[0];
335  double minHt = paramsHt[1];
336  double maxHt = paramsHt[2];
337 
338  if ((!_useNminOneCuts) || sources[i] == "rec")
339  _elements[nameVtxPlot] = ibooker.book1D(nameVtxPlot.c_str(), titlePu.c_str(), nBinsPu, minPu, maxPu);
340  if (_bookHtPlots)
341  _elements[nameHtPlot] = ibooker.book1D(nameHtPlot.c_str(), titleHt.c_str(), nBinsHt, minHt, maxHt);
342  for (size_t j = 0; j < _hltPathsToCheck.size(); j++) {
343  //declare the efficiency vs interaction plots
345  std::string shortpath = path;
346  if (path.rfind("_v") < path.length()) {
347  shortpath = path.substr(0, path.rfind("_v"));
348  }
349  std::string titlePassingPu = "nb of interations in the event passing path " + shortpath;
350  if ((!_useNminOneCuts) || sources[i] == "rec")
351  _elements[nameVtxPlot + "_" + shortpath] =
352  ibooker.book1D(nameVtxPlot + "_" + shortpath, titlePassingPu.c_str(), nBinsPu, minPu, maxPu);
353 
354  std::string titlePassingHt = "sum of jet pT in the event passing path " + shortpath;
355  if (_bookHtPlots)
356  _elements[nameHtPlot + "_" + shortpath] =
357  ibooker.book1D(nameHtPlot + "_" + shortpath, titlePassingHt.c_str(), nBinsHt, minHt, maxHt);
358 
359  //fill the bin labels of the summary plot
360  _elements[nameGlobalEfficiency]->setBinLabel(j + 1, shortpath);
361  _elements[nameGlobalEfficiencyPassing]->setBinLabel(j + 1, shortpath);
362  }
363  }
364 }
365 
367  // Initialize the collection (the ones which hasn't been initialiazed yet)
368  this->initobjects(iEvent, cols);
369  // utility map
370  std::map<unsigned int, std::string> u2str;
371  u2str[GEN] = "gen";
372  u2str[RECO] = "rec";
373 
374  std::map<unsigned int, double> Htmap;
375  Htmap[GEN] = 0.;
376  Htmap[RECO] = 0.;
377 
379  iEvent.getByToken(_puSummaryInfo, puInfo);
380  int nbMCvtx = -1;
381  if (puInfo.isValid()) {
382  std::vector<PileupSummaryInfo>::const_iterator PVI;
383  for (PVI = puInfo->begin(); PVI != puInfo->end(); ++PVI) {
384  if (PVI->getBunchCrossing() == 0) {
385  nbMCvtx = PVI->getPU_NumInteractions();
386  break;
387  }
388  }
389  }
390 
391  // Extract the match structure containing the gen/reco candidates (electron, muons,...)
392  // common to all the SubAnalysis
393  //---- Generation
394  // Make each good gen object into the base cand for a MatchStruct
395  std::vector<MatchStruct>* matches = new std::vector<MatchStruct>;
396  // bool alreadyMu = false;
397  for (std::map<unsigned int, std::string>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
398  // Use genJets for jet matchstructs
399  if (it->first == EVTColContainer::PFJET) {
400  // Skip genJets for N-1 plots
401  if (!_useNminOneCuts) {
402  // Initialize selectors when first event
403  if (!_genJetSelector) {
405  }
406  for (size_t i = 0; i < cols->genJets->size(); ++i) {
407  if (_genJetSelector->operator()(cols->genJets->at(i))) {
408  matches->push_back(MatchStruct(&cols->genJets->at(i), it->first));
409  }
410  }
411  }
412  }
413  // Use genParticles
414  else {
415  // Avoiding the TkMu and Mu case
416  /* if( alreadyMu )
417  {
418  continue;
419  }*/
420  // Initialize selectors when first event
421  if (!_genSelectorMap[it->first]) {
423  }
424 
425  for (size_t i = 0; i < cols->genParticles->size(); ++i) {
426  if (_genSelectorMap[it->first]->operator()(cols->genParticles->at(i))) {
427  matches->push_back(MatchStruct(&cols->genParticles->at(i), it->first));
428  }
429  }
430  /* if( it->first == EVTColContainer::MUON || it->first == EVTColContainer::TRACK )
431  {
432  alreadyMu = true;
433  }*/
434  }
435  }
436  // Sort the MatchStructs by pT for later filling of turn-on curve
437  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
438 
439  // Map to reference the source (gen/reco) with the recoCandidates
440  std::map<unsigned int, std::vector<MatchStruct>> sourceMatchMap; // To be a pointer to delete
441  // --- Storing the generating candidates
442  sourceMatchMap[GEN] = *matches;
443 
444  // Reuse the vector
445  matches->clear();
446  // --- same for RECO objects
447 
448  // Different treatment for jets (b-tag)
449  std::map<std::string, bool> nMinOne;
450  std::map<std::string, bool> jetCutResult;
451  float dEtaqq;
452  float mqq;
453  float dPhibb;
454  float CSV1;
455  float CSV2;
456  float CSV3;
457  bool passAllCuts = false;
458  if (_recLabels.find(EVTColContainer::PFJET) != _recLabels.end()) {
459  // Initialize jet selector
461  // Initialize and insert pfJets
462  this->initAndInsertJets(iEvent, cols, matches);
463  // Make sure to skip events that don't have enough jets
464  if (matches->size() < NptPlots) {
465  delete matches;
466  return;
467  }
468  // Cuts on multiple jet events (RECO)
469  if (_useNminOneCuts) {
470  this->passJetCuts(matches, jetCutResult, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3);
471  }
472  }
473  // Extraction of the objects candidates
474  for (std::map<unsigned int, std::string>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
475  // Reco selectors (the function takes into account if it was instantiated
476  // before or not
477  this->InitSelector(it->first);
478  // -- Storing the matches
479  this->insertcandidates(it->first, cols, matches);
480  }
481 
482  // Sort the MatchStructs by pT for later filling of turn-on curve
483  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
484 
485  if (_useNminOneCuts) {
486  // Check non-jet N-1 Cuts
487  this->passOtherCuts(*matches, jetCutResult);
488 
489  // Make N-1 booleans from jetCutResults
490  for (std::map<std::string, bool>::const_iterator it = jetCutResult.begin(); it != jetCutResult.end(); ++it) {
491  nMinOne[it->first] = true;
492  for (std::map<std::string, bool>::const_iterator it2 = jetCutResult.begin(); it2 != jetCutResult.end(); ++it2) {
493  //ignore CSV2,CSV3 cut plotting CSV1
494  if (it->first == "CSV1" && it2->first == "CSV3")
495  continue;
496  if (it->first == "CSV1" && it2->first == "CSV2")
497  continue;
498 
499  //ignore CSV3 plotting cut CSV2
500  if (it->first == "CSV2" && it2->first == "CSV3")
501  continue;
502 
503  if (it->first != it2->first && !(it2->second)) {
504  nMinOne[it->first] = false;
505  break;
506  }
507  }
508  }
509  bool temp = false;
510  for (std::map<std::string, bool>::const_iterator it = nMinOne.begin(); it != nMinOne.end(); ++it) {
511  if (temp && it->second) {
512  passAllCuts = true;
513  break;
514  }
515  if (it->second)
516  temp = true;
517  }
518  }
519 
520  // --- Storing the reco candidates
521  sourceMatchMap[RECO] = *matches;
522  // --- All the objects are in place
523  delete matches;
524 
525  // -- Trigger Results
526  const edm::TriggerNames& trigNames = iEvent.triggerNames(*(cols->triggerResults));
527 
528  if (_bookHtPlots) {
530  iEvent.getByToken(_recoHtJetLabel, recoJet);
531  if (recoJet.isValid()) {
532  for (reco::PFJetCollection::const_iterator iJet = recoJet->begin(); iJet != recoJet->end(); iJet++) {
533  double pt = iJet->pt();
534  double eta = iJet->eta();
535  if (pt > _HtJetPtMin && fabs(eta) < _HtJetEtaMax) {
536  Htmap[RECO] += pt;
537  }
538  }
539  }
540 
542  iEvent.getByToken(_genJetLabel, genJet);
543  if (genJet.isValid()) {
544  for (reco::GenJetCollection::const_iterator iJet = genJet->begin(); iJet != genJet->end(); iJet++) {
545  double pt = iJet->pt();
546  double eta = iJet->eta();
547  if (pt > _HtJetPtMin && fabs(eta) < _HtJetEtaMax) {
548  Htmap[GEN] += pt;
549  }
550  }
551  }
552  }
553 
554  // Filling the histograms if pass the minimum amount of candidates needed by the analysis:
555  // GEN + RECO CASE in the same loop
556  for (std::map<unsigned int, std::vector<MatchStruct>>::iterator it = sourceMatchMap.begin();
557  it != sourceMatchMap.end();
558  ++it) {
559  // it->first: gen/reco it->second: matches (std::vector<MatchStruc>)
560  if (it->second.size() < _minCandidates) // FIXME: A bug is potentially here: what about the mixed channels?
561  {
562  continue;
563  }
564 
565  // Filling the gen/reco objects (eff-denominators):
566  // Just the first two different ones, if there are more
567  std::map<unsigned int, int>* countobjects = new std::map<unsigned int, int>;
568  // Initializing the count of the used object
569  for (std::map<unsigned int, std::string>::iterator co = _recLabels.begin(); co != _recLabels.end(); ++co) {
570  if (!(_useNminOneCuts && co->first == EVTColContainer::PFJET && it->first == GEN)) // genJets are not there
571  countobjects->insert(std::pair<unsigned int, int>(co->first, 0));
572  }
573  int counttotal = 0;
574  const int totalobjectssize2 = NptPlots * countobjects->size();
575  for (size_t j = 0; j < it->second.size(); ++j) {
576  const unsigned int objType = it->second[j].objType;
578 
579  float pt = (it->second)[j].pt;
580  float eta = (it->second)[j].eta;
581  float phi = (it->second)[j].phi;
582 
583  // PFMET N-1 cut
584  if (_useNminOneCuts && objType == EVTColContainer::PFMET && _NminOneCuts[8] && !nMinOne["PFMET"]) {
585  continue;
586  }
587 
588  TString maxPt;
589  if ((unsigned)(*countobjects)[objType] < NptPlots) {
590  maxPt = "MaxPt";
591  maxPt += (*countobjects)[objType] + 1;
593  if (nMinOne[maxPt.Data()]) {
594  this->fillHist(u2str[it->first], objTypeStr, maxPt.Data(), pt);
595  }
596  } else {
597  this->fillHist(u2str[it->first], objTypeStr, maxPt.Data(), pt);
598  }
599  // Filled the high pt ...
600  ++((*countobjects)[objType]);
601  ++counttotal;
602  } else {
603  if ((unsigned)(*countobjects)[objType] < _minCandidates) { // To get correct results for HZZ
604  ++((*countobjects)[objType]);
605  ++counttotal;
606  } else
607  continue; // Otherwise too many entries in Eta and Phi distributions
608  }
609 
610  // Jet N-1 Cuts
612  if (passAllCuts) {
613  this->fillHist(u2str[it->first], objTypeStr, "Eta", eta);
614  this->fillHist(u2str[it->first], objTypeStr, "Phi", phi);
615  }
616  } else {
617  this->fillHist(u2str[it->first], objTypeStr, "Eta", eta);
618  this->fillHist(u2str[it->first], objTypeStr, "Phi", phi);
619  }
620 
621  // Already the minimum two objects has been filled, get out...
622  if (counttotal == totalobjectssize2) {
623  break;
624  }
625  }
626  delete countobjects;
627 
628  if (_useNminOneCuts && it->first == RECO) {
629  if (_NminOneCuts[0] && nMinOne["dEtaqq"]) {
630  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), "dEtaqq", dEtaqq);
631  }
632  if (_NminOneCuts[1] && nMinOne["mqq"]) {
633  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), "mqq", mqq);
634  }
635  if (_NminOneCuts[2] && nMinOne["dPhibb"]) {
636  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), "dPhibb", dPhibb);
637  }
638  if (_NminOneCuts[3]) {
639  std::string nameCSVplot = "CSV1";
640  if (_NminOneCuts[6])
641  nameCSVplot = "maxCSV";
642  if (nMinOne[nameCSVplot])
643  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), nameCSVplot, CSV1);
644  }
645  if (_NminOneCuts[4] && nMinOne["CSV2"]) {
646  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV2", CSV2);
647  }
648  if (_NminOneCuts[5] && nMinOne["CSV3"]) {
649  this->fillHist(u2str[it->first], EVTColContainer::getTypeString(EVTColContainer::PFJET), "CSV3", CSV3);
650  }
651  }
652 
653  //fill the efficiency vs nb of interactions
654  std::string nameVtxPlot = "trueVtxDist_" + _analysisname + "_" + u2str[it->first];
655  if ((!_useNminOneCuts) || it->first == RECO)
656  _elements[nameVtxPlot]->Fill(nbMCvtx);
657 
658  //fill the efficiency vs sum pT of jets
659  std::string nameHtPlot = "HtDist_" + _analysisname + "_" + u2str[it->first];
660  if (_bookHtPlots)
661  _elements[nameHtPlot]->Fill(Htmap[it->first]);
662 
663  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
664  std::string SummaryName = "SummaryPaths_" + _analysisname + "_" + u2str[it->first];
665  const std::string source = u2str[it->first];
666  for (std::vector<HLTHiggsPlotter>::iterator an = _analyzers.begin(); an != _analyzers.end(); ++an) {
667  const std::string hltPath = _shortpath2long[an->gethltpath()];
668  const std::string fillShortPath = an->gethltpath();
669  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
670 
671  if (_useNminOneCuts) {
672  an->analyze(ispassTrigger, source, it->second, nMinOne, dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3, passAllCuts);
673  } else {
674  an->analyze(ispassTrigger, source, it->second, _minCandidates);
675  }
676 
677  int refOfThePath = -1;
678  for (size_t itePath = 0; itePath < _hltPathsToCheck.size(); itePath++) {
679  refOfThePath++;
680  if (TString(hltPath).Contains(_hltPathsToCheck[itePath]))
681  break;
682  }
683  _elements[SummaryName]->Fill(refOfThePath);
684  if (ispassTrigger) {
685  _elements[SummaryName + "_passingHLT"]->Fill(refOfThePath, 1);
686  if ((!_useNminOneCuts) || it->first == RECO)
687  _elements[nameVtxPlot + "_" + fillShortPath]->Fill(nbMCvtx);
688  if (_bookHtPlots)
689  _elements[nameHtPlot + "_" + fillShortPath]->Fill(Htmap[it->first]);
690  } else {
691  _elements[SummaryName + "_passingHLT"]->Fill(refOfThePath, 0);
692  }
693  }
694  }
695 }
696 
697 // Return the objects (muons,electrons,photons,...) needed by a hlt path.
698 const std::vector<unsigned int> HLTHiggsSubAnalysis::getObjectsType(const std::string& hltPath) const {
699  static const unsigned int objSize = 7;
700  static const unsigned int objtriggernames[] = {EVTColContainer::MUON,
703  // EVTColContainer::TRACK, // Note is tracker muon
708 
709  std::set<unsigned int> objsType;
710  // The object to deal has to be entered via the config .py
711  for (unsigned int i = 0; i < objSize; ++i) {
712  std::string objTypeStr = EVTColContainer::getTypeString(objtriggernames[i]);
713  // Check if it is needed this object for this trigger
714  if (!TString(hltPath).Contains(objTypeStr)) {
715  if ((objtriggernames[i] == EVTColContainer::PFJET &&
716  TString(hltPath).Contains("WHbbBoost")) || // fix for HLT_Ele27_WPLoose_Gsf_WHbbBoost_v
717  (objtriggernames[i] == EVTColContainer::PFJET && TString(hltPath).Contains("CSV")) || // fix for ZnnHbb PFJET
718  (objtriggernames[i] == EVTColContainer::PFMET && TString(hltPath).Contains("MHT")) || // fix for ZnnHbb PFMET
719  (objtriggernames[i] == EVTColContainer::PHOTON && TString(hltPath).Contains("Diphoton"))) {
720  objsType.insert(objtriggernames[i]); //case of the New Diphoton paths
721  }
722  continue;
723  }
724  if ((objtriggernames[i] == EVTColContainer::CALOMET &&
725  (TString(hltPath).Contains("PFMET") || TString(hltPath).Contains("MHT"))) || // fix for PFMET
726  (objtriggernames[i] == EVTColContainer::PFJET && TString(hltPath).Contains("JetIdCleaned") &&
727  !TString(hltPath).Contains(TRegexp("Jet[^I]"))) || // fix for Htaunu
728  (objtriggernames[i] == EVTColContainer::MUON && TString(hltPath).Contains("METNoMu"))) // fix for VBFHToInv
729  {
730  continue;
731  }
732 
733  objsType.insert(objtriggernames[i]);
734  }
735 
736  return std::vector<unsigned int>(objsType.begin(), objsType.end());
737 }
738 
739 // Booking the maps: recLabels and genParticle selectors
741  if (anpset.exists("recMuonLabel")) {
742  _recLabels[EVTColContainer::MUON] = anpset.getParameter<std::string>("recMuonLabel");
745  }
746  if (anpset.exists("recElecLabel")) {
747  _recLabels[EVTColContainer::ELEC] = anpset.getParameter<std::string>("recElecLabel");
750  }
751  if (anpset.exists("recPhotonLabel")) {
752  _recLabels[EVTColContainer::PHOTON] = anpset.getParameter<std::string>("recPhotonLabel");
755  }
756  if (anpset.exists("recCaloMETLabel")) {
757  _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<std::string>("recCaloMETLabel");
760  }
761  if (anpset.exists("recPFMETLabel")) {
762  _recLabels[EVTColContainer::PFMET] = anpset.getParameter<std::string>("recPFMETLabel");
765  }
766  if (anpset.exists("recPFTauLabel")) {
767  _recLabels[EVTColContainer::PFTAU] = anpset.getParameter<std::string>("recPFTauLabel");
770  }
771  if (anpset.exists("recJetLabel")) {
772  _recLabels[EVTColContainer::PFJET] = anpset.getParameter<std::string>("recJetLabel");
774  if (anpset.exists("jetTagLabel"))
776  _genJetSelector = nullptr;
777  }
778  /*if( anpset.exists("recTrackLabel") )
779  {
780  _recLabels[EVTColContainer::TRACK] = anpset.getParameter<std::string>("recTrackLabel");
781  _genSelectorMap[EVTColContainer::TRACK] = 0 ;
782  }*/
783 
784  if (_recLabels.empty()) {
785  edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::bookobjects, "
786  << "Not included any object (recMuonLabel, recElecLabel, ...) "
787  << "in the analysis " << _analysisname;
788  return;
789  }
790 }
791 
793  /*if( col != 0 && col->isAllInit() )
794  {
795  // Already init, not needed to do nothing
796  return;
797  }*/
798  if (!col->isCommonInit()) {
799  // extract the trigger results (path info, pass,...)
801  iEvent.getByToken(_trigResultsTag, trigResults);
802  if (trigResults.isValid()) {
803  col->triggerResults = trigResults.product();
804  }
805 
806  // GenParticle collection if is there (genJets only if there need to be jets)
808  iEvent.getByToken(_genParticleLabel, genPart);
809  if (genPart.isValid()) {
810  col->genParticles = genPart.product();
811  }
812  }
813 
814  for (std::map<unsigned int, std::string>::iterator it = _recLabels.begin(); it != _recLabels.end(); ++it) {
815  if (it->first == EVTColContainer::MUON) {
817  iEvent.getByToken(_recLabelsMuon, theHandle);
818  col->set(theHandle.product());
819  } else if (it->first == EVTColContainer::ELEC) {
821  iEvent.getByToken(_recLabelsElec, theHandle);
822  col->set(theHandle.product());
823  } else if (it->first == EVTColContainer::PHOTON) {
825  iEvent.getByToken(_recLabelsPhoton, theHandle);
826  col->set(theHandle.product());
827  } else if (it->first == EVTColContainer::CALOMET) {
829  iEvent.getByToken(_recLabelsCaloMET, theHandle);
830  col->set(theHandle.product());
831  } else if (it->first == EVTColContainer::PFMET) {
833  iEvent.getByToken(_recLabelsPFMET, theHandle);
834  col->set(theHandle.product());
835  } else if (it->first == EVTColContainer::PFTAU) {
837  iEvent.getByToken(_recLabelsPFTau, theHandle);
838  col->set(theHandle.product());
839  }
840  // PFJets loaded in seperate function initAndInsertJets because they need to be combined with the btags using the Handle (not the product) and for ordering them seperately in the MatchStruct's
841  else if (it->first == EVTColContainer::PFJET) {
842  if (!_useNminOneCuts) {
843  // GenJet collection
845  iEvent.getByToken(_genJetLabel, genJet);
846  if (genJet.isValid()) {
847  col->genJets = genJet.product();
848  }
849  }
850  } else {
851  edm::LogError("HiggsValidation") << "HLTHiggsSubAnalysis::initobjects "
852  << " NOT IMPLEMENTED (yet) ERROR: '" << it->second << "'";
853  //return; ??
854  }
855  }
856 }
857 
859  const std::string& objType,
860  const std::string& variable,
861  DQMStore::IBooker& ibooker) {
862  std::string sourceUpper = source;
863  sourceUpper[0] = std::toupper(sourceUpper[0]);
865  TH1F* h = nullptr;
866 
867  if (variable.find("MaxPt") != std::string::npos) {
869  if (variable == "MaxPt1")
870  desc = "Leading";
871  else if (variable == "MaxPt2")
872  desc = "Next-to-Leading";
873  else
874  desc = variable.substr(5, 6) + "th Leading";
875  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
876  const size_t nBinsStandard = _parametersTurnOn.size() - 1;
877  size_t nBins = nBinsStandard;
878  float* edges = new float[nBinsStandard + 1];
879  for (size_t i = 0; i < nBinsStandard + 1; i++) {
881  }
882 
884  if (objType == jetObj) {
885  const size_t nBinsJets = 25;
886  nBins = nBinsJets;
887  delete[] edges;
888  edges = new float[nBinsJets + 1];
889  for (size_t i = 0; i < nBinsJets + 1; i++) {
890  edges[i] = i * 10;
891  }
892  }
894  const size_t nBinsJets = 30;
895  nBins = nBinsJets;
896  delete[] edges;
897  edges = new float[nBinsJets + 1];
898  for (size_t i = 0; i < nBinsJets + 1; i++) {
899  edges[i] = i * 10;
900  }
901  }
902  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
903  delete[] edges;
904  } else if (variable == "dEtaqq") {
905  std::string title = "#Delta #eta_{qq} of " + sourceUpper + " " + objType;
906  int nBins = 20;
907  double min = 0;
908  double max = 4.8;
909  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
910  } else if (variable == "mqq") {
911  std::string title = "m_{qq} of " + sourceUpper + " " + objType;
912  int nBins = 20;
913  double min = 0;
914  double max = 1000;
915  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
916  } else if (variable == "dPhibb") {
917  std::string title = "#Delta #phi_{bb} of " + sourceUpper + " " + objType;
918  int nBins = 10;
919  double min = 0;
920  double max = 3.1416;
921  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
922  } else if (variable == "CSV1") {
923  std::string title = "CSV1 of " + sourceUpper + " " + objType;
924  int nBins = 20;
925  double min = 0;
926  double max = 1;
927  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
928  } else if (variable == "CSV2") {
929  std::string title = "CSV2 of " + sourceUpper + " " + objType;
930  int nBins = 20;
931  double min = 0;
932  double max = 1;
933  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
934  } else if (variable == "CSV3") {
935  std::string title = "CSV3 of " + sourceUpper + " " + objType;
936  int nBins = 20;
937  double min = 0;
938  double max = 1;
939  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
940  } else if (variable == "maxCSV") {
941  std::string title = "max CSV of " + sourceUpper + " " + objType;
942  int nBins = 20;
943  double min = 0;
944  double max = 1;
945  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
946  } else {
947  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
948  std::string title = symbol + " of " + sourceUpper + " " + objType;
949  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
950 
951  int nBins = (int)params[0];
952  double min = params[1];
953  double max = params[2];
954  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
955  }
956  h->Sumw2();
957  _elements[name] = ibooker.book1D(name, h);
958  delete h;
959 }
960 
962  const std::string& objType,
963  const std::string& variable,
964  const float& value) {
965  std::string sourceUpper = source;
966  sourceUpper[0] = toupper(sourceUpper[0]);
968 
969  _elements[name]->Fill(value);
970 }
971 
972 // Initialize the selectors
973 void HLTHiggsSubAnalysis::InitSelector(const unsigned int& objtype) {
974  if (objtype == EVTColContainer::MUON && _recMuonSelector == nullptr) {
976  } else if (objtype == EVTColContainer::ELEC && _recElecSelector == nullptr) {
978  } else if (objtype == EVTColContainer::PHOTON && _recPhotonSelector == nullptr) {
980  } else if (objtype == EVTColContainer::CALOMET && _recCaloMETSelector == nullptr) {
982  } else if (objtype == EVTColContainer::PFMET && _recPFMETSelector == nullptr) {
984  } else if (objtype == EVTColContainer::PFTAU && _recPFTauSelector == nullptr) {
986  } else if (objtype == EVTColContainer::PFJET && _recPFJetSelector == nullptr) {
988  }
989  /*else if( objtype == EVTColContainer::TRACK && _recTrackSelector == 0)
990  {
991  _recTrackSelector = new StringCutObjectSelector<reco::Track>(_recCut[objtype]);
992  }*/
993  /* else
994  {
995 FIXME: ERROR NO IMPLEMENTADO
996  }*/
997 }
998 
1000  EVTColContainer* cols,
1001  std::vector<MatchStruct>* matches) {
1003  iEvent.getByToken(_recLabelsPFJet, PFJetHandle);
1004  cols->set(PFJetHandle.product());
1005 
1007  if (_useNminOneCuts) {
1008  iEvent.getByToken(_recTagPFJet, JetTagHandle);
1009  }
1010 
1011  for (reco::PFJetCollection::const_iterator it = PFJetHandle->begin(); it != PFJetHandle->end(); ++it) {
1012  reco::PFJetRef jetRef(PFJetHandle, it - PFJetHandle->begin());
1013  reco::JetBaseRef jetBaseRef(jetRef);
1014 
1015  if (_recPFJetSelector->operator()(*it)) {
1016  if (_useNminOneCuts) {
1017  float bTag = (*(JetTagHandle.product()))[jetBaseRef];
1019  } else {
1020  matches->push_back(MatchStruct(&*it, EVTColContainer::PFJET));
1021  }
1022  }
1023  }
1024 }
1025 
1027  std::vector<MatchStruct>* matches,
1028  std::map<std::string, bool>& jetCutResult,
1029  float& dEtaqq,
1030  float& mqq,
1031  float& dPhibb,
1032  float& CSV1,
1033  float& CSV2,
1034  float& CSV3) { //dEtaqq, mqq, dPhibb, CSV1, CSV2, CSV3, maxCSV_jets, maxCSV_E, PFMET, pt1, pt2, pt3, pt4
1035 
1036  // Perform pt cuts
1037  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
1038  TString maxPt;
1039  for (unsigned int i = 0; i < NptPlots; i++) {
1040  maxPt = "MaxPt";
1041  maxPt += i + 1;
1042  if ((*matches)[i].pt > _NminOneCuts[9 + i])
1043  jetCutResult[maxPt.Data()] = true;
1044  else
1045  jetCutResult[maxPt.Data()] = false;
1046  }
1047 
1048  unsigned int NbTag = ((_NminOneCuts[0] || _NminOneCuts[1]) ? 4 : 8);
1049  if (matches->size() < NbTag)
1050  NbTag = matches->size();
1051  // Perform b-tag ordered cuts
1052  std::sort(matches->begin(), matches->begin() + NbTag, matchesByDescendingBtag());
1053 
1054  if (_NminOneCuts[0]) {
1055  jetCutResult["dEtaqq"] = false;
1056  if (matches->size() > 2) {
1057  dEtaqq = fabs((*matches)[2].eta - (*matches)[3].eta);
1058  if (dEtaqq > _NminOneCuts[0])
1059  jetCutResult["dEtaqq"] = true;
1060  }
1061  }
1062 
1063  if (_NminOneCuts[1]) {
1064  jetCutResult["mqq"] = false;
1065  if (matches->size() > 2) {
1066  mqq = ((*matches)[2].lorentzVector + (*matches)[3].lorentzVector).M();
1067  if (mqq > _NminOneCuts[1])
1068  jetCutResult["mqq"] = true;
1069  }
1070  }
1071 
1072  if (_NminOneCuts[2]) {
1073  jetCutResult["dPhibb"] = false;
1074  if (matches->size() > 1) {
1075  dPhibb = fmod(fabs((*matches)[0].phi - (*matches)[1].phi), 3.1416);
1076  if (dPhibb < _NminOneCuts[2])
1077  jetCutResult["dPhibb"] = true;
1078  }
1079  }
1080 
1081  if (_NminOneCuts[4]) {
1082  std::string nameCSV2plot = "CSV2";
1083  jetCutResult[nameCSV2plot] = false;
1084  if (matches->size() > 1) {
1085  CSV2 = (*matches)[1].bTag;
1086  if (CSV2 > _NminOneCuts[4])
1087  jetCutResult[nameCSV2plot] = true;
1088  }
1089  }
1090 
1091  if (_NminOneCuts[5]) {
1092  std::string nameCSV3plot = "CSV3";
1093  jetCutResult[nameCSV3plot] = false;
1094  if (matches->size() > 2) {
1095  CSV3 = (*matches)[2].bTag;
1096  if (CSV3 > _NminOneCuts[5])
1097  jetCutResult[nameCSV3plot] = true;
1098  }
1099  }
1100 
1101  if (_NminOneCuts[3]) {
1102  CSV1 = (*matches)[0].bTag;
1103  std::string nameCSVplot = "CSV1";
1104  if (_NminOneCuts[6])
1105  nameCSVplot = "maxCSV";
1106 
1107  if (CSV1 > _NminOneCuts[3])
1108  jetCutResult[nameCSVplot] = true;
1109  else
1110  jetCutResult[nameCSVplot] = false;
1111 
1112  // max(CSV)
1113  if (_NminOneCuts[6]) {
1114  std::sort(matches->begin(), matches->end(), matchesByDescendingPt());
1115  CSV1 = (*matches)[0].bTag;
1116  unsigned int Njets = (unsigned int)_NminOneCuts[6];
1117  if (_NminOneCuts[6] > matches->size())
1118  Njets = matches->size();
1119  for (unsigned int i = 1; i < (unsigned int)Njets; ++i) {
1120  if ((*matches)[i].bTag > CSV1 && (*matches)[i].pt > _NminOneCuts[7])
1121  CSV1 = (*matches)[i].bTag;
1122  }
1123  }
1124  }
1125 }
1126 
1127 void HLTHiggsSubAnalysis::passOtherCuts(const std::vector<MatchStruct>& matches,
1128  std::map<std::string, bool>& jetCutResult) {
1129  if (_NminOneCuts[8]) {
1130  jetCutResult["PFMET"] = false;
1131  for (std::vector<MatchStruct>::const_iterator it = matches.begin(); it != matches.end(); ++it) {
1132  if (it->objType == EVTColContainer::PFMET) {
1133  if (it->pt > _NminOneCuts[8])
1134  jetCutResult["PFMET"] = true;
1135  break;
1136  }
1137  }
1138  }
1139 }
1140 
1142  const EVTColContainer* cols,
1143  std::vector<MatchStruct>* matches) {
1144  if (objType == EVTColContainer::MUON) {
1145  for (size_t i = 0; i < cols->muons->size(); i++) {
1146  if (_recMuonSelector->operator()(cols->muons->at(i))) {
1147  matches->push_back(MatchStruct(&cols->muons->at(i), objType));
1148  }
1149  }
1150  } else if (objType == EVTColContainer::ELEC) {
1151  for (size_t i = 0; i < cols->electrons->size(); i++) {
1152  if (_recElecSelector->operator()(cols->electrons->at(i))) {
1153  matches->push_back(MatchStruct(&cols->electrons->at(i), objType));
1154  }
1155  }
1156  } else if (objType == EVTColContainer::PHOTON) {
1157  for (size_t i = 0; i < cols->photons->size(); i++) {
1158  if (_recPhotonSelector->operator()(cols->photons->at(i))) {
1159  matches->push_back(MatchStruct(&cols->photons->at(i), objType));
1160  }
1161  }
1162  } else if (objType == EVTColContainer::CALOMET) {
1163  for (size_t i = 0; i < cols->caloMETs->size(); i++) {
1164  if (_recCaloMETSelector->operator()(cols->caloMETs->at(i))) {
1165  matches->push_back(MatchStruct(&cols->caloMETs->at(i), objType));
1166  }
1167  }
1168  } else if (objType == EVTColContainer::PFMET) {
1169  for (size_t i = 0; i < cols->pfMETs->size(); i++) {
1170  if (_recPFMETSelector->operator()(cols->pfMETs->at(i))) {
1171  matches->push_back(MatchStruct(&cols->pfMETs->at(i), objType));
1172  }
1173  }
1174  } else if (objType == EVTColContainer::PFTAU) {
1175  for (size_t i = 0; i < cols->pfTaus->size(); i++) {
1176  if (_recPFTauSelector->operator()(cols->pfTaus->at(i))) {
1177  matches->push_back(MatchStruct(&cols->pfTaus->at(i), objType));
1178  }
1179  }
1180  }
1181  // else if( objType == EVTColContainer::PFJET )
1182  // {
1183  // already inserted
1184  // }
1185  /*else if( objType == EVTColContainer::TRACK )
1186  {
1187  for(size_t i = 0; i < cols->tracks->size(); i++)
1188  {
1189  if(_recTrackSelector->operator()(cols->tracks->at(i)))
1190  {
1191  matches->push_back(MatchStruct(&cols->tracks->at(i),objType));
1192  }
1193  }
1194  }*/
1195  /*
1196  else FIXME: Control errores
1197  {
1198  }
1199  */
1200 }
const std::vector< reco::Muon > * muons
std::vector< double > _parametersTurnOn
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool accept() const
Has at least one path accepted the event?
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
void InitSelector(const unsigned int &objtype)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< std::string, std::string > _shortpath2long
Relation between the short version of a path.
StringCutObjectSelector< reco::CaloMET > * _recCaloMETSelector
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
edm::EDGetTokenT< reco::PFMETCollection > _recLabelsPFMET
edm::EDGetTokenT< reco::PFJetCollection > _recLabelsPFJet
edm::EDGetTokenT< reco::GenParticleCollection > _genParticleLabel
void passJetCuts(std::vector< MatchStruct > *matches, std::map< std::string, bool > &jetCutResult, float &dEtaqq, float &mqq, float &dPhibb, float &CSV1, float &CSV2, float &CSV3)
void initobjects(const edm::Event &iEvent, EVTColContainer *col)
edm::EDGetTokenT< reco::PFJetCollection > _recoHtJetLabel
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
const std::vector< reco::CaloMET > * caloMETs
edm::EDGetTokenT< reco::PFTauCollection > _recLabelsPFTau
unsigned int _minCandidates
The minimum number of reco/gen candidates needed by the analysis.
std::map< std::string, MonitorElement * > _elements
std::vector< double > _NminOneCuts
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< GenJet > GenJetCollection
collection of GenJet objects
T const * product() const
Definition: Handle.h:70
edm::ParameterSet _pset
std::set< std::string > _hltPaths
the hlt paths found in the hltConfig
const reco::GenParticleCollection * genParticles
container with all the objects needed
StringCutObjectSelector< reco::PFMET > * _recPFMETSelector
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
Log< level::Error, false > LogError
edm::EDGetTokenT< reco::GenJetCollection > _genJetLabel
std::map< unsigned int, StringCutObjectSelector< reco::GenParticle > * > _genSelectorMap
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
HLTConfigProvider _hltConfig
__host__ __device__ VT * co
Definition: prefixScan.h:47
edm::EDGetTokenT< reco::JetTagCollection > _recTagPFJet
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const std::vector< reco::PFTau > * pfTaus
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
void bookHistograms(DQMStore::IBooker &)
std::map< unsigned int, std::string > _recCut
std::vector< double > _parametersPu
#define LogTrace(id)
edm::EDGetTokenT< reco::PhotonCollection > _recLabelsPhoton
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::CaloMETCollection > _recLabelsCaloMET
StringCutObjectSelector< reco::Track > * _recTrackSelector
void passOtherCuts(const std::vector< MatchStruct > &matches, std::map< std::string, bool > &jetCutResult)
void set(const reco::MuonCollection *v)
Setter: multiple overloaded function.
int iEvent
Definition: GenABIO.cc:224
const reco::GenJetCollection * genJets
StringCutObjectSelector< reco::GenJet > * _genJetSelector
std::map< unsigned int, std::string > _genCut
gen/rec objects cuts
void initAndInsertJets(const edm::Event &iEvent, EVTColContainer *cols, std::vector< MatchStruct > *matches)
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > _puSummaryInfo
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
std::vector< HLTHiggsPlotter > _analyzers
std::map< unsigned int, double > _cutMaxEta
const std::vector< reco::Photon > * photons
void analyze(const edm::Event &iEvent, const edm::EventSetup &iEventSetup, EVTColContainer *cols)
Definition: value.py:1
StringCutObjectSelector< reco::PFTau > * _recPFTauSelector
std::map< unsigned int, double > _cutMinPt
void beginRun(const edm::Run &iRun, const edm::EventSetup &iEventSetup)
edm::EDGetTokenT< edm::TriggerResults > _trigResultsTag
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
void bookHist(const std::string &source, const std::string &objType, const std::string &variable, DQMStore::IBooker &)
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
std::vector< double > _parametersHt
edm::EDGetTokenT< reco::GsfElectronCollection > _recLabelsElec
HLTHiggsSubAnalysis(const edm::ParameterSet &pset, const std::string &analysisname, edm::ConsumesCollector &&iC)
StringCutObjectSelector< reco::Muon > * _recMuonSelector
void fillHist(const std::string &source, const std::string &objType, const std::string &variable, const float &value)
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
maxPt
Definition: PV_cfg.py:224
const std::vector< reco::GsfElectron > * electrons
const std::vector< std::string > & triggerNames() const
names of trigger paths
Helper structure to order MatchStruct.
Definition: MatchStruct.h:58
bool isValid() const
Definition: HandleBase.h:70
void insertcandidates(const unsigned int &objtype, const EVTColContainer *col, std::vector< MatchStruct > *matches)
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
edm::EDGetTokenT< reco::MuonCollection > _recLabelsMuon
HLT enums.
std::vector< double > _parametersPhi
std::vector< std::string > _hltPathsToCheck
the hlt paths with regular expressions
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
std::vector< double > _parametersEta
Some kinematical parameters.
col
Definition: cuy.py:1009
void bookobjects(const edm::ParameterSet &anpset, edm::ConsumesCollector &iC)
StringCutObjectSelector< reco::Photon > * _recPhotonSelector
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::map< unsigned int, std::string > _recLabels
const std::vector< reco::PFMET > * pfMETs
StringCutObjectSelector< reco::PFJet > * _recPFJetSelector
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const std::vector< unsigned int > getObjectsType(const std::string &hltpath) const
Extract what objects need this analysis.
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
const edm::TriggerResults * triggerResults
static std::string const source
Definition: EdmProvDump.cc:49
StringCutObjectSelector< reco::GsfElectron > * _recElecSelector
Definition: Run.h:45
#define LogDebug(id)
def exit(msg="")