CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetTester.cc
Go to the documentation of this file.
1 // Producer for validation histograms for Calo, JPT and PF jet objects
2 // F. Ratnikov, Sept. 7, 2006
3 // Modified by Chiyoung Jeong, Feb. 2, 2010
4 // Modified by J. Piedra, Sept. 11, 2013
5 
6 #include "JetTester.h"
7 
8 using namespace edm;
9 using namespace reco;
10 using namespace std;
11 
13  mInputCollection (iConfig.getParameter<edm::InputTag> ("src")),
14 // rhoTag (iConfig.getParameter<edm::InputTag> ("srcRho")),
15  JetType (iConfig.getUntrackedParameter<std::string>("JetType")),
16  mRecoJetPtThreshold (iConfig.getParameter<double> ("recoJetPtThreshold")),
17  mMatchGenPtThreshold (iConfig.getParameter<double> ("matchGenPtThreshold")),
18  mRThreshold (iConfig.getParameter<double> ("RThreshold"))
19 {
20  std::string inputCollectionLabel(mInputCollection.label());
21 
22  isCaloJet = (std::string("calo")==JetType);
23  isPFJet = (std::string("pf") ==JetType);
24  isMiniAODJet = (std::string("miniaod") ==JetType);
25  if(!isMiniAODJet){
26  mJetCorrector =iConfig.getParameter<edm::InputTag>("JetCorrections");
27  }
28 
29  //consumes
30  pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<edm::InputTag>("primVertex"));
31  if (isCaloJet) caloJetsToken_ = consumes<reco::CaloJetCollection>(mInputCollection);
32  if (isPFJet) pfJetsToken_ = consumes<reco::PFJetCollection>(mInputCollection);
33  if(isMiniAODJet)patJetsToken_ = consumes<pat::JetCollection>(mInputCollection);
35  genJetsToken_ = consumes<reco::GenJetCollection>(edm::InputTag(mInputGenCollection));
36  evtToken_ = consumes<GenEventInfoProduct>(edm::InputTag("generator"));
37  if(!isMiniAODJet && !mJetCorrector.label().empty()){
38  jetCorrectorToken_ = consumes<reco::JetCorrector>(mJetCorrector);
39  }
40 
41  // Events variables
42  mNvtx = 0;
43 
44  // Jet parameters
45  mEta = 0;
46  mPhi = 0;
47  mEnergy = 0;
48  mP = 0;
49  mPt = 0;
50  mMass = 0;
51  mConstituents = 0;
52  mJetArea = 0;
53 // mRho = 0;
54 
55  // Corrected jets
56  mCorrJetPt = 0;
57  mCorrJetEta = 0;
58  mCorrJetPhi = 0;
59  mCorrJetEta_Pt40 = 0;
60  mCorrJetPhi_Pt40 = 0;
61 
62  // Corrected jets profiles
85 
86  // Generation
87  mGenEta = 0;
88  mGenPhi = 0;
89  mGenPt = 0;
90  mGenEtaFirst = 0;
91  mGenPhiFirst = 0;
92  mPtHat = 0;
93  mDeltaEta = 0;
94  mDeltaPhi = 0;
95  mDeltaPt = 0;
96 
119 
120  // Generation profiles
135 
136  // Some jet algebra
137  mEtaFirst = 0;
138  mPhiFirst = 0;
139  mPtFirst = 0;
140  mMjj = 0;
141  mNJetsEta_B_20_40 = 0;
142  mNJetsEta_E_20_40 = 0;
143  mNJetsEta_B_40 = 0;
144  mNJetsEta_E_40 = 0;
145  mNJets1 = 0;
146  mNJets2 = 0;
147 
148 // // PFJet specific
149 // mHadEnergyInHF = 0;
150 // mEmEnergyInHF = 0;
151 // mChargedEmEnergy = 0;
152 // mChargedHadronEnergy = 0;
153 // mNeutralEmEnergy = 0;
154 // mNeutralHadronEnergy = 0;
155 
156  // ---- Calo Jet specific information ----
158  maxEInEmTowers = 0;
160  maxEInHadTowers = 0;
164  emEnergyFraction = 0;
166  hadEnergyInHB = 0;
168  hadEnergyInHO = 0;
170  hadEnergyInHE = 0;
172  hadEnergyInHF = 0;
174  emEnergyInEB = 0;
176  emEnergyInEE = 0;
178  emEnergyInHF = 0;
180  towersArea = 0;
182  n90 = 0;
184  n60 = 0;
185 
186  // ---- JPT Jet specific information ----
188 // elecMultiplicity = 0;
189 
190  // ---- JPT or PF Jet specific information ----
192  muonMultiplicity = 0;
196  chargedEmEnergy = 0;
198  neutralEmEnergy = 0;
211 
212  // ---- PF Jet specific information ----
214  photonEnergy = 0;
218  electronEnergy = 0;
222  muonEnergy = 0;
224  muonEnergyFraction = 0;
226  HFHadronEnergy = 0;
230  HFEMEnergy = 0;
232  HFEMEnergyFraction = 0;
238  photonMultiplicity = 0;
244  HFEMMultiplicity = 0;
246  chargedMuEnergy = 0;
251 
253  HOEnergy = 0;
255  HOEnergyFraction = 0;
256 }
257 
259  edm::Run const & iRun,
260  edm::EventSetup const & ) {
261 
262  ibooker.setCurrentFolder("JetMET/JetValidation/"+mInputCollection.label());
263 
264  double log10PtMin = 0.50;
265  double log10PtMax = 3.75;
266  int log10PtBins = 26;
267 
268  //if eta range changed here need change in JetTesterPostProcessor as well
269  double etaRange[91] = {-6.0, -5.8, -5.6, -5.4, -5.2, -5.0, -4.8, -4.6, -4.4, -4.2,
270  -4.0, -3.8, -3.6, -3.4, -3.2, -3.0, -2.9, -2.8, -2.7, -2.6,
271  -2.5, -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6,
272  -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6,
273  -0.5, -0.4, -0.3, -0.2, -0.1,
274  0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,
275  1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9,
276  2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9,
277  3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.2, 4.4, 4.6, 4.8,
278  5.0, 5.2, 5.4, 5.6, 5.8, 6.0};
279 
280  // Event variables
281  mNvtx = ibooker.book1D("Nvtx", "number of vertices", 60, 0, 60);
282 
283  // Jet parameters
284  mEta = ibooker.book1D("Eta", "Eta", 120, -6, 6);
285  mPhi = ibooker.book1D("Phi", "Phi", 70, -3.5, 3.5);
286  mPt = ibooker.book1D("Pt", "Pt", 100, 0, 1000);
287  mP = ibooker.book1D("P", "P", 100, 0, 1000);
288  mEnergy = ibooker.book1D("Energy", "Energy", 100, 0, 1000);
289  mMass = ibooker.book1D("Mass", "Mass", 100, 0, 200);
290  mConstituents = ibooker.book1D("Constituents", "Constituents", 100, 0, 100);
291  mJetArea = ibooker.book1D("JetArea", "JetArea", 100, 0, 4);
292 
293  // Corrected jets
294  if (isMiniAODJet || !mJetCorrector.label().empty()) {//if correction label is filled, but fill also for MiniAOD though
295  mCorrJetPt = ibooker.book1D("CorrJetPt", "CorrJetPt", 150, 0, 1500);
296  mCorrJetEta = ibooker.book1D("CorrJetEta", "CorrJetEta Pt>20", 60, -6, 6);
297  mCorrJetPhi = ibooker.book1D("CorrJetPhi", "CorrJetPhi Pt>20", 70, -3.5, 3.5);
298  mCorrJetEta_Pt40 = ibooker.book1D("CorrJetEta_Pt40", "CorrJetEta Pt>40", 60, -6, 6);
299  mCorrJetPhi_Pt40 = ibooker.book1D("CorrJetPhi_Pt40", "CorrJetPhi Pt>40", 70, -3.5, 3.5);
300 
301  // Corrected jets profiles
302  mPtCorrOverReco_Pt_B = ibooker.bookProfile("PtCorrOverReco_Pt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
303  mPtCorrOverReco_Pt_E = ibooker.bookProfile("PtCorrOverReco_Pt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
304  mPtCorrOverReco_Pt_F = ibooker.bookProfile("PtCorrOverReco_Pt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
305 
306  mPtCorrOverReco_Eta_20_40 = ibooker.bookProfile("PtCorrOverReco_Eta_20_40", "20<genPt<40", 90, etaRange, 0, 5, " ");
307  mPtCorrOverReco_Eta_40_200 = ibooker.bookProfile("PtCorrOverReco_Eta_40_200", "40<genPt<200", 90, etaRange, 0, 5, " ");
308  mPtCorrOverReco_Eta_200_600 = ibooker.bookProfile("PtCorrOverReco_Eta_200_600", "200<genPt<600", 90, etaRange, 0, 5, " ");
309  mPtCorrOverReco_Eta_600_1500 = ibooker.bookProfile("PtCorrOverReco_Eta_600_1500", "600<genPt<1500", 90, etaRange, 0, 5, " ");
310  mPtCorrOverReco_Eta_1500_3500 = ibooker.bookProfile("PtCorrOverReco_Eta_1500_3500", "1500<genPt<3500", 90, etaRange, 0, 5, " ");
311  mPtCorrOverReco_Eta_3500_5000 = ibooker.bookProfile("PtCorrOverReco_Eta_3500_5000", "3500<genPt<5000", 90, etaRange, 0, 5, " ");
312  mPtCorrOverReco_Eta_5000_6500 = ibooker.bookProfile("PtCorrOverReco_Eta_5000_6500", "5000<genPt<6500", 90, etaRange, 0, 5, " ");
313  mPtCorrOverReco_Eta_3500 = ibooker.bookProfile("PtCorrOverReco_Eta_3500", "genPt>3500", 90, etaRange, 0, 5, " ");
314 
315  mPtCorrOverGen_GenPt_B = ibooker.bookProfile("PtCorrOverGen_GenPt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
316  mPtCorrOverGen_GenPt_E = ibooker.bookProfile("PtCorrOverGen_GenPt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
317  mPtCorrOverGen_GenPt_F = ibooker.bookProfile("PtCorrOverGen_GenPt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
318  //if eta range changed here need change in JetTesterPostProcessor as well
319  mPtCorrOverGen_GenEta_20_40 = ibooker.bookProfile("PtCorrOverGen_GenEta_20_40", "20<genPt<40;#eta", 90, etaRange, 0.8, 1.2, " ");
320  mPtCorrOverGen_GenEta_40_200 = ibooker.bookProfile("PtCorrOverGen_GenEta_40_200", "40<genPt<200;#eta", 90, etaRange, 0.8, 1.2, " ");
321  mPtCorrOverGen_GenEta_200_600 = ibooker.bookProfile("PtCorrOverGen_GenEta_200_600", "200<genPt<600;#eta", 90, etaRange, 0.8, 1.2, " ");
322  mPtCorrOverGen_GenEta_600_1500 = ibooker.bookProfile("PtCorrOverGen_GenEta_600_1500", "600<genPt<1500;#eta", 90, etaRange, 0.8, 1.2, " ");
323  mPtCorrOverGen_GenEta_1500_3500 = ibooker.bookProfile("PtCorrOverGen_GenEta_1500_3500", "1500<genPt<3500;#eta", 90, etaRange, 0.8, 1.2, " ");
324  mPtCorrOverGen_GenEta_3500_5000 = ibooker.bookProfile("PtCorrOverGen_GenEta_3500_5000", "3500<genPt<5000;#eta", 90, etaRange, 0.8, 1.2, " ");
325  mPtCorrOverGen_GenEta_5000_6500 = ibooker.bookProfile("PtCorrOverGen_GenEta_5000_6500", "5000<genPt<6500;#eta", 90, etaRange, 0.8, 1.2, " ");
326  mPtCorrOverGen_GenEta_3500 = ibooker.bookProfile("PtCorrOverGen_GenEta_3500", "genPt>3500;#eta", 90, etaRange, 0.8, 1.2, " ");
327  }
328 
329  mGenEta = ibooker.book1D("GenEta", "GenEta", 120, -6, 6);
330  mGenPhi = ibooker.book1D("GenPhi", "GenPhi", 70, -3.5, 3.5);
331  mGenPt = ibooker.book1D("GenPt", "GenPt", 100, 0, 1000);
332  mGenEtaFirst = ibooker.book1D("GenEtaFirst", "GenEtaFirst", 120, -6, 6);
333  mGenPhiFirst = ibooker.book1D("GenPhiFirst", "GenPhiFirst", 70, -3.5, 3.5);
334  mPtHat = ibooker.book1D("PtHat", "PtHat", 100, 0, 1000);
335  mDeltaEta = ibooker.book1D("DeltaEta", "DeltaEta", 100, -0.5, 0.5);
336  mDeltaPhi = ibooker.book1D("DeltaPhi", "DeltaPhi", 100, -0.5, 0.5);
337  mDeltaPt = ibooker.book1D("DeltaPt", "DeltaPt", 100, -1.0, 1.0);
338 
339  mPtRecoOverGen_B_20_40 = ibooker.book1D("PtRecoOverGen_B_20_40", "20<genpt<40", 90, 0, 2);
340  mPtRecoOverGen_E_20_40 = ibooker.book1D("PtRecoOverGen_E_20_40", "20<genpt<40", 90, 0, 2);
341  mPtRecoOverGen_F_20_40 = ibooker.book1D("PtRecoOverGen_F_20_40", "20<genpt<40", 90, 0, 2);
342  mPtRecoOverGen_B_40_200 = ibooker.book1D("PtRecoOverGen_B_40_200", "40<genpt<200", 90, 0, 2);
343  mPtRecoOverGen_E_40_200 = ibooker.book1D("PtRecoOverGen_E_40_200", "40<genpt<200", 90, 0, 2);
344  mPtRecoOverGen_F_40_200 = ibooker.book1D("PtRecoOverGen_F_40_200", "40<genpt<200", 90, 0, 2);
345  mPtRecoOverGen_B_200_600 = ibooker.book1D("PtRecoOverGen_B_200_600", "200<genpt<600", 90, 0, 2);
346  mPtRecoOverGen_E_200_600 = ibooker.book1D("PtRecoOverGen_E_200_600", "200<genpt<600", 90, 0, 2);
347  mPtRecoOverGen_F_200_600 = ibooker.book1D("PtRecoOverGen_F_200_600", "200<genpt<600", 90, 0, 2);
348  mPtRecoOverGen_B_600_1500 = ibooker.book1D("PtRecoOverGen_B_600_1500", "600<genpt<1500", 90, 0, 2);
349  mPtRecoOverGen_E_600_1500 = ibooker.book1D("PtRecoOverGen_E_600_1500", "600<genpt<1500", 90, 0, 2);
350  mPtRecoOverGen_F_600_1500 = ibooker.book1D("PtRecoOverGen_F_600_1500", "600<genpt<1500", 90, 0, 2);
351  mPtRecoOverGen_B_1500_3500 = ibooker.book1D("PtRecoOverGen_B_1500_3500", "1500<genpt<3500", 90, 0, 2);
352  mPtRecoOverGen_E_1500_3500 = ibooker.book1D("PtRecoOverGen_E_1500_3500", "1500<genpt<3500", 90, 0, 2);
353  mPtRecoOverGen_F_1500_3500 = ibooker.book1D("PtRecoOverGen_F_1500_3500", "1500<genpt<3500", 90, 0, 2);
354  mPtRecoOverGen_B_3500_5000 = ibooker.book1D("PtRecoOverGen_B_3500_5000", "3500<genpt<5000", 90, 0, 2);
355  mPtRecoOverGen_E_3500_5000 = ibooker.book1D("PtRecoOverGen_E_3500_5000", "3500<genpt<5000", 90, 0, 2);
356  mPtRecoOverGen_B_5000_6500 = ibooker.book1D("PtRecoOverGen_B_5000_6500", "5000<genpt<6500", 90, 0, 2);
357  mPtRecoOverGen_E_5000_6500 = ibooker.book1D("PtRecoOverGen_E_5000_6500", "5000<genpt<6500", 90, 0, 2);
358  mPtRecoOverGen_B_3500 = ibooker.book1D("PtRecoOverGen_B_3500", "genpt>3500", 90, 0, 2);
359  mPtRecoOverGen_E_3500 = ibooker.book1D("PtRecoOverGen_E_3500", "genpt>3500", 90, 0, 2);
360  mPtRecoOverGen_F_3500 = ibooker.book1D("PtRecoOverGen_F_3500", "genpt>3500", 90, 0, 2);
361 
362  // Generation profiles
363  mPtRecoOverGen_GenPt_B = ibooker.bookProfile("PtRecoOverGen_GenPt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
364  mPtRecoOverGen_GenPt_E = ibooker.bookProfile("PtRecoOverGen_GenPt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
365  mPtRecoOverGen_GenPt_F = ibooker.bookProfile("PtRecoOverGen_GenPt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
366  mPtRecoOverGen_GenPhi_B = ibooker.bookProfile("PtRecoOverGen_GenPhi_B", "0<|eta|<1.5", 70, -3.5, 3.5, 0, 2, " ");
367  mPtRecoOverGen_GenPhi_E = ibooker.bookProfile("PtRecoOverGen_GenPhi_E", "1.5<|eta|<3", 70, -3.5, 3.5, 0, 2, " ");
368  mPtRecoOverGen_GenPhi_F = ibooker.bookProfile("PtRecoOverGen_GenPhi_F", "3<|eta|<6", 70, -3.5, 3.5, 0, 2, " ");
369  //if eta range changed here need change in JetTesterPostProcessor as well
370  mPtRecoOverGen_GenEta_20_40 = ibooker.bookProfile("PtRecoOverGen_GenEta_20_40", "20<genpt<40", 90, etaRange, 0, 2, " ");
371  mPtRecoOverGen_GenEta_40_200 = ibooker.bookProfile("PtRecoOverGen_GenEta_40_200", "40<genpt<200", 90, etaRange, 0, 2, " ");
372  mPtRecoOverGen_GenEta_200_600 = ibooker.bookProfile("PtRecoOverGen_GenEta_200_600", "200<genpt<600", 90, etaRange, 0, 2, " ");
373  mPtRecoOverGen_GenEta_600_1500 = ibooker.bookProfile("PtRecoOverGen_GenEta_600_1500", "600<genpt<1500", 90, etaRange, 0, 2, " ");
374  mPtRecoOverGen_GenEta_1500_3500 = ibooker.bookProfile("PtRecoOverGen_GenEta_1500_3500", "1500<genpt<3500", 90, etaRange, 0, 2, " ");
375  mPtRecoOverGen_GenEta_3500_5000 = ibooker.bookProfile("PtRecoOverGen_GenEta_3500_5000", "3500<genpt<5000", 90, etaRange, 0, 2, " ");
376  mPtRecoOverGen_GenEta_5000_6500 = ibooker.bookProfile("PtRecoOverGen_GenEta_5000_6500", "5000<genpt<6500", 90, etaRange, 0, 2, " ");
377  mPtRecoOverGen_GenEta_3500 = ibooker.bookProfile("PtRecoOverGen_GenEta_3500", "genpt>3500", 90, etaRange, 0, 2, " ");
378 
379  // Some jet algebra
380  //------------------------------------------------------------------------
381  mEtaFirst = ibooker.book1D("EtaFirst", "EtaFirst", 120, -6, 6);
382  mPhiFirst = ibooker.book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);
383  mPtFirst = ibooker.book1D("PtFirst", "PtFirst", 50, 0, 1000);
384  mMjj = ibooker.book1D("Mjj", "Mjj", 100, 0, 2000);
385  mNJetsEta_B_20_40 = ibooker.book1D("NJetsEta_B_20_40", "NJetsEta_B 20<Pt<40", 15, 0, 15);
386  mNJetsEta_E_20_40 = ibooker.book1D("NJetsEta_E_20_40", "NJetsEta_E 20<Pt<40", 15, 0, 15);
387  mNJetsEta_B_40 = ibooker.book1D("NJetsEta_B", "NJetsEta_B 40<Pt", 15, 0, 15);
388  mNJetsEta_E_40 = ibooker.book1D("NJetsEta_E", "NJetsEta_E 40<Pt", 15, 0, 15);
389  mNJets_40 = ibooker.book1D("NJets", "NJets 40>Pt", 15, 0, 15);
390  mNJets1 = ibooker.bookProfile("NJets1", "Number of jets above Pt threshold", 100, 0, 200, 100, 0, 50, "s");
391  mNJets2 = ibooker.bookProfile("NJets2", "Number of jets above Pt threshold", 100, 0, 4000, 100, 0, 50, "s");
392 
393 
394  if (isCaloJet) {
395  maxEInEmTowers = ibooker.book1D("maxEInEmTowers", "maxEInEmTowers", 50,0,500);
396  maxEInHadTowers = ibooker.book1D("maxEInHadTowers", "maxEInHadTowers", 50,0,500);
397  energyFractionHadronic = ibooker.book1D("energyFractionHadronic", "energyFractionHadronic", 50,0,1);
398  emEnergyFraction = ibooker.book1D("emEnergyFraction", "emEnergyFraction", 50,0,1);
399  hadEnergyInHB = ibooker.book1D("hadEnergyInHB", "hadEnergyInHB", 50,0,500);
400  hadEnergyInHO = ibooker.book1D("hadEnergyInHO", "hadEnergyInHO", 50,0,500);
401  hadEnergyInHE = ibooker.book1D("hadEnergyInHE", "hadEnergyInHE", 50,0,500);
402  hadEnergyInHF = ibooker.book1D("hadEnergyInHF", "hadEnergyInHF", 50,0,500);
403  emEnergyInEB = ibooker.book1D("emEnergyInEB", "emEnergyInEB", 50,0,500);
404  emEnergyInEE = ibooker.book1D("emEnergyInEE", "emEnergyInEE", 50,0,500);
405  emEnergyInHF = ibooker.book1D("emEnergyInHF", "emEnergyInHF", 50,0,500);
406  towersArea = ibooker.book1D("towersArea", "towersArea", 50,0,1);
407  n90 = ibooker.book1D("n90", "n90", 30,0,30);
408  n60 = ibooker.book1D("n60", "n60", 30,0,30);
409  }
410 
411  if (isPFJet || isMiniAODJet) {
412  muonMultiplicity = ibooker.book1D("muonMultiplicity", "muonMultiplicity", 10,0,10);
413  chargedMultiplicity = ibooker.book1D("chargedMultiplicity", "chargedMultiplicity", 100,0,100);
414  chargedEmEnergy = ibooker.book1D("chargedEmEnergy", "chargedEmEnergy", 100,0,500);
415  neutralEmEnergy = ibooker.book1D("neutralEmEnergy", "neutralEmEnergy", 100,0,500);
416  chargedHadronEnergy = ibooker.book1D("chargedHadronEnergy", "chargedHadronEnergy", 100,0,500);
417  neutralHadronEnergy = ibooker.book1D("neutralHadronEnergy", "neutralHadronEnergy", 100,0,500);
418  chargedHadronEnergyFraction = ibooker.book1D("chargedHadronEnergyFraction", "chargedHadronEnergyFraction", 50,0,1);
419  neutralHadronEnergyFraction = ibooker.book1D("neutralHadronEnergyFraction", "neutralHadronEnergyFraction", 50,0,1);
420  chargedEmEnergyFraction = ibooker.book1D("chargedEmEnergyFraction", "chargedEmEnergyFraction", 50,0,1);
421  neutralEmEnergyFraction = ibooker.book1D("neutralEmEnergyFraction", "neutralEmEnergyFraction", 50,0,1);
422  photonEnergy = ibooker.book1D("photonEnergy", "photonEnergy", 50,0,500);
423  photonEnergyFraction = ibooker.book1D("photonEnergyFraction", "photonEnergyFraction", 50,0,1);
424  electronEnergy = ibooker.book1D("electronEnergy", "electronEnergy", 50,0,500);
425  electronEnergyFraction = ibooker.book1D("electronEnergyFraction", "electronEnergyFraction", 50,0,1);
426  muonEnergy = ibooker.book1D("muonEnergy", "muonEnergy", 50,0,500);
427  muonEnergyFraction = ibooker.book1D("muonEnergyFraction", "muonEnergyFraction", 50,0,1);
428  HFHadronEnergy = ibooker.book1D("HFHadronEnergy", "HFHadronEnergy", 50,0,500);
429  HFHadronEnergyFraction = ibooker.book1D("HFHadronEnergyFraction", "HFHadronEnergyFraction", 50,0,1);
430  HFEMEnergy = ibooker.book1D("HFEMEnergy", "HFEMEnergy", 50,0,500);
431  HFEMEnergyFraction = ibooker.book1D("HFEMEnergyFraction", "HFEMEnergyFraction", 50,0,1);
432  chargedHadronMultiplicity = ibooker.book1D("chargedHadronMultiplicity", "chargedHadronMultiplicity", 50,0,50);
433  neutralHadronMultiplicity = ibooker.book1D("neutralHadronMultiplicity", "neutralHadronMultiplicity", 50,0,50);
434  photonMultiplicity = ibooker.book1D("photonMultiplicity", "photonMultiplicity", 10,0,10);
435  electronMultiplicity = ibooker.book1D("electronMultiplicity", "electronMultiplicity", 10,0,10);
436  HFHadronMultiplicity = ibooker.book1D("HFHadronMultiplicity", "HFHadronMultiplicity", 50,0,50);
437  HFEMMultiplicity = ibooker.book1D("HFEMMultiplicity", "HFEMMultiplicity", 50,0,50);
438  chargedMuEnergy = ibooker.book1D("chargedMuEnergy", "chargedMuEnergy", 50,0,500);
439  chargedMuEnergyFraction = ibooker.book1D("chargedMuEnergyFraction", "chargedMuEnergyFraction", 50,0,1);
440  neutralMultiplicity = ibooker.book1D("neutralMultiplicity", "neutralMultiplicity", 50,0,50);
441  HOEnergy = ibooker.book1D("HOEnergy", "HOEnergy", 50,0,500);
442  HOEnergyFraction = ibooker.book1D("HOEnergyFraction", "HOEnergyFraction", 50,0,1);
443  }
444 }
445 
446 
447 //------------------------------------------------------------------------------
448 // ~JetTester
449 //------------------------------------------------------------------------------
451 
452 
453 //------------------------------------------------------------------------------
454 // analyze
455 //------------------------------------------------------------------------------
456 void JetTester::analyze(const edm::Event& mEvent, const edm::EventSetup& mSetup)
457 {
458  // Get the primary vertices
459  //----------------------------------------------------------------------------
461  mEvent.getByToken(pvToken_, pvHandle);
462 
463  int nGoodVertices = 0;
464 
465  if (pvHandle.isValid())
466  {
467  for (unsigned i=0; i<pvHandle->size(); i++)
468  {
469  if ((*pvHandle)[i].ndof() > 4 &&
470  (fabs((*pvHandle)[i].z()) <= 24) &&
471  (fabs((*pvHandle)[i].position().rho()) <= 2))
472  nGoodVertices++;
473  }
474  }
475 
476  mNvtx->Fill(nGoodVertices);
477 
478 // // Get the jet rho
479 // //----------------------------------------------------------------------------
480 // edm::Handle<double> pRho;
481 // mEvent.getByToken(rhoTag, pRho);
482 //
483 // if (pRho.isValid())
484 // {
485 // double jetRho = *pRho;
486 //
487 // if (mRho) mRho->Fill(jetRho);
488 // }
489 
490 
491  // Get the Jet collection
492  //----------------------------------------------------------------------------
493  math::XYZTLorentzVector p4tmp[2];
494 
495  std::vector<Jet> recoJets;
496  recoJets.clear();
497 
500 // edm::Handle<JPTJetCollection> jptJets;
502 
503  if (isCaloJet) mEvent.getByToken(caloJetsToken_, caloJets);
504  if (isPFJet) mEvent.getByToken(pfJetsToken_, pfJets);
505 // if (isJPTJet) mEvent.getByToken(jptJetsToken_, jptJets);
506  if (isMiniAODJet) mEvent.getByToken(patJetsToken_, patJets);
507 
508  if (isCaloJet && !caloJets.isValid()) return;
509  if (isPFJet && !pfJets.isValid()) return;
510 // if (isJPTJet && !jptJets.isValid()) return;
511  if (isMiniAODJet && !patJets.isValid()) return;
512 
513 
514  if (isCaloJet)
515  {
516  for (unsigned ijet=0; ijet<caloJets->size(); ijet++)
517  recoJets.push_back((*caloJets)[ijet]);
518  }
519 
520 /* if (isJPTJet)
521  {
522  for (unsigned ijet=0; ijet<jptJets->size(); ijet++)
523  recoJets.push_back((*jptJets)[ijet]);
524  }*/
525 
526  if (isPFJet) {
527  for (unsigned ijet=0; ijet<pfJets->size(); ijet++)
528  recoJets.push_back((*pfJets)[ijet]);
529  }
530  if (isMiniAODJet) {
531  for (unsigned ijet=0; ijet<patJets->size(); ijet++)
532  recoJets.push_back((*patJets)[ijet]);
533  }
534 
535  int nJet = 0;
536  int nJet_E_20_40 = 0;
537  int nJet_B_20_40 = 0;
538  int nJet_E_40 = 0;
539  int nJet_B_40 = 0;
540  int nJet_40 = 0;
541 
542  int index_first_jet=-1;
543  double pt_first=-1;
544 
545  int index_second_jet=-1;
546  double pt_second=-1;
547 
548  for (unsigned ijet=0; ijet<recoJets.size(); ijet++) {
549  bool pass_lowjet=false;
550  bool pass_mediumjet = false;
551  if(!isMiniAODJet){
552  if ( (recoJets[ijet].pt() > 20.) && (recoJets[ijet].pt() < mRecoJetPtThreshold)) {
553  pass_lowjet=true;
554  }
555  }
556  if(isMiniAODJet){
557  if((recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected"))>20. && ((recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected")) < mRecoJetPtThreshold)){
558  pass_lowjet=true;
559  }
560  }
561  if (pass_lowjet) {
562  if (fabs(recoJets[ijet].eta()) > 1.5)
563  nJet_E_20_40++;
564  else
565  nJet_B_20_40++;
566  }
567  if(!isMiniAODJet){
568  if (recoJets[ijet].pt() > mRecoJetPtThreshold) {
569  pass_mediumjet = true;
570  }
571  }
572  if(isMiniAODJet){
573  if((recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected")) > mRecoJetPtThreshold){
574  pass_mediumjet=true;
575  }
576  }
577  if (pass_mediumjet) {
578  if(isMiniAODJet){
579  if( (recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected"))>pt_first){
580  pt_second=pt_first;
581  pt_first=recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected");
582  index_second_jet=index_first_jet;
583  index_first_jet=ijet;
584  }else if( (recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected"))>pt_second){
585  index_second_jet=ijet;
586  pt_second=recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected");
587  }
588  }
589  //counting forward and barrel jets
590  if (fabs(recoJets[ijet].eta()) > 1.5)
591  nJet_E_40++;
592  else
593  nJet_B_40++;
594  nJet_40++;
595 
596  if (mEta) mEta->Fill(recoJets[ijet].eta());
597 
598  if (mJetArea) mJetArea ->Fill(recoJets[ijet].jetArea());
599  if (mPhi) mPhi ->Fill(recoJets[ijet].phi());
600  if(!isMiniAODJet){
601  if (mEnergy) mEnergy ->Fill(recoJets[ijet].energy());
602  if (mP) mP ->Fill(recoJets[ijet].p());
603  if (mPt) mPt ->Fill(recoJets[ijet].pt());
604  if (mMass) mMass ->Fill(recoJets[ijet].mass());
605  }else{
606  if (mEnergy) mEnergy ->Fill(recoJets[ijet].energy()*(*patJets)[ijet].jecFactor("Uncorrected"));
607  if (mP) mP ->Fill(recoJets[ijet].p()*(*patJets)[ijet].jecFactor("Uncorrected"));
608  if (mPt) mPt ->Fill(recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected"));
609  if (mMass) mMass ->Fill(recoJets[ijet].mass()*(*patJets)[ijet].jecFactor("Uncorrected"));
610  }
611  if (mConstituents) mConstituents->Fill(recoJets[ijet].nConstituents());
612  if(!isMiniAODJet){
613  if (ijet == 0) {
614  if (mEtaFirst) mEtaFirst->Fill(recoJets[ijet].eta());
615  if (mPhiFirst) mPhiFirst->Fill(recoJets[ijet].phi());
616  if (mPtFirst) mPtFirst ->Fill(recoJets[ijet].pt());
617  }
618 
619  if (ijet == 0) {nJet++; p4tmp[0] = recoJets[ijet].p4();}
620  if (ijet == 1) {nJet++; p4tmp[1] = recoJets[ijet].p4();}
621  }
622  // if (isPFJet || isCaloJet) {
623  // if (mHadEnergyInHF) mHadEnergyInHF ->Fill((*pfJets)[ijet].HFHadronEnergy());
624  // if (mEmEnergyInHF) mEmEnergyInHF ->Fill((*pfJets)[ijet].HFEMEnergy());
625  // if (mChargedEmEnergy) mChargedEmEnergy ->Fill((*pfJets)[ijet].chargedEmEnergy());
626  // if (mChargedHadronEnergy) mChargedHadronEnergy->Fill((*pfJets)[ijet].chargedHadronEnergy());
627  // if (mNeutralEmEnergy) mNeutralEmEnergy ->Fill((*pfJets)[ijet].neutralEmEnergy());
628  // if (mNeutralHadronEnergy) mNeutralHadronEnergy->Fill((*pfJets)[ijet].neutralHadronEnergy());
629  // }
630 
631 
632  // ---- Calo Jet specific information ----
633  if (isCaloJet) {
634  maxEInEmTowers ->Fill((*caloJets)[ijet].maxEInEmTowers());
635  maxEInHadTowers ->Fill((*caloJets)[ijet].maxEInHadTowers());
636  energyFractionHadronic ->Fill((*caloJets)[ijet].energyFractionHadronic());
637  emEnergyFraction ->Fill((*caloJets)[ijet].emEnergyFraction());
638  hadEnergyInHB ->Fill((*caloJets)[ijet].hadEnergyInHB());
639  hadEnergyInHO ->Fill((*caloJets)[ijet].hadEnergyInHO());
640  hadEnergyInHE ->Fill((*caloJets)[ijet].hadEnergyInHE());
641  hadEnergyInHF ->Fill((*caloJets)[ijet].hadEnergyInHF());
642  emEnergyInEB ->Fill((*caloJets)[ijet].emEnergyInEB());
643  emEnergyInEE ->Fill((*caloJets)[ijet].emEnergyInEE());
644  emEnergyInHF ->Fill((*caloJets)[ijet].emEnergyInHF());
645  towersArea ->Fill((*caloJets)[ijet].towersArea());
646  n90 ->Fill((*caloJets)[ijet].n90());
647  n60 ->Fill((*caloJets)[ijet].n60());
648  }
649  // ---- PF Jet specific information ----
650  if (isPFJet) {
651  muonMultiplicity ->Fill((*pfJets)[ijet].muonMultiplicity());
652  chargedMultiplicity ->Fill((*pfJets)[ijet].chargedMultiplicity());
653  chargedEmEnergy ->Fill((*pfJets)[ijet].chargedEmEnergy());
654  neutralEmEnergy ->Fill((*pfJets)[ijet].neutralEmEnergy());
655  chargedHadronEnergy ->Fill((*pfJets)[ijet].chargedHadronEnergy());
656  neutralHadronEnergy ->Fill((*pfJets)[ijet].neutralHadronEnergy());
661  photonEnergy ->Fill((*pfJets)[ijet].photonEnergy());
662  photonEnergyFraction ->Fill((*pfJets)[ijet].photonEnergyFraction());
663  electronEnergy ->Fill((*pfJets)[ijet].electronEnergy());
665  muonEnergy ->Fill((*pfJets)[ijet].muonEnergy());
666  muonEnergyFraction ->Fill((*pfJets)[ijet].muonEnergyFraction());
667  HFHadronEnergy ->Fill((*pfJets)[ijet].HFHadronEnergy());
669  HFEMEnergy ->Fill((*pfJets)[ijet].HFEMEnergy());
670  HFEMEnergyFraction ->Fill((*pfJets)[ijet].HFEMEnergyFraction());
673  photonMultiplicity ->Fill((*pfJets)[ijet].photonMultiplicity());
674  electronMultiplicity ->Fill((*pfJets)[ijet].electronMultiplicity());
675  HFHadronMultiplicity ->Fill((*pfJets)[ijet].HFHadronMultiplicity());
676  HFEMMultiplicity ->Fill((*pfJets)[ijet].HFEMMultiplicity());
677  chargedMuEnergy ->Fill((*pfJets)[ijet].chargedMuEnergy());
679  neutralMultiplicity ->Fill((*pfJets)[ijet].neutralMultiplicity());
680  HOEnergy ->Fill((*pfJets)[ijet].hoEnergy());
681  HOEnergyFraction ->Fill((*pfJets)[ijet].hoEnergyFraction());
682  }
683  if (isMiniAODJet && (*patJets)[ijet].isPFJet()) {
684  muonMultiplicity ->Fill((*patJets)[ijet].muonMultiplicity());
685  chargedMultiplicity ->Fill((*patJets)[ijet].chargedMultiplicity());
686  chargedEmEnergy ->Fill((*patJets)[ijet].chargedEmEnergy());
687  neutralEmEnergy ->Fill((*patJets)[ijet].neutralEmEnergy());
688  chargedHadronEnergy ->Fill((*patJets)[ijet].chargedHadronEnergy());
689  neutralHadronEnergy ->Fill((*patJets)[ijet].neutralHadronEnergy());
694  photonEnergy ->Fill((*patJets)[ijet].photonEnergy());
695  photonEnergyFraction ->Fill((*patJets)[ijet].photonEnergyFraction());
696  electronEnergy ->Fill((*patJets)[ijet].electronEnergy());
697  electronEnergyFraction ->Fill((*patJets)[ijet].electronEnergyFraction());
698  muonEnergy ->Fill((*patJets)[ijet].muonEnergy());
699  muonEnergyFraction ->Fill((*patJets)[ijet].muonEnergyFraction());
700  HFHadronEnergy ->Fill((*patJets)[ijet].HFHadronEnergy());
701  HFHadronEnergyFraction ->Fill((*patJets)[ijet].HFHadronEnergyFraction());
702  HFEMEnergy ->Fill((*patJets)[ijet].HFEMEnergy());
703  HFEMEnergyFraction ->Fill((*patJets)[ijet].HFEMEnergyFraction());
706  photonMultiplicity ->Fill((*patJets)[ijet].photonMultiplicity());
707  electronMultiplicity ->Fill((*patJets)[ijet].electronMultiplicity());
708  HFHadronMultiplicity ->Fill((*patJets)[ijet].HFHadronMultiplicity());
709  HFEMMultiplicity ->Fill((*patJets)[ijet].HFEMMultiplicity());
710  chargedMuEnergy ->Fill((*patJets)[ijet].chargedMuEnergy());
712  neutralMultiplicity ->Fill((*patJets)[ijet].neutralMultiplicity());
713  HOEnergy ->Fill((*patJets)[ijet].hoEnergy());
714  HOEnergyFraction ->Fill((*patJets)[ijet].hoEnergyFraction());
715  }
716  }//fill quantities for medium jets
717  }
718 
719  if (mNJetsEta_B_20_40) mNJetsEta_B_20_40->Fill(nJet_B_20_40);
720  if (mNJetsEta_E_20_40) mNJetsEta_E_20_40->Fill(nJet_E_20_40);
721  if (mNJetsEta_B_40) mNJetsEta_B_40->Fill(nJet_B_40);
722  if (mNJetsEta_E_40) mNJetsEta_E_40->Fill(nJet_E_40);
723  if (mNJets_40) mNJets_40->Fill(nJet_40);
724  if(!isMiniAODJet){
725  if (nJet >= 2)
726  {
727  if (mMjj) mMjj->Fill((p4tmp[0]+p4tmp[1]).mass());
728  }
729  }else{
730  if(index_first_jet>-1){
731  if (mEtaFirst) mEtaFirst->Fill(recoJets[index_first_jet].eta());
732  if (mPhiFirst) mPhiFirst->Fill(recoJets[index_first_jet].phi());
733  if (mPtFirst) mPtFirst ->Fill(recoJets[index_first_jet].pt()*(*patJets)[index_first_jet].jecFactor("Uncorrected"));
734  nJet++; p4tmp[0] = recoJets[index_first_jet].p4()*(*patJets)[index_first_jet].jecFactor("Uncorrected");
735  }
736  if(index_second_jet>-1){
737  nJet++; p4tmp[1] = recoJets[index_second_jet].p4()*(*patJets)[index_second_jet].jecFactor("Uncorrected");
738  }
739  if (nJet >= 2)
740  {
741  if (mMjj) mMjj->Fill((p4tmp[0]+p4tmp[1]).mass());
742  }
743  }
744 
745  // Count jets above pt cut
746  //----------------------------------------------------------------------------
747  for (int istep=0; istep<100; ++istep)
748  {
749  int njets1 = 0;
750  int njets2 = 0;
751 
752  float ptStep1 = (istep * ( 200. / 100.));
753  float ptStep2 = (istep * (4000. / 100.));
754 
755  for (unsigned ijet=0; ijet<recoJets.size(); ijet++) {
756  if(!isMiniAODJet){
757  if (recoJets[ijet].pt() > ptStep1) njets1++;
758  if (recoJets[ijet].pt() > ptStep2) njets2++;
759  }else{
760  if ((recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected")) > ptStep1) njets1++;
761  if ((recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected")) > ptStep2) njets2++;
762  }
763  mNJets1->Fill(ptStep1, njets1);
764  mNJets2->Fill(ptStep2, njets2);
765  }
766  }
767 
768 
769  // Corrected jets
770  //----------------------------------------------------------------------------
771  double scale = -999;
773  bool pass_correction_flag =false;
774  if(!isMiniAODJet && !mJetCorrector.label().empty()){
775  mEvent.getByToken(jetCorrectorToken_, jetCorr);
776  if (jetCorr.isValid()){
777  pass_correction_flag=true;
778  }
779  }
780  if(isMiniAODJet){
781  pass_correction_flag =true;
782  }
783  for (unsigned ijet=0; ijet<recoJets.size(); ijet++) {
784  Jet correctedJet = recoJets[ijet];
785  if(pass_correction_flag){
786  if (isCaloJet) scale = jetCorr->correction((*caloJets)[ijet]);
787  if (isPFJet) scale = jetCorr->correction((*pfJets)[ijet]);
788  //if (isJPTJet) scale = jetCorr->correction((*jptJets)[ijet]);
789  if(!isMiniAODJet){
790  correctedJet.scaleEnergy(scale);
791  }
792 
793  if (correctedJet.pt() < 20) continue;
794 
795  mCorrJetEta->Fill(correctedJet.eta());
796  mCorrJetPhi->Fill(correctedJet.phi());
797  mCorrJetPt ->Fill(correctedJet.pt());
798  if (correctedJet.pt() >= 40) {
799  mCorrJetEta_Pt40->Fill(correctedJet.eta());
800  mCorrJetPhi_Pt40->Fill(correctedJet.phi());
801  }
802 
803  double ijetEta = recoJets[ijet].eta();
804  double ijetPt = recoJets[ijet].pt();
805  if(isMiniAODJet){
806  ijetPt=recoJets[ijet].pt()*(*patJets)[ijet].jecFactor("Uncorrected");
807  }
808  double ratio = correctedJet.pt() / ijetPt;
809  if(isMiniAODJet){
810  ratio =1./(*patJets)[ijet].jecFactor("Uncorrected");
811  }
812 
813  if (fabs(ijetEta) < 1.5) mPtCorrOverReco_Pt_B->Fill(log10(ijetPt), ratio);
814  else if (fabs(ijetEta) < 3.0) mPtCorrOverReco_Pt_E->Fill(log10(ijetPt), ratio);
815  else if (fabs(ijetEta) < 6.0) mPtCorrOverReco_Pt_F->Fill(log10(ijetPt), ratio);
816 
817  if (ijetPt < 40) mPtCorrOverReco_Eta_20_40 ->Fill(ijetEta, ratio);
818  else if (ijetPt < 200) mPtCorrOverReco_Eta_40_200 ->Fill(ijetEta, ratio);
819  else if (ijetPt < 600) mPtCorrOverReco_Eta_200_600 ->Fill(ijetEta, ratio);
820  else if (ijetPt < 1500) mPtCorrOverReco_Eta_600_1500 ->Fill(ijetEta, ratio);
821  else if (ijetPt < 3500) mPtCorrOverReco_Eta_1500_3500->Fill(ijetEta, ratio);
822  else if (ijetPt < 5000) mPtCorrOverReco_Eta_3500_5000->Fill(ijetEta, ratio);
823  else if (ijetPt < 6500) mPtCorrOverReco_Eta_5000_6500->Fill(ijetEta, ratio);
824  if (ijetPt > 3500) mPtCorrOverReco_Eta_3500->Fill(ijetEta, ratio);
825  }
826  }
827 
828  //----------------------------------------------------------------------------
829  //
830  // Generation
831  //
832  //----------------------------------------------------------------------------
833  if (!mEvent.isRealData())
834  {
835  // Get ptHat
836  //------------------------------------------------------------------------
838  mEvent.getByToken(evtToken_, myGenEvt);
839 
840  if (myGenEvt.isValid()) {
841  if(myGenEvt->hasBinningValues()){
842  double ptHat = myGenEvt->binningValues()[0];
843  if (mPtHat) mPtHat->Fill(ptHat);
844  }
845  }
846  // Gen jets
847  //------------------------------------------------------------------------
849  mEvent.getByToken(genJetsToken_, genJets);
850 
851  if (!genJets.isValid()) return;
852 
853  for (GenJetCollection::const_iterator gjet=genJets->begin(); gjet!=genJets->end(); gjet++) {
854  //for MiniAOD we have here intrinsic thresholds, introduce also threshold for RECO
855  if(gjet->pt() > mMatchGenPtThreshold){
856  if (mGenEta) mGenEta->Fill(gjet->eta());
857  if (mGenPhi) mGenPhi->Fill(gjet->phi());
858  if (mGenPt) mGenPt ->Fill(gjet->pt());
859  if (gjet == genJets->begin()) {
860  if (mGenEtaFirst) mGenEtaFirst->Fill(gjet->eta());
861  if (mGenPhiFirst) mGenPhiFirst->Fill(gjet->phi());
862  }
863  }
864  }
865 
866  if (!(mInputGenCollection.label().empty())) {
867  for (GenJetCollection::const_iterator gjet=genJets->begin(); gjet!=genJets->end(); gjet++) {
868  if (fabs(gjet->eta()) > 6.) continue; // Out of the detector
869  if (gjet->pt() < mMatchGenPtThreshold) continue;
870  if (recoJets.size() <= 0) continue;
871  // pt response
872  //------------------------------------------------------------
873  int iMatch = -1;
874  double CorrdeltaRBest = 999;
875  double CorrJetPtBest = 0;
876  for (unsigned ijet=0; ijet<recoJets.size(); ++ijet) {
877  Jet correctedJet = recoJets[ijet];
878  if(pass_correction_flag && !isMiniAODJet){
879  if (isCaloJet) scale = jetCorr->correction((*caloJets)[ijet]);
880  if (isPFJet) scale = jetCorr->correction((*pfJets)[ijet]);
881  correctedJet.scaleEnergy(scale);
882  }
883  double CorrJetPt = correctedJet.pt();
884  if (CorrJetPt > 10) {
885  double CorrdR = deltaR(gjet->eta(), gjet->phi(), correctedJet.eta(), correctedJet.phi());
886  if (CorrdR < CorrdeltaRBest) {
887  CorrdeltaRBest = CorrdR;
888  CorrJetPtBest = CorrJetPt;
889  iMatch = ijet;
890  }
891  }
892  }
893  if (iMatch<0) continue;
894  if(!isMiniAODJet){
895  fillMatchHists(gjet->eta(), gjet->phi(), gjet->pt(), recoJets[iMatch].eta(), recoJets[iMatch].phi(), recoJets[iMatch].pt());
896  }else{
897  fillMatchHists(gjet->eta(), gjet->phi(), gjet->pt(), (*patJets)[iMatch].eta(), (*patJets)[iMatch].phi(),(*patJets)[iMatch].pt()*(*patJets)[iMatch].jecFactor("Uncorrected"));
898  }
899  if (pass_correction_flag) {//fill only for corrected jets
900  if (CorrdeltaRBest < mRThreshold) {
901  double response = CorrJetPtBest / gjet->pt();
902 
903  if (fabs(gjet->eta()) < 1.5) mPtCorrOverGen_GenPt_B->Fill(log10(gjet->pt()), response);
904  else if (fabs(gjet->eta()) < 3.0) mPtCorrOverGen_GenPt_E->Fill(log10(gjet->pt()), response);
905  else if (fabs(gjet->eta()) < 6.0) mPtCorrOverGen_GenPt_F->Fill(log10(gjet->pt()), response);
906 
907  if (gjet->pt() > 20) {
908  if (gjet->pt() < 40) mPtCorrOverGen_GenEta_20_40 ->Fill(gjet->eta(), response);
909  else if (gjet->pt() < 200) mPtCorrOverGen_GenEta_40_200 ->Fill(gjet->eta(), response);
910  else if (gjet->pt() < 600) mPtCorrOverGen_GenEta_200_600 ->Fill(gjet->eta(), response);
911  else if (gjet->pt() < 1500) mPtCorrOverGen_GenEta_600_1500 ->Fill(gjet->eta(), response);
912  else if (gjet->pt() < 3500) mPtCorrOverGen_GenEta_1500_3500->Fill(gjet->eta(), response);
913  else if (gjet->pt() < 5000) mPtCorrOverGen_GenEta_3500_5000->Fill(gjet->eta(), response);
914  else if (gjet->pt() < 6500) mPtCorrOverGen_GenEta_5000_6500->Fill(gjet->eta(), response);
915  if (gjet->pt() > 3500) mPtCorrOverGen_GenEta_3500->Fill(gjet->eta(), response);
916  }
917  }
918  }
919  }
920  }
921  }
922 }
923 
924 
925 //------------------------------------------------------------------------------
926 // fillMatchHists
927 //------------------------------------------------------------------------------
928 void JetTester::fillMatchHists(const double GenEta,
929  const double GenPhi,
930  const double GenPt,
931  const double RecoEta,
932  const double RecoPhi,
933  const double RecoPt)
934 {
935  if (GenPt > mMatchGenPtThreshold) {
936  mDeltaEta->Fill(GenEta - RecoEta);
937  mDeltaPhi->Fill(GenPhi - RecoPhi);
938  mDeltaPt ->Fill((GenPt - RecoPt) / GenPt);
939  }
940 
941  if (fabs(GenEta) < 1.5)
942  {
943  mPtRecoOverGen_GenPt_B ->Fill(log10(GenPt), RecoPt / GenPt);
944  mPtRecoOverGen_GenPhi_B->Fill(GenPhi, RecoPt / GenPt);
945 
946  if (GenPt > 20 && GenPt < 40) mPtRecoOverGen_B_20_40 ->Fill(RecoPt / GenPt);
947  else if (GenPt < 200) mPtRecoOverGen_B_40_200 ->Fill(RecoPt / GenPt);
948  else if (GenPt < 600) mPtRecoOverGen_B_200_600 ->Fill(RecoPt / GenPt);
949  else if (GenPt < 1500) mPtRecoOverGen_B_600_1500 ->Fill(RecoPt / GenPt);
950  else if (GenPt < 3500) mPtRecoOverGen_B_1500_3500->Fill(RecoPt / GenPt);
951  else if (GenPt < 5000) mPtRecoOverGen_B_3500_5000->Fill(RecoPt / GenPt);
952  else if (GenPt < 6500) mPtRecoOverGen_B_5000_6500->Fill(RecoPt / GenPt);
953  if (GenPt>3500) mPtRecoOverGen_B_3500->Fill(RecoPt / GenPt);
954  }
955  else if (fabs(GenEta) < 3.0)
956  {
957  mPtRecoOverGen_GenPt_E ->Fill(log10(GenPt), RecoPt / GenPt);
958  mPtRecoOverGen_GenPhi_E->Fill(GenPhi, RecoPt / GenPt);
959 
960  if (GenPt > 20 && GenPt < 40) mPtRecoOverGen_E_20_40 ->Fill(RecoPt / GenPt);
961  else if (GenPt < 200) mPtRecoOverGen_E_40_200 ->Fill(RecoPt / GenPt);
962  else if (GenPt < 600) mPtRecoOverGen_E_200_600 ->Fill(RecoPt / GenPt);
963  else if (GenPt < 1500) mPtRecoOverGen_E_600_1500 ->Fill(RecoPt / GenPt);
964  else if (GenPt < 3500) mPtRecoOverGen_E_1500_3500->Fill(RecoPt / GenPt);
965  else if (GenPt < 5000) mPtRecoOverGen_E_3500_5000->Fill(RecoPt / GenPt);
966  else if (GenPt < 6500) mPtRecoOverGen_E_5000_6500->Fill(RecoPt / GenPt);
967  if (GenPt>3500) mPtRecoOverGen_E_3500->Fill(RecoPt / GenPt);
968  }
969  else if (fabs(GenEta) < 6.0)
970  {
971  mPtRecoOverGen_GenPt_F ->Fill (log10(GenPt), RecoPt / GenPt);
972  mPtRecoOverGen_GenPhi_F->Fill (GenPhi, RecoPt / GenPt);
973 
974  if (GenPt > 20 && GenPt < 40) mPtRecoOverGen_F_20_40 ->Fill(RecoPt / GenPt);
975  else if (GenPt < 200) mPtRecoOverGen_F_40_200 ->Fill(RecoPt / GenPt);
976  else if (GenPt < 600) mPtRecoOverGen_F_200_600 ->Fill(RecoPt / GenPt);
977  else if (GenPt < 1500) mPtRecoOverGen_F_600_1500 ->Fill(RecoPt / GenPt);
978  else if (GenPt < 3500) mPtRecoOverGen_F_1500_3500->Fill(RecoPt / GenPt);
979  if (GenPt>3500) mPtRecoOverGen_F_3500->Fill(RecoPt / GenPt);
980  }
981 
982  if (GenPt > 20 && GenPt < 40) mPtRecoOverGen_GenEta_20_40 ->Fill(GenEta, RecoPt / GenPt);
983  else if (GenPt < 200) mPtRecoOverGen_GenEta_40_200 ->Fill(GenEta, RecoPt / GenPt);
984  else if (GenPt < 600) mPtRecoOverGen_GenEta_200_600 ->Fill(GenEta, RecoPt / GenPt);
985  else if (GenPt < 1500) mPtRecoOverGen_GenEta_600_1500 ->Fill(GenEta, RecoPt / GenPt);
986  else if (GenPt < 3500) mPtRecoOverGen_GenEta_1500_3500->Fill(GenEta, RecoPt / GenPt);
987  else if (GenPt < 5000) mPtRecoOverGen_GenEta_3500_5000->Fill(GenEta, RecoPt / GenPt);
988  else if (GenPt < 6500) mPtRecoOverGen_GenEta_5000_6500->Fill(GenEta, RecoPt / GenPt);
989  if (GenPt > 3500) mPtRecoOverGen_GenEta_3500->Fill(GenEta, RecoPt / GenPt);
990 }
T getParameter(std::string const &) const
MonitorElement * mNJetsEta_B_40
Definition: JetTester.h:174
MonitorElement * mPtRecoOverGen_E_20_40
Definition: JetTester.h:127
int i
Definition: DBlmapReader.cc:9
MonitorElement * mPtRecoOverGen_B_5000_6500
Definition: JetTester.h:144
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
Definition: JetTester.h:63
MonitorElement * mPtCorrOverGen_GenEta_40_200
Definition: JetTester.h:107
MonitorElement * mPtCorrOverReco_Pt_E
Definition: JetTester.h:93
MonitorElement * hadEnergyInHE
Definition: JetTester.h:187
MonitorElement * mNvtx
Definition: JetTester.h:72
MonitorElement * HFHadronEnergyFraction
Definition: JetTester.h:216
MonitorElement * mPtRecoOverGen_B_20_40
Definition: JetTester.h:126
MonitorElement * mPtCorrOverGen_GenPt_F
Definition: JetTester.h:105
MonitorElement * mPtRecoOverGen_F_40_200
Definition: JetTester.h:131
edm::EDGetTokenT< reco::GenJetCollection > genJetsToken_
Definition: JetTester.h:66
bool isMiniAODJet
Definition: JetTester.h:237
MonitorElement * mPtRecoOverGen_GenEta_3500
Definition: JetTester.h:164
MonitorElement * HOEnergy
Definition: JetTester.h:228
virtual void scaleEnergy(double fScale)
scale energy of the jet
MonitorElement * neutralHadronEnergy
Definition: JetTester.h:202
MonitorElement * electronEnergyFraction
Definition: JetTester.h:212
MonitorElement * mPtRecoOverGen_B_200_600
Definition: JetTester.h:132
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: JetTester.cc:258
MonitorElement * HFEMEnergyFraction
Definition: JetTester.h:218
bool isPFJet
Definition: JetTester.h:236
MonitorElement * mPtRecoOverGen_E_3500_5000
Definition: JetTester.h:143
MonitorElement * mPtRecoOverGen_GenPt_F
Definition: JetTester.h:153
MonitorElement * mMjj
Definition: JetTester.h:171
edm::InputTag mInputGenCollection
Definition: JetTester.h:58
MonitorElement * mPtFirst
Definition: JetTester.h:170
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< reco::CaloJetCollection > caloJetsToken_
Definition: JetTester.h:64
MonitorElement * photonEnergyFraction
Definition: JetTester.h:210
edm::EDGetTokenT< pat::JetCollection > patJetsToken_
Definition: JetTester.h:68
MonitorElement * neutralMultiplicity
Definition: JetTester.h:227
MonitorElement * mPtRecoOverGen_F_3500
Definition: JetTester.h:148
MonitorElement * mDeltaPhi
Definition: JetTester.h:123
MonitorElement * mPtRecoOverGen_GenEta_3500_5000
Definition: JetTester.h:162
Base class for all types of Jets.
Definition: Jet.h:20
bool isCaloJet
Definition: JetTester.h:235
edm::InputTag mJetCorrector
Definition: JetTester.h:59
MonitorElement * mPtRecoOverGen_GenPhi_E
Definition: JetTester.h:155
MonitorElement * mPtRecoOverGen_GenEta_20_40
Definition: JetTester.h:157
MonitorElement * hadEnergyInHB
Definition: JetTester.h:185
MonitorElement * mPtCorrOverReco_Eta_40_200
Definition: JetTester.h:96
MonitorElement * photonMultiplicity
Definition: JetTester.h:221
MonitorElement * mCorrJetPhi
Definition: JetTester.h:88
MonitorElement * energyFractionHadronic
Definition: JetTester.h:183
double mMatchGenPtThreshold
Definition: JetTester.h:233
MonitorElement * mPtRecoOverGen_E_40_200
Definition: JetTester.h:130
edm::EDGetTokenT< reco::JetCorrector > jetCorrectorToken_
Definition: JetTester.h:69
MonitorElement * mNJets2
Definition: JetTester.h:178
MonitorElement * mPtCorrOverReco_Eta_200_600
Definition: JetTester.h:97
MonitorElement * muonEnergyFraction
Definition: JetTester.h:214
MonitorElement * n90
Definition: JetTester.h:193
MonitorElement * mPtRecoOverGen_GenPhi_B
Definition: JetTester.h:154
MonitorElement * mEtaFirst
Definition: JetTester.h:168
MonitorElement * mPtRecoOverGen_E_5000_6500
Definition: JetTester.h:145
MonitorElement * mPtCorrOverGen_GenEta_3500_5000
Definition: JetTester.h:111
bool isRealData() const
Definition: EventBase.h:64
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
MonitorElement * emEnergyFraction
Definition: JetTester.h:184
MonitorElement * mCorrJetEta
Definition: JetTester.h:87
MonitorElement * mPtCorrOverReco_Eta_3500
Definition: JetTester.h:102
MonitorElement * photonEnergy
Definition: JetTester.h:209
MonitorElement * towersArea
Definition: JetTester.h:192
void Fill(long long x)
MonitorElement * hadEnergyInHF
Definition: JetTester.h:188
MonitorElement * HFHadronMultiplicity
Definition: JetTester.h:223
MonitorElement * mGenPt
Definition: JetTester.h:118
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
MonitorElement * muonEnergy
Definition: JetTester.h:213
MonitorElement * electronMultiplicity
Definition: JetTester.h:222
MonitorElement * mPtRecoOverGen_B_600_1500
Definition: JetTester.h:135
MonitorElement * mEnergy
Definition: JetTester.h:79
MonitorElement * mPtRecoOverGen_GenPt_E
Definition: JetTester.h:152
MonitorElement * mNJetsEta_E_40
Definition: JetTester.h:175
MonitorElement * mEta
Definition: JetTester.h:75
MonitorElement * mGenEtaFirst
Definition: JetTester.h:119
MonitorElement * mNJetsEta_B_20_40
Definition: JetTester.h:172
MonitorElement * mPtRecoOverGen_B_3500
Definition: JetTester.h:146
MonitorElement * chargedMuEnergy
Definition: JetTester.h:225
MonitorElement * mPtRecoOverGen_F_1500_3500
Definition: JetTester.h:140
MonitorElement * mDeltaEta
Definition: JetTester.h:122
MonitorElement * mNJets_40
Definition: JetTester.h:176
MonitorElement * HFHadronEnergy
Definition: JetTester.h:215
MonitorElement * mNJetsEta_E_20_40
Definition: JetTester.h:173
MonitorElement * mDeltaPt
Definition: JetTester.h:124
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * mPtRecoOverGen_B_40_200
Definition: JetTester.h:129
MonitorElement * mPtRecoOverGen_B_1500_3500
Definition: JetTester.h:138
MonitorElement * mPtRecoOverGen_F_200_600
Definition: JetTester.h:134
MonitorElement * mPhiFirst
Definition: JetTester.h:169
MonitorElement * mP
Definition: JetTester.h:78
void fillMatchHists(const double GenEta, const double GenPhi, const double GenPt, const double RecoEta, const double RecoPhi, const double RecoPt)
Definition: JetTester.cc:928
edm::EDGetTokenT< GenEventInfoProduct > evtToken_
Definition: JetTester.h:67
MonitorElement * mPtCorrOverGen_GenPt_B
Definition: JetTester.h:103
MonitorElement * mPtCorrOverReco_Eta_600_1500
Definition: JetTester.h:98
MonitorElement * n60
Definition: JetTester.h:194
MonitorElement * mPtCorrOverReco_Eta_5000_6500
Definition: JetTester.h:101
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
MonitorElement * mPtCorrOverReco_Eta_3500_5000
Definition: JetTester.h:100
MonitorElement * HOEnergyFraction
Definition: JetTester.h:229
MonitorElement * mGenEta
Definition: JetTester.h:116
MonitorElement * hadEnergyInHO
Definition: JetTester.h:186
MonitorElement * mPhi
Definition: JetTester.h:76
MonitorElement * mPtRecoOverGen_E_3500
Definition: JetTester.h:147
MonitorElement * mPtCorrOverGen_GenEta_3500
Definition: JetTester.h:113
MonitorElement * mPtCorrOverGen_GenEta_200_600
Definition: JetTester.h:108
MonitorElement * mPt
Definition: JetTester.h:77
edm::InputTag mInputCollection
Definition: JetTester.h:57
MonitorElement * emEnergyInHF
Definition: JetTester.h:191
MonitorElement * mPtRecoOverGen_E_200_600
Definition: JetTester.h:133
JetTester(const edm::ParameterSet &)
Definition: JetTester.cc:12
MonitorElement * mPtRecoOverGen_GenPhi_F
Definition: JetTester.h:156
MonitorElement * chargedHadronEnergyFraction
Definition: JetTester.h:203
MonitorElement * mPtRecoOverGen_E_600_1500
Definition: JetTester.h:136
bool isValid() const
Definition: HandleBase.h:75
MonitorElement * mPtHat
Definition: JetTester.h:121
MonitorElement * chargedHadronEnergy
Definition: JetTester.h:201
MonitorElement * mPtCorrOverReco_Pt_B
Definition: JetTester.h:92
MonitorElement * mPtRecoOverGen_GenPt_B
Definition: JetTester.h:151
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
MonitorElement * mPtCorrOverReco_Eta_1500_3500
Definition: JetTester.h:99
MonitorElement * mJetArea
Definition: JetTester.h:82
MonitorElement * mMass
Definition: JetTester.h:80
MonitorElement * HFEMMultiplicity
Definition: JetTester.h:224
MonitorElement * chargedEmEnergy
Definition: JetTester.h:199
MonitorElement * mPtRecoOverGen_GenEta_40_200
Definition: JetTester.h:158
MonitorElement * mPtRecoOverGen_E_1500_3500
Definition: JetTester.h:139
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * mPtRecoOverGen_F_600_1500
Definition: JetTester.h:137
MonitorElement * chargedMuEnergyFraction
Definition: JetTester.h:226
MonitorElement * electronEnergy
Definition: JetTester.h:211
MonitorElement * emEnergyInEE
Definition: JetTester.h:190
tuple recoJets
Definition: RecoJets_cff.py:56
MonitorElement * mPtCorrOverGen_GenEta_20_40
Definition: JetTester.h:106
double mRecoJetPtThreshold
Definition: JetTester.h:232
MonitorElement * mPtCorrOverGen_GenEta_1500_3500
Definition: JetTester.h:110
MonitorElement * mGenPhi
Definition: JetTester.h:117
MonitorElement * maxEInHadTowers
Definition: JetTester.h:182
MonitorElement * mCorrJetEta_Pt40
Definition: JetTester.h:89
std::string const & label() const
Definition: InputTag.h:43
MonitorElement * emEnergyInEB
Definition: JetTester.h:189
edm::EDGetTokenT< reco::PFJetCollection > pfJetsToken_
Definition: JetTester.h:65
MonitorElement * mConstituents
Definition: JetTester.h:81
MonitorElement * maxEInEmTowers
Definition: JetTester.h:181
MonitorElement * mPtRecoOverGen_F_20_40
Definition: JetTester.h:128
MonitorElement * mGenPhiFirst
Definition: JetTester.h:120
MonitorElement * mCorrJetPt
Definition: JetTester.h:86
MonitorElement * mPtCorrOverGen_GenPt_E
Definition: JetTester.h:104
MonitorElement * mPtRecoOverGen_GenEta_600_1500
Definition: JetTester.h:160
static int position[264][3]
Definition: ReadPGInfo.cc:509
MonitorElement * mPtRecoOverGen_GenEta_200_600
Definition: JetTester.h:159
MonitorElement * mPtCorrOverReco_Eta_20_40
Definition: JetTester.h:95
MonitorElement * chargedEmEnergyFraction
Definition: JetTester.h:205
MonitorElement * mPtCorrOverReco_Pt_F
Definition: JetTester.h:94
MonitorElement * muonMultiplicity
Definition: JetTester.h:197
MonitorElement * neutralHadronEnergyFraction
Definition: JetTester.h:204
double mRThreshold
Definition: JetTester.h:234
MonitorElement * neutralEmEnergy
Definition: JetTester.h:200
MonitorElement * chargedHadronMultiplicity
Definition: JetTester.h:219
MonitorElement * mPtRecoOverGen_B_3500_5000
Definition: JetTester.h:142
std::string JetType
Definition: JetTester.h:60
MonitorElement * mPtRecoOverGen_GenEta_1500_3500
Definition: JetTester.h:161
MonitorElement * mNJets1
Definition: JetTester.h:177
MonitorElement * mPtCorrOverGen_GenEta_600_1500
Definition: JetTester.h:109
MonitorElement * chargedMultiplicity
Definition: JetTester.h:198
tuple pfJets
Definition: pfJets_cff.py:8
virtual double phi() const
momentum azimuthal angle
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: JetTester.cc:456
MonitorElement * HFEMEnergy
Definition: JetTester.h:217
MonitorElement * mCorrJetPhi_Pt40
Definition: JetTester.h:90
MonitorElement * neutralHadronMultiplicity
Definition: JetTester.h:220
Definition: Run.h:43
MonitorElement * neutralEmEnergyFraction
Definition: JetTester.h:206
MonitorElement * mPtRecoOverGen_GenEta_5000_6500
Definition: JetTester.h:163
MonitorElement * mPtCorrOverGen_GenEta_5000_6500
Definition: JetTester.h:112