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