CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTExoticaSubAnalysis.cc
Go to the documentation of this file.
1 
10 
15 
16 #include "TPRegexp.h"
17 #include "TString.h"
18 
21 
22 #include <set>
23 #include <algorithm>
24 
25 static constexpr int verbose=0;
26 
29  const std::string & analysisname,
30  edm::ConsumesCollector && consCollector) :
31  _pset(pset),
32  _analysisname(analysisname),
33  _minCandidates(0),
34  _hltProcessName(pset.getParameter<std::string>("hltProcessName")),
35  _genParticleLabel(pset.getParameter<std::string>("genParticleLabel")),
36  _trigResultsLabel("TriggerResults", "", _hltProcessName),
37  _beamSpotLabel(pset.getParameter<std::string>("beamSpotLabel")),
38  _parametersEta(pset.getParameter<std::vector<double> >("parametersEta")),
39  _parametersPhi(pset.getParameter<std::vector<double> >("parametersPhi")),
40  _parametersTurnOn(pset.getParameter<std::vector<double> >("parametersTurnOn")),
41  _parametersDxy(pset.getParameter<std::vector<double> >("parametersDxy")),
42  _recMuonSelector(0),
43  _recMuonTrkSelector(0),
44  _recTrackSelector(0),
45  _recElecSelector(0),
46  _recMETSelector(0),
47  _recPFMETSelector(0),
48  _recPFMHTSelector(0),
49  _genMETSelector(0),
50  _recCaloMETSelector(0),
51  _l1METSelector(0),
52  _recPFTauSelector(0),
53  _recPhotonSelector(0),
54  _recPFJetSelector(0),
55  _recCaloJetSelector(0)
56 {
57 
58  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::constructor()";
59 
60  // Specific parameters for this analysis
61  edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
62 
63  // If this analysis has a particular set of binnings, use it.
64  // (Taken from the analysis-specific parameter set, of course)
65  // The "true" in the beginning of _pset.insert() means
66  // "overwrite the parameter if need be".
67  if (anpset.exists("parametersTurnOn")) {
68  _parametersTurnOn = anpset.getParameter<std::vector<double> >("parametersTurnOn");
69  _pset.insert(true, "parametersTurnOn", anpset.retrieve("parametersTurnOn"));
70  }
71  if (anpset.exists("parametersEta")) {
72  _parametersEta = anpset.getParameter<std::vector<double> >("parametersEta");
73  _pset.insert(true, "parametersEta", anpset.retrieve("parametersEta"));
74  }
75  if (anpset.exists("parametersPhi")) {
76  _parametersPhi = anpset.getParameter<std::vector<double> >("parametersPhi");
77  _pset.insert(true, "parametersPhi", anpset.retrieve("parametersPhi"));
78  }
79  if (anpset.exists("parametersDxy")) {
80  _parametersDxy = anpset.getParameter<std::vector<double> >("parametersDxy");
81  _pset.insert(true, "parametersDxy", anpset.retrieve("parametersDxy"));
82  }
83 
84  // Get names of objects that we may want to get from the event.
85  // Notice that genParticles are dealt with separately.
86  this->getNamesOfObjects(anpset);
87 
88  // Since now we have the names, we should register the consumption
89  // of objects.
90  this->registerConsumes(consCollector);
91 
92  // Generic objects: Initialization of basic phase space cuts.
93  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
94  it != _recLabels.end(); ++it) {
95  const std::string objStr = EVTColContainer::getTypeString(it->first);
96  _genCut[it->first] = pset.getParameter<std::string>(objStr + "_genCut");
97  _recCut[it->first] = pset.getParameter<std::string>(objStr + "_recCut");
98  auto const genCutParam = objStr + "_genCut_leading";
99  if (pset.exists(genCutParam)) {
100  _genCut_leading[it->first] = pset.getParameter<std::string>(genCutParam);
101  } else {
102  _genCut_leading[it->first] = "pt>0"; // no cut
103  }
104  auto const recCutParam = objStr + "_recCut_leading";
105  if (pset.exists(recCutParam)) {
106  _recCut_leading[it->first] = pset.getParameter<std::string>(recCutParam);
107  } else {
108  _recCut_leading[it->first] = "pt>0"; // no cut
109  }
110  }
111 
112  //--- Updating parameters if has to be modified for this particular specific analysis
113  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
114  it != _recLabels.end(); ++it) {
115  const std::string objStr = EVTColContainer::getTypeString(it->first);
116 
117  auto const genCutParam = objStr + "_genCut";
118  if(anpset.existsAs<std::string>(genCutParam,false) ) {
119  _genCut[it->first] = anpset.getUntrackedParameter<std::string>(genCutParam);
120  }
121 
122  auto const recCutParam = objStr + "_recCut";
123  if(anpset.existsAs<std::string>(recCutParam,false) ) {
124  _recCut[it->first] = anpset.getUntrackedParameter<std::string>(recCutParam);
125  }
126 
127  }
128 
130  _hltPathsToCheck = anpset.getParameter<std::vector<std::string> >("hltPathsToCheck");
132  _minCandidates = anpset.getParameter<unsigned int>("minCandidates");
133 
134 }
135 
137 {
138  for (std::map<unsigned int, StringCutObjectSelector<reco::GenParticle>* >::iterator it = _genSelectorMap.begin();
139  it != _genSelectorMap.end(); ++it) {
140  delete it->second;
141  it->second = 0;
142  }
143  delete _recMuonSelector;
144  _recMuonSelector = 0;
145  delete _recMuonTrkSelector;
147  delete _recTrackSelector;
148  _recTrackSelector = 0;
149  delete _recElecSelector;
150  _recElecSelector = 0;
151  delete _recPhotonSelector;
152  _recPhotonSelector = 0;
153  delete _recMETSelector;
154  _recMETSelector = 0;
155  delete _recPFMETSelector;
156  _recPFMETSelector = 0;
157  delete _recPFMHTSelector;
158  _recPFMHTSelector = 0;
159  delete _genMETSelector;
160  _genMETSelector = 0;
161  delete _recCaloMETSelector;
163  delete _l1METSelector;
164  _l1METSelector = 0;
165  delete _recPFTauSelector;
166  _recPFTauSelector = 0;
167  delete _recPFJetSelector;
168  _recPFJetSelector = 0;
169  delete _recCaloJetSelector;
171 }
172 
173 
175 {
176 }
177 
178 
179 // 2014-02-03 -- Thiago
180 // Due to the fact that the DQM has to be thread safe now, we have to do things differently:
181 // 1) Implement the bookHistograms() method in the container class
182 // 2) Make the iBooker from above be known to this class
183 // 3) Separate all booking histograms routines in this and any auxiliary classe to be called
184 // from bookHistograms() in the container class
186  const edm::Run & iRun,
187  const edm::EventSetup & iSetup)
188 {
189 
190  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::subAnalysisBookHistos()";
191 
192  // Create the folder structure inside HLT/Exotica
193  std::string baseDir = "HLT/Exotica/" + _analysisname + "/";
194  iBooker.setCurrentFolder(baseDir);
195 
196  // Book the gen/reco analysis-dependent histograms (denominators)
197  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
198  it != _recLabels.end(); ++it) {
199  const std::string objStr = EVTColContainer::getTypeString(it->first);
200  std::vector<std::string> sources(2);
201  sources[0] = "gen";
202  sources[1] = "rec";
203 
204  for (size_t i = 0; i < sources.size(); i++) {
205  std::string source = sources[i];
206 
207  if ( source == "gen" ) {
208  if ( TString(objStr).Contains("MET") ||
209  TString(objStr).Contains("MHT") ||
210  TString(objStr).Contains("Jet") ) {
211  continue;
212  } else {
213  bookHist(iBooker, source, objStr, "MaxPt1");
214  bookHist(iBooker, source, objStr, "MaxPt2");
215  bookHist(iBooker, source, objStr, "MaxPt3");
216  bookHist(iBooker, source, objStr, "Eta");
217  bookHist(iBooker, source, objStr, "Phi");
218 
219  // If the target is electron or muon,
220  // we will add Dxy plots.
221  if ( it->first == EVTColContainer::ELEC ||
222  it->first == EVTColContainer::MUON ) {
223  bookHist(iBooker, source, objStr, "Dxy");
224  }
225  }
226  } else { // reco
227  if ( TString(objStr).Contains("MET") ||
228  TString(objStr).Contains("MHT") ) {
229  bookHist(iBooker, source, objStr, "MaxPt1");
230  bookHist(iBooker, source, objStr, "SumEt");
231  } else {
232  bookHist(iBooker, source, objStr, "MaxPt1");
233  bookHist(iBooker, source, objStr, "MaxPt2");
234  bookHist(iBooker, source, objStr, "MaxPt3");
235  bookHist(iBooker, source, objStr, "Eta");
236  bookHist(iBooker, source, objStr, "Phi");
237 
238  // If the target is electron or muon,
239  // we will add Dxy plots.
240  if ( it->first == EVTColContainer::ELEC ||
241  it->first == EVTColContainer::MUON ) {
242  bookHist(iBooker, source, objStr, "Dxy");
243  }
244  }
245  }
246 
247  }
248  } // closes loop in _recLabels
249 
250  // Call the plotterBookHistos() (which books all the path dependent histograms)
251  LogDebug("ExoticaValidation") << " number of plotters = " << _plotters.size();
252  for (std::vector<HLTExoticaPlotter>::iterator it = _plotters.begin();
253  it != _plotters.end(); ++it) {
254  it->plotterBookHistos(iBooker, iRun, iSetup);
255  }
256 }
257 
258 void HLTExoticaSubAnalysis::beginRun(const edm::Run & iRun, const edm::EventSetup & iSetup)
259 {
260 
261  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::beginRun()";
262 
265 
266  // Initialize the HLT config.
267  bool changedConfig(true);
268  if (!_hltConfig.init(iRun, iSetup, _hltProcessName, changedConfig)) {
269  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): "
270  << "Initialization of HLTConfigProvider failed!";
271  }
272 
273  // Parse the input paths to get them if they are in the table and associate
274  // them to the last filter of the path (in order to extract the objects).
275  _hltPaths.clear();
276  for (size_t i = 0; i < _hltPathsToCheck.size(); ++i) {
277  bool found = false;
278  TPRegexp pattern(_hltPathsToCheck[i]);
279 
280  // Loop over triggerNames from _hltConfig
281  for (size_t j = 0 ; j < _hltConfig.triggerNames().size(); ++j) {
282  std::string thetriggername = _hltConfig.triggerNames()[j];
283  if (TString(thetriggername).Contains(pattern)) {
284  _hltPaths.insert(thetriggername);
285  found = true;
286  }
287  if(verbose>2 && i==0)
288  std::cout << "--- TRIGGER PATH : " << thetriggername << std::endl;
289  }
290 
291  // Oh dear, the path we wanted seems to not be available
292  if (! found && verbose>2) {
293  edm::LogWarning("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): In "
294  << _analysisname << " subfolder NOT found the path: '"
295  << _hltPathsToCheck[i] << "*'" ;
296  }
297  } // Close loop over paths to check.
298 
299  // At this point, _hltpaths contains the names of the paths to check
300  // that were found. Let's log it at trace level.
301  LogTrace("ExoticaValidation") << "SubAnalysis: " << _analysisname
302  << "\nHLT Trigger Paths found >>>";
303  for (std::set<std::string>::const_iterator iter = _hltPaths.begin();
304  iter != _hltPaths.end(); ++iter) {
305  LogTrace("ExoticaValidation") << (*iter) << "\n";
306  }
307 
308  // Initialize the plotters (analysers for each trigger path)
309  _plotters.clear();
310  for (std::set<std::string>::iterator iPath = _hltPaths.begin();
311  iPath != _hltPaths.end(); ++iPath) {
312  // Avoiding the dependence of the version number for the trigger paths
313  std::string path = * iPath;
314  std::string shortpath = path;
315  if (path.rfind("_v") < path.length()) {
316  shortpath = path.substr(0, path.rfind("_v"));
317  }
318  _shortpath2long[shortpath] = path;
319 
320  // Objects needed by the HLT path
321  // Thiago: instead of trying to decode the objects from the path,
322  // put the burden on the user to tell us which objects are needed.
323  //const std::vector<unsigned int> objsNeedHLT = this->getObjectsType(shortpath);
324  std::vector<unsigned int> objsNeedHLT;
325  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin() ;
326  it != _recLabels.end(); ++it) {
327  objsNeedHLT.push_back(it->first);
328  }
329 
330  /*std::vector<unsigned int> userInstantiate;
331  // Sanity check: the object needed by a trigger path should be
332  // introduced by the user via config python (_recLabels datamember)
333  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin() ;
334  it != _recLabels.end(); ++it) {
335  userInstantiate.push_back(it->first);
336  }
337  for (std::vector<unsigned int>::const_iterator it = objsNeedHLT.begin(); it != objsNeedHLT.end();
338  ++it) {
339  if (std::find(userInstantiate.begin(), userInstantiate.end(), *it) ==
340  userInstantiate.end()) {
341  edm::LogError("ExoticaValidation") << "In HLTExoticaSubAnalysis::beginRun, "
342  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
343  << _analysisname << "' has been asked to evaluate the trigger path '"
344  << shortpath << "' (found it in 'hltPathsToCheck') BUT this path"
345  << " needs a '" << EVTColContainer::getTypeString(*it)
346  << "' which has not been instantiated ('recVariableLabels'"
347  << ")" ;
348  exit(-1); // This should probably throw an exception...
349  }
350  }
351  */
352  LogTrace("ExoticaValidation") << " --- " << shortpath;
353 
354  // The hlt path, the objects (electrons, muons, photons, ...)
355  // needed to evaluate the path are the argumens of the plotter
356  HLTExoticaPlotter analyzer(_pset, shortpath, objsNeedHLT);
357  _plotters.push_back(analyzer);
358  }// Okay, at this point we have prepared all the plotters.
359 
360 }
361 
362 
364 {
365  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::analyze()";
366 
367  if(verbose>2) std::cerr << "### Category : " << _analysisname << std::endl;
368  // Loop over _recLabels to make sure everything is alright.
369  /*
370  std::cout << "Now printing the _recLabels" << std::endl;
371  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
372  it != _recLabels.end(); ++it) {
373  std::cout << "Number: " << it->first << "\t" << "Label: " << it->second.label() << std::endl;
374  }
375  */
376 
377  // Initialize the collection (the ones which have not been initialiazed yet)
378  //std::cout << "Setting handles to objects..." << std::endl;
379  this->getHandlesToObjects(iEvent, cols);
380 
381  // Utility map, mapping kinds of objects (GEN, RECO) to strings ("gen","rec")
382  //std::map<Level, std::string> u2str;
383  //u2str[Level::GEN] = "gen";
384  //u2str[Level::RECO] = "rec";
385 
386  // Extract the match structure containing the gen/reco candidates (electron, muons,...). This part is common to all the SubAnalyses
387  std::vector<reco::LeafCandidate> matchesGen; matchesGen.clear();
388  std::vector<reco::LeafCandidate> matchesReco; matchesReco.clear();
389  std::map<int , double> theSumEt; // map< pdgId ; SumEt > in order to keep track of the MET type
390  std::map<int, std::vector<const reco::Track*> > trkObjs;
391 
392  // --- deal with GEN objects first.
393  // Make each good GEN object into the base cand for a MatchStruct
394  // Our definition of "good" is "passes the selector" defined in the config.py
395  // Save all the MatchStructs in the "matchesGen" vector.
396 
397  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
398  it != _recLabels.end(); ++it) {
399  // Here we are filling the vector of StringCutObjectSelector<reco::GenParticle>
400  // with objects constructed from the strings saved in _genCut.
401  // Initialize selectors when first event
402 
403  //std::cout << "Loop over the kinds of objects: objects of kind " << it->first << std::endl;
404 
405 
406  if (!_genSelectorMap[it->first]) {
408  }
409 
410  const std::string objTypeStr = EVTColContainer::getTypeString(it->first);
411  // genAnyMET doesn't make sense. No need their matchesGens
412  if ( TString(objTypeStr).Contains("MET") ||
413  TString(objTypeStr).Contains("MHT") ||
414  TString(objTypeStr).Contains("Jet") ) continue;
415 
416  // Now loop over the genParticles, and apply the operator() over each of them.
417  // Fancy syntax: for objects X and Y, X.operator()(Y) is the same as X(Y).
418  for (size_t i = 0; i < cols->genParticles->size(); ++i) {
419  //std::cout << "Now matchesGen.size() is " << matchesGen.size() << std::endl;
420  if (_genSelectorMap[it->first]->operator()(cols->genParticles->at(i))) {
421  const reco::Candidate* cand = &(cols->genParticles->at(i));
422  //std::cout << "Found good cand: cand->pt() = " << cand->pt() << std::endl;
423  //matchesGen.push_back(MatchStruct(cand, it->first));
426  reco::LeafCandidate v(0,cand->p4(),cand->vertex(),it->first,0,true);
427 
428  matchesGen.push_back(v);
429  }
430  }
431  }
432 
433  // Sort the matches by pT for later filling of turn-on curve
434  //std::cout << "Before sorting: matchesGen.size() = " << matchesGen.size() << std::endl;
435 
436  // GreaterByPt<reco::LeafCandidate> comparator;
437  // std::sort(matchesGen.begin(),
438  // matchesGen.end(),
439  // comparator);
440 
441  // --- same for RECO objects
442  // Extraction of the objects candidates
443  if(verbose>0) std::cout << "-- enter loop over recLabels" << std::endl;
444  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
445  it != _recLabels.end(); ++it) {
446  //std::cout << "Filling RECO \"matchesReco\" vector for particle kind it->first = "
447  // << it->first << ", which means " << it->second.label() << std::endl;
448  // Reco selectors (the function takes into account if it was instantiated
449  // before or not) ### Thiago ---> Then why don't we put it in the beginRun???
450  this->initSelector(it->first);
451  // -- Storing the matchesReco
452  this->insertCandidates(it->first, cols, &matchesReco, theSumEt, trkObjs);
453  if(verbose>0) std::cout << "--- " << EVTColContainer::getTypeString(it->first)
454  << " sumEt=" << theSumEt[it->first] << std::endl;
455  }
456 
457  // std::sort(matchesReco.begin(),
458  // matchesReco.end(),
459  // comparator);
460 
461  // -- Trigger Results
462  const edm::TriggerNames trigNames = iEvent.triggerNames(*(cols->triggerResults));
463 
465 
466  //for (std::map<unsigned int, std::vector<MatchStruct> >::iterator it = sourceMatchMap.begin(); it != sourceMatchMap.end(); ++it) {
467  // it->first: gen/reco it->second: HLT matches (std::vector<MatchStruct>)
468 
469  //if (it->second.size() < _minCandidates) { // FIXME: A bug is potentially here: what about the mixed channels?
470  //continue;
471  //}
472 
476  if(verbose>2) std::cerr << "### matchesGen.size() = " << matchesGen.size() << std::endl;
477  if( matchesGen.size() >= _minCandidates) { // FIXME: A bug is potentially here: what about the mixed channels?
478  // Okay, there are enough candidates. Move on!
479 
480  // Filling the gen/reco objects (eff-denominators):
481  // Just the first two different ones, if there are more
482  // The countobjects maps uints (object types, really) --> integers.
483  // Example:
484  // | uint | int |
485  // | 0 | 1 | --> 1 muon used
486  // | 1 | 2 | --> 2 electrons used
487 
488  // Initializing the count of the used objects.
489  std::map<unsigned int, int> countobjects;
490  for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin();
491  co != _recLabels.end(); ++co) {
492  //countobjects->insert(std::pair<unsigned int, int>(co->first, 0));
493  countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
494  }
495 
496  int counttotal = 0;
497 
498  // 3 : pt1, pt2, pt3
499  int totalobjectssize3 = 3 * countobjects.size();
500 
501 
502  bool isPassedLeadingCut = true;
503  // We will proceed only when cuts for the pt-leading are satisified.
504  for (size_t j = 0; j != matchesGen.size(); ++j) {
505  const unsigned int objType = matchesGen[j].pdgId();
506  // Cut for the pt-leading object
508  if ( !select( matchesGen[j] ) ) { // No interest case
509  isPassedLeadingCut = false; // Will skip the following matchesGen loop
510  matchesGen.clear();
511  break;
512  }
513  }
514 
515  std::vector<float> dxys; dxys.clear();
516 
517  for (size_t j = 0; ( j != matchesGen.size() ) && isPassedLeadingCut; ++j) {
518  const unsigned int objType = matchesGen[j].pdgId();
519  //std::cout << "(4) Gonna call with " << objType << std::endl;
520  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
521 
522  float pt = matchesGen[j].pt();
523 
524  if (countobjects[objType] == 0) {
525  this->fillHist("gen", objTypeStr, "MaxPt1", pt);
526  ++(countobjects[objType]);
527  ++counttotal;
528  }
529  else if (countobjects[objType] == 1) {
530  this->fillHist("gen", objTypeStr, "MaxPt2", pt);
531  ++(countobjects[objType]);
532  ++counttotal;
533  }
534  else if (countobjects[objType] == 2) {
535  this->fillHist("gen", objTypeStr, "MaxPt3", pt);
536  ++(countobjects[objType]);
537  ++counttotal;
538  }
539  else {
540  // Already the minimum three objects has been filled, get out...
541  if (counttotal == totalobjectssize3) {
542  size_t max_size = matchesGen.size();
543  for ( size_t jj = j; jj < max_size; jj++ ) {
544  matchesGen.erase(matchesGen.end());
545  }
546  break;
547  }
548  }
549 
550  float eta = matchesGen[j].eta();
551  float phi = matchesGen[j].phi();
552 
553  this->fillHist("gen", objTypeStr, "Eta", eta);
554  this->fillHist("gen", objTypeStr, "Phi", phi);
555 
556  // If the target is electron or muon,
557  // we will add Dxy plots.
558  if ( objType == EVTColContainer::MUON ||
559  objType == EVTColContainer::ELEC ) {
560  const math::XYZPoint & vtx = matchesGen[j].vertex();
561  float momphi = matchesGen[j].momentum().phi();
562  float dxyGen = (-(vtx.x()-cols->bs->x0())*sin(momphi)+(vtx.y()-cols->bs->y0())*cos(momphi));
563  dxys.push_back(dxyGen);
564  this->fillHist("gen", objTypeStr, "Dxy", dxyGen);
565  }
566 
567  } // Closes loop in gen
568 
569  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
570  //const std::string source = "gen";
571  for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
572  const std::string hltPath = _shortpath2long[an->gethltpath()];
573  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
574  LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
575  an->analyze(ispassTrigger, "gen", matchesGen, theSumEt, dxys);
576  LogDebug("ExoticaValidation") << " called the plotter";
577  }
578  }
579 
583  if(verbose>2) std::cerr << "### matchesReco.size() = " << matchesReco.size() << std::endl;
584 
585  {
586  if(matchesReco.size() < _minCandidates) return; // FIXME: A bug is potentially here: what about the mixed channels?
587 
588  // Okay, there are enough candidates. Move on!
589 
590  // Filling the gen/reco objects (eff-denominators):
591  // Just the first two different ones, if there are more
592  // The countobjects maps uints (object types, really) --> integers.
593  // Example:
594  // | uint | int |
595  // | 0 | 1 | --> 1 muon used
596  // | 1 | 2 | --> 2 electrons used
597  // Initializing the count of the used objects.
598  //std::map<unsigned int, int> * countobjects = new std::map<unsigned int, int>;
599  std::map<unsigned int, int> countobjects;
600  for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin();
601  co != _recLabels.end(); ++co) {
602  countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
603  }
604 
605  int counttotal = 0;
606 
607  // 3 : pt1, pt2, pt3
608  int totalobjectssize3 = 3 * countobjects.size();
609 
611  //std::cout << "Our RECO vector has matchesReco.size() = " << matchesReco.size() << std::endl;
612 
613  std::vector<float> dxys; dxys.clear();
614 
615  bool isPassedLeadingCut = true;
616  // We will proceed only when cuts for the pt-leading are satisified.
617  for (size_t j = 0; j != matchesReco.size(); ++j) {
618  const unsigned int objType = matchesReco[j].pdgId();
619  // Cut for the pt-leading object
621  if ( !select( matchesReco[j] ) ) { // No interest case
622  isPassedLeadingCut = false; // Will skip the following matchesReco loop
623  matchesReco.clear();
624  break;
625  }
626  }
627 
628  for (size_t j = 0; ( j != matchesReco.size() ) && isPassedLeadingCut; ++j) {
629  const unsigned int objType = matchesReco[j].pdgId();
630  //std::cout << "(4) Gonna call with " << objType << std::endl;
631  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
632 
633  float pt = matchesReco[j].pt();
634 
635  if (countobjects[objType] == 0) {
636  this->fillHist("rec", objTypeStr, "MaxPt1", pt);
637  ++(countobjects[objType]);
638  ++counttotal;
639  }
640  else if (countobjects[objType] == 1) {
641  if( ! ( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
642  this->fillHist("rec", objTypeStr, "MaxPt2", pt);
643  }
644  ++(countobjects[objType]);
645  ++counttotal;
646  }
647  else if (countobjects[objType] == 2) {
648  if( ! ( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
649  this->fillHist("rec", objTypeStr, "MaxPt3", pt);
650  }
651  ++(countobjects[objType]);
652  ++counttotal;
653  }
654  else {
655  // Already the minimum three objects has been filled, get out...
656  if (counttotal == totalobjectssize3) {
657  size_t max_size = matchesReco.size();
658  for ( size_t jj = j; jj < max_size; jj++ ) {
659  matchesReco.erase(matchesReco.end());
660  }
661  break;
662  }
663  }
664 
665  float eta = matchesReco[j].eta();
666  float phi = matchesReco[j].phi();
667 
668  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
669  this->fillHist("rec", objTypeStr, "Eta", eta);
670  this->fillHist("rec", objTypeStr, "Phi", phi);
671  }
672  else {
673  this->fillHist("rec", objTypeStr, "SumEt", theSumEt[objType]);
674  }
675 
676  if (trkObjs[objType].size()>=j+1) {
677  float dxyRec = trkObjs[objType].at(j)->dxy(cols->bs->position());
678  this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
679  dxys.push_back(dxyRec);
680  }
681 
682  } // Closes loop in reco
683 
684  //LogDebug("ExoticaValidation") << " deleting countobjects";
685  //delete countobjects;
686 
687  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
688  //const std::string source = "reco";
689  for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
690  const std::string hltPath = _shortpath2long[an->gethltpath()];
691  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
692  LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
693  an->analyze(ispassTrigger, "rec", matchesReco, theSumEt, dxys);
694  LogDebug("ExoticaValidation") << " called the plotter";
695  }
696  }
697 
698 }
699 
700 
701 // Return the objects (muons,electrons,photons,...) needed by a hlt path.
702 const std::vector<unsigned int> HLTExoticaSubAnalysis::getObjectsType(const std::string & hltPath) const
703 {
704  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getObjectsType()";
705 
706  static const unsigned int objSize = 14;
707  static const unsigned int objtriggernames[] = {
722  };
723 
724  std::set<unsigned int> objsType;
725  // The object to deal has to be entered via the config .py
726  for (unsigned int i = 0; i < objSize; ++i) {
727  //std::cout << "(5) Gonna call with " << objtriggernames[i] << std::endl;
728  std::string objTypeStr = EVTColContainer::getTypeString(objtriggernames[i]);
729  // Check if it is needed this object for this trigger
730  if (! TString(hltPath).Contains(objTypeStr)) {
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 {
743  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getNamesOfObjects()";
744 
745  if (anpset.exists("recMuonLabel")) {
746  _recLabels[EVTColContainer::MUON] = anpset.getParameter<edm::InputTag>("recMuonLabel");
748  }
749  if (anpset.exists("recMuonTrkLabel")) {
750  _recLabels[EVTColContainer::MUTRK] = anpset.getParameter<edm::InputTag>("recMuonTrkLabel");
752  }
753  if (anpset.exists("recTrackLabel")) {
754  _recLabels[EVTColContainer::TRACK] = anpset.getParameter<edm::InputTag>("recTrackLabel");
756  }
757  if (anpset.exists("recElecLabel")) {
758  _recLabels[EVTColContainer::ELEC] = anpset.getParameter<edm::InputTag>("recElecLabel");
760  }
761  if (anpset.exists("recPhotonLabel")) {
762  _recLabels[EVTColContainer::PHOTON] = anpset.getParameter<edm::InputTag>("recPhotonLabel");
764  }
765  if (anpset.exists("recMETLabel")) {
766  _recLabels[EVTColContainer::MET] = anpset.getParameter<edm::InputTag>("recMETLabel");
768  }
769  if (anpset.exists("recPFMETLabel")) {
770  _recLabels[EVTColContainer::PFMET] = anpset.getParameter<edm::InputTag>("recPFMETLabel");
772  }
773  if (anpset.exists("recPFMHTLabel")) {
774  _recLabels[EVTColContainer::PFMHT] = anpset.getParameter<edm::InputTag>("recPFMHTLabel");
776  }
777  if (anpset.exists("genMETLabel")) {
780  }
781  if (anpset.exists("recCaloMETLabel")) {
782  _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<edm::InputTag>("recCaloMETLabel");
784  }
785  if (anpset.exists("hltMETLabel")) {
788  }
789  if (anpset.exists("l1METLabel")) {
792  }
793  if (anpset.exists("recPFTauLabel")) {
794  _recLabels[EVTColContainer::PFTAU] = anpset.getParameter<edm::InputTag>("recPFTauLabel");
796  }
797  if (anpset.exists("recPFJetLabel")) {
798  _recLabels[EVTColContainer::PFJET] = anpset.getParameter<edm::InputTag>("recPFJetLabel");
800  }
801  if (anpset.exists("recCaloJetLabel")) {
802  _recLabels[EVTColContainer::CALOJET] = anpset.getParameter<edm::InputTag>("recCaloJetLabel");
804  }
805 
806  if (_recLabels.size() < 1) {
807  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getNamesOfObjects, "
808  << "Not included any object (recMuonLabel, recElecLabel, ...) "
809  << "in the analysis " << _analysisname;
810  return;
811  }
812 }
813 
814 // Register consumption of objects.
815 // I have chosen to centralize all consumes() calls here.
817 {
818  // Register that we are getting genParticles
820 
821  // Register that we are getting the trigger results
823 
824  // Register beamspot
826 
827  // Loop over _recLabels, see what we need, and register.
828  // Then save the registered token in _tokens.
829  // Remember: _recLabels is a map<uint, edm::InputTag>
830  // Remember: _tokens is a map<uint, edm::EDGetToken>
831  LogDebug("ExoticaValidation") << "We have got " << _recLabels.size() << "recLabels";
832  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
833  it != _recLabels.end(); ++it) {
834  if (it->first == EVTColContainer::MUON) {
835  edm::EDGetTokenT<reco::MuonCollection> particularToken = iC.consumes<reco::MuonCollection>(it->second);
836  edm::EDGetToken token(particularToken);
837  _tokens[it->first] = token;
838  }
839  else if (it->first == EVTColContainer::MUTRK) {
841  edm::EDGetToken token(particularToken);
842  _tokens[it->first] = token;
843  }
844  else if (it->first == EVTColContainer::TRACK) {
846  edm::EDGetToken token(particularToken);
847  _tokens[it->first] = token;
848  }
849  else if (it->first == EVTColContainer::ELEC) {
851  edm::EDGetToken token(particularToken);
852  _tokens[it->first] = token;
853  }
854  else if (it->first == EVTColContainer::PHOTON) {
856  edm::EDGetToken token(particularToken);
857  _tokens[it->first] = token;
858  }
859  else if (it->first == EVTColContainer::MET) {
860  edm::EDGetTokenT<reco::METCollection> particularToken = iC.consumes<reco::METCollection>(it->second);
861  edm::EDGetToken token(particularToken);
862  _tokens[it->first] = token;
863  }
864  else if (it->first == EVTColContainer::PFMET) {
866  edm::EDGetToken token(particularToken);
867  _tokens[it->first] = token;
868  }
869  else if (it->first == EVTColContainer::PFMHT) {
871  edm::EDGetToken token(particularToken);
872  _tokens[it->first] = token;
873  }
874  else if (it->first == EVTColContainer::GENMET) {
876  edm::EDGetToken token(particularToken);
877  _tokens[it->first] = token;
878  }
879  else if (it->first == EVTColContainer::CALOMET) {
881  edm::EDGetToken token(particularToken);
882  _tokens[it->first] = token;
883  }
884  else if (it->first == EVTColContainer::L1MET) {
886  edm::EDGetToken token(particularToken);
887  _tokens[it->first] = token;
888  }
889  else if (it->first == EVTColContainer::PFTAU) {
891  edm::EDGetToken token(particularToken);
892  _tokens[it->first] = token;
893  }
894  else if (it->first == EVTColContainer::PFJET) {
896  edm::EDGetToken token(particularToken);
897  _tokens[it->first] = token;
898  }
899  else if (it->first == EVTColContainer::CALOJET) {
901  edm::EDGetToken token(particularToken);
902  _tokens[it->first] = token;
903  }
904  else {
905  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::registerConsumes"
906  << " NOT IMPLEMENTED (yet) ERROR: '" << it->second.label() << "'";
907  }
908  }
909 
910 }
911 
912 // Setting the collections of objects in EVTColContainer
914 {
915  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getHandlesToObjects()";
916 
917  if (! col->isCommonInit()) {
918  // Extract the trigger results (path info, pass,...)
920  iEvent.getByToken(_trigResultsToken, trigResults);
921  if (trigResults.isValid()) {
922  col->triggerResults = trigResults.product();
923  LogDebug("ExoticaValidation") << "Added handle to triggerResults";
924  }
925 
926  // Extract the genParticles
928  iEvent.getByToken(_genParticleToken, genPart);
929  if (genPart.isValid()) {
930  col->genParticles = genPart.product();
931  LogDebug("ExoticaValidation") << "Added handle to genParticles";
932  }
933 
934  // BeamSpot for dxy
936  iEvent.getByToken(_bsToken, bsHandle);
937  if (bsHandle.isValid()) {
938  col->bs = bsHandle.product();
939  }
940  }
941 
942  // Loop over the tokens and extract all other objects
943  LogDebug("ExoticaValidation") << "We have got " << _tokens.size() << "tokens";
944  for (std::map<unsigned int, edm::EDGetToken>::iterator it = _tokens.begin();
945  it != _tokens.end(); ++it) {
946  if (it->first == EVTColContainer::MUON) {
948  iEvent.getByToken(it->second, theHandle);
949  if (theHandle.isValid()) col->set(theHandle.product());
950  }
951  else if (it->first == EVTColContainer::MUTRK) {
953  iEvent.getByToken(it->second, theHandle);
954  if (theHandle.isValid()) col->set(theHandle.product());
955  }
956  else if (it->first == EVTColContainer::TRACK) {
958  iEvent.getByToken(it->second, theHandle);
959  if (theHandle.isValid()) col->set(theHandle.product());
960  }
961  else if (it->first == EVTColContainer::ELEC) {
963  iEvent.getByToken(it->second, theHandle);
964  if (theHandle.isValid()) col->set(theHandle.product());
965  }
966  else if (it->first == EVTColContainer::PHOTON) {
968  iEvent.getByToken(it->second, theHandle);
969  if (theHandle.isValid()) col->set(theHandle.product());
970  }
971  else if (it->first == EVTColContainer::MET) {
973  iEvent.getByToken(it->second, theHandle);
974  if (theHandle.isValid()) col->set(theHandle.product());
975  }
976  else if (it->first == EVTColContainer::PFMET) {
978  iEvent.getByToken(it->second, theHandle);
979  if (theHandle.isValid()) col->set(theHandle.product());
980  }
981  else if (it->first == EVTColContainer::PFMHT) {
983  iEvent.getByToken(it->second, theHandle);
984  if (theHandle.isValid()) col->setPFMHT(theHandle.product());
985  }
986  else if (it->first == EVTColContainer::GENMET) {
988  iEvent.getByToken(it->second, theHandle);
989  if (theHandle.isValid()) col->set(theHandle.product());
990  }
991  else if (it->first == EVTColContainer::CALOMET) {
993  iEvent.getByToken(it->second, theHandle);
994  if (theHandle.isValid()) col->set(theHandle.product());
995  }
996  else if (it->first == EVTColContainer::L1MET) {
998  iEvent.getByToken(it->second, theHandle);
999  if (theHandle.isValid()) col->set(theHandle.product());
1000  }
1001  else if (it->first == EVTColContainer::PFTAU) {
1003  iEvent.getByToken(it->second, theHandle);
1004  if (theHandle.isValid()) col->set(theHandle.product());
1005  }
1006  else if (it->first == EVTColContainer::PFJET) {
1008  iEvent.getByToken(it->second, theHandle);
1009  if (theHandle.isValid()) col->set(theHandle.product());
1010  }
1011  else if (it->first == EVTColContainer::CALOJET) {
1013  iEvent.getByToken(it->second, theHandle);
1014  if (theHandle.isValid()) col->set(theHandle.product());
1015  }
1016  else {
1017  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getHandlesToObjects "
1018  << " NOT IMPLEMENTED (yet) ERROR: '" << it->first << "'";
1019  }
1020  }
1021 }
1022 
1023 // Booking the histograms, and putting them in DQM
1025  const std::string & source,
1026  const std::string & objType,
1027  const std::string & variable)
1028 {
1029  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::bookHist()";
1030  std::string sourceUpper = source;
1031  sourceUpper[0] = std::toupper(sourceUpper[0]);
1032  std::string name = source + objType + variable ;
1033  TH1F * h = 0;
1034 
1035  if (variable.find("SumEt") != std::string::npos) {
1036  std::string title = "Sum ET of " + sourceUpper + " " + objType;
1037  const size_t nBins = _parametersTurnOn.size() - 1;
1038  float * edges = new float[nBins + 1];
1039  for (size_t i = 0; i < nBins + 1; i++) {
1040  edges[i] = _parametersTurnOn[i];
1041  }
1042  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1043  delete[] edges;
1044  }
1045 
1046  else if (variable.find("Dxy") != std::string::npos) {
1047  std::string title = "Dxy " + sourceUpper + " " + objType;
1048  int nBins = _parametersDxy[0];
1049  double min = _parametersDxy[1];
1050  double max = _parametersDxy[2];
1051  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1052  }
1053 
1054  else if (variable.find("MaxPt") != std::string::npos) {
1055  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
1056  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
1057  const size_t nBins = _parametersTurnOn.size() - 1;
1058  float * edges = new float[nBins + 1];
1059  for (size_t i = 0; i < nBins + 1; i++) {
1060  edges[i] = _parametersTurnOn[i];
1061  }
1062  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1063  delete[] edges;
1064  }
1065 
1066  else {
1067  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
1068  std::string title = symbol + " of " + sourceUpper + " " + objType;
1069  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
1070  int nBins = (int)params[0];
1071  double min = params[1];
1072  double max = params[2];
1073  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1074  }
1075 
1076  h->Sumw2();
1077  // This is the trick, that takes a normal TH1F and puts it in in the DQM
1078  // machinery. Seems to be easy!
1079  // Updated to use the new iBooker machinery.
1080  _elements[name] = iBooker.book1D(name, h);
1081  delete h;
1082 }
1083 
1084 // Fill the histograms
1086  const std::string & objType,
1087  const std::string & variable,
1088  const float & value)
1089 {
1090  std::string sourceUpper = source;
1091  sourceUpper[0] = toupper(sourceUpper[0]);
1092  std::string name = source + objType + variable ;
1093 
1094  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " " << value;
1095  _elements[name]->Fill(value);
1096  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " worked";
1097 }
1098 
1099 // Initialize the selectors
1100 void HLTExoticaSubAnalysis::initSelector(const unsigned int & objtype)
1101 {
1102 
1103  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::initSelector()";
1104 
1105  if (objtype == EVTColContainer::MUON && _recMuonSelector == 0) {
1107  } else if (objtype == EVTColContainer::MUTRK && _recMuonTrkSelector == 0) {
1109  } else if (objtype == EVTColContainer::TRACK && _recTrackSelector == 0) {
1111  } else if (objtype == EVTColContainer::ELEC && _recElecSelector == 0) {
1113  } else if (objtype == EVTColContainer::PHOTON && _recPhotonSelector == 0) {
1115  } else if (objtype == EVTColContainer::MET && _recMETSelector == 0) {
1117  } else if (objtype == EVTColContainer::PFMET && _recPFMETSelector == 0) {
1119  } else if (objtype == EVTColContainer::PFMHT && _recPFMHTSelector == 0) {
1121  } else if (objtype == EVTColContainer::GENMET && _genMETSelector == 0) {
1123  } else if (objtype == EVTColContainer::CALOMET && _recCaloMETSelector == 0) {
1125  } else if (objtype == EVTColContainer::L1MET && _l1METSelector == 0) {
1127  } else if (objtype == EVTColContainer::PFTAU && _recPFTauSelector == 0) {
1129  } else if (objtype == EVTColContainer::PFJET && _recPFJetSelector == 0) {
1131  } else if (objtype == EVTColContainer::CALOJET && _recCaloJetSelector == 0) {
1133  }
1134  /* else
1135  {
1136  FIXME: ERROR NOT IMPLEMENTED
1137  }*/
1138 }
1139 
1140 // Insert the HLT candidates
1141 void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const EVTColContainer * cols, std::vector<reco::LeafCandidate> * matches,
1142  std::map<int,double> & theSumEt, std::map<int,std::vector<const reco::Track*> > & trkObjs )
1143 {
1144 
1145  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::insertCandidates()";
1146 
1147  theSumEt[objType] = -1;
1148 
1149  if (objType == EVTColContainer::MUON) {
1150  for (size_t i = 0; i < cols->muons->size(); i++) {
1151  LogDebug("ExoticaValidation") << "Inserting muon " << i ;
1152  if (_recMuonSelector->operator()(cols->muons->at(i))) {
1153  reco::LeafCandidate m(0, cols->muons->at(i).p4(), cols->muons->at(i).vertex(), objType, 0, true);
1154  matches->push_back(m);
1155 
1156  // for making dxy plots
1157  trkObjs[objType].push_back(cols->muons->at(i).bestTrack());
1158  }
1159  }
1160  } else if (objType == EVTColContainer::MUTRK) {
1161  for (size_t i = 0; i < cols->tracks->size(); i++) {
1162  LogDebug("ExoticaValidation") << "Inserting muonTrack " << i ;
1163  if (_recMuonTrkSelector->operator()(cols->tracks->at(i))) {
1164  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1165  ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1166  mom4.SetXYZT(mom3.x(),mom3.y(),mom3.z(),mom3.r());
1167  reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1168  matches->push_back(m);
1169  }
1170  }
1171  } else if (objType == EVTColContainer::TRACK) {
1172  for (size_t i = 0; i < cols->tracks->size(); i++) {
1173  LogDebug("ExoticaValidation") << "Inserting Track " << i ;
1174  if (_recTrackSelector->operator()(cols->tracks->at(i))) {
1175  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1176  ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1177  mom4.SetXYZT(mom3.x(),mom3.y(),mom3.z(),mom3.r());
1178  reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1179  matches->push_back(m);
1180  }
1181  }
1182  } else if (objType == EVTColContainer::ELEC) {
1183  for (size_t i = 0; i < cols->electrons->size(); i++) {
1184  LogDebug("ExoticaValidation") << "Inserting electron " << i ;
1185  if (_recElecSelector->operator()(cols->electrons->at(i))) {
1186  reco::LeafCandidate m(0, cols->electrons->at(i).p4(), cols->electrons->at(i).vertex(), objType, 0, true);
1187  matches->push_back(m);
1188 
1189  // for making dxy plots
1190  trkObjs[objType].push_back(cols->electrons->at(i).bestTrack());
1191  }
1192  }
1193  } else if (objType == EVTColContainer::PHOTON) {
1194  for (size_t i = 0; i < cols->photons->size(); i++) {
1195  LogDebug("ExoticaValidation") << "Inserting photon " << i ;
1196  if (_recPhotonSelector->operator()(cols->photons->at(i))) {
1197  reco::LeafCandidate m(0, cols->photons->at(i).p4(), cols->photons->at(i).vertex(), objType, 0, true);
1198  matches->push_back(m);
1199  }
1200  }
1201  } else if (objType == EVTColContainer::PFMET) {
1205  for (size_t i = 0; i < cols->pfMETs->size(); i++) {
1206  LogDebug("ExoticaValidation") << "Inserting PFMET " << i ;
1207  if (_recPFMETSelector->operator()(cols->pfMETs->at(i))) {
1208  reco::LeafCandidate m(0, cols->pfMETs->at(i).p4(), cols->pfMETs->at(i).vertex(), objType, 0, true);
1209  matches->push_back(m);
1210  if(i==0) theSumEt[objType] = cols->pfMETs->at(i).sumEt();
1211  }
1212  }
1213  } else if (objType == EVTColContainer::PFMHT) {
1214  for (size_t i = 0; i < cols->pfMHTs->size(); i++) {
1215  LogDebug("ExoticaValidation") << "Inserting PFMHT " << i ;
1216  if (_recPFMHTSelector->operator()(cols->pfMHTs->at(i))) {
1217  reco::LeafCandidate m(0, cols->pfMHTs->at(i).p4(), cols->pfMHTs->at(i).vertex(), objType, 0, true);
1218  matches->push_back(m);
1219  if(i==0) theSumEt[objType] = cols->pfMHTs->at(i).sumEt();
1220  }
1221  }
1222  } else if (objType == EVTColContainer::GENMET) {
1223  for (size_t i = 0; i < cols->genMETs->size(); i++) {
1224  LogDebug("ExoticaValidation") << "Inserting GENMET " << i ;
1225  if (_genMETSelector->operator()(cols->genMETs->at(i))) {
1226  reco::LeafCandidate m(0, cols->genMETs->at(i).p4(), cols->genMETs->at(i).vertex(), objType, 0, true);
1227  matches->push_back(m);
1228  if(i==0) theSumEt[objType] = cols->genMETs->at(i).sumEt();
1229  }
1230  }
1231  } else if (objType == EVTColContainer::CALOMET) {
1232  for (size_t i = 0; i < cols->caloMETs->size(); i++) {
1233  LogDebug("ExoticaValidation") << "Inserting CALOMET " << i ;
1234  if (_recCaloMETSelector->operator()(cols->caloMETs->at(i))) {
1235  reco::LeafCandidate m(0, cols->caloMETs->at(i).p4(), cols->caloMETs->at(i).vertex(), objType, 0, true);
1236  matches->push_back(m);
1237  if(i==0) theSumEt[objType] = cols->caloMETs->at(i).sumEt();
1238  }
1239  }
1240  } else if (objType == EVTColContainer::L1MET) {
1241  for (size_t i = 0; i < cols->l1METs->size(); i++) {
1242  LogDebug("ExoticaValidation") << "Inserting L1MET " << i ;
1243  if (_l1METSelector->operator()(cols->l1METs->at(i))) {
1244  reco::LeafCandidate m(0, cols->l1METs->at(i).p4(), cols->l1METs->at(i).vertex(), objType, 0, true);
1245  matches->push_back(m);
1246  if(i==0) theSumEt[objType] = cols->l1METs->at(i).etTotal();
1247  }
1248  }
1249  } else if (objType == EVTColContainer::PFTAU) {
1250  for (size_t i = 0; i < cols->pfTaus->size(); i++) {
1251  LogDebug("ExoticaValidation") << "Inserting PFtau " << i ;
1252  if (_recPFTauSelector->operator()(cols->pfTaus->at(i))) {
1253  reco::LeafCandidate m(0, cols->pfTaus->at(i).p4(), cols->pfTaus->at(i).vertex(), objType, 0, true);
1254  matches->push_back(m);
1255  }
1256  }
1257  } else if (objType == EVTColContainer::PFJET) {
1258  for (size_t i = 0; i < cols->pfJets->size(); i++) {
1259  LogDebug("ExoticaValidation") << "Inserting jet " << i ;
1260  if (_recPFJetSelector->operator()(cols->pfJets->at(i))) {
1261  reco::LeafCandidate m(0, cols->pfJets->at(i).p4(), cols->pfJets->at(i).vertex(), objType, 0, true);
1262  matches->push_back(m);
1263  }
1264  }
1265  } else if (objType == EVTColContainer::CALOJET) {
1266  for (size_t i = 0; i < cols->caloJets->size(); i++) {
1267  LogDebug("ExoticaValidation") << "Inserting jet " << i ;
1268  if (_recCaloJetSelector->operator()(cols->caloJets->at(i))) {
1269  reco::LeafCandidate m(0, cols->caloJets->at(i).p4(), cols->caloJets->at(i).vertex(), objType, 0, true);
1270  matches->push_back(m);
1271  }
1272  }
1273  }
1274 
1275  /* else
1276  {
1277  FIXME: ERROR NOT IMPLEMENTED
1278  }*/
1279 }
#define LogDebug(id)
const std::vector< reco::Muon > * muons
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
StringCutObjectSelector< reco::Track > * _recMuonTrkSelector
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
unsigned int _minCandidates
The minimum number of reco/gen candidates needed by the analysis.
Entry const & retrieve(char const *) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
void getNamesOfObjects(const edm::ParameterSet &anpset)
Creates the maps that map which collection should come from which label.
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
const std::vector< reco::CaloMET > * caloMETs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
std::vector< reco::GenMET > GenMETCollection
collection of GenMET objects
std::map< unsigned int, std::string > _genCut
gen/rec objects cuts
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
std::vector< HLTExoticaPlotter > _plotters
The plotters: managers of each hlt path where the plots are done.
bool exists(std::string const &parameterName) const
checks if a parameter exists
StringCutObjectSelector< reco::CaloJet > * _recCaloJetSelector
StringCutObjectSelector< reco::GenMET > * _genMETSelector
std::vector< double > _parametersPhi
list pattern
Definition: chain.py:104
const std::vector< reco::CaloJet > * caloJets
void insert(bool ok_to_replace, char const *, Entry const &)
void fillHist(const std::string &source, const std::string &objType, const std::string &variable, const float &value)
const reco::GenParticleCollection * genParticles
container with all the objects needed
void analyze(const edm::Event &iEvent, const edm::EventSetup &iEventSetup, EVTColContainer *cols)
T eta() const
StringCutObjectSelector< reco::MET > * _recMETSelector
edm::EDGetTokenT< edm::TriggerResults > _trigResultsToken
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
dictionary edges
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
#define constexpr
const std::vector< reco::PFTau > * pfTaus
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
std::map< unsigned int, std::string > _genCut_leading
gen/rec pt-leading objects cuts
StringCutObjectSelector< reco::PFJet > * _recPFJetSelector
void setPFMHT(const reco::PFMETCollection *v)
std::map< unsigned int, edm::InputTag > _recLabels
StringCutObjectSelector< reco::GsfElectron > * _recElecSelector
void set(const reco::MuonCollection *v)
Setter: multiple overloaded function.
std::map< unsigned int, std::string > _recCut_leading
const std::vector< reco::PFMET > * pfMHTs
int iEvent
Definition: GenABIO.cc:230
StringCutObjectSelector< reco::Muon > * _recMuonSelector
tuple path
else: Piece not in the list, fine.
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
const std::vector< reco::GenMET > * genMETs
edm::ParameterSet _pset
Internal, working copy of the PSet passed from above.
const reco::BeamSpot * bs
void subAnalysisBookHistos(DQMStore::IBooker &iBooker, const edm::Run &iRun, const edm::EventSetup &iSetup)
std::vector< double > _parametersEta
Some kinematical parameters.
std::map< unsigned int, std::string > _recCut
std::vector< double > _parametersDxy
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const std::vector< unsigned int > getObjectsType(const std::string &hltpath) const
closes analyze method
StringCutObjectSelector< reco::Track > * _recTrackSelector
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
const std::vector< reco::PFJet > * pfJets
HLTConfigProvider _hltConfig
Interface to the HLT information.
const std::vector< reco::Track > * tracks
const std::vector< reco::Photon > * photons
virtual const Point & vertex() const =0
vertex position
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
~HLTExoticaSubAnalysis()
End Constructor.
T min(T a, T b)
Definition: MathUtil.h:58
bool isValid() const
Definition: HandleBase.h:75
std::vector< std::string > _hltPathsToCheck
The hlt paths to check for.
#define LogTrace(id)
std::string _hltProcessName
The labels of the object collections to be used in this analysis.
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
Transform3DPJ::Vector XYZVector
const std::vector< l1extra::L1EtMissParticle > * l1METs
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
void registerConsumes(edm::ConsumesCollector &consCollector)
Registers consumption of objects.
T const * product() const
Definition: Handle.h:81
void getHandlesToObjects(const edm::Event &iEvent, EVTColContainer *col)
Gets the collections themselves.
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
StringCutObjectSelector< reco::PFMET > * _recPFMETSelector
std::string _analysisname
The name of this sub-analysis.
StringCutObjectSelector< reco::Photon > * _recPhotonSelector
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
std::map< unsigned int, StringCutObjectSelector< reco::GenParticle > * > _genSelectorMap
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void beginRun(const edm::Run &iRun, const edm::EventSetup &iEventSetup)
StringCutObjectSelector< l1extra::L1EtMissParticle > * _l1METSelector
const std::vector< reco::GsfElectron > * electrons
std::vector< double > _parametersTurnOn
std::map< unsigned int, edm::EDGetToken > _tokens
std::map< std::string, MonitorElement * > _elements
Structure of the MonitorElements.
StringCutObjectSelector< reco::CaloMET > * _recCaloMETSelector
std::vector< PFJet > PFJetCollection
collection of PFJet objects
HLTExoticaSubAnalysis(const edm::ParameterSet &pset, const std::string &analysisname, edm::ConsumesCollector &&consCollector)
Constructor.
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
double y0() const
y coordinate
Definition: BeamSpot.h:66
edm::EDGetTokenT< reco::GenParticleCollection > _genParticleToken
And also the tokens to get the object collections.
tuple cout
Definition: gather_cfg.py:121
const Point & position() const
position
Definition: BeamSpot.h:62
void initSelector(const unsigned int &objtype)
Initializes the selectors of the objects based on which object it is.
std::vector< L1EtMissParticle > L1EtMissParticleCollection
const std::vector< reco::PFMET > * pfMETs
int col
Definition: cuy.py:1008
std::set< std::string > _hltPaths
The hlt paths found in the hltConfig.
static const std::string getTypeString(const unsigned int &objtype)
Tranform types into strings.
const edm::TriggerResults * triggerResults
StringCutObjectSelector< reco::PFMET > * _recPFMHTSelector
static std::string const source
Definition: EdmProvDump.cc:42
edm::EDGetTokenT< reco::BeamSpot > _bsToken
StringCutObjectSelector< reco::PFTau > * _recPFTauSelector
tuple size
Write out results.
void bookHist(DQMStore::IBooker &iBooker, const std::string &source, const std::string &objType, const std::string &variable)
The internal functions to book and fill histograms.
Definition: Run.h:41
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
std::map< std::string, std::string > _shortpath2long
Relation between the short and long versions of the path.
void insertCandidates(const unsigned int &objtype, const EVTColContainer *col, std::vector< reco::LeafCandidate > *matches, std::map< int, double > &theSumEt, std::map< int, std::vector< const reco::Track * > > &trkObjs)
double x0() const
x coordinate
Definition: BeamSpot.h:64
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
Definition: DDAxes.h:10