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  _parametersTurnOnSumEt(pset.getParameter<std::vector<double> >("parametersTurnOnSumEt")),
42  _parametersDxy(pset.getParameter<std::vector<double> >("parametersDxy")),
43  _drop_pt2(false),
44  _drop_pt3(false),
45  _recMuonSelector(0),
46  _recMuonTrkSelector(0),
47  _recTrackSelector(0),
48  _recElecSelector(0),
49  _recMETSelector(0),
50  _recPFMETSelector(0),
51  _recPFMHTSelector(0),
52  _genMETSelector(0),
53  _recCaloMETSelector(0),
54  _recCaloMHTSelector(0),
55  _l1METSelector(0),
56  _recPFTauSelector(0),
57  _recPhotonSelector(0),
58  _recPFJetSelector(0),
59  _recCaloJetSelector(0)
60 {
61 
62  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::constructor()";
63 
64  // Specific parameters for this analysis
65  edm::ParameterSet anpset = pset.getParameter<edm::ParameterSet>(analysisname);
66 
67  // If this analysis has a particular set of binnings, use it.
68  // (Taken from the analysis-specific parameter set, of course)
69  // The "true" in the beginning of _pset.insert() means
70  // "overwrite the parameter if need be".
71  if (anpset.exists("parametersTurnOn")) {
72  _parametersTurnOn = anpset.getParameter<std::vector<double> >("parametersTurnOn");
73  _pset.insert(true, "parametersTurnOn", anpset.retrieve("parametersTurnOn"));
74  }
75  if (anpset.exists("parametersEta")) {
76  _parametersEta = anpset.getParameter<std::vector<double> >("parametersEta");
77  _pset.insert(true, "parametersEta", anpset.retrieve("parametersEta"));
78  }
79  if (anpset.exists("parametersPhi")) {
80  _parametersPhi = anpset.getParameter<std::vector<double> >("parametersPhi");
81  _pset.insert(true, "parametersPhi", anpset.retrieve("parametersPhi"));
82  }
83  if (anpset.exists("parametersDxy")) {
84  _parametersDxy = anpset.getParameter<std::vector<double> >("parametersDxy");
85  _pset.insert(true, "parametersDxy", anpset.retrieve("parametersDxy"));
86  }
87  if (anpset.exists("parametersTurnOnSumEt")) {
88  _parametersTurnOnSumEt = anpset.getParameter<std::vector<double> >("parametersTurnOnSumEt");
89  _pset.insert(true, "parametersTurnOnSumEt", anpset.retrieve("parametersTurnOnSumEt"));
90  }
91  if (anpset.exists("dropPt2")) {
92  _drop_pt2 = anpset.getParameter<bool>("dropPt2");
93  _pset.insert(true, "dropPt2", anpset.retrieve("dropPt2"));
94  }
95  if (anpset.exists("dropPt3")) {
96  _drop_pt3 = anpset.getParameter<bool>("dropPt3");
97  _pset.insert(true, "dropPt3", anpset.retrieve("dropPt3"));
98  }
99 
100  // Get names of objects that we may want to get from the event.
101  // Notice that genParticles are dealt with separately.
102  this->getNamesOfObjects(anpset);
103 
104  // Since now we have the names, we should register the consumption
105  // of objects.
106  this->registerConsumes(consCollector);
107 
108  // Generic objects: Initialization of basic phase space cuts.
109  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
110  it != _recLabels.end(); ++it) {
111  const std::string objStr = EVTColContainer::getTypeString(it->first);
112  _genCut[it->first] = pset.getParameter<std::string>(objStr + "_genCut");
113  _recCut[it->first] = pset.getParameter<std::string>(objStr + "_recCut");
114  auto const genCutParam = objStr + "_genCut_leading";
115  if (pset.exists(genCutParam)) {
116  _genCut_leading[it->first] = pset.getParameter<std::string>(genCutParam);
117  } else {
118  _genCut_leading[it->first] = "pt>0"; // no cut
119  }
120  auto const recCutParam = objStr + "_recCut_leading";
121  if (pset.exists(recCutParam)) {
122  _recCut_leading[it->first] = pset.getParameter<std::string>(recCutParam);
123  } else {
124  _recCut_leading[it->first] = "pt>0"; // no cut
125  }
126  }
127 
128  //--- Updating parameters if has to be modified for this particular specific analysis
129  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
130  it != _recLabels.end(); ++it) {
131  const std::string objStr = EVTColContainer::getTypeString(it->first);
132 
133  auto const genCutParam = objStr + "_genCut";
134  if(anpset.existsAs<std::string>(genCutParam,false) ) {
135  _genCut[it->first] = anpset.getUntrackedParameter<std::string>(genCutParam);
136  }
137 
138  auto const recCutParam = objStr + "_recCut";
139  if(anpset.existsAs<std::string>(recCutParam,false) ) {
140  _recCut[it->first] = anpset.getUntrackedParameter<std::string>(recCutParam);
141  }
142 
143  }
144 
146  _hltPathsToCheck = anpset.getParameter<std::vector<std::string> >("hltPathsToCheck");
148  _minCandidates = anpset.getParameter<unsigned int>("minCandidates");
149 
150 }
151 
153 {
154  for (std::map<unsigned int, StringCutObjectSelector<reco::GenParticle>* >::iterator it = _genSelectorMap.begin();
155  it != _genSelectorMap.end(); ++it) {
156  delete it->second;
157  it->second = 0;
158  }
159  delete _recMuonSelector;
160  _recMuonSelector = 0;
161  delete _recMuonTrkSelector;
163  delete _recTrackSelector;
164  _recTrackSelector = 0;
165  delete _recElecSelector;
166  _recElecSelector = 0;
167  delete _recPhotonSelector;
168  _recPhotonSelector = 0;
169  delete _recMETSelector;
170  _recMETSelector = 0;
171  delete _recPFMETSelector;
172  _recPFMETSelector = 0;
173  delete _recPFMHTSelector;
174  _recPFMHTSelector = 0;
175  delete _genMETSelector;
176  _genMETSelector = 0;
177  delete _recCaloMETSelector;
179  delete _recCaloMHTSelector;
181  delete _l1METSelector;
182  _l1METSelector = 0;
183  delete _recPFTauSelector;
184  _recPFTauSelector = 0;
185  delete _recPFJetSelector;
186  _recPFJetSelector = 0;
187  delete _recCaloJetSelector;
189 }
190 
191 
193 {
194 }
195 
196 
197 // 2014-02-03 -- Thiago
198 // Due to the fact that the DQM has to be thread safe now, we have to do things differently:
199 // 1) Implement the bookHistograms() method in the container class
200 // 2) Make the iBooker from above be known to this class
201 // 3) Separate all booking histograms routines in this and any auxiliary classe to be called
202 // from bookHistograms() in the container class
204  const edm::Run & iRun,
205  const edm::EventSetup & iSetup)
206 {
207 
208  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::subAnalysisBookHistos()";
209 
210  // Create the folder structure inside HLT/Exotica
211  std::string baseDir = "HLT/Exotica/" + _analysisname + "/";
212  iBooker.setCurrentFolder(baseDir);
213 
214  // Book the gen/reco analysis-dependent histograms (denominators)
215  for (std::map<unsigned int, edm::InputTag>::const_iterator it = _recLabels.begin();
216  it != _recLabels.end(); ++it) {
217  const std::string objStr = EVTColContainer::getTypeString(it->first);
218  std::vector<std::string> sources(2);
219  sources[0] = "gen";
220  sources[1] = "rec";
221 
222  for (size_t i = 0; i < sources.size(); i++) {
223  std::string source = sources[i];
224 
225  if ( source == "gen" ) {
226  if ( TString(objStr).Contains("MET") ||
227  TString(objStr).Contains("MHT") ||
228  TString(objStr).Contains("Jet") ) {
229  continue;
230  } else {
231  bookHist(iBooker, source, objStr, "MaxPt1");
232  if (!_drop_pt2) bookHist(iBooker, source, objStr, "MaxPt2");
233  if (!_drop_pt3) bookHist(iBooker, source, objStr, "MaxPt3");
234  bookHist(iBooker, source, objStr, "Eta");
235  bookHist(iBooker, source, objStr, "Phi");
236 
237  // If the target is electron or muon,
238  // we will add Dxy plots.
239  if ( it->first == EVTColContainer::ELEC ||
240  it->first == EVTColContainer::MUON ) {
241  bookHist(iBooker, source, objStr, "Dxy");
242  }
243  }
244  } else { // reco
245  if ( TString(objStr).Contains("MET") ||
246  TString(objStr).Contains("MHT") ) {
247  bookHist(iBooker, source, objStr, "MaxPt1");
248  bookHist(iBooker, source, objStr, "SumEt");
249  } else {
250  bookHist(iBooker, source, objStr, "MaxPt1");
251  if (!_drop_pt2) bookHist(iBooker, source, objStr, "MaxPt2");
252  if (!_drop_pt3) bookHist(iBooker, source, objStr, "MaxPt3");
253  bookHist(iBooker, source, objStr, "Eta");
254  bookHist(iBooker, source, objStr, "Phi");
255 
256  // If the target is electron or muon,
257  // we will add Dxy plots.
258  if ( it->first == EVTColContainer::ELEC ||
259  it->first == EVTColContainer::MUON ) {
260  bookHist(iBooker, source, objStr, "Dxy");
261  }
262  }
263  }
264 
265  }
266  } // closes loop in _recLabels
267 
268  // Call the plotterBookHistos() (which books all the path dependent histograms)
269  LogDebug("ExoticaValidation") << " number of plotters = " << _plotters.size();
270  for (std::vector<HLTExoticaPlotter>::iterator it = _plotters.begin();
271  it != _plotters.end(); ++it) {
272  it->plotterBookHistos(iBooker, iRun, iSetup);
273  }
274 }
275 
276 void HLTExoticaSubAnalysis::beginRun(const edm::Run & iRun, const edm::EventSetup & iSetup)
277 {
278 
279  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::beginRun()";
280 
283 
284  // Initialize the HLT config.
285  bool changedConfig(true);
286  if (!_hltConfig.init(iRun, iSetup, _hltProcessName, changedConfig)) {
287  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): "
288  << "Initialization of HLTConfigProvider failed!";
289  }
290 
291  // Parse the input paths to get them if they are in the table and associate
292  // them to the last filter of the path (in order to extract the objects).
293  _hltPaths.clear();
294  for (size_t i = 0; i < _hltPathsToCheck.size(); ++i) {
295  bool found = false;
296  TPRegexp pattern(_hltPathsToCheck[i]);
297 
298  // Loop over triggerNames from _hltConfig
299  for (size_t j = 0 ; j < _hltConfig.triggerNames().size(); ++j) {
300  std::string thetriggername = _hltConfig.triggerNames()[j];
301  if (TString(thetriggername).Contains(pattern)) {
302  _hltPaths.insert(thetriggername);
303  found = true;
304  }
305  if(verbose>2 && i==0)
306  LogDebug("ExoticaValidation") << "--- TRIGGER PATH : " << thetriggername;
307  }
308 
309  // Oh dear, the path we wanted seems to not be available
310  if (! found && verbose>2) {
311  edm::LogWarning("ExoticaValidation") << "HLTExoticaSubAnalysis::constructor(): In "
312  << _analysisname << " subfolder NOT found the path: '"
313  << _hltPathsToCheck[i] << "*'" ;
314  }
315  } // Close loop over paths to check.
316 
317  // At this point, _hltpaths contains the names of the paths to check
318  // that were found. Let's log it at trace level.
319  LogTrace("ExoticaValidation") << "SubAnalysis: " << _analysisname
320  << "\nHLT Trigger Paths found >>>";
321  for (std::set<std::string>::const_iterator iter = _hltPaths.begin();
322  iter != _hltPaths.end(); ++iter) {
323  LogTrace("ExoticaValidation") << (*iter) << "\n";
324  }
325 
326  // Initialize the plotters (analysers for each trigger path)
327  _plotters.clear();
328  for (std::set<std::string>::iterator iPath = _hltPaths.begin();
329  iPath != _hltPaths.end(); ++iPath) {
330  // Avoiding the dependence of the version number for the trigger paths
331  std::string path = * iPath;
332  std::string shortpath = path;
333  if (path.rfind("_v") < path.length()) {
334  shortpath = path.substr(0, path.rfind("_v"));
335  }
336  _shortpath2long[shortpath] = path;
337 
338  // Objects needed by the HLT path
339  // Thiago: instead of trying to decode the objects from the path,
340  // put the burden on the user to tell us which objects are needed.
341  //const std::vector<unsigned int> objsNeedHLT = this->getObjectsType(shortpath);
342  std::vector<unsigned int> objsNeedHLT;
343  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin() ;
344  it != _recLabels.end(); ++it) {
345  objsNeedHLT.push_back(it->first);
346  }
347 
348  /*std::vector<unsigned int> userInstantiate;
349  // Sanity check: the object needed by a trigger path should be
350  // introduced by the user via config python (_recLabels datamember)
351  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin() ;
352  it != _recLabels.end(); ++it) {
353  userInstantiate.push_back(it->first);
354  }
355  for (std::vector<unsigned int>::const_iterator it = objsNeedHLT.begin(); it != objsNeedHLT.end();
356  ++it) {
357  if (std::find(userInstantiate.begin(), userInstantiate.end(), *it) ==
358  userInstantiate.end()) {
359  edm::LogError("ExoticaValidation") << "In HLTExoticaSubAnalysis::beginRun, "
360  << "Incoherence found in the python configuration file!!\nThe SubAnalysis '"
361  << _analysisname << "' has been asked to evaluate the trigger path '"
362  << shortpath << "' (found it in 'hltPathsToCheck') BUT this path"
363  << " needs a '" << EVTColContainer::getTypeString(*it)
364  << "' which has not been instantiated ('recVariableLabels'"
365  << ")" ;
366  exit(-1); // This should probably throw an exception...
367  }
368  }
369  */
370  LogTrace("ExoticaValidation") << " --- " << shortpath;
371 
372  // The hlt path, the objects (electrons, muons, photons, ...)
373  // needed to evaluate the path are the argumens of the plotter
374  HLTExoticaPlotter analyzer(_pset, shortpath, objsNeedHLT);
375  _plotters.push_back(analyzer);
376  // counting HLT passed events for debug
378  }// Okay, at this point we have prepared all the plotters.
379 
380 }
381 
382 
384 {
385  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::analyze()";
386 
387  // Loop over _recLabels to make sure everything is alright.
388  /*
389  std::cout << "Now printing the _recLabels" << std::endl;
390  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
391  it != _recLabels.end(); ++it) {
392  std::cout << "Number: " << it->first << "\t" << "Label: " << it->second.label() << std::endl;
393  }
394  */
395 
396  // Initialize the collection (the ones which have not been initialiazed yet)
397  //std::cout << "Setting handles to objects..." << std::endl;
398  this->getHandlesToObjects(iEvent, cols);
399 
400  // Utility map, mapping kinds of objects (GEN, RECO) to strings ("gen","rec")
401  //std::map<Level, std::string> u2str;
402  //u2str[Level::GEN] = "gen";
403  //u2str[Level::RECO] = "rec";
404 
405  // Extract the match structure containing the gen/reco candidates (electron, muons,...). This part is common to all the SubAnalyses
406  std::vector<reco::LeafCandidate> matchesGen; matchesGen.clear();
407  std::vector<reco::LeafCandidate> matchesReco; matchesReco.clear();
408  std::map<int , double> theSumEt; // map< pdgId ; SumEt > in order to keep track of the MET type
409  std::map<int, std::vector<const reco::Track*> > trkObjs;
410 
411  // --- deal with GEN objects first.
412  // Make each good GEN object into the base cand for a MatchStruct
413  // Our definition of "good" is "passes the selector" defined in the config.py
414  // Save all the MatchStructs in the "matchesGen" vector.
415 
416  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
417  it != _recLabels.end(); ++it) {
418  // Here we are filling the vector of StringCutObjectSelector<reco::GenParticle>
419  // with objects constructed from the strings saved in _genCut.
420  // Initialize selectors when first event
421 
422  //std::cout << "Loop over the kinds of objects: objects of kind " << it->first << std::endl;
423 
424 
425  if (!_genSelectorMap[it->first]) {
427  }
428 
429  const std::string objTypeStr = EVTColContainer::getTypeString(it->first);
430  // genAnyMET doesn't make sense. No need their matchesGens
431  if ( TString(objTypeStr).Contains("MET") ||
432  TString(objTypeStr).Contains("MHT") ||
433  TString(objTypeStr).Contains("Jet") ) continue;
434 
435  // Now loop over the genParticles, and apply the operator() over each of them.
436  // Fancy syntax: for objects X and Y, X.operator()(Y) is the same as X(Y).
437  for (size_t i = 0; i < cols->genParticles->size(); ++i) {
438  //std::cout << "Now matchesGen.size() is " << matchesGen.size() << std::endl;
439  if (_genSelectorMap[it->first]->operator()(cols->genParticles->at(i))) {
440  const reco::Candidate* cand = &(cols->genParticles->at(i));
441  //std::cout << "Found good cand: cand->pt() = " << cand->pt() << std::endl;
442  //matchesGen.push_back(MatchStruct(cand, it->first));
445  reco::LeafCandidate v(0,cand->p4(),cand->vertex(),it->first,0,true);
446 
447  matchesGen.push_back(v);
448  }
449  }
450  }
451 
452  // Sort the matches by pT for later filling of turn-on curve
453  //std::cout << "Before sorting: matchesGen.size() = " << matchesGen.size() << std::endl;
454 
455  // GreaterByPt<reco::LeafCandidate> comparator;
456  // std::sort(matchesGen.begin(),
457  // matchesGen.end(),
458  // comparator);
459 
460  // --- same for RECO objects
461  // Extraction of the objects candidates
462  if(verbose>0) LogDebug("ExoticaValidation") << "-- enter loop over recLabels" ;
463  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
464  it != _recLabels.end(); ++it) {
465  //std::cout << "Filling RECO \"matchesReco\" vector for particle kind it->first = "
466  // << it->first << ", which means " << it->second.label() << std::endl;
467  // Reco selectors (the function takes into account if it was instantiated
468  // before or not) ### Thiago ---> Then why don't we put it in the beginRun???
469  this->initSelector(it->first);
470  // -- Storing the matchesReco
471  this->insertCandidates(it->first, cols, &matchesReco, theSumEt, trkObjs);
472  if(verbose>0) LogDebug("ExoticaValidation") << "--- " << EVTColContainer::getTypeString(it->first)
473  << " sumEt=" << theSumEt[it->first] ;
474  }
475 
476  // std::sort(matchesReco.begin(),
477  // matchesReco.end(),
478  // comparator);
479 
480  // -- Trigger Results
481  const edm::TriggerNames trigNames = iEvent.triggerNames(*(cols->triggerResults));
482 
483  // counting HLT passed events for debugging
484  for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
485  const std::string hltPath = _shortpath2long[an->gethltpath()];
486  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
487  if (ispassTrigger) _triggerCounter.find(an->gethltpath())->second++;
488  }
489 
491 
492  //for (std::map<unsigned int, std::vector<MatchStruct> >::iterator it = sourceMatchMap.begin(); it != sourceMatchMap.end(); ++it) {
493  // it->first: gen/reco it->second: HLT matches (std::vector<MatchStruct>)
494 
495  //if (it->second.size() < _minCandidates) { // FIXME: A bug is potentially here: what about the mixed channels?
496  //continue;
497  //}
498 
502  if( matchesGen.size() >= _minCandidates) { // FIXME: A bug is potentially here: what about the mixed channels?
503  // Okay, there are enough candidates. Move on!
504 
505  // Filling the gen/reco objects (eff-denominators):
506  // Just the first two different ones, if there are more
507  // The countobjects maps uints (object types, really) --> integers.
508  // Example:
509  // | uint | int |
510  // | 0 | 1 | --> 1 muon used
511  // | 1 | 2 | --> 2 electrons used
512 
513  // Initializing the count of the used objects.
514  std::map<unsigned int, int> countobjects;
515  for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin();
516  co != _recLabels.end(); ++co) {
517  //countobjects->insert(std::pair<unsigned int, int>(co->first, 0));
518  countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
519  }
520 
521  int counttotal = 0;
522 
523  // 3 : pt1, pt2, pt3
524  int totalobjectssize = 1;
525  if (!_drop_pt2) totalobjectssize++;
526  if (!_drop_pt3) totalobjectssize++;
527  totalobjectssize *= countobjects.size();
528 
529 
530  bool isPassedLeadingCut = true;
531  // We will proceed only when cuts for the pt-leading are satisified.
532  for (size_t j = 0; j != matchesGen.size(); ++j) {
533  const unsigned int objType = matchesGen[j].pdgId();
534  // Cut for the pt-leading object
536  if ( !select( matchesGen[j] ) ) { // No interest case
537  isPassedLeadingCut = false; // Will skip the following matchesGen loop
538  matchesGen.clear();
539  break;
540  }
541  }
542 
543  std::vector<float> dxys; dxys.clear();
544 
545  for (size_t j = 0; ( j != matchesGen.size() ) && isPassedLeadingCut; ++j) {
546  const unsigned int objType = matchesGen[j].pdgId();
547  //std::cout << "(4) Gonna call with " << objType << std::endl;
548  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
549 
550  float pt = matchesGen[j].pt();
551 
552  if (countobjects[objType] == 0) {
553  this->fillHist("gen", objTypeStr, "MaxPt1", pt);
554  ++(countobjects[objType]);
555  ++counttotal;
556  }
557  else if (countobjects[objType] == 1 && !_drop_pt2) {
558  this->fillHist("gen", objTypeStr, "MaxPt2", pt);
559  ++(countobjects[objType]);
560  ++counttotal;
561  }
562  else if (countobjects[objType] == 2 && !_drop_pt3) {
563  this->fillHist("gen", objTypeStr, "MaxPt3", pt);
564  ++(countobjects[objType]);
565  ++counttotal;
566  }
567  else {
568  // Already the minimum three objects has been filled, get out...
569  if (counttotal == totalobjectssize) {
570  size_t max_size = matchesGen.size();
571  for ( size_t jj = j; jj < max_size; jj++ ) {
572  matchesGen.erase(matchesGen.end());
573  }
574  break;
575  }
576  }
577 
578  float eta = matchesGen[j].eta();
579  float phi = matchesGen[j].phi();
580 
581  this->fillHist("gen", objTypeStr, "Eta", eta);
582  this->fillHist("gen", objTypeStr, "Phi", phi);
583 
584  // If the target is electron or muon,
585 
586  if ( objType == EVTColContainer::MUON ||
587  objType == EVTColContainer::ELEC ) {
588  const math::XYZPoint & vtx = matchesGen[j].vertex();
589  float momphi = matchesGen[j].momentum().phi();
590  float dxyGen = (-(vtx.x()-cols->bs->x0())*sin(momphi)+(vtx.y()-cols->bs->y0())*cos(momphi));
591  dxys.push_back(dxyGen);
592  this->fillHist("gen", objTypeStr, "Dxy", dxyGen);
593  }
594 
595  } // Closes loop in gen
596 
597  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
598  //const std::string source = "gen";
599  for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
600  const std::string hltPath = _shortpath2long[an->gethltpath()];
601  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
602  LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
603  an->analyze(ispassTrigger, "gen", matchesGen, theSumEt, dxys);
604  LogDebug("ExoticaValidation") << " called the plotter";
605  }
606  }
607 
611 
612  {
613  if(matchesReco.size() < _minCandidates) return; // FIXME: A bug is potentially here: what about the mixed channels?
614 
615  // Okay, there are enough candidates. Move on!
616 
617  // Filling the gen/reco objects (eff-denominators):
618  // Just the first two different ones, if there are more
619  // The countobjects maps uints (object types, really) --> integers.
620  // Example:
621  // | uint | int |
622  // | 0 | 1 | --> 1 muon used
623  // | 1 | 2 | --> 2 electrons used
624  // Initializing the count of the used objects.
625  //std::map<unsigned int, int> * countobjects = new std::map<unsigned int, int>;
626  std::map<unsigned int, int> countobjects;
627  for (std::map<unsigned int, edm::InputTag>::iterator co = _recLabels.begin();
628  co != _recLabels.end(); ++co) {
629  countobjects.insert(std::pair<unsigned int, int>(co->first, 0));
630  }
631 
632  int counttotal = 0;
633 
634  // 3 : pt1, pt2, pt3
635  int totalobjectssize = 1;
636  if (!_drop_pt2) totalobjectssize++;
637  if (!_drop_pt3) totalobjectssize++;
638  totalobjectssize *= countobjects.size();
639 
641  //std::cout << "Our RECO vector has matchesReco.size() = " << matchesReco.size() << std::endl;
642 
643  std::vector<float> dxys; dxys.clear();
644 
645  bool isPassedLeadingCut = true;
646  // We will proceed only when cuts for the pt-leading are satisified.
647  for (size_t j = 0; j != matchesReco.size(); ++j) {
648  const unsigned int objType = matchesReco[j].pdgId();
649  // Cut for the pt-leading object
651  if ( !select( matchesReco[j] ) ) { // No interest case
652  isPassedLeadingCut = false; // Will skip the following matchesReco loop
653  matchesReco.clear();
654  break;
655  }
656  }
657 
658  for (size_t j = 0; ( j != matchesReco.size() ) && isPassedLeadingCut; ++j) {
659  const unsigned int objType = matchesReco[j].pdgId();
660  //std::cout << "(4) Gonna call with " << objType << std::endl;
661  const std::string objTypeStr = EVTColContainer::getTypeString(objType);
662 
663  float pt = matchesReco[j].pt();
664 
665  if (countobjects[objType] == 0) {
666  this->fillHist("rec", objTypeStr, "MaxPt1", pt);
667  ++(countobjects[objType]);
668  ++counttotal;
669  }
670  else if (countobjects[objType] == 1 && !_drop_pt2) {
671  if( ! ( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
672  this->fillHist("rec", objTypeStr, "MaxPt2", pt);
673  }
674  ++(countobjects[objType]);
675  ++counttotal;
676  }
677  else if (countobjects[objType] == 2 && !_drop_pt3) {
678  if( ! ( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
679  this->fillHist("rec", objTypeStr, "MaxPt3", pt);
680  }
681  ++(countobjects[objType]);
682  ++counttotal;
683  }
684  else {
685  // Already the minimum three objects has been filled, get out...
686  if (counttotal == totalobjectssize) {
687  size_t max_size = matchesReco.size();
688  for ( size_t jj = j; jj < max_size; jj++ ) {
689  matchesReco.erase(matchesReco.end());
690  }
691  break;
692  }
693  }
694 
695  float eta = matchesReco[j].eta();
696  float phi = matchesReco[j].phi();
697 
698  if ( !( TString(objTypeStr).Contains("MET") || TString(objTypeStr).Contains("MHT") ) ) {
699  this->fillHist("rec", objTypeStr, "Eta", eta);
700  this->fillHist("rec", objTypeStr, "Phi", phi);
701  }
702  else {
703  this->fillHist("rec", objTypeStr, "SumEt", theSumEt[objType]);
704  }
705 
706  if (trkObjs[objType].size()>=j+1) {
707  float dxyRec = trkObjs[objType].at(j)->dxy(cols->bs->position());
708  this->fillHist("rec", objTypeStr, "Dxy", dxyRec);
709  dxys.push_back(dxyRec);
710  }
711 
712  } // Closes loop in reco
713 
714  //LogDebug("ExoticaValidation") << " deleting countobjects";
715  //delete countobjects;
716 
717  // Calling to the plotters analysis (where the evaluation of the different trigger paths are done)
718  //const std::string source = "reco";
719  for (std::vector<HLTExoticaPlotter>::iterator an = _plotters.begin(); an != _plotters.end(); ++an) {
720  const std::string hltPath = _shortpath2long[an->gethltpath()];
721  const bool ispassTrigger = cols->triggerResults->accept(trigNames.triggerIndex(hltPath));
722  LogDebug("ExoticaValidation") << " preparing to call the plotters analysis";
723  an->analyze(ispassTrigger, "rec", matchesReco, theSumEt, dxys);
724  LogDebug("ExoticaValidation") << " called the plotter";
725  }
726  }
727 
728 }
729 
730 
731 // Return the objects (muons,electrons,photons,...) needed by a hlt path.
732 const std::vector<unsigned int> HLTExoticaSubAnalysis::getObjectsType(const std::string & hltPath) const
733 {
734  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getObjectsType()";
735 
736  static const unsigned int objSize = 15;
737  static const unsigned int objtriggernames[] = {
753  };
754 
755  std::set<unsigned int> objsType;
756  // The object to deal has to be entered via the config .py
757  for (unsigned int i = 0; i < objSize; ++i) {
758  //std::cout << "(5) Gonna call with " << objtriggernames[i] << std::endl;
759  std::string objTypeStr = EVTColContainer::getTypeString(objtriggernames[i]);
760  // Check if it is needed this object for this trigger
761  if (! TString(hltPath).Contains(objTypeStr)) {
762  continue;
763  }
764 
765  objsType.insert(objtriggernames[i]);
766  }
767 
768  return std::vector<unsigned int>(objsType.begin(), objsType.end());
769 }
770 
771 // Booking the maps: recLabels and genParticle selectors
773 {
774  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getNamesOfObjects()";
775 
776  if (anpset.exists("recMuonLabel")) {
777  _recLabels[EVTColContainer::MUON] = anpset.getParameter<edm::InputTag>("recMuonLabel");
779  }
780  if (anpset.exists("recMuonTrkLabel")) {
781  _recLabels[EVTColContainer::MUTRK] = anpset.getParameter<edm::InputTag>("recMuonTrkLabel");
783  }
784  if (anpset.exists("recTrackLabel")) {
785  _recLabels[EVTColContainer::TRACK] = anpset.getParameter<edm::InputTag>("recTrackLabel");
787  }
788  if (anpset.exists("recElecLabel")) {
789  _recLabels[EVTColContainer::ELEC] = anpset.getParameter<edm::InputTag>("recElecLabel");
791  }
792  if (anpset.exists("recPhotonLabel")) {
793  _recLabels[EVTColContainer::PHOTON] = anpset.getParameter<edm::InputTag>("recPhotonLabel");
795  }
796  if (anpset.exists("recMETLabel")) {
797  _recLabels[EVTColContainer::MET] = anpset.getParameter<edm::InputTag>("recMETLabel");
799  }
800  if (anpset.exists("recPFMETLabel")) {
801  _recLabels[EVTColContainer::PFMET] = anpset.getParameter<edm::InputTag>("recPFMETLabel");
803  }
804  if (anpset.exists("recPFMHTLabel")) {
805  _recLabels[EVTColContainer::PFMHT] = anpset.getParameter<edm::InputTag>("recPFMHTLabel");
807  }
808  if (anpset.exists("genMETLabel")) {
811  }
812  if (anpset.exists("recCaloMETLabel")) {
813  _recLabels[EVTColContainer::CALOMET] = anpset.getParameter<edm::InputTag>("recCaloMETLabel");
815  }
816  if (anpset.exists("recCaloMHTLabel")) {
817  _recLabels[EVTColContainer::CALOMHT] = anpset.getParameter<edm::InputTag>("recCaloMHTLabel");
819  }
820  if (anpset.exists("hltMETLabel")) {
823  }
824  if (anpset.exists("l1METLabel")) {
827  }
828  if (anpset.exists("recPFTauLabel")) {
829  _recLabels[EVTColContainer::PFTAU] = anpset.getParameter<edm::InputTag>("recPFTauLabel");
831  }
832  if (anpset.exists("recPFJetLabel")) {
833  _recLabels[EVTColContainer::PFJET] = anpset.getParameter<edm::InputTag>("recPFJetLabel");
835  }
836  if (anpset.exists("recCaloJetLabel")) {
837  _recLabels[EVTColContainer::CALOJET] = anpset.getParameter<edm::InputTag>("recCaloJetLabel");
839  }
840 
841  if (_recLabels.size() < 1) {
842  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getNamesOfObjects, "
843  << "Not included any object (recMuonLabel, recElecLabel, ...) "
844  << "in the analysis " << _analysisname;
845  return;
846  }
847 }
848 
849 // Register consumption of objects.
850 // I have chosen to centralize all consumes() calls here.
852 {
853  // Register that we are getting genParticles
855 
856  // Register that we are getting the trigger results
858 
859  // Register beamspot
861 
862  // Loop over _recLabels, see what we need, and register.
863  // Then save the registered token in _tokens.
864  // Remember: _recLabels is a map<uint, edm::InputTag>
865  // Remember: _tokens is a map<uint, edm::EDGetToken>
866  LogDebug("ExoticaValidation") << "We have got " << _recLabels.size() << "recLabels";
867  for (std::map<unsigned int, edm::InputTag>::iterator it = _recLabels.begin();
868  it != _recLabels.end(); ++it) {
869  if (it->first == EVTColContainer::MUON) {
870  edm::EDGetTokenT<reco::MuonCollection> particularToken = iC.consumes<reco::MuonCollection>(it->second);
871  edm::EDGetToken token(particularToken);
872  _tokens[it->first] = token;
873  }
874  else if (it->first == EVTColContainer::MUTRK) {
876  edm::EDGetToken token(particularToken);
877  _tokens[it->first] = token;
878  }
879  else if (it->first == EVTColContainer::TRACK) {
881  edm::EDGetToken token(particularToken);
882  _tokens[it->first] = token;
883  }
884  else if (it->first == EVTColContainer::ELEC) {
886  edm::EDGetToken token(particularToken);
887  _tokens[it->first] = token;
888  }
889  else if (it->first == EVTColContainer::PHOTON) {
891  edm::EDGetToken token(particularToken);
892  _tokens[it->first] = token;
893  }
894  else if (it->first == EVTColContainer::MET) {
895  edm::EDGetTokenT<reco::METCollection> particularToken = iC.consumes<reco::METCollection>(it->second);
896  edm::EDGetToken token(particularToken);
897  _tokens[it->first] = token;
898  }
899  else if (it->first == EVTColContainer::PFMET) {
901  edm::EDGetToken token(particularToken);
902  _tokens[it->first] = token;
903  }
904  else if (it->first == EVTColContainer::PFMHT) {
906  edm::EDGetToken token(particularToken);
907  _tokens[it->first] = token;
908  }
909  else if (it->first == EVTColContainer::GENMET) {
911  edm::EDGetToken token(particularToken);
912  _tokens[it->first] = token;
913  }
914  else if (it->first == EVTColContainer::CALOMET) {
916  edm::EDGetToken token(particularToken);
917  _tokens[it->first] = token;
918  }
919  else if (it->first == EVTColContainer::CALOMHT) {
921  edm::EDGetToken token(particularToken);
922  _tokens[it->first] = token;
923  }
924  else if (it->first == EVTColContainer::L1MET) {
926  edm::EDGetToken token(particularToken);
927  _tokens[it->first] = token;
928  }
929  else if (it->first == EVTColContainer::PFTAU) {
931  edm::EDGetToken token(particularToken);
932  _tokens[it->first] = token;
933  }
934  else if (it->first == EVTColContainer::PFJET) {
936  edm::EDGetToken token(particularToken);
937  _tokens[it->first] = token;
938  }
939  else if (it->first == EVTColContainer::CALOJET) {
941  edm::EDGetToken token(particularToken);
942  _tokens[it->first] = token;
943  }
944  else {
945  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::registerConsumes"
946  << " NOT IMPLEMENTED (yet) ERROR: '" << it->second.label() << "'";
947  }
948  }
949 
950 }
951 
952 // Setting the collections of objects in EVTColContainer
954 {
955  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::getHandlesToObjects()";
956 
957  if (! col->isCommonInit()) {
958  // Extract the trigger results (path info, pass,...)
960  iEvent.getByToken(_trigResultsToken, trigResults);
961  if (trigResults.isValid()) {
962  col->triggerResults = trigResults.product();
963  LogDebug("ExoticaValidation") << "Added handle to triggerResults";
964  }
965 
966  // Extract the genParticles
968  iEvent.getByToken(_genParticleToken, genPart);
969  if (genPart.isValid()) {
970  col->genParticles = genPart.product();
971  LogDebug("ExoticaValidation") << "Added handle to genParticles";
972  }
973 
974  // BeamSpot for dxy
976  iEvent.getByToken(_bsToken, bsHandle);
977  if (bsHandle.isValid()) {
978  col->bs = bsHandle.product();
979  }
980  }
981 
982  // Loop over the tokens and extract all other objects
983  LogDebug("ExoticaValidation") << "We have got " << _tokens.size() << "tokens";
984  for (std::map<unsigned int, edm::EDGetToken>::iterator it = _tokens.begin();
985  it != _tokens.end(); ++it) {
986  if (it->first == EVTColContainer::MUON) {
988  iEvent.getByToken(it->second, theHandle);
989  if (theHandle.isValid()) col->set(theHandle.product());
990  }
991  else if (it->first == EVTColContainer::MUTRK) {
993  iEvent.getByToken(it->second, theHandle);
994  if (theHandle.isValid()) col->set(theHandle.product());
995  }
996  else if (it->first == EVTColContainer::TRACK) {
998  iEvent.getByToken(it->second, theHandle);
999  if (theHandle.isValid()) col->set(theHandle.product());
1000  }
1001  else if (it->first == EVTColContainer::ELEC) {
1003  iEvent.getByToken(it->second, theHandle);
1004  if (theHandle.isValid()) col->set(theHandle.product());
1005  }
1006  else if (it->first == EVTColContainer::PHOTON) {
1008  iEvent.getByToken(it->second, theHandle);
1009  if (theHandle.isValid()) col->set(theHandle.product());
1010  }
1011  else if (it->first == EVTColContainer::MET) {
1013  iEvent.getByToken(it->second, theHandle);
1014  if (theHandle.isValid()) col->set(theHandle.product());
1015  }
1016  else if (it->first == EVTColContainer::PFMET) {
1018  iEvent.getByToken(it->second, theHandle);
1019  if (theHandle.isValid()) col->set(theHandle.product());
1020  }
1021  else if (it->first == EVTColContainer::PFMHT) {
1023  iEvent.getByToken(it->second, theHandle);
1024  if (theHandle.isValid()) col->setPFMHT(theHandle.product());
1025  }
1026  else if (it->first == EVTColContainer::GENMET) {
1028  iEvent.getByToken(it->second, theHandle);
1029  if (theHandle.isValid()) col->set(theHandle.product());
1030  }
1031  else if (it->first == EVTColContainer::CALOMET) {
1033  iEvent.getByToken(it->second, theHandle);
1034  if (theHandle.isValid()) col->set(theHandle.product());
1035  }
1036  else if (it->first == EVTColContainer::CALOMHT) {
1038  iEvent.getByToken(it->second, theHandle);
1039  if (theHandle.isValid()) col->setCaloMHT(theHandle.product());
1040  }
1041  else if (it->first == EVTColContainer::L1MET) {
1043  iEvent.getByToken(it->second, theHandle);
1044  if (theHandle.isValid()) col->set(theHandle.product());
1045  }
1046  else if (it->first == EVTColContainer::PFTAU) {
1048  iEvent.getByToken(it->second, theHandle);
1049  if (theHandle.isValid()) col->set(theHandle.product());
1050  }
1051  else if (it->first == EVTColContainer::PFJET) {
1053  iEvent.getByToken(it->second, theHandle);
1054  if (theHandle.isValid()) col->set(theHandle.product());
1055  }
1056  else if (it->first == EVTColContainer::CALOJET) {
1058  iEvent.getByToken(it->second, theHandle);
1059  if (theHandle.isValid()) col->set(theHandle.product());
1060  }
1061  else {
1062  edm::LogError("ExoticaValidation") << "HLTExoticaSubAnalysis::getHandlesToObjects "
1063  << " NOT IMPLEMENTED (yet) ERROR: '" << it->first << "'";
1064  }
1065  }
1066 }
1067 
1068 // Booking the histograms, and putting them in DQM
1070  const std::string & source,
1071  const std::string & objType,
1072  const std::string & variable)
1073 {
1074  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::bookHist()";
1075  std::string sourceUpper = source;
1076  sourceUpper[0] = std::toupper(sourceUpper[0]);
1077  std::string name = source + objType + variable ;
1078  TH1F * h = 0;
1079 
1080  if (variable.find("SumEt") != std::string::npos) {
1081  std::string title = "Sum ET of " + sourceUpper + " " + objType;
1082  const size_t nBins = _parametersTurnOnSumEt.size() - 1;
1083  float * edges = new float[nBins + 1];
1084  for (size_t i = 0; i < nBins + 1; i++) {
1085  edges[i] = _parametersTurnOnSumEt[i];
1086  }
1087  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1088  delete[] edges;
1089  }
1090 
1091  else if (variable.find("Dxy") != std::string::npos) {
1092  std::string title = "Dxy " + sourceUpper + " " + objType;
1093  int nBins = _parametersDxy[0];
1094  double min = _parametersDxy[1];
1095  double max = _parametersDxy[2];
1096  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1097  }
1098 
1099  else if (variable.find("MaxPt") != std::string::npos) {
1100  std::string desc = (variable == "MaxPt1") ? "Leading" : "Next-to-Leading";
1101  std::string title = "pT of " + desc + " " + sourceUpper + " " + objType;
1102  const size_t nBins = _parametersTurnOn.size() - 1;
1103  float * edges = new float[nBins + 1];
1104  for (size_t i = 0; i < nBins + 1; i++) {
1105  edges[i] = _parametersTurnOn[i];
1106  }
1107  h = new TH1F(name.c_str(), title.c_str(), nBins, edges);
1108  delete[] edges;
1109  }
1110 
1111  else {
1112  std::string symbol = (variable == "Eta") ? "#eta" : "#phi";
1113  std::string title = symbol + " of " + sourceUpper + " " + objType;
1114  std::vector<double> params = (variable == "Eta") ? _parametersEta : _parametersPhi;
1115  int nBins = (int)params[0];
1116  double min = params[1];
1117  double max = params[2];
1118  h = new TH1F(name.c_str(), title.c_str(), nBins, min, max);
1119  }
1120 
1121  h->Sumw2();
1122  // This is the trick, that takes a normal TH1F and puts it in in the DQM
1123  // machinery. Seems to be easy!
1124  // Updated to use the new iBooker machinery.
1125  _elements[name] = iBooker.book1D(name, h);
1126  delete h;
1127 }
1128 
1129 // Fill the histograms
1131  const std::string & objType,
1132  const std::string & variable,
1133  const float & value)
1134 {
1135  std::string sourceUpper = source;
1136  sourceUpper[0] = toupper(sourceUpper[0]);
1137  std::string name = source + objType + variable ;
1138 
1139  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " " << value;
1140  _elements[name]->Fill(value);
1141  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::fillHist() " << name << " worked";
1142 }
1143 
1144 // Initialize the selectors
1145 void HLTExoticaSubAnalysis::initSelector(const unsigned int & objtype)
1146 {
1147 
1148  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::initSelector()";
1149 
1150  if (objtype == EVTColContainer::MUON && _recMuonSelector == 0) {
1152  } else if (objtype == EVTColContainer::MUTRK && _recMuonTrkSelector == 0) {
1154  } else if (objtype == EVTColContainer::TRACK && _recTrackSelector == 0) {
1156  } else if (objtype == EVTColContainer::ELEC && _recElecSelector == 0) {
1158  } else if (objtype == EVTColContainer::PHOTON && _recPhotonSelector == 0) {
1160  } else if (objtype == EVTColContainer::MET && _recMETSelector == 0) {
1162  } else if (objtype == EVTColContainer::PFMET && _recPFMETSelector == 0) {
1164  } else if (objtype == EVTColContainer::PFMHT && _recPFMHTSelector == 0) {
1166  } else if (objtype == EVTColContainer::GENMET && _genMETSelector == 0) {
1168  } else if (objtype == EVTColContainer::CALOMET && _recCaloMETSelector == 0) {
1170  } else if (objtype == EVTColContainer::CALOMHT && _recCaloMHTSelector == 0) {
1172  } else if (objtype == EVTColContainer::L1MET && _l1METSelector == 0) {
1174  } else if (objtype == EVTColContainer::PFTAU && _recPFTauSelector == 0) {
1176  } else if (objtype == EVTColContainer::PFJET && _recPFJetSelector == 0) {
1178  } else if (objtype == EVTColContainer::CALOJET && _recCaloJetSelector == 0) {
1180  }
1181  /* else
1182  {
1183  FIXME: ERROR NOT IMPLEMENTED
1184  }*/
1185 }
1186 
1187 // Insert the HLT candidates
1188 void HLTExoticaSubAnalysis::insertCandidates(const unsigned int & objType, const EVTColContainer * cols, std::vector<reco::LeafCandidate> * matches,
1189  std::map<int,double> & theSumEt, std::map<int,std::vector<const reco::Track*> > & trkObjs )
1190 {
1191 
1192  LogDebug("ExoticaValidation") << "In HLTExoticaSubAnalysis::insertCandidates()";
1193 
1194  theSumEt[objType] = -1;
1195 
1196  if (objType == EVTColContainer::MUON) {
1197  for (size_t i = 0; i < cols->muons->size(); i++) {
1198  LogDebug("ExoticaValidation") << "Inserting muon " << i ;
1199  if (_recMuonSelector->operator()(cols->muons->at(i))) {
1200  reco::LeafCandidate m(0, cols->muons->at(i).p4(), cols->muons->at(i).vertex(), objType, 0, true);
1201  matches->push_back(m);
1202 
1203  // for making dxy plots
1204  trkObjs[objType].push_back(cols->muons->at(i).bestTrack());
1205  }
1206  }
1207  } else if (objType == EVTColContainer::MUTRK) {
1208  for (size_t i = 0; i < cols->tracks->size(); i++) {
1209  LogDebug("ExoticaValidation") << "Inserting muonTrack " << i ;
1210  if (_recMuonTrkSelector->operator()(cols->tracks->at(i))) {
1211  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1212  ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1213  mom4.SetXYZT(mom3.x(),mom3.y(),mom3.z(),mom3.r());
1214  reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1215  matches->push_back(m);
1216  }
1217  }
1218  } else if (objType == EVTColContainer::TRACK) {
1219  for (size_t i = 0; i < cols->tracks->size(); i++) {
1220  LogDebug("ExoticaValidation") << "Inserting Track " << i ;
1221  if (_recTrackSelector->operator()(cols->tracks->at(i))) {
1222  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> mom4;
1223  ROOT::Math::XYZVector mom3 = cols->tracks->at(i).momentum();
1224  mom4.SetXYZT(mom3.x(),mom3.y(),mom3.z(),mom3.r());
1225  reco::LeafCandidate m(0, mom4, cols->tracks->at(i).vertex(), objType, 0, true);
1226  matches->push_back(m);
1227  }
1228  }
1229  } else if (objType == EVTColContainer::ELEC) {
1230  for (size_t i = 0; i < cols->electrons->size(); i++) {
1231  LogDebug("ExoticaValidation") << "Inserting electron " << i ;
1232  if (_recElecSelector->operator()(cols->electrons->at(i))) {
1233  reco::LeafCandidate m(0, cols->electrons->at(i).p4(), cols->electrons->at(i).vertex(), objType, 0, true);
1234  matches->push_back(m);
1235 
1236  // for making dxy plots
1237  trkObjs[objType].push_back(cols->electrons->at(i).bestTrack());
1238  }
1239  }
1240  } else if (objType == EVTColContainer::PHOTON) {
1241  for (size_t i = 0; i < cols->photons->size(); i++) {
1242  LogDebug("ExoticaValidation") << "Inserting photon " << i ;
1243  if (_recPhotonSelector->operator()(cols->photons->at(i))) {
1244  reco::LeafCandidate m(0, cols->photons->at(i).p4(), cols->photons->at(i).vertex(), objType, 0, true);
1245  matches->push_back(m);
1246  }
1247  }
1248  } else if (objType == EVTColContainer::PFMET) {
1252  for (size_t i = 0; i < cols->pfMETs->size(); i++) {
1253  LogDebug("ExoticaValidation") << "Inserting PFMET " << i ;
1254  if (_recPFMETSelector->operator()(cols->pfMETs->at(i))) {
1255  reco::LeafCandidate m(0, cols->pfMETs->at(i).p4(), cols->pfMETs->at(i).vertex(), objType, 0, true);
1256  matches->push_back(m);
1257  if(i==0) theSumEt[objType] = cols->pfMETs->at(i).sumEt();
1258  }
1259  }
1260  } else if (objType == EVTColContainer::PFMHT) {
1261  for (size_t i = 0; i < cols->pfMHTs->size(); i++) {
1262  LogDebug("ExoticaValidation") << "Inserting PFMHT " << i ;
1263  if (_recPFMHTSelector->operator()(cols->pfMHTs->at(i))) {
1264  reco::LeafCandidate m(0, cols->pfMHTs->at(i).p4(), cols->pfMHTs->at(i).vertex(), objType, 0, true);
1265  matches->push_back(m);
1266  if(i==0) theSumEt[objType] = cols->pfMHTs->at(i).sumEt();
1267  }
1268  }
1269  } else if (objType == EVTColContainer::GENMET) {
1270  for (size_t i = 0; i < cols->genMETs->size(); i++) {
1271  LogDebug("ExoticaValidation") << "Inserting GENMET " << i ;
1272  if (_genMETSelector->operator()(cols->genMETs->at(i))) {
1273  reco::LeafCandidate m(0, cols->genMETs->at(i).p4(), cols->genMETs->at(i).vertex(), objType, 0, true);
1274  matches->push_back(m);
1275  if(i==0) theSumEt[objType] = cols->genMETs->at(i).sumEt();
1276  }
1277  }
1278  } else if (objType == EVTColContainer::CALOMET) {
1279  for (size_t i = 0; i < cols->caloMETs->size(); i++) {
1280  LogDebug("ExoticaValidation") << "Inserting CALOMET " << i ;
1281  if (_recCaloMETSelector->operator()(cols->caloMETs->at(i))) {
1282  reco::LeafCandidate m(0, cols->caloMETs->at(i).p4(), cols->caloMETs->at(i).vertex(), objType, 0, true);
1283  matches->push_back(m);
1284  if(i==0) theSumEt[objType] = cols->caloMETs->at(i).sumEt();
1285  }
1286  }
1287  } else if (objType == EVTColContainer::CALOMHT) {
1288  for (size_t i = 0; i < cols->caloMHTs->size(); i++) {
1289  LogDebug("ExoticaValidation") << "Inserting CaloMHT " << i ;
1290  if (_recCaloMHTSelector->operator()(cols->caloMHTs->at(i))) {
1291  reco::LeafCandidate m(0, cols->caloMHTs->at(i).p4(), cols->caloMHTs->at(i).vertex(), objType, 0, true);
1292  matches->push_back(m);
1293  if(i==0) theSumEt[objType] = cols->caloMHTs->at(i).sumEt();
1294  }
1295  }
1296  } else if (objType == EVTColContainer::L1MET) {
1297  for (size_t i = 0; i < cols->l1METs->size(); i++) {
1298  LogDebug("ExoticaValidation") << "Inserting L1MET " << i ;
1299  if (_l1METSelector->operator()(cols->l1METs->at(i))) {
1300  reco::LeafCandidate m(0, cols->l1METs->at(i).p4(), cols->l1METs->at(i).vertex(), objType, 0, true);
1301  matches->push_back(m);
1302  if(i==0) theSumEt[objType] = cols->l1METs->at(i).etTotal();
1303  }
1304  }
1305  } else if (objType == EVTColContainer::PFTAU) {
1306  for (size_t i = 0; i < cols->pfTaus->size(); i++) {
1307  LogDebug("ExoticaValidation") << "Inserting PFtau " << i ;
1308  if (_recPFTauSelector->operator()(cols->pfTaus->at(i))) {
1309  reco::LeafCandidate m(0, cols->pfTaus->at(i).p4(), cols->pfTaus->at(i).vertex(), objType, 0, true);
1310  matches->push_back(m);
1311  }
1312  }
1313  } else if (objType == EVTColContainer::PFJET) {
1314  for (size_t i = 0; i < cols->pfJets->size(); i++) {
1315  LogDebug("ExoticaValidation") << "Inserting jet " << i ;
1316  if (_recPFJetSelector->operator()(cols->pfJets->at(i))) {
1317  reco::LeafCandidate m(0, cols->pfJets->at(i).p4(), cols->pfJets->at(i).vertex(), objType, 0, true);
1318  matches->push_back(m);
1319  }
1320  }
1321  } else if (objType == EVTColContainer::CALOJET) {
1322  for (size_t i = 0; i < cols->caloJets->size(); i++) {
1323  LogDebug("ExoticaValidation") << "Inserting jet " << i ;
1324  if (_recCaloJetSelector->operator()(cols->caloJets->at(i))) {
1325  reco::LeafCandidate m(0, cols->caloJets->at(i).p4(), cols->caloJets->at(i).vertex(), objType, 0, true);
1326  matches->push_back(m);
1327  }
1328  }
1329  }
1330 
1331  /* else
1332  {
1333  FIXME: ERROR NOT IMPLEMENTED
1334  }*/
1335 }
1336 
1338  // Dump trigger results
1339  std::stringstream log;
1340  log << std::endl;
1341  log << "===========================================================================" << std::endl;
1342  log << " Trigger Results ( " << _analysisname << " ) " << std::endl;
1343  log << "===========================================================================" << std::endl;
1344  log << std::setw(18) << "# of passed events : HLT path names" << std::endl;
1345  log << "-------------------:-------------------------------------------------------" << std::endl;
1346  for (std::map<std::string,int>::iterator it = _triggerCounter.begin();
1347  it != _triggerCounter.end(); ++it) {
1348  log << std::setw(18) << it->second << " : " << it->first << std::endl;
1349  }
1350  log << "===========================================================================" << std::endl;
1351  LogDebug("ExoticaValidation") << log.str().data();
1352 }
#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
std::map< std::string, int > _triggerCounter
counting HLT passed events
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
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)
U second(std::pair< T, U > const &p)
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
Container::value_type value_type
std::vector< std::string > _hltPathsToCheck
The hlt paths to check for.
#define LogTrace(id)
StringCutObjectSelector< reco::CaloMET > * _recCaloMHTSelector
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
const std::vector< reco::CaloMET > * caloMHTs
edm::EDGetTokenT< reco::GenParticleCollection > _genParticleToken
And also the tokens to get the object collections.
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
volatile std::atomic< bool > shutdown_flag false
std::vector< double > _parametersTurnOnSumEt
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 setCaloMHT(const reco::CaloMETCollection *v)
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
tuple log
Definition: cmsBatch.py:347
Definition: DDAxes.h:10