CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EmDQMReco.cc
Go to the documentation of this file.
1 // Header file for this //
5 
7 // Collaborating Class Header //
15 //#include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
16 //#include "DataFormats/EgammaCandidates/interface/Photon.h"
19 //#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
23 
27 //#include "PhysicsTools/UtilAlgos/interface/TFileService.h"
33 #include <boost/format.hpp>
35 // Root include files //
37 #include "TFile.h"
38 #include "TDirectory.h"
39 #include "TH1F.h"
40 #include <iostream>
41 #include <string>
42 #include <Math/VectorUtil.h>
43 using namespace ROOT::Math::VectorUtil ;
44 
45 //----------------------------------------------------------------------
46 // class EmDQMReco::FourVectorMonitorElements
47 //----------------------------------------------------------------------
49  DQMStore::IBooker &iBooker,
50  const std::string &histogramNameTemplate,
51  const std::string &histogramTitleTemplate
52  ) :
53  parent(_parent)
54 {
55  // introducing variables for better code readability later on
56  std::string histName;
57  std::string histTitle;
58 
59  // et
60  histName = boost::str(boost::format(histogramNameTemplate) % "et");
61  histTitle = boost::str(boost::format(histogramTitleTemplate) % "E_{T}");
62  etMonitorElement = iBooker.book1D(histName.c_str(),
63  histTitle.c_str(),
66  parent->plotPtMax);
67 
68  // eta
69  histName = boost::str(boost::format(histogramNameTemplate) % "eta");
70  histTitle= boost::str(boost::format(histogramTitleTemplate) % "#eta");
71  etaMonitorElement = iBooker.book1D(histName.c_str(),
72  histTitle.c_str(),
74  - parent->plotEtaMax,
76 
77  // phi
78  histName = boost::str(boost::format(histogramNameTemplate) % "phi");
79  histTitle= boost::str(boost::format(histogramTitleTemplate) % "#phi");
80  phiMonitorElement = iBooker.book1D(histName.c_str(),
81  histTitle.c_str(),
83  - parent->plotPhiMax,
85 }
86 
87 //----------------------------------------------------------------------
88 
89 void
91 {
92  etMonitorElement->Fill(momentum.Et());
93  etaMonitorElement->Fill(momentum.eta() );
94  phiMonitorElement->Fill(momentum.phi() );
95 }
96 
97 //----------------------------------------------------------------------
98 
100 // Constructor //
103 {
105  // Read from configuration file //
107  dirname_="HLT/HLTEgammaValidation/"+pset.getParameter<std::string>("@module_label");
108 
109  // parameters for generator study
110  reqNum = pset.getParameter<unsigned int>("reqNum");
111  pdgGen = pset.getParameter<int>("pdgGen");
112  recoEtaAcc = pset.getParameter<double>("genEtaAcc");
113  recoEtAcc = pset.getParameter<double>("genEtAcc");
114  // plotting parameters (untracked because they don't affect the physics)
115  plotPtMin = pset.getUntrackedParameter<double>("PtMin",0.);
116  plotPtMax = pset.getUntrackedParameter<double>("PtMax",1000.);
117  plotEtaMax = pset.getUntrackedParameter<double>("EtaMax", 2.7);
118  plotPhiMax = pset.getUntrackedParameter<double>("PhiMax", 3.15);
119  plotBins = pset.getUntrackedParameter<unsigned int>("Nbins",50);
120  useHumanReadableHistTitles = pset.getUntrackedParameter<bool>("useHumanReadableHistTitles", false);
121 
122  triggerNameRecoMonPath = pset.getUntrackedParameter<std::string>("triggerNameRecoMonPath","HLT_MinBias");
123  processNameRecoMonPath = pset.getUntrackedParameter<std::string>("processNameRecoMonPath","HLT");
124 
125  recoElectronsInput = consumes<reco::GsfElectronCollection>(pset.getUntrackedParameter<edm::InputTag>("recoElectrons",edm::InputTag("gsfElectrons")));
126  recoObjectsEBT = consumes<std::vector<reco::SuperCluster>>(edm::InputTag("correctedHybridSuperClusters"));
127  recoObjectsEET = consumes<std::vector<reco::SuperCluster>>(edm::InputTag("correctedMulti5x5SuperClustersWithPreshower"));
128  hltResultsT = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults","",processNameRecoMonPath));
129  triggerObjT = consumes<trigger::TriggerEventWithRefs>(edm::InputTag("hltTriggerSummaryRAW"));
130 
131  // preselction cuts
132  // recocutCollection_= pset.getParameter<edm::InputTag>("cutcollection");
133  recocut_ = pset.getParameter<int>("cutnum");
134 
135  // prescale = 10;
136  eventnum = 0;
137 
138  // just init
139  isHltConfigInitialized_ = false;
140 
142  // Read in the Vector of Parameter Sets. //
143  // Information for each filter-step //
145  std::vector<edm::ParameterSet> filters =
146  pset.getParameter<std::vector<edm::ParameterSet> >("filters");
147 
148  int i = 0;
149  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++)
150  {
151 
152  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
153  theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
154  // Grab the human-readable name, if it is not specified, use the Collection Label
155  theHLTCollectionHumanNames.push_back(filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName",theHLTCollectionLabels[i].label()));
156 
157  std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
158  // If the size of plot "bounds" vector != 2, abort
159  assert(bounds.size() == 2);
160  plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
161  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
162 
163  for (unsigned int i=0; i<isoNames.back().size(); i++) {
164  switch(theHLTOutputTypes.back()) {
167  break;
168  case trigger::TriggerL1IsoEG: // Isolated Level 1
170  break;
171  case trigger::TriggerPhoton: // Photon
173  break;
174  case trigger::TriggerElectron: // Electron
176  break;
177  case trigger::TriggerCluster: // TriggerCluster
179  break;
180  default:
181  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
182  }
183  }
184 
185  // If the size of the isoNames vector is not greater than zero, abort
186  assert(isoNames.back().size()>0);
187  if (isoNames.back().at(0).label()=="none") {
188  plotiso.push_back(false);
189  } else {
190  plotiso.push_back(true);
191  }
192  i++;
193  } // END of loop over parameter sets
194 
195  // Record number of HLTCollectionLabels
197 
198 }
199 
203 void EmDQMReco::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup ) {
204 
205  bool isHltConfigChanged = false; // change of cfg at run boundaries?
206  isHltConfigInitialized_ = hltConfig_.init( iRun, iSetup, "HLT", isHltConfigChanged );
207 
208 }
209 
211 // book DQM histograms //
213 void
215 {
216  //edm::Service<TFileService> fs;
217  iBooker.setCurrentFolder(dirname_);
218 
220  // Set up Histogram of Effiency vs Step. //
221  // theHLTCollectionLabels is a vector of InputTags //
222  // from the configuration file. //
224 
225  std::string histName="total_eff";
226  std::string histTitle = "total events passing";
227  // This plot will have bins equal to 2+(number of
228  // HLTCollectionLabels in the config file)
229  totalreco = iBooker.book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
232  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
233 
234  histName="total_eff_RECO_matched";
235  histTitle="total events passing (Reco matched)";
236  totalmatchreco = iBooker.book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
237  totalmatchreco->setBinLabel(numOfHLTCollectionLabels+1,"Total");
238  totalmatchreco->setBinLabel(numOfHLTCollectionLabels+2,"Reco");
239  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalmatchreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
240 
241  // MonitorElement* tmphisto;
242  MonitorElement* tmpiso;
243 
245  // Set up generator-level histograms //
247  std::string pdgIdString;
248  switch(pdgGen) {
249  case 11:
250  pdgIdString="Electron";break;
251  case 22:
252  pdgIdString="Photon";break;
253  default:
254  pdgIdString="Particle";
255  }
256 
257  //--------------------
258 
259  // reco
260  // (note that reset(..) must be used to set the value of the scoped_ptr...)
261  histReco.reset(
262  new FourVectorMonitorElements(this, iBooker,
263  "reco_%s", // pattern for histogram name
264  "%s of " + pdgIdString + "s"
265  ));
266 
267  //--------------------
268 
269  // monpath
270  histRecoMonpath.reset(
271  new FourVectorMonitorElements(this, iBooker,
272  "reco_%s_monpath", // pattern for histogram name
273  "%s of " + pdgIdString + "s monpath"
274  )
275  );
276 
277  //--------------------
278 
279  // TODO: WHAT ARE THESE HISTOGRAMS FOR ? THEY SEEM NEVER REFERENCED ANYWHERE IN THIS FILE...
280  // final X monpath
281  histMonpath.reset(
282  new FourVectorMonitorElements(this, iBooker,
283  "final_%s_monpath", // pattern for histogram name
284  "Final %s Monpath"
285  )
286  );
287 
288  //--------------------
289 
291  // Set up histograms of HLT objects //
293 
294  // Determine what strings to use for histogram titles
295  std::vector<std::string> HltHistTitle;
296  if ( theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles ) {
297  HltHistTitle = theHLTCollectionHumanNames;
298  } else {
299  for (unsigned int i =0; i < numOfHLTCollectionLabels; i++) {
300  HltHistTitle.push_back(theHLTCollectionLabels[i].label());
301  }
302  }
303 
304  for(unsigned int i = 0; i< numOfHLTCollectionLabels ; i++){
305  //--------------------
306  // distributions of HLT objects passing filter i
307  //--------------------
308 
309 // // Et
310 // histName = theHLTCollectionLabels[i].label()+"et_all";
311 // histTitle = HltHistTitle[i]+" Et (ALL)";
312 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
313 // ethist.push_back(tmphisto);
314 //
315 // // Eta
316 // histName = theHLTCollectionLabels[i].label()+"eta_all";
317 // histTitle = HltHistTitle[i]+" #eta (ALL)";
318 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
319 // etahist.push_back(tmphisto);
320 //
321 // // phi
322 // histName = theHLTCollectionLabels[i].label()+"phi_all";
323 // histTitle = HltHistTitle[i]+" #phi (ALL)";
324 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
325 // phiHist.push_back(tmphisto);
326 
327  standardHist.push_back(new FourVectorMonitorElements(this, iBooker,
328  theHLTCollectionLabels[i].label()+"%s_all", // histogram name
329  HltHistTitle[i]+" %s (ALL)" // histogram title
330  ));
331 
332  //--------------------
333  // distributions of reco object matching HLT object passing filter i
334  //--------------------
335 
336  // Et
337 // histName = theHLTCollectionLabels[i].label()+"et_RECO_matched";
338 // histTitle = HltHistTitle[i]+" Et (RECO matched)";
339 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
340 // ethistmatchreco.push_back(tmphisto);
341 
342 // // Eta
343 // histName = theHLTCollectionLabels[i].label()+"eta_RECO_matched";
344 // histTitle = HltHistTitle[i]+" #eta (RECO matched)";
345 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
346 // etahistmatchreco.push_back(tmphisto);
347 //
348 // // phi
349 // histName = theHLTCollectionLabels[i].label()+"phi_RECO_matched";
350 // histTitle = HltHistTitle[i]+" #phi (RECO matched)";
351 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
352 // phiHistMatchReco.push_back(tmphisto);
353  histMatchReco.push_back(new FourVectorMonitorElements(this, iBooker,
354  theHLTCollectionLabels[i].label()+"%s_RECO_matched", // histogram name
355  HltHistTitle[i]+" %s (RECO matched)" // histogram title
356  ));
357 
358  //--------------------
359  // distributions of reco object matching HLT object passing filter i
360  //--------------------
361 
362 // // Et
363 // histName = theHLTCollectionLabels[i].label()+"et_RECO_matched_monpath";
364 // histTitle = HltHistTitle[i]+" Et (RECO matched, monpath)";
365 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
366 // ethistmatchrecomonpath.push_back(tmphisto);
367 //
368 // // Eta
369 // histName = theHLTCollectionLabels[i].label()+"eta_RECO_matched_monpath";
370 // histTitle = HltHistTitle[i]+" #eta (RECO matched, monpath)";
371 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
372 // etahistmatchrecomonpath.push_back(tmphisto);
373 //
374 // // phi
375 // histName = theHLTCollectionLabels[i].label()+"phi_RECO_matched_monpath";
376 // histTitle = HltHistTitle[i]+" #phi (RECO matched, monpath)";
377 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
378 // phiHistMatchRecoMonPath.push_back(tmphisto);
379 
380  histMatchRecoMonPath.push_back(new FourVectorMonitorElements(this, iBooker,
381  theHLTCollectionLabels[i].label()+"%s_RECO_matched_monpath", // histogram name
382  HltHistTitle[i]+" %s (RECO matched, monpath)" // histogram title
383  ));
384  //--------------------
385  // distributions of HLT object that is closest delta-R match to sorted reco particle(s)
386  //--------------------
387 
388  // Et
389 // histName = theHLTCollectionLabels[i].label()+"et_reco";
390 // histTitle = HltHistTitle[i]+" Et (reco)";
391 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
392 // histEtOfHltObjMatchToReco.push_back(tmphisto);
393 //
394 // // eta
395 // histName = theHLTCollectionLabels[i].label()+"eta_reco";
396 // histTitle = HltHistTitle[i]+" eta (reco)";
397 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
398 // histEtaOfHltObjMatchToReco.push_back(tmphisto);
399 //
400 // // phi
401 // histName = theHLTCollectionLabels[i].label()+"phi_reco";
402 // histTitle = HltHistTitle[i]+" phi (reco)";
403 // tmphisto = iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
404 // histPhiOfHltObjMatchToReco.push_back(tmphisto);
405 
406  histHltObjMatchToReco.push_back(new FourVectorMonitorElements(this, iBooker,
407  theHLTCollectionLabels[i].label()+"%s_reco", // histogram name
408  HltHistTitle[i]+" %s (reco)" // histogram title
409  ));
410 
411  //--------------------
412 
413  if (!plotiso[i]) {
414  tmpiso = NULL;
415  etahistiso.push_back(tmpiso);
416  ethistiso.push_back(tmpiso);
417  phiHistIso.push_back(tmpiso);
418 
419  etahistisomatchreco.push_back(tmpiso);
420  ethistisomatchreco.push_back(tmpiso);
421  phiHistIsoMatchReco.push_back(tmpiso);
422 
423  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
424  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
425  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
426 
427  } else {
428 
429  //--------------------
430  // 2D plot: Isolation values vs X for all objects
431  //--------------------
432 
433  // X = eta
434  histName = theHLTCollectionLabels[i].label()+"eta_isolation_all";
435  histTitle = HltHistTitle[i]+" isolation vs #eta (all)";
436  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
437  etahistiso.push_back(tmpiso);
438 
439  // X = et
440  histName = theHLTCollectionLabels[i].label()+"et_isolation_all";
441  histTitle = HltHistTitle[i]+" isolation vs Et (all)";
442  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
443  ethistiso.push_back(tmpiso);
444 
445  // X = phi
446  histName = theHLTCollectionLabels[i].label()+"phi_isolation_all";
447  histTitle = HltHistTitle[i]+" isolation vs #phi (all)";
448  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
449  phiHistIso.push_back(tmpiso);
450 
451  //--------------------
452  // 2D plot: Isolation values vs X for reco matched objects
453  //--------------------
454 
455  // X = eta
456  histName = theHLTCollectionLabels[i].label()+"eta_isolation_RECO_matched";
457  histTitle = HltHistTitle[i]+" isolation vs #eta (reco matched)";
458  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
459  etahistisomatchreco.push_back(tmpiso);
460 
461  // X = et
462  histName = theHLTCollectionLabels[i].label()+"et_isolation_RECO_matched";
463  histTitle = HltHistTitle[i]+" isolation vs Et (reco matched)";
464  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
465  ethistisomatchreco.push_back(tmpiso);
466 
467  // X = eta
468  histName = theHLTCollectionLabels[i].label()+"phi_isolation_RECO_matched";
469  histTitle = HltHistTitle[i]+" isolation vs #phi (reco matched)";
470  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
471  phiHistIsoMatchReco.push_back(tmpiso);
472 
473  //--------------------
474  // 2D plot: Isolation values vs X for HLT object that
475  // is closest delta-R match to sorted reco particle(s)
476  //--------------------
477 
478  // X = eta
479  histName = theHLTCollectionLabels[i].label()+"eta_isolation_reco";
480  histTitle = HltHistTitle[i]+" isolation vs #eta (reco)";
481  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
482  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
483 
484  // X = et
485  histName = theHLTCollectionLabels[i].label()+"et_isolation_reco";
486  histTitle = HltHistTitle[i]+" isolation vs Et (reco)";
487  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
488  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
489 
490  // X = phi
491  histName = theHLTCollectionLabels[i].label()+"phi_isolation_reco";
492  histTitle = HltHistTitle[i]+" isolation vs #phi (reco)";
493  tmpiso = iBooker.book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
494  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
495  //--------------------
496 
497  } // END of HLT histograms
498  }
499 }
500 
501 
503 // Destructor //
506 }
507 
508 
510 // method called to for each event //
512 void
514 {
515 
516  // protect from hlt config failure
517  if( !isHltConfigInitialized_ ) return;
518 
519  eventnum++;
520  bool plotMonpath = false;
521  bool plotReco = true;
522 
526 
527  if (pdgGen == 11) {
528 
529  event.getByToken(recoElectronsInput, recoObjects);
530 
531  if (recoObjects->size() < (unsigned int)recocut_) {
532  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco particles with pdgId=" << pdgGen << ". Only " << cutRecoCounter->size() << " particles.";
533  return;
534  }
535  } else if (pdgGen == 22) {
536 
537  event.getByToken(recoObjectsEBT, recoObjectsEB);
538  event.getByToken(recoObjectsEET, recoObjectsEE);
539 
540  if (recoObjectsEB->size() + recoObjectsEE->size() < (unsigned int)recocut_) {
541  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco particles with pdgId=" << pdgGen << ". Only " << cutRecoCounter.size() << " particles.";
542  return;
543  }
544  }
545 
547  event.getByToken(hltResultsT, HLTR);
548 
553 
554  /* if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt8"){
555  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG8");
556  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt5") {
557  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG5");
558  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedDoubleEgammaEt5") {
559  triggerIndex = hltConfig.triggerIndex("HLT_L1DoubleEG5");
560  } else {
561  triggerIndex = hltConfig.triggerIndex("");
562  } */
563 
564  unsigned int triggerIndex;
566 
567  //triggerIndex must be less than the size of HLTR or you get a CMSException
568  bool isFired = false;
569  if (triggerIndex < HLTR->size()){
570  isFired = HLTR->accept(triggerIndex);
571  }
572 
573  // fill L1 and HLT info
574  // get objects possed by each filter
576  event.getByToken(triggerObjT, triggerObj);
577 
578  if(!triggerObj.isValid()) {
579  edm::LogWarning("EmDQMReco") << "RAW-type HLT results not found, skipping event";
580  return;
581  }
582 
584  // Fill the bin labeled "Total" //
585  // This will be the number of events looked at. //
589 
591  // Fill the bin labeled "Total" //
592  // This will be the number of events looked at. //
594  //total->Fill(numOfHLTCollectionLabels+0.5);
595  //totalmatch->Fill(numOfHLTCollectionLabels+0.5);
596 
597 
599  // Fill reconstruction info //
601  // the recocut_ highest Et generator objects of the preselected type are our matches
602 
603  std::vector<reco::Particle> sortedReco;
604  if (plotReco == true) {
605  if (pdgGen == 11) {
606  for(edm::View<reco::Candidate>::const_iterator recopart = recoObjects->begin(); recopart != recoObjects->end();recopart++){
607  reco::Particle tmpcand( recopart->charge(), recopart->p4(), recopart->vertex(),recopart->pdgId(),recopart->status() );
608  sortedReco.push_back(tmpcand);
609  }
610  }
611  else if (pdgGen == 22) {
612  for(std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEB->begin(); recopart2 != recoObjectsEB->end();recopart2++){
613  float en = recopart2->energy();
614  float er = sqrt(pow(recopart2->x(),2) + pow(recopart2->y(),2) + pow(recopart2->z(),2) );
615  float px = recopart2->energy()*recopart2->x()/er;
616  float py = recopart2->energy()*recopart2->y()/er;
617  float pz = recopart2->energy()*recopart2->z()/er;
618  reco::Candidate::LorentzVector thisLV(px,py,pz,en);
619  reco::Particle tmpcand( 0, thisLV, math::XYZPoint(0.,0.,0.), 22, 1 );
620  sortedReco.push_back(tmpcand);
621  }
622  for(std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEE->begin(); recopart2 != recoObjectsEE->end();recopart2++){
623  float en = recopart2->energy();
624  float er = sqrt(pow(recopart2->x(),2) + pow(recopart2->y(),2) + pow(recopart2->z(),2) );
625  float px = recopart2->energy()*recopart2->x()/er;
626  float py = recopart2->energy()*recopart2->y()/er;
627  float pz = recopart2->energy()*recopart2->z()/er;
628  reco::Candidate::LorentzVector thisLV(px,py,pz,en);
629  reco::Particle tmpcand( 0, thisLV, math::XYZPoint(0.,0.,0.), 22, 1 );
630  sortedReco.push_back(tmpcand);
631  }
632  }
633 
634  std::sort(sortedReco.begin(),sortedReco.end(),pTComparator_ );
635 
636  // Now the collection of gen particles is sorted by pt.
637  // So, remove all particles from the collection so that we
638  // only have the top "1 thru recocut_" particles in it
639 
640  sortedReco.erase(sortedReco.begin()+recocut_,sortedReco.end());
641 
642  for (unsigned int i = 0 ; i < recocut_ ; i++ ) {
643  //validity has been implicitily checked by the cut on recocut_ above
644  histReco->fill(sortedReco[i].p4());
645 
646 // etreco ->Fill( sortedReco[i].et() );
647 // etareco->Fill( sortedReco[i].eta() );
648 // phiReco->Fill( sortedReco[i].phi() );
649 
650  if (isFired) {
651  histRecoMonpath->fill(sortedReco[i].p4());
652  plotMonpath = true;
653  }
654 
655  } // END of loop over Reconstructed particles
656 
657  if (recocut_ >= reqNum) totalreco->Fill(numOfHLTCollectionLabels+1.5); // this isn't really needed anymore keep for backward comp.
658  if (recocut_ >= reqNum) totalmatchreco->Fill(numOfHLTCollectionLabels+1.5); // this isn't really needed anymore keep for backward comp.
659 
660  }
661 
662 
663 
664 
666  // Loop over filter modules //
668  for(unsigned int n=0; n < numOfHLTCollectionLabels ; n++) {
669  // These numbers are from the Parameter Set, such as:
670  // theHLTOutputTypes = cms.uint32(100)
671  switch(theHLTOutputTypes[n])
672  {
673  case trigger::TriggerL1NoIsoEG: // Non-isolated Level 1
674  histoFillerL1NonIso->fillHistos(triggerObj,event,n, sortedReco, plotReco, plotMonpath);
675  break;
676  case trigger::TriggerL1IsoEG: // Isolated Level 1
677  histoFillerL1Iso->fillHistos(triggerObj,event,n, sortedReco, plotReco, plotMonpath);
678  break;
679  case trigger::TriggerPhoton: // Photon
680  histoFillerPho->fillHistos(triggerObj,event,n, sortedReco, plotReco, plotMonpath);
681  break;
682  case trigger::TriggerElectron: // Electron
683  histoFillerEle->fillHistos(triggerObj,event,n, sortedReco, plotReco, plotMonpath);
684  break;
685  case trigger::TriggerCluster: // TriggerCluster
686  histoFillerClu->fillHistos(triggerObj,event,n, sortedReco, plotReco, plotMonpath);
687  break;
688  default:
689  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
690  }
691  } // END of loop over filter modules
692 }
693 
694 
696 // fillHistos //
697 // Called by analyze method. //
699 template <class T> void HistoFillerReco<T>::fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& triggerObj,const edm::Event& iEvent ,unsigned int n, std::vector<reco::Particle>& sortedReco, bool plotReco, bool plotMonpath)
700 {
701  std::vector<edm::Ref<T> > recoecalcands;
702  if ( ( triggerObj->filterIndex(dqm->theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
703  return;
704  }
705 
707  // Retrieve saved filter objects //
709  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),dqm->theHLTOutputTypes[n],recoecalcands);
710  //Danger: special case, L1 non-isolated
711  // needs to be merged with L1 iso
713  std::vector<edm::Ref<T> > isocands;
714  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
715  if (isocands.size()>0)
716  {
717  for (unsigned int i=0; i < isocands.size(); i++)
718  recoecalcands.push_back(isocands[i]);
719  }
720  } // END of if theHLTOutputTypes == 82
721 
722 
723  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
724  return;
725  }
726 
727 
728  if (recoecalcands.size() >= dqm->reqNum )
729  dqm->totalreco->Fill(n+0.5);
730 
731 
733  // check for validity //
734  // prevents crash in CMSSW_3_1_0_pre6 //
736  for (unsigned int j=0; j<recoecalcands.size(); j++){
737  if(!( recoecalcands.at(j).isAvailable())){
738  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl << "invalid refs for: " << dqm->theHLTCollectionLabels[n].label();
739  return;
740  }
741  }
742 
744  // Loop over all HLT objects in this filter step, and //
745  // fill histograms. //
747  // bool foundAllMatches = false;
748  // unsigned int numOfHLTobjectsMatched = 0;
749  for (unsigned int i=0; i<recoecalcands.size(); i++) {
750 
751  dqm->standardHist[n].fill(recoecalcands[i]->p4());
752 
754  // Plot isolation variables (show the not-yet-cut //
755  // isolation, i.e. associated to next filter) //
757  if ( n+1 < dqm->numOfHLTCollectionLabels ) { // can't plot beyond last
758  if (dqm->plotiso[n+1]) {
759  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
761  iEvent.getByToken(isoNameTokens_.at(j),depMap);
762  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
763  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
764  if (mapi!=depMap->end()){ // found candidate in isolation map!
765  dqm->etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
766  dqm->ethistiso[n+1]->Fill(recoecalcands[i]->et() ,mapi->val);
767  dqm->phiHistIso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
768  }
769  }
770  }
771  }
772  } // END of if n+1 < then the number of hlt collections
773  }
774 
776  // Loop over the Reconstructed Particles, and find the //
777  // closest HLT object match. //
779  if (plotReco == true) {
780  for (unsigned int i=0; i < dqm->recocut_; i++) {
781  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
782 
783  // float closestRecoDeltaR = 0.5;
784  float closestRecoDeltaR = 1000.;
785  int closestRecoEcalCandIndex = -1;
786  for (unsigned int j=0; j<recoecalcands.size(); j++) {
787  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentRecoParticleMomentum);
788 
789  if (deltaR < closestRecoDeltaR) {
790  closestRecoDeltaR = deltaR;
791  closestRecoEcalCandIndex = j;
792  }
793  }
794 
795  // If an HLT object was found within some delta-R
796  // of this reco particle, store it in a histogram
797  if ( closestRecoEcalCandIndex >= 0 ) {
798 // histEtOfHltObjMatchToReco[n] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et() );
799 // histEtaOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta() );
800 // histPhiOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->phi() );
801 
802  dqm->histHltObjMatchToReco[n].fill(recoecalcands[closestRecoEcalCandIndex]->p4());
803 
804  // Also store isolation info
805  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
806  if (dqm->plotiso[n+1] ){ // only plot if requested in config
807  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
809  iEvent.getByToken(isoNameTokens_.at(j),depMap);
810  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
811  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestRecoEcalCandIndex]);
812  if (mapi!=depMap->end()) { // found candidate in isolation map!
813  dqm->histEtaIsoOfHltObjMatchToReco[n+1]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta(),mapi->val);
814  dqm->histEtIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et(), mapi->val);
815  dqm->histPhiIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->phi(), mapi->val);
816  }
817  }
818  }
819  }
820  }
821  } // END of if closestEcalCandIndex >= 0
822  }
823 
825  // Fill reco matched objects into histograms //
827  unsigned int mtachedRecoParts = 0;
828  float minrecodist=0.3;
829  if(n==0) minrecodist=0.5; //low L1-resolution => allow wider matching
830  for(unsigned int i =0; i < dqm->recocut_; i++){
831  //match generator candidate
832  bool matchThis= false;
833  math::XYZVector candDir=sortedReco[i].momentum();
834  unsigned int closest = 0;
835  double closestDr = 1000.;
836  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
837  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
838  if (dr < closestDr) {
839  closestDr = dr;
840  closest = trigOb;
841  }
842  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
843  closest = -1;
844  } else {
845  mtachedRecoParts++;
846  matchThis = true;
847  }
848  }
849  if ( !matchThis ) continue; // only plot matched candidates
850  // fill coordinates of mc particle matching trigger object
851 // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
852 // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
853 // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
854  dqm->histMatchReco[n].fill(sortedReco[i].p4());
855 
856  if (plotMonpath) {
857 // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
858 // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
859 // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
860  dqm->histMatchRecoMonPath[n].fill(sortedReco[i].p4());
861 
862  }
864  // Plot isolation variables (show the not-yet-cut //
865  // isolation, i.e. associated to next filter) //
867  if (n+1 < dqm->numOfHLTCollectionLabels){ // can't plot beyond last
868  if (dqm->plotiso[n+1] ){ // only plot if requested in config
869  for (unsigned int j = 0 ; j < isoNameTokens_.size() ;j++ ){
871  iEvent.getByToken(isoNameTokens_.at(j),depMapReco);
872  if (depMapReco.isValid()){ //Map may not exist if only one candidate passes a double filter
873  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMapReco->find(recoecalcands[closest]);
874  if (mapi!=depMapReco->end()){ // found candidate in isolation map!
875  dqm->etahistisomatchreco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
876  dqm->ethistisomatchreco[n+1]->Fill(sortedReco[i].et(),mapi->val);
877  dqm->phiHistIsoMatchReco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
878  }
879  }
880  }
881  }
882  } // END of if n+1 < then the number of hlt collections
883  }
884  // fill total reco matched efficiency
885  if (mtachedRecoParts >= dqm->reqNum )
886  dqm-> totalmatchreco->Fill(n+0.5);
887  }
888 
889 }
890 
891 
893 // method called once each job just after ending the event loop //
896 
897 }
898 
int pdgGen
Definition: EmDQMReco.h:124
void fill(const math::XYZTLorentzVector &momentum)
Definition: EmDQMReco.cc:90
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
boost::ptr_vector< FourVectorMonitorElements > standardHist
Definition: EmDQMReco.h:167
std::vector< std::vector< edm::InputTag > > isoNames
Definition: EmDQMReco.h:113
double energy() const
energy
Definition: Particle.h:83
void analyze(const edm::Event &event, const edm::EventSetup &)
Definition: EmDQMReco.cc:513
HistoFillerReco< reco::RecoEcalCandidateCollection > * histoFillerPho
Definition: EmDQMReco.h:234
HistoFillerReco< reco::ElectronCollection > * histoFillerEle
Definition: EmDQMReco.h:231
std::string dirname_
Definition: EmDQMReco.h:229
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
boost::ptr_vector< FourVectorMonitorElements > histMatchReco
Definition: EmDQMReco.h:172
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int eventnum
Definition: EmDQMReco.h:225
assert(m_qm.get())
void endJob()
Definition: EmDQMReco.cc:895
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:197
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
EmDQMReco(const edm::ParameterSet &pset)
Constructor.
Definition: EmDQMReco.cc:102
#define NULL
Definition: scimark2.h:8
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:111
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &triggerObj, const edm::Event &iEvent, unsigned int n, std::vector< reco::Particle > &sortedReco, bool plotReco, bool plotMonpath)
Definition: EmDQMReco.cc:699
string format
Some error handling for the usage.
edm::EDGetTokenT< std::vector< reco::SuperCluster > > recoObjectsEET
Definition: EmDQMReco.h:154
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:191
unsigned int plotBins
Definition: EmDQMReco.h:134
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:198
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
bool isHltConfigInitialized_
Definition: EmDQMReco.h:117
double recoEtaAcc
Definition: EmDQMReco.h:125
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void Fill(long long x)
HLTConfigProvider hltConfig_
Definition: EmDQMReco.h:116
FourVectorMonitorElements(EmDQMReco *_parent, DQMStore::IBooker &iBooker, const std::string &histogramNameTemplate, const std::string &histogramTitleTemplate)
Definition: EmDQMReco.cc:48
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
boost::ptr_vector< FourVectorMonitorElements > histMatchRecoMonPath
Definition: EmDQMReco.h:177
double recoEtAcc
Definition: EmDQMReco.h:126
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQMReco.h:238
int iEvent
Definition: GenABIO.cc:230
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQMReco.h:109
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:106
HistoFillerReco< l1extra::L1EmParticleCollection > * histoFillerL1Iso
Definition: EmDQMReco.h:235
~EmDQMReco()
Destructor.
Definition: EmDQMReco.cc:505
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
MonitorElement * totalreco
Definition: EmDQMReco.h:204
EmDQMReco * dqm
Definition: EmDQMReco.h:41
MonitorElement * etaMonitorElement
Definition: EmDQMReco.h:74
edm::EDGetTokenT< std::vector< reco::SuperCluster > > recoObjectsEBT
Definition: EmDQMReco.h:153
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
MonitorElement * totalmatchreco
Definition: EmDQMReco.h:205
unsigned int recocut_
Definition: EmDQMReco.h:138
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:194
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:75
std::string triggerNameRecoMonPath
Definition: EmDQMReco.h:142
std::vector< bool > plotiso
Definition: EmDQMReco.h:112
edm::EDGetTokenT< reco::GsfElectronCollection > recoElectronsInput
Definition: EmDQMReco.h:152
bool useHumanReadableHistTitles
Definition: EmDQMReco.h:108
double plotPhiMax
Definition: EmDQMReco.h:131
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerObjT
Definition: EmDQMReco.h:156
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
HistoFillerReco< l1extra::L1EmParticleCollection > * histoFillerL1NonIso
Definition: EmDQMReco.h:233
MonitorElement * phiMonitorElement
Definition: EmDQMReco.h:75
unsigned int reqNum
Definition: EmDQMReco.h:123
boost::scoped_ptr< FourVectorMonitorElements > histRecoMonpath
Definition: EmDQMReco.h:217
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:189
boost::scoped_ptr< FourVectorMonitorElements > histMonpath
Definition: EmDQMReco.h:222
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
Definition: EmDQMReco.cc:203
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:193
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< std::pair< double, double > > plotBounds
Definition: EmDQMReco.h:114
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:38
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:104
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
edm::EDGetTokenT< edm::TriggerResults > hltResultsT
Definition: EmDQMReco.h:155
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
double plotPtMin
Definition: EmDQMReco.h:129
double plotPtMax
Definition: EmDQMReco.h:130
boost::ptr_vector< FourVectorMonitorElements > histHltObjMatchToReco
Definition: EmDQMReco.h:183
double plotEtaMax
Definition: EmDQMReco.h:128
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:190
std::string processNameRecoMonPath
Definition: EmDQMReco.h:147
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EmDQMReco.cc:214
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
boost::scoped_ptr< FourVectorMonitorElements > histReco
Definition: EmDQMReco.h:212
tuple size
Write out results.
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:195
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: Run.h:43
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:199
HistoFillerReco< reco::RecoEcalCandidateCollection > * histoFillerClu
Definition: EmDQMReco.h:232