CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Validation/RecoJets/plugins/PFJetTester.cc

Go to the documentation of this file.
00001 // Producer for validation histograms for CaloJet objects
00002 // F. Ratnikov, Sept. 7, 2006
00003 // Modified by J F Novak July 10, 2008
00004 // $Id: PFJetTester.cc,v 1.32 2013/01/01 21:46:23 kovitang Exp $
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "DataFormats/Common/interface/Handle.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/ServiceRegistry/interface/Service.h"
00011 
00012 #include "DataFormats/Math/interface/deltaR.h"
00013 
00014 #include "DQMServices/Core/interface/DQMStore.h"
00015 #include "DQMServices/Core/interface/MonitorElement.h"
00016 
00017 #include "DataFormats/JetReco/interface/PFJet.h"
00018 #include "DataFormats/JetReco/interface/GenJet.h"
00019 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00020 
00021 //I don't know which of these I actually need yet
00022 #include "DataFormats/METReco/interface/CaloMET.h"
00023 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00024 #include "DataFormats/METReco/interface/GenMET.h"
00025 #include "DataFormats/METReco/interface/GenMETCollection.h"
00026 #include "DataFormats/METReco/interface/MET.h"
00027 #include "DataFormats/METReco/interface/METCollection.h"
00028 
00029 #include "RecoJets/JetProducers/interface/JetMatchingTools.h"
00030 
00031 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00032 
00033 #include "PFJetTester.h"
00034 
00035 #include <cmath>
00036 
00037 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00038 
00039 using namespace edm;
00040 using namespace reco;
00041 using namespace std;
00042 
00043 namespace {
00044   bool is_B (const reco::Jet& fJet) {return fabs (fJet.eta()) < 1.3;}
00045   bool is_E (const reco::Jet& fJet) {return fabs (fJet.eta()) >= 1.3 && fabs (fJet.eta()) < 3.;}
00046   bool is_F (const reco::Jet& fJet) {return fabs (fJet.eta()) >= 3.;}
00047 }
00048 
00049 PFJetTester::PFJetTester(const edm::ParameterSet& iConfig)
00050   : mInputCollection (iConfig.getParameter<edm::InputTag>( "src" )),
00051     mInputGenCollection (iConfig.getParameter<edm::InputTag>( "srcGen" )),
00052     mOutputFile (iConfig.getUntrackedParameter<std::string>("outputFile", "")),
00053     mMatchGenPtThreshold (iConfig.getParameter<double>("genPtThreshold")),
00054     mGenEnergyFractionThreshold (iConfig.getParameter<double>("genEnergyFractionThreshold")),
00055     mReverseEnergyFractionThreshold (iConfig.getParameter<double>("reverseEnergyFractionThreshold")),
00056     mRThreshold (iConfig.getParameter<double>("RThreshold")),
00057     JetCorrectionService  (iConfig.getParameter<std::string>  ("JetCorrectionService"  )),
00058     mTurnOnEverything (iConfig.getUntrackedParameter<std::string>("TurnOnEverything",""))
00059 {
00060     numberofevents
00061     = mEta = mEtaFineBin = mPhi = mPhiFineBin = mE = mE_80
00062     = mP = mP_80 = mPt = mPt_80
00063     = mMass = mMass_80 = mConstituents = mConstituents_80
00064     = mEtaFirst = mPhiFirst = mPtFirst = mPtFirst_80 = mPtFirst_3000
00065     = mMjj = mMjj_3000 = mDelEta = mDelPhi = mDelPt 
00066       //    = mMaxEInEmTowers = mMaxEInHadTowers 
00067       //    = mHadEnergyInHO = mHadEnergyInHB = mHadEnergyInHE 
00068       = mHadEnergyInHF = mHadEnergyInHF_80 = mHadEnergyInHF_3000
00069       //    = mHadEnergyInHO_80 = mHadEnergyInHB_80 = mHadEnergyInHE_80 
00070       //    = mHadEnergyInHO_3000 = mHadEnergyInHB_3000 = mHadEnergyInHE_3000 
00071       //    = mEmEnergyInEB = mEmEnergyInEE
00072       = mEmEnergyInHF = mEmEnergyInHF_80 = mEmEnergyInHF_3000
00073       //    = mEmEnergyInEB_80 = mEmEnergyInEE_80
00074       //    = mEmEnergyInEB_3000 = mEmEnergyInEE_3000
00075       //    = mEnergyFractionHadronic = mEnergyFractionEm 
00076       //    = mHFLong = mHFTotal = mHFLong_80 = mHFLong_3000 = mHFShort = mHFShort_80 = mHFShort_3000
00077       //    = mN90
00078     = mChargedEmEnergy_80 = mChargedHadronEnergy_80 = mNeutralEmEnergy_80 = mNeutralHadronEnergy_80
00079     = mChargedEmEnergy_3000 = mChargedHadronEnergy_3000 = mNeutralEmEnergy_3000 = mNeutralHadronEnergy_3000
00080     = mChargedEmEnergyFraction_B = mChargedEmEnergyFraction_E = mChargedEmEnergyFraction_F 
00081     = mChargedHadronEnergyFraction_B = mChargedHadronEnergyFraction_E = mChargedHadronEnergyFraction_F 
00082     = mNeutralEmEnergyFraction_B = mNeutralEmEnergyFraction_E = mNeutralEmEnergyFraction_F
00083     = mNeutralHadronEnergyFraction_B = mNeutralHadronEnergyFraction_E = mNeutralHadronEnergyFraction_F
00084       //= mCaloMEx = mCaloMEx_3000 = mCaloMEy = mCaloMEy_3000 = mCaloMETSig = mCaloMETSig_3000
00085       //= mCaloMET = mCaloMET_3000 =  mCaloMETPhi = mCaloSumET  = mCaloSumET_3000   
00086     = mHadTiming = mEmTiming 
00087     = mNJetsEtaC = mNJetsEtaF = mNJets1 = mNJets2
00088       //= mAllGenJetsPt = mMatchedGenJetsPt = mAllGenJetsEta = mMatchedGenJetsEta 
00089       //= mGenJetMatchEnergyFraction = mReverseMatchEnergyFraction = mRMatch
00090       = mDeltaEta = mDeltaPhi //= mEScale = mlinEScale = mDeltaE
00091       //= mHadEnergyProfile = mEmEnergyProfile = mJetEnergyProfile 
00092       //    = mHadJetEnergyProfile = mEMJetEnergyProfile
00093     = mEScale_pt10 = mEScaleFineBin
00094       //= mpTScaleB_s = mpTScaleE_s = mpTScaleF_s 
00095     = mpTScaleB_d = mpTScaleE_d = mpTScaleF_d
00096      = mpTScalePhiB_d = mpTScalePhiE_d = mpTScalePhiF_d
00097       //= mpTScale_30_200_s = mpTScale_200_600_s = mpTScale_600_1500_s = mpTScale_1500_3500_s
00098     = mpTScale_30_200_d = mpTScale_200_600_d = mpTScale_600_1500_d = mpTScale_1500_3500_d
00099       
00100     = mpTScale1DB_30_200    = mpTScale1DE_30_200    = mpTScale1DF_30_200 
00101     = mpTScale1DB_200_600   = mpTScale1DE_200_600   = mpTScale1DF_200_600 
00102     = mpTScale1DB_600_1500   = mpTScale1DE_600_1500   = mpTScale1DF_600_1500 
00103     = mpTScale1DB_1500_3500 = mpTScale1DE_1500_3500 = mpTScale1DF_1500_3500
00104         /*
00105     = mpTScale1D_30_200 = mpTScale1D_200_600 = mpTScale1D_600_1500 = mpTScale1D_1500_3500
00106     = mHBEne = mHBTime = mHEEne = mHETime = mHFEne = mHFTime = mHOEne = mHOTime
00107     = mEBEne = mEBTime = mEEEne = mEETime 
00108       */
00109     = mPthat_80 = mPthat_3000
00110 
00111       //Corr Jet
00112     = mCorrJetPt =mCorrJetPt_80 =mCorrJetEta =mCorrJetPhi =mpTRatio =mpTResponse
00113       = mpTRatioB_d = mpTRatioE_d = mpTRatioF_d
00114       = mpTRatio_30_200_d = mpTRatio_200_600_d = mpTRatio_600_1500_d = mpTRatio_1500_3500_d
00115       = mpTResponseB_d = mpTResponseE_d = mpTResponseF_d
00116       = mpTResponse_30_200_d = mpTResponse_200_600_d = mpTResponse_600_1500_d = mpTResponse_1500_3500_d
00117       = mpTResponse_30_d =mjetArea
00118       = nvtx_0_30 = nvtx_0_60
00119       = mpTResponse_nvtx_0_5 = mpTResponse_nvtx_5_10 =mpTResponse_nvtx_10_15 
00120       = mpTResponse_nvtx_15_20 = mpTResponse_nvtx_20_30 = mpTResponse_nvtx_30_inf
00121       = mpTScale_a_nvtx_0_5 = mpTScale_b_nvtx_0_5 = mpTScale_c_nvtx_0_5 
00122       = mpTScale_a_nvtx_5_10 = mpTScale_b_nvtx_5_10 = mpTScale_c_nvtx_5_10
00123       = mpTScale_a_nvtx_10_15 = mpTScale_b_nvtx_10_15 = mpTScale_c_nvtx_10_15
00124       = mpTScale_a_nvtx_15_20 = mpTScale_b_nvtx_15_20 = mpTScale_c_nvtx_15_20
00125       = mpTScale_a_nvtx_20_30 = mpTScale_b_nvtx_20_30 = mpTScale_c_nvtx_20_30
00126       = mpTScale_a_nvtx_30_inf = mpTScale_b_nvtx_30_inf = mpTScale_c_nvtx_30_inf
00127       = mpTScale_nvtx_0_5 = mpTScale_nvtx_5_10 = mpTScale_nvtx_10_15 
00128       = mpTScale_nvtx_15_20 = mpTScale_nvtx_20_30 = mpTScale_nvtx_30_inf
00129       = mNJetsEtaF_30
00130       = mpTScale_a = mpTScale_b = mpTScale_c = mpTScale_pT
00131       = 0;
00132   
00133   DQMStore* dbe = &*edm::Service<DQMStore>();
00134   if (dbe) {
00135     dbe->setCurrentFolder("JetMET/RecoJetsV/PFJetTask_" + mInputCollection.label());
00136     //
00137     numberofevents    = dbe->book1D("numberofevents","numberofevents", 3, 0 , 2);
00138     //
00139     mEta              = dbe->book1D("Eta", "Eta", 120, -6, 6); 
00140     mEtaFineBin       = dbe->book1D("EtaFineBin_Pt10", "EtaFineBin_Pt10", 600, -6, 6);
00141     /* 
00142     mEtaFineBin1p     = dbe->book1D("EtaFineBin1p_Pt10", "EtaFineBin1p_Pt10", 100, 0, 1.3); 
00143     mEtaFineBin2p     = dbe->book1D("EtaFineBin2p_Pt10", "EtaFineBin2p_Pt10", 100, 1.3, 3); 
00144     mEtaFineBin3p     = dbe->book1D("EtaFineBin3p_Pt10", "EtaFineBin3p_Pt10", 100, 3, 5); 
00145     mEtaFineBin1m     = dbe->book1D("EtaFineBin1m_Pt10", "EtaFineBin1m_Pt10", 100, -1.3, 0); 
00146     mEtaFineBin2m     = dbe->book1D("EtaFineBin2m_Pt10", "EtaFineBin2m_Pt10", 100, -3, -1.3); 
00147     mEtaFineBin3m     = dbe->book1D("EtaFineBin3m_Pt10", "EtaFineBin3m_Pt10", 100, -5, -3);
00148     */ 
00149     //
00150     mPhi              = dbe->book1D("Phi", "Phi", 70, -3.5, 3.5); 
00151     mPhiFineBin       = dbe->book1D("PhiFineBin_Pt10", "PhiFineBin_Pt10", 350, -3.5, 3.5); 
00152     //
00153     mE                = dbe->book1D("E", "E", 100, 0, 500); 
00154     mE_80             = dbe->book1D("E_80", "E_80", 100, 0, 4000);  
00155     //
00156     mP                = dbe->book1D("P", "P", 100, 0, 500); 
00157     mP_80             = dbe->book1D("P_80", "P_80", 100, 0, 4000); 
00158     //
00159     mPt               = dbe->book1D("Pt", "Pt", 100, 0, 150); 
00160     mPt_80            = dbe->book1D("Pt_80", "Pt_80", 100, 0, 4000);  
00161     //
00162     mMass             = dbe->book1D("Mass", "Mass", 100, 0, 200); 
00163     mMass_80          = dbe->book1D("Mass_80", "Mass_80", 100, 0, 500);  
00164     //
00165     mConstituents     = dbe->book1D("Constituents", "# of Constituents", 100, 0, 100); 
00166     mConstituents_80  = dbe->book1D("Constituents_80", "# of Constituents_80", 40, 0, 40); 
00167     //
00168     mEtaFirst         = dbe->book1D("EtaFirst", "EtaFirst", 120, -6, 6); 
00169     mPhiFirst         = dbe->book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);      
00170     mPtFirst          = dbe->book1D("PtFirst", "PtFirst", 100, 0, 50); 
00171     mPtFirst_80       = dbe->book1D("PtFirst_80", "PtFirst_80", 100, 0, 140);
00172     mPtFirst_3000     = dbe->book1D("PtFirst_3000", "PtFirst_3000", 100, 0, 4000);
00173     //
00174     mMjj              = dbe->book1D("Mjj", "Mjj", 100, 0, 2000); 
00175     mMjj_3000         = dbe->book1D("Mjj_3000", "Mjj_3000", 100, 0, 10000); 
00176     mDelEta           = dbe->book1D("DelEta", "DelEta", 100, -.5, .5); 
00177     mDelPhi           = dbe->book1D("DelPhi", "DelPhi", 100, -.5, .5); 
00178     mDelPt            = dbe->book1D("DelPt", "DelPt", 100, -1, 1); 
00179     //
00180     //    mMaxEInEmTowers   = dbe->book1D("MaxEInEmTowers", "MaxEInEmTowers", 100, 0, 100); 
00181     //    mMaxEInHadTowers  = dbe->book1D("MaxEInHadTowers", "MaxEInHadTowers", 100, 0, 100); 
00182     //    mHadEnergyInHO    = dbe->book1D("HadEnergyInHO", "HadEnergyInHO", 100, 0, 10); 
00183     //    mHadEnergyInHB    = dbe->book1D("HadEnergyInHB", "HadEnergyInHB", 100, 0, 50); 
00184     mHadEnergyInHF    = dbe->book1D("HadEnergyInHF", "HadEnergyInHF", 100, 0, 2500); 
00185     mHadEnergyInHF_80    = dbe->book1D("HadEnergyInHF_80", "HadEnergyInHF_80", 100, 0, 3000); 
00186     mHadEnergyInHF_3000    = dbe->book1D("HadEnergyInHF_3000", "HadEnergyInHF_3000", 100, 0, 1800); 
00187     //    mHadEnergyInHE    = dbe->book1D("HadEnergyInHE", "HadEnergyInHE", 100, 0, 100); 
00188     //
00189     //    mHadEnergyInHO_80    = dbe->book1D("HadEnergyInHO_80", "HadEnergyInHO_80", 100, 0, 50); 
00190     //    mHadEnergyInHB_80    = dbe->book1D("HadEnergyInHB_80", "HadEnergyInHB_80", 100, 0, 200); 
00191     //    mHadEnergyInHE_80    = dbe->book1D("HadEnergyInHE_80", "HadEnergyInHE_80", 100, 0, 1000); 
00192     //    mHadEnergyInHO_3000  = dbe->book1D("HadEnergyInHO_3000", "HadEnergyInHO_3000", 100, 0, 500); 
00193     //    mHadEnergyInHB_3000  = dbe->book1D("HadEnergyInHB_3000", "HadEnergyInHB_3000", 100, 0, 3000); 
00194     //    mHadEnergyInHE_3000  = dbe->book1D("HadEnergyInHE_3000", "HadEnergyInHE_3000", 100, 0, 2000); 
00195     //
00196     //    mEmEnergyInEB     = dbe->book1D("EmEnergyInEB", "EmEnergyInEB", 100, 0, 50); 
00197     //    mEmEnergyInEE     = dbe->book1D("EmEnergyInEE", "EmEnergyInEE", 100, 0, 50); 
00198     mEmEnergyInHF     = dbe->book1D("EmEnergyInHF", "EmEnergyInHF", 100, -20, 450); 
00199     mEmEnergyInHF_80     = dbe->book1D("EmEnergyInHF_80", "EmEnergyInHF_80", 100, -20, 440); 
00200     mEmEnergyInHF_3000     = dbe->book1D("EmEnergyInHF_3000", "EmEnergyInHF_3000", 100, -20, 190); 
00201     //    mEmEnergyInEB_80  = dbe->book1D("EmEnergyInEB_80", "EmEnergyInEB_80", 100, 0, 200); 
00202     //    mEmEnergyInEE_80  = dbe->book1D("EmEnergyInEE_80", "EmEnergyInEE_80", 100, 0, 1000); 
00203     //    mEmEnergyInEB_3000= dbe->book1D("EmEnergyInEB_3000", "EmEnergyInEB_3000", 100, 0, 3000); 
00204     //    mEmEnergyInEE_3000= dbe->book1D("EmEnergyInEE_3000", "EmEnergyInEE_3000", 100, 0, 2000); 
00205     //    mEnergyFractionHadronic = dbe->book1D("EnergyFractionHadronic", "EnergyFractionHadronic", 120, -0.1, 1.1); 
00206     //    mEnergyFractionEm = dbe->book1D("EnergyFractionEm", "EnergyFractionEm", 120, -0.1, 1.1); 
00207     //
00208     //    mHFTotal          = dbe->book1D("HFTotal", "HFTotal", 100, 0, 500);
00209     //    mHFTotal_80       = dbe->book1D("HFTotal_80", "HFTotal_80", 100, 0, 3000);
00210     //    mHFTotal_3000     = dbe->book1D("HFTotal_3000", "HFTotal_3000", 100, 0, 6000);
00211     //    mHFLong           = dbe->book1D("HFLong", "HFLong", 100, 0, 500);
00212     //    mHFLong_80        = dbe->book1D("HFLong_80", "HFLong_80", 100, 0, 200);
00213     //    mHFLong_3000      = dbe->book1D("HFLong_3000", "HFLong_3000", 100, 0, 1500);
00214     //    mHFShort          = dbe->book1D("HFShort", "HFShort", 100, 0, 500);
00215     //    mHFShort_80       = dbe->book1D("HFShort_80", "HFShort_80", 100, 0, 200);
00216     //    mHFShort_3000     = dbe->book1D("HFShort_3000", "HFShort_3000", 100, 0, 1500);
00217     //
00218     //    mN90              = dbe->book1D("N90", "N90", 50, 0, 50); 
00219     //
00220 
00221     mChargedEmEnergy_80 = dbe->book1D("ChargedEmEnergy_80","ChargedEmEnergy_80",100,0.,500.);
00222     mChargedHadronEnergy_80 = dbe->book1D("ChargedHadronEnergy_80","ChargedHadronEnergy_80",100,0.,500.);
00223     mNeutralEmEnergy_80 = dbe->book1D("NeutralEmEnergy_80","NeutralEmEnergy_80",100,0.,500.);
00224     mNeutralHadronEnergy_80 = dbe->book1D("NeutralHadronEnergy_80","NeutralHadronEnergy_80",100,0.,500.);
00225 
00226     mChargedEmEnergy_3000 = dbe->book1D("ChargedEmEnergy_3000","ChargedEmEnergy_3000",100,0.,2000.);
00227     mChargedHadronEnergy_3000 = dbe->book1D("ChargedHadronEnergy_3000","ChargedHadronEnergy_3000",100,0.,2000.);
00228     mNeutralEmEnergy_3000 = dbe->book1D("NeutralEmEnergy_3000","NeutralEmEnergy_3000",100,0.,2000.);
00229     mNeutralHadronEnergy_3000 = dbe->book1D("NeutralHadronEnergy_3000","NeutralHadronEnergy_3000",100,0.,2000.);
00230 
00231     mChargedEmEnergyFraction_B = dbe->book1D("ChargedEmEnergyFraction_B","ChargedEmEnergyFraction_B",120,-0.1,1.1);
00232     mChargedEmEnergyFraction_E = dbe->book1D("ChargedEmEnergyFraction_E","ChargedEmEnergyFraction_E",120,-0.1,1.1);
00233     mChargedEmEnergyFraction_F = dbe->book1D("ChargedEmEnergyFraction_F","ChargedEmEnergyFraction_F",120,-0.1,1.1);
00234     mChargedHadronEnergyFraction_B = dbe->book1D("ChargedHadronEnergyFraction_B","ChargedHadronEnergyFraction_B",120,-0.1,1.1);
00235     mChargedHadronEnergyFraction_E = dbe->book1D("ChargedHadronEnergyFraction_E","ChargedHadronEnergyFraction_E",120,-0.1,1.1);
00236     mChargedHadronEnergyFraction_F = dbe->book1D("ChargedHadronEnergyFraction_F","ChargedHadronEnergyFraction_F",120,-0.1,1.1);
00237     mNeutralEmEnergyFraction_B = dbe->book1D("NeutralEmEnergyFraction_B","NeutralEmEnergyFraction_B",120,-0.1,1.1);
00238     mNeutralEmEnergyFraction_E = dbe->book1D("NeutralEmEnergyFraction_E","NeutralEmEnergyFraction_E",120,-0.1,1.1);
00239     mNeutralEmEnergyFraction_F = dbe->book1D("NeutralEmEnergyFraction_F","NeutralEmEnergyFraction_F",120,-0.1,1.1);
00240     mNeutralHadronEnergyFraction_B = dbe->book1D("NeutralHadronEnergyFraction_B","NeutralHadronEnergyFraction_B",120,-0.1,1.1);
00241     mNeutralHadronEnergyFraction_E = dbe->book1D("NeutralHadronEnergyFraction_E","NeutralHadronEnergyFraction_E",120,-0.1,1.1);
00242     mNeutralHadronEnergyFraction_F = dbe->book1D("NeutralHadronEnergyFraction_F","NeutralHadronEnergyFraction_F",120,-0.1,1.1);
00243 
00244     mGenEta           = dbe->book1D("GenEta", "GenEta", 120, -6, 6);
00245     mGenPhi           = dbe->book1D("GenPhi", "GenPhi", 70, -3.5, 3.5);
00246     mGenPt            = dbe->book1D("GenPt", "GenPt", 100, 0, 150);
00247     mGenPt_80         = dbe->book1D("GenPt_80", "GenPt_80", 100, 0, 1500);
00248     //
00249     mGenEtaFirst      = dbe->book1D("GenEtaFirst", "GenEtaFirst", 100, -5, 5);
00250     mGenPhiFirst      = dbe->book1D("GenPhiFirst", "GenPhiFirst", 70, -3.5, 3.5);
00251     //
00252     /*
00253     mCaloMEx          = dbe->book1D("CaloMEx","CaloMEx",200,-150,150);
00254     mCaloMEx_3000     = dbe->book1D("CaloMEx_3000","CaloMEx_3000",100,-500,500);
00255     mCaloMEy          = dbe->book1D("CaloMEy","CaloMEy",200,-150,150);
00256     mCaloMEy_3000     = dbe->book1D("CaloMEy_3000","CaloMEy_3000",100,-500,500);
00257     mCaloMETSig       = dbe->book1D("CaloMETSig","CaloMETSig",100,0,15);
00258     mCaloMETSig_3000  = dbe->book1D("CaloMETSig_3000","CaloMETSig_3000",100,0,50);
00259     mCaloMET          = dbe->book1D("CaloMET","CaloMET",100,0,150);
00260     mCaloMET_3000     = dbe->book1D("CaloMET_3000","CaloMET_3000",100,0,1000);
00261     mCaloMETPhi       = dbe->book1D("CaloMETPhi","CaloMETPhi",70, -3.5, 3.5);
00262     mCaloSumET        = dbe->book1D("CaloSumET","CaloSumET",100,0,500);
00263     mCaloSumET_3000   = dbe->book1D("CaloSumET_3000","CaloSumET_3000",100,3000,8000);
00264     */
00265     //
00266     mHadTiming        = dbe->book1D("HadTiming", "HadTiming", 75, -50, 100);
00267     mEmTiming         = dbe->book1D("EMTiming", "EMTiming", 75, -50, 100);
00268     //
00269     mNJetsEtaC        = dbe->book1D("NJetsEtaC_Pt10", "NJetsEtaC_Pt10", 15, 0, 15);
00270     mNJetsEtaF        = dbe->book1D("NJetsEtaF_Pt10", "NJetsEtaF_Pt10", 15, 0, 15);
00271     mNJetsEtaF_30        = dbe->book1D("NJetsEtaF_Pt30", "NJetsEtaF_Pt30", 15, 0, 15);
00272     //
00273     mNJets1           = dbe->bookProfile("NJets1", "NJets1", 100, 0, 200,  100, 0, 50, "s");
00274     mNJets2           = dbe->bookProfile("NJets2", "NJets2", 100, 0, 4000, 100, 0, 50, "s");
00275     //
00276     /*
00277     mHBEne     = dbe->book1D( "HBEne",  "HBEne", 1000, -20, 100 );
00278     mHBTime    = dbe->book1D( "HBTime", "HBTime", 200, -200, 200 );
00279     mHEEne     = dbe->book1D( "HEEne",  "HEEne", 1000, -20, 100 );
00280     mHETime    = dbe->book1D( "HETime", "HETime", 200, -200, 200 );
00281     mHOEne     = dbe->book1D( "HOEne",  "HOEne", 1000, -20, 100 );
00282     mHOTime    = dbe->book1D( "HOTime", "HOTime", 200, -200, 200 );
00283     mHFEne     = dbe->book1D( "HFEne",  "HFEne", 1000, -20, 100 );
00284     mHFTime    = dbe->book1D( "HFTime", "HFTime", 200, -200, 200 );
00285     mEBEne     = dbe->book1D( "EBEne",  "EBEne", 1000, -20, 100 );
00286     mEBTime    = dbe->book1D( "EBTime", "EBTime", 200, -200, 200 );
00287     mEEEne     = dbe->book1D( "EEEne",  "EEEne", 1000, -20, 100 );
00288     mEETime    = dbe->book1D( "EETime", "EETime", 200, -200, 200 );
00289     */
00290     //
00291     mPthat_80            = dbe->book1D("Pthat_80", "Pthat_80", 100, 0.0, 1000.0); 
00292     mPthat_3000          = dbe->book1D("Pthat_3000", "Pthat_3000", 100, 1000.0, 4000.0); 
00293 
00294     //Corr
00295     mCorrJetPt  = dbe->book1D("CorrPt", "CorrPt", 100, 0, 150);
00296     mCorrJetPt_80 = dbe->book1D("CorrPt_80", "CorrPt_80", 100, 0, 4000);
00297     mCorrJetEta = dbe->book1D("CorrEta", "CorrEta", 120, -6, 6);
00298     mCorrJetPhi = dbe->book1D("CorrPhi", "CorrPhi", 70, -3.5, 3.5);
00299 
00300     mjetArea = dbe->book1D("jetArea","jetArea",26,-0.5,12.5);
00301 
00302     //nvtx
00303     nvtx_0_30 = dbe->book1D("nvtx_0_30","nvtx_0_30",31,-0.5,30.5);
00304     nvtx_0_60 = dbe->book1D("nvtx_0_60","nvtx_0_60",61,-0.5,60.5);
00305 
00306     //pT scale with nvtx
00307     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);
00308     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);
00309     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);
00310     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);
00311     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);
00312     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);
00313     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);
00314     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);
00315     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);
00316     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);
00317     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);
00318     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);
00319     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);
00320     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);
00321     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);
00322     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);
00323     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);
00324     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);
00325     mpTScale_a = dbe->book1D("mpTScale_a", "pTScale_a_60_120",100, 0, 2);
00326     mpTScale_b = dbe->book1D("mpTScale_b", "pTScale_b_200_300",100, 0, 2);
00327     mpTScale_c = dbe->book1D("mpTScale_c", "pTScale_c_600_900",100, 0, 2);
00328     //
00329     double log10PtMin = 0.5; //=3.1622766
00330     double log10PtMax = 3.75; //=5623.41325
00331     int log10PtBins = 26; 
00332     //double etaMin = -6.;
00333     //double etaMax = 6.;
00334     //int etaBins = 50;
00335     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};
00336 
00337     //double linPtMin = 5;
00338     //double linPtMax = 155;
00339     //int linPtBins = 15;
00340 
00341     //int log10PtFineBins = 50;
00342     /*
00343     mAllGenJetsPt = dbe->book1D("GenJetLOGpT", "GenJet LOG(pT_gen)", 
00344                                 log10PtBins, log10PtMin, log10PtMax);
00345     mMatchedGenJetsPt = dbe->book1D("MatchedGenJetLOGpT", "MatchedGenJet LOG(pT_gen)", 
00346                                     log10PtBins, log10PtMin, log10PtMax);
00347     mAllGenJetsEta = dbe->book2D("GenJetEta", "GenJet Eta vs LOG(pT_gen)", 
00348                                  log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax);
00349     mMatchedGenJetsEta = dbe->book2D("MatchedGenJetEta", "MatchedGenJet Eta vs LOG(pT_gen)", 
00350                                      log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax);
00351     */
00352     //
00353     if (mTurnOnEverything.compare("yes")==0) {
00354       /*
00355       mHadEnergyProfile = dbe->bookProfile2D("HadEnergyProfile", "HadEnergyProfile", 82, -41, 41, 73, 0, 73, 100, 0, 10000, "s");
00356       mEmEnergyProfile  = dbe->bookProfile2D("EmEnergyProfile", "EmEnergyProfile", 82, -41, 41, 73, 0, 73, 100, 0, 10000, "s");
00357       */
00358     }
00359     //mJetEnergyProfile = dbe->bookProfile2D("JetEnergyProfile", "JetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00360     //    mHadJetEnergyProfile = dbe->bookProfile2D("HadJetEnergyProfile", "HadJetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00361     //    mEMJetEnergyProfile = dbe->bookProfile2D("EMJetEnergyProfile", "EMJetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00362     //
00363     if (mTurnOnEverything.compare("yes")==0) {
00364       /*
00365     mGenJetMatchEnergyFraction  = dbe->book3D("GenJetMatchEnergyFraction", "GenJetMatchEnergyFraction vs LOG(pT_gen) vs eta", 
00366                                               log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 101, 0, 1.01);
00367     mReverseMatchEnergyFraction  = dbe->book3D("ReverseMatchEnergyFraction", "ReverseMatchEnergyFraction vs LOG(pT_gen) vs eta", 
00368                                                log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 101, 0, 1.01);
00369     mRMatch  = dbe->book3D("RMatch", "delta(R)(Gen-Calo) vs LOG(pT_gen) vs eta", 
00370                            log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 30, 0, 3);
00371       */
00372 /*
00373     mDeltaEta = dbe->book3D("DeltaEta", "DeltaEta vs LOG(pT_gen) vs eta", 
00374                               log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, -1, 1);
00375     mDeltaPhi = dbe->book3D("DeltaPhi", "DeltaPhi vs LOG(pT_gen) vs eta", 
00376                               log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, -1, 1);
00377 */  
00378   /*
00379     mEScale = dbe->book3D("EScale", "EnergyScale vs LOG(pT_gen) vs eta", 
00380                             log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00381     mlinEScale = dbe->book3D("linEScale", "EnergyScale vs LOG(pT_gen) vs eta", 
00382                             linPtBins, linPtMin, linPtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00383     mDeltaE = dbe->book3D("DeltaE", "DeltaE vs LOG(pT_gen) vs eta", 
00384                             log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 2000, -200, 200);
00385     */
00386     //
00387    /* mEScale_pt10 = dbe->book3D("EScale_pt10", "EnergyScale vs LOG(pT_gen) vs eta", 
00388                             log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00389     mEScaleFineBin = dbe->book3D("EScaleFineBins", "EnergyScale vs LOG(pT_gen) vs eta", 
00390                             log10PtFineBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00391 */  
00392   }
00393     /*
00394     mpTScaleB_s = dbe->bookProfile("pTScaleB_s", "pTScale_s_0<|eta|<1.3",
00395                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00396     mpTScaleE_s = dbe->bookProfile("pTScaleE_s", "pTScale_s_1.3<|eta|<3.0",
00397                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00398     mpTScaleF_s = dbe->bookProfile("pTScaleF_s", "pTScale_s_3.0<|eta|<5.0",
00399                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00400     */
00401     mpTScaleB_d = dbe->bookProfile("pTScaleB_d", "pTScale_d_0<|eta|<1.5",
00402                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00403     mpTScaleE_d = dbe->bookProfile("pTScaleE_d", "pTScale_d_1.5<|eta|<3.0",
00404                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00405     mpTScaleF_d = dbe->bookProfile("pTScaleF_d", "pTScale_d_3.0<|eta|<6.0",
00406                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00407     mpTScalePhiB_d = dbe->bookProfile("pTScalePhiB_d", "pTScalePhi_d_0<|eta|<1.5",
00408                                    70, -3.5, 3.5, 0, 2, " ");
00409     mpTScalePhiE_d = dbe->bookProfile("pTScalePhiE_d", "pTScalePhi_d_1.5<|eta|<3.0",
00410                                    70, -3.5, 3.5, 0, 2, " ");
00411     mpTScalePhiF_d = dbe->bookProfile("pTScalePhiF_d", "pTScalePhi_d_3.0<|eta|<6.0",
00412                                       70, -3.5, 3.5, 0, 2, " ");
00413     /*
00414     mpTScale_30_200_s    = dbe->bookProfile("pTScale_30_200_s", "pTScale_s_30<pT<200",
00415                                           etaBins, etaMin, etaMax, 0., 2., "s");
00416     mpTScale_200_600_s   = dbe->bookProfile("pTScale_200_600_s", "pTScale_s_200<pT<600",
00417                                           etaBins, etaMin, etaMax, 0., 2., "s");
00418     mpTScale_600_1500_s   = dbe->bookProfile("pTScale_600_1500_s", "pTScale_s_600<pT<1500",
00419                                           etaBins, etaMin, etaMax, 0., 2., "s");
00420     mpTScale_1500_3500_s = dbe->bookProfile("pTScale_1500_3500_s", "pTScale_s_1500<pt<3500",
00421                                           etaBins, etaMin, etaMax, 0., 2., "s");
00422     */
00423     mpTScale_30_200_d    = dbe->bookProfile("pTScale_30_200_d", "pTScale_d_30<pT<200",
00424                                           90,etaRange, 0., 2., " ");
00425     mpTScale_200_600_d   = dbe->bookProfile("pTScale_200_600_d", "pTScale_d_200<pT<600",
00426                                           90,etaRange, 0., 2., " ");
00427     mpTScale_600_1500_d   = dbe->bookProfile("pTScale_600_1500_d", "pTScale_d_600<pT<1500",
00428                                           90,etaRange, 0., 2., " ");
00429     mpTScale_1500_3500_d = dbe->bookProfile("pTScale_1500_3500_d", "pTScale_d_1500<pt<3500",
00430                                           90,etaRange, 0., 2., " ");
00431     
00432     mpTScale1DB_30_200 = dbe->book1D("pTScale1DB_30_200", "pTScale_distribution_for_0<|eta|<1.5_30_200",
00433                                    100, 0, 2);
00434     mpTScale1DE_30_200 = dbe->book1D("pTScale1DE_30_200", "pTScale_distribution_for_1.5<|eta|<3.0_30_200",
00435                                    50, 0, 2);
00436     mpTScale1DF_30_200 = dbe->book1D("pTScale1DF_30_200", "pTScale_distribution_for_3.0<|eta|<6.0_30_200",
00437                                    50, 0, 2);
00438 
00439     mpTScale1DB_200_600 = dbe->book1D("pTScale1DB_200_600", "pTScale_distribution_for_0<|eta|<1.5_200_600",
00440                                    100, 0, 2);
00441     mpTScale1DE_200_600 = dbe->book1D("pTScale1DE_200_600", "pTScale_distribution_for_1.5<|eta|<3.0_200_600",
00442                                    50, 0, 2);
00443     mpTScale1DF_200_600 = dbe->book1D("pTScale1DF_200_600", "pTScale_distribution_for_3.0<|eta|<6.0_200_600",
00444                                    50, 0, 2);
00445 
00446     mpTScale1DB_600_1500 = dbe->book1D("pTScale1DB_600_1500", "pTScale_distribution_for_0<|eta|<1.5_600_1500",
00447                                    100, 0, 2);
00448     mpTScale1DE_600_1500 = dbe->book1D("pTScale1DE_600_1500", "pTScale_distribution_for_1.5<|eta|<3.0_600_1500",
00449                                    50, 0, 2);
00450     mpTScale1DF_600_1500 = dbe->book1D("pTScale1DF_600_1500", "pTScale_distribution_for_3.0<|eta|<6.0_600_1500",
00451                                    50, 0, 2);
00452 
00453     mpTScale1DB_1500_3500 = dbe->book1D("pTScale1DB_1500_3500", "pTScale_distribution_for_0<|eta|<1.5_1500_3500",
00454                                    100, 0, 2);
00455     mpTScale1DE_1500_3500 = dbe->book1D("pTScale1DE_1500_3500", "pTScale_distribution_for_1.5<|eta|<3.0_1500_3500",
00456                                    50, 0, 2);
00457     mpTScale1DF_1500_3500 = dbe->book1D("pTScale1DF_1500_3500", "pTScale_distribution_for_3.0<|eta|<6.0_1500_3500",
00458                                    50, 0, 2);
00459         /*
00460     mpTScale1D_30_200    = dbe->book1D("pTScale1D_30_200", "pTScale_distribution_for_30<pT<200",
00461                                             100, 0, 2);
00462     mpTScale1D_200_600    = dbe->book1D("pTScale1D_200_600", "pTScale_distribution_for_200<pT<600",
00463                                             100, 0, 2);
00464     mpTScale1D_600_1500    = dbe->book1D("pTScale1D_600_1500", "pTScale_distribution_for_600<pT<1500",
00465                                             100, 0, 2);
00466     mpTScale1D_1500_3500 = dbe->book1D("pTScale1D_1500_3500", "pTScale_distribution_for_1500<pt<3500",
00467                                             100, 0, 2);
00468     */
00469 
00470   mpTScale_nvtx_0_5  = dbe->bookProfile("pTScale_nvtx_0_5", "pTScale_nvtx_0_5_0<|eta|<1.3",
00471                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00472    mpTScale_nvtx_5_10  = dbe->bookProfile("pTScale_nvtx_5_10", "pTScale_nvtx_5_10_0<|eta|<1.3",
00473                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00474    mpTScale_nvtx_10_15  = dbe->bookProfile("pTScale_nvtx_10_15", "pTScale_nvtx_10_15_0<|eta|<1.3",
00475                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00476    mpTScale_nvtx_15_20  = dbe->bookProfile("pTScale_nvtx_15_20", "pTScale_nvtx_15_20_0<|eta|<1.3",
00477                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00478    mpTScale_nvtx_20_30  = dbe->bookProfile("pTScale_nvtx_20_30", "pTScale_nvtx_20_30_0<|eta|<1.3",
00479                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00480    mpTScale_nvtx_30_inf  = dbe->bookProfile("pTScale_nvtx_30_inf", "pTScale_nvtx_30_inf_0<|eta|<1.3",
00481                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00482    mpTScale_pT = dbe->bookProfile("pTScale_pT", "pTScale_vs_pT",
00483                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00485     mpTRatio = dbe->bookProfile("pTRatio", "pTRatio",
00486                                 log10PtBins, log10PtMin, log10PtMax, 100, 0.,5., " ");
00487     mpTRatioB_d = dbe->bookProfile("pTRatioB_d", "pTRatio_d_0<|eta|<1.5",
00488                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00489     mpTRatioE_d = dbe->bookProfile("pTRatioE_d", "pTRatio_d_1.5<|eta|<3.0",
00490                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00491     mpTRatioF_d = dbe->bookProfile("pTRatioF_d", "pTRatio_d_3.0<|eta|<6.0",
00492                                    log10PtBins, log10PtMin, log10PtMax, 0, 5, " ");
00493     mpTRatio_30_200_d    = dbe->bookProfile("pTRatio_30_200_d", "pTRatio_d_30<pT<200",
00494                                           90,etaRange, 0., 5., " ");
00495     mpTRatio_200_600_d   = dbe->bookProfile("pTRatio_200_600_d", "pTRatio_d_200<pT<600",
00496                                           90,etaRange, 0., 5., " ");
00497     mpTRatio_600_1500_d   = dbe->bookProfile("pTRatio_600_1500_d", "pTRatio_d_600<pT<1500",
00498                                           90,etaRange, 0., 5., " ");    mpTRatio_1500_3500_d = dbe->bookProfile("pTRatio_1500_3500_d", "pTRatio_d_1500<pt<3500",
00499                                           90,etaRange, 0., 5., " ");
00500     mpTResponse = dbe->bookProfile("pTResponse", "pTResponse",
00501                                 log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00502     mpTResponseB_d = dbe->bookProfile("pTResponseB_d", "pTResponse_d_0<|eta|<1.5",
00503                                    log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00504     mpTResponseE_d = dbe->bookProfile("pTResponseE_d", "pTResponse_d_1.5<|eta|<3.0",
00505                                    log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00506     mpTResponseF_d = dbe->bookProfile("pTResponseF_d", "pTResponse_d_3.0<|eta|<6.0",
00507                                    log10PtBins, log10PtMin, log10PtMax, 0.8, 1.2, " ");
00508     mpTResponse_30_200_d    = dbe->bookProfile("pTResponse_30_200_d", "pTResponse_d_30<pT<200",
00509                                           90,etaRange, 0.8, 1.2, " ");
00510     mpTResponse_200_600_d   = dbe->bookProfile("pTResponse_200_600_d", "pTResponse_d_200<pT<600",
00511                                           90,etaRange, 0.8, 1.2, " ");
00512     mpTResponse_600_1500_d   = dbe->bookProfile("pTResponse_600_1500_d", "pTResponse_d_600<pT<1500",
00513                                           90,etaRange, 0.8, 1.2, " ");
00514     mpTResponse_1500_3500_d = dbe->bookProfile("pTResponse_1500_3500_d", "pTResponse_d_1500<pt<3500",
00515                                                90,etaRange, 0.8, 1.2, " ");
00516     mpTResponse_30_d = dbe->bookProfile("pTResponse_30_d", "pTResponse_d_pt>30",
00517                                                90,etaRange, 0.8, 1.2, " ");
00518     mpTResponse_nvtx_0_5 = dbe->bookProfile("pTResponse_nvtx_0_5", "pTResponse_nvtx_0_5", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00519    mpTResponse_nvtx_5_10 = dbe->bookProfile("pTResponse_nvtx_5_10", "pTResponse_nvtx_5_10", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00520    mpTResponse_nvtx_10_15 = dbe->bookProfile("pTResponse_nvtx_10_15", "pTResponse_nvtx_10_15", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00521    mpTResponse_nvtx_15_20 = dbe->bookProfile("pTResponse_nvtx_15_20", "pTResponse_nvtx_15_20", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00522    mpTResponse_nvtx_20_30 = dbe->bookProfile("pTResponse_nvtx_20_30", "pTResponse_nvtx_20_30", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00523    mpTResponse_nvtx_30_inf = dbe->bookProfile("pTResponse_nvtx_30_inf", "pTResponse_nvtx_30_inf", log10PtBins, log10PtMin, log10PtMax, 100, 0.8,1.2, " ");
00524   }
00525 
00526   if (mOutputFile.empty ()) {
00527     LogInfo("OutputInfo") << " PFJet histograms will NOT be saved";
00528   } 
00529   else {
00530     LogInfo("OutputInfo") << " PFJethistograms will be saved to file:" << mOutputFile;
00531   }
00532 }
00533    
00534 PFJetTester::~PFJetTester()
00535 {
00536 }
00537 
00538 void PFJetTester::beginJob(){
00539 }
00540 
00541 void PFJetTester::endJob() {
00542  if (!mOutputFile.empty() && &*edm::Service<DQMStore>()) edm::Service<DQMStore>()->save (mOutputFile);
00543 }
00544 
00545 
00546 void PFJetTester::analyze(const edm::Event& mEvent, const edm::EventSetup& mSetup)
00547 {
00548   double countsfornumberofevents = 1;
00549   numberofevents->Fill(countsfornumberofevents);
00550  
00551   //get primary vertices
00552   edm::Handle<vector<reco::Vertex> >pvHandle;
00553   try {
00554     mEvent.getByLabel( "offlinePrimaryVertices", pvHandle );
00555   } catch ( cms::Exception & e ) {
00556     //cout <<prefix<<"error: " << e.what() << endl;
00557   }
00558   vector<reco::Vertex> goodVertices;
00559   for (unsigned i = 0; i < pvHandle->size(); i++) {
00560     if ( (*pvHandle)[i].ndof() > 4 &&
00561        ( fabs((*pvHandle)[i].z()) <= 24. ) &&
00562        ( fabs((*pvHandle)[i].position().rho()) <= 2.0 ) )
00563        goodVertices.push_back((*pvHandle)[i]);
00564   }
00565   
00566   nvtx_0_30->Fill(goodVertices.size());
00567   nvtx_0_60->Fill(goodVertices.size());
00568   
00569   // *********************************
00570   // *** Get pThat
00571   // *********************************
00572 if (!mEvent.isRealData()){
00573   edm::Handle<HepMCProduct> evt;
00574   mEvent.getByLabel("generator", evt);
00575   if (evt.isValid()) {
00576   HepMC::GenEvent * myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
00577   
00578   double pthat = myGenEvent->event_scale();
00579 
00580   mPthat_80->Fill(pthat);
00581   mPthat_3000->Fill(pthat);
00582 
00583   delete myGenEvent; 
00584   }
00585 }
00586   // ***********************************
00587   // *** Get CaloMET
00588   // ***********************************
00589 /*
00590   const CaloMET *calomet;
00591   edm::Handle<CaloMETCollection> calo;
00592   mEvent.getByLabel("met", calo);
00593   if (!calo.isValid()) {
00594     edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00595     edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00596   } else {
00597     const CaloMETCollection *calometcol = calo.product();
00598     calomet = &(calometcol->front());
00599     
00600     double caloSumET = calomet->sumEt();
00601     double caloMETSig = calomet->mEtSig();
00602     double caloMET = calomet->pt();
00603     double caloMEx = calomet->px();
00604     double caloMEy = calomet->py();
00605     double caloMETPhi = calomet->phi();
00606 
00607     mCaloMEx->Fill(caloMEx);
00608     mCaloMEx_3000->Fill(caloMEx);
00609     mCaloMEy->Fill(caloMEy);
00610     mCaloMEy_3000->Fill(caloMEy);
00611     mCaloMET->Fill(caloMET);
00612     mCaloMET_3000->Fill(caloMET);
00613     mCaloMETPhi->Fill(caloMETPhi);
00614     mCaloSumET->Fill(caloSumET);
00615     mCaloSumET_3000->Fill(caloSumET);
00616     mCaloMETSig->Fill(caloMETSig);
00617     mCaloMETSig_3000->Fill(caloMETSig);
00618     
00619   }
00620 */
00621   // ***********************************
00622   // *** Get the CaloTower collection
00623   // ***********************************
00624   Handle<CaloTowerCollection> caloTowers;
00625   mEvent.getByLabel( "towerMaker", caloTowers );
00626   if (caloTowers.isValid()) {
00627   for( CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++ cal ){
00628 
00629     //To compensate for the index
00630     if (mTurnOnEverything.compare("yes")==0) {
00631       /*
00632       if (cal->ieta() >> 0 ){mHadEnergyProfile->Fill (cal->ieta()-1, cal->iphi(), cal->hadEnergy());
00633       mEmEnergyProfile->Fill (cal->ieta()-1, cal->iphi(), cal->emEnergy());}
00634       mHadEnergyProfile->Fill (cal->ieta(), cal->iphi(), cal->hadEnergy());
00635       mEmEnergyProfile->Fill (cal->ieta(), cal->iphi(), cal->emEnergy());
00636       */
00637     }
00638 
00639     mHadTiming->Fill (cal->hcalTime());
00640     mEmTiming->Fill (cal->ecalTime());    
00641   }
00642   }  
00643 
00644   // ***********************************
00645   // *** Get the RecHits collection
00646   // ***********************************
00647   try {
00648     std::vector<edm::Handle<HBHERecHitCollection> > colls;
00649     mEvent.getManyByType(colls);
00650     std::vector<edm::Handle<HBHERecHitCollection> >::iterator i;
00651     for (i=colls.begin(); i!=colls.end(); i++) {
00652       for (HBHERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00653         //      std::cout << *j << std::endl;
00654         /*
00655         if (j->id().subdet() == HcalBarrel) {
00656           mHBEne->Fill(j->energy()); 
00657           mHBTime->Fill(j->time()); 
00658         }
00659         if (j->id().subdet() == HcalEndcap) {
00660           mHEEne->Fill(j->energy()); 
00661           mHETime->Fill(j->time()); 
00662         }
00663         */
00664       }
00665     }
00666   } catch (...) {
00667     edm::LogInfo("OutputInfo") << " No HB/HE RecHits.";
00668   }
00669 
00670   try {
00671     std::vector<edm::Handle<HFRecHitCollection> > colls;
00672     mEvent.getManyByType(colls);
00673     std::vector<edm::Handle<HFRecHitCollection> >::iterator i;
00674     for (i=colls.begin(); i!=colls.end(); i++) {
00675       for (HFRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00676         //      std::cout << *j << std::endl;
00677         /*
00678         if (j->id().subdet() == HcalForward) {
00679           mHFEne->Fill(j->energy()); 
00680           mHFTime->Fill(j->time()); 
00681         }
00682         */
00683       }
00684     }
00685   } catch (...) {
00686     edm::LogInfo("OutputInfo") << " No HF RecHits.";
00687   }
00688 
00689   try {
00690     std::vector<edm::Handle<HORecHitCollection> > colls;
00691     mEvent.getManyByType(colls);
00692     std::vector<edm::Handle<HORecHitCollection> >::iterator i;
00693     for (i=colls.begin(); i!=colls.end(); i++) {
00694       for (HORecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00695         /*
00696         if (j->id().subdet() == HcalOuter) {
00697           mHOEne->Fill(j->energy()); 
00698           mHOTime->Fill(j->time()); 
00699         }
00700         */
00701       }
00702     }
00703   } catch (...) {
00704     edm::LogInfo("OutputInfo") << " No HO RecHits.";
00705   }
00706   try {
00707     std::vector<edm::Handle<EBRecHitCollection> > colls;
00708     mEvent.getManyByType(colls);
00709     std::vector<edm::Handle<EBRecHitCollection> >::iterator i;
00710     for (i=colls.begin(); i!=colls.end(); i++) {
00711       for (EBRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00712         //      if (j->id() == EcalBarrel) {
00713         //mEBEne->Fill(j->energy()); 
00714         //mEBTime->Fill(j->time()); 
00715         //    }
00716         //      std::cout << *j << std::endl;
00717         //      std::cout << j->id() << std::endl;
00718       }
00719     }
00720   } catch (...) {
00721     edm::LogInfo("OutputInfo") << " No EB RecHits.";
00722   }
00723 
00724   try {
00725     std::vector<edm::Handle<EERecHitCollection> > colls;
00726     mEvent.getManyByType(colls);
00727     std::vector<edm::Handle<EERecHitCollection> >::iterator i;
00728     for (i=colls.begin(); i!=colls.end(); i++) {
00729       for (EERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00730         //      if (j->id().subdet() == EcalEndcap) {
00731         //mEEEne->Fill(j->energy()); 
00732         //mEETime->Fill(j->time()); 
00733         //    }
00734         //      std::cout << *j << std::endl;
00735       }
00736     }
00737   } catch (...) {
00738     edm::LogInfo("OutputInfo") << " No EE RecHits.";
00739   }
00740 
00741 
00742   //***********************************
00743   //*** Get the Jet collection
00744   //***********************************
00745   math::XYZTLorentzVector p4tmp[2];
00746   Handle<PFJetCollection> pfJets;
00747   mEvent.getByLabel(mInputCollection, pfJets);
00748   if (!pfJets.isValid()) return;
00749   PFJetCollection::const_iterator jet = pfJets->begin ();
00750   int jetIndex = 0;
00751   int nJet = 0;
00752   int nJetF = 0;
00753   int nJetC = 0;
00754   int nJetF_30 =0;
00755   for (; jet != pfJets->end (); jet++, jetIndex++) {
00756 
00757     if (jet->pt() > 10.) {
00758       if (fabs(jet->eta()) > 1.5) 
00759         nJetF++;
00760       else 
00761         nJetC++;          
00762     }
00763     if (jet->pt() > 30.) nJetF_30++;
00764     if (jet->pt() > 10.) {
00765       if (mEta) mEta->Fill (jet->eta());
00766       if (mEtaFineBin) mEtaFineBin->Fill (jet->eta());
00767       //if (mEtaFineBin1p) mEtaFineBin1p->Fill (jet->eta());
00768       //if (mEtaFineBin2p) mEtaFineBin2p->Fill (jet->eta());
00769       //if (mEtaFineBin3p) mEtaFineBin3p->Fill (jet->eta());
00770       //if (mEtaFineBin1m) mEtaFineBin1m->Fill (jet->eta());
00771       //if (mEtaFineBin2m) mEtaFineBin2m->Fill (jet->eta());
00772       //if (mEtaFineBin3m) mEtaFineBin3m->Fill (jet->eta());
00773       if (mPhiFineBin) mPhiFineBin->Fill (jet->phi());
00774     }
00775     if (mjetArea) mjetArea->Fill(jet->jetArea());
00776     if (mPhi) mPhi->Fill (jet->phi());
00777     if (mE) mE->Fill (jet->energy());
00778     if (mE_80) mE_80->Fill (jet->energy());
00779     if (mP) mP->Fill (jet->p());
00780     if (mP_80) mP_80->Fill (jet->p());
00781     if (mPt) mPt->Fill (jet->pt());
00782     if (mPt_80) mPt_80->Fill (jet->pt());
00783     if (mMass) mMass->Fill (jet->mass());
00784     if (mMass_80) mMass_80->Fill (jet->mass());
00785     if (mConstituents) mConstituents->Fill (jet->nConstituents());
00786     if (mConstituents_80) mConstituents_80->Fill (jet->nConstituents());
00787     if (jet == pfJets->begin ()) { // first jet
00788       if (mEtaFirst) mEtaFirst->Fill (jet->eta());
00789       if (mPhiFirst) mPhiFirst->Fill (jet->phi());
00790       if (mPtFirst) mPtFirst->Fill (jet->pt());
00791       if (mPtFirst_80) mPtFirst_80->Fill (jet->pt());
00792       if (mPtFirst_3000) mPtFirst_3000->Fill (jet->pt());
00793     }
00794     if (jetIndex == 0) {
00795       nJet++;
00796       p4tmp[0] = jet->p4();     
00797     }
00798     if (jetIndex == 1) {
00799       nJet++;
00800       p4tmp[1] = jet->p4();     
00801     }
00802 
00803     //    if (mMaxEInEmTowers) mMaxEInEmTowers->Fill (jet->maxEInEmTowers());
00804     //    if (mMaxEInHadTowers) mMaxEInHadTowers->Fill (jet->maxEInHadTowers());
00805     //    if (mHadEnergyInHO) mHadEnergyInHO->Fill (jet->hadEnergyInHO());
00806     //    if (mHadEnergyInHO_80)   mHadEnergyInHO_80->Fill (jet->hadEnergyInHO());
00807     //    if (mHadEnergyInHO_3000) mHadEnergyInHO_3000->Fill (jet->hadEnergyInHO());
00808     //    if (mHadEnergyInHB) mHadEnergyInHB->Fill (jet->hadEnergyInHB());
00809     //    if (mHadEnergyInHB_80)   mHadEnergyInHB_80->Fill (jet->hadEnergyInHB());
00810     //    if (mHadEnergyInHB_3000) mHadEnergyInHB_3000->Fill (jet->hadEnergyInHB());
00811     if (mHadEnergyInHF) mHadEnergyInHF->Fill (jet->HFHadronEnergy());
00812     if (mHadEnergyInHF_80) mHadEnergyInHF_80->Fill (jet->HFHadronEnergy());
00813     if (mHadEnergyInHF_3000) mHadEnergyInHF_3000->Fill (jet->HFHadronEnergy());
00814     //    if (mHadEnergyInHE) mHadEnergyInHE->Fill (jet->hadEnergyInHE());
00815     //    if (mHadEnergyInHE_80)   mHadEnergyInHE_80->Fill (jet->hadEnergyInHE());
00816     //    if (mHadEnergyInHE_3000) mHadEnergyInHE_3000->Fill (jet->hadEnergyInHE());
00817     //    if (mEmEnergyInEB) mEmEnergyInEB->Fill (jet->emEnergyInEB());
00818     //    if (mEmEnergyInEB_80)   mEmEnergyInEB_80->Fill (jet->emEnergyInEB());
00819     //    if (mEmEnergyInEB_3000) mEmEnergyInEB_3000->Fill (jet->emEnergyInEB());
00820     //    if (mEmEnergyInEE) mEmEnergyInEE->Fill (jet->emEnergyInEE());
00821     //    if (mEmEnergyInEE_80)   mEmEnergyInEE_80->Fill (jet->emEnergyInEE());
00822     //    if (mEmEnergyInEE_3000) mEmEnergyInEE_3000->Fill (jet->emEnergyInEE());
00823     if (mEmEnergyInHF) mEmEnergyInHF->Fill (jet->HFEMEnergy());
00824     if (mEmEnergyInHF_80) mEmEnergyInHF_80->Fill (jet->HFEMEnergy());
00825     if (mEmEnergyInHF_3000) mEmEnergyInHF_3000->Fill (jet->HFEMEnergy());
00826     //    if (mEnergyFractionHadronic) mEnergyFractionHadronic->Fill (jet->energyFractionHadronic());
00827     //    if (mEnergyFractionEm) mEnergyFractionEm->Fill (jet->emEnergyFraction());
00828     //
00829     //    if (mHFTotal)      mHFTotal->Fill (jet->hadEnergyInHF()+jet->emEnergyInHF());
00830     //    if (mHFTotal_80)   mHFTotal_80->Fill (jet->hadEnergyInHF()+jet->emEnergyInHF());
00831     //    if (mHFTotal_3000) mHFTotal_3000->Fill (jet->hadEnergyInHF()+jet->emEnergyInHF());
00832     //    if (mHFLong)       mHFLong->Fill (jet->hadEnergyInHF()*0.5+jet->emEnergyInHF());
00833     //    if (mHFLong_80)    mHFLong_80->Fill (jet->hadEnergyInHF()*0.5+jet->emEnergyInHF());
00834     //    if (mHFLong_3000)  mHFLong_3000->Fill (jet->hadEnergyInHF()*0.5+jet->emEnergyInHF());
00835     //    if (mHFShort)      mHFShort->Fill (jet->hadEnergyInHF()*0.5);
00836     //    if (mHFShort_80)   mHFShort_80->Fill (jet->hadEnergyInHF()*0.5);
00837     //    if (mHFShort_3000) mHFShort_3000->Fill (jet->hadEnergyInHF()*0.5);
00838 
00839     if (mChargedEmEnergy_80) mChargedEmEnergy_80->Fill (jet->chargedEmEnergy());
00840     if (mChargedHadronEnergy_80) mChargedHadronEnergy_80->Fill (jet->chargedHadronEnergy());
00841     if (mNeutralEmEnergy_80) mNeutralEmEnergy_80->Fill (jet->neutralEmEnergy());
00842     if (mNeutralHadronEnergy_80) mNeutralHadronEnergy_80->Fill (jet->neutralHadronEnergy());
00843 
00844     if (mChargedEmEnergy_3000) mChargedEmEnergy_3000->Fill (jet->chargedEmEnergy());
00845     if (mChargedHadronEnergy_3000) mChargedHadronEnergy_3000->Fill (jet->chargedHadronEnergy());
00846     if (mNeutralEmEnergy_3000) mNeutralEmEnergy_3000->Fill (jet->neutralEmEnergy());
00847     if (mNeutralHadronEnergy_3000) mNeutralHadronEnergy_3000->Fill (jet->neutralHadronEnergy());
00848 
00849     if (fabs(jet->eta())<1.5) mChargedEmEnergyFraction_B->Fill (jet->chargedEmEnergyFraction());
00850     if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) mChargedEmEnergyFraction_E->Fill (jet->chargedEmEnergyFraction());
00851     if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) mChargedEmEnergyFraction_F->Fill (jet->chargedEmEnergyFraction());
00852     if (fabs(jet->eta())<1.5) mChargedHadronEnergyFraction_B->Fill (jet->chargedHadronEnergyFraction());
00853     if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) mChargedHadronEnergyFraction_E->Fill (jet->chargedHadronEnergyFraction());
00854     if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) mChargedHadronEnergyFraction_F->Fill (jet->chargedHadronEnergyFraction());
00855     if (fabs(jet->eta())<1.5) mNeutralEmEnergyFraction_B->Fill (jet->neutralEmEnergyFraction());
00856     if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) mNeutralEmEnergyFraction_E->Fill (jet->neutralEmEnergyFraction());
00857     if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) mNeutralEmEnergyFraction_F->Fill (jet->neutralEmEnergyFraction());
00858     if (fabs(jet->eta())<1.5) mNeutralHadronEnergyFraction_B->Fill (jet->neutralHadronEnergyFraction());
00859     if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) mNeutralHadronEnergyFraction_E->Fill (jet->neutralHadronEnergyFraction());
00860     if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) mNeutralHadronEnergyFraction_F->Fill (jet->neutralHadronEnergyFraction());
00861 
00862     //    if (mN90) mN90->Fill (jet->n90());
00863     // mJetEnergyProfile->Fill (jet->eta(), jet->phi(), jet->energy());
00864     //    mHadJetEnergyProfile->Fill (jet->eta(), jet->phi(), jet->hadEnergyInHO()+jet->hadEnergyInHB()+jet->hadEnergyInHF()+jet->hadEnergyInHE());
00865     //    mEMJetEnergyProfile->Fill (jet->eta(), jet->phi(), jet->emEnergyInEB()+jet->emEnergyInEE()+jet->emEnergyInHF());
00866   }
00867 
00868   if (mNJetsEtaC) mNJetsEtaC->Fill( nJetC );
00869   if (mNJetsEtaF) mNJetsEtaF->Fill( nJetF );
00870   if (mNJetsEtaF_30) mNJetsEtaF_30->Fill( nJetF_30 );  
00871 
00872   if (nJet == 2) {
00873     if (mMjj) mMjj->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00874     if (mMjj_3000) mMjj_3000->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00875   }
00876 
00877   // Count Jets above Pt cut
00878   for (int istep = 0; istep < 100; ++istep) {
00879     int     njet = 0;
00880     float ptStep = (istep * (200./100.));
00881 
00882     for ( PFJetCollection::const_iterator cal = pfJets->begin(); cal != pfJets->end(); ++ cal ) {
00883       if ( cal->pt() > ptStep ) njet++;
00884     }
00885     mNJets1->Fill( ptStep, njet );
00886   }
00887 
00888   for (int istep = 0; istep < 100; ++istep) {
00889     int     njet = 0;
00890     float ptStep = (istep * (4000./100.));
00891     for ( PFJetCollection::const_iterator cal = pfJets->begin(); cal != pfJets->end(); ++ cal ) {
00892       if ( cal->pt() > ptStep ) njet++;
00893     }
00894     mNJets2->Fill( ptStep, njet );
00895   }
00896 
00897  // Correction jets
00898   const JetCorrector* corrector = JetCorrector::getJetCorrector (JetCorrectionService,mSetup);
00899 
00900   for (PFJetCollection::const_iterator jet = pfJets->begin(); jet !=pfJets ->end(); jet++) 
00901   {
00902  
00903       PFJet  correctedJet = *jet;
00904       //double scale = corrector->correction(jet->p4());
00905       double scale = corrector->correction(*jet,mEvent,mSetup); 
00906       correctedJet.scaleEnergy(scale); 
00907       if(correctedJet.pt()>30){
00908       mCorrJetPt->Fill(correctedJet.pt());
00909       mCorrJetPt_80->Fill(correctedJet.pt());
00910       if(correctedJet.pt()>10) mCorrJetEta->Fill(correctedJet.eta());
00911       mCorrJetPhi->Fill(correctedJet.phi());
00912       mpTRatio->Fill(log10(jet->pt()),correctedJet.pt()/jet->pt());
00913 
00914       if (fabs(jet->eta())<1.5) {
00915            mpTRatioB_d->Fill(log10(jet->pt()), correctedJet.pt()/jet->pt());
00916       }
00917 
00918      if (fabs(jet->eta())>1.5 && fabs(jet->eta())<3.0) {
00919         mpTRatioE_d->Fill (log10(jet->pt()), correctedJet.pt()/jet->pt());
00920      }
00921      if (fabs(jet->eta())>3.0 && fabs(jet->eta())<6.0) {
00922         mpTRatioF_d->Fill (log10(jet->pt()), correctedJet.pt()/jet->pt());
00923     }
00924      if (jet->pt()>30.0 && jet->pt()<200.0) {
00925     mpTRatio_30_200_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00926   }
00927    if (jet->pt()>200.0 && jet->pt()<600.0) {
00928     mpTRatio_200_600_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00929   }
00930 if (jet->pt()>600.0 && jet->pt()<1500.0) {
00931     mpTRatio_600_1500_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00932   }
00933 if (jet->pt()>1500.0 && jet->pt()<3500.0) {
00934     mpTRatio_1500_3500_d->Fill (jet->eta(),correctedJet.pt()/jet->pt());
00935   }
00936       }
00937 
00938 
00939 
00940   }
00941 
00942 if (!mEvent.isRealData()){
00943   // Gen jet analysis
00944   Handle<GenJetCollection> genJets;
00945   mEvent.getByLabel(mInputGenCollection, genJets);
00946   if (!genJets.isValid()) return;
00947   GenJetCollection::const_iterator gjet = genJets->begin ();
00948   int gjetIndex = 0;
00949   for (; gjet != genJets->end (); gjet++, gjetIndex++) {
00950     if (mGenEta) mGenEta->Fill (gjet->eta());
00951     if (mGenPhi) mGenPhi->Fill (gjet->phi());
00952     if (mGenPt) mGenPt->Fill (gjet->pt());
00953     if (mGenPt_80) mGenPt_80->Fill (gjet->pt());
00954     if (gjet == genJets->begin ()) { // first jet
00955       if (mGenEtaFirst) mGenEtaFirst->Fill (gjet->eta());
00956       if (mGenPhiFirst) mGenPhiFirst->Fill (gjet->phi());
00957     }
00958   }
00959 
00960 
00961   // now match PFJets to GenJets
00962   JetMatchingTools jetMatching (mEvent);
00963   if (!(mInputGenCollection.label().empty())) {
00964     //    Handle<GenJetCollection> genJets;
00965     //    mEvent.getByLabel(mInputGenCollection, genJets);
00966 
00967     std::vector <std::vector <const reco::GenParticle*> > genJetConstituents (genJets->size());
00968     std::vector <std::vector <const reco::GenParticle*> > pfJetConstituents (pfJets->size());
00969     /*
00970     if (mRThreshold > 0) { 
00971     }
00972     else {
00973       for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
00974         genJetConstituents [iGenJet] = jetMatching.getGenParticles ((*genJets) [iGenJet]);
00975       }
00976       
00977       for (unsigned iPFJet = 0; iPFJet < pfJets->size(); ++iPFJet) {
00978         pfJetConstituents [iPFJet] = jetMatching.getGenParticles ((*pfJets) [iPFJet], false);
00979       }
00980     }
00981     */
00982     
00983     for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {               //****************************************************************
00984     //for (unsigned iGenJet = 0; iGenJet < 1; ++iGenJet) {                           // only FIRST Jet !!!!
00985       const GenJet& genJet = (*genJets) [iGenJet];
00986       double genJetPt = genJet.pt();
00987 
00988       //std::cout << iGenJet <<". Genjet: pT = " << genJetPt << "GeV" << std::endl;  //  *****************************************************
00989 
00990       if (fabs(genJet.eta()) > 6.) continue; // out of detector 
00991       if (genJetPt < mMatchGenPtThreshold) continue; // no low momentum 
00992       //double logPtGen = log10 (genJetPt);
00993       //mAllGenJetsPt->Fill (logPtGen);
00994       //mAllGenJetsEta->Fill (logPtGen, genJet.eta());
00995       if (pfJets->size() <= 0) continue; // no PFJets - nothing to match
00996       if (mRThreshold > 0) {
00997         unsigned iPFJetBest = 0;
00998         double deltaRBest = 999.;
00999         for (unsigned iPFJet = 0; iPFJet < pfJets->size(); ++iPFJet) {
01000           double dR = deltaR (genJet.eta(), genJet.phi(), (*pfJets) [iPFJet].eta(), (*pfJets) [iPFJet].phi());
01001           if (deltaRBest < mRThreshold && dR < mRThreshold && genJet.pt() > 5.) {
01002             /*
01003             std::cout << "Yet another matched jet for GenJet pt=" << genJet.pt()
01004                       << " previous PFJet pt/dr: " << (*pfJets) [iPFJetBest].pt() << '/' << deltaRBest
01005                       << " new PFJet pt/dr: " << (*pfJets) [iPFJet].pt() << '/' << dR
01006                       << std::endl;
01007             */
01008           }
01009           if (dR < deltaRBest) {
01010             iPFJetBest = iPFJet;
01011             deltaRBest = dR;
01012           }
01013         }
01014         if (mTurnOnEverything.compare("yes")==0) {
01015           //mRMatch->Fill (logPtGen, genJet.eta(), deltaRBest);
01016         }
01017         if (deltaRBest < mRThreshold) { // Matched
01018           fillMatchHists (genJet, (*pfJets) [iPFJetBest],goodVertices);
01019         }
01020 
01022         double CorrdeltaRBest = 999.;
01023         double CorrJetPtBest = 0;
01024         for (PFJetCollection::const_iterator jet = pfJets->begin(); jet !=pfJets ->end(); jet++) {
01025           PFJet  correctedJet = *jet;
01026           //double scale = corrector->correction(jet->p4());
01027           double scale = corrector->correction(*jet,mEvent,mSetup); 
01028           correctedJet.scaleEnergy(scale);
01029           double CorrJetPt = correctedJet.pt();
01030           if(CorrJetPt>30){
01031           double CorrdR = deltaR (genJet.eta(), genJet.phi(), correctedJet.eta(), correctedJet.phi());
01032           if (CorrdR < CorrdeltaRBest) {
01033             CorrdeltaRBest = CorrdR;
01034             CorrJetPtBest = CorrJetPt;
01035           }
01036         }
01037         }
01038         if (deltaRBest < mRThreshold) { // Matched
01039           mpTResponse->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01040           
01041           if (fabs(genJet.eta())<1.5) {
01042             mpTResponseB_d->Fill(log10(genJet.pt()), CorrJetPtBest/genJet.pt());
01043           }     
01044           
01045           if (fabs(genJet.eta())>1.5 && fabs(genJet.eta())<3.0) {
01046             mpTResponseE_d->Fill (log10(genJet.pt()), CorrJetPtBest/genJet.pt());   
01047           }
01048           if (fabs(genJet.eta())>3.0 && fabs(genJet.eta())<6.0) {
01049         mpTResponseF_d->Fill (log10(genJet.pt()), CorrJetPtBest/genJet.pt());
01050           }
01051           if (genJet.pt()>30.0 && genJet.pt()<200.0) {
01052             mpTResponse_30_200_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
01053           }
01054           if (genJet.pt()>200.0 && genJet.pt()<600.0) {
01055             mpTResponse_200_600_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
01056           }
01057           if (genJet.pt()>600.0 && genJet.pt()<1500.0) {
01058             mpTResponse_600_1500_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
01059           }
01060           if (genJet.pt()>1500.0 && genJet.pt()<3500.0) {
01061             mpTResponse_1500_3500_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
01062           }
01063           if (genJet.pt()>30.0) {
01064             mpTResponse_30_d->Fill (genJet.eta(),CorrJetPtBest/genJet.pt());
01065           }
01066           if(goodVertices.size()<=5) mpTResponse_nvtx_0_5->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01067           if(goodVertices.size()>5 && goodVertices.size()<=10) mpTResponse_nvtx_5_10->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01068           if(goodVertices.size()>10 && goodVertices.size()<=15) mpTResponse_nvtx_10_15->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());       
01069           if(goodVertices.size()>15 && goodVertices.size()<=20) mpTResponse_nvtx_15_20->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01070           if(goodVertices.size()>20 && goodVertices.size()<=30) mpTResponse_nvtx_20_30->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01071           if(goodVertices.size()>30) mpTResponse_nvtx_30_inf->Fill(log10(genJet.pt()),CorrJetPtBest/genJet.pt());
01072         }
01074 
01075       }
01076       /*
01077       else {
01078         unsigned iPFJetBest = 0;
01079         double energyFractionBest = 0.;
01080         for (unsigned iPFJet = 0; iPFJet < pfJets->size(); ++iPFJet) {
01081           double energyFraction = jetMatching.overlapEnergyFraction (genJetConstituents [iGenJet], 
01082                                                                      pfJetConstituents [iPFJet]);
01083           if (energyFraction > energyFractionBest) {
01084             iPFJetBest = iPFJet;
01085             energyFractionBest = energyFraction;
01086           }
01087         }
01088         if (mTurnOnEverything.compare("yes")==0) {
01089           mGenJetMatchEnergyFraction->Fill (logPtGen, genJet.eta(), energyFractionBest);
01090         }
01091         if (energyFractionBest > mGenEnergyFractionThreshold) { // good enough
01092           double reverseEnergyFraction = jetMatching.overlapEnergyFraction (pfJetConstituents [iPFJetBest], 
01093                                                                             genJetConstituents [iGenJet]);
01094           if (mTurnOnEverything.compare("yes")==0) {
01095             mReverseMatchEnergyFraction->Fill (logPtGen, genJet.eta(), reverseEnergyFraction);
01096           }
01097           if (reverseEnergyFraction > mReverseEnergyFractionThreshold) { // Matched
01098             fillMatchHists (genJet, (*pfJets) [iPFJetBest]);
01099           }
01100         }
01101       }
01102       */
01103     }
01104   }
01105 }
01106 
01107 }
01108 
01109 void PFJetTester::fillMatchHists (const reco::GenJet& fGenJet, const reco::PFJet& fPFJet,std::vector<reco::Vertex> goodVertices) {
01110   double logPtGen = log10 (fGenJet.pt());
01111   double PtGen = fGenJet.pt();
01112   double PtPF = fPFJet.pt();
01113   //mMatchedGenJetsPt->Fill (logPtGen);
01114   //mMatchedGenJetsEta->Fill (logPtGen, fGenJet.eta());
01115 
01116   double PtThreshold = 10.;
01117 
01118   if (mTurnOnEverything.compare("yes")==0) {
01119     mDeltaEta->Fill (logPtGen, fGenJet.eta(), fPFJet.eta()-fGenJet.eta());
01120     mDeltaPhi->Fill (logPtGen, fGenJet.eta(), fPFJet.phi()-fGenJet.phi());
01121     //mEScale->Fill (logPtGen, fGenJet.eta(), fPFJet.energy()/fGenJet.energy());
01122     //mlinEScale->Fill (fGenJet.pt(), fGenJet.eta(), fPFJet.energy()/fGenJet.energy());
01123     //mDeltaE->Fill (logPtGen, fGenJet.eta(), fPFJet.energy()-fGenJet.energy());
01124 
01125     mEScaleFineBin->Fill (logPtGen, fGenJet.eta(), fPFJet.energy()/fGenJet.energy());
01126   
01127     if (fGenJet.pt()>PtThreshold) {
01128       mEScale_pt10->Fill (logPtGen, fGenJet.eta(), fPFJet.energy()/fGenJet.energy());
01129 
01130     }
01131 
01132   }
01133   if (fPFJet.pt() > PtThreshold) {
01134     mDelEta->Fill (fGenJet.eta()-fPFJet.eta());
01135     mDelPhi->Fill (fGenJet.phi()-fPFJet.phi());
01136     mDelPt->Fill  ((fGenJet.pt()-fPFJet.pt())/fGenJet.pt());
01137   }
01138 
01139   if (fabs(fGenJet.eta())<1.5) {
01140 
01141     //mpTScaleB_s->Fill (log10(PtGen), PtPF/PtGen);
01142     mpTScaleB_d->Fill (log10(PtGen), PtPF/PtGen);
01143     mpTScalePhiB_d->Fill (fGenJet.phi(), PtPF/PtGen);
01144     
01145     if (PtGen>30.0 && PtGen<200.0) {
01146       mpTScale1DB_30_200->Fill (fPFJet.pt()/fGenJet.pt());
01147     }
01148     if (PtGen>200.0 && PtGen<600.0) {
01149       mpTScale1DB_200_600->Fill (fPFJet.pt()/fGenJet.pt());
01150     }
01151     if (PtGen>600.0 && PtGen<1500.0) {
01152       mpTScale1DB_600_1500->Fill (fPFJet.pt()/fGenJet.pt());
01153     }
01154     if (PtGen>1500.0 && PtGen<3500.0) {
01155       mpTScale1DB_1500_3500->Fill (fPFJet.pt()/fGenJet.pt());
01156     }
01157     
01158   }
01159 
01160   if (fabs(fGenJet.eta())>1.5 && fabs(fGenJet.eta())<3.0) {
01161 
01162     //mpTScaleE_s->Fill (log10(PtGen), PtPF/PtGen);
01163     mpTScaleE_d->Fill (log10(PtGen), PtPF/PtGen);
01164     mpTScalePhiE_d->Fill (fGenJet.phi(), PtPF/PtGen);
01165     
01166     if (PtGen>30.0 && PtGen<200.0) {
01167       mpTScale1DE_30_200->Fill (fPFJet.pt()/fGenJet.pt());
01168     }
01169     if (PtGen>200.0 && PtGen<600.0) {
01170       mpTScale1DE_200_600->Fill (fPFJet.pt()/fGenJet.pt());
01171     }
01172     if (PtGen>600.0 && PtGen<1500.0) {
01173       mpTScale1DE_600_1500->Fill (fPFJet.pt()/fGenJet.pt());
01174     }
01175     if (PtGen>1500.0 && PtGen<3500.0) {
01176       mpTScale1DE_1500_3500->Fill (fPFJet.pt()/fGenJet.pt());
01177     }
01178     
01179   }
01180 
01181   if (fabs(fGenJet.eta())>3.0 && fabs(fGenJet.eta())<6.0) {
01182 
01183     //mpTScaleF_s->Fill (log10(PtGen), PtPF/PtGen);
01184     mpTScaleF_d->Fill (log10(PtGen), PtPF/PtGen);
01185     mpTScalePhiF_d->Fill (fGenJet.phi(), PtPF/PtGen);
01186     
01187     if (PtGen>30.0 && PtGen<200.0) {
01188       mpTScale1DF_30_200->Fill (fPFJet.pt()/fGenJet.pt());
01189     }
01190     if (PtGen>200.0 && PtGen<600.0) {
01191       mpTScale1DF_200_600->Fill (fPFJet.pt()/fGenJet.pt());
01192     }
01193     if (PtGen>600.0 && PtGen<1500.0) {
01194       mpTScale1DF_600_1500->Fill (fPFJet.pt()/fGenJet.pt());
01195     }
01196     if (PtGen>1500.0 && PtGen<3500.0) {
01197       mpTScale1DF_1500_3500->Fill (fPFJet.pt()/fGenJet.pt());
01198     }
01199     
01200   }
01201 
01202   if (fGenJet.pt()>30.0 && fGenJet.pt()<200.0) {
01203     //mpTScale_30_200_s->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01204     mpTScale_30_200_d->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01205     //mpTScale1D_30_200->Fill (fPFJet.pt()/fGenJet.pt());
01206   }
01207 
01208   if (fGenJet.pt()>200.0 && fGenJet.pt()<600.0) {
01209     //mpTScale_200_600_s->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01210     mpTScale_200_600_d->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01211     //mpTScale1D_200_600->Fill (fPFJet.pt()/fGenJet.pt());
01212   }
01213 
01214   if (fGenJet.pt()>600.0 && fGenJet.pt()<1500.0) {
01215     //mpTScale_600_1500_s->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01216     mpTScale_600_1500_d->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01217     //mpTScale1D_600_1500->Fill (fPFJet.pt()/fGenJet.pt());
01218   }
01219 
01220   if (fGenJet.pt()>1500.0 && fGenJet.pt()<3500.0) {
01221     //mpTScale_1500_3500_s->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01222     mpTScale_1500_3500_d->Fill (fGenJet.eta(),fPFJet.pt()/fGenJet.pt());
01223     //mpTScale1D_1500_3500->Fill (fPFJet.pt()/fGenJet.pt());
01224   }
01225   if (fabs(fGenJet.eta())<1.3) {
01226     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01227      if(goodVertices.size()<=5) mpTScale_a_nvtx_0_5->Fill( PtPF/PtGen);
01228     }
01229     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01230      if(goodVertices.size()<=5) mpTScale_b_nvtx_0_5->Fill( PtPF/PtGen);
01231     }
01232     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01233      if(goodVertices.size()<=5) mpTScale_c_nvtx_0_5->Fill( PtPF/PtGen);
01234     }
01235 
01236     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01237      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_a_nvtx_5_10->Fill( PtPF/PtGen);
01238     }
01239     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01240      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_b_nvtx_5_10->Fill( PtPF/PtGen);
01241     }
01242     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01243      if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_c_nvtx_5_10->Fill( PtPF/PtGen);
01244     }
01245 
01246     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01247      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_a_nvtx_10_15->Fill( PtPF/PtGen);
01248     }
01249     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01250      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_b_nvtx_10_15->Fill( PtPF/PtGen);
01251     }
01252     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01253      if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_c_nvtx_10_15->Fill( PtPF/PtGen);
01254     }
01255 
01256     if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01257      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_a_nvtx_15_20->Fill( PtPF/PtGen);
01258     }
01259     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01260      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_b_nvtx_15_20->Fill( PtPF/PtGen);
01261     }
01262     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01263      if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_c_nvtx_15_20->Fill( PtPF/PtGen);
01264     }
01265 
01266 if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01267      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_a_nvtx_20_30->Fill( PtPF/PtGen);
01268     }
01269     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01270      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_b_nvtx_20_30->Fill( PtPF/PtGen);
01271     }
01272     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01273      if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_c_nvtx_20_30->Fill( PtPF/PtGen);
01274     }
01275 
01276 if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
01277      if(goodVertices.size()>30) mpTScale_a_nvtx_30_inf->Fill( PtPF/PtGen);
01278     }
01279     if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
01280      if(goodVertices.size()>30) mpTScale_b_nvtx_30_inf->Fill( PtPF/PtGen);
01281     }
01282     if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
01283      if(goodVertices.size()>30) mpTScale_c_nvtx_30_inf->Fill( PtPF/PtGen);
01284     }
01285 
01286    if(goodVertices.size()<=5) mpTScale_nvtx_0_5->Fill(log10(PtGen),PtPF/PtGen);
01287     if(goodVertices.size()>5 && goodVertices.size()<=10) mpTScale_nvtx_5_10->Fill(log10(PtGen),PtPF/PtGen);
01288     if(goodVertices.size()>10 && goodVertices.size()<=15) mpTScale_nvtx_10_15->Fill(log10(PtGen),PtPF/PtGen);
01289     if(goodVertices.size()>15 && goodVertices.size()<=20) mpTScale_nvtx_15_20->Fill(log10(PtGen), PtPF/PtGen);
01290     if(goodVertices.size()>20 && goodVertices.size()<=30) mpTScale_nvtx_20_30->Fill(log10(PtGen), PtPF/PtGen);
01291     if(goodVertices.size()>30) mpTScale_nvtx_30_inf->Fill(log10(PtGen), PtPF/PtGen);
01292 }
01293   if (fabs(fGenJet.eta())<1.3) {
01294   if(fGenJet.pt()>60.0 && fGenJet.pt()<120.0) mpTScale_a->Fill(PtPF/PtGen);
01295   if(fGenJet.pt()>200.0 && fGenJet.pt()<300.0) mpTScale_b->Fill(PtPF/PtGen);
01296   if(fGenJet.pt()>600.0 && fGenJet.pt()<900.0) mpTScale_c->Fill(PtPF/PtGen);
01297   }
01298   mpTScale_pT->Fill (log10(PtGen), PtPF/PtGen);
01299 }