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  const std::string &histogramNameTemplate,
50  const std::string &histogramTitleTemplate
51  ) :
52  parent(_parent)
53 {
54  // introducing variables for better code readability later on
55  std::string histName;
56  std::string histTitle;
57 
58  // et
59  histName = boost::str(boost::format(histogramNameTemplate) % "et");
60  histTitle = boost::str(boost::format(histogramTitleTemplate) % "E_{T}");
61  etMonitorElement = parent->dbe->book1D(histName.c_str(),
62  histTitle.c_str(),
65  parent->plotPtMax);
66 
67  // eta
68  histName = boost::str(boost::format(histogramNameTemplate) % "eta");
69  histTitle= boost::str(boost::format(histogramTitleTemplate) % "#eta");
70  etaMonitorElement = parent->dbe->book1D(histName.c_str(),
71  histTitle.c_str(),
73  - parent->plotEtaMax,
75 
76  // phi
77  histName = boost::str(boost::format(histogramNameTemplate) % "phi");
78  histTitle= boost::str(boost::format(histogramTitleTemplate) % "#phi");
79  phiMonitorElement = parent->dbe->book1D(histName.c_str(),
80  histTitle.c_str(),
82  - parent->plotPhiMax,
84 }
85 
86 //----------------------------------------------------------------------
87 
88 void
90 {
91  etMonitorElement->Fill(momentum.Et());
92  etaMonitorElement->Fill(momentum.eta() );
93  phiMonitorElement->Fill(momentum.phi() );
94 }
95 
96 //----------------------------------------------------------------------
97 
99 // Constructor //
102 {
103 
105  dbe->setVerbose(0);
106 
107 
109  // Read from configuration file //
111  dirname_="HLT/HLTEgammaValidation/"+pset.getParameter<std::string>("@module_label");
113 
114  // parameters for generator study
115  reqNum = pset.getParameter<unsigned int>("reqNum");
116  pdgGen = pset.getParameter<int>("pdgGen");
117  recoEtaAcc = pset.getParameter<double>("genEtaAcc");
118  recoEtAcc = pset.getParameter<double>("genEtAcc");
119  // plotting parameters (untracked because they don't affect the physics)
120  plotPtMin = pset.getUntrackedParameter<double>("PtMin",0.);
121  plotPtMax = pset.getUntrackedParameter<double>("PtMax",1000.);
122  plotEtaMax = pset.getUntrackedParameter<double>("EtaMax", 2.7);
123  plotPhiMax = pset.getUntrackedParameter<double>("PhiMax", 3.15);
124  plotBins = pset.getUntrackedParameter<unsigned int>("Nbins",50);
125  useHumanReadableHistTitles = pset.getUntrackedParameter<bool>("useHumanReadableHistTitles", false);
126 
127  triggerNameRecoMonPath = pset.getUntrackedParameter<std::string>("triggerNameRecoMonPath","HLT_MinBias");
128  processNameRecoMonPath = pset.getUntrackedParameter<std::string>("processNameRecoMonPath","HLT");
129 
130  recoElectronsInputTag = pset.getUntrackedParameter<edm::InputTag>("recoElectrons",edm::InputTag("gsfElectrons"));
131 
132  // preselction cuts
133  // recocutCollection_= pset.getParameter<edm::InputTag>("cutcollection");
134  recocut_ = pset.getParameter<int>("cutnum");
135 
136  // prescale = 10;
137  eventnum = 0;
138 
139  // just init
140  isHltConfigInitialized_ = false;
141 
143  // Read in the Vector of Parameter Sets. //
144  // Information for each filter-step //
146  std::vector<edm::ParameterSet> filters =
147  pset.getParameter<std::vector<edm::ParameterSet> >("filters");
148 
149  int i = 0;
150  for(std::vector<edm::ParameterSet>::iterator filterconf = filters.begin() ; filterconf != filters.end() ; filterconf++)
151  {
152 
153  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
154  theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
155  // Grab the human-readable name, if it is not specified, use the Collection Label
156  theHLTCollectionHumanNames.push_back(filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName",theHLTCollectionLabels[i].label()));
157 
158  std::vector<double> bounds = filterconf->getParameter<std::vector<double> >("PlotBounds");
159  // If the size of plot "bounds" vector != 2, abort
160  assert(bounds.size() == 2);
161  plotBounds.push_back(std::pair<double,double>(bounds[0],bounds[1]));
162  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag> >("IsoCollections"));
163  // If the size of the isoNames vector is not greater than zero, abort
164  assert(isoNames.back().size()>0);
165  if (isoNames.back().at(0).label()=="none") {
166  plotiso.push_back(false);
167  } else {
168  plotiso.push_back(true);
169  }
170  i++;
171  } // END of loop over parameter sets
172 
173  // Record number of HLTCollectionLabels
175 
176 }
177 
178 
179 
183 void EmDQMReco::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup ) {
184 
185  bool isHltConfigChanged = false; // change of cfg at run boundaries?
186  isHltConfigInitialized_ = hltConfig_.init( iRun, iSetup, "HLT", isHltConfigChanged );
187 
188 }
189 
190 
191 
192 
193 
195 // method called once each job just before starting event loop //
197 void
199 {
200  //edm::Service<TFileService> fs;
202 
204  // Set up Histogram of Effiency vs Step. //
205  // theHLTCollectionLabels is a vector of InputTags //
206  // from the configuration file. //
208 
209  std::string histName="total_eff";
210  std::string histTitle = "total events passing";
211  // This plot will have bins equal to 2+(number of
212  // HLTCollectionLabels in the config file)
213  totalreco = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
216  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
217 
218  histName="total_eff_RECO_matched";
219  histTitle="total events passing (Reco matched)";
220  totalmatchreco = dbe->book1D(histName.c_str(),histTitle.c_str(),numOfHLTCollectionLabels+2,0,numOfHLTCollectionLabels+2);
221  totalmatchreco->setBinLabel(numOfHLTCollectionLabels+1,"Total");
222  totalmatchreco->setBinLabel(numOfHLTCollectionLabels+2,"Reco");
223  for (unsigned int u=0; u<numOfHLTCollectionLabels; u++){totalmatchreco->setBinLabel(u+1,theHLTCollectionLabels[u].label().c_str());}
224 
225  // MonitorElement* tmphisto;
226  MonitorElement* tmpiso;
227 
229  // Set up generator-level histograms //
231  std::string pdgIdString;
232  switch(pdgGen) {
233  case 11:
234  pdgIdString="Electron";break;
235  case 22:
236  pdgIdString="Photon";break;
237  default:
238  pdgIdString="Particle";
239  }
240 
241  //--------------------
242 
243  // reco
244  // (note that reset(..) must be used to set the value of the scoped_ptr...)
245  histReco.reset(
246  new FourVectorMonitorElements(this,
247  "reco_%s", // pattern for histogram name
248  "%s of " + pdgIdString + "s"
249  ));
250 
251  //--------------------
252 
253  // monpath
254  histRecoMonpath.reset(
255  new FourVectorMonitorElements(this,
256  "reco_%s_monpath", // pattern for histogram name
257  "%s of " + pdgIdString + "s monpath"
258  )
259  );
260 
261  //--------------------
262 
263  // TODO: WHAT ARE THESE HISTOGRAMS FOR ? THEY SEEM NEVER REFERENCED ANYWHERE IN THIS FILE...
264  // final X monpath
265  histMonpath.reset(
266  new FourVectorMonitorElements(this,
267  "final_%s_monpath", // pattern for histogram name
268  "Final %s Monpath"
269  )
270  );
271 
272  //--------------------
273 
275  // Set up histograms of HLT objects //
277 
278  // Determine what strings to use for histogram titles
279  std::vector<std::string> HltHistTitle;
280  if ( theHLTCollectionHumanNames.size() == numOfHLTCollectionLabels && useHumanReadableHistTitles ) {
281  HltHistTitle = theHLTCollectionHumanNames;
282  } else {
283  for (unsigned int i =0; i < numOfHLTCollectionLabels; i++) {
284  HltHistTitle.push_back(theHLTCollectionLabels[i].label());
285  }
286  }
287 
288  for(unsigned int i = 0; i< numOfHLTCollectionLabels ; i++){
289  //--------------------
290  // distributions of HLT objects passing filter i
291  //--------------------
292 
293 // // Et
294 // histName = theHLTCollectionLabels[i].label()+"et_all";
295 // histTitle = HltHistTitle[i]+" Et (ALL)";
296 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
297 // ethist.push_back(tmphisto);
298 //
299 // // Eta
300 // histName = theHLTCollectionLabels[i].label()+"eta_all";
301 // histTitle = HltHistTitle[i]+" #eta (ALL)";
302 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
303 // etahist.push_back(tmphisto);
304 //
305 // // phi
306 // histName = theHLTCollectionLabels[i].label()+"phi_all";
307 // histTitle = HltHistTitle[i]+" #phi (ALL)";
308 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
309 // phiHist.push_back(tmphisto);
310 
311  standardHist.push_back(new FourVectorMonitorElements(this,
312  theHLTCollectionLabels[i].label()+"%s_all", // histogram name
313  HltHistTitle[i]+" %s (ALL)" // histogram title
314  ));
315 
316  //--------------------
317  // distributions of reco object matching HLT object passing filter i
318  //--------------------
319 
320  // Et
321 // histName = theHLTCollectionLabels[i].label()+"et_RECO_matched";
322 // histTitle = HltHistTitle[i]+" Et (RECO matched)";
323 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
324 // ethistmatchreco.push_back(tmphisto);
325 
326 // // Eta
327 // histName = theHLTCollectionLabels[i].label()+"eta_RECO_matched";
328 // histTitle = HltHistTitle[i]+" #eta (RECO matched)";
329 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
330 // etahistmatchreco.push_back(tmphisto);
331 //
332 // // phi
333 // histName = theHLTCollectionLabels[i].label()+"phi_RECO_matched";
334 // histTitle = HltHistTitle[i]+" #phi (RECO matched)";
335 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
336 // phiHistMatchReco.push_back(tmphisto);
337  histMatchReco.push_back(new FourVectorMonitorElements(this,
338  theHLTCollectionLabels[i].label()+"%s_RECO_matched", // histogram name
339  HltHistTitle[i]+" %s (RECO matched)" // histogram title
340  ));
341 
342  //--------------------
343  // distributions of reco object matching HLT object passing filter i
344  //--------------------
345 
346 // // Et
347 // histName = theHLTCollectionLabels[i].label()+"et_RECO_matched_monpath";
348 // histTitle = HltHistTitle[i]+" Et (RECO matched, monpath)";
349 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
350 // ethistmatchrecomonpath.push_back(tmphisto);
351 //
352 // // Eta
353 // histName = theHLTCollectionLabels[i].label()+"eta_RECO_matched_monpath";
354 // histTitle = HltHistTitle[i]+" #eta (RECO matched, monpath)";
355 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
356 // etahistmatchrecomonpath.push_back(tmphisto);
357 //
358 // // phi
359 // histName = theHLTCollectionLabels[i].label()+"phi_RECO_matched_monpath";
360 // histTitle = HltHistTitle[i]+" #phi (RECO matched, monpath)";
361 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
362 // phiHistMatchRecoMonPath.push_back(tmphisto);
363 
365  theHLTCollectionLabels[i].label()+"%s_RECO_matched_monpath", // histogram name
366  HltHistTitle[i]+" %s (RECO matched, monpath)" // histogram title
367  ));
368  //--------------------
369  // distributions of HLT object that is closest delta-R match to sorted reco particle(s)
370  //--------------------
371 
372  // Et
373 // histName = theHLTCollectionLabels[i].label()+"et_reco";
374 // histTitle = HltHistTitle[i]+" Et (reco)";
375 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
376 // histEtOfHltObjMatchToReco.push_back(tmphisto);
377 //
378 // // eta
379 // histName = theHLTCollectionLabels[i].label()+"eta_reco";
380 // histTitle = HltHistTitle[i]+" eta (reco)";
381 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
382 // histEtaOfHltObjMatchToReco.push_back(tmphisto);
383 //
384 // // phi
385 // histName = theHLTCollectionLabels[i].label()+"phi_reco";
386 // histTitle = HltHistTitle[i]+" phi (reco)";
387 // tmphisto = dbe->book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
388 // histPhiOfHltObjMatchToReco.push_back(tmphisto);
389 
391  theHLTCollectionLabels[i].label()+"%s_reco", // histogram name
392  HltHistTitle[i]+" %s (reco)" // histogram title
393  ));
394 
395  //--------------------
396 
397  if (!plotiso[i]) {
398  tmpiso = NULL;
399  etahistiso.push_back(tmpiso);
400  ethistiso.push_back(tmpiso);
401  phiHistIso.push_back(tmpiso);
402 
403  etahistisomatchreco.push_back(tmpiso);
404  ethistisomatchreco.push_back(tmpiso);
405  phiHistIsoMatchReco.push_back(tmpiso);
406 
407  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
408  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
409  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
410 
411  } else {
412 
413  //--------------------
414  // 2D plot: Isolation values vs X for all objects
415  //--------------------
416 
417  // X = eta
418  histName = theHLTCollectionLabels[i].label()+"eta_isolation_all";
419  histTitle = HltHistTitle[i]+" isolation vs #eta (all)";
420  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
421  etahistiso.push_back(tmpiso);
422 
423  // X = et
424  histName = theHLTCollectionLabels[i].label()+"et_isolation_all";
425  histTitle = HltHistTitle[i]+" isolation vs Et (all)";
426  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
427  ethistiso.push_back(tmpiso);
428 
429  // X = phi
430  histName = theHLTCollectionLabels[i].label()+"phi_isolation_all";
431  histTitle = HltHistTitle[i]+" isolation vs #phi (all)";
432  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
433  phiHistIso.push_back(tmpiso);
434 
435  //--------------------
436  // 2D plot: Isolation values vs X for reco matched objects
437  //--------------------
438 
439  // X = eta
440  histName = theHLTCollectionLabels[i].label()+"eta_isolation_RECO_matched";
441  histTitle = HltHistTitle[i]+" isolation vs #eta (reco matched)";
442  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
443  etahistisomatchreco.push_back(tmpiso);
444 
445  // X = et
446  histName = theHLTCollectionLabels[i].label()+"et_isolation_RECO_matched";
447  histTitle = HltHistTitle[i]+" isolation vs Et (reco matched)";
448  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
449  ethistisomatchreco.push_back(tmpiso);
450 
451  // X = eta
452  histName = theHLTCollectionLabels[i].label()+"phi_isolation_RECO_matched";
453  histTitle = HltHistTitle[i]+" isolation vs #phi (reco matched)";
454  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
455  phiHistIsoMatchReco.push_back(tmpiso);
456 
457  //--------------------
458  // 2D plot: Isolation values vs X for HLT object that
459  // is closest delta-R match to sorted reco particle(s)
460  //--------------------
461 
462  // X = eta
463  histName = theHLTCollectionLabels[i].label()+"eta_isolation_reco";
464  histTitle = HltHistTitle[i]+" isolation vs #eta (reco)";
465  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax,plotBins,plotBounds[i].first,plotBounds[i].second);
466  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
467 
468  // X = et
469  histName = theHLTCollectionLabels[i].label()+"et_isolation_reco";
470  histTitle = HltHistTitle[i]+" isolation vs Et (reco)";
471  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax,plotBins,plotBounds[i].first,plotBounds[i].second);
472  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
473 
474  // X = phi
475  histName = theHLTCollectionLabels[i].label()+"phi_isolation_reco";
476  histTitle = HltHistTitle[i]+" isolation vs #phi (reco)";
477  tmpiso = dbe->book2D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax,plotBins,plotBounds[i].first,plotBounds[i].second);
478  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
479  //--------------------
480 
481  } // END of HLT histograms
482 
483  }
484 }
485 
486 
488 // Destructor //
491 }
492 
493 
495 // method called to for each event //
497 void
499 {
500 
501  // protect from hlt config failure
502  if( !isHltConfigInitialized_ ) return;
503 
504  eventnum++;
505  bool plotMonpath = false;
506  bool plotReco = true;
507 
511 
512  if (pdgGen == 11) {
513 
514  event.getByLabel(recoElectronsInputTag, recoObjects);
515 
516  if (recoObjects->size() < (unsigned int)recocut_) {
517  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco particles with pdgId=" << pdgGen << ". Only " << cutRecoCounter->size() << " particles.";
518  return;
519  }
520  } else if (pdgGen == 22) {
521 
522  event.getByLabel("correctedHybridSuperClusters", recoObjectsEB);
523  event.getByLabel("correctedMulti5x5SuperClustersWithPreshower", recoObjectsEE);
524 
525  if (recoObjectsEB->size() + recoObjectsEE->size() < (unsigned int)recocut_) {
526  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco particles with pdgId=" << pdgGen << ". Only " << cutRecoCounter.size() << " particles.";
527  return;
528  }
529  }
530 
532  event.getByLabel(edm::InputTag("TriggerResults","",processNameRecoMonPath), HLTR);
533 
538 
539  /* if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt8"){
540  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG8");
541  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt5") {
542  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG5");
543  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedDoubleEgammaEt5") {
544  triggerIndex = hltConfig.triggerIndex("HLT_L1DoubleEG5");
545  } else {
546  triggerIndex = hltConfig.triggerIndex("");
547  } */
548 
549  unsigned int triggerIndex;
551 
552  //triggerIndex must be less than the size of HLTR or you get a CMSException
553  bool isFired = false;
554  if (triggerIndex < HLTR->size()){
555  isFired = HLTR->accept(triggerIndex);
556  }
557 
558  // fill L1 and HLT info
559  // get objects possed by each filter
561  event.getByLabel("hltTriggerSummaryRAW",triggerObj);
562  if(!triggerObj.isValid()) {
563  edm::LogWarning("EmDQMReco") << "RAW-type HLT results not found, skipping event";
564  return;
565  }
566 
568  // Fill the bin labeled "Total" //
569  // This will be the number of events looked at. //
573 
574  /* edm::Handle< edm::View<reco::GsfElectron> > recoParticles;
575  event.getByLabel("gsfElectrons", recoParticles);
576 
577  std::vector<reco::GsfElectron> allSortedRecoParticles;
578 
579  for(edm::View<reco::GsfElectron>::const_iterator currentRecoParticle = recoParticles->begin(); currentRecoParticle != recoParticles->end(); currentRecoParticle++){
580  if ( !((*currentRecoParticle).et() > 2.0) ) continue;
581  reco::GsfElectron tmpcand( *(currentRecoParticle) );
582  allSortedRecoParticles.push_back(tmpcand);
583  }
584 
585  std::sort(allSortedRecoParticles.begin(), allSortedRecoParticles.end(),pTRecoComparator_);*/
586 
587  // Were enough high energy gen particles found?
588  // It was an event worth keeping. Continue.
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  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
675  case trigger::TriggerL1IsoEG: // Isolated Level 1
676  fillHistos<l1extra::L1EmParticleCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
677  case trigger::TriggerPhoton: // Photon
678  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
679  case trigger::TriggerElectron: // Electron
680  fillHistos<reco::ElectronCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
681  case trigger::TriggerCluster: // TriggerCluster
682  fillHistos<reco::RecoEcalCandidateCollection>(triggerObj,event,n, sortedReco, plotReco, plotMonpath);break;
683  default:
684  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]" );
685  }
686  } // END of loop over filter modules
687 }
688 
689 
691 // fillHistos //
692 // Called by analyze method. //
694 template <class T> void EmDQMReco::fillHistos(edm::Handle<trigger::TriggerEventWithRefs>& triggerObj,const edm::Event& iEvent ,unsigned int n, std::vector<reco::Particle>& sortedReco, bool plotReco, bool plotMonpath)
695 {
696  std::vector<edm::Ref<T> > recoecalcands;
697  if ( ( triggerObj->filterIndex(theHLTCollectionLabels[n])>=triggerObj->size() )){ // only process if available
698  return;
699  }
700 
702  // Retrieve saved filter objects //
704  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),theHLTOutputTypes[n],recoecalcands);
705  //Danger: special case, L1 non-isolated
706  // needs to be merged with L1 iso
708  std::vector<edm::Ref<T> > isocands;
709  triggerObj->getObjects(triggerObj->filterIndex(theHLTCollectionLabels[n]),trigger::TriggerL1IsoEG,isocands);
710  if (isocands.size()>0)
711  {
712  for (unsigned int i=0; i < isocands.size(); i++)
713  recoecalcands.push_back(isocands[i]);
714  }
715  } // END of if theHLTOutputTypes == 82
716 
717 
718  if (recoecalcands.size() < 1){ // stop if no object passed the previous filter
719  return;
720  }
721 
722 
723  if (recoecalcands.size() >= reqNum )
724  totalreco->Fill(n+0.5);
725 
726 
728  // check for validity //
729  // prevents crash in CMSSW_3_1_0_pre6 //
731  for (unsigned int j=0; j<recoecalcands.size(); j++){
732  if(!( recoecalcands.at(j).isAvailable())){
733  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains invalid Refs" << std::endl << "invalid refs for: " << theHLTCollectionLabels[n].label();
734  return;
735  }
736  }
737 
739  // Loop over all HLT objects in this filter step, and //
740  // fill histograms. //
742  // bool foundAllMatches = false;
743  // unsigned int numOfHLTobjectsMatched = 0;
744  for (unsigned int i=0; i<recoecalcands.size(); i++) {
745 
746  standardHist[n].fill(recoecalcands[i]->p4());
747 
749  // Plot isolation variables (show the not-yet-cut //
750  // isolation, i.e. associated to next filter) //
752  if ( n+1 < numOfHLTCollectionLabels ) { // can't plot beyond last
753  if (plotiso[n+1]) {
754  for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
756  iEvent.getByLabel(isoNames[n+1].at(j),depMap);
757  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
758  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[i]);
759  if (mapi!=depMap->end()){ // found candidate in isolation map!
760  etahistiso[n+1]->Fill(recoecalcands[i]->eta(),mapi->val);
761  ethistiso[n+1]->Fill(recoecalcands[i]->et() ,mapi->val);
762  phiHistIso[n+1]->Fill(recoecalcands[i]->phi(),mapi->val);
763  }
764  }
765  }
766  }
767  } // END of if n+1 < then the number of hlt collections
768  }
769 
771  // Loop over the Reconstructed Particles, and find the //
772  // closest HLT object match. //
774  if (plotReco == true) {
775  for (unsigned int i=0; i < recocut_; i++) {
776  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
777 
778  // float closestRecoDeltaR = 0.5;
779  float closestRecoDeltaR = 1000.;
780  int closestRecoEcalCandIndex = -1;
781  for (unsigned int j=0; j<recoecalcands.size(); j++) {
782  float deltaR = DeltaR(recoecalcands[j]->momentum(),currentRecoParticleMomentum);
783 
784  if (deltaR < closestRecoDeltaR) {
785  closestRecoDeltaR = deltaR;
786  closestRecoEcalCandIndex = j;
787  }
788  }
789 
790  // If an HLT object was found within some delta-R
791  // of this reco particle, store it in a histogram
792  if ( closestRecoEcalCandIndex >= 0 ) {
793 // histEtOfHltObjMatchToReco[n] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et() );
794 // histEtaOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta() );
795 // histPhiOfHltObjMatchToReco[n]->Fill( recoecalcands[closestRecoEcalCandIndex]->phi() );
796 
797  histHltObjMatchToReco[n].fill(recoecalcands[closestRecoEcalCandIndex]->p4());
798 
799  // Also store isolation info
800  if (n+1 < numOfHLTCollectionLabels){ // can't plot beyond last
801  if (plotiso[n+1] ){ // only plot if requested in config
802  for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
804  iEvent.getByLabel(isoNames[n+1].at(j),depMap);
805  if (depMap.isValid()){ //Map may not exist if only one candidate passes a double filter
806  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMap->find(recoecalcands[closestRecoEcalCandIndex]);
807  if (mapi!=depMap->end()) { // found candidate in isolation map!
808  histEtaIsoOfHltObjMatchToReco[n+1]->Fill( recoecalcands[closestRecoEcalCandIndex]->eta(),mapi->val);
809  histEtIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->et(), mapi->val);
810  histPhiIsoOfHltObjMatchToReco[n+1] ->Fill( recoecalcands[closestRecoEcalCandIndex]->phi(), mapi->val);
811  }
812  }
813  }
814  }
815  }
816  } // END of if closestEcalCandIndex >= 0
817  }
818 
820  // Fill reco matched objects into histograms //
822  unsigned int mtachedRecoParts = 0;
823  float minrecodist=0.3;
824  if(n==0) minrecodist=0.5; //low L1-resolution => allow wider matching
825  for(unsigned int i =0; i < recocut_; i++){
826  //match generator candidate
827  bool matchThis= false;
828  math::XYZVector candDir=sortedReco[i].momentum();
829  unsigned int closest = 0;
830  double closestDr = 1000.;
831  for(unsigned int trigOb = 0 ; trigOb < recoecalcands.size(); trigOb++){
832  double dr = DeltaR(recoecalcands[trigOb]->momentum(),candDir);
833  if (dr < closestDr) {
834  closestDr = dr;
835  closest = trigOb;
836  }
837  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
838  closest = -1;
839  } else {
840  mtachedRecoParts++;
841  matchThis = true;
842  }
843  }
844  if ( !matchThis ) continue; // only plot matched candidates
845  // fill coordinates of mc particle matching trigger object
846 // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
847 // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
848 // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
849  histMatchReco[n].fill(sortedReco[i].p4());
850 
851  if (plotMonpath) {
852 // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
853 // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
854 // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
855  histMatchRecoMonPath[n].fill(sortedReco[i].p4());
856 
857  }
859  // Plot isolation variables (show the not-yet-cut //
860  // isolation, i.e. associated to next filter) //
862  if (n+1 < numOfHLTCollectionLabels){ // can't plot beyond last
863  if (plotiso[n+1] ){ // only plot if requested in config
864  for (unsigned int j = 0 ; j < isoNames[n+1].size() ;j++ ){
866  iEvent.getByLabel(isoNames[n+1].at(j),depMapReco);
867  if (depMapReco.isValid()){ //Map may not exist if only one candidate passes a double filter
868  typename edm::AssociationMap<edm::OneToValue< T , float > >::const_iterator mapi = depMapReco->find(recoecalcands[closest]);
869  if (mapi!=depMapReco->end()){ // found candidate in isolation map!
870  etahistisomatchreco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
871  ethistisomatchreco[n+1]->Fill(sortedReco[i].et(),mapi->val);
872  phiHistIsoMatchReco[n+1]->Fill(sortedReco[i].eta(),mapi->val);
873  }
874  }
875  }
876  }
877  } // END of if n+1 < then the number of hlt collections
878  }
879  // fill total reco matched efficiency
880  if (mtachedRecoParts >= reqNum )
881  totalmatchreco->Fill(n+0.5);
882  }
883 
884 }
885 
886 
888 // method called once each job just after ending the event loop //
891 
892 }
893 
int pdgGen
Definition: EmDQMReco.h:101
void fill(const math::XYZTLorentzVector &momentum)
Definition: EmDQMReco.cc:89
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:141
std::vector< std::vector< edm::InputTag > > isoNames
Definition: EmDQMReco.h:90
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
double energy() const
energy
Definition: Particle.h:76
void analyze(const edm::Event &event, const edm::EventSetup &)
Definition: EmDQMReco.cc:498
list parent
Definition: dbtoconf.py:74
const std::string & label
Definition: MVAComputer.cc:186
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
std::string dirname_
Definition: EmDQMReco.h:204
Definition: deltaR.h:51
boost::ptr_vector< FourVectorMonitorElements > histMatchReco
Definition: EmDQMReco.h:146
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int eventnum
Definition: EmDQMReco.h:199
void endJob()
Definition: EmDQMReco.cc:890
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:171
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:101
#define NULL
Definition: scimark2.h:8
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:88
T eta() const
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:165
unsigned int plotBins
Definition: EmDQMReco.h:111
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:172
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
bool isHltConfigInitialized_
Definition: EmDQMReco.h:94
double recoEtaAcc
Definition: EmDQMReco.h:102
void Fill(long long x)
HLTConfigProvider hltConfig_
Definition: EmDQMReco.h:93
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:30
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: EmDQMReco.cc:183
boost::ptr_vector< FourVectorMonitorElements > histMatchRecoMonPath
Definition: EmDQMReco.h:151
double recoEtAcc
Definition: EmDQMReco.h:103
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQMReco.h:207
int iEvent
Definition: GenABIO.cc:243
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQMReco.h:86
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:83
~EmDQMReco()
Destructor.
Definition: EmDQMReco.cc:490
T sqrt(T t)
Definition: SSEVec.h:28
double p4[4]
Definition: TauolaWrapper.h:92
MonitorElement * totalreco
Definition: EmDQMReco.h:178
MonitorElement * etaMonitorElement
Definition: EmDQMReco.h:55
int j
Definition: DBlmapReader.cc:9
MonitorElement * totalmatchreco
Definition: EmDQMReco.h:179
FourVectorMonitorElements(EmDQMReco *_parent, const std::string &histogramNameTemplate, const std::string &histogramTitleTemplate)
Definition: EmDQMReco.cc:48
void setVerbose(unsigned level)
Definition: DQMStore.cc:196
DQMStore * dbe
Definition: EmDQMReco.h:203
unsigned int recocut_
Definition: EmDQMReco.h:115
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:168
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:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::string triggerNameRecoMonPath
Definition: EmDQMReco.h:119
std::vector< bool > plotiso
Definition: EmDQMReco.h:89
bool useHumanReadableHistTitles
Definition: EmDQMReco.h:85
double plotPhiMax
Definition: EmDQMReco.h:108
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
MonitorElement * phiMonitorElement
Definition: EmDQMReco.h:56
unsigned int reqNum
Definition: EmDQMReco.h:100
boost::scoped_ptr< FourVectorMonitorElements > histRecoMonpath
Definition: EmDQMReco.h:191
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:163
boost::scoped_ptr< FourVectorMonitorElements > histMonpath
Definition: EmDQMReco.h:196
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:167
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
std::vector< std::pair< double, double > > plotBounds
Definition: EmDQMReco.h:91
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:81
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &, const edm::Event &, unsigned int, std::vector< reco::Particle > &, bool, bool)
Definition: EmDQMReco.cc:694
double plotPtMin
Definition: EmDQMReco.h:106
double plotPtMax
Definition: EmDQMReco.h:107
edm::InputTag recoElectronsInputTag
Definition: EmDQMReco.h:129
boost::ptr_vector< FourVectorMonitorElements > histHltObjMatchToReco
Definition: EmDQMReco.h:157
double plotEtaMax
Definition: EmDQMReco.h:105
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:164
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:642
std::string processNameRecoMonPath
Definition: EmDQMReco.h:124
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
boost::scoped_ptr< FourVectorMonitorElements > histReco
Definition: EmDQMReco.h:186
tuple size
Write out results.
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:169
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void beginJob()
Definition: EmDQMReco.cc:198
Definition: Run.h:32
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:173
list at
Definition: asciidump.py:428
Definition: DDAxes.h:10