Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:40

0001 // Producer for validation histograms for Calo, JPT and PF jet objects
0002 // F. Ratnikov, Sept. 7, 2006
0003 // Modified by Chiyoung Jeong, Feb. 2, 2010
0004 // Modified by J. Piedra, Sept. 11, 2013
0005 
0006 #include "JetTester.h"
0007 
0008 using namespace edm;
0009 using namespace reco;
0010 using namespace std;
0011 
0012 JetTester::JetTester(const edm::ParameterSet &iConfig)
0013     : mInputCollection(iConfig.getParameter<edm::InputTag>("src")),
0014       //  rhoTag                         (iConfig.getParameter<edm::InputTag>
0015       //  ("srcRho")),
0016       JetType(iConfig.getUntrackedParameter<std::string>("JetType")),
0017       mRecoJetPtThreshold(iConfig.getParameter<double>("recoJetPtThreshold")),
0018       mMatchGenPtThreshold(iConfig.getParameter<double>("matchGenPtThreshold")),
0019       mRThreshold(iConfig.getParameter<double>("RThreshold")) {
0020   std::string inputCollectionLabel(mInputCollection.label());
0021 
0022   isCaloJet = (std::string("calo") == JetType);
0023   isPFJet = (std::string("pf") == JetType);
0024   isMiniAODJet = (std::string("miniaod") == JetType);
0025   if (!isMiniAODJet) {
0026     mJetCorrector = iConfig.getParameter<edm::InputTag>("JetCorrections");
0027   }
0028 
0029   // consumes
0030   pvToken_ = consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("primVertex"));
0031   if (isCaloJet)
0032     caloJetsToken_ = consumes<reco::CaloJetCollection>(mInputCollection);
0033   if (isPFJet)
0034     pfJetsToken_ = consumes<reco::PFJetCollection>(mInputCollection);
0035   if (isMiniAODJet)
0036     patJetsToken_ = consumes<pat::JetCollection>(mInputCollection);
0037   mInputGenCollection = iConfig.getParameter<edm::InputTag>("srcGen");
0038   genJetsToken_ = consumes<reco::GenJetCollection>(edm::InputTag(mInputGenCollection));
0039   evtToken_ = consumes<GenEventInfoProduct>(edm::InputTag("generator"));
0040   if (!isMiniAODJet && !mJetCorrector.label().empty()) {
0041     jetCorrectorToken_ = consumes<reco::JetCorrector>(mJetCorrector);
0042   }
0043 
0044   // Events variables
0045   mNvtx = nullptr;
0046 
0047   // Jet parameters
0048   mEta = nullptr;
0049   mPhi = nullptr;
0050   mEnergy = nullptr;
0051   mP = nullptr;
0052   mPt = nullptr;
0053   mMass = nullptr;
0054   mConstituents = nullptr;
0055   mJetArea = nullptr;
0056   //  mRho          = 0;
0057 
0058   // Corrected jets
0059   mCorrJetPt = nullptr;
0060   mCorrJetEta = nullptr;
0061   mCorrJetPhi = nullptr;
0062   mCorrJetEta_Pt40 = nullptr;
0063   mCorrJetPhi_Pt40 = nullptr;
0064 
0065   // Corrected jets profiles
0066   mPtCorrOverReco_Pt_B = nullptr;
0067   mPtCorrOverReco_Pt_E = nullptr;
0068   mPtCorrOverReco_Pt_F = nullptr;
0069   mPtCorrOverReco_Eta_20_40 = nullptr;
0070   mPtCorrOverReco_Eta_40_200 = nullptr;
0071   mPtCorrOverReco_Eta_200_600 = nullptr;
0072   mPtCorrOverReco_Eta_600_1500 = nullptr;
0073   mPtCorrOverReco_Eta_1500_3500 = nullptr;
0074   mPtCorrOverReco_Eta_3500_5000 = nullptr;
0075   mPtCorrOverReco_Eta_5000_6500 = nullptr;
0076   mPtCorrOverReco_Eta_3500 = nullptr;
0077   mPtCorrOverGen_GenPt_B = nullptr;
0078   mPtCorrOverGen_GenPt_E = nullptr;
0079   mPtCorrOverGen_GenPt_F = nullptr;
0080   mPtCorrOverGen_GenEta_20_40 = nullptr;
0081   mPtCorrOverGen_GenEta_40_200 = nullptr;
0082   mPtCorrOverGen_GenEta_200_600 = nullptr;
0083   mPtCorrOverGen_GenEta_600_1500 = nullptr;
0084   mPtCorrOverGen_GenEta_1500_3500 = nullptr;
0085   mPtCorrOverGen_GenEta_3500_5000 = nullptr;
0086   mPtCorrOverGen_GenEta_5000_6500 = nullptr;
0087   mPtCorrOverGen_GenEta_3500 = nullptr;
0088 
0089   // Generation
0090   mGenEta = nullptr;
0091   mGenPhi = nullptr;
0092   mGenPt = nullptr;
0093   mGenEtaFirst = nullptr;
0094   mGenPhiFirst = nullptr;
0095   mPtHat = nullptr;
0096   mDeltaEta = nullptr;
0097   mDeltaPhi = nullptr;
0098   mDeltaPt = nullptr;
0099 
0100   mPtRecoOverGen_B_20_40 = nullptr;
0101   mPtRecoOverGen_E_20_40 = nullptr;
0102   mPtRecoOverGen_F_20_40 = nullptr;
0103   mPtRecoOverGen_B_40_200 = nullptr;
0104   mPtRecoOverGen_E_40_200 = nullptr;
0105   mPtRecoOverGen_F_40_200 = nullptr;
0106   mPtRecoOverGen_B_200_600 = nullptr;
0107   mPtRecoOverGen_E_200_600 = nullptr;
0108   mPtRecoOverGen_F_200_600 = nullptr;
0109   mPtRecoOverGen_B_600_1500 = nullptr;
0110   mPtRecoOverGen_E_600_1500 = nullptr;
0111   mPtRecoOverGen_F_600_1500 = nullptr;
0112   mPtRecoOverGen_B_1500_3500 = nullptr;
0113   mPtRecoOverGen_E_1500_3500 = nullptr;
0114   mPtRecoOverGen_F_1500_3500 = nullptr;
0115   mPtRecoOverGen_B_3500_5000 = nullptr;
0116   mPtRecoOverGen_E_3500_5000 = nullptr;
0117   mPtRecoOverGen_B_5000_6500 = nullptr;
0118   mPtRecoOverGen_E_5000_6500 = nullptr;
0119   mPtRecoOverGen_B_3500 = nullptr;
0120   mPtRecoOverGen_E_3500 = nullptr;
0121   mPtRecoOverGen_F_3500 = nullptr;
0122 
0123   // Generation profiles
0124   mPtRecoOverGen_GenPt_B = nullptr;
0125   mPtRecoOverGen_GenPt_E = nullptr;
0126   mPtRecoOverGen_GenPt_F = nullptr;
0127   mPtRecoOverGen_GenPhi_B = nullptr;
0128   mPtRecoOverGen_GenPhi_E = nullptr;
0129   mPtRecoOverGen_GenPhi_F = nullptr;
0130   mPtRecoOverGen_GenEta_20_40 = nullptr;
0131   mPtRecoOverGen_GenEta_40_200 = nullptr;
0132   mPtRecoOverGen_GenEta_200_600 = nullptr;
0133   mPtRecoOverGen_GenEta_600_1500 = nullptr;
0134   mPtRecoOverGen_GenEta_1500_3500 = nullptr;
0135   mPtRecoOverGen_GenEta_3500_5000 = nullptr;
0136   mPtRecoOverGen_GenEta_5000_6500 = nullptr;
0137   mPtRecoOverGen_GenEta_3500 = nullptr;
0138 
0139   // Some jet algebra
0140   mEtaFirst = nullptr;
0141   mPhiFirst = nullptr;
0142   mPtFirst = nullptr;
0143   mMjj = nullptr;
0144   mNJetsEta_B_20_40 = nullptr;
0145   mNJetsEta_E_20_40 = nullptr;
0146   mNJetsEta_B_40 = nullptr;
0147   mNJetsEta_E_40 = nullptr;
0148   mNJets1 = nullptr;
0149   mNJets2 = nullptr;
0150 
0151   //  // PFJet specific
0152   //  mHadEnergyInHF       = 0;
0153   //  mEmEnergyInHF        = 0;
0154   //  mChargedEmEnergy     = 0;
0155   //  mChargedHadronEnergy = 0;
0156   //  mNeutralEmEnergy     = 0;
0157   //  mNeutralHadronEnergy = 0;
0158 
0159   // ---- Calo Jet specific information ----
0160   /// returns the maximum energy deposited in ECAL towers
0161   maxEInEmTowers = nullptr;
0162   /// returns the maximum energy deposited in HCAL towers
0163   maxEInHadTowers = nullptr;
0164   /// returns the jet hadronic energy fraction
0165   energyFractionHadronic = nullptr;
0166   /// returns the jet electromagnetic energy fraction
0167   emEnergyFraction = nullptr;
0168   /// returns the jet hadronic energy in HB
0169   hadEnergyInHB = nullptr;
0170   /// returns the jet hadronic energy in HO
0171   hadEnergyInHO = nullptr;
0172   /// returns the jet hadronic energy in HE
0173   hadEnergyInHE = nullptr;
0174   /// returns the jet hadronic energy in HF
0175   hadEnergyInHF = nullptr;
0176   /// returns the jet electromagnetic energy in EB
0177   emEnergyInEB = nullptr;
0178   /// returns the jet electromagnetic energy in EE
0179   emEnergyInEE = nullptr;
0180   /// returns the jet electromagnetic energy extracted from HF
0181   emEnergyInHF = nullptr;
0182   /// returns area of contributing towers
0183   towersArea = nullptr;
0184   /// returns the number of constituents carrying a 90% of the total Jet
0185   /// energy*/
0186   n90 = nullptr;
0187   /// returns the number of constituents carrying a 60% of the total Jet
0188   /// energy*/
0189   n60 = nullptr;
0190 
0191   // ---- JPT Jet specific information ----
0192   /// chargedMultiplicity
0193   //  elecMultiplicity = 0;
0194 
0195   // ---- JPT or PF Jet specific information ----
0196   /// muonMultiplicity
0197   muonMultiplicity = nullptr;
0198   /// chargedMultiplicity
0199   chargedMultiplicity = nullptr;
0200   /// chargedEmEnergy
0201   chargedEmEnergy = nullptr;
0202   /// neutralEmEnergy
0203   neutralEmEnergy = nullptr;
0204   /// chargedHadronEnergy
0205   chargedHadronEnergy = nullptr;
0206   /// neutralHadronEnergy
0207   neutralHadronEnergy = nullptr;
0208   /// chargedHadronEnergyFraction (relative to uncorrected jet energy)
0209   chargedHadronEnergyFraction = nullptr;
0210   /// neutralHadronEnergyFraction (relative to uncorrected jet energy)
0211   neutralHadronEnergyFraction = nullptr;
0212   /// chargedEmEnergyFraction (relative to uncorrected jet energy)
0213   chargedEmEnergyFraction = nullptr;
0214   /// neutralEmEnergyFraction (relative to uncorrected jet energy)
0215   neutralEmEnergyFraction = nullptr;
0216 
0217   // ---- PF Jet specific information ----
0218   /// photonEnergy
0219   photonEnergy = nullptr;
0220   /// photonEnergyFraction (relative to corrected jet energy)
0221   photonEnergyFraction = nullptr;
0222   /// electronEnergy
0223   electronEnergy = nullptr;
0224   /// electronEnergyFraction (relative to corrected jet energy)
0225   electronEnergyFraction = nullptr;
0226   /// muonEnergy
0227   muonEnergy = nullptr;
0228   /// muonEnergyFraction (relative to corrected jet energy)
0229   muonEnergyFraction = nullptr;
0230   /// HFHadronEnergy
0231   HFHadronEnergy = nullptr;
0232   /// HFHadronEnergyFraction (relative to corrected jet energy)
0233   HFHadronEnergyFraction = nullptr;
0234   /// HFEMEnergy
0235   HFEMEnergy = nullptr;
0236   /// HFEMEnergyFraction (relative to corrected jet energy)
0237   HFEMEnergyFraction = nullptr;
0238   /// chargedHadronMultiplicity
0239   chargedHadronMultiplicity = nullptr;
0240   /// neutralHadronMultiplicity
0241   neutralHadronMultiplicity = nullptr;
0242   /// photonMultiplicity
0243   photonMultiplicity = nullptr;
0244   /// electronMultiplicity
0245   electronMultiplicity = nullptr;
0246   /// HFHadronMultiplicity
0247   HFHadronMultiplicity = nullptr;
0248   /// HFEMMultiplicity
0249   HFEMMultiplicity = nullptr;
0250   /// chargedMuEnergy
0251   chargedMuEnergy = nullptr;
0252   /// chargedMuEnergyFraction
0253   chargedMuEnergyFraction = nullptr;
0254   /// neutralMultiplicity
0255   neutralMultiplicity = nullptr;
0256 
0257   /// HOEnergy
0258   HOEnergy = nullptr;
0259   /// HOEnergyFraction (relative to corrected jet energy)
0260   HOEnergyFraction = nullptr;
0261 
0262   hadronFlavor = nullptr;
0263   partonFlavor = nullptr;
0264   genPartonPDGID = nullptr;
0265 }
0266 
0267 void JetTester::bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &) {
0268   ibooker.setCurrentFolder("JetMET/JetValidation/" + mInputCollection.label());
0269 
0270   double log10PtMin = 0.50;
0271   double log10PtMax = 3.75;
0272   int log10PtBins = 26;
0273 
0274   // if eta range changed here need change in JetTesterPostProcessor as well
0275   double etaRange[91] = {-6.0, -5.8, -5.6, -5.4, -5.2, -5.0, -4.8, -4.6, -4.4, -4.2, -4.0, -3.8, -3.6, -3.4, -3.2, -3.0,
0276                          -2.9, -2.8, -2.7, -2.6, -2.5, -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4,
0277                          -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.0,  0.1,  0.2,
0278                          0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9,  1.0,  1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8,
0279                          1.9,  2.0,  2.1,  2.2,  2.3,  2.4,  2.5,  2.6,  2.7,  2.8,  2.9,  3.0,  3.2,  3.4,  3.6,  3.8,
0280                          4.0,  4.2,  4.4,  4.6,  4.8,  5.0,  5.2,  5.4,  5.6,  5.8,  6.0};
0281 
0282   // Event variables
0283   mNvtx = ibooker.book1D("Nvtx", "number of vertices", 60, 0, 60);
0284 
0285   // Jet parameters
0286   mEta = ibooker.book1D("Eta", "Eta", 120, -6, 6);
0287   mPhi = ibooker.book1D("Phi", "Phi", 70, -3.5, 3.5);
0288   mPt = ibooker.book1D("Pt", "Pt", 100, 0, 1000);
0289   mP = ibooker.book1D("P", "P", 100, 0, 1000);
0290   mEnergy = ibooker.book1D("Energy", "Energy", 100, 0, 1000);
0291   mMass = ibooker.book1D("Mass", "Mass", 100, 0, 200);
0292   mConstituents = ibooker.book1D("Constituents", "Constituents", 100, 0, 100);
0293   mJetArea = ibooker.book1D("JetArea", "JetArea", 100, 0, 4);
0294   // jet flavors contained in MiniAOD
0295   if (isMiniAODJet) {
0296     hadronFlavor = ibooker.book1D("HadronFlavor", "HadronFlavor", 44, -22, 22);
0297     partonFlavor = ibooker.book1D("PartonFlavor", "PartonFlavor", 44, -22, 22);
0298     genPartonPDGID = ibooker.book1D("genPartonPDGID", "genPartonPDGID", 44, -22, 22);
0299   }
0300   // Corrected jets
0301   if (isMiniAODJet || !mJetCorrector.label().empty()) {  // if correction label is filled, but
0302                                                          // fill also for MiniAOD though
0303     mCorrJetPt = ibooker.book1D("CorrJetPt", "CorrJetPt", 150, 0, 1500);
0304     mCorrJetEta = ibooker.book1D("CorrJetEta", "CorrJetEta Pt>20", 60, -6, 6);
0305     mCorrJetPhi = ibooker.book1D("CorrJetPhi", "CorrJetPhi Pt>20", 70, -3.5, 3.5);
0306     mCorrJetEta_Pt40 = ibooker.book1D("CorrJetEta_Pt40", "CorrJetEta Pt>40", 60, -6, 6);
0307     mCorrJetPhi_Pt40 = ibooker.book1D("CorrJetPhi_Pt40", "CorrJetPhi Pt>40", 70, -3.5, 3.5);
0308 
0309     // Corrected jets profiles
0310     mPtCorrOverReco_Pt_B =
0311         ibooker.bookProfile("PtCorrOverReco_Pt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
0312     mPtCorrOverReco_Pt_E =
0313         ibooker.bookProfile("PtCorrOverReco_Pt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
0314     mPtCorrOverReco_Pt_F =
0315         ibooker.bookProfile("PtCorrOverReco_Pt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
0316 
0317     mPtCorrOverReco_Eta_20_40 = ibooker.bookProfile("PtCorrOverReco_Eta_20_40", "20<genPt<40", 90, etaRange, 0, 5, " ");
0318     mPtCorrOverReco_Eta_40_200 =
0319         ibooker.bookProfile("PtCorrOverReco_Eta_40_200", "40<genPt<200", 90, etaRange, 0, 5, " ");
0320     mPtCorrOverReco_Eta_200_600 =
0321         ibooker.bookProfile("PtCorrOverReco_Eta_200_600", "200<genPt<600", 90, etaRange, 0, 5, " ");
0322     mPtCorrOverReco_Eta_600_1500 =
0323         ibooker.bookProfile("PtCorrOverReco_Eta_600_1500", "600<genPt<1500", 90, etaRange, 0, 5, " ");
0324     mPtCorrOverReco_Eta_1500_3500 =
0325         ibooker.bookProfile("PtCorrOverReco_Eta_1500_3500", "1500<genPt<3500", 90, etaRange, 0, 5, " ");
0326     mPtCorrOverReco_Eta_3500_5000 =
0327         ibooker.bookProfile("PtCorrOverReco_Eta_3500_5000", "3500<genPt<5000", 90, etaRange, 0, 5, " ");
0328     mPtCorrOverReco_Eta_5000_6500 =
0329         ibooker.bookProfile("PtCorrOverReco_Eta_5000_6500", "5000<genPt<6500", 90, etaRange, 0, 5, " ");
0330     mPtCorrOverReco_Eta_3500 = ibooker.bookProfile("PtCorrOverReco_Eta_3500", "genPt>3500", 90, etaRange, 0, 5, " ");
0331 
0332     mPtCorrOverGen_GenPt_B =
0333         ibooker.bookProfile("PtCorrOverGen_GenPt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
0334     mPtCorrOverGen_GenPt_E =
0335         ibooker.bookProfile("PtCorrOverGen_GenPt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
0336     mPtCorrOverGen_GenPt_F =
0337         ibooker.bookProfile("PtCorrOverGen_GenPt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
0338     // if eta range changed here need change in JetTesterPostProcessor as well
0339     mPtCorrOverGen_GenEta_20_40 =
0340         ibooker.bookProfile("PtCorrOverGen_GenEta_20_40", "20<genPt<40;#eta", 90, etaRange, 0.8, 1.2, " ");
0341     mPtCorrOverGen_GenEta_40_200 =
0342         ibooker.bookProfile("PtCorrOverGen_GenEta_40_200", "40<genPt<200;#eta", 90, etaRange, 0.8, 1.2, " ");
0343     mPtCorrOverGen_GenEta_200_600 =
0344         ibooker.bookProfile("PtCorrOverGen_GenEta_200_600", "200<genPt<600;#eta", 90, etaRange, 0.8, 1.2, " ");
0345     mPtCorrOverGen_GenEta_600_1500 =
0346         ibooker.bookProfile("PtCorrOverGen_GenEta_600_1500", "600<genPt<1500;#eta", 90, etaRange, 0.8, 1.2, " ");
0347     mPtCorrOverGen_GenEta_1500_3500 =
0348         ibooker.bookProfile("PtCorrOverGen_GenEta_1500_3500", "1500<genPt<3500;#eta", 90, etaRange, 0.8, 1.2, " ");
0349     mPtCorrOverGen_GenEta_3500_5000 =
0350         ibooker.bookProfile("PtCorrOverGen_GenEta_3500_5000", "3500<genPt<5000;#eta", 90, etaRange, 0.8, 1.2, " ");
0351     mPtCorrOverGen_GenEta_5000_6500 =
0352         ibooker.bookProfile("PtCorrOverGen_GenEta_5000_6500", "5000<genPt<6500;#eta", 90, etaRange, 0.8, 1.2, " ");
0353     mPtCorrOverGen_GenEta_3500 =
0354         ibooker.bookProfile("PtCorrOverGen_GenEta_3500", "genPt>3500;#eta", 90, etaRange, 0.8, 1.2, " ");
0355   }
0356 
0357   mGenEta = ibooker.book1D("GenEta", "GenEta", 120, -6, 6);
0358   mGenPhi = ibooker.book1D("GenPhi", "GenPhi", 70, -3.5, 3.5);
0359   mGenPt = ibooker.book1D("GenPt", "GenPt", 100, 0, 1000);
0360   mGenEtaFirst = ibooker.book1D("GenEtaFirst", "GenEtaFirst", 120, -6, 6);
0361   mGenPhiFirst = ibooker.book1D("GenPhiFirst", "GenPhiFirst", 70, -3.5, 3.5);
0362   mPtHat = ibooker.book1D("PtHat", "PtHat", 100, 0, 1000);
0363   mDeltaEta = ibooker.book1D("DeltaEta", "DeltaEta", 100, -0.5, 0.5);
0364   mDeltaPhi = ibooker.book1D("DeltaPhi", "DeltaPhi", 100, -0.5, 0.5);
0365   mDeltaPt = ibooker.book1D("DeltaPt", "DeltaPt", 100, -1.0, 1.0);
0366 
0367   mPtRecoOverGen_B_20_40 = ibooker.book1D("PtRecoOverGen_B_20_40", "20<genpt<40", 90, 0, 2);
0368   mPtRecoOverGen_E_20_40 = ibooker.book1D("PtRecoOverGen_E_20_40", "20<genpt<40", 90, 0, 2);
0369   mPtRecoOverGen_F_20_40 = ibooker.book1D("PtRecoOverGen_F_20_40", "20<genpt<40", 90, 0, 2);
0370   mPtRecoOverGen_B_40_200 = ibooker.book1D("PtRecoOverGen_B_40_200", "40<genpt<200", 90, 0, 2);
0371   mPtRecoOverGen_E_40_200 = ibooker.book1D("PtRecoOverGen_E_40_200", "40<genpt<200", 90, 0, 2);
0372   mPtRecoOverGen_F_40_200 = ibooker.book1D("PtRecoOverGen_F_40_200", "40<genpt<200", 90, 0, 2);
0373   mPtRecoOverGen_B_200_600 = ibooker.book1D("PtRecoOverGen_B_200_600", "200<genpt<600", 90, 0, 2);
0374   mPtRecoOverGen_E_200_600 = ibooker.book1D("PtRecoOverGen_E_200_600", "200<genpt<600", 90, 0, 2);
0375   mPtRecoOverGen_F_200_600 = ibooker.book1D("PtRecoOverGen_F_200_600", "200<genpt<600", 90, 0, 2);
0376   mPtRecoOverGen_B_600_1500 = ibooker.book1D("PtRecoOverGen_B_600_1500", "600<genpt<1500", 90, 0, 2);
0377   mPtRecoOverGen_E_600_1500 = ibooker.book1D("PtRecoOverGen_E_600_1500", "600<genpt<1500", 90, 0, 2);
0378   mPtRecoOverGen_F_600_1500 = ibooker.book1D("PtRecoOverGen_F_600_1500", "600<genpt<1500", 90, 0, 2);
0379   mPtRecoOverGen_B_1500_3500 = ibooker.book1D("PtRecoOverGen_B_1500_3500", "1500<genpt<3500", 90, 0, 2);
0380   mPtRecoOverGen_E_1500_3500 = ibooker.book1D("PtRecoOverGen_E_1500_3500", "1500<genpt<3500", 90, 0, 2);
0381   mPtRecoOverGen_F_1500_3500 = ibooker.book1D("PtRecoOverGen_F_1500_3500", "1500<genpt<3500", 90, 0, 2);
0382   mPtRecoOverGen_B_3500_5000 = ibooker.book1D("PtRecoOverGen_B_3500_5000", "3500<genpt<5000", 90, 0, 2);
0383   mPtRecoOverGen_E_3500_5000 = ibooker.book1D("PtRecoOverGen_E_3500_5000", "3500<genpt<5000", 90, 0, 2);
0384   mPtRecoOverGen_B_5000_6500 = ibooker.book1D("PtRecoOverGen_B_5000_6500", "5000<genpt<6500", 90, 0, 2);
0385   mPtRecoOverGen_E_5000_6500 = ibooker.book1D("PtRecoOverGen_E_5000_6500", "5000<genpt<6500", 90, 0, 2);
0386   mPtRecoOverGen_B_3500 = ibooker.book1D("PtRecoOverGen_B_3500", "genpt>3500", 90, 0, 2);
0387   mPtRecoOverGen_E_3500 = ibooker.book1D("PtRecoOverGen_E_3500", "genpt>3500", 90, 0, 2);
0388   mPtRecoOverGen_F_3500 = ibooker.book1D("PtRecoOverGen_F_3500", "genpt>3500", 90, 0, 2);
0389 
0390   mMassRecoOverGen_B_20_40 = ibooker.book1D("MassRecoOverGen_B_20_40", "20<genpt<40", 90, 0, 3);
0391   mMassRecoOverGen_E_20_40 = ibooker.book1D("MassRecoOverGen_E_20_40", "20<genpt<40", 90, 0, 3);
0392   mMassRecoOverGen_F_20_40 = ibooker.book1D("MassRecoOverGen_F_20_40", "20<genpt<40", 90, 0, 3);
0393   mMassRecoOverGen_B_40_200 = ibooker.book1D("MassRecoOverGen_B_40_200", "40<genpt<200", 90, 0, 3);
0394   mMassRecoOverGen_E_40_200 = ibooker.book1D("MassRecoOverGen_E_40_200", "40<genpt<200", 90, 0, 3);
0395   mMassRecoOverGen_F_40_200 = ibooker.book1D("MassRecoOverGen_F_40_200", "40<genpt<200", 90, 0, 3);
0396   mMassRecoOverGen_B_200_500 = ibooker.book1D("MassRecoOverGen_B_200_500", "200<genpt<500", 90, 0, 3);
0397   mMassRecoOverGen_E_200_500 = ibooker.book1D("MassRecoOverGen_E_200_500", "200<genpt<500", 90, 0, 3);
0398   mMassRecoOverGen_F_200_500 = ibooker.book1D("MassRecoOverGen_F_200_500", "200<genpt<500", 90, 0, 3);
0399   mMassRecoOverGen_B_500_750 = ibooker.book1D("MassRecoOverGen_B_500_750", "500<genpt<750", 90, 0, 3);
0400   mMassRecoOverGen_E_500_750 = ibooker.book1D("MassRecoOverGen_E_500_750", "500<genpt<750", 90, 0, 3);
0401   mMassRecoOverGen_F_500_750 = ibooker.book1D("MassRecoOverGen_F_500_750", "500<genpt<750", 90, 0, 3);
0402   mMassRecoOverGen_B_750_1000 = ibooker.book1D("MassRecoOverGen_B_750_1000", "750<genpt<1000", 90, 0, 3);
0403   mMassRecoOverGen_E_750_1000 = ibooker.book1D("MassRecoOverGen_E_750_1000", "750<genpt<1000", 90, 0, 3);
0404   mMassRecoOverGen_F_750_1000 = ibooker.book1D("MassRecoOverGen_F_750_1000", "750<genpt<1000", 90, 0, 3);
0405   mMassRecoOverGen_B_1000_1500 = ibooker.book1D("MassRecoOverGen_B_1000_1500", "1000<genpt<1500", 90, 0, 3);
0406   mMassRecoOverGen_E_1000_1500 = ibooker.book1D("MassRecoOverGen_E_1000_1500", "1000<genpt<1500", 90, 0, 3);
0407   mMassRecoOverGen_F_1000_1500 = ibooker.book1D("MassRecoOverGen_F_1000_1500", "1000<genpt<1500", 90, 0, 3);
0408   mMassRecoOverGen_B_1500_3500 = ibooker.book1D("MassRecoOverGen_B_1500_3500", "1500<genpt<3500", 90, 0, 3);
0409   mMassRecoOverGen_E_1500_3500 = ibooker.book1D("MassRecoOverGen_E_1500_3500", "1500<genpt<3500", 90, 0, 3);
0410   mMassRecoOverGen_F_1500 = ibooker.book1D("MassRecoOverGen_F_1500", "genpt>1500", 90, 0, 3);
0411   mMassRecoOverGen_B_3500_5000 = ibooker.book1D("MassRecoOverGen_B_3500_5000", "3500<genpt<5000", 90, 0, 3);
0412   mMassRecoOverGen_E_3500_5000 = ibooker.book1D("MassRecoOverGen_E_3500_5000", "3500<genpt<5000", 90, 0, 3);
0413   mMassRecoOverGen_B_5000 = ibooker.book1D("MassRecoOverGen_B_5000", "genpt>5000", 90, 0, 3);
0414   mMassRecoOverGen_E_5000 = ibooker.book1D("MassRecoOverGen_E_5000", "genpt>5000", 90, 0, 3);
0415 
0416   // Generation profiles
0417   mPtRecoOverGen_GenPt_B =
0418       ibooker.bookProfile("PtRecoOverGen_GenPt_B", "0<|eta|<1.5", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
0419   mPtRecoOverGen_GenPt_E =
0420       ibooker.bookProfile("PtRecoOverGen_GenPt_E", "1.5<|eta|<3", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
0421   mPtRecoOverGen_GenPt_F =
0422       ibooker.bookProfile("PtRecoOverGen_GenPt_F", "3<|eta|<6", log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
0423   mPtRecoOverGen_GenPhi_B = ibooker.bookProfile("PtRecoOverGen_GenPhi_B", "0<|eta|<1.5", 70, -3.5, 3.5, 0, 2, " ");
0424   mPtRecoOverGen_GenPhi_E = ibooker.bookProfile("PtRecoOverGen_GenPhi_E", "1.5<|eta|<3", 70, -3.5, 3.5, 0, 2, " ");
0425   mPtRecoOverGen_GenPhi_F = ibooker.bookProfile("PtRecoOverGen_GenPhi_F", "3<|eta|<6", 70, -3.5, 3.5, 0, 2, " ");
0426   // if eta range changed here need change in JetTesterPostProcessor as well
0427   mPtRecoOverGen_GenEta_20_40 =
0428       ibooker.bookProfile("PtRecoOverGen_GenEta_20_40", "20<genpt<40", 90, etaRange, 0, 2, " ");
0429   mPtRecoOverGen_GenEta_40_200 =
0430       ibooker.bookProfile("PtRecoOverGen_GenEta_40_200", "40<genpt<200", 90, etaRange, 0, 2, " ");
0431   mPtRecoOverGen_GenEta_200_600 =
0432       ibooker.bookProfile("PtRecoOverGen_GenEta_200_600", "200<genpt<600", 90, etaRange, 0, 2, " ");
0433   mPtRecoOverGen_GenEta_600_1500 =
0434       ibooker.bookProfile("PtRecoOverGen_GenEta_600_1500", "600<genpt<1500", 90, etaRange, 0, 2, " ");
0435   mPtRecoOverGen_GenEta_1500_3500 =
0436       ibooker.bookProfile("PtRecoOverGen_GenEta_1500_3500", "1500<genpt<3500", 90, etaRange, 0, 2, " ");
0437   mPtRecoOverGen_GenEta_3500_5000 =
0438       ibooker.bookProfile("PtRecoOverGen_GenEta_3500_5000", "3500<genpt<5000", 90, etaRange, 0, 2, " ");
0439   mPtRecoOverGen_GenEta_5000_6500 =
0440       ibooker.bookProfile("PtRecoOverGen_GenEta_5000_6500", "5000<genpt<6500", 90, etaRange, 0, 2, " ");
0441   mPtRecoOverGen_GenEta_3500 = ibooker.bookProfile("PtRecoOverGen_GenEta_3500", "genpt>3500", 90, etaRange, 0, 2, " ");
0442 
0443   // Some jet algebra
0444   //------------------------------------------------------------------------
0445   mEtaFirst = ibooker.book1D("EtaFirst", "EtaFirst", 120, -6, 6);
0446   mPhiFirst = ibooker.book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);
0447   mPtFirst = ibooker.book1D("PtFirst", "PtFirst", 50, 0, 1000);
0448   mMjj = ibooker.book1D("Mjj", "Mjj", 100, 0, 2000);
0449   mNJetsEta_B_20_40 = ibooker.book1D("NJetsEta_B_20_40", "NJetsEta_B 20<Pt<40", 15, 0, 15);
0450   mNJetsEta_E_20_40 = ibooker.book1D("NJetsEta_E_20_40", "NJetsEta_E 20<Pt<40", 15, 0, 15);
0451   mNJetsEta_B_40 = ibooker.book1D("NJetsEta_B", "NJetsEta_B 40<Pt", 15, 0, 15);
0452   mNJetsEta_E_40 = ibooker.book1D("NJetsEta_E", "NJetsEta_E 40<Pt", 15, 0, 15);
0453   mNJets_40 = ibooker.book1D("NJets", "NJets 40>Pt", 15, 0, 15);
0454   mNJets1 = ibooker.bookProfile("NJets1", "Number of jets above Pt threshold", 100, 0, 200, 100, 0, 50, "s");
0455   mNJets2 = ibooker.bookProfile("NJets2", "Number of jets above Pt threshold", 100, 0, 4000, 100, 0, 50, "s");
0456 
0457   if (isCaloJet) {
0458     maxEInEmTowers = ibooker.book1D("maxEInEmTowers", "maxEInEmTowers", 50, 0, 500);
0459     maxEInHadTowers = ibooker.book1D("maxEInHadTowers", "maxEInHadTowers", 50, 0, 500);
0460     energyFractionHadronic = ibooker.book1D("energyFractionHadronic", "energyFractionHadronic", 50, 0, 1);
0461     emEnergyFraction = ibooker.book1D("emEnergyFraction", "emEnergyFraction", 50, 0, 1);
0462     hadEnergyInHB = ibooker.book1D("hadEnergyInHB", "hadEnergyInHB", 50, 0, 500);
0463     hadEnergyInHO = ibooker.book1D("hadEnergyInHO", "hadEnergyInHO", 50, 0, 500);
0464     hadEnergyInHE = ibooker.book1D("hadEnergyInHE", "hadEnergyInHE", 50, 0, 500);
0465     hadEnergyInHF = ibooker.book1D("hadEnergyInHF", "hadEnergyInHF", 50, 0, 500);
0466     emEnergyInEB = ibooker.book1D("emEnergyInEB", "emEnergyInEB", 50, 0, 500);
0467     emEnergyInEE = ibooker.book1D("emEnergyInEE", "emEnergyInEE", 50, 0, 500);
0468     emEnergyInHF = ibooker.book1D("emEnergyInHF", "emEnergyInHF", 50, 0, 500);
0469     towersArea = ibooker.book1D("towersArea", "towersArea", 50, 0, 1);
0470     n90 = ibooker.book1D("n90", "n90", 30, 0, 30);
0471     n60 = ibooker.book1D("n60", "n60", 30, 0, 30);
0472   }
0473 
0474   if (isPFJet || isMiniAODJet) {
0475     muonMultiplicity = ibooker.book1D("muonMultiplicity", "muonMultiplicity", 10, 0, 10);
0476     chargedMultiplicity = ibooker.book1D("chargedMultiplicity", "chargedMultiplicity", 100, 0, 100);
0477     chargedEmEnergy = ibooker.book1D("chargedEmEnergy", "chargedEmEnergy", 100, 0, 500);
0478     neutralEmEnergy = ibooker.book1D("neutralEmEnergy", "neutralEmEnergy", 100, 0, 500);
0479     chargedHadronEnergy = ibooker.book1D("chargedHadronEnergy", "chargedHadronEnergy", 100, 0, 500);
0480     neutralHadronEnergy = ibooker.book1D("neutralHadronEnergy", "neutralHadronEnergy", 100, 0, 500);
0481     chargedHadronEnergyFraction =
0482         ibooker.book1D("chargedHadronEnergyFraction", "chargedHadronEnergyFraction", 50, 0, 1);
0483     neutralHadronEnergyFraction =
0484         ibooker.book1D("neutralHadronEnergyFraction", "neutralHadronEnergyFraction", 50, 0, 1);
0485     chargedEmEnergyFraction = ibooker.book1D("chargedEmEnergyFraction", "chargedEmEnergyFraction", 50, 0, 1);
0486     neutralEmEnergyFraction = ibooker.book1D("neutralEmEnergyFraction", "neutralEmEnergyFraction", 50, 0, 1);
0487     photonEnergy = ibooker.book1D("photonEnergy", "photonEnergy", 50, 0, 500);
0488     photonEnergyFraction = ibooker.book1D("photonEnergyFraction", "photonEnergyFraction", 50, 0, 1);
0489     electronEnergy = ibooker.book1D("electronEnergy", "electronEnergy", 50, 0, 500);
0490     electronEnergyFraction = ibooker.book1D("electronEnergyFraction", "electronEnergyFraction", 50, 0, 1);
0491     muonEnergy = ibooker.book1D("muonEnergy", "muonEnergy", 50, 0, 500);
0492     muonEnergyFraction = ibooker.book1D("muonEnergyFraction", "muonEnergyFraction", 50, 0, 1);
0493     HFHadronEnergy = ibooker.book1D("HFHadronEnergy", "HFHadronEnergy", 50, 0, 500);
0494     HFHadronEnergyFraction = ibooker.book1D("HFHadronEnergyFraction", "HFHadronEnergyFraction", 50, 0, 1);
0495     HFEMEnergy = ibooker.book1D("HFEMEnergy", "HFEMEnergy", 50, 0, 500);
0496     HFEMEnergyFraction = ibooker.book1D("HFEMEnergyFraction", "HFEMEnergyFraction", 50, 0, 1);
0497     chargedHadronMultiplicity = ibooker.book1D("chargedHadronMultiplicity", "chargedHadronMultiplicity", 50, 0, 50);
0498     neutralHadronMultiplicity = ibooker.book1D("neutralHadronMultiplicity", "neutralHadronMultiplicity", 50, 0, 50);
0499     photonMultiplicity = ibooker.book1D("photonMultiplicity", "photonMultiplicity", 10, 0, 10);
0500     electronMultiplicity = ibooker.book1D("electronMultiplicity", "electronMultiplicity", 10, 0, 10);
0501     HFHadronMultiplicity = ibooker.book1D("HFHadronMultiplicity", "HFHadronMultiplicity", 50, 0, 50);
0502     HFEMMultiplicity = ibooker.book1D("HFEMMultiplicity", "HFEMMultiplicity", 50, 0, 50);
0503     chargedMuEnergy = ibooker.book1D("chargedMuEnergy", "chargedMuEnergy", 50, 0, 500);
0504     chargedMuEnergyFraction = ibooker.book1D("chargedMuEnergyFraction", "chargedMuEnergyFraction", 50, 0, 1);
0505     neutralMultiplicity = ibooker.book1D("neutralMultiplicity", "neutralMultiplicity", 50, 0, 50);
0506     HOEnergy = ibooker.book1D("HOEnergy", "HOEnergy", 50, 0, 500);
0507     HOEnergyFraction = ibooker.book1D("HOEnergyFraction", "HOEnergyFraction", 50, 0, 1);
0508   }
0509 }
0510 
0511 //------------------------------------------------------------------------------
0512 // ~JetTester
0513 //------------------------------------------------------------------------------
0514 JetTester::~JetTester() {}
0515 
0516 //------------------------------------------------------------------------------
0517 // analyze
0518 //------------------------------------------------------------------------------
0519 void JetTester::analyze(const edm::Event &mEvent, const edm::EventSetup &mSetup) {
0520   // Get the primary vertices
0521   //----------------------------------------------------------------------------
0522   edm::Handle<vector<reco::Vertex>> pvHandle;
0523   mEvent.getByToken(pvToken_, pvHandle);
0524 
0525   int nGoodVertices = 0;
0526 
0527   if (pvHandle.isValid()) {
0528     for (unsigned i = 0; i < pvHandle->size(); i++) {
0529       if ((*pvHandle)[i].ndof() > 4 && (fabs((*pvHandle)[i].z()) <= 24) && (fabs((*pvHandle)[i].position().rho()) <= 2))
0530         nGoodVertices++;
0531     }
0532   }
0533 
0534   mNvtx->Fill(nGoodVertices);
0535 
0536   //  // Get the jet rho
0537   //  //----------------------------------------------------------------------------
0538   //  edm::Handle<double> pRho;
0539   //  mEvent.getByToken(rhoTag, pRho);
0540   //
0541   //  if (pRho.isValid())
0542   //    {
0543   //      double jetRho = *pRho;
0544   //
0545   //      if (mRho) mRho->Fill(jetRho);
0546   //    }
0547 
0548   // Get the Jet collection
0549   //----------------------------------------------------------------------------
0550   math::XYZTLorentzVector p4tmp[2];
0551 
0552   std::vector<Jet> recoJets;
0553   recoJets.clear();
0554 
0555   edm::Handle<CaloJetCollection> caloJets;
0556   edm::Handle<PFJetCollection> pfJets;
0557   //  edm::Handle<JPTJetCollection>  jptJets;
0558   edm::Handle<pat::JetCollection> patJets;
0559 
0560   if (isCaloJet)
0561     mEvent.getByToken(caloJetsToken_, caloJets);
0562   if (isPFJet)
0563     mEvent.getByToken(pfJetsToken_, pfJets);
0564   //  if (isJPTJet)  mEvent.getByToken(jptJetsToken_, jptJets);
0565   if (isMiniAODJet)
0566     mEvent.getByToken(patJetsToken_, patJets);
0567 
0568   if (isCaloJet && !caloJets.isValid())
0569     return;
0570   if (isPFJet && !pfJets.isValid())
0571     return;
0572   //  if (isJPTJet  && !jptJets.isValid())  return;
0573   if (isMiniAODJet && !patJets.isValid())
0574     return;
0575 
0576   if (isCaloJet) {
0577     for (unsigned ijet = 0; ijet < caloJets->size(); ijet++)
0578       recoJets.push_back((*caloJets)[ijet]);
0579   }
0580 
0581   /*  if (isJPTJet)
0582       {
0583         for (unsigned ijet=0; ijet<jptJets->size(); ijet++)
0584           recoJets.push_back((*jptJets)[ijet]);
0585       }*/
0586 
0587   if (isPFJet) {
0588     for (unsigned ijet = 0; ijet < pfJets->size(); ijet++)
0589       recoJets.push_back((*pfJets)[ijet]);
0590   }
0591   if (isMiniAODJet) {
0592     for (unsigned ijet = 0; ijet < patJets->size(); ijet++)
0593       recoJets.push_back((*patJets)[ijet]);
0594   }
0595 
0596   int nJet = 0;
0597   int nJet_E_20_40 = 0;
0598   int nJet_B_20_40 = 0;
0599   int nJet_E_40 = 0;
0600   int nJet_B_40 = 0;
0601   int nJet_40 = 0;
0602 
0603   int index_first_jet = -1;
0604   double pt_first = -1;
0605 
0606   int index_second_jet = -1;
0607   double pt_second = -1;
0608 
0609   for (unsigned ijet = 0; ijet < recoJets.size(); ijet++) {
0610     bool pass_lowjet = false;
0611     bool pass_mediumjet = false;
0612     if (!isMiniAODJet) {
0613       if ((recoJets[ijet].pt() > 20.) && (recoJets[ijet].pt() < mRecoJetPtThreshold)) {
0614         pass_lowjet = true;
0615       }
0616     }
0617     if (isMiniAODJet) {
0618       if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > 20. &&
0619           ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) < mRecoJetPtThreshold)) {
0620         pass_lowjet = true;
0621       }
0622     }
0623     if (pass_lowjet) {
0624       if (fabs(recoJets[ijet].eta()) > 1.5)
0625         nJet_E_20_40++;
0626       else
0627         nJet_B_20_40++;
0628     }
0629     if (!isMiniAODJet) {
0630       if (recoJets[ijet].pt() > mRecoJetPtThreshold) {
0631         pass_mediumjet = true;
0632       }
0633     }
0634     if (isMiniAODJet) {
0635       if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > mRecoJetPtThreshold) {
0636         pass_mediumjet = true;
0637       }
0638     }
0639     if (pass_mediumjet) {
0640       if (isMiniAODJet) {
0641         if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > pt_first) {
0642           pt_second = pt_first;
0643           pt_first = recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected");
0644           index_second_jet = index_first_jet;
0645           index_first_jet = ijet;
0646         } else if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > pt_second) {
0647           index_second_jet = ijet;
0648           pt_second = recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected");
0649         }
0650       }
0651       // counting forward and barrel jets
0652       if (fabs(recoJets[ijet].eta()) > 1.5)
0653         nJet_E_40++;
0654       else
0655         nJet_B_40++;
0656       nJet_40++;
0657 
0658       if (mEta)
0659         mEta->Fill(recoJets[ijet].eta());
0660 
0661       if (mJetArea)
0662         mJetArea->Fill(recoJets[ijet].jetArea());
0663       if (mPhi)
0664         mPhi->Fill(recoJets[ijet].phi());
0665       if (!isMiniAODJet) {
0666         if (mEnergy)
0667           mEnergy->Fill(recoJets[ijet].energy());
0668         if (mP)
0669           mP->Fill(recoJets[ijet].p());
0670         if (mPt)
0671           mPt->Fill(recoJets[ijet].pt());
0672         if (mMass)
0673           mMass->Fill(recoJets[ijet].mass());
0674       } else {
0675         if (mEnergy)
0676           mEnergy->Fill(recoJets[ijet].energy() * (*patJets)[ijet].jecFactor("Uncorrected"));
0677         if (mP)
0678           mP->Fill(recoJets[ijet].p() * (*patJets)[ijet].jecFactor("Uncorrected"));
0679         if (mPt)
0680           mPt->Fill(recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected"));
0681         if (mMass)
0682           mMass->Fill(recoJets[ijet].mass() * (*patJets)[ijet].jecFactor("Uncorrected"));
0683       }
0684       if (mConstituents)
0685         mConstituents->Fill(recoJets[ijet].nConstituents());
0686       if (!isMiniAODJet) {
0687         if (ijet == 0) {
0688           if (mEtaFirst)
0689             mEtaFirst->Fill(recoJets[ijet].eta());
0690           if (mPhiFirst)
0691             mPhiFirst->Fill(recoJets[ijet].phi());
0692           if (mPtFirst)
0693             mPtFirst->Fill(recoJets[ijet].pt());
0694         }
0695 
0696         if (ijet == 0) {
0697           nJet++;
0698           p4tmp[0] = recoJets[ijet].p4();
0699         }
0700         if (ijet == 1) {
0701           nJet++;
0702           p4tmp[1] = recoJets[ijet].p4();
0703         }
0704       }
0705       //    if (isPFJet || isCaloJet) {
0706       //      if (mHadEnergyInHF)       mHadEnergyInHF
0707       //      ->Fill((*pfJets)[ijet].HFHadronEnergy()); if (mEmEnergyInHF)
0708       //      mEmEnergyInHF       ->Fill((*pfJets)[ijet].HFEMEnergy()); if
0709       //      (mChargedEmEnergy)     mChargedEmEnergy
0710       //      ->Fill((*pfJets)[ijet].chargedEmEnergy()); if
0711       //      (mChargedHadronEnergy)
0712       //      mChargedHadronEnergy->Fill((*pfJets)[ijet].chargedHadronEnergy());
0713       //      if (mNeutralEmEnergy)     mNeutralEmEnergy
0714       //      ->Fill((*pfJets)[ijet].neutralEmEnergy()); if
0715       //      (mNeutralHadronEnergy)
0716       //      mNeutralHadronEnergy->Fill((*pfJets)[ijet].neutralHadronEnergy());
0717       //    }
0718 
0719       // ---- Calo Jet specific information ----
0720       if (isCaloJet) {
0721         maxEInEmTowers->Fill((*caloJets)[ijet].maxEInEmTowers());
0722         maxEInHadTowers->Fill((*caloJets)[ijet].maxEInHadTowers());
0723         energyFractionHadronic->Fill((*caloJets)[ijet].energyFractionHadronic());
0724         emEnergyFraction->Fill((*caloJets)[ijet].emEnergyFraction());
0725         hadEnergyInHB->Fill((*caloJets)[ijet].hadEnergyInHB());
0726         hadEnergyInHO->Fill((*caloJets)[ijet].hadEnergyInHO());
0727         hadEnergyInHE->Fill((*caloJets)[ijet].hadEnergyInHE());
0728         hadEnergyInHF->Fill((*caloJets)[ijet].hadEnergyInHF());
0729         emEnergyInEB->Fill((*caloJets)[ijet].emEnergyInEB());
0730         emEnergyInEE->Fill((*caloJets)[ijet].emEnergyInEE());
0731         emEnergyInHF->Fill((*caloJets)[ijet].emEnergyInHF());
0732         towersArea->Fill((*caloJets)[ijet].towersArea());
0733         n90->Fill((*caloJets)[ijet].n90());
0734         n60->Fill((*caloJets)[ijet].n60());
0735       }
0736       // ---- PF Jet specific information ----
0737       if (isPFJet) {
0738         muonMultiplicity->Fill((*pfJets)[ijet].muonMultiplicity());
0739         chargedMultiplicity->Fill((*pfJets)[ijet].chargedMultiplicity());
0740         chargedEmEnergy->Fill((*pfJets)[ijet].chargedEmEnergy());
0741         neutralEmEnergy->Fill((*pfJets)[ijet].neutralEmEnergy());
0742         chargedHadronEnergy->Fill((*pfJets)[ijet].chargedHadronEnergy());
0743         neutralHadronEnergy->Fill((*pfJets)[ijet].neutralHadronEnergy());
0744         chargedHadronEnergyFraction->Fill((*pfJets)[ijet].chargedHadronEnergyFraction());
0745         neutralHadronEnergyFraction->Fill((*pfJets)[ijet].neutralHadronEnergyFraction());
0746         chargedEmEnergyFraction->Fill((*pfJets)[ijet].chargedEmEnergyFraction());
0747         neutralEmEnergyFraction->Fill((*pfJets)[ijet].neutralEmEnergyFraction());
0748         photonEnergy->Fill((*pfJets)[ijet].photonEnergy());
0749         photonEnergyFraction->Fill((*pfJets)[ijet].photonEnergyFraction());
0750         electronEnergy->Fill((*pfJets)[ijet].electronEnergy());
0751         electronEnergyFraction->Fill((*pfJets)[ijet].electronEnergyFraction());
0752         muonEnergy->Fill((*pfJets)[ijet].muonEnergy());
0753         muonEnergyFraction->Fill((*pfJets)[ijet].muonEnergyFraction());
0754         HFHadronEnergy->Fill((*pfJets)[ijet].HFHadronEnergy());
0755         HFHadronEnergyFraction->Fill((*pfJets)[ijet].HFHadronEnergyFraction());
0756         HFEMEnergy->Fill((*pfJets)[ijet].HFEMEnergy());
0757         HFEMEnergyFraction->Fill((*pfJets)[ijet].HFEMEnergyFraction());
0758         chargedHadronMultiplicity->Fill((*pfJets)[ijet].chargedHadronMultiplicity());
0759         neutralHadronMultiplicity->Fill((*pfJets)[ijet].neutralHadronMultiplicity());
0760         photonMultiplicity->Fill((*pfJets)[ijet].photonMultiplicity());
0761         electronMultiplicity->Fill((*pfJets)[ijet].electronMultiplicity());
0762         HFHadronMultiplicity->Fill((*pfJets)[ijet].HFHadronMultiplicity());
0763         HFEMMultiplicity->Fill((*pfJets)[ijet].HFEMMultiplicity());
0764         chargedMuEnergy->Fill((*pfJets)[ijet].chargedMuEnergy());
0765         chargedMuEnergyFraction->Fill((*pfJets)[ijet].chargedMuEnergyFraction());
0766         neutralMultiplicity->Fill((*pfJets)[ijet].neutralMultiplicity());
0767         HOEnergy->Fill((*pfJets)[ijet].hoEnergy());
0768         HOEnergyFraction->Fill((*pfJets)[ijet].hoEnergyFraction());
0769       }
0770       if (isMiniAODJet && (*patJets)[ijet].isPFJet()) {
0771         muonMultiplicity->Fill((*patJets)[ijet].muonMultiplicity());
0772         chargedMultiplicity->Fill((*patJets)[ijet].chargedMultiplicity());
0773         chargedEmEnergy->Fill((*patJets)[ijet].chargedEmEnergy());
0774         neutralEmEnergy->Fill((*patJets)[ijet].neutralEmEnergy());
0775         chargedHadronEnergy->Fill((*patJets)[ijet].chargedHadronEnergy());
0776         neutralHadronEnergy->Fill((*patJets)[ijet].neutralHadronEnergy());
0777         chargedHadronEnergyFraction->Fill((*patJets)[ijet].chargedHadronEnergyFraction());
0778         neutralHadronEnergyFraction->Fill((*patJets)[ijet].neutralHadronEnergyFraction());
0779         chargedEmEnergyFraction->Fill((*patJets)[ijet].chargedEmEnergyFraction());
0780         neutralEmEnergyFraction->Fill((*patJets)[ijet].neutralEmEnergyFraction());
0781         photonEnergy->Fill((*patJets)[ijet].photonEnergy());
0782         photonEnergyFraction->Fill((*patJets)[ijet].photonEnergyFraction());
0783         electronEnergy->Fill((*patJets)[ijet].electronEnergy());
0784         electronEnergyFraction->Fill((*patJets)[ijet].electronEnergyFraction());
0785         muonEnergy->Fill((*patJets)[ijet].muonEnergy());
0786         muonEnergyFraction->Fill((*patJets)[ijet].muonEnergyFraction());
0787         HFHadronEnergy->Fill((*patJets)[ijet].HFHadronEnergy());
0788         HFHadronEnergyFraction->Fill((*patJets)[ijet].HFHadronEnergyFraction());
0789         HFEMEnergy->Fill((*patJets)[ijet].HFEMEnergy());
0790         HFEMEnergyFraction->Fill((*patJets)[ijet].HFEMEnergyFraction());
0791         chargedHadronMultiplicity->Fill((*patJets)[ijet].chargedHadronMultiplicity());
0792         neutralHadronMultiplicity->Fill((*patJets)[ijet].neutralHadronMultiplicity());
0793         photonMultiplicity->Fill((*patJets)[ijet].photonMultiplicity());
0794         electronMultiplicity->Fill((*patJets)[ijet].electronMultiplicity());
0795         HFHadronMultiplicity->Fill((*patJets)[ijet].HFHadronMultiplicity());
0796         HFEMMultiplicity->Fill((*patJets)[ijet].HFEMMultiplicity());
0797         chargedMuEnergy->Fill((*patJets)[ijet].chargedMuEnergy());
0798         chargedMuEnergyFraction->Fill((*patJets)[ijet].chargedMuEnergyFraction());
0799         neutralMultiplicity->Fill((*patJets)[ijet].neutralMultiplicity());
0800         HOEnergy->Fill((*patJets)[ijet].hoEnergy());
0801         HOEnergyFraction->Fill((*patJets)[ijet].hoEnergyFraction());
0802       }
0803     }  // fill quantities for medium jets
0804   }
0805 
0806   if (mNJetsEta_B_20_40)
0807     mNJetsEta_B_20_40->Fill(nJet_B_20_40);
0808   if (mNJetsEta_E_20_40)
0809     mNJetsEta_E_20_40->Fill(nJet_E_20_40);
0810   if (mNJetsEta_B_40)
0811     mNJetsEta_B_40->Fill(nJet_B_40);
0812   if (mNJetsEta_E_40)
0813     mNJetsEta_E_40->Fill(nJet_E_40);
0814   if (mNJets_40)
0815     mNJets_40->Fill(nJet_40);
0816   if (!isMiniAODJet) {
0817     if (nJet >= 2) {
0818       if (mMjj)
0819         mMjj->Fill((p4tmp[0] + p4tmp[1]).mass());
0820     }
0821   } else {
0822     if (index_first_jet > -1) {
0823       if (mEtaFirst)
0824         mEtaFirst->Fill(recoJets[index_first_jet].eta());
0825       if (mPhiFirst)
0826         mPhiFirst->Fill(recoJets[index_first_jet].phi());
0827       if (mPtFirst)
0828         mPtFirst->Fill(recoJets[index_first_jet].pt() * (*patJets)[index_first_jet].jecFactor("Uncorrected"));
0829       nJet++;
0830       p4tmp[0] = recoJets[index_first_jet].p4() * (*patJets)[index_first_jet].jecFactor("Uncorrected");
0831     }
0832     if (index_second_jet > -1) {
0833       nJet++;
0834       p4tmp[1] = recoJets[index_second_jet].p4() * (*patJets)[index_second_jet].jecFactor("Uncorrected");
0835     }
0836     if (nJet >= 2) {
0837       if (mMjj)
0838         mMjj->Fill((p4tmp[0] + p4tmp[1]).mass());
0839     }
0840   }
0841 
0842   // Count jets above pt cut
0843   //----------------------------------------------------------------------------
0844   for (int istep = 0; istep < 100; ++istep) {
0845     int njets1 = 0;
0846     int njets2 = 0;
0847 
0848     float ptStep1 = (istep * (200. / 100.));
0849     float ptStep2 = (istep * (4000. / 100.));
0850 
0851     for (unsigned ijet = 0; ijet < recoJets.size(); ijet++) {
0852       if (!isMiniAODJet) {
0853         if (recoJets[ijet].pt() > ptStep1)
0854           njets1++;
0855         if (recoJets[ijet].pt() > ptStep2)
0856           njets2++;
0857       } else {
0858         if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > ptStep1)
0859           njets1++;
0860         if ((recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected")) > ptStep2)
0861           njets2++;
0862       }
0863       mNJets1->Fill(ptStep1, njets1);
0864       mNJets2->Fill(ptStep2, njets2);
0865     }
0866   }
0867 
0868   // Corrected jets
0869   //----------------------------------------------------------------------------
0870   double scale = -999;
0871   edm::Handle<reco::JetCorrector> jetCorr;
0872   bool pass_correction_flag = false;
0873   if (!isMiniAODJet && !mJetCorrector.label().empty()) {
0874     mEvent.getByToken(jetCorrectorToken_, jetCorr);
0875     if (jetCorr.isValid()) {
0876       pass_correction_flag = true;
0877     }
0878   }
0879   if (isMiniAODJet) {
0880     pass_correction_flag = true;
0881   }
0882   for (unsigned ijet = 0; ijet < recoJets.size(); ijet++) {
0883     Jet correctedJet = recoJets[ijet];
0884     if (pass_correction_flag) {
0885       if (isCaloJet)
0886         scale = jetCorr->correction((*caloJets)[ijet]);
0887       if (isPFJet)
0888         scale = jetCorr->correction((*pfJets)[ijet]);
0889       // if (isJPTJet)  scale = jetCorr->correction((*jptJets)[ijet]);
0890       if (!isMiniAODJet) {
0891         correctedJet.scaleEnergy(scale);
0892       }
0893 
0894       if (correctedJet.pt() < 20)
0895         continue;
0896 
0897       if (isMiniAODJet) {
0898         if (hadronFlavor)
0899           hadronFlavor->Fill((*patJets)[ijet].hadronFlavour());
0900         if (partonFlavor)
0901           partonFlavor->Fill((*patJets)[ijet].partonFlavour());
0902         if (genPartonPDGID && (*patJets)[ijet].genParton() != nullptr)
0903           genPartonPDGID->Fill((*patJets)[ijet].genParton()->pdgId());
0904       }
0905 
0906       mCorrJetEta->Fill(correctedJet.eta());
0907       mCorrJetPhi->Fill(correctedJet.phi());
0908       mCorrJetPt->Fill(correctedJet.pt());
0909       if (correctedJet.pt() >= 40) {
0910         mCorrJetEta_Pt40->Fill(correctedJet.eta());
0911         mCorrJetPhi_Pt40->Fill(correctedJet.phi());
0912       }
0913 
0914       double ijetEta = recoJets[ijet].eta();
0915       double ijetPt = recoJets[ijet].pt();
0916       if (isMiniAODJet) {
0917         ijetPt = recoJets[ijet].pt() * (*patJets)[ijet].jecFactor("Uncorrected");
0918       }
0919       double ratio = correctedJet.pt() / ijetPt;
0920       if (isMiniAODJet) {
0921         ratio = 1. / (*patJets)[ijet].jecFactor("Uncorrected");
0922       }
0923 
0924       if (fabs(ijetEta) < 1.5)
0925         mPtCorrOverReco_Pt_B->Fill(log10(ijetPt), ratio);
0926       else if (fabs(ijetEta) < 3.0)
0927         mPtCorrOverReco_Pt_E->Fill(log10(ijetPt), ratio);
0928       else if (fabs(ijetEta) < 6.0)
0929         mPtCorrOverReco_Pt_F->Fill(log10(ijetPt), ratio);
0930 
0931       if (ijetPt < 40)
0932         mPtCorrOverReco_Eta_20_40->Fill(ijetEta, ratio);
0933       else if (ijetPt < 200)
0934         mPtCorrOverReco_Eta_40_200->Fill(ijetEta, ratio);
0935       else if (ijetPt < 600)
0936         mPtCorrOverReco_Eta_200_600->Fill(ijetEta, ratio);
0937       else if (ijetPt < 1500)
0938         mPtCorrOverReco_Eta_600_1500->Fill(ijetEta, ratio);
0939       else if (ijetPt < 3500)
0940         mPtCorrOverReco_Eta_1500_3500->Fill(ijetEta, ratio);
0941       else if (ijetPt < 5000)
0942         mPtCorrOverReco_Eta_3500_5000->Fill(ijetEta, ratio);
0943       else if (ijetPt < 6500)
0944         mPtCorrOverReco_Eta_5000_6500->Fill(ijetEta, ratio);
0945       if (ijetPt > 3500)
0946         mPtCorrOverReco_Eta_3500->Fill(ijetEta, ratio);
0947     }
0948   }
0949 
0950   //----------------------------------------------------------------------------
0951   //
0952   // Generation
0953   //
0954   //----------------------------------------------------------------------------
0955   if (!mEvent.isRealData()) {
0956     // Get ptHat
0957     //------------------------------------------------------------------------
0958     edm::Handle<GenEventInfoProduct> myGenEvt;
0959     mEvent.getByToken(evtToken_, myGenEvt);
0960 
0961     if (myGenEvt.isValid()) {
0962       if (myGenEvt->hasBinningValues()) {
0963         double ptHat = myGenEvt->binningValues()[0];
0964         if (mPtHat)
0965           mPtHat->Fill(ptHat);
0966       }
0967     }
0968     // Gen jets
0969     //------------------------------------------------------------------------
0970     edm::Handle<GenJetCollection> genJets;
0971     mEvent.getByToken(genJetsToken_, genJets);
0972 
0973     if (!genJets.isValid())
0974       return;
0975 
0976     for (GenJetCollection::const_iterator gjet = genJets->begin(); gjet != genJets->end(); gjet++) {
0977       // for MiniAOD we have here intrinsic thresholds, introduce also threshold
0978       // for RECO
0979       if (gjet->pt() > mMatchGenPtThreshold) {
0980         if (mGenEta)
0981           mGenEta->Fill(gjet->eta());
0982         if (mGenPhi)
0983           mGenPhi->Fill(gjet->phi());
0984         if (mGenPt)
0985           mGenPt->Fill(gjet->pt());
0986         if (gjet == genJets->begin()) {
0987           if (mGenEtaFirst)
0988             mGenEtaFirst->Fill(gjet->eta());
0989           if (mGenPhiFirst)
0990             mGenPhiFirst->Fill(gjet->phi());
0991         }
0992       }
0993     }
0994 
0995     if (!(mInputGenCollection.label().empty())) {
0996       for (GenJetCollection::const_iterator gjet = genJets->begin(); gjet != genJets->end(); gjet++) {
0997         if (fabs(gjet->eta()) > 6.)
0998           continue;  // Out of the detector
0999         if (gjet->pt() < mMatchGenPtThreshold)
1000           continue;
1001         if (recoJets.empty())
1002           continue;
1003         // pt response
1004         //------------------------------------------------------------
1005         int iMatch = -1;
1006         double CorrdeltaRBest = 999;
1007         double CorrJetPtBest = 0;
1008         double CorrJetMassBest = 0;
1009         for (unsigned ijet = 0; ijet < recoJets.size(); ++ijet) {
1010           Jet correctedJet = recoJets[ijet];
1011           if (pass_correction_flag && !isMiniAODJet) {
1012             if (isCaloJet)
1013               scale = jetCorr->correction((*caloJets)[ijet]);
1014             if (isPFJet)
1015               scale = jetCorr->correction((*pfJets)[ijet]);
1016             correctedJet.scaleEnergy(scale);
1017           }
1018           double CorrJetPt = correctedJet.pt();
1019           if (CorrJetPt > 10) {
1020             double CorrdR = deltaR(gjet->eta(), gjet->phi(), correctedJet.eta(), correctedJet.phi());
1021             if (CorrdR < CorrdeltaRBest) {
1022               CorrJetMassBest = correctedJet.mass();
1023               CorrdeltaRBest = CorrdR;
1024               CorrJetPtBest = CorrJetPt;
1025               iMatch = ijet;
1026             }
1027           }
1028         }
1029         if (iMatch < 0)
1030           continue;
1031         // use mass after jet energy correction -> for MiniAOD that is the case
1032         // per default
1033         if (!isMiniAODJet) {
1034           fillMatchHists(gjet->eta(),
1035                          gjet->phi(),
1036                          gjet->pt(),
1037                          gjet->mass(),
1038                          recoJets[iMatch].eta(),
1039                          recoJets[iMatch].phi(),
1040                          recoJets[iMatch].pt(),
1041                          CorrJetMassBest);
1042         } else {
1043           fillMatchHists(gjet->eta(),
1044                          gjet->phi(),
1045                          gjet->pt(),
1046                          gjet->mass(),
1047                          (*patJets)[iMatch].eta(),
1048                          (*patJets)[iMatch].phi(),
1049                          (*patJets)[iMatch].pt() * (*patJets)[iMatch].jecFactor("Uncorrected"),
1050                          recoJets[iMatch].mass());
1051         }
1052         if (pass_correction_flag) {  // fill only for corrected jets
1053           if (CorrdeltaRBest < mRThreshold) {
1054             double response = CorrJetPtBest / gjet->pt();
1055 
1056             if (fabs(gjet->eta()) < 1.5)
1057               mPtCorrOverGen_GenPt_B->Fill(log10(gjet->pt()), response);
1058             else if (fabs(gjet->eta()) < 3.0)
1059               mPtCorrOverGen_GenPt_E->Fill(log10(gjet->pt()), response);
1060             else if (fabs(gjet->eta()) < 6.0)
1061               mPtCorrOverGen_GenPt_F->Fill(log10(gjet->pt()), response);
1062 
1063             if (gjet->pt() > 20) {
1064               if (gjet->pt() < 40)
1065                 mPtCorrOverGen_GenEta_20_40->Fill(gjet->eta(), response);
1066               else if (gjet->pt() < 200)
1067                 mPtCorrOverGen_GenEta_40_200->Fill(gjet->eta(), response);
1068               else if (gjet->pt() < 600)
1069                 mPtCorrOverGen_GenEta_200_600->Fill(gjet->eta(), response);
1070               else if (gjet->pt() < 1500)
1071                 mPtCorrOverGen_GenEta_600_1500->Fill(gjet->eta(), response);
1072               else if (gjet->pt() < 3500)
1073                 mPtCorrOverGen_GenEta_1500_3500->Fill(gjet->eta(), response);
1074               else if (gjet->pt() < 5000)
1075                 mPtCorrOverGen_GenEta_3500_5000->Fill(gjet->eta(), response);
1076               else if (gjet->pt() < 6500)
1077                 mPtCorrOverGen_GenEta_5000_6500->Fill(gjet->eta(), response);
1078               if (gjet->pt() > 3500)
1079                 mPtCorrOverGen_GenEta_3500->Fill(gjet->eta(), response);
1080             }
1081           }
1082         }
1083       }
1084     }
1085   }
1086 }
1087 
1088 //------------------------------------------------------------------------------
1089 // fillMatchHists
1090 //------------------------------------------------------------------------------
1091 void JetTester::fillMatchHists(const double GenEta,
1092                                const double GenPhi,
1093                                const double GenPt,
1094                                const double GenMass,
1095                                const double RecoEta,
1096                                const double RecoPhi,
1097                                const double RecoPt,
1098                                const double RecoMass) {
1099   if (GenPt > mMatchGenPtThreshold) {
1100     mDeltaEta->Fill(GenEta - RecoEta);
1101     mDeltaPhi->Fill(GenPhi - RecoPhi);
1102     mDeltaPt->Fill((GenPt - RecoPt) / GenPt);
1103   }
1104 
1105   if (fabs(GenEta) < 1.5) {
1106     mPtRecoOverGen_GenPt_B->Fill(log10(GenPt), RecoPt / GenPt);
1107     mPtRecoOverGen_GenPhi_B->Fill(GenPhi, RecoPt / GenPt);
1108 
1109     if (GenPt > 20 && GenPt < 40)
1110       mMassRecoOverGen_B_20_40->Fill(RecoMass / GenMass);
1111     else if (GenPt < 200)
1112       mMassRecoOverGen_B_40_200->Fill(RecoMass / GenMass);
1113     else if (GenPt < 500)
1114       mMassRecoOverGen_B_200_500->Fill(RecoMass / GenMass);
1115     else if (GenPt < 750)
1116       mMassRecoOverGen_B_500_750->Fill(RecoMass / GenMass);
1117     else if (GenPt < 1000)
1118       mMassRecoOverGen_B_750_1000->Fill(RecoMass / GenMass);
1119     else if (GenPt < 1500)
1120       mMassRecoOverGen_B_1000_1500->Fill(RecoMass / GenMass);
1121     else if (GenPt < 3500)
1122       mMassRecoOverGen_B_1500_3500->Fill(RecoMass / GenMass);
1123     else if (GenPt < 5000)
1124       mMassRecoOverGen_B_3500_5000->Fill(RecoMass / GenMass);
1125     else if (GenPt >= 5000)
1126       mMassRecoOverGen_B_5000->Fill(RecoMass / GenMass);
1127 
1128     if (GenPt > 20 && GenPt < 40)
1129       mPtRecoOverGen_B_20_40->Fill(RecoPt / GenPt);
1130     else if (GenPt < 200)
1131       mPtRecoOverGen_B_40_200->Fill(RecoPt / GenPt);
1132     else if (GenPt < 600)
1133       mPtRecoOverGen_B_200_600->Fill(RecoPt / GenPt);
1134     else if (GenPt < 1500)
1135       mPtRecoOverGen_B_600_1500->Fill(RecoPt / GenPt);
1136     else if (GenPt < 3500)
1137       mPtRecoOverGen_B_1500_3500->Fill(RecoPt / GenPt);
1138     else if (GenPt < 5000)
1139       mPtRecoOverGen_B_3500_5000->Fill(RecoPt / GenPt);
1140     else if (GenPt < 6500)
1141       mPtRecoOverGen_B_5000_6500->Fill(RecoPt / GenPt);
1142     if (GenPt > 3500)
1143       mPtRecoOverGen_B_3500->Fill(RecoPt / GenPt);
1144   } else if (fabs(GenEta) < 3.0) {
1145     mPtRecoOverGen_GenPt_E->Fill(log10(GenPt), RecoPt / GenPt);
1146     mPtRecoOverGen_GenPhi_E->Fill(GenPhi, RecoPt / GenPt);
1147 
1148     if (GenPt > 20 && GenPt < 40)
1149       mPtRecoOverGen_E_20_40->Fill(RecoPt / GenPt);
1150     else if (GenPt < 200)
1151       mPtRecoOverGen_E_40_200->Fill(RecoPt / GenPt);
1152     else if (GenPt < 600)
1153       mPtRecoOverGen_E_200_600->Fill(RecoPt / GenPt);
1154     else if (GenPt < 1500)
1155       mPtRecoOverGen_E_600_1500->Fill(RecoPt / GenPt);
1156     else if (GenPt < 3500)
1157       mPtRecoOverGen_E_1500_3500->Fill(RecoPt / GenPt);
1158     else if (GenPt < 5000)
1159       mPtRecoOverGen_E_3500_5000->Fill(RecoPt / GenPt);
1160     else if (GenPt < 6500)
1161       mPtRecoOverGen_E_5000_6500->Fill(RecoPt / GenPt);
1162     if (GenPt > 3500)
1163       mPtRecoOverGen_E_3500->Fill(RecoPt / GenPt);
1164 
1165     if (GenPt > 20 && GenPt < 40)
1166       mMassRecoOverGen_E_20_40->Fill(RecoMass / GenMass);
1167     else if (GenPt < 200)
1168       mMassRecoOverGen_E_40_200->Fill(RecoMass / GenMass);
1169     else if (GenPt < 500)
1170       mMassRecoOverGen_E_200_500->Fill(RecoMass / GenMass);
1171     else if (GenPt < 750)
1172       mMassRecoOverGen_E_500_750->Fill(RecoMass / GenMass);
1173     else if (GenPt < 1000)
1174       mMassRecoOverGen_E_750_1000->Fill(RecoMass / GenMass);
1175     else if (GenPt < 1500)
1176       mMassRecoOverGen_E_1000_1500->Fill(RecoMass / GenMass);
1177     else if (GenPt < 3500)
1178       mMassRecoOverGen_E_1500_3500->Fill(RecoMass / GenMass);
1179     else if (GenPt < 5000)
1180       mMassRecoOverGen_E_3500_5000->Fill(RecoMass / GenMass);
1181     else if (GenPt >= 5000)
1182       mMassRecoOverGen_E_5000->Fill(RecoMass / GenMass);
1183 
1184   } else if (fabs(GenEta) < 6.0) {
1185     mPtRecoOverGen_GenPt_F->Fill(log10(GenPt), RecoPt / GenPt);
1186     mPtRecoOverGen_GenPhi_F->Fill(GenPhi, RecoPt / GenPt);
1187 
1188     if (GenPt > 20 && GenPt < 40)
1189       mPtRecoOverGen_F_20_40->Fill(RecoPt / GenPt);
1190     else if (GenPt < 200)
1191       mPtRecoOverGen_F_40_200->Fill(RecoPt / GenPt);
1192     else if (GenPt < 600)
1193       mPtRecoOverGen_F_200_600->Fill(RecoPt / GenPt);
1194     else if (GenPt < 1500)
1195       mPtRecoOverGen_F_600_1500->Fill(RecoPt / GenPt);
1196     else if (GenPt < 3500)
1197       mPtRecoOverGen_F_1500_3500->Fill(RecoPt / GenPt);
1198     if (GenPt > 3500)
1199       mPtRecoOverGen_F_3500->Fill(RecoPt / GenPt);
1200 
1201     if (GenPt > 20 && GenPt < 40)
1202       mMassRecoOverGen_F_20_40->Fill(RecoMass / GenMass);
1203     else if (GenPt < 200)
1204       mMassRecoOverGen_F_40_200->Fill(RecoMass / GenMass);
1205     else if (GenPt < 500)
1206       mMassRecoOverGen_F_200_500->Fill(RecoMass / GenMass);
1207     else if (GenPt < 750)
1208       mMassRecoOverGen_F_500_750->Fill(RecoMass / GenMass);
1209     else if (GenPt < 1000)
1210       mMassRecoOverGen_F_750_1000->Fill(RecoMass / GenMass);
1211     else if (GenPt < 1500)
1212       mMassRecoOverGen_F_1000_1500->Fill(RecoMass / GenMass);
1213     else if (GenPt >= 1500)
1214       mMassRecoOverGen_F_1500->Fill(RecoMass / GenMass);
1215   }
1216 
1217   if (GenPt > 20 && GenPt < 40)
1218     mPtRecoOverGen_GenEta_20_40->Fill(GenEta, RecoPt / GenPt);
1219   else if (GenPt < 200)
1220     mPtRecoOverGen_GenEta_40_200->Fill(GenEta, RecoPt / GenPt);
1221   else if (GenPt < 600)
1222     mPtRecoOverGen_GenEta_200_600->Fill(GenEta, RecoPt / GenPt);
1223   else if (GenPt < 1500)
1224     mPtRecoOverGen_GenEta_600_1500->Fill(GenEta, RecoPt / GenPt);
1225   else if (GenPt < 3500)
1226     mPtRecoOverGen_GenEta_1500_3500->Fill(GenEta, RecoPt / GenPt);
1227   else if (GenPt < 5000)
1228     mPtRecoOverGen_GenEta_3500_5000->Fill(GenEta, RecoPt / GenPt);
1229   else if (GenPt < 6500)
1230     mPtRecoOverGen_GenEta_5000_6500->Fill(GenEta, RecoPt / GenPt);
1231   if (GenPt > 3500)
1232     mPtRecoOverGen_GenEta_3500->Fill(GenEta, RecoPt / GenPt);
1233 }