CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Validation/RecoJets/plugins/JPTJetTester.cc

Go to the documentation of this file.
00001 
00002 // Producer for validation histograms for CaloJet objects
00003 // F. Ratnikov, Sept. 7, 2006
00004 // Modified by J F Novak July 10, 2008
00005 // $Id: JPTJetTester.cc,v 1.25 2013/03/19 21:24:16 kovitang Exp $
00006 
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 
00013 #include "DataFormats/Math/interface/deltaR.h"
00014 
00015 #include "DQMServices/Core/interface/DQMStore.h"
00016 #include "DQMServices/Core/interface/MonitorElement.h"
00017 
00018 #include "DataFormats/JetReco/interface/JPTJet.h"
00019 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
00020 #include "DataFormats/JetReco/interface/GenJet.h"
00021 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00022 
00023 #include "DataFormats/METReco/interface/CaloMET.h"
00024 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00025 
00026 #include "RecoJets/JetProducers/interface/JetMatchingTools.h"
00027 
00028 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00029 
00030 #include "JPTJetTester.h"
00031 
00032 #include <cmath>
00033 
00034 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00035 
00036 using namespace edm;
00037 using namespace reco;
00038 using namespace std;
00039 
00040 namespace {
00041   bool is_B (const reco::Jet& fJet) {return fabs (fJet.eta()) < 1.3;}
00042   bool is_E (const reco::Jet& fJet) {return fabs (fJet.eta()) >= 1.3 && fabs (fJet.eta()) < 3.;}
00043   bool is_F (const reco::Jet& fJet) {return fabs (fJet.eta()) >= 3.;}
00044 }
00045 
00046 JPTJetTester::JPTJetTester(const edm::ParameterSet& iConfig)
00047   : mInputCollection (iConfig.getParameter<edm::InputTag>( "src" )),
00048     mInputGenCollection (iConfig.getParameter<edm::InputTag>( "srcGen" )),
00049     mOutputFile (iConfig.getUntrackedParameter<std::string>("outputFile", "")),
00050     mMatchGenPtThreshold (iConfig.getParameter<double>("genPtThreshold")),
00051     mGenEnergyFractionThreshold (iConfig.getParameter<double>("genEnergyFractionThreshold")),
00052     mReverseEnergyFractionThreshold (iConfig.getParameter<double>("reverseEnergyFractionThreshold")),
00053     mRThreshold (iConfig.getParameter<double>("RThreshold")),
00054      JetCorrectionService  (iConfig.getParameter<std::string>  ("JetCorrectionService"  )),
00055     mTurnOnEverything (iConfig.getUntrackedParameter<std::string>("TurnOnEverything",""))
00056 {
00057     numberofevents
00058     = mEta = mEtaFineBin = mPhi = mPhiFineBin = mE = mE_80 
00059     = mP = mP_80  = mPt = mPt_80 
00060     = mMass = mMass_80 
00061     = mEtaFirst = mPhiFirst  = mPtFirst = mPtFirst_80 = mPtFirst_3000
00062     = mMjj = mMjj_3000 = mDelEta = mDelPhi = mDelPt 
00063     = mHadTiming = mEmTiming 
00064     = mNJetsEtaC = mNJetsEtaF = mNJets1 = mNJets2
00065       = mDeltaEta = mDeltaPhi 
00066     = mHadEnergyProfile = mEmEnergyProfile = mJetEnergyProfile 
00067     = mEScale_pt10 = mEScaleFineBin
00068     = mpTScaleB_d = mpTScaleE_d = mpTScaleF_d
00069       = mpTScalePhiB_d = mpTScalePhiE_d = mpTScalePhiF_d
00070     = mpTScale_30_200_d = mpTScale_200_600_d = mpTScale_600_1500_d = mpTScale_1500_3500_d
00071       
00072     = mpTScale1DB_30_200    = mpTScale1DE_30_200    = mpTScale1DF_30_200 
00073     = mpTScale1DB_200_600   = mpTScale1DE_200_600   = mpTScale1DF_200_600 
00074     = mpTScale1DB_600_1500   = mpTScale1DE_600_1500   = mpTScale1DF_600_1500 
00075     = mpTScale1DB_1500_3500 = mpTScale1DE_1500_3500 = mpTScale1DF_1500_3500
00076     = mPthat_80 = mPthat_3000
00077 
00078       //Corr Jet
00079     = mCorrJetPt =mCorrJetPt_80  =mCorrJetEta =mCorrJetPhi =mpTRatio =mpTResponse
00080       = mpTRatioB_d = mpTRatioE_d = mpTRatioF_d
00081       = mpTRatio_30_200_d = mpTRatio_200_600_d = mpTRatio_600_1500_d = mpTRatio_1500_3500_d
00082       = mpTResponseB_d = mpTResponseE_d = mpTResponseF_d
00083       = mpTResponse_30_200_d = mpTResponse_200_600_d = mpTResponse_600_1500_d = mpTResponse_1500_3500_d
00084       = mpTResponse_30_d 
00085       = nvtx_0_30 = nvtx_0_60 
00086       = mpTResponse_nvtx_0_5 = mpTResponse_nvtx_5_10 =mpTResponse_nvtx_10_15 
00087       = mpTResponse_nvtx_15_20 = mpTResponse_nvtx_20_30 = mpTResponse_nvtx_30_inf
00088       = mpTScale_a_nvtx_0_5 = mpTScale_b_nvtx_0_5 = mpTScale_c_nvtx_0_5 
00089       = mpTScale_a_nvtx_5_10 = mpTScale_b_nvtx_5_10 = mpTScale_c_nvtx_5_10
00090       = mpTScale_a_nvtx_10_15 = mpTScale_b_nvtx_10_15 = mpTScale_c_nvtx_10_15
00091       = mpTScale_a_nvtx_15_20 = mpTScale_b_nvtx_15_20 = mpTScale_c_nvtx_15_20
00092       = mpTScale_a_nvtx_20_30 = mpTScale_b_nvtx_20_30 = mpTScale_c_nvtx_20_30
00093       = mpTScale_a_nvtx_30_inf = mpTScale_b_nvtx_30_inf = mpTScale_c_nvtx_30_inf
00094       = mpTScale_nvtx_0_5 = mpTScale_nvtx_5_10 = mpTScale_nvtx_10_15 
00095       = mpTScale_nvtx_15_20 = mpTScale_nvtx_20_30 = mpTScale_nvtx_30_inf
00096       = mNJetsEtaF_30
00097       = mpTScale_a = mpTScale_b = mpTScale_c = mpTScale_pT
00098       = 0;
00099   
00100   DQMStore* dbe = &*edm::Service<DQMStore>();
00101   if (dbe) {
00102     dbe->setCurrentFolder("JetMET/RecoJetsV/JPTJetTask_" + mInputCollection.label());
00103     //
00104     numberofevents    = dbe->book1D("numberofevents","numberofevents", 3, 0 , 2);
00105     //
00106     mEta              = dbe->book1D("Eta", "Eta", 120, -6, 6); 
00107     mEtaFineBin       = dbe->book1D("EtaFineBin_Pt10", "EtaFineBin_Pt10", 600, -6, 6); 
00108     //
00109     mPhi              = dbe->book1D("Phi", "Phi", 70, -3.5, 3.5); 
00110     mPhiFineBin       = dbe->book1D("PhiFineBin_Pt10", "PhiFineBin_Pt10", 350, -3.5, 3.5); 
00111     //
00112     mE                = dbe->book1D("E", "E", 100, 0, 500); 
00113     mE_80             = dbe->book1D("E_80", "E_80", 100, 0, 5000); 
00114     //
00115     mP                = dbe->book1D("P", "P", 100, 0, 500); 
00116     mP_80             = dbe->book1D("P_80", "P_80", 100, 0, 5000); 
00117     //
00118     mPt               = dbe->book1D("Pt", "Pt", 100, 0, 150); 
00119     mPt_80            = dbe->book1D("Pt_80", "Pt_80", 100, 0, 4000);
00120     //
00121     mMass             = dbe->book1D("Mass", "Mass", 100, 0, 200); 
00122     mMass_80          = dbe->book1D("Mass_80", "Mass_80", 100, 0, 500); 
00123     mEtaFirst         = dbe->book1D("EtaFirst", "EtaFirst", 120, -6, 6); 
00124     mPhiFirst         = dbe->book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);      
00125     mPtFirst          = dbe->book1D("PtFirst", "PtFirst", 100, 0, 50); 
00126     mPtFirst_80       = dbe->book1D("PtFirst_80", "PtFirst_80", 100, 0, 140);
00127     mPtFirst_3000     = dbe->book1D("PtFirst_3000", "PtFirst_3000", 100, 0, 4000);
00128     //
00129     mMjj              = dbe->book1D("Mjj", "Mjj", 100, 0, 2000); 
00130     mMjj_3000         = dbe->book1D("Mjj_3000", "Mjj_3000", 100, 0, 10000); 
00131     mDelEta           = dbe->book1D("DelEta", "DelEta", 100, -.5, .5); 
00132     mDelPhi           = dbe->book1D("DelPhi", "DelPhi", 100, -.5, .5); 
00133     mDelPt            = dbe->book1D("DelPt", "DelPt", 100, -1, 1); 
00134     //
00135 
00136     //
00137     mGenEta           = dbe->book1D("GenEta", "GenEta", 120, -6, 6);
00138     mGenPhi           = dbe->book1D("GenPhi", "GenPhi", 70, -3.5, 3.5);
00139     mGenPt            = dbe->book1D("GenPt", "GenPt", 100, 0, 150);
00140     mGenPt_80         = dbe->book1D("GenPt_80", "GenPt_80", 100, 0, 1500);
00141     //
00142     mGenEtaFirst      = dbe->book1D("GenEtaFirst", "GenEtaFirst", 100, -5, 5);
00143     mGenPhiFirst      = dbe->book1D("GenPhiFirst", "GenPhiFirst", 70, -3.5, 3.5);
00144     //
00145     //
00146     mHadTiming        = dbe->book1D("HadTiming", "HadTiming", 75, -50, 100);
00147     mEmTiming         = dbe->book1D("EMTiming", "EMTiming", 75, -50, 100);
00148     //
00149     mNJetsEtaC        = dbe->book1D("NJetsEtaC_Pt10", "NJetsEtaC_Pt10", 15, 0, 15);
00150     mNJetsEtaF        = dbe->book1D("NJetsEtaF_Pt10", "NJetsEtaF_Pt10", 15, 0, 15);
00151     mNJetsEtaF_30        = dbe->book1D("NJetsEtaF_Pt30", "NJetsEtaF_Pt30", 15, 0, 15);
00152     //
00153     mNJets1           = dbe->bookProfile("NJets1", "NJets1", 100, 0, 200,  100, 0, 50, "s");
00154     mNJets2           = dbe->bookProfile("NJets2", "NJets2", 100, 0, 4000, 100, 0, 50, "s");
00155     //
00156     //
00157     mPthat_80            = dbe->book1D("Pthat_80", "Pthat_80", 100, 0.0, 1000.0); 
00158     mPthat_3000          = dbe->book1D("Pthat_3000", "Pthat_3000", 100, 1000.0, 4000.0); 
00159 
00160     //Corr
00161     mCorrJetPt  = dbe->book1D("CorrPt", "CorrPt", 100, 0, 150);
00162     mCorrJetPt_80 = dbe->book1D("CorrPt_80", "CorrPt_80", 100, 0, 4000);
00163     mCorrJetEta = dbe->book1D("CorrEta", "CorrEta", 120, -6, 6);
00164     mCorrJetPhi = dbe->book1D("CorrPhi", "CorrPhi", 70, -3.5, 3.5);
00165     //mjetArea = dbe->book1D("jetArea","jetArea",25,0,2.5);
00166 
00167     //nvtx
00168     nvtx_0_30 = dbe->book1D("nvtx_0_30","nvtx_0_30",31,-0.5,30.5);
00169     nvtx_0_60 = dbe->book1D("nvtx_0_60","nvtx_0_60",61,-0.5,60.5);
00170 
00171     //pT scale with nvtx
00172     mpTScale_a_nvtx_0_5 = dbe->book1D("mpTScale_a_nvtx_0_5", "pTScale_a_nvtx_0_5_0<|eta|<1.3_60_120",100, 0, 2);
00173     mpTScale_b_nvtx_0_5 = dbe->book1D("mpTScale_b_nvtx_0_5", "pTScale_b_nvtx_0_5_0<|eta|<1.3_200_300",100, 0, 2);
00174     mpTScale_c_nvtx_0_5 = dbe->book1D("mpTScale_c_nvtx_0_5", "pTScale_c_nvtx_0_5_0<|eta|<1.3_600_900",100, 0, 2);
00175     mpTScale_a_nvtx_5_10 = dbe->book1D("mpTScale_a_nvtx_5_10", "pTScale_a_nvtx_5_10_0<|eta|<1.3_60_120",100, 0, 2);
00176     mpTScale_b_nvtx_5_10 = dbe->book1D("mpTScale_b_nvtx_5_10", "pTScale_b_nvtx_5_10_0<|eta|<1.3_200_300",100, 0, 2);
00177     mpTScale_c_nvtx_5_10 = dbe->book1D("mpTScale_c_nvtx_5_10", "pTScale_c_nvtx_5_10_0<|eta|<1.3_600_900",100, 0, 2);
00178     mpTScale_a_nvtx_10_15 = dbe->book1D("mpTScale_a_nvtx_10_15", "pTScale_a_nvtx_10_15_0<|eta|<1.3_60_120",100, 0, 2);
00179     mpTScale_b_nvtx_10_15 = dbe->book1D("mpTScale_b_nvtx_10_15", "pTScale_b_nvtx_10_15_0<|eta|<1.3_200_300",100, 0, 2);
00180     mpTScale_c_nvtx_10_15 = dbe->book1D("mpTScale_c_nvtx_10_15", "pTScale_c_nvtx_10_15_0<|eta|<1.3_600_900",100, 0, 2);
00181     mpTScale_a_nvtx_15_20 = dbe->book1D("mpTScale_a_nvtx_15_20", "pTScale_a_nvtx_15_20_0<|eta|<1.3_60_120",100, 0, 2);
00182     mpTScale_b_nvtx_15_20 = dbe->book1D("mpTScale_b_nvtx_15_20", "pTScale_b_nvtx_15_20_0<|eta|<1.3_200_300",100, 0, 2);
00183     mpTScale_c_nvtx_15_20 = dbe->book1D("mpTScale_c_nvtx_15_20", "pTScale_c_nvtx_15_20_0<|eta|<1.3_600_900",100, 0, 2);
00184     mpTScale_a_nvtx_20_30 = dbe->book1D("mpTScale_a_nvtx_20_30", "pTScale_a_nvtx_20_30_0<|eta|<1.3_60_120",100, 0, 2);
00185     mpTScale_b_nvtx_20_30 = dbe->book1D("mpTScale_b_nvtx_20_30", "pTScale_b_nvtx_20_30_0<|eta|<1.3_200_300",100, 0, 2);
00186     mpTScale_c_nvtx_20_30 = dbe->book1D("mpTScale_c_nvtx_20_30", "pTScale_c_nvtx_20_30_0<|eta|<1.3_600_900",100, 0, 2);
00187     mpTScale_a_nvtx_30_inf = dbe->book1D("mpTScale_a_nvtx_30_inf", "pTScale_a_nvtx_30_inf_0<|eta|<1.3_60_120",100, 0, 2);
00188     mpTScale_b_nvtx_30_inf = dbe->book1D("mpTScale_b_nvtx_30_inf", "pTScale_b_nvtx_30_inf_0<|eta|<1.3_200_300",100, 0, 2);
00189     mpTScale_c_nvtx_30_inf = dbe->book1D("mpTScale_c_nvtx_30_inf", "pTScale_c_nvtx_30_inf_0<|eta|<1.3_600_900",100, 0, 2);
00190     mpTScale_a = dbe->book1D("mpTScale_a", "pTScale_a_60_120",100, 0, 2);
00191     mpTScale_b = dbe->book1D("mpTScale_b", "pTScale_b_200_300",100, 0, 2);
00192     mpTScale_c = dbe->book1D("mpTScale_c", "pTScale_c_600_900",100, 0, 2);
00193     //
00194     double log10PtMin = 0.5; //=3.1622766
00195     double log10PtMax = 3.75; //=5623.41325
00196     int log10PtBins = 26; 
00197     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,-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,-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,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,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,4.0,4.2,4.4,4.6,4.8,5.0,5.2,5.4,5.6,5.8,6.0};
00198 
00199 
00200    // int log10PtFineBins = 50;
00201     //
00202     if (mTurnOnEverything.compare("yes")==0) {
00203     }
00204 
00205     //
00206     if (mTurnOnEverything.compare("yes")==0) {
00207   }
00208     mpTScaleB_d = dbe->bookProfile("pTScaleB_d", "pTScale_d_0<|eta|<1.5",
00209                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00210     mpTScaleE_d = dbe->bookProfile("pTScaleE_d", "pTScale_d_1.5<|eta|<3.0",
00211                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00212     mpTScaleF_d = dbe->bookProfile("pTScaleF_d", "pTScale_d_3.0<|eta|<6.0",
00213                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00214     mpTScalePhiB_d = dbe->bookProfile("pTScalePhiB_d", "pTScalePhi_d_0<|eta|<1.5",
00215                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00216     mpTScalePhiE_d = dbe->bookProfile("pTScalePhiE_d", "pTScalePhi_d_1.5<|eta|<3.0",
00217                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00218     mpTScalePhiF_d = dbe->bookProfile("pTScalePhiF_d", "pTScalePhi_d_3.0<|eta|<6.0",
00219                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00220     mpTScale_30_200_d    = dbe->bookProfile("pTScale_30_200_d", "pTScale_d_30<pT<200",
00221                                           90,etaRange, 0., 2., " ");
00222     mpTScale_200_600_d   = dbe->bookProfile("pTScale_200_600_d", "pTScale_d_200<pT<600",
00223                                           90,etaRange, 0., 2., " ");
00224     mpTScale_600_1500_d   = dbe->bookProfile("pTScale_600_1500_d", "pTScale_d_600<pT<1500",
00225                                           90,etaRange, 0., 2., " ");
00226     mpTScale_1500_3500_d = dbe->bookProfile("pTScale_1500_3500_d", "pTScale_d_1500<pt<3500",
00227                                           90,etaRange, 0., 2., " ");
00228     
00229     mpTScale1DB_30_200 = dbe->book1D("pTScale1DB_30_200", "pTScale_distribution_for_0<|eta|<1.5_30_200",
00230                                    100, 0, 2);
00231     mpTScale1DE_30_200 = dbe->book1D("pTScale1DE_30_200", "pTScale_distribution_for_1.5<|eta|<3.0_30_200",
00232                                    50, 0, 2);
00233     mpTScale1DF_30_200 = dbe->book1D("pTScale1DF_30_200", "pTScale_distribution_for_3.0<|eta|<6.0_30_200",
00234                                    50, 0, 2);
00235 
00236     mpTScale1DB_200_600 = dbe->book1D("pTScale1DB_200_600", "pTScale_distribution_for_0<|eta|<1.5_200_600",
00237                                    100, 0, 2);
00238     mpTScale1DE_200_600 = dbe->book1D("pTScale1DE_200_600", "pTScale_distribution_for_1.5<|eta|<3.0_200_600",
00239                                    50, 0, 2);
00240     mpTScale1DF_200_600 = dbe->book1D("pTScale1DF_200_600", "pTScale_distribution_for_3.0<|eta|<6.0_200_600",
00241                                    50, 0, 2);
00242 
00243     mpTScale1DB_600_1500 = dbe->book1D("pTScale1DB_600_1500", "pTScale_distribution_for_0<|eta|<1.5_600_1500",
00244                                    100, 0, 2);
00245     mpTScale1DE_600_1500 = dbe->book1D("pTScale1DE_600_1500", "pTScale_distribution_for_1.5<|eta|<3.0_600_1500",
00246                                    50, 0, 2);
00247     mpTScale1DF_600_1500 = dbe->book1D("pTScale1DF_600_1500", "pTScale_distribution_for_3.0<|eta|<6.0_600_1500",
00248                                    50, 0, 2);
00249 
00250     mpTScale1DB_1500_3500 = dbe->book1D("pTScale1DB_1500_3500", "pTScale_distribution_for_0<|eta|<1.5_1500_3500",
00251                                    100, 0, 2);
00252     mpTScale1DE_1500_3500 = dbe->book1D("pTScale1DE_1500_3500", "pTScale_distribution_for_1.5<|eta|<3.0_1500_3500",
00253                                    50, 0, 2);
00254     mpTScale1DF_1500_3500 = dbe->book1D("pTScale1DF_1500_3500", "pTScale_distribution_for_3.0<|eta|<6.0_1500_3500",
00255                                    50, 0, 2);
00256 
00257   mpTScale_nvtx_0_5  = dbe->bookProfile("pTScale_nvtx_0_5", "pTScale_nvtx_0_5_0<|eta|<1.3",
00258                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00259    mpTScale_nvtx_5_10  = dbe->bookProfile("pTScale_nvtx_5_10", "pTScale_nvtx_5_10_0<|eta|<1.3",
00260                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00261    mpTScale_nvtx_10_15  = dbe->bookProfile("pTScale_nvtx_10_15", "pTScale_nvtx_10_15_0<|eta|<1.3",
00262                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00263    mpTScale_nvtx_15_20  = dbe->bookProfile("pTScale_nvtx_15_20", "pTScale_nvtx_15_20_0<|eta|<1.3",
00264                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00265    mpTScale_nvtx_20_30  = dbe->bookProfile("pTScale_nvtx_20_30", "pTScale_nvtx_20_30_0<|eta|<1.3",
00266                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00267    mpTScale_nvtx_30_inf  = dbe->bookProfile("pTScale_nvtx_30_inf", "pTScale_nvtx_30_inf_0<|eta|<1.3",
00268                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00269  mpTScale_pT = dbe->bookProfile("pTScale_pT", "pTScale_vs_pT",
00270                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00272     mpTRatio = dbe->bookProfile("pTRatio", "pTRatio",
00273                                 log10PtBins, log10PtMin, log10PtMax, 100, 0.,5., " ");
00274     mpTRatioB_d = dbe->bookProfile("pTRatioB_d", "pTRatio_d_0<|eta|<1.5",
00275                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00276     mpTRatioE_d = dbe->bookProfile("pTRatioE_d", "pTRatio_d_1.5<|eta|<3.0",
00277                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00278     mpTRatioF_d = dbe->bookProfile("pTRatioF_d", "pTRatio_d_3.0<|eta|<6.0",
00279                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00280     mpTRatio_30_200_d    = dbe->bookProfile("pTRatio_30_200_d", "pTRatio_d_30<pT<200",
00281                                           90,etaRange, 0., 5., " ");
00282     mpTRatio_200_600_d   = dbe->bookProfile("pTRatio_200_600_d", "pTRatio_d_200<pT<600",
00283                                           90,etaRange, 0., 5., " ");
00284     mpTRatio_600_1500_d   = dbe->bookProfile("pTRatio_600_1500_d", "pTRatio_d_600<pT<1500",
00285                                           90,etaRange, 0., 5., " ");
00286     mpTRatio_1500_3500_d = dbe->bookProfile("pTRatio_1500_3500_d", "pTRatio_d_1500<pt<3500",
00287                                           90,etaRange, 0., 5., " ");
00288     mpTResponse = dbe->bookProfile("pTResponse", "pTResponse",
00289                                 log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00290     mpTResponseB_d = dbe->bookProfile("pTResponseB_d", "pTResponse_d_0<|eta|<1.5",
00291                                       log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00292     mpTResponseE_d = dbe->bookProfile("pTResponseE_d", "pTResponse_d_1.5<|eta|<3.0",
00293                                    log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00294     mpTResponseF_d = dbe->bookProfile("pTResponseF_d", "pTResponse_d_3.0<|eta|<6.0",
00295                                    log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00296     mpTResponse_30_200_d    = dbe->bookProfile("pTResponse_30_200_d", "pTResponse_d_30<pT<200",
00297                                           90,etaRange, 0.8, 1.2, " ");
00298     mpTResponse_200_600_d   = dbe->bookProfile("pTResponse_200_600_d", "pTResponse_d_200<pT<600",
00299                                           90,etaRange, 0.8, 1.2, " ");
00300     mpTResponse_600_1500_d   = dbe->bookProfile("pTResponse_600_1500_d", "pTResponse_d_600<pT<1500",
00301                                           90,etaRange, 0.8, 1.2, " ");
00302     mpTResponse_1500_3500_d = dbe->bookProfile("pTResponse_1500_3500_d", "pTResponse_d_1500<pt<3500",
00303                                                90,etaRange, 0.8, 1.2, " ");
00304     mpTResponse_30_d = dbe->bookProfile("pTResponse_30_d", "pTResponse_d_pt>30",
00305                                                90,etaRange, 0.8, 1.2, " ");
00306 
00307     mpTResponse_nvtx_0_5 = dbe->bookProfile("pTResponse_nvtx_0_5", "pTResponse_nvtx_0_5", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00308    mpTResponse_nvtx_5_10 = dbe->bookProfile("pTResponse_nvtx_5_10", "pTResponse_nvtx_5_10", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00309    mpTResponse_nvtx_10_15 = dbe->bookProfile("pTResponse_nvtx_10_15", "pTResponse_nvtx_10_15", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00310    mpTResponse_nvtx_15_20 = dbe->bookProfile("pTResponse_nvtx_15_20", "pTResponse_nvtx_15_20", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00311    mpTResponse_nvtx_20_30 = dbe->bookProfile("pTResponse_nvtx_20_30", "pTResponse_nvtx_20_30", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00312    mpTResponse_nvtx_30_inf = dbe->bookProfile("pTResponse_nvtx_30_inf", "pTResponse_nvtx_30_inf", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00313 
00314 
00315   } // if (dbe)
00316 
00317   if (mOutputFile.empty ()) {
00318     LogInfo("OutputInfo") << " JPTJet histograms will NOT be saved";
00319   } 
00320   else {
00321     LogInfo("OutputInfo") << " JPTJethistograms will be saved to file:" << mOutputFile;
00322   }
00323 }
00324    
00325 JPTJetTester::~JPTJetTester()
00326 {
00327 }
00328 
00329 void JPTJetTester::beginJob(){
00330 }
00331 
00332 void JPTJetTester::endJob() {
00333  if (!mOutputFile.empty() && &*edm::Service<DQMStore>()) edm::Service<DQMStore>()->save (mOutputFile);
00334 }
00335 
00336 
00337 void JPTJetTester::analyze(const edm::Event& mEvent, const edm::EventSetup& mSetup)
00338 {
00339   double countsfornumberofevents = 1;
00340   numberofevents->Fill(countsfornumberofevents);
00341 
00342   //get primary vertices
00343   edm::Handle<vector<reco::Vertex> >pvHandle;
00344   try {
00345     mEvent.getByLabel( "offlinePrimaryVertices", pvHandle );
00346   } catch ( cms::Exception & e ) {
00347     //cout <<prefix<<"error: " << e.what() << endl;
00348   }
00349   vector<reco::Vertex> goodVertices;
00350   for (unsigned i = 0; i < pvHandle->size(); i++) {
00351     if ( (*pvHandle)[i].ndof() > 4 &&
00352        ( fabs((*pvHandle)[i].z()) <= 24. ) &&
00353        ( fabs((*pvHandle)[i].position().rho()) <= 2.0 ) )
00354        goodVertices.push_back((*pvHandle)[i]);
00355   }
00356   
00357   nvtx_0_30->Fill(goodVertices.size());
00358   nvtx_0_60->Fill(goodVertices.size());
00359 
00360   // *********************************
00361   // *** Get pThat
00362   // *********************************
00363 if (!mEvent.isRealData()){
00364   edm::Handle<HepMCProduct> evt;
00365   mEvent.getByLabel("generator", evt);
00366   if (evt.isValid()) {
00367   HepMC::GenEvent * myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
00368   
00369   double pthat = myGenEvent->event_scale();
00370 
00371   mPthat_80->Fill(pthat);
00372   mPthat_3000->Fill(pthat);
00373 
00374   delete myGenEvent; 
00375   }
00376 }
00377   // ***********************************
00378   // *** Get CaloMET
00379   // ***********************************
00380 /*
00381   const CaloMET *calomet;
00382   edm::Handle<CaloMETCollection> calo;
00383   mEvent.getByLabel("met", calo);
00384   if (!calo.isValid()) {
00385     edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00386     edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00387   } else {
00388     const CaloMETCollection *calometcol = calo.product();
00389     calomet = &(calometcol->front());
00390   }
00391 */
00392   // ***********************************
00393   // *** Get the CaloTower collection
00394   // ***********************************
00395   Handle<CaloTowerCollection> caloTowers;
00396   mEvent.getByLabel( "towerMaker", caloTowers );
00397   if (caloTowers.isValid()) {
00398   for( CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++ cal ){
00399 
00400     //To compensate for the index
00401     if (mTurnOnEverything.compare("yes")==0) {
00402   }
00403 
00404     mHadTiming->Fill (cal->hcalTime());
00405     mEmTiming->Fill (cal->ecalTime());    
00406   }
00407   }
00408   
00409   // ***********************************
00410   // *** Get the RecHits collection
00411   // ***********************************
00412   try {
00413     std::vector<edm::Handle<HBHERecHitCollection> > colls;
00414     mEvent.getManyByType(colls);
00415     std::vector<edm::Handle<HBHERecHitCollection> >::iterator i;
00416     for (i=colls.begin(); i!=colls.end(); i++) {
00417       for (HBHERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00418         //      std::cout << *j << std::endl;
00419       }
00420     }
00421   } catch (...) {
00422     edm::LogInfo("OutputInfo") << " No HB/HE RecHits.";
00423   }
00424   
00425   try {
00426     std::vector<edm::Handle<HFRecHitCollection> > colls;
00427     mEvent.getManyByType(colls);
00428     std::vector<edm::Handle<HFRecHitCollection> >::iterator i;
00429     for (i=colls.begin(); i!=colls.end(); i++) {
00430       for (HFRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00431         //      std::cout << *j << std::endl;
00432       }
00433     }
00434   } catch (...) {
00435     edm::LogInfo("OutputInfo") << " No HF RecHits.";
00436   }
00437 
00438   try {
00439     std::vector<edm::Handle<HORecHitCollection> > colls;
00440     mEvent.getManyByType(colls);
00441     std::vector<edm::Handle<HORecHitCollection> >::iterator i;
00442     for (i=colls.begin(); i!=colls.end(); i++) {
00443       for (HORecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00444       }
00445     }
00446   } catch (...) {
00447     edm::LogInfo("OutputInfo") << " No HO RecHits.";
00448   }
00449   try {
00450     std::vector<edm::Handle<EBRecHitCollection> > colls;
00451     mEvent.getManyByType(colls);
00452     std::vector<edm::Handle<EBRecHitCollection> >::iterator i;
00453     for (i=colls.begin(); i!=colls.end(); i++) {
00454       for (EBRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00455       }
00456     }
00457   } catch (...) {
00458     edm::LogInfo("OutputInfo") << " No EB RecHits.";
00459   }
00460 
00461   try {
00462     std::vector<edm::Handle<EERecHitCollection> > colls;
00463     mEvent.getManyByType(colls);
00464     std::vector<edm::Handle<EERecHitCollection> >::iterator i;
00465     for (i=colls.begin(); i!=colls.end(); i++) {
00466       for (EERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00467       }
00468     }
00469   } catch (...) {
00470     edm::LogInfo("OutputInfo") << " No EE RecHits.";
00471   }
00472 
00473   //***********************************
00474   //*** Get the Jet collection
00475   //***********************************
00476   math::XYZTLorentzVector p4tmp[2];
00477   Handle<JPTJetCollection> jptJets;
00478   mEvent.getByLabel(mInputCollection, jptJets);
00479   if (!jptJets.isValid()) return;
00480   JPTJetCollection::const_iterator jet = jptJets->begin ();
00481   int jetIndex = 0;
00482   int nJet = 0;
00483   int nJetF = 0;
00484   int nJetC = 0;
00485   int nJetF_30 =0;
00486   for (; jet != jptJets->end (); jet++, jetIndex++) {
00487     if (jet->pt() > 10.) {
00488       if (fabs(jet->eta()) > 1.5) 
00489         nJetF++;
00490       else 
00491         nJetC++;          
00492     }
00493     if (jet->pt() > 30.) nJetF_30++;
00494     if (jet->pt() > 10.) {
00495       if (mEta) mEta->Fill (jet->eta());
00496       if (mEtaFineBin) mEtaFineBin->Fill (jet->eta());
00497       if (mPhiFineBin) mPhiFineBin->Fill (jet->phi());
00498     }
00499     //if (mjetArea) mjetArea->Fill(jet->jetArea());
00500     if (mPhi) mPhi->Fill (jet->phi());
00501     if (mE) mE->Fill (jet->energy());
00502     if (mE_80) mE_80->Fill (jet->energy());
00503     if (mP) mP->Fill (jet->p());
00504     if (mP_80) mP_80->Fill (jet->p());
00505     if (mPt) mPt->Fill (jet->pt());
00506     if (mPt_80) mPt_80->Fill (jet->pt());
00507     if (mMass) mMass->Fill (jet->mass());
00508     if (mMass_80) mMass_80->Fill (jet->mass());
00509     if (jet == jptJets->begin ()) { // first jet
00510       if (mEtaFirst) mEtaFirst->Fill (jet->eta());
00511       if (mPhiFirst) mPhiFirst->Fill (jet->phi());
00512       if (mPtFirst) mPtFirst->Fill (jet->pt());
00513       if (mPtFirst_80) mPtFirst_80->Fill (jet->pt());
00514       if (mPtFirst_3000) mPtFirst_3000->Fill (jet->pt());
00515     }
00516     if (jetIndex == 0) {
00517       nJet++;
00518       p4tmp[0] = jet->p4();     
00519     }
00520     if (jetIndex == 1) {
00521       nJet++;
00522       p4tmp[1] = jet->p4();     
00523     }
00524 
00525   }
00526 
00527   if (mNJetsEtaC) mNJetsEtaC->Fill( nJetC );
00528   if (mNJetsEtaF) mNJetsEtaF->Fill( nJetF );
00529   if (mNJetsEtaF_30) mNJetsEtaF_30->Fill( nJetF_30 );
00530 
00531   if (nJet == 2) {
00532     if (mMjj) mMjj->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00533     if (mMjj_3000) mMjj_3000->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00534   }
00535 
00536  // Correction jets
00537   const JetCorrector* corrector = JetCorrector::getJetCorrector (JetCorrectionService,mSetup);
00538 
00539   for (JPTJetCollection::const_iterator jet = jptJets->begin(); jet !=jptJets ->end(); jet++) 
00540   {
00541  
00542       JPTJet  correctedJet = *jet;
00543       //double scale = corrector->correction(jet->p4()); 
00544       //double scale = corrector->correction(*jet);
00545       double scale = corrector->correction(*jet,mEvent,mSetup);
00546       correctedJet.scaleEnergy(scale); 
00547       if(correctedJet.pt()>30){
00548       mCorrJetPt->Fill(correctedJet.pt());
00549       mCorrJetPt_80->Fill(correctedJet.pt());  
00550       if (correctedJet.pt()>10) mCorrJetEta->Fill(correctedJet.eta());
00551       mCorrJetPhi->Fill(correctedJet.phi());
00552       mpTRatio->Fill(log10(jet->pt()),correctedJet.pt()/jet->pt());
00553 
00554        if (fabs(jet->eta())<1.5) {
00555            mpTRatioB_d->Fill(log10(jet->pt()), correctedJet.pt()/jet->pt());
00556       }
00557 
00558      if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) {
00559         mpTRatioE_d->Fill (log10(jet->pt()), correctedJet.pt()/jet->pt());
00560      }
00561      if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) {
00562         mpTRatioF_d->Fill (log10(jet->pt()), correctedJet.pt()/jet->pt());
00563     }
00564      if (jet->pt()>30.0 && jet->pt()<200.0) {
00565     mpTRatio_30_200_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00566   }
00567    if (jet->pt()>200.0 && jet->pt()<600.0) {
00568     mpTRatio_200_600_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00569   }
00570    if (jet->pt()>600.0 && jet->pt()<1500.0) {
00571     mpTRatio_600_1500_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00572   }
00573    if (jet->pt()>1500.0 && jet->pt()<3500.0) {
00574     mpTRatio_1500_3500_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00575   }
00576 
00577       }
00578   }
00579   // Count Jets above Pt cut
00580   for (int istep = 0; istep < 100; ++istep) {
00581     int     njet = 0;
00582     float ptStep = (istep * (200./100.));
00583 
00584     for ( JPTJetCollection::const_iterator jpt = jptJets->begin(); jpt != jptJets->end(); ++ jpt ) {
00585       if ( jpt->pt() > ptStep ) njet++;
00586     }
00587     mNJets1->Fill( ptStep, njet );
00588   }
00589 
00590   for (int istep = 0; istep < 100; ++istep) {
00591     int     njet = 0;
00592     float ptStep = (istep * (4000./100.));
00593     for ( JPTJetCollection::const_iterator jpt = jptJets->begin(); jpt != jptJets->end(); ++ jpt ) {
00594       if ( jpt->pt() > ptStep ) njet++;
00595     }
00596     mNJets2->Fill( ptStep, njet );
00597   }
00598 
00599 if (!mEvent.isRealData()){
00600   // Gen jet analysis
00601   Handle<GenJetCollection> genJets;
00602   mEvent.getByLabel(mInputGenCollection, genJets);
00603   if (!genJets.isValid()) return;
00604   GenJetCollection::const_iterator gjet = genJets->begin ();
00605   int gjetIndex = 0;
00606   for (; gjet != genJets->end (); gjet++, gjetIndex++) {
00607     if (mGenEta) mGenEta->Fill (gjet->eta());
00608     if (mGenPhi) mGenPhi->Fill (gjet->phi());
00609     if (mGenPt) mGenPt->Fill (gjet->pt());
00610     if (mGenPt_80) mGenPt_80->Fill (gjet->pt());
00611     if (gjet == genJets->begin ()) { // first jet
00612       if (mGenEtaFirst) mGenEtaFirst->Fill (gjet->eta());
00613       if (mGenPhiFirst) mGenPhiFirst->Fill (gjet->phi());
00614     }
00615   }
00616 
00617 
00618   // now match JPTJets to GenJets
00619   JetMatchingTools jetMatching (mEvent);
00620   if (!(mInputGenCollection.label().empty())) {
00621     //    Handle<GenJetCollection> genJets;
00622     //    mEvent.getByLabel(mInputGenCollection, genJets);
00623 
00624     std::vector <std::vector <const reco::GenParticle*> > genJetConstituents (genJets->size());
00625     std::vector <std::vector <const reco::GenParticle*> > jptJetConstituents (jptJets->size());
00626     
00627     for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {               //****************************************************************
00628     //for (unsigned iGenJet = 0; iGenJet < 1; ++iGenJet) {                           // only FIRST Jet !!!!
00629       const GenJet& genJet = (*genJets) [iGenJet];
00630       double genJetPt = genJet.pt();
00631 
00632       //std::cout << iGenJet <<". Genjet: pT = " << genJetPt << "GeV" << std::endl;  //  *****************************************************
00633 
00634       if (fabs(genJet.eta()) > 6.) continue; // out of detector 
00635       if (genJetPt < mMatchGenPtThreshold) continue; // no low momentum 
00636       //double logPtGen = log10 (genJetPt);
00637       //mAllGenJetsPt->Fill (logPtGen);
00638       //mAllGenJetsEta->Fill (logPtGen, genJet.eta());
00639       if (jptJets->size() <= 0) continue; // no JPTJets - nothing to match
00640       if (mRThreshold > 0) {
00641         unsigned iJPTJetBest = 0;
00642         double deltaRBest = 999.;
00643         for (unsigned iJPTJet = 0; iJPTJet < jptJets->size(); ++iJPTJet) {
00644           double dR = deltaR (genJet.eta(), genJet.phi(), (*jptJets) [iJPTJet].eta(), (*jptJets) [iJPTJet].phi());
00645           if (deltaRBest < mRThreshold && dR < mRThreshold && genJet.pt() > 5.) {
00646             /*
00647             std::cout << "Yet another matched jet for GenJet pt=" << genJet.pt()
00648                       << " previous JPTJet pt/dr: " << (*jptJets) [iJPTJetBest].pt() << '/' << deltaRBest
00649                       << " new JPTJet pt/dr: " << (*jptJets) [iJPTJet].pt() << '/' << dR
00650                       << std::endl;
00651             */
00652           }
00653           if (dR < deltaRBest) {
00654             iJPTJetBest = iJPTJet;
00655             deltaRBest = dR;
00656           }
00657         }
00658         if (mTurnOnEverything.compare("yes")==0) {
00659           //mRMatch->Fill (logPtGen, genJet.eta(), deltaRBest);
00660         }
00661         if (deltaRBest < mRThreshold) { // Matched
00662           fillMatchHists (genJet, (*jptJets) [iJPTJetBest],goodVertices);
00663         }
00664 
00666         double CorrdeltaRBest = 999.;
00667         double CorrJetPtBest = 0;
00668         for (JPTJetCollection::const_iterator jet = jptJets->begin(); jet !=jptJets ->end(); jet++) {
00669           JPTJet  correctedJet = *jet;
00670           //double scale = corrector->correction(jet->p4());
00671           //double scale = corrector->correction(*jet);
00672           double scale = corrector->correction(*jet,mEvent,mSetup);
00673           correctedJet.scaleEnergy(scale);
00674           double CorrJetPt = correctedJet.pt();
00675           if(CorrJetPt>30){
00676           double CorrdR = deltaR (genJet.eta(), genJet.phi(), correctedJet.eta(), correctedJet.phi());
00677           if (CorrdR < CorrdeltaRBest) {
00678             CorrdeltaRBest = CorrdR;
00679             CorrJetPtBest = CorrJetPt;
00680           }
00681         }
00682         }
00683         if (deltaRBest < mRThreshold) { // Matched
00684           mpTResponse->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00685           
00686           if (fabs(genJet.eta())<1.5) {
00687             mpTResponseB_d->Fill(log10(genJet.pt()), CorrJetPtBest/genJet.pt());
00688           }     
00689           
00690           if (fabs(genJet.eta())>1.5 && fabs(genJet.eta())<3.0) {
00691             mpTResponseE_d->Fill (log10(genJet.pt()), CorrJetPtBest/genJet.pt());   
00692           }
00693           
00694           if (fabs(genJet.eta())>3.0 && fabs(genJet.eta())<6.0) {
00695         mpTResponseF_d->Fill (log10(genJet.pt()), CorrJetPtBest/genJet.pt());
00696           }
00697           if (genJet.pt()>30.0 && genJet.pt()<200.0) {
00698             mpTResponse_30_200_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
00699           }
00700           if (genJet.pt()>200.0 && genJet.pt()<600.0) {
00701             mpTResponse_200_600_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
00702           }
00703           if (genJet.pt()>600.0 && genJet.pt()<1500.0) {
00704             mpTResponse_600_1500_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
00705           }
00706           if (genJet.pt()>1500.0 && genJet.pt()<3500.0) {
00707             mpTResponse_1500_3500_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
00708           }
00709           if (genJet.pt()>30.0) {
00710             mpTResponse_30_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
00711           }
00712 
00713           if(goodVertices.size()<=5) mpTResponse_nvtx_0_5->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00714           if(goodVertices.size()>5 && goodVertices.size()<=10) mpTResponse_nvtx_5_10->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00715           if(goodVertices.size()>10 && goodVertices.size()<=15) mpTResponse_nvtx_10_15->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());       
00716           if(goodVertices.size()>15 && goodVertices.size()<=20) mpTResponse_nvtx_15_20->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00717           if(goodVertices.size()>20 && goodVertices.size()<=30) mpTResponse_nvtx_20_30->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00718           if(goodVertices.size()>30) mpTResponse_nvtx_30_inf->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
00719 
00720 
00721         }
00723       }
00724       
00725     }
00726   }
00727 }
00728 
00729 }
00730 
00731 void JPTJetTester::fillMatchHists (const reco::GenJet& fGenJet, const reco::JPTJet& fJPTJet,std::vector<reco::Vertex> goodVertices) {
00732   double logPtGen = log10 (fGenJet.pt());
00733   double PtGen = fGenJet.pt();
00734   double PtJpt = fJPTJet.pt();
00735 
00736   double PtThreshold = 10.;
00737 
00738   if (mTurnOnEverything.compare("yes")==0) {
00739     mDeltaEta->Fill (logPtGen, fGenJet.eta(), fJPTJet.eta()-fGenJet.eta());
00740     mDeltaPhi->Fill (logPtGen, fGenJet.eta(), fJPTJet.phi()-fGenJet.phi());
00741 
00742     mEScaleFineBin->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00743   
00744     if (fGenJet.pt()>PtThreshold) {
00745       mEScale_pt10->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00746 
00747     }
00748 
00749   }
00750   if (fJPTJet.pt() > PtThreshold) {
00751     mDelEta->Fill (fGenJet.eta()-fJPTJet.eta());
00752     mDelPhi->Fill (fGenJet.phi()-fJPTJet.phi());
00753     mDelPt->Fill  ((fGenJet.pt()-fJPTJet.pt())/fGenJet.pt());
00754   }
00755 
00756   if (fabs(fGenJet.eta())<1.5) {
00757 
00758     mpTScaleB_d->Fill (log10(PtGen), PtJpt/PtGen);
00759     mpTScalePhiB_d->Fill (fGenJet.phi(), PtJpt/PtGen);
00760     
00761     if (PtGen>30.0 && PtGen<200.0) {
00762       mpTScale1DB_30_200->Fill (fJPTJet.pt()/fGenJet.pt());
00763     }
00764     if (PtGen>200.0 && PtGen<600.0) {
00765       mpTScale1DB_200_600->Fill (fJPTJet.pt()/fGenJet.pt());
00766     }
00767     if (PtGen>600.0 && PtGen<1500.0) {
00768       mpTScale1DB_600_1500->Fill (fJPTJet.pt()/fGenJet.pt());
00769     }
00770     if (PtGen>1500.0 && PtGen<3500.0) {
00771       mpTScale1DB_1500_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00772     }
00773     
00774   }
00775 
00776   if (fabs(fGenJet.eta())>1.5 && fabs(fGenJet.eta())<3.0) {
00777     mpTScaleE_d->Fill (log10(PtGen), PtJpt/PtGen);
00778     mpTScalePhiE_d->Fill (fGenJet.phi(), PtJpt/PtGen);
00779     
00780     if (PtGen>30.0 && PtGen<200.0) {
00781       mpTScale1DE_30_200->Fill (fJPTJet.pt()/fGenJet.pt());
00782     }
00783     if (PtGen>200.0 && PtGen<600.0) {
00784       mpTScale1DE_200_600->Fill (fJPTJet.pt()/fGenJet.pt());
00785     }
00786     if (PtGen>600.0 && PtGen<1500.0) {
00787       mpTScale1DE_600_1500->Fill (fJPTJet.pt()/fGenJet.pt());
00788     }
00789     if (PtGen>1500.0 && PtGen<3500.0) {
00790       mpTScale1DE_1500_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00791     }
00792     
00793   }
00794 
00795   if (fabs(fGenJet.eta())>3.0 && fabs(fGenJet.eta())<6.0) {
00796 
00797     mpTScaleF_d->Fill (log10(PtGen), PtJpt/PtGen);
00798     mpTScalePhiF_d->Fill (fGenJet.phi(), PtJpt/PtGen);
00799     
00800     if (PtGen>30.0 && PtGen<200.0) {
00801       mpTScale1DF_30_200->Fill (fJPTJet.pt()/fGenJet.pt());
00802     }
00803     if (PtGen>200.0 && PtGen<600.0) {
00804       mpTScale1DF_200_600->Fill (fJPTJet.pt()/fGenJet.pt());
00805     }
00806     if (PtGen>600.0 && PtGen<1500.0) {
00807       mpTScale1DF_600_1500->Fill (fJPTJet.pt()/fGenJet.pt());
00808     }
00809     if (PtGen>1500.0 && PtGen<3500.0) {
00810       mpTScale1DF_1500_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00811     }
00812     
00813   }
00814 
00815   if (fGenJet.pt()>30.0 && fGenJet.pt()<200.0) {
00816     //mpTScale_30_200_s->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00817     mpTScale_30_200_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00818     //mpTScale1D_30_200->Fill (fJPTJet.pt()/fGenJet.pt());
00819   }
00820 
00821   if (fGenJet.pt()>200.0 && fGenJet.pt()<600.0) {
00822     mpTScale_200_600_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00823   }
00824 
00825   if (fGenJet.pt()>600.0 && fGenJet.pt()<1500.0) {
00826     mpTScale_600_1500_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00827   }
00828 
00829   if (fGenJet.pt()>1500.0 && fGenJet.pt()<3500.0) {
00830     mpTScale_1500_3500_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00831   }
00832 
00833   if (fabs(fGenJet.eta())<1.3) {
00834     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00835      if(goodVertices.size()<=5) mpTScale_a_nvtx_0_5->Fill( PtJpt/PtGen);
00836     }
00837     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00838      if(goodVertices.size()<=5) mpTScale_b_nvtx_0_5->Fill( PtJpt/PtGen);
00839     }
00840     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00841      if(goodVertices.size()<=5) mpTScale_c_nvtx_0_5->Fill( PtJpt/PtGen);
00842     }
00843 
00844     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00845      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_a_nvtx_5_10->Fill( PtJpt/PtGen);
00846     }
00847     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00848      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_b_nvtx_5_10->Fill( PtJpt/PtGen);
00849     }
00850     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00851      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_c_nvtx_5_10->Fill( PtJpt/PtGen);
00852     }
00853 
00854     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00855      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_a_nvtx_10_15->Fill( PtJpt/PtGen);
00856     }
00857     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00858      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_b_nvtx_10_15->Fill( PtJpt/PtGen);
00859     }
00860     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00861      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_c_nvtx_10_15->Fill( PtJpt/PtGen);
00862     }
00863 
00864     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00865      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_a_nvtx_15_20->Fill( PtJpt/PtGen);
00866     }
00867     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00868      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_b_nvtx_15_20->Fill( PtJpt/PtGen);
00869     }
00870     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00871      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_c_nvtx_15_20->Fill( PtJpt/PtGen);
00872     }
00873 
00874 if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00875      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_a_nvtx_20_30->Fill( PtJpt/PtGen);
00876     }
00877     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00878      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_b_nvtx_20_30->Fill( PtJpt/PtGen);
00879     }
00880     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00881      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_c_nvtx_20_30->Fill( PtJpt/PtGen);
00882     }
00883 
00884 if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00885      if(goodVertices.size()>30) mpTScale_a_nvtx_30_inf->Fill( PtJpt/PtGen);
00886     }
00887     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00888      if(goodVertices.size()>30) mpTScale_b_nvtx_30_inf->Fill( PtJpt/PtGen);
00889     }
00890     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00891      if(goodVertices.size()>30) mpTScale_c_nvtx_30_inf->Fill( PtJpt/PtGen);
00892     }
00893 
00894     if(goodVertices.size()<=5) mpTScale_nvtx_0_5->Fill(log10(PtGen),PtJpt/PtGen);
00895     if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_nvtx_5_10->Fill(log10(PtGen),PtJpt/PtGen);
00896     if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_nvtx_10_15->Fill(log10(PtGen),PtJpt/PtGen);
00897     if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_nvtx_15_20->Fill(log10(PtGen), PtJpt/PtGen);
00898     if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_nvtx_20_30->Fill(log10(PtGen), PtJpt/PtGen);
00899     if(goodVertices.size()>30) mpTScale_nvtx_30_inf->Fill(log10(PtGen), PtJpt/PtGen);
00900 }
00901   if (fabs(fGenJet.eta())<1.3) {
00902   if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) mpTScale_a->Fill(PtJpt/PtGen);
00903   if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) mpTScale_b->Fill(PtJpt/PtGen);
00904   if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) mpTScale_c->Fill(PtJpt/PtGen);
00905   }
00906   mpTScale_pT->Fill (log10(PtGen), PtJpt/PtGen);
00907 
00908 }
00909 
00910 double JPTJetTester::getSumPt(const reco::TrackRefVector& tracks){
00911 
00912   double sumpt = 0.;
00913   
00914   for (reco::TrackRefVector::const_iterator itrack = tracks.begin(); itrack != tracks.end(); ++itrack){
00915     const reco::Track& track = **itrack;
00916     sumpt += track.pt(); 
00917   }
00918   
00919   return sumpt;
00920 
00921 }