CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCEmbeddingValidationAnalyzer.h
Go to the documentation of this file.
1 #ifndef TauAnalysis_MCEmbeddingTools_MCEmbeddingValidationAnalyzer_h
2 #define TauAnalysis_MCEmbeddingTools_MCEmbeddingValidationAnalyzer_h
3 
26 
30 
46 
47 /*#include "EGamma/EGammaAnalysisTools/interface/EGammaMvaEleEstimator.h"*/
56 
57 #include <TString.h>
58 #include <TArrayD.h>
59 
60 #include <string>
61 #include <vector>
62 
63 namespace
64 {
65  void countDecayProducts(const reco::GenParticle* genParticle,
66  int& numElectrons, int& numElecNeutrinos, int& numMuons, int& numMuNeutrinos,
67  int& numChargedHadrons, int& numPi0s, int& numOtherNeutralHadrons, int& numPhotons)
68  {
69  //std::cout << " genParticle: pdgId = " << genParticle->pdgId() << std::endl;
70 
71  int absPdgId = TMath::Abs(genParticle->pdgId());
72  int status = genParticle->status();
73  int charge = genParticle->charge();
74 
75  if ( absPdgId == 111 ) ++numPi0s;
76  else if ( status == 1 ) {
77  if ( absPdgId == 11 ) ++numElectrons;
78  else if ( absPdgId == 12 ) ++numElecNeutrinos;
79  else if ( absPdgId == 13 ) ++numMuons;
80  else if ( absPdgId == 14 ) ++numMuNeutrinos;
81  else if ( absPdgId == 15 ) {
82  edm::LogError ("countDecayProducts")
83  << "Found tau lepton with status code 1 !!";
84  return;
85  }
86  else if ( absPdgId == 16 ) return; // no need to count tau neutrinos
87  else if ( absPdgId == 22 ) ++numPhotons;
88  else if ( charge != 0 ) ++numChargedHadrons;
89  else ++numOtherNeutralHadrons;
90  } else {
91  unsigned numDaughters = genParticle->numberOfDaughters();
92  for ( unsigned iDaughter = 0; iDaughter < numDaughters; ++iDaughter ) {
93  const reco::GenParticle* daughter = genParticle->daughterRef(iDaughter).get();
94 
95  countDecayProducts(daughter,
96  numElectrons, numElecNeutrinos, numMuons, numMuNeutrinos,
97  numChargedHadrons, numPi0s, numOtherNeutralHadrons, numPhotons);
98  }
99  }
100  }
101 
102  std::string getGenTauDecayMode(const reco::GenParticle* genParticle)
103  {
104 //--- determine generator level tau decay mode
105 //
106 // NOTE:
107 // (1) function implements logic defined in PhysicsTools/JetMCUtils/src/JetMCTag::genTauDecayMode
108 // for different type of argument
109 // (2) this implementation should be more robust to handle cases of tau --> tau + gamma radiation
110 //
111 
112  //std::cout << "<MCEmbeddingValidationAnalyzer::getGenTauDecayMode>:" << std::endl;
113 
114  int numElectrons = 0;
115  int numElecNeutrinos = 0;
116  int numMuons = 0;
117  int numMuNeutrinos = 0;
118  int numChargedHadrons = 0;
119  int numPi0s = 0;
120  int numOtherNeutralHadrons = 0;
121  int numPhotons = 0;
122 
123  countDecayProducts(genParticle,
124  numElectrons, numElecNeutrinos, numMuons, numMuNeutrinos,
125  numChargedHadrons, numPi0s, numOtherNeutralHadrons, numPhotons);
126 
127  if ( numElectrons == 1 && numElecNeutrinos == 1 ) return std::string("electron");
128  else if ( numMuons == 1 && numMuNeutrinos == 1 ) return std::string("muon");
129 
130  switch ( numChargedHadrons ) {
131  case 1 :
132  if ( numOtherNeutralHadrons != 0 ) return std::string("oneProngOther");
133  switch ( numPi0s ) {
134  case 0:
135  return std::string("oneProng0Pi0");
136  case 1:
137  return std::string("oneProng1Pi0");
138  case 2:
139  return std::string("oneProng2Pi0");
140  default:
141  return std::string("oneProngOther");
142  }
143  case 3 :
144  if ( numOtherNeutralHadrons != 0 ) return std::string("threeProngOther");
145  switch ( numPi0s ) {
146  case 0:
147  return std::string("threeProng0Pi0");
148  case 1:
149  return std::string("threeProng1Pi0");
150  default:
151  return std::string("threeProngOther");
152  }
153  default:
154  return std::string("rare");
155  }
156  }
157 
158  MonitorElement* bookHistogram2D(DQMStore& dqmStore, const std::string& name, const std::string& title, int numBinsX, float* binningX, int numBinsY, float yMin, float yMax)
159  {
160  assert(numBinsY >= 1);
161  TArrayF binningY(numBinsY + 1);
162  float dy = (yMax - yMin)/numBinsY;
163  for ( int iBinY = 0; iBinY <= numBinsY; ++iBinY ) {
164  binningY[iBinY] = yMin + iBinY*dy;
165  }
166  MonitorElement* histogram = dqmStore.book2D(name, title, numBinsX, binningX, numBinsY, binningY.GetArray());
167  return histogram;
168  }
169 
170  std::pair<double, double> compMEtProjU(const reco::Candidate::LorentzVector& zP4, double metPx, double metPy, int& errorFlag, bool subtract_qT)
171  {
172  if ( zP4.pt() == 0. ) {
173  edm::LogWarning ("compMEtProjU")
174  << " Failed to compute projection, because Z0 candidate has zero Pt --> returning dummy solution !!";
175  errorFlag = 1;
176  return std::pair<double, double>(0., 0.);
177  }
178 
179  double qX = zP4.px();
180  double qY = zP4.py();
181  double qT = TMath::Sqrt(qX*qX + qY*qY);
182 
183  double uX = -metPx;
184  double uY = -metPy;
185  if ( subtract_qT ) {
186  uX -= qX;
187  uY -= qY;
188  }
189 
190  double u1 = (uX*qX + uY*qY)/qT;
191  double u2 = (uX*qY - uY*qX)/qT;
192 
193  return std::pair<double, double>(u1, u2);
194  }
195 }
196 
198 {
199  public:
202 
203  void analyze(const edm::Event&, const edm::EventSetup&);
204  void beginJob();
205 
206  private:
208 
209  std::string dqmDirectory_full(const std::string& dqmSubDirectory)
210  {
211  TString dqmDirectory_full = dqmDirectory_.data();
212  if ( !dqmDirectory_full.EndsWith("/") ) dqmDirectory_full.Append("/");
213  dqmDirectory_full.Append(dqmSubDirectory);
214  return dqmDirectory_full.Data();
215  }
216 
228  double dRminSeparation_; // CV: minimum separation in dR between replaced muons and embedded tau leptons
244  typedef std::vector<edm::InputTag> vInputTag;
247 
249 
251 
253 
255 
263 
269 
273 
279 
285 
308 
320 
323 
330 
336 
342 
371 
376 
385 
389 
391  {
393  const std::string& dqmDirectory)
394  : srcWeight_(srcWeight),
395  dqmDirectory_(dqmDirectory)
396  {
397  evtWeightKey_ = Form("%s_%s", srcWeight_.label().data(), srcWeight_.instance().data());
398  }
400  void bookHistograms(DQMStore& dqmStore)
401  {
402  dqmStore.setCurrentFolder(dqmDirectory_.data());
403  std::string histogramWeightName = Form("weight_%s_%s", srcWeight_.label().data(), srcWeight_.instance().data());
404  histogramWeight_ = dqmStore.book1D(histogramWeightName.data(), histogramWeightName.data(), 1001, -0.005, 10.005);
405  }
406  void fillHistograms(const edm::Event& evt, const std::map<std::string, double>& evtWeightMap_other)
407  {
409  evt.getByLabel(srcWeight_, weight);
410  double evtWeightOther = 1.;
411  for ( std::map<std::string, double>::const_iterator evtWeightEntry_other = evtWeightMap_other.begin();
412  evtWeightEntry_other != evtWeightMap_other.end(); ++evtWeightEntry_other ) {
413  if ( evtWeightEntry_other->first != evtWeightKey_ ) evtWeightOther *= evtWeightEntry_other->second;
414  }
415  histogramWeight_->Fill(*weight, evtWeightOther);
416  }
421  };
422 
423  std::vector<plotEntryTypeEvtWeight*> evtWeightPlotEntries_;
424 
426  {
427  plotEntryTypeMuonRadCorrUncertainty(int minJets, int maxJets,
428  const std::string& dqmDirectory)
429  : minJets_(minJets),
430  maxJets_(maxJets)
431  {
432  dqmDirectory_ = dqmDirectory;
433  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
434  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
435  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
436  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
437  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
438  }
440  void bookHistograms(DQMStore& dqmStore)
441  {
442  dqmStore.setCurrentFolder(dqmDirectory_.data());
443  histogramMuonPlusPt_unweighted_ = dqmStore.book1D("muonPlusPt_unweighted", "muonPlusPt_unweighted", 250, 0., 250.);
444  histogramMuonPlusPt_weighted_ = dqmStore.book1D("muonPlusPt_weighted", "muonPlusPt_weighted", 250, 0., 250.);
445  histogramMuonPlusPt_weightedUp_ = dqmStore.book1D("muonPlusPt_weightedUp", "muonPlusPt_weightedUp", 250, 0., 250.);
446  histogramMuonPlusPt_weightedDown_ = dqmStore.book1D("muonPlusPt_weightedDown", "muonPlusPt_weightedDown", 250, 0., 250.);
447  histogramMuonPlusEta_unweighted_ = dqmStore.book1D("muonPlusEta_unweighted", "muonPlusEta_unweighted", 198, -9.9, +9.9);
448  histogramMuonPlusEta_weighted_ = dqmStore.book1D("muonPlusEta_weighted", "muonPlusEta_weighted", 198, -9.9, +9.9);
449  histogramMuonPlusEta_weightedUp_ = dqmStore.book1D("muonPlusEta_weightedUp", "muonPlusEta_weightedUp", 198, -9.9, +9.9);
450  histogramMuonPlusEta_weightedDown_ = dqmStore.book1D("muonPlusEta_weightedDown", "muonPlusEta_weightedDown", 198, -9.9, +9.9);
451  histogramMuonMinusPt_unweighted_ = dqmStore.book1D("muonMinusPt_unweighted", "muonMinusPt_unweighted", 250, 0., 250.);
452  histogramMuonMinusPt_weighted_ = dqmStore.book1D("muonMinusPt_weighted", "muonMinusPt_weighted", 250, 0., 250.);
453  histogramMuonMinusPt_weightedUp_ = dqmStore.book1D("muonMinusPt_weightedUp", "muonMinusPt_weightedUp", 250, 0., 250.);
454  histogramMuonMinusPt_weightedDown_ = dqmStore.book1D("muonMinusPt_weightedDown", "muonMinusPt_weightedDown", 250, 0., 250.);
455  histogramMuonMinusEta_unweighted_ = dqmStore.book1D("muonMinusEta_unweighted", "muonMinusEta_unweighted", 198, -9.9, +9.9);
456  histogramMuonMinusEta_weighted_ = dqmStore.book1D("muonMinusEta_weighted", "muonMinusEta_weighted", 198, -9.9, +9.9);
457  histogramMuonMinusEta_weightedUp_ = dqmStore.book1D("muonMinusEta_weightedUp", "muonMinusEta_weightedUp", 198, -9.9, +9.9);
458  histogramMuonMinusEta_weightedDown_ = dqmStore.book1D("muonMinusEta_weightedDown", "muonMinusEta_weightedDown", 198, -9.9, +9.9);
459  histogramDiMuonMass_unweighted_ = dqmStore.book1D("diMuonMass_unweighted", "diMuonMass_unweighted", 250, 0., 250.);
460  histogramDiMuonMass_weighted_ = dqmStore.book1D("diMuonMass_weighted", "diMuonMass_weighted", 250, 0., 250.);
461  histogramDiMuonMass_weightedUp_ = dqmStore.book1D("diMuonMass_weightedUp", "diMuonMass_weightedUp", 250, 0., 250.);
462  histogramDiMuonMass_weightedDown_ = dqmStore.book1D("diMuonMass_weightedDown", "diMuonMass_weightedDown", 250, 0., 250.);
463  histogramMuonRadCorrWeight_ = dqmStore.book1D("muonRadCorrWeight", "muonRadCorrWeight", 1001, -0.005, 10.005);
464  histogramMuonRadCorrWeightUp_ = dqmStore.book1D("muonRadCorrWeightUp", "muonRadCorrWeightUp", 1001, -0.005, 10.005);
465  histogramMuonRadCorrWeightDown_ = dqmStore.book1D("muonRadCorrWeightDown", "muonRadCorrWeightDown", 1001, -0.005, 10.005);
466  }
467  void fillHistograms(int numJets,
468  const reco::Candidate::LorentzVector& muonPlusP4, const reco::Candidate::LorentzVector& muonMinusP4,
469  double evtWeight_others, double muonRadCorrWeight, double muonRadCorrWeightUp, double muonRadCorrWeightDown)
470  {
471  if ( (minJets_ == -1 || numJets >= minJets_) &&
472  (maxJets_ == -1 || numJets <= maxJets_) ) {
473  histogramMuonPlusPt_unweighted_->Fill(muonPlusP4.pt(), evtWeight_others);
474  histogramMuonPlusPt_weighted_->Fill(muonPlusP4.pt(), evtWeight_others*muonRadCorrWeight);
475  histogramMuonPlusPt_weightedUp_->Fill(muonPlusP4.pt(), evtWeight_others*muonRadCorrWeightUp);
476  histogramMuonPlusPt_weightedDown_->Fill(muonPlusP4.pt(), evtWeight_others*muonRadCorrWeightDown);
477  histogramMuonPlusEta_unweighted_->Fill(muonPlusP4.eta(), evtWeight_others);
478  histogramMuonPlusEta_weighted_->Fill(muonPlusP4.eta(), evtWeight_others*muonRadCorrWeight);
479  histogramMuonPlusEta_weightedUp_->Fill(muonPlusP4.eta(), evtWeight_others*muonRadCorrWeightUp);
480  histogramMuonPlusEta_weightedDown_->Fill(muonPlusP4.eta(), evtWeight_others*muonRadCorrWeightDown);
481  histogramMuonMinusPt_unweighted_->Fill(muonMinusP4.pt(), evtWeight_others);
482  histogramMuonMinusPt_weighted_->Fill(muonMinusP4.pt(), evtWeight_others*muonRadCorrWeight);
483  histogramMuonMinusPt_weightedUp_->Fill(muonMinusP4.pt(), evtWeight_others*muonRadCorrWeightUp);
484  histogramMuonMinusPt_weightedDown_->Fill(muonMinusP4.pt(), evtWeight_others*muonRadCorrWeightDown);
485  histogramMuonMinusEta_unweighted_->Fill(muonMinusP4.eta(), evtWeight_others);
486  histogramMuonMinusEta_weighted_->Fill(muonMinusP4.eta(), evtWeight_others*muonRadCorrWeight);
487  histogramMuonMinusEta_weightedUp_->Fill(muonMinusP4.eta(), evtWeight_others*muonRadCorrWeightUp);
488  histogramMuonMinusEta_weightedDown_->Fill(muonMinusP4.eta(), evtWeight_others*muonRadCorrWeightDown);
489  double diMuonMass = (muonPlusP4 + muonMinusP4).mass();
490  histogramDiMuonMass_unweighted_->Fill(diMuonMass, evtWeight_others);
491  histogramDiMuonMass_weighted_->Fill(diMuonMass, evtWeight_others*muonRadCorrWeight);
492  histogramDiMuonMass_weightedUp_->Fill(diMuonMass, evtWeight_others*muonRadCorrWeightUp);
493  histogramDiMuonMass_weightedDown_->Fill(diMuonMass, evtWeight_others*muonRadCorrWeightDown);
494  histogramMuonRadCorrWeight_->Fill(muonRadCorrWeight, evtWeight_others);
495  histogramMuonRadCorrWeightUp_->Fill(muonRadCorrWeightUp, evtWeight_others);
496  histogramMuonRadCorrWeightDown_->Fill(muonRadCorrWeightDown, evtWeight_others);
497  }
498  }
499  int minJets_;
500  int maxJets_;
525  };
526 
527  std::vector<plotEntryTypeMuonRadCorrUncertainty*> muonRadCorrUncertaintyPlotEntries_beforeRad_;
528  std::vector<plotEntryTypeMuonRadCorrUncertainty*> muonRadCorrUncertaintyPlotEntries_afterRad_;
529  std::vector<plotEntryTypeMuonRadCorrUncertainty*> muonRadCorrUncertaintyPlotEntries_afterRadAndCorr_;
532 
534  {
536  : genTauDecayMode_(genTauDecayMode)
537  {
538  dqmDirectory_ = dqmDirectory;
539  if ( genTauDecayMode != "" ) dqmDirectory_.append("_").append(genTauDecayMode);
540  }
542  void bookHistograms(DQMStore& dqmStore)
543  {
544  dqmStore.setCurrentFolder(dqmDirectory_.data());
545  const int qTnumBins = 34;
546  float qTbinning[qTnumBins + 1] = {
547  0., 2.5, 5., 7.5, 10., 12.5, 15., 17.5, 20., 22.5, 25., 27.5, 30., 35., 40., 45., 50.,
548  60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 200., 220., 240., 260., 300.
549  };
550  histogramL1ETM_ = dqmStore.book1D( "L1ETM", "L1ETM", 250, 0., 250.);
551  histogramL1ETM_vs_genCaloMEt_ = dqmStore.book2D( "L1ETM_vs_genCaloMEt", "L1ETM_vs_genCaloMEt", 250, 0., 250., 250, 0., 250.);
552  histogramL1ETM_vs_recCaloMEt_ = dqmStore.book2D( "L1ETM_vs_recCaloMEt", "L1ETM_vs_recCaloMEt", 250, 0., 250., 250, 0., 250.);
553  histogramL1ETMparlZdivQtVsQt_ = bookHistogram2D(dqmStore, "L1ETMparlZdivQtVsQt", "L1ETMparlZdivQtVsQt", qTnumBins, qTbinning, 400, -5., +5.);
554  histogramL1ETMparlZvsQt_ = bookHistogram2D(dqmStore, "L1ETMparlZvsQt", "L1ETMparlZvsQt", qTnumBins, qTbinning, 400, -500., +500.);
555  histogramL1ETMperpZvsQt_ = bookHistogram2D(dqmStore, "L1ETMperpZvsQt", "L1ETMperpZvsQt", qTnumBins, qTbinning, 60, -75., +75.);
556  histogramRecCaloMEtParlZdivQtVsQt_ = bookHistogram2D(dqmStore, "recCaloMEtParlZdivQtVsQt", "recCaloMEtParlZdivQtVsQt", qTnumBins, qTbinning, 400, -5., +5.);
557  histogramRecCaloMEtParlZvsQt_ = bookHistogram2D(dqmStore, "recCaloMEtParlZvsQt", "recCaloMEtParlZvsQt", qTnumBins, qTbinning, 400, -500., +500.);
558  histogramRecCaloMEtPerpZvsQt_ = bookHistogram2D(dqmStore, "recCaloMEtPerpZvsQt", "recCaloMEtPerpZvsQt", qTnumBins, qTbinning, 60, -75., +75.);
559  histogramL1ETMminusGenCaloMEtParlZdivQtVsQt_ = bookHistogram2D(dqmStore, "L1ETMminusGenCaloMEtParlZdivQtVsQt", "L1ETMminusGenCaloMEtParlZdivQtVsQt", qTnumBins, qTbinning, 400, -5., +5.);
560  histogramL1ETMminusGenCaloMEtParlZvsQt_ = bookHistogram2D(dqmStore, "L1ETMminusGenCaloMEtParlZvsQt", "L1ETMminusGenCaloMEtParlZvsQt", qTnumBins, qTbinning, 400, -500., +500.);
561  histogramL1ETMminusGenCaloMEtPerpZvsQt_ = bookHistogram2D(dqmStore, "L1ETMminusGenCaloMEtPerpZvsQt", "L1ETMminusGenCaloMEtPerpZvsQt", qTnumBins, qTbinning, 60, -75., +75.);
562  histogramL1ETMminusRecCaloMEtParlZdivQtVsQt_ = bookHistogram2D(dqmStore, "L1ETMminusRecCaloMEtParlZdivQtVsQt", "L1ETMminusRecCaloMEtParlZdivQtVsQt", qTnumBins, qTbinning, 400, -5., +5.);
563  histogramL1ETMminusRecCaloMEtParlZvsQt_ = bookHistogram2D(dqmStore, "L1ETMminusRecCaloMEtParlZvsQt", "L1ETMminusRecCaloMEtParlZvsQt", qTnumBins, qTbinning, 400, -500., +500.);
564  histogramL1ETMminusRecCaloMEtPerpZvsQt_ = bookHistogram2D(dqmStore, "L1ETMminusRecCaloMEtPerpZvsQt", "L1ETMminusRecCaloMEtPerpZvsQt", qTnumBins, qTbinning, 60, -75., +75.);
565  histogramQt_ = dqmStore.book1D( "qT", "qT", 600, 0., 300.);
566  }
567  void fillHistograms(const std::string& genTauDecayMode_ref,
568  const reco::Candidate::LorentzVector& l1MEtP4, const reco::Candidate::LorentzVector& genCaloMEtP4, const reco::Candidate::LorentzVector& recCaloMEtP4,
569  const reco::Candidate::LorentzVector& genDiTauP4, double evtWeight)
570  {
571  if ( genTauDecayMode_ == "" || genTauDecayMode_ref == genTauDecayMode_ ) {
572  histogramL1ETM_->Fill(l1MEtP4.pt(), evtWeight);
573  histogramL1ETM_vs_genCaloMEt_->Fill(genCaloMEtP4.pt(), l1MEtP4.pt(), evtWeight);
574  histogramL1ETM_vs_recCaloMEt_->Fill(recCaloMEtP4.pt(), l1MEtP4.pt(), evtWeight);
575  double qT = genDiTauP4.pt();
576  int errorFlag = 0;
577  std::pair<double, double> uT = compMEtProjU(genDiTauP4, l1MEtP4.px(), l1MEtP4.py(), errorFlag, false);
578  if ( !errorFlag ) {
579  double uParl = uT.first;
580  double uPerp = uT.second;
581  if ( qT > 0. ) histogramL1ETMparlZdivQtVsQt_->Fill(qT, uParl/qT, evtWeight);
582  histogramL1ETMparlZvsQt_->Fill(qT, uParl, evtWeight);
583  histogramL1ETMperpZvsQt_->Fill(qT, uPerp, evtWeight);
584  }
585  errorFlag = 0;
586  uT = compMEtProjU(genDiTauP4, recCaloMEtP4.px(), recCaloMEtP4.py(), errorFlag, false);
587  if ( !errorFlag ) {
588  double uParl = uT.first;
589  double uPerp = uT.second;
590  if ( qT > 0. ) histogramRecCaloMEtParlZdivQtVsQt_->Fill(qT, uParl/qT, evtWeight);
591  histogramRecCaloMEtParlZvsQt_->Fill(qT, uParl, evtWeight);
592  histogramRecCaloMEtPerpZvsQt_->Fill(qT, uPerp, evtWeight);
593  }
594  errorFlag = 0;
595  uT = compMEtProjU(genDiTauP4, l1MEtP4.px() - genCaloMEtP4.px(), l1MEtP4.py() - genCaloMEtP4.py(), errorFlag, false);
596  if ( !errorFlag ) {
597  double uParl = uT.first;
598  double uPerp = uT.second;
599  if ( qT > 0. ) histogramL1ETMminusGenCaloMEtParlZdivQtVsQt_->Fill(qT, uParl/qT, evtWeight);
600  histogramL1ETMminusGenCaloMEtParlZvsQt_->Fill(qT, uParl, evtWeight);
601  histogramL1ETMminusGenCaloMEtPerpZvsQt_->Fill(qT, uPerp, evtWeight);
602  }
603  errorFlag = 0;
604  uT = compMEtProjU(genDiTauP4, l1MEtP4.px() - recCaloMEtP4.px(), l1MEtP4.py() - recCaloMEtP4.py(), errorFlag, false);
605  if ( !errorFlag ) {
606  double uParl = uT.first;
607  double uPerp = uT.second;
608  if ( qT > 0. ) histogramL1ETMminusRecCaloMEtParlZdivQtVsQt_->Fill(qT, uParl/qT, evtWeight);
609  histogramL1ETMminusRecCaloMEtParlZvsQt_->Fill(qT, uParl, evtWeight);
610  histogramL1ETMminusRecCaloMEtPerpZvsQt_->Fill(qT, uPerp, evtWeight);
611  }
612  histogramQt_->Fill(qT, evtWeight);
613  }
614  }
633  };
634 
635  std::vector<plotEntryTypeL1ETM*> l1ETMplotEntries_;
636 
637  template <typename T>
639  {
640  leptonDistributionT(int minJets, int maxJets,
641  const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec, double dRmatch, const std::string& dqmDirectory)
642  : minJets_(minJets),
643  maxJets_(maxJets),
644  srcGen_(srcGen),
645  cutGen_(0),
646  srcRec_(srcRec),
647  cutRec_(0),
648  dRmatch_(dRmatch),
649  dqmDirectory_(dqmDirectory)
650  {
651  if ( cutGen != "" ) cutGen_ = new StringCutObjectSelector<reco::Candidate>(cutGen);
652  if ( cutRec != "" ) cutRec_ = new StringCutObjectSelector<T>(cutRec);
653  dqmDirectory_ = dqmDirectory;
654  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
655  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
656  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
657  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
658  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
659  }
661  {
662  delete cutGen_;
663  delete cutRec_;
664  }
665  void bookHistograms(DQMStore& dqmStore)
666  {
667  dqmStore.setCurrentFolder(dqmDirectory_.data());
668  histogramNumGenLeptons_ = dqmStore.book1D("numGenLeptons", "numGenLeptons", 10, -0.5, 9.5);
669  histogramGenLeptonPt_ = dqmStore.book1D("genLeptonPt", "genLeptonPt", 250, 0., 250.);
670  histogramGenLeptonEta_ = dqmStore.book1D("genLeptonEta", "genLeptonEta", 198, -9.9, +9.9);
671  histogramGenLeptonPhi_ = dqmStore.book1D("genLeptonPhi", "genLeptonPhi", 72, -TMath::Pi(), +TMath::Pi());
672  histogramNumRecLeptons_ = dqmStore.book1D("numRecLeptons", "numRecLeptons", 10, -0.5, 9.5);
673  histogramRecLeptonPt_ = dqmStore.book1D("recLeptonPt", "recLeptonPt", 250, 0., 250.);
674  histogramRecLeptonEta_ = dqmStore.book1D("recLeptonEta", "recLeptonEta", 198, -9.9, +9.9);
675  histogramRecLeptonPhi_ = dqmStore.book1D("recLeptonPhi", "recLeptonPhi", 72, -TMath::Pi(), +TMath::Pi());
676  histogramRecMinusGenLeptonPt_ = dqmStore.book1D("recMinusGenLeptonPt", "recMinusGenLeptonPt", 200, -100., +100.);
677  histogramRecMinusGenLeptonPt_div_genLeptonPt_ = dqmStore.book1D("recMinusGenLeptonPt_div_genLeptonPt", "recMinusGenLeptonPt_div_genLeptonPt", 200, 0., 2.);
678  histogramRecMinusGenLeptonEta_ = dqmStore.book1D("recMinusGenLeptonEta", "recMinusGenLeptonEta", 100, -0.5, +0.5);
679  histogramRecMinusGenLeptonPhi_ = dqmStore.book1D("recMinusGenLeptonPhi", "recMinusGenLeptonPhi", 100, -0.5, +0.5);
680  }
681  void fillHistograms(int numJets,
682  const edm::Event& evt, double evtWeight)
683  {
684  if ( (minJets_ == -1 || numJets >= minJets_) &&
685  (maxJets_ == -1 || numJets <= maxJets_) ) {
687  edm::Handle<CandidateView> genLeptons;
688  evt.getByLabel(srcGen_, genLeptons);
689  histogramNumGenLeptons_->Fill(genLeptons->size(), evtWeight);
690  typedef std::vector<T> recLeptonCollection;
692  evt.getByLabel(srcRec_, recLeptons);
693  histogramNumRecLeptons_->Fill(recLeptons->size(), evtWeight);
694  for ( CandidateView::const_iterator genLepton = genLeptons->begin();
695  genLepton != genLeptons->end(); ++genLepton ) {
696  if ( cutGen_ && !(*cutGen_)(*genLepton) ) continue;
697  for ( typename recLeptonCollection::const_iterator recLepton = recLeptons->begin();
698  recLepton != recLeptons->end(); ++recLepton ) {
699  if ( cutRec_ && !(*cutRec_)(*recLepton) ) continue;
700  double dR = deltaR(genLepton->p4(), recLepton->p4());
701  if ( dR < dRmatch_ ) {
702  histogramGenLeptonPt_->Fill(genLepton->pt(), evtWeight);
703  histogramGenLeptonEta_->Fill(genLepton->eta(), evtWeight);
704  histogramGenLeptonPhi_->Fill(genLepton->phi(), evtWeight);
705  histogramRecLeptonPt_->Fill(recLepton->pt(), evtWeight);
706  histogramRecLeptonEta_->Fill(recLepton->eta(), evtWeight);
707  histogramRecLeptonPhi_->Fill(recLepton->phi(), evtWeight);
708  histogramRecMinusGenLeptonPt_->Fill(recLepton->pt() - genLepton->pt(), evtWeight);
709  if ( genLepton->pt() > 0. ) histogramRecMinusGenLeptonPt_div_genLeptonPt_->Fill((recLepton->pt() - genLepton->pt())/genLepton->pt(), evtWeight);
710  histogramRecMinusGenLeptonEta_->Fill(recLepton->eta() - genLepton->eta(), evtWeight);
711  histogramRecMinusGenLeptonPhi_->Fill(recLepton->phi() - genLepton->phi(), evtWeight);
712  }
713  }
714  }
715  }
716  }
717  int minJets_;
718  int maxJets_;
723  double dRmatch_;
737  };
738 
740  {
741  electronDistributionExtra(int minJets, int maxJets,
742  const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec,
743  double dRmatch, const std::string& dqmDirectory,
744  const edm::InputTag& srcTheRecVertex,
746  : minJets_(minJets),
747  maxJets_(maxJets),
748  srcGen_(srcGen),
749  cutGen_(0),
750  srcRec_(srcRec),
751  cutRec_(0),
752  dRmatch_(dRmatch),
753  srcTheRecVertex_(srcTheRecVertex),
754  ebRHToken_(tk1),
755  eeRHToken_(tk2)
756  {
757  if ( cutGen != "" ) cutGen_ = new StringCutObjectSelector<reco::Candidate>(cutGen);
758  if ( cutRec != "" ) cutRec_ = new StringCutObjectSelector<pat::Electron>(cutRec);
759  dqmDirectory_ = dqmDirectory;
760  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
761  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
762  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
763  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
764  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
765  /*if ( !fMVA_isInitialized_ ) {
766  std::vector<std::string> mvaWeightFiles;
767  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat1.weights.xml");
768  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat2.weights.xml");
769  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat3.weights.xml");
770  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat4.weights.xml");
771  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat5.weights.xml");
772  mvaWeightFiles.push_back("EGamma/EGammaAnalysisTools/data/Electrons_BDTG_NonTrigV0_Cat6.weights.xml");
773  std::vector<std::string> mvaWeightFiles_full;
774  for ( std::vector<std::string>::const_iterator mvaWeightFile = mvaWeightFiles.begin();
775  mvaWeightFile != mvaWeightFiles.end(); ++mvaWeightFile ) {
776  edm::FileInPath mvaWeightFile_full(*mvaWeightFile);
777  if ( mvaWeightFile_full.location() == edm::FileInPath::Unknown )
778  throw cms::Exception("MCEmbeddingValidationAnalyzer")
779  << " Failed to find File = " << (*mvaWeightFile) << " !!\n";
780  mvaWeightFiles_full.push_back(mvaWeightFile_full.fullPath());
781  }
782  fMVA_ = new EGammaMvaEleEstimator();
783  fMVA_->initialize("BDT",
784  EGammaMvaEleEstimator::kNonTrig,
785  true,
786  mvaWeightFiles_full);
787  fMVA_isInitialized_ = true;
788  }*/
789  }
791  {
792  delete cutGen_;
793  delete cutRec_;
794  /*if ( fMVA_isInitialized_ ) {
795  delete fMVA_;
796  fMVA_ = 0;
797  fMVA_isInitialized_ = false;
798  }*/
799  }
800  void bookHistograms(DQMStore& dqmStore)
801  {
802  dqmStore.setCurrentFolder(dqmDirectory_.data());
803  histogramMVAptLt20AbsEtaLt0_8_ = dqmStore.book1D("MVAptLt20AbsEtaLt0_8", "MVAptLt20AbsEtaLt0_8", 201, -1.005, +1.005);
804  histogramMVAptLt20AbsEta0_8to1_479_ = dqmStore.book1D("MVAptLt20AbsEta0_8to1_479", "MVAptLt20AbsEta0_8to1_479", 201, -1.005, +1.005);
805  histogramMVAptLt20AbsEtaGt1_479_ = dqmStore.book1D("MVAptLt20AbsEtaGt1_479", "MVAptLt20AbsEtaGt1_479", 201, -1.005, +1.005);
806  histogramMVAptGt20AbsEtaLt0_8_ = dqmStore.book1D("MVAptGt20AbsEtaLt0_8", "MVAptGt20AbsEtaLt0_8", 201, -1.005, +1.005);
807  histogramMVAptGt20AbsEta0_8to1_479_ = dqmStore.book1D("MVAptGt20AbsEta0_8to1_479", "MVAptGt20AbsEta0_8to1_479", 201, -1.005, +1.005);
808  histogramMVAptGt20AbsEtaGt1_479_ = dqmStore.book1D("MVAptGt20AbsEtaGt1_479", "MVAptGt20AbsEtaGt1_479", 201, -1.005, +1.005);
809  histogramFBrem_ = dqmStore.book1D("fBrem", "fBrem", 1100, -1., +10.);
810  histogramKFchi2_ = dqmStore.book1D("kfChi2", "kfChi2", 1001, -0.05, +100.05);
811  histogramNumKFhits_ = dqmStore.book1D("numKFhits", "numKFhits", 25, -0.5, +24.5);
812  histogramGSFchi2_ = dqmStore.book1D("gsfChi2", "gsfChi2", 1001, -0.05, +100.05);
813  histogramDEta_ = dqmStore.book1D("dEta", "dEta", 1000, -0.5, +0.5);
814  histogramDPhi_ = dqmStore.book1D("dPhi", "dPhi", 1000, -0.5, +0.5);
815  histogramDEtaCalo_ = dqmStore.book1D("dEtaCalo", "dEtaCalo", 1000, -0.5, +0.5);
816  histogramSee_ = dqmStore.book1D("See", "See", 500, 0., 0.5);
817  histogramSpp_ = dqmStore.book1D("Spp", "Spp", 500, 0., 0.5);
818  histogramEtaWidth_ = dqmStore.book1D("etaWidth", "etaWidth", 500, 0., 0.5);
819  histogramPhiWidth_ = dqmStore.book1D("phiWidth", "phiWidth", 500, 0., 0.5);
820  histogramOneMinusE1x5E5x5_ = dqmStore.book1D("oneMinusE1x5E5x5", "oneMinusE1x5E5x5", 201, -1.005, +1.005);
821  histogramR9_ = dqmStore.book1D("R9", "R9", 1000, 0., 10.);
822  histogramHoE_ = dqmStore.book1D("HoE", "HoE", 200, -1., +1.);
823  histogramEoP_ = dqmStore.book1D("EoP", "EoP", 1000, 0., 10.);
824  histogramIoEmIoP_ = dqmStore.book1D("IoEmIoP", "IoEmIoP", 1000, 0., 10.);
825  histogramEleEoPout_ = dqmStore.book1D("EleEoPout", "EleEoPout", 1000, 0., 10.);
826  histogramPreShowerOverRaw_ = dqmStore.book1D("PreShowerOverRaw", "PreShowerOverRaw", 1000, 0., 10.);
827  histogramD0_ = dqmStore.book1D("D0", "D0", 1000, 0., 0.1);
828  histogramIP3d_ = dqmStore.book1D("IP3d", "IP3d", 5000, 0., 0.5);
829  histogramEta_ = dqmStore.book1D("eta", "eta", 198, -9.9, +9.9);
830  histogramPt_ = dqmStore.book1D("pt", "pt", 250, 0., 250.);
831  histogramCharge_ = dqmStore.book1D("charge", "charge", 3, -1.5, +1.5);
832  histogramFlags_ = dqmStore.book1D("flags", "flags", 12, -0.5, +11.5);
833  }
834  void fillHistograms(int numJets,
835  const edm::Event& evt, const edm::EventSetup& es, double evtWeight)
836  {
837  if ( (minJets_ == -1 || numJets >= minJets_) &&
838  (maxJets_ == -1 || numJets <= maxJets_) ) {
840  edm::Handle<CandidateView> genLeptons;
841  evt.getByLabel(srcGen_, genLeptons);
842  typedef std::vector<pat::Electron> recLeptonCollection;
844  evt.getByLabel(srcRec_, recLeptons);
845  for ( CandidateView::const_iterator genLepton = genLeptons->begin();
846  genLepton != genLeptons->end(); ++genLepton ) {
847  if ( cutGen_ && !(*cutGen_)(*genLepton) ) continue;
848  for ( recLeptonCollection::const_iterator recLepton = recLeptons->begin();
849  recLepton != recLeptons->end(); ++recLepton ) {
850  if ( cutRec_ && !(*cutRec_)(*recLepton) ) continue;
851  double dR = deltaR(genLepton->p4(), recLepton->p4());
852  if ( dR < dRmatch_ ) {
854  evt.getByLabel(srcTheRecVertex_, theVertex);
855  if ( !(theVertex->size() >= 1) ) return;
856  edm::ESHandle<TransientTrackBuilder> trackBuilderHandle;
857  es.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilderHandle);
858  const TransientTrackBuilder* trackBuilder = trackBuilderHandle.product();
859  if ( !trackBuilder )
860  throw cms::Exception("MCEmbeddingValidationAnalyzer")
861  << " Failed to access TransientTrackBuilder !!\n";
862  EcalClusterLazyTools myEcalCluster(evt, es, ebRHToken_, eeRHToken_);
863  /*double mva = fMVA_->mvaValue(*recLepton, theVertex->front(), *trackBuilder, myEcalCluster);
864  if ( recLepton->pt() < 20. ) {
865  if ( TMath::Abs(recLepton->eta()) < 0.8 ) histogramMVAptLt20AbsEtaLt0_8_->Fill(mva, evtWeight);
866  else if ( TMath::Abs(recLepton->eta()) < 1.479 ) histogramMVAptLt20AbsEta0_8to1_479_->Fill(mva, evtWeight);
867  else histogramMVAptLt20AbsEtaGt1_479_->Fill(mva, evtWeight);
868  } else {
869  if ( TMath::Abs(recLepton->eta()) < 0.8 ) histogramMVAptGt20AbsEtaLt0_8_->Fill(mva, evtWeight);
870  else if ( TMath::Abs(recLepton->eta()) < 1.479 ) histogramMVAptGt20AbsEta0_8to1_479_->Fill(mva, evtWeight);
871  else histogramMVAptGt20AbsEtaGt1_479_->Fill(mva, evtWeight);
872  }
873  histogramFBrem_->Fill(fMVA_->fBrem(), evtWeight);
874  histogramKFchi2_->Fill(fMVA_->kfChi2(), evtWeight);
875  histogramNumKFhits_->Fill(fMVA_->numKFhits(), evtWeight);
876  histogramGSFchi2_->Fill(fMVA_->gsfChi2(), evtWeight);
877  histogramDEta_->Fill(fMVA_->dEta(), evtWeight);
878  histogramDPhi_->Fill(fMVA_->dPhi(), evtWeight);
879  histogramDEtaCalo_->Fill(fMVA_->dEtaCalo(), evtWeight);
880  histogramSee_->Fill(fMVA_->See(), evtWeight);
881  histogramSpp_->Fill(fMVA_->Spp(), evtWeight);
882  histogramEtaWidth_->Fill(fMVA_->etaWidth(), evtWeight);
883  histogramPhiWidth_->Fill(fMVA_->phiWidth(), evtWeight);
884  histogramOneMinusE1x5E5x5_->Fill(fMVA_->oneMinusE1x5E5x5(), evtWeight);
885  histogramR9_->Fill(fMVA_->R9(), evtWeight);
886  histogramHoE_->Fill(fMVA_->HoE(), evtWeight);
887  histogramEoP_->Fill(fMVA_->EoP(), evtWeight);
888  histogramIoEmIoP_->Fill(fMVA_->IoEmIoP(), evtWeight);
889  histogramEleEoPout_->Fill(fMVA_->eleEoPout(), evtWeight);
890  histogramPreShowerOverRaw_->Fill(fMVA_->preShowerOverRaw(), evtWeight);
891  histogramD0_->Fill(fMVA_->d0(), evtWeight);
892  //std::cout << "d0 = " << fMVA_->d0() << std::endl;
893  histogramIP3d_->Fill(fMVA_->ip3d(), evtWeight);
894  //std::cout << "ip3d = " << fMVA_->ip3d() << std::endl;
895  histogramEta_->Fill(fMVA_->eta(), evtWeight);
896  histogramPt_->Fill(fMVA_->pt(), evtWeight);*/
897  histogramCharge_->Fill(recLepton->charge(), evtWeight);
898  histogramFlags_->Fill(0, evtWeight);
899  if ( recLepton->isEB() ) histogramFlags_->Fill(1, evtWeight);
900  if ( recLepton->isEE() ) histogramFlags_->Fill(2, evtWeight);
901  if ( recLepton->isEBEEGap() ) histogramFlags_->Fill(3, evtWeight);
902  if ( recLepton->isEBEtaGap() ) histogramFlags_->Fill(4, evtWeight);
903  if ( recLepton->isEBPhiGap() ) histogramFlags_->Fill(5, evtWeight);
904  if ( recLepton->isEEDeeGap() ) histogramFlags_->Fill(6, evtWeight);
905  if ( recLepton->isEERingGap() ) histogramFlags_->Fill(7, evtWeight);
906  if ( recLepton->ecalDrivenSeed() ) histogramFlags_->Fill(8, evtWeight);
907  if ( recLepton->trackerDrivenSeed() ) histogramFlags_->Fill(9, evtWeight);
908  if ( recLepton->superCluster().isNonnull() || recLepton->superCluster().id() != recLepton->parentSuperCluster().id() ) histogramFlags_->Fill(10, evtWeight);
909  if ( recLepton->parentSuperCluster().isNonnull() ) histogramFlags_->Fill(11, evtWeight);
910  }
911  }
912  }
913  }
914  }
915  int minJets_;
916  int maxJets_;
921  double dRmatch_;
923  /*static EGammaMvaEleEstimator* fMVA_;
924  static bool fMVA_isInitialized_;*/
957  };
958 
960  {
961  tauDistributionExtra(int minJets, int maxJets,
962  const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec, double dRmatch, const std::string& dqmDirectory)
963  : minJets_(minJets),
964  maxJets_(maxJets),
965  srcGen_(srcGen),
966  cutGen_(0),
967  srcRec_(srcRec),
968  cutRec_(0),
969  dRmatch_(dRmatch)
970  {
971  if ( cutGen != "" ) cutGen_ = new StringCutObjectSelector<reco::Candidate>(cutGen);
972  if ( cutRec != "" ) cutRec_ = new StringCutObjectSelector<pat::Tau>(cutRec);
973  dqmDirectory_ = dqmDirectory;
974  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
975  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
976  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
977  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
978  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
979  }
981  {
982  delete cutGen_;
983  delete cutRec_;
984  }
985  void bookHistograms(DQMStore& dqmStore)
986  {
987  dqmStore.setCurrentFolder(dqmDirectory_.data());
988  histogramGenTauDecayMode_ = dqmStore.book1D("genTauDecayMode", "genTauDecayMode", 21, -1.5, +19.5);
989  histogramRecTauDecayMode_ = dqmStore.book1D("recTauDecayMode", "recTauDecayMode", 21, -1.5, +19.5);
990  }
991  void fillHistograms(int numJets,
992  const edm::Event& evt, double evtWeight)
993  {
994  if ( (minJets_ == -1 || numJets >= minJets_) &&
995  (maxJets_ == -1 || numJets <= maxJets_) ) {
997  edm::Handle<CandidateView> genLeptons;
998  evt.getByLabel(srcGen_, genLeptons);
999  typedef std::vector<pat::Tau> recLeptonCollection;
1001  evt.getByLabel(srcRec_, recLeptons);
1002  for ( CandidateView::const_iterator genLepton = genLeptons->begin();
1003  genLepton != genLeptons->end(); ++genLepton ) {
1004  if ( cutGen_ && !(*cutGen_)(*genLepton) ) continue;
1005  const reco::CompositePtrCandidate* genLepton_composite = dynamic_cast<const reco::CompositePtrCandidate*>(&(*genLepton));
1006  for ( recLeptonCollection::const_iterator recLepton = recLeptons->begin();
1007  recLepton != recLeptons->end(); ++recLepton ) {
1008  if ( cutRec_ && !(*cutRec_)(*recLepton) ) continue;
1009  double dR = deltaR(genLepton->p4(), recLepton->p4());
1010  if ( dR < dRmatch_ ) {
1011  std::string genTauDecayMode_string = JetMCTagUtils::genTauDecayMode(*genLepton_composite);
1012  //std::cout << "--> genTauDecayMode: = " << genTauDecayMode_string << std::endl;
1013  int genTauDecayMode = -1;
1014  if ( genTauDecayMode_string == "electron" ) genTauDecayMode = reco::PFTauDecayMode::tauDecaysElectron;
1015  else if ( genTauDecayMode_string == "muon" ) genTauDecayMode = reco::PFTauDecayMode::tauDecayMuon;
1016  else if ( genTauDecayMode_string == "oneProng0Pi0" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay1ChargedPion0PiZero;
1017  else if ( genTauDecayMode_string == "oneProng1Pi0" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay1ChargedPion1PiZero;
1018  else if ( genTauDecayMode_string == "oneProng2Pi0" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay1ChargedPion2PiZero;
1019  else if ( genTauDecayMode_string == "oneProngOther" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay1ChargedPion3PiZero;
1020  else if ( genTauDecayMode_string == "threeProng0Pi0" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay3ChargedPion0PiZero;
1021  else if ( genTauDecayMode_string == "threeProng1Pi0" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay3ChargedPion1PiZero;
1022  else if ( genTauDecayMode_string == "threeProngOther" ) genTauDecayMode = reco::PFTauDecayMode::tauDecay3ChargedPion2PiZero;
1023  else if ( genTauDecayMode_string == "rare" ) genTauDecayMode = reco::PFTauDecayMode::tauDecayOther;
1024  histogramGenTauDecayMode_->Fill(genTauDecayMode, evtWeight);
1025  int recTauDecayMode = recLepton->decayMode();
1026  histogramRecTauDecayMode_->Fill(recTauDecayMode, evtWeight);
1027  }
1028  }
1029  }
1030  //edm::Handle<reco::GenParticleCollection> genParticles;
1031  //evt.getByLabel("genParticles", genParticles);
1032  //for ( reco::GenParticleCollection::const_iterator genParticle = genParticles->begin();
1033  // genParticle != genParticles->end(); ++genParticle ) {
1034  // if ( TMath::Abs(genParticle->pdgId()) == 15 ) {
1035  // for ( recLeptonCollection::const_iterator recLepton = recLeptons->begin();
1036  // recLepton != recLeptons->end(); ++recLepton ) {
1037  // if ( cutRec_ && !(*cutRec_)(*recLepton) ) continue;
1038  // double dR = deltaR(genParticle->p4(), recLepton->p4());
1039  // if ( dR < dRmatch_ ) {
1040  // std::string genTauDecayMode_string = getGenTauDecayMode(&(*genParticle));
1041  // std::cout << "--> genTauDecayMode: = " << genTauDecayMode_string << std::endl;
1042  // }
1043  // }
1044  // }
1045  //}
1046  }
1047  }
1054  double dRmatch_;
1058  };
1059 
1060  template <typename T>
1061  void setupLeptonDistribution(int, int, const edm::ParameterSet&, const std::string&, std::vector<leptonDistributionT<T>*>&);
1062  void setupElectronDistributionExtra(int, int, const edm::ParameterSet&, const std::string&, std::vector<electronDistributionExtra*>&);
1063  void setupTauDistributionExtra(int, int, const edm::ParameterSet&, const std::string&, std::vector<tauDistributionExtra*>&);
1064 
1065  std::vector<leptonDistributionT<pat::Electron>*> electronDistributions_;
1066  std::vector<electronDistributionExtra*> electronDistributionsExtra_;
1067  std::vector<leptonDistributionT<pat::Muon>*> muonDistributions_;
1068  std::vector<leptonDistributionT<pat::Tau>*> tauDistributions_;
1069  std::vector<tauDistributionExtra*> tauDistributionsExtra_;
1070 
1071  template <typename T>
1073  {
1074  leptonEfficiencyT(int minJets, int maxJets,
1075  const edm::InputTag& srcGen, const std::string& cutGen, const edm::InputTag& srcRec, const std::string& cutRec, double dRmatch, const std::string& dqmDirectory)
1076  : minJets_(minJets),
1077  maxJets_(maxJets),
1078  srcGen_(srcGen),
1079  cutGen_(0),
1080  srcRec_(srcRec),
1081  cutRec_(0),
1082  dRmatch_(dRmatch)
1083  {
1084  if ( cutGen != "" ) cutGen_ = new StringCutObjectSelector<reco::Candidate>(cutGen);
1085  if ( cutRec != "" ) cutRec_ = new StringCutObjectSelector<T>(cutRec);
1086  dqmDirectory_ = dqmDirectory;
1087  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
1088  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
1089  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
1090  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
1091  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
1092  }
1094  {
1095  delete cutGen_;
1096  delete cutRec_;
1097  }
1098  void bookHistograms(DQMStore& dqmStore)
1099  {
1100  dqmStore.setCurrentFolder(dqmDirectory_.data());
1101  histogramNumGenLeptons_ = dqmStore.book1D("numGenLeptons", "numGenLeptons", 10, -0.5, 9.5);
1102  histogramNumRecLeptons_ = dqmStore.book1D("numRecLeptons", "numRecLeptons", 10, -0.5, 9.5);
1103  histogramNumeratorPt_ = dqmStore.book1D("numeratorPt", "numeratorPt", 250, 0., 250.);
1104  histogramDenominatorPt_ = dqmStore.book1D("denominatorPt", "denominatorPt", 250, 0., 250.);
1105  histogramNumeratorEta_ = dqmStore.book1D("numeratorEta", "numeratorEta", 198, -9.9, +9.9);
1106  histogramDenominatorEta_ = dqmStore.book1D("denominatorEta", "denominatorEta", 198, -9.9, +9.9);
1107  histogramNumeratorPhi_ = dqmStore.book1D("numeratorPhi", "numeratorPhi", 72, -TMath::Pi(), +TMath::Pi());
1108  histogramDenominatorPhi_ = dqmStore.book1D("denominatorPhi", "denominatorPhi", 72, -TMath::Pi(), +TMath::Pi());
1109  }
1110  void fillHistograms(int numJets,
1111  const edm::Event& evt, double evtWeight)
1112  {
1113  if ( (minJets_ == -1 || numJets >= minJets_) &&
1114  (maxJets_ == -1 || numJets <= maxJets_) ) {
1116  edm::Handle<CandidateView> genLeptons;
1117  evt.getByLabel(srcGen_, genLeptons);
1118  histogramNumGenLeptons_->Fill(genLeptons->size(), evtWeight);
1119  typedef std::vector<T> recLeptonCollection;
1121  evt.getByLabel(srcRec_, recLeptons);
1122  histogramNumRecLeptons_->Fill(recLeptons->size(), evtWeight);
1123  for ( CandidateView::const_iterator genLepton = genLeptons->begin();
1124  genLepton != genLeptons->end(); ++genLepton ) {
1125  if ( cutGen_ && !(*cutGen_)(*genLepton) ) continue;
1126  bool isMatched = false;
1127  for ( typename recLeptonCollection::const_iterator recLepton = recLeptons->begin();
1128  recLepton != recLeptons->end(); ++recLepton ) {
1129  if ( cutRec_ && !(*cutRec_)(*recLepton) ) continue;
1130  double dR = deltaR(genLepton->p4(), recLepton->p4());
1131  if ( dR < dRmatch_ ) isMatched = true;
1132  }
1133  histogramDenominatorPt_->Fill(genLepton->pt(), evtWeight);
1134  histogramDenominatorEta_->Fill(genLepton->eta(), evtWeight);
1135  histogramDenominatorPhi_->Fill(genLepton->phi(), evtWeight);
1136  if ( isMatched ) {
1137  histogramNumeratorPt_->Fill(genLepton->pt(), evtWeight);
1138  histogramNumeratorEta_->Fill(genLepton->eta(), evtWeight);
1139  histogramNumeratorPhi_->Fill(genLepton->phi(), evtWeight);
1140  }
1141  }
1142  }
1143  }
1150  double dRmatch_;
1160  };
1161 
1162  template <typename T>
1163  void setupLeptonEfficiency(int, int, const edm::ParameterSet&, const std::string&, std::vector<leptonEfficiencyT<T>*>&);
1164 
1165  std::vector<leptonEfficiencyT<reco::GsfElectron>*> gsfElectronEfficiencies_;
1166  std::vector<leptonEfficiencyT<pat::Electron>*> electronEfficiencies_;
1167  std::vector<leptonEfficiencyT<pat::Muon>*> muonEfficiencies_;
1168  std::vector<leptonEfficiencyT<pat::Tau>*> tauEfficiencies_;
1169 
1170  template <typename T1, typename T2>
1172  {
1173  leptonL1TriggerEfficiencyT1T2(int minJets, int maxJets,
1174  const edm::InputTag& srcRef, const std::string& cutRef, const edm::InputTag& srcL1, const std::string& cutL1, double dRmatch, const std::string& dqmDirectory)
1175  : minJets_(minJets),
1176  maxJets_(maxJets),
1177  srcRef_(srcRef),
1178  cutRef_(0),
1179  srcL1_(srcL1),
1180  cutL1_(0),
1181  dRmatch_(dRmatch)
1182  {
1183  if ( cutRef != "" ) cutRef_ = new StringCutObjectSelector<T1>(cutRef);
1184  if ( cutL1 != "" ) cutL1_ = new StringCutObjectSelector<T2>(cutL1);
1185  dqmDirectory_ = dqmDirectory;
1186  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
1187  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
1188  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
1189  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
1190  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
1191  }
1193  {
1194  delete cutRef_;
1195  delete cutL1_;
1196  }
1197  void bookHistograms(DQMStore& dqmStore)
1198  {
1199  dqmStore.setCurrentFolder(dqmDirectory_.data());
1200  histogramNumeratorPt_ = dqmStore.book1D("numeratorPt", "numeratorPt", 250, 0., 250.);
1201  histogramDenominatorPt_ = dqmStore.book1D("denominatorPt", "denominatorPt", 250, 0., 250.);
1202  histogramNumeratorEta_ = dqmStore.book1D("numeratorEta", "numeratorEta", 198, -9.9, +9.9);
1203  histogramDenominatorEta_ = dqmStore.book1D("denominatorEta", "denominatorEta", 198, -9.9, +9.9);
1204  histogramNumeratorPhi_ = dqmStore.book1D("numeratorPhi", "numeratorPhi", 72, -TMath::Pi(), +TMath::Pi());
1205  histogramDenominatorPhi_ = dqmStore.book1D("denominatorPhi", "denominatorPhi", 72, -TMath::Pi(), +TMath::Pi());
1206  }
1207  void fillHistograms(int numJets,
1208  const edm::Event& evt, double evtWeight)
1209  {
1210  if ( (minJets_ == -1 || numJets >= minJets_) &&
1211  (maxJets_ == -1 || numJets <= maxJets_) ) {
1212  typedef std::vector<T1> refLeptonCollection;
1214  evt.getByLabel(srcRef_, refLeptons);
1215  typedef std::vector<T2> l1LeptonCollection;
1217  evt.getByLabel(srcL1_, l1Leptons);
1218  for ( typename refLeptonCollection::const_iterator refLepton = refLeptons->begin();
1219  refLepton != refLeptons->end(); ++refLepton ) {
1220  if ( cutRef_ && !(*cutRef_)(*refLepton) ) continue;
1221  bool isMatched = false;
1222  for ( typename l1LeptonCollection::const_iterator l1Lepton = l1Leptons->begin();
1223  l1Lepton != l1Leptons->end(); ++l1Lepton ) {
1224  if ( cutL1_ && !(*cutL1_)(*l1Lepton) ) continue;
1225  double dR = deltaR(refLepton->p4(), l1Lepton->p4());
1226  if ( dR < dRmatch_ ) isMatched = true;
1227  }
1228  histogramDenominatorPt_->Fill(refLepton->pt(), evtWeight);
1229  histogramDenominatorEta_->Fill(refLepton->eta(), evtWeight);
1230  histogramDenominatorPhi_->Fill(refLepton->phi(), evtWeight);
1231  if ( isMatched ) {
1232  histogramNumeratorPt_->Fill(refLepton->pt(), evtWeight);
1233  histogramNumeratorEta_->Fill(refLepton->eta(), evtWeight);
1234  histogramNumeratorPhi_->Fill(refLepton->phi(), evtWeight);
1235  }
1236  }
1237  }
1238  }
1245  double dRmatch_;
1253  };
1254 
1255  template <typename T1, typename T2>
1257 
1258  std::vector<leptonL1TriggerEfficiencyT1T2<pat::Electron, l1extra::L1EmParticle>*> electronL1TriggerEfficiencies_;
1259  std::vector<leptonL1TriggerEfficiencyT1T2<pat::Muon, l1extra::L1MuonParticle>*> muonL1TriggerEfficiencies_;
1260 
1261  template <typename T>
1263  {
1264  l1ExtraObjectDistributionT(int minJets, int maxJets,
1265  const edm::InputTag& src, const std::string& cut, const std::string& dqmDirectory)
1266  : minJets_(minJets),
1267  maxJets_(maxJets),
1268  src_(src),
1269  cut_(0)
1270  {
1271  if ( cut != "" ) cut_ = new StringCutObjectSelector<T>(cut);
1272  dqmDirectory_ = dqmDirectory;
1273  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
1274  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
1275  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
1276  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
1277  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
1278  }
1280  {
1281  delete cut_;
1282  }
1283  void bookHistograms(DQMStore& dqmStore)
1284  {
1285  dqmStore.setCurrentFolder(dqmDirectory_.data());
1286  histogramNumL1ExtraObjects_ = dqmStore.book1D("numL1ExtraObjects", "numL1ExtraObjects", 10, -0.5, 9.5);
1287  histogramL1ExtraObjectPt_ = dqmStore.book1D("l1ExtraObjectPt", "l1ExtraObjectPt", 250, 0., 250.);
1288  histogramL1ExtraObjectEta_ = dqmStore.book1D("l1ExtraObjectEta", "l1ExtraObjectEta", 198, -9.9, +9.9);
1289  histogramL1ExtraObjectPhi_ = dqmStore.book1D("l1ExtraObjectPhi", "l1ExtraObjectPhi", 72, -TMath::Pi(), +TMath::Pi());
1290  }
1291  void fillHistograms(int numJets,
1292  const edm::Event& evt, double evtWeight)
1293  {
1294  if ( (minJets_ == -1 || numJets >= minJets_) &&
1295  (maxJets_ == -1 || numJets <= maxJets_) ) {
1296  typedef std::vector<T> l1ExtraObjectCollection;
1297  edm::Handle<l1ExtraObjectCollection> l1ExtraObjects;
1298  evt.getByLabel(src_, l1ExtraObjects);
1299  int numL1ExtraObjects = 0;
1300  for ( typename l1ExtraObjectCollection::const_iterator l1ExtraObject = l1ExtraObjects->begin();
1301  l1ExtraObject != l1ExtraObjects->end(); ++l1ExtraObject ) {
1302  if ( cut_ && !(*cut_)(*l1ExtraObject) ) continue;
1303  ++numL1ExtraObjects;
1304  histogramL1ExtraObjectPt_->Fill(l1ExtraObject->pt(), evtWeight);
1305  histogramL1ExtraObjectEta_->Fill(l1ExtraObject->eta(), evtWeight);
1306  histogramL1ExtraObjectPhi_->Fill(l1ExtraObject->phi(), evtWeight);
1307  }
1308  histogramNumL1ExtraObjects_->Fill(numL1ExtraObjects, evtWeight);
1309  }
1310  }
1320  };
1321 
1322  template <typename T>
1323  void setupL1ExtraObjectDistribution(int, int, const edm::ParameterSet&, const std::string&, std::vector<l1ExtraObjectDistributionT<T>*>&);
1324 
1325  std::vector<l1ExtraObjectDistributionT<l1extra::L1EmParticle>*> l1ElectronDistributions_;
1326  std::vector<l1ExtraObjectDistributionT<l1extra::L1MuonParticle>*> l1MuonDistributions_;
1327  std::vector<l1ExtraObjectDistributionT<l1extra::L1JetParticle>*> l1TauDistributions_;
1328  std::vector<l1ExtraObjectDistributionT<l1extra::L1JetParticle>*> l1CentralJetDistributions_;
1329  std::vector<l1ExtraObjectDistributionT<l1extra::L1JetParticle>*> l1ForwardJetDistributions_;
1330 
1332  {
1333  metDistributionType(int minJets, int maxJets,
1334  const edm::InputTag& srcGen, const edm::InputTag& srcRec, const edm::InputTag& srcGenZs, const std::string& dqmDirectory)
1335  : minJets_(minJets),
1336  maxJets_(maxJets),
1337  srcGen_(srcGen),
1338  srcRec_(srcRec),
1339  srcGenZs_(srcGenZs)
1340  {
1341  dqmDirectory_ = dqmDirectory;
1342  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
1343  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
1344  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
1345  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
1346  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
1347  }
1349  void bookHistograms(DQMStore& dqmStore)
1350  {
1351  dqmStore.setCurrentFolder(dqmDirectory_.data());
1352  histogramGenMEtPt_ = dqmStore.book1D("genMEtPt", "genMEtPt", 250, 0., 250.);
1353  histogramGenMEtPhi_ = dqmStore.book1D("genMEtPhi", "genMEtPhi", 72, -TMath::Pi(), +TMath::Pi());
1354  histogramRecMEtPt_ = dqmStore.book1D("recMEtPt", "recMEtPt", 250, 0., 250.);
1355  histogramRecMEtPhi_ = dqmStore.book1D("recMEtPhi", "recMEtPhi", 72, -TMath::Pi(), +TMath::Pi());
1356  histogramRecMinusGenMEtParlZ_ = dqmStore.book1D("recMinusGenMEtParlZ", "recMinusGenMEtParlZ", 200, -100., +100.);
1357  histogramRecMinusGenMEtPerpZ_ = dqmStore.book1D("recMinusGenMEtPerpZ", "recMinusGenMEtPerpZ", 100, 0., 100.);
1358  }
1359  void fillHistograms(int numJets,
1360  const edm::Event& evt, double evtWeight)
1361  {
1362  if ( (minJets_ == -1 || numJets >= minJets_) &&
1363  (maxJets_ == -1 || numJets <= maxJets_) ) {
1364  typedef edm::View<reco::MET> METView;
1365  edm::Handle<METView> genMETs;
1366  evt.getByLabel(srcGen_, genMETs);
1367  const reco::Candidate::LorentzVector& genMEtP4 = genMETs->front().p4();
1368  edm::Handle<METView> recMETs;
1369  evt.getByLabel(srcRec_, recMETs);
1370  const reco::Candidate::LorentzVector& recMEtP4 = recMETs->front().p4();
1371  //std::cout << "<MCEmbeddingValidationAnalyzer>:" << std::endl;
1372  //std::cout << " recMEt(" << srcRec_.label() << "): Pt = " << recMEtP4.pt() << ", phi = " << recMEtP4.phi()
1373  // << " (Px = " << recMEtP4.px() << ", Py = " << recMEtP4.py() << ")" << std::endl;
1376  evt.getByLabel(srcGenZs_, genZs);
1377  if ( !(genZs->size() >= 1) ) return;
1378  const reco::Candidate::LorentzVector& genZp4 = genZs->front().p4();
1379  histogramGenMEtPt_->Fill(genMEtP4.pt(), evtWeight);
1380  histogramGenMEtPhi_->Fill(genMEtP4.phi(), evtWeight);
1381  histogramRecMEtPt_->Fill(recMEtP4.pt(), evtWeight);
1382  histogramRecMEtPhi_->Fill(recMEtP4.phi(), evtWeight);
1383  if ( genZp4.pt() > 0. ) {
1384  double qX = genZp4.px();
1385  double qY = genZp4.py();
1386  double qT = TMath::Sqrt(qX*qX + qY*qY);
1387  double dX = recMEtP4.px() - genMEtP4.px();
1388  double dY = recMEtP4.py() - genMEtP4.py();
1389  double dParl = (dX*qX + dY*qY)/qT;
1390  double dPerp = (dX*qY - dY*qX)/qT;
1391  histogramRecMinusGenMEtParlZ_->Fill(dParl, evtWeight);
1392  histogramRecMinusGenMEtPerpZ_->Fill(TMath::Abs(dPerp), evtWeight);
1393  }
1394  }
1395  }
1408  };
1409 
1410  void setupMEtDistribution(int, int, const edm::ParameterSet&, const std::string&, std::vector<metDistributionType*>&);
1411 
1412  std::vector<metDistributionType*> metDistributions_;
1413 
1415  {
1416  metL1TriggerEfficiencyType(int minJets, int maxJets,
1417  const edm::InputTag& srcRef, const edm::InputTag& srcL1, double cutL1Et, double cutL1Pt, const std::string& dqmDirectory)
1418  : minJets_(minJets),
1419  maxJets_(maxJets),
1420  srcRef_(srcRef),
1421  srcL1_(srcL1),
1422  cutL1Et_(cutL1Et),
1423  cutL1Pt_(cutL1Pt)
1424  {
1425  dqmDirectory_ = dqmDirectory;
1426  if ( minJets_ < 0 && maxJets_ < 0 ) dqmDirectory_.append("");
1427  else if ( maxJets_ < 0 ) dqmDirectory_.append(Form("_numJetsGe%i", minJets_));
1428  else if ( minJets_ < 0 ) dqmDirectory_.append(Form("_numJetsLe%i", maxJets_));
1429  else if ( maxJets_ == minJets_ ) dqmDirectory_.append(Form("_numJetsEq%i", minJets_));
1430  else dqmDirectory_.append(Form("_numJets%ito%i", minJets_, maxJets_));
1431  }
1433  void bookHistograms(DQMStore& dqmStore)
1434  {
1435  dqmStore.setCurrentFolder(dqmDirectory_.data());
1436  histogramNumeratorPt_ = dqmStore.book1D("numeratorPt", "numeratorPt", 250, 0., 250.);
1437  histogramDenominatorPt_ = dqmStore.book1D("denominatorPt", "denominatorPt", 250, 0., 250.);
1438  histogramNumeratorPhi_ = dqmStore.book1D("numeratorPhi", "numeratorPhi", 72, -TMath::Pi(), +TMath::Pi());
1439  histogramDenominatorPhi_ = dqmStore.book1D("denominatorPhi", "denominatorPhi", 72, -TMath::Pi(), +TMath::Pi());
1440  }
1441  void fillHistograms(int numJets,
1442  const edm::Event& evt, double evtWeight)
1443  {
1444  if ( (minJets_ == -1 || numJets >= minJets_) &&
1445  (maxJets_ == -1 || numJets <= maxJets_) ) {
1446  typedef edm::View<reco::MET> METView;
1447  edm::Handle<METView> refMETs;
1448  evt.getByLabel(srcRef_, refMETs);
1449  const reco::Candidate::LorentzVector& refMEtP4 = refMETs->front().p4();
1451  evt.getByLabel(srcL1_, l1METs);
1452  for ( l1extra::L1EtMissParticleCollection::const_iterator l1MEt = l1METs->begin();
1453  l1MEt != l1METs->end(); ++l1MEt ) {
1454  if ( !(l1MEt->bx() == 0) ) continue;
1455  double l1MEt_et = l1METs->front().etMiss();
1456  double l1MEt_pt = l1METs->front().pt();
1457  histogramDenominatorPt_->Fill(refMEtP4.pt(), evtWeight);
1458  histogramDenominatorPhi_->Fill(refMEtP4.phi(), evtWeight);
1459  if ( l1MEt_et > cutL1Et_ && l1MEt_pt > cutL1Pt_ ) {
1460  histogramNumeratorPt_->Fill(refMEtP4.pt(), evtWeight);
1461  histogramNumeratorPhi_->Fill(refMEtP4.phi(), evtWeight);
1462  }
1463  }
1464  }
1465  }
1470  double cutL1Et_;
1471  double cutL1Pt_;
1477  };
1478 
1479  void setupMEtL1TriggerEfficiency(int, int, const edm::ParameterSet&, const std::string&, std::vector<metL1TriggerEfficiencyType*>&);
1480 
1481  std::vector<metL1TriggerEfficiencyType*> metL1TriggerEfficiencies_;
1482 
1483  template <typename T>
1484  void cleanCollection(std::vector<T*> collection)
1485  {
1486  for ( typename std::vector<T*>::iterator object = collection.begin();
1487  object != collection.end(); ++object ) {
1488  delete (*object);
1489  }
1490  }
1491 
1492  template <typename T>
1493  void bookHistograms(std::vector<T*> collection, DQMStore& dqmStore)
1494  {
1495  for ( typename std::vector<T*>::iterator object = collection.begin();
1496  object != collection.end(); ++object ) {
1497  (*object)->bookHistograms(dqmStore);
1498  }
1499  }
1500 
1501  template <typename T>
1502  void fillHistograms(std::vector<T*> collection, int numJets, const edm::Event& evt, double evtWeight)
1503  {
1504  for ( typename std::vector<T*>::iterator object = collection.begin();
1505  object != collection.end(); ++object ) {
1506  (*object)->fillHistograms(numJets, evt, evtWeight);
1507  }
1508  }
1509  template <typename T>
1510  void fillHistograms(std::vector<T*> collection, int numJets, const edm::Event& evt, const edm::EventSetup& es, double evtWeight)
1511  {
1512  for ( typename std::vector<T*>::iterator object = collection.begin();
1513  object != collection.end(); ++object ) {
1514  (*object)->fillHistograms(numJets, evt, es, evtWeight);
1515  }
1516  }
1517 
1519 };
1520 
1521 #endif
void fillHistograms(std::vector< T * > collection, int numJets, const edm::Event &evt, const edm::EventSetup &es, double evtWeight)
const double Pi
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:81
std::vector< metL1TriggerEfficiencyType * > metL1TriggerEfficiencies_
void fillHistograms(std::vector< T * > collection, int numJets, const edm::Event &evt, double evtWeight)
void setupL1ExtraObjectDistribution(int, int, const edm::ParameterSet &, const std::string &, std::vector< l1ExtraObjectDistributionT< T > * > &)
std::vector< plotEntryTypeMuonRadCorrUncertainty * > muonRadCorrUncertaintyPlotEntries_afterRad_
tauDistributionExtra(int minJets, int maxJets, const edm::InputTag &srcGen, const std::string &cutGen, const edm::InputTag &srcRec, const std::string &cutRec, double dRmatch, const std::string &dqmDirectory)
std::vector< leptonEfficiencyT< pat::Electron > * > electronEfficiencies_
void analyze(const edm::Event &, const edm::EventSetup &)
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:1021
metDistributionType(int minJets, int maxJets, const edm::InputTag &srcGen, const edm::InputTag &srcRec, const edm::InputTag &srcGenZs, const std::string &dqmDirectory)
std::vector< leptonL1TriggerEfficiencyT1T2< pat::Electron, l1extra::L1EmParticle > * > electronL1TriggerEfficiencies_
MCEmbeddingValidationAnalyzer(const edm::ParameterSet &)
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
assert(m_qm.get())
leptonL1TriggerEfficiencyT1T2(int minJets, int maxJets, const edm::InputTag &srcRef, const std::string &cutRef, const edm::InputTag &srcL1, const std::string &cutL1, double dRmatch, const std::string &dqmDirectory)
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
StringCutObjectSelector< reco::Candidate > * cutGen_
l1ExtraObjectDistributionT(int minJets, int maxJets, const edm::InputTag &src, const std::string &cut, const std::string &dqmDirectory)
void setupMEtL1TriggerEfficiency(int, int, const edm::ParameterSet &, const std::string &, std::vector< metL1TriggerEfficiencyType * > &)
std::vector< plotEntryTypeL1ETM * > l1ETMplotEntries_
std::vector< tauDistributionExtra * > tauDistributionsExtra_
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
std::vector< plotEntryTypeMuonRadCorrUncertainty * > muonRadCorrUncertaintyPlotEntries_afterRadAndCorr_
void Fill(long long x)
std::vector< leptonDistributionT< pat::Electron > * > electronDistributions_
void fillHistograms(int numJets, const edm::Event &evt, const edm::EventSetup &es, double evtWeight)
plotEntryTypeL1ETM(const std::string &genTauDecayMode, const std::string &dqmDirectory)
edm::View< reco::Candidate > CandidateView
virtual int status() const final
status word
tuple numMuons
Definition: patZpeak.py:40
std::vector< edm::InputTag > vInputTag
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
void bookHistograms(std::vector< T * > collection, DQMStore &dqmStore)
void setupLeptonL1TriggerEfficiency(int, int, const edm::ParameterSet &, const std::string &, std::vector< leptonL1TriggerEfficiencyT1T2< T1, T2 > * > &)
std::vector< leptonEfficiencyT< reco::GsfElectron > * > gsfElectronEfficiencies_
edm::EDGetTokenT< EcalRecHitCollection > eeRHToken_
virtual size_t numberOfDaughters() const
number of daughters
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
T Abs(T a)
Definition: MathUtil.h:49
void fillHistograms(const edm::Event &evt, const std::map< std::string, double > &evtWeightMap_other)
edm::View< reco::MET > METView
leptonDistributionT(int minJets, int maxJets, const edm::InputTag &srcGen, const std::string &cutGen, const edm::InputTag &srcRec, const std::string &cutRec, double dRmatch, const std::string &dqmDirectory)
bool isMatched(TrackingRecHit const &hit)
void fillHistograms(const std::string &genTauDecayMode_ref, const reco::Candidate::LorentzVector &l1MEtP4, const reco::Candidate::LorentzVector &genCaloMEtP4, const reco::Candidate::LorentzVector &recCaloMEtP4, const reco::Candidate::LorentzVector &genDiTauP4, double evtWeight)
StringCutObjectSelector< reco::Candidate > * cutGen_
std::vector< leptonEfficiencyT< pat::Muon > * > muonEfficiencies_
std::string dqmDirectory_full(const std::string &dqmSubDirectory)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
std::vector< plotEntryTypeEvtWeight * > evtWeightPlotEntries_
std::pair< double, double > compMEtProjU(const reco::Candidate::LorentzVector &zP4, double metPx, double metPy, int &errorFlag)
std::vector< l1ExtraObjectDistributionT< l1extra::L1JetParticle > * > l1CentralJetDistributions_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
metL1TriggerEfficiencyType(int minJets, int maxJets, const edm::InputTag &srcRef, const edm::InputTag &srcL1, double cutL1Et, double cutL1Pt, const std::string &dqmDirectory)
StringCutObjectSelector< reco::Candidate > * cutGen_
std::vector< plotEntryTypeMuonRadCorrUncertainty * > muonRadCorrUncertaintyPlotEntries_beforeRad_
std::vector< l1ExtraObjectDistributionT< l1extra::L1JetParticle > * > l1TauDistributions_
std::vector< metDistributionType * > metDistributions_
leptonEfficiencyT(int minJets, int maxJets, const edm::InputTag &srcGen, const std::string &cutGen, const edm::InputTag &srcRec, const std::string &cutRec, double dRmatch, const std::string &dqmDirectory)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void setupLeptonDistribution(int, int, const edm::ParameterSet &, const std::string &, std::vector< leptonDistributionT< T > * > &)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
std::string const & label() const
Definition: InputTag.h:36
void fillHistograms(int numJets, const reco::Candidate::LorentzVector &muonPlusP4, const reco::Candidate::LorentzVector &muonMinusP4, double evtWeight_others, double muonRadCorrWeight, double muonRadCorrWeightUp, double muonRadCorrWeightDown)
void cleanCollection(std::vector< T * > collection)
virtual int pdgId() const final
PDG identifier.
plotEntryTypeEvtWeight(const edm::InputTag &srcWeight, const std::string &dqmDirectory)
void setupMEtDistribution(int, int, const edm::ParameterSet &, const std::string &, std::vector< metDistributionType * > &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::vector< leptonL1TriggerEfficiencyT1T2< pat::Muon, l1extra::L1MuonParticle > * > muonL1TriggerEfficiencies_
void setupTauDistributionExtra(int, int, const edm::ParameterSet &, const std::string &, std::vector< tauDistributionExtra * > &)
void fillHistograms(int numJets, const edm::Event &evt, double evtWeight)
edm::EDGetTokenT< EcalRecHitCollection > ebRHToken_
void setupElectronDistributionExtra(int, int, const edm::ParameterSet &, const std::string &, std::vector< electronDistributionExtra * > &)
T get() const
get a component
Definition: Candidate.h:217
std::vector< l1ExtraObjectDistributionT< l1extra::L1EmParticle > * > l1ElectronDistributions_
std::vector< l1ExtraObjectDistributionT< l1extra::L1MuonParticle > * > l1MuonDistributions_
std::vector< leptonDistributionT< pat::Muon > * > muonDistributions_
int weight
Definition: histoStyle.py:50
electronDistributionExtra(int minJets, int maxJets, const edm::InputTag &srcGen, const std::string &cutGen, const edm::InputTag &srcRec, const std::string &cutRec, double dRmatch, const std::string &dqmDirectory, const edm::InputTag &srcTheRecVertex, edm::EDGetTokenT< EcalRecHitCollection > tk1, edm::EDGetTokenT< EcalRecHitCollection > tk2)
std::vector< electronDistributionExtra * > electronDistributionsExtra_
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:1149
std::vector< leptonEfficiencyT< pat::Tau > * > tauEfficiencies_
plotEntryTypeMuonRadCorrUncertainty(int minJets, int maxJets, const std::string &dqmDirectory)
std::string const & instance() const
Definition: InputTag.h:37
std::vector< l1ExtraObjectDistributionT< l1extra::L1JetParticle > * > l1ForwardJetDistributions_
void setupLeptonEfficiency(int, int, const edm::ParameterSet &, const std::string &, std::vector< leptonEfficiencyT< T > * > &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:727
tuple status
Definition: mps_update.py:57
std::vector< leptonDistributionT< pat::Tau > * > tauDistributions_