CMS 3D CMS Logo

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