CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Validation/RecoJets/plugins/JPTJetTester.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: JPTJetTester.cc,v 1.8 2010/08/07 14:56:05 wmtan 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/CaloJet.h"
00018 //#include "DataFormats/JetReco/interface/CaloJetCollection.h"
00019 #include "DataFormats/JetReco/interface/JPTJet.h"
00020 #include "DataFormats/JetReco/interface/JPTJetCollection.h"
00021 #include "DataFormats/JetReco/interface/GenJet.h"
00022 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00023 
00024 #include "DataFormats/METReco/interface/CaloMET.h"
00025 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00026 // #include "DataFormats/METReco/interface/GenMET.h"
00027 // #include "DataFormats/METReco/interface/GenMETCollection.h"
00028 // #include "DataFormats/METReco/interface/MET.h"
00029 // #include "DataFormats/METReco/interface/METCollection.h"
00030 
00031 #include "RecoJets/JetProducers/interface/JetMatchingTools.h"
00032 
00033 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
00034 
00035 #include "JPTJetTester.h"
00036 
00037 #include <cmath>
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 JPTJetTester::JPTJetTester(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     mTurnOnEverything (iConfig.getUntrackedParameter<std::string>("TurnOnEverything",""))
00058 {
00059     numberofevents
00060     = mEta = mEtaFineBin = mPhi = mPhiFineBin = mE = mE_80 = mE_3000
00061     = mP = mP_80 = mP_3000 = mPt = mPt_80 = mPt_3000
00062     = mMass = mMass_80 = mMass_3000
00063       //    = mConstituents = mConstituents_80
00064     = mEtaFirst = mPhiFirst = mEFirst = mEFirst_80 = mEFirst_3000 = mPtFirst = mPtFirst_80 = mPtFirst_3000
00065     = mMjj = mMjj_3000 = mDelEta = mDelPhi = mDelPt 
00066     /*  
00067     = mMaxEInEmTowers = mMaxEInHadTowers 
00068     = mHadEnergyInHO = mHadEnergyInHB = mHadEnergyInHF = mHadEnergyInHE 
00069     = mHadEnergyInHO_80 = mHadEnergyInHB_80 = mHadEnergyInHE_80 
00070     = mHadEnergyInHO_3000 = mHadEnergyInHB_3000 = mHadEnergyInHE_3000 
00071     = mEmEnergyInEB = mEmEnergyInEE = mEmEnergyInHF 
00072     = mEmEnergyInEB_80 = mEmEnergyInEE_80
00073     = mEmEnergyInEB_3000 = mEmEnergyInEE_3000
00074     = mEnergyFractionHadronic = mEnergyFractionEm 
00075     = mHFLong = mHFTotal = mHFLong_80 = mHFLong_3000 = mHFShort = mHFShort_80 = mHFShort_3000
00076     = mN90
00077     */
00078     = mPtFractionPionInVertexInCalo = mPtFractionPionInVertexOutCalo = mPtFractionPionOutVertexInCalo
00079     = mPtFractionMuonInVertexInCalo = mPtFractionMuonInVertexOutCalo = mPtFractionMuonOutVertexInCalo
00080     = mPtFractionElecInVertexInCalo = mPtFractionElecInVertexOutCalo = mPtFractionElecOutVertexInCalo
00081     = mMultiplicityPionInVertexInCalo = mMultiplicityPionInVertexOutCalo = mMultiplicityPionOutVertexInCalo
00082     = mMultiplicityMuonInVertexInCalo = mMultiplicityMuonInVertexOutCalo = mMultiplicityMuonOutVertexInCalo
00083     = mMultiplicityElecInVertexInCalo = mMultiplicityElecInVertexOutCalo = mMultiplicityElecOutVertexInCalo
00084     //
00085     = mCaloMEx = mCaloMEx_3000 = mCaloMEy = mCaloMEy_3000 = mCaloMETSig = mCaloMETSig_3000
00086     = mCaloMET = mCaloMET_3000 =  mCaloMETPhi = mCaloSumET  = mCaloSumET_3000   
00087     = mHadTiming = mEmTiming 
00088     = mNJetsEtaC = mNJetsEtaF = mNJets1 = mNJets2
00089     = mAllGenJetsPt = mMatchedGenJetsPt = mAllGenJetsEta = mMatchedGenJetsEta 
00090     = mGenJetMatchEnergyFraction = mReverseMatchEnergyFraction = mRMatch
00091     = mDeltaEta = mDeltaPhi = mEScale = mlinEScale = mDeltaE
00092     = mHadEnergyProfile = mEmEnergyProfile = mJetEnergyProfile 
00093     /*
00094     = mHadJetEnergyProfile = mEMJetEnergyProfile
00095     */
00096     = mEScale_pt10 = mEScaleFineBin
00097     = mpTScaleB_s = mpTScaleE_s = mpTScaleF_s 
00098     = mpTScaleB_d = mpTScaleE_d = mpTScaleF_d
00099     = mpTScale_60_120_s = mpTScale_200_300_s = mpTScale_600_900_s = mpTScale_2700_3500_s
00100     = mpTScale_60_120_d = mpTScale_200_300_d = mpTScale_600_900_d = mpTScale_2700_3500_d
00101     = mpTScale1DB_60_120    = mpTScale1DE_60_120    = mpTScale1DF_60_120 
00102     = mpTScale1DB_200_300   = mpTScale1DE_200_300   = mpTScale1DF_200_300 
00103     = mpTScale1DB_600_900   = mpTScale1DE_600_900   = mpTScale1DF_600_900 
00104     = mpTScale1DB_2700_3500 = mpTScale1DE_2700_3500 = mpTScale1DF_2700_3500
00105     = mpTScale1D_60_120 = mpTScale1D_200_300 = mpTScale1D_600_900 = mpTScale1D_2700_3500
00106     = mHBEne = mHBTime = mHEEne = mHETime = mHFEne = mHFTime = mHOEne = mHOTime
00107     = mEBEne = mEBTime = mEEEne = mEETime 
00108     = mPthat_80 = mPthat_3000
00109     = 0;
00110   
00111   DQMStore* dbe = &*edm::Service<DQMStore>();
00112   if (dbe) {
00113     dbe->setCurrentFolder("JetMET/RecoJetsV/JPTJetTask_" + mInputCollection.label());
00114     //
00115     numberofevents    = dbe->book1D("numberofevents","numberofevents", 3, 0 , 2);
00116     //
00117     mEta              = dbe->book1D("Eta", "Eta", 100, -5, 5); 
00118     mEtaFineBin       = dbe->book1D("EtaFineBin_Pt10", "EtaFineBin_Pt10", 500, -5, 5); 
00119     mEtaFineBin1p     = dbe->book1D("EtaFineBin1p_Pt10", "EtaFineBin1p_Pt10", 100, 0, 1.3); 
00120     mEtaFineBin2p     = dbe->book1D("EtaFineBin2p_Pt10", "EtaFineBin2p_Pt10", 100, 1.3, 3); 
00121     mEtaFineBin3p     = dbe->book1D("EtaFineBin3p_Pt10", "EtaFineBin3p_Pt10", 100, 3, 5); 
00122     mEtaFineBin1m     = dbe->book1D("EtaFineBin1m_Pt10", "EtaFineBin1m_Pt10", 100, -1.3, 0); 
00123     mEtaFineBin2m     = dbe->book1D("EtaFineBin2m_Pt10", "EtaFineBin2m_Pt10", 100, -3, -1.3); 
00124     mEtaFineBin3m     = dbe->book1D("EtaFineBin3m_Pt10", "EtaFineBin3m_Pt10", 100, -5, -3); 
00125     //
00126     mPhi              = dbe->book1D("Phi", "Phi", 70, -3.5, 3.5); 
00127     mPhiFineBin       = dbe->book1D("PhiFineBin_Pt10", "PhiFineBin_Pt10", 350, -3.5, 3.5); 
00128     //
00129     mE                = dbe->book1D("E", "E", 100, 0, 500); 
00130     mE_80             = dbe->book1D("E_80", "E_80", 100, 0, 4500); 
00131     mE_3000           = dbe->book1D("E_3000", "E_3000", 100, 0, 6000); 
00132     //
00133     mP                = dbe->book1D("P", "P", 100, 0, 500); 
00134     mP_80             = dbe->book1D("P_80", "P_80", 100, 0, 4500); 
00135     mP_3000           = dbe->book1D("P_3000", "P_3000", 100, 0, 6000); 
00136     //
00137     mPt               = dbe->book1D("Pt", "Pt", 100, 0, 50); 
00138     mPt_80            = dbe->book1D("Pt_80", "Pt_80", 100, 0, 140); 
00139     mPt_3000          = dbe->book1D("Pt_3000", "Pt_3000", 100, 0, 4000); 
00140     //
00141     mMass             = dbe->book1D("Mass", "Mass", 100, 0, 25); 
00142     mMass_80          = dbe->book1D("Mass_80", "Mass_80", 100, 0, 120); 
00143     mMass_3000        = dbe->book1D("Mass_3000", "Mass_3000", 100, 0, 500); 
00144     //
00145     //    mConstituents     = dbe->book1D("Constituents", "# of Constituents", 100, 0, 100); 
00146     //    mConstituents_80  = dbe->book1D("Constituents_80", "# of Constituents_80", 40, 0, 40); 
00147     //
00148     mEtaFirst         = dbe->book1D("EtaFirst", "EtaFirst", 100, -5, 5); 
00149     mPhiFirst         = dbe->book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);     
00150     mEFirst           = dbe->book1D("EFirst", "EFirst", 100, 0, 1000); 
00151     mEFirst_80        = dbe->book1D("EFirst_80", "EFirst_80", 100, 0, 180); 
00152     mEFirst_3000      = dbe->book1D("EFirst_3000", "EFirst_3000", 100, 0, 4000); 
00153     mPtFirst          = dbe->book1D("PtFirst", "PtFirst", 100, 0, 50); 
00154     mPtFirst_80       = dbe->book1D("PtFirst_80", "PtFirst_80", 100, 0, 140);
00155     mPtFirst_3000     = dbe->book1D("PtFirst_3000", "PtFirst_3000", 100, 0, 4000);
00156     //
00157     mMjj              = dbe->book1D("Mjj", "Mjj", 100, 0, 2000); 
00158     mMjj_3000         = dbe->book1D("Mjj_3000", "Mjj_3000", 100, 0, 10000); 
00159     mDelEta           = dbe->book1D("DelEta", "DelEta", 100, -.5, .5); 
00160     mDelPhi           = dbe->book1D("DelPhi", "DelPhi", 100, -.5, .5); 
00161     mDelPt            = dbe->book1D("DelPt", "DelPt", 100, -1, 1); 
00162     //
00163     mPtFractionPionInVertexInCalo  = dbe->book1D("PtFractionPionInVertexInCalo", "PtFractionPionInVertexInCalo",51,0.,1.02);
00164     mPtFractionPionInVertexOutCalo = dbe->book1D("PtFractionPionInVertexOutCalo","PtFractionPionInVertexOutCalo",51,0.,1.02);
00165     mPtFractionPionOutVertexInCalo = dbe->book1D("PtFractionPionOutVertexInCalo","PtFractionPionOutVertexInCalo",51,0.,1.02);
00166 
00167     mPtFractionMuonInVertexInCalo  = dbe->book1D("PtFractionMuonInVertexInCalo", "PtFractionMuonInVertexInCalo",51,0.,1.02);
00168     mPtFractionMuonInVertexOutCalo = dbe->book1D("PtFractionMuonInVertexOutCalo","PtFractionMuonInVertexOutCalo",51,0.,1.02);
00169     mPtFractionMuonOutVertexInCalo = dbe->book1D("PtFractionMuonOutVertexInCalo","PtFractionMuonOutVertexInCalo",51,0.,1.02);
00170 
00171     mPtFractionElecInVertexInCalo  = dbe->book1D("PtFractionElecInVertexInCalo", "PtFractionElecInVertexInCalo",51,0.,1.02);
00172     mPtFractionElecInVertexOutCalo = dbe->book1D("PtFractionElecInVertexOutCalo","PtFractionElecInVertexOutCalo",51,0.,1.02);
00173     mPtFractionElecOutVertexInCalo = dbe->book1D("PtFractionElecOutVertexInCalo","PtFractionElecOutVertexInCalo",51,0.,1.02);
00174     //
00175     mMultiplicityPionInVertexInCalo  = dbe->book1D("MultiplicityPionInVertexInCalo","MultiplicityPionInVertexInCalo",100,0.,100.);
00176     mMultiplicityPionInVertexOutCalo = dbe->book1D("MultiplicityPionInVertexOutCalo","MultiplicityPionInVertexOutCalo",100,0.,100.);
00177     mMultiplicityPionOutVertexInCalo = dbe->book1D("MultiplicityPionOutVertexInCalo","MultiplicityPionOutVertexInCalo",100,0.,100.);
00178 
00179     mMultiplicityMuonInVertexInCalo  = dbe->book1D("MultiplicityMuonInVertexInCalo","MultiplicityMuonInVertexInCalo",100,0.,100.);
00180     mMultiplicityMuonInVertexOutCalo = dbe->book1D("MultiplicityMuonInVertexOutCalo","MultiplicityMuonInVertexOutCalo",100,0.,100.);
00181     mMultiplicityMuonOutVertexInCalo = dbe->book1D("MultiplicityMuonOutVertexInCalo","MultiplicityMuonOutVertexInCalo",100,0.,100.);
00182 
00183     mMultiplicityElecInVertexInCalo  = dbe->book1D("MultiplicityElecInVertexInCalo","MultiplicityElecInVertexInCalo",100,0.,100.);
00184     mMultiplicityElecInVertexOutCalo = dbe->book1D("MultiplicityElecInVertexOutCalo","MultiplicityElecInVertexOutCalo",100,0.,100.);
00185     mMultiplicityElecOutVertexInCalo = dbe->book1D("MultiplicityElecOutVertexInCalo","MultiplicityElecOutVertexInCalo",100,0.,100.);
00186     /*
00187     mMaxEInEmTowers   = dbe->book1D("MaxEInEmTowers", "MaxEInEmTowers", 100, 0, 100); 
00188     mMaxEInHadTowers  = dbe->book1D("MaxEInHadTowers", "MaxEInHadTowers", 100, 0, 100); 
00189     mHadEnergyInHO    = dbe->book1D("HadEnergyInHO", "HadEnergyInHO", 100, 0, 10); 
00190     mHadEnergyInHB    = dbe->book1D("HadEnergyInHB", "HadEnergyInHB", 100, 0, 50); 
00191     mHadEnergyInHF    = dbe->book1D("HadEnergyInHF", "HadEnergyInHF", 100, 0, 50); 
00192     mHadEnergyInHE    = dbe->book1D("HadEnergyInHE", "HadEnergyInHE", 100, 0, 100); 
00193     //
00194     mHadEnergyInHO_80    = dbe->book1D("HadEnergyInHO_80", "HadEnergyInHO_80", 100, 0, 50); 
00195     mHadEnergyInHB_80    = dbe->book1D("HadEnergyInHB_80", "HadEnergyInHB_80", 100, 0, 200); 
00196     mHadEnergyInHE_80    = dbe->book1D("HadEnergyInHE_80", "HadEnergyInHE_80", 100, 0, 1000); 
00197     mHadEnergyInHO_3000  = dbe->book1D("HadEnergyInHO_3000", "HadEnergyInHO_3000", 100, 0, 500); 
00198     mHadEnergyInHB_3000  = dbe->book1D("HadEnergyInHB_3000", "HadEnergyInHB_3000", 100, 0, 3000); 
00199     mHadEnergyInHE_3000  = dbe->book1D("HadEnergyInHE_3000", "HadEnergyInHE_3000", 100, 0, 2000); 
00200     //
00201     mEmEnergyInEB     = dbe->book1D("EmEnergyInEB", "EmEnergyInEB", 100, 0, 50); 
00202     mEmEnergyInEE     = dbe->book1D("EmEnergyInEE", "EmEnergyInEE", 100, 0, 50); 
00203     mEmEnergyInHF     = dbe->book1D("EmEnergyInHF", "EmEnergyInHF", 120, -20, 100); 
00204     mEmEnergyInEB_80  = dbe->book1D("EmEnergyInEB_80", "EmEnergyInEB_80", 100, 0, 200); 
00205     mEmEnergyInEE_80  = dbe->book1D("EmEnergyInEE_80", "EmEnergyInEE_80", 100, 0, 1000); 
00206     mEmEnergyInEB_3000= dbe->book1D("EmEnergyInEB_3000", "EmEnergyInEB_3000", 100, 0, 3000); 
00207     mEmEnergyInEE_3000= dbe->book1D("EmEnergyInEE_3000", "EmEnergyInEE_3000", 100, 0, 2000); 
00208     mEnergyFractionHadronic = dbe->book1D("EnergyFractionHadronic", "EnergyFractionHadronic", 120, -0.1, 1.1); 
00209     mEnergyFractionEm = dbe->book1D("EnergyFractionEm", "EnergyFractionEm", 120, -0.1, 1.1); 
00210     //
00211     mHFTotal          = dbe->book1D("HFTotal", "HFTotal", 100, 0, 500);
00212     mHFTotal_80       = dbe->book1D("HFTotal_80", "HFTotal_80", 100, 0, 3000);
00213     mHFTotal_3000     = dbe->book1D("HFTotal_3000", "HFTotal_3000", 100, 0, 6000);
00214     mHFLong           = dbe->book1D("HFLong", "HFLong", 100, 0, 500);
00215     mHFLong_80        = dbe->book1D("HFLong_80", "HFLong_80", 100, 0, 200);
00216     mHFLong_3000      = dbe->book1D("HFLong_3000", "HFLong_3000", 100, 0, 1500);
00217     mHFShort          = dbe->book1D("HFShort", "HFShort", 100, 0, 500);
00218     mHFShort_80       = dbe->book1D("HFShort_80", "HFShort_80", 100, 0, 200);
00219     mHFShort_3000     = dbe->book1D("HFShort_3000", "HFShort_3000", 100, 0, 1500);
00220     //
00221     mN90              = dbe->book1D("N90", "N90", 50, 0, 50); 
00222     */
00223     //
00224     mGenEta           = dbe->book1D("GenEta", "GenEta", 100, -5, 5);
00225     mGenPhi           = dbe->book1D("GenPhi", "GenPhi", 70, -3.5, 3.5);
00226     mGenPt            = dbe->book1D("GenPt", "GenPt", 100, 0, 50);
00227     mGenPt_80         = dbe->book1D("GenPt_80", "GenPt_80", 100, 0, 140);
00228     mGenPt_3000       = dbe->book1D("GenPt_3000", "GenPt_3000", 100, 0, 1500);
00229     //
00230     mGenEtaFirst      = dbe->book1D("GenEtaFirst", "GenEtaFirst", 100, -5, 5);
00231     mGenPhiFirst      = dbe->book1D("GenPhiFirst", "GenPhiFirst", 70, -3.5, 3.5);
00232     //
00233     mCaloMEx          = dbe->book1D("CaloMEx","CaloMEx",200,-150,150);
00234     mCaloMEx_3000     = dbe->book1D("CaloMEx_3000","CaloMEx_3000",100,-500,500);
00235     mCaloMEy          = dbe->book1D("CaloMEy","CaloMEy",200,-150,150);
00236     mCaloMEy_3000     = dbe->book1D("CaloMEy_3000","CaloMEy_3000",100,-500,500);
00237     mCaloMETSig       = dbe->book1D("CaloMETSig","CaloMETSig",100,0,15);
00238     mCaloMETSig_3000  = dbe->book1D("CaloMETSig_3000","CaloMETSig_3000",100,0,50);
00239     mCaloMET          = dbe->book1D("CaloMET","CaloMET",100,0,150);
00240     mCaloMET_3000     = dbe->book1D("CaloMET_3000","CaloMET_3000",100,0,1000);
00241     mCaloMETPhi       = dbe->book1D("CaloMETPhi","CaloMETPhi",70, -3.5, 3.5);
00242     mCaloSumET        = dbe->book1D("CaloSumET","CaloSumET",100,0,500);
00243     mCaloSumET_3000   = dbe->book1D("CaloSumET_3000","CaloSumET_3000",100,3000,8000);
00244     //
00245     mHadTiming        = dbe->book1D("HadTiming", "HadTiming", 75, -50, 100);
00246     mEmTiming         = dbe->book1D("EMTiming", "EMTiming", 75, -50, 100);
00247     //
00248     mNJetsEtaC        = dbe->book1D("NJetsEtaC_Pt10", "NJetsEtaC_Pt10", 15, 0, 15);
00249     mNJetsEtaF        = dbe->book1D("NJetsEtaF_Pt10", "NJetsEtaF_Pt10", 15, 0, 15);
00250     //
00251     mNJets1           = dbe->bookProfile("NJets1", "NJets1", 100, 0, 200,  100, 0, 50, "s");
00252     mNJets2           = dbe->bookProfile("NJets2", "NJets2", 100, 0, 4000, 100, 0, 50, "s");
00253     //
00254     mHBEne     = dbe->book1D( "HBEne",  "HBEne", 1000, -20, 100 );
00255     mHBTime    = dbe->book1D( "HBTime", "HBTime", 200, -200, 200 );
00256     mHEEne     = dbe->book1D( "HEEne",  "HEEne", 1000, -20, 100 );
00257     mHETime    = dbe->book1D( "HETime", "HETime", 200, -200, 200 );
00258     mHOEne     = dbe->book1D( "HOEne",  "HOEne", 1000, -20, 100 );
00259     mHOTime    = dbe->book1D( "HOTime", "HOTime", 200, -200, 200 );
00260     mHFEne     = dbe->book1D( "HFEne",  "HFEne", 1000, -20, 100 );
00261     mHFTime    = dbe->book1D( "HFTime", "HFTime", 200, -200, 200 );
00262     mEBEne     = dbe->book1D( "EBEne",  "EBEne", 1000, -20, 100 );
00263     mEBTime    = dbe->book1D( "EBTime", "EBTime", 200, -200, 200 );
00264     mEEEne     = dbe->book1D( "EEEne",  "EEEne", 1000, -20, 100 );
00265     mEETime    = dbe->book1D( "EETime", "EETime", 200, -200, 200 );
00266     //
00267     mPthat_80            = dbe->book1D("Pthat_80", "Pthat_80", 100, 40.0, 160.0); 
00268     mPthat_3000          = dbe->book1D("Pthat_3000", "Pthat_3000", 100, 2500.0, 4000.0); 
00269     //
00270     double log10PtMin = 0.5; //=3.1622766
00271     double log10PtMax = 3.75; //=5623.41325
00272     int log10PtBins = 26; 
00273     double etaMin = -5.;
00274     double etaMax = 5.;
00275     int etaBins = 50;
00276 
00277     double linPtMin = 5;
00278     double linPtMax = 155;
00279     int linPtBins = 15;
00280 
00281     int log10PtFineBins = 50;
00282 
00283     mAllGenJetsPt = dbe->book1D("GenJetLOGpT", "GenJet LOG(pT_gen)", 
00284                                 log10PtBins, log10PtMin, log10PtMax);
00285     mMatchedGenJetsPt = dbe->book1D("MatchedGenJetLOGpT", "MatchedGenJet LOG(pT_gen)", 
00286                                     log10PtBins, log10PtMin, log10PtMax);
00287     mAllGenJetsEta = dbe->book2D("GenJetEta", "GenJet Eta vs LOG(pT_gen)", 
00288                                  log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax);
00289     mMatchedGenJetsEta = dbe->book2D("MatchedGenJetEta", "MatchedGenJet Eta vs LOG(pT_gen)", 
00290                                      log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax);
00291     //
00292     if (mTurnOnEverything.compare("yes")==0) {
00293       mHadEnergyProfile = dbe->bookProfile2D("HadEnergyProfile", "HadEnergyProfile", 82, -41, 41, 73, 0, 73, 100, 0, 10000, "s");
00294       mEmEnergyProfile  = dbe->bookProfile2D("EmEnergyProfile", "EmEnergyProfile", 82, -41, 41, 73, 0, 73, 100, 0, 10000, "s");
00295     }
00296     mJetEnergyProfile = dbe->bookProfile2D("JetEnergyProfile", "JetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00297     /*
00298     mHadJetEnergyProfile = dbe->bookProfile2D("HadJetEnergyProfile", "HadJetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00299     mEMJetEnergyProfile = dbe->bookProfile2D("EMJetEnergyProfile", "EMJetEnergyProfile", 50, -5, 5, 36, -3.1415987, 3.1415987, 100, 0, 10000, "s");
00300     */
00301 
00302     //
00303     if (mTurnOnEverything.compare("yes")==0) {
00304       mGenJetMatchEnergyFraction  = dbe->book3D("GenJetMatchEnergyFraction", "GenJetMatchEnergyFraction vs LOG(pT_gen) vs eta", 
00305                                                 log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 101, 0, 1.01);
00306       mReverseMatchEnergyFraction  = dbe->book3D("ReverseMatchEnergyFraction", "ReverseMatchEnergyFraction vs LOG(pT_gen) vs eta", 
00307                                                log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 101, 0, 1.01);
00308       mRMatch  = dbe->book3D("RMatch", "delta(R)(Gen-Calo) vs LOG(pT_gen) vs eta", 
00309                              log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 60, 0, 3);
00310       mDeltaEta = dbe->book3D("DeltaEta", "DeltaEta vs LOG(pT_gen) vs eta", 
00311                               log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, -1, 1);
00312       mDeltaPhi = dbe->book3D("DeltaPhi", "DeltaPhi vs LOG(pT_gen) vs eta", 
00313                               log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, -1, 1);
00314       mEScale = dbe->book3D("EScale", "EnergyScale vs LOG(pT_gen) vs eta", 
00315                             log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00316       mlinEScale = dbe->book3D("linEScale", "EnergyScale vs LOG(pT_gen) vs eta", 
00317                                linPtBins, linPtMin, linPtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00318       mDeltaE = dbe->book3D("DeltaE", "DeltaE vs LOG(pT_gen) vs eta", 
00319                             log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 2000, -200, 200);
00320       //
00321       mEScale_pt10 = dbe->book3D("EScale_pt10", "EnergyScale vs LOG(pT_gen) vs eta", 
00322                                  log10PtBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00323       mEScaleFineBin = dbe->book3D("EScaleFineBins", "EnergyScale vs LOG(pT_gen) vs eta", 
00324                                    log10PtFineBins, log10PtMin, log10PtMax, etaBins, etaMin, etaMax, 100, 0, 2);
00325     }
00326 
00327     mpTScaleB_s = dbe->bookProfile("pTScaleB_s", "pTScale_s_0<|eta|<1.3",
00328                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00329     mpTScaleE_s = dbe->bookProfile("pTScaleE_s", "pTScale_s_1.3<|eta|<3.0",
00330                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00331     mpTScaleF_s = dbe->bookProfile("pTScaleF_s", "pTScale_s_3.0<|eta|<5.0",
00332                                     log10PtBins, log10PtMin, log10PtMax, 0, 2, "s");
00333     mpTScaleB_d = dbe->bookProfile("pTScaleB_d", "pTScale_d_0<|eta|<1.3",
00334                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00335     mpTScaleE_d = dbe->bookProfile("pTScaleE_d", "pTScale_d_1.3<|eta|<3.0",
00336                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00337     mpTScaleF_d = dbe->bookProfile("pTScaleF_d", "pTScale_d_3.0<|eta|<5.0",
00338                                    log10PtBins, log10PtMin, log10PtMax, 0, 2, " ");
00339 
00340     mpTScale_60_120_s    = dbe->bookProfile("pTScale_60_120_s", "pTScale_s_60<pT<120",
00341                                           etaBins, etaMin, etaMax, 0., 2., "s");
00342     mpTScale_200_300_s   = dbe->bookProfile("pTScale_200_300_s", "pTScale_s_200<pT<300",
00343                                           etaBins, etaMin, etaMax, 0., 2., "s");
00344     mpTScale_600_900_s   = dbe->bookProfile("pTScale_600_900_s", "pTScale_s_600<pT<900",
00345                                           etaBins, etaMin, etaMax, 0., 2., "s");
00346     mpTScale_2700_3500_s = dbe->bookProfile("pTScale_2700_3500_s", "pTScale_s_2700<pt<3500",
00347                                           etaBins, etaMin, etaMax, 0., 2., "s");
00348     mpTScale_60_120_d    = dbe->bookProfile("pTScale_60_120_d", "pTScale_d_60<pT<120",
00349                                           etaBins, etaMin, etaMax, 0., 2., " ");
00350     mpTScale_200_300_d   = dbe->bookProfile("pTScale_200_300_d", "pTScale_d_200<pT<300",
00351                                           etaBins, etaMin, etaMax, 0., 2., " ");
00352     mpTScale_600_900_d   = dbe->bookProfile("pTScale_600_900_d", "pTScale_d_600<pT<900",
00353                                           etaBins, etaMin, etaMax, 0., 2., " ");
00354     mpTScale_2700_3500_d = dbe->bookProfile("pTScale_2700_3500_d", "pTScale_d_2700<pt<3500",
00355                                           etaBins, etaMin, etaMax, 0., 2., " ");
00356 
00357     mpTScale1DB_60_120 = dbe->book1D("pTScale1DB_60_120", "pTScale_distribution_for_0<|eta|<1.3_60_120",
00358                                    100, 0, 2);
00359     mpTScale1DE_60_120 = dbe->book1D("pTScale1DE_60_120", "pTScale_distribution_for_1.3<|eta|<3.0_60_120",
00360                                    100, 0, 2);
00361     mpTScale1DF_60_120 = dbe->book1D("pTScale1DF_60_120", "pTScale_distribution_for_3.0<|eta|<5.0_60_120",
00362                                    100, 0, 2);
00363 
00364     mpTScale1DB_200_300 = dbe->book1D("pTScale1DB_200_300", "pTScale_distribution_for_0<|eta|<1.3_200_300",
00365                                    100, 0, 2);
00366     mpTScale1DE_200_300 = dbe->book1D("pTScale1DE_200_300", "pTScale_distribution_for_1.3<|eta|<3.0_200_300",
00367                                    100, 0, 2);
00368     mpTScale1DF_200_300 = dbe->book1D("pTScale1DF_200_300", "pTScale_distribution_for_3.0<|eta|<5.0_200_300",
00369                                    100, 0, 2);
00370 
00371     mpTScale1DB_600_900 = dbe->book1D("pTScale1DB_600_900", "pTScale_distribution_for_0<|eta|<1.3_600_900",
00372                                    100, 0, 2);
00373     mpTScale1DE_600_900 = dbe->book1D("pTScale1DE_600_900", "pTScale_distribution_for_1.3<|eta|<3.0_600_900",
00374                                    100, 0, 2);
00375     mpTScale1DF_600_900 = dbe->book1D("pTScale1DF_600_900", "pTScale_distribution_for_3.0<|eta|<5.0_600_900",
00376                                    100, 0, 2);
00377 
00378     mpTScale1DB_2700_3500 = dbe->book1D("pTScale1DB_2700_3500", "pTScale_distribution_for_0<|eta|<1.3_2700_3500",
00379                                    100, 0, 2);
00380     mpTScale1DE_2700_3500 = dbe->book1D("pTScale1DE_2700_3500", "pTScale_distribution_for_1.3<|eta|<3.0_2700_3500",
00381                                    100, 0, 2);
00382     mpTScale1DF_2700_3500 = dbe->book1D("pTScale1DF_2700_3500", "pTScale_distribution_for_3.0<|eta|<5.0_2700_3500",
00383                                    100, 0, 2);
00384 
00385     mpTScale1D_60_120    = dbe->book1D("pTScale1D_60_120", "pTScale_distribution_for_60<pT<120",
00386                                             100, 0, 2);
00387     mpTScale1D_200_300    = dbe->book1D("pTScale1D_200_300", "pTScale_distribution_for_200<pT<300",
00388                                             100, 0, 2);
00389     mpTScale1D_600_900    = dbe->book1D("pTScale1D_600_900", "pTScale_distribution_for_600<pT<900",
00390                                             100, 0, 2);
00391     mpTScale1D_2700_3500 = dbe->book1D("pTScale1D_2700_3500", "pTScale_distribution_for_2700<pt<3500",
00392                                             100, 0, 2);
00393   } // if (dbe)
00394 
00395   if (mOutputFile.empty ()) {
00396     LogInfo("OutputInfo") << " JPTJet histograms will NOT be saved";
00397   } 
00398   else {
00399     LogInfo("OutputInfo") << " JPTJethistograms will be saved to file:" << mOutputFile;
00400   }
00401 }
00402    
00403 JPTJetTester::~JPTJetTester()
00404 {
00405 }
00406 
00407 void JPTJetTester::beginJob(){
00408 }
00409 
00410 void JPTJetTester::endJob() {
00411  if (!mOutputFile.empty() && &*edm::Service<DQMStore>()) edm::Service<DQMStore>()->save (mOutputFile);
00412 }
00413 
00414 
00415 void JPTJetTester::analyze(const edm::Event& mEvent, const edm::EventSetup& mSetup)
00416 {
00417   double countsfornumberofevents = 1;
00418   numberofevents->Fill(countsfornumberofevents);
00419   // *********************************
00420   // *** Get pThat
00421   // *********************************
00422 
00423   edm::Handle<HepMCProduct> evt;
00424   mEvent.getByLabel("generator", evt);
00425   if (evt.isValid()) {
00426   HepMC::GenEvent * myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
00427   
00428   double pthat = myGenEvent->event_scale();
00429 
00430   mPthat_80->Fill(pthat);
00431   mPthat_3000->Fill(pthat);
00432 
00433   delete myGenEvent; 
00434   }
00435 
00436   // ***********************************
00437   // *** Get CaloMET
00438   // ***********************************
00439 
00440   const CaloMET *calomet;
00441   edm::Handle<CaloMETCollection> calo;
00442   mEvent.getByLabel("met", calo);
00443   if (!calo.isValid()) {
00444     edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
00445     edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
00446   } else {
00447     const CaloMETCollection *calometcol = calo.product();
00448     calomet = &(calometcol->front());
00449     
00450     double caloSumET = calomet->sumEt();
00451     double caloMETSig = calomet->mEtSig();
00452     double caloMET = calomet->pt();
00453     double caloMEx = calomet->px();
00454     double caloMEy = calomet->py();
00455     double caloMETPhi = calomet->phi();
00456 
00457     mCaloMEx->Fill(caloMEx);
00458     mCaloMEx_3000->Fill(caloMEx);
00459     mCaloMEy->Fill(caloMEy);
00460     mCaloMEy_3000->Fill(caloMEy);
00461     mCaloMET->Fill(caloMET);
00462     mCaloMET_3000->Fill(caloMET);
00463     mCaloMETPhi->Fill(caloMETPhi);
00464     mCaloSumET->Fill(caloSumET);
00465     mCaloSumET_3000->Fill(caloSumET);
00466     mCaloMETSig->Fill(caloMETSig);
00467     mCaloMETSig_3000->Fill(caloMETSig);
00468   }
00469 
00470   // ***********************************
00471   // *** Get the CaloTower collection
00472   // ***********************************
00473   Handle<CaloTowerCollection> caloTowers;
00474   mEvent.getByLabel( "towerMaker", caloTowers );
00475   if (caloTowers.isValid()) {
00476   for( CaloTowerCollection::const_iterator cal = caloTowers->begin(); cal != caloTowers->end(); ++ cal ){
00477 
00478     //To compensate for the index
00479     if (mTurnOnEverything.compare("yes")==0) {
00480       if (cal->ieta() >> 0 ){mHadEnergyProfile->Fill (cal->ieta()-1, cal->iphi(), cal->hadEnergy());
00481       mEmEnergyProfile->Fill (cal->ieta()-1, cal->iphi(), cal->emEnergy());}
00482       mHadEnergyProfile->Fill (cal->ieta(), cal->iphi(), cal->hadEnergy());
00483       mEmEnergyProfile->Fill (cal->ieta(), cal->iphi(), cal->emEnergy());
00484     }
00485 
00486     mHadTiming->Fill (cal->hcalTime());
00487     mEmTiming->Fill (cal->ecalTime());    
00488   }
00489   }
00490   
00491   // ***********************************
00492   // *** Get the RecHits collection
00493   // ***********************************
00494   try {
00495     std::vector<edm::Handle<HBHERecHitCollection> > colls;
00496     mEvent.getManyByType(colls);
00497     std::vector<edm::Handle<HBHERecHitCollection> >::iterator i;
00498     for (i=colls.begin(); i!=colls.end(); i++) {
00499       for (HBHERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00500         //      std::cout << *j << std::endl;
00501         if (j->id().subdet() == HcalBarrel) {
00502           mHBEne->Fill(j->energy()); 
00503           mHBTime->Fill(j->time()); 
00504         }
00505         if (j->id().subdet() == HcalEndcap) {
00506           mHEEne->Fill(j->energy()); 
00507           mHETime->Fill(j->time()); 
00508         }
00509       }
00510     }
00511   } catch (...) {
00512     edm::LogInfo("OutputInfo") << " No HB/HE RecHits.";
00513   }
00514   
00515   try {
00516     std::vector<edm::Handle<HFRecHitCollection> > colls;
00517     mEvent.getManyByType(colls);
00518     std::vector<edm::Handle<HFRecHitCollection> >::iterator i;
00519     for (i=colls.begin(); i!=colls.end(); i++) {
00520       for (HFRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00521         //      std::cout << *j << std::endl;
00522         if (j->id().subdet() == HcalForward) {
00523           mHFEne->Fill(j->energy()); 
00524           mHFTime->Fill(j->time()); 
00525         }
00526       }
00527     }
00528   } catch (...) {
00529     edm::LogInfo("OutputInfo") << " No HF RecHits.";
00530   }
00531 
00532   try {
00533     std::vector<edm::Handle<HORecHitCollection> > colls;
00534     mEvent.getManyByType(colls);
00535     std::vector<edm::Handle<HORecHitCollection> >::iterator i;
00536     for (i=colls.begin(); i!=colls.end(); i++) {
00537       for (HORecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00538         if (j->id().subdet() == HcalOuter) {
00539           mHOEne->Fill(j->energy()); 
00540           mHOTime->Fill(j->time()); 
00541         }
00542       }
00543     }
00544   } catch (...) {
00545     edm::LogInfo("OutputInfo") << " No HO RecHits.";
00546   }
00547   try {
00548     std::vector<edm::Handle<EBRecHitCollection> > colls;
00549     mEvent.getManyByType(colls);
00550     std::vector<edm::Handle<EBRecHitCollection> >::iterator i;
00551     for (i=colls.begin(); i!=colls.end(); i++) {
00552       for (EBRecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00553         //      if (j->id() == EcalBarrel) {
00554         mEBEne->Fill(j->energy()); 
00555         mEBTime->Fill(j->time()); 
00556         //    }
00557         //      std::cout << *j << std::endl;
00558         //      std::cout << j->id() << std::endl;
00559       }
00560     }
00561   } catch (...) {
00562     edm::LogInfo("OutputInfo") << " No EB RecHits.";
00563   }
00564 
00565   try {
00566     std::vector<edm::Handle<EERecHitCollection> > colls;
00567     mEvent.getManyByType(colls);
00568     std::vector<edm::Handle<EERecHitCollection> >::iterator i;
00569     for (i=colls.begin(); i!=colls.end(); i++) {
00570       for (EERecHitCollection::const_iterator j=(*i)->begin(); j!=(*i)->end(); j++) {
00571         //      if (j->id().subdet() == EcalEndcap) {
00572         mEEEne->Fill(j->energy()); 
00573         mEETime->Fill(j->time()); 
00574         //    }
00575         //      std::cout << *j << std::endl;
00576       }
00577     }
00578   } catch (...) {
00579     edm::LogInfo("OutputInfo") << " No EE RecHits.";
00580   }
00581 
00582   //***********************************
00583   //*** Get the Jet collection
00584   //***********************************
00585   math::XYZTLorentzVector p4tmp[2];
00586   Handle<JPTJetCollection> jptJets;
00587   mEvent.getByLabel(mInputCollection, jptJets);
00588   if (!jptJets.isValid()) return;
00589   JPTJetCollection::const_iterator jet = jptJets->begin ();
00590   int jetIndex = 0;
00591   int nJet = 0;
00592   int nJetF = 0;
00593   int nJetC = 0;
00594   for (; jet != jptJets->end (); jet++, jetIndex++) {
00595     if (mEta) mEta->Fill (jet->eta());
00596 
00597     if (jet->pt() > 10.) {
00598       if (fabs(jet->eta()) > 1.3) 
00599         nJetF++;
00600       else 
00601         nJetC++;          
00602     }
00603     if (jet->pt() > 10.) {
00604       if (mEtaFineBin) mEtaFineBin->Fill (jet->eta());
00605       if (mEtaFineBin1p) mEtaFineBin1p->Fill (jet->eta());
00606       if (mEtaFineBin2p) mEtaFineBin2p->Fill (jet->eta());
00607       if (mEtaFineBin3p) mEtaFineBin3p->Fill (jet->eta());
00608       if (mEtaFineBin1m) mEtaFineBin1m->Fill (jet->eta());
00609       if (mEtaFineBin2m) mEtaFineBin2m->Fill (jet->eta());
00610       if (mEtaFineBin3m) mEtaFineBin3m->Fill (jet->eta());
00611       if (mPhiFineBin) mPhiFineBin->Fill (jet->phi());
00612     }
00613     if (mPhi) mPhi->Fill (jet->phi());
00614     if (mE) mE->Fill (jet->energy());
00615     if (mE_80) mE_80->Fill (jet->energy());
00616     if (mE_3000) mE_3000->Fill (jet->energy());
00617     if (mP) mP->Fill (jet->p());
00618     if (mP_80) mP_80->Fill (jet->p());
00619     if (mP_3000) mP_3000->Fill (jet->p());
00620     if (mPt) mPt->Fill (jet->pt());
00621     if (mPt_80) mPt_80->Fill (jet->pt());
00622     if (mPt_3000) mPt_3000->Fill (jet->pt());
00623     if (mMass) mMass->Fill (jet->mass());
00624     if (mMass_80) mMass_80->Fill (jet->mass());
00625     if (mMass_3000) mMass_3000->Fill (jet->mass());
00626     //    if (mConstituents) mConstituents->Fill (jet->nConstituents());
00627     //    if (mConstituents_80) mConstituents_80->Fill (jet->nConstituents());
00628     if (jet == jptJets->begin ()) { // first jet
00629       if (mEtaFirst) mEtaFirst->Fill (jet->eta());
00630       if (mPhiFirst) mPhiFirst->Fill (jet->phi());
00631       if (mEFirst) mEFirst->Fill (jet->energy());
00632       if (mEFirst_80) mEFirst_80->Fill (jet->energy());
00633       if (mEFirst_3000) mEFirst_3000->Fill (jet->energy());
00634       if (mPtFirst) mPtFirst->Fill (jet->pt());
00635       if (mPtFirst_80) mPtFirst_80->Fill (jet->pt());
00636       if (mPtFirst_3000) mPtFirst_3000->Fill (jet->pt());
00637     }
00638     if (jetIndex == 0) {
00639       nJet++;
00640       p4tmp[0] = jet->p4();     
00641     }
00642     if (jetIndex == 1) {
00643       nJet++;
00644       p4tmp[1] = jet->p4();     
00645     }
00646 
00647     double sumPtPionsInVertexInCalo = getSumPt(jet->getPionsInVertexInCalo());
00648     double sumPtPionsInVertexOutCalo = getSumPt(jet->getPionsInVertexOutCalo());
00649     double sumPtPionsOutVertexInCalo = getSumPt(jet->getPionsOutVertexInCalo());
00650     double sumPtMuonsInVertexInCalo = getSumPt(jet->getMuonsInVertexInCalo());
00651     double sumPtMuonsInVertexOutCalo = getSumPt(jet->getMuonsInVertexOutCalo());
00652     double sumPtMuonsOutVertexInCalo = getSumPt(jet->getMuonsOutVertexInCalo());
00653     double sumPtElecsInVertexInCalo = getSumPt(jet->getElecsInVertexInCalo());
00654     double sumPtElecsInVertexOutCalo = getSumPt(jet->getElecsInVertexOutCalo());
00655     double sumPtElecsOutVertexInCalo = getSumPt(jet->getElecsOutVertexInCalo());
00656     if (jet->pt()!=0.){
00657       mPtFractionPionInVertexInCalo->Fill(sumPtPionsInVertexInCalo/jet->pt());
00658       mPtFractionPionInVertexOutCalo->Fill(sumPtPionsInVertexOutCalo/jet->pt());
00659       mPtFractionPionOutVertexInCalo->Fill(sumPtPionsOutVertexInCalo/jet->pt());
00660 
00661       mPtFractionMuonInVertexInCalo->Fill(sumPtMuonsInVertexInCalo/jet->pt());
00662       mPtFractionMuonInVertexOutCalo->Fill(sumPtMuonsInVertexOutCalo/jet->pt());
00663       mPtFractionMuonOutVertexInCalo->Fill(sumPtMuonsOutVertexInCalo/jet->pt());
00664 
00665       mPtFractionElecInVertexInCalo->Fill(sumPtElecsInVertexInCalo/jet->pt());
00666       mPtFractionElecInVertexOutCalo->Fill(sumPtElecsInVertexOutCalo/jet->pt());
00667       mPtFractionElecOutVertexInCalo->Fill(sumPtElecsOutVertexInCalo/jet->pt());
00668 
00669       //
00670       mMultiplicityPionInVertexInCalo->Fill(jet->getPionsInVertexInCalo().size());
00671       mMultiplicityPionInVertexOutCalo->Fill(jet->getPionsInVertexOutCalo().size());
00672       mMultiplicityPionOutVertexInCalo->Fill(jet->getPionsOutVertexInCalo().size());
00673 
00674       mMultiplicityMuonInVertexInCalo->Fill(jet->getMuonsInVertexInCalo().size());
00675       mMultiplicityMuonInVertexOutCalo->Fill(jet->getMuonsInVertexOutCalo().size());
00676       mMultiplicityMuonOutVertexInCalo->Fill(jet->getMuonsOutVertexInCalo().size());
00677 
00678       mMultiplicityElecInVertexInCalo->Fill(jet->getElecsInVertexInCalo().size());
00679       mMultiplicityElecInVertexOutCalo->Fill(jet->getElecsInVertexOutCalo().size());
00680       mMultiplicityElecOutVertexInCalo->Fill(jet->getElecsOutVertexInCalo().size());
00681     }
00682 
00683     /*
00684     if (mMaxEInEmTowers) mMaxEInEmTowers->Fill ( (jet->getCaloJetRef()->maxEInEmTowers());
00685     if (mMaxEInHadTowers) mMaxEInHadTowers->Fill (jet->getCaloJetRef()->maxEInHadTowers());
00686     if (mHadEnergyInHO) mHadEnergyInHO->Fill (jet->getCaloJetRef()->hadEnergyInHO());
00687     if (mHadEnergyInHO_80)   mHadEnergyInHO_80->Fill (jet->getCaloJetRef()->hadEnergyInHO());
00688     if (mHadEnergyInHO_3000) mHadEnergyInHO_3000->Fill (jet->getCaloJetRef()->hadEnergyInHO());
00689     if (mHadEnergyInHB) mHadEnergyInHB->Fill (jet->getCaloJetRef()->hadEnergyInHB());
00690     if (mHadEnergyInHB_80)   mHadEnergyInHB_80->Fill (jet->getCaloJetRef()->hadEnergyInHB());
00691     if (mHadEnergyInHB_3000) mHadEnergyInHB_3000->Fill (jet->getCaloJetRef()->hadEnergyInHB());
00692     if (mHadEnergyInHF) mHadEnergyInHF->Fill (jet->getCaloJetRef()->hadEnergyInHF());
00693     if (mHadEnergyInHE) mHadEnergyInHE->Fill (jet->getCaloJetRef()->hadEnergyInHE());
00694     if (mHadEnergyInHE_80)   mHadEnergyInHE_80->Fill (jet->getCaloJetRef()->hadEnergyInHE());
00695     if (mHadEnergyInHE_3000) mHadEnergyInHE_3000->Fill (jet->getCaloJetRef()->hadEnergyInHE());
00696     if (mEmEnergyInEB) mEmEnergyInEB->Fill (jet->getCaloJetRef()->emEnergyInEB());
00697     if (mEmEnergyInEB_80)   mEmEnergyInEB_80->Fill (jet->getCaloJetRef()->emEnergyInEB());
00698     if (mEmEnergyInEB_3000) mEmEnergyInEB_3000->Fill (jet->getCaloJetRef()->emEnergyInEB());
00699     if (mEmEnergyInEE) mEmEnergyInEE->Fill (jet->getCaloJetRef()->emEnergyInEE());
00700     if (mEmEnergyInEE_80)   mEmEnergyInEE_80->Fill (jet->getCaloJetRef()->emEnergyInEE());
00701     if (mEmEnergyInEE_3000) mEmEnergyInEE_3000->Fill (jet->getCaloJetRef()->emEnergyInEE());
00702     if (mEmEnergyInHF) mEmEnergyInHF->Fill (jet->getCaloJetRef()->emEnergyInHF());
00703     if (mEnergyFractionHadronic) mEnergyFractionHadronic->Fill (jet->getCaloJetRef()->energyFractionHadronic());
00704     if (mEnergyFractionEm) mEnergyFractionEm->Fill (jet->getCaloJetRef()->emEnergyFraction());
00705 
00706     if (mHFTotal)      mHFTotal->Fill (jet->getCaloJetRef()->hadEnergyInHF()+jet->getCaloJetRef()->emEnergyInHF());
00707     if (mHFTotal_80)   mHFTotal_80->Fill (jet->getCaloJetRef()->hadEnergyInHF()+jet->getCaloJetRef()->emEnergyInHF());
00708     if (mHFTotal_3000) mHFTotal_3000->Fill (jet->getCaloJetRef()->hadEnergyInHF()+jet->getCaloJetRef()->emEnergyInHF());
00709     if (mHFLong)       mHFLong->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5+jet->getCaloJetRef()->emEnergyInHF());
00710     if (mHFLong_80)    mHFLong_80->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5+jet->getCaloJetRef()->emEnergyInHF());
00711     if (mHFLong_3000)  mHFLong_3000->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5+jet->getCaloJetRef()->emEnergyInHF());
00712     if (mHFShort)      mHFShort->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5);
00713     if (mHFShort_80)   mHFShort_80->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5);
00714     if (mHFShort_3000) mHFShort_3000->Fill (jet->getCaloJetRef()->hadEnergyInHF()*0.5);
00715     */
00716 
00717     /*
00718     if (mN90) mN90->Fill (jet->getCaloJetRef()->n90());
00719     */
00720     mJetEnergyProfile->Fill (jet->eta(), jet->phi(), jet->energy());
00721     /*
00722     mHadJetEnergyProfile->Fill (jet->eta(), jet->phi(), 
00723                                 jet->getCaloJetRef()->hadEnergyInHO()+
00724                                 jet->getCaloJetRef()->hadEnergyInHB()+
00725                                 jet->getCaloJetRef()->hadEnergyInHF()+
00726                                 jet->getCaloJetRef()->hadEnergyInHE());
00727     mEMJetEnergyProfile->Fill (jet->eta(), jet->phi(), 
00728                                jet->getCaloJetRef()->emEnergyInEB()+
00729                                jet->getCaloJetRef()->emEnergyInEE()+
00730                                jet->getCaloJetRef()->emEnergyInHF());
00731     */
00732   }
00733 
00734   if (mNJetsEtaC) mNJetsEtaC->Fill( nJetC );
00735   if (mNJetsEtaF) mNJetsEtaF->Fill( nJetF );
00736 
00737   if (nJet == 2) {
00738     if (mMjj) mMjj->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00739     if (mMjj_3000) mMjj_3000->Fill( (p4tmp[0]+p4tmp[1]).mass() );
00740   }
00741 
00742   // Count Jets above Pt cut
00743   for (int istep = 0; istep < 100; ++istep) {
00744     int     njet = 0;
00745     float ptStep = (istep * (200./100.));
00746 
00747     for ( JPTJetCollection::const_iterator jpt = jptJets->begin(); jpt != jptJets->end(); ++ jpt ) {
00748       if ( jpt->pt() > ptStep ) njet++;
00749     }
00750     mNJets1->Fill( ptStep, njet );
00751   }
00752 
00753   for (int istep = 0; istep < 100; ++istep) {
00754     int     njet = 0;
00755     float ptStep = (istep * (4000./100.));
00756     for ( JPTJetCollection::const_iterator jpt = jptJets->begin(); jpt != jptJets->end(); ++ jpt ) {
00757       if ( jpt->pt() > ptStep ) njet++;
00758     }
00759     mNJets2->Fill( ptStep, njet );
00760   }
00761 
00762   // Gen jet analysis
00763   Handle<GenJetCollection> genJets;
00764   mEvent.getByLabel(mInputGenCollection, genJets);
00765   if (!genJets.isValid()) return;
00766   GenJetCollection::const_iterator gjet = genJets->begin ();
00767   int gjetIndex = 0;
00768   for (; gjet != genJets->end (); gjet++, gjetIndex++) {
00769     if (mGenEta) mGenEta->Fill (gjet->eta());
00770     if (mGenPhi) mGenPhi->Fill (gjet->phi());
00771     if (mGenPt) mGenPt->Fill (gjet->pt());
00772     if (mGenPt_80) mGenPt_80->Fill (gjet->pt());
00773     if (mGenPt_3000) mGenPt_3000->Fill (gjet->pt());
00774     if (gjet == genJets->begin ()) { // first jet
00775       if (mGenEtaFirst) mGenEtaFirst->Fill (gjet->eta());
00776       if (mGenPhiFirst) mGenPhiFirst->Fill (gjet->phi());
00777     }
00778   }
00779 
00780 
00781   // now match JPTJets to GenJets
00782   JetMatchingTools jetMatching (mEvent);
00783   if (!(mInputGenCollection.label().empty())) {
00784     //    Handle<GenJetCollection> genJets;
00785     //    mEvent.getByLabel(mInputGenCollection, genJets);
00786 
00787     std::vector <std::vector <const reco::GenParticle*> > genJetConstituents (genJets->size());
00788     std::vector <std::vector <const reco::GenParticle*> > jptJetConstituents (jptJets->size());
00789     //     if (mRThreshold > 0) { 
00790     //     }
00791     //     else {
00792     //       for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
00793     //  genJetConstituents [iGenJet] = jetMatching.getGenParticles ((*genJets) [iGenJet]);
00794     //       }
00795     
00796     //       for (unsigned iJPTJet = 0; iJPTJet < jptJets->size(); ++iJPTJet) {
00797     //  jptJetConstituents [iJPTJet] = jetMatching.getGenParticles ((*(*jptJets) [iJPTJet].getCaloJetRef()), false);
00798     //       }
00799     //     }
00800     
00801     for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {               //****************************************************************
00802     //for (unsigned iGenJet = 0; iGenJet < 1; ++iGenJet) {                           // only FIRST Jet !!!!
00803       const GenJet& genJet = (*genJets) [iGenJet];
00804       double genJetPt = genJet.pt();
00805 
00806       //std::cout << iGenJet <<". Genjet: pT = " << genJetPt << "GeV" << std::endl;  //  *****************************************************
00807 
00808       if (fabs(genJet.eta()) > 5.) continue; // out of detector 
00809       if (genJetPt < mMatchGenPtThreshold) continue; // no low momentum 
00810       double logPtGen = log10 (genJetPt);
00811       mAllGenJetsPt->Fill (logPtGen);
00812       mAllGenJetsEta->Fill (logPtGen, genJet.eta());
00813       if (jptJets->size() <= 0) continue; // no JPTJets - nothing to match
00814       if (mRThreshold > 0) {
00815         unsigned iJPTJetBest = 0;
00816         double deltaRBest = 999.;
00817         for (unsigned iJPTJet = 0; iJPTJet < jptJets->size(); ++iJPTJet) {
00818           double dR = deltaR (genJet.eta(), genJet.phi(), (*jptJets) [iJPTJet].eta(), (*jptJets) [iJPTJet].phi());
00819           if (deltaRBest < mRThreshold && dR < mRThreshold && genJet.pt() > 5.) {
00820             /*
00821             std::cout << "Yet another matched jet for GenJet pt=" << genJet.pt()
00822                       << " previous JPTJet pt/dr: " << (*jptJets) [iJPTJetBest].pt() << '/' << deltaRBest
00823                       << " new JPTJet pt/dr: " << (*jptJets) [iJPTJet].pt() << '/' << dR
00824                       << std::endl;
00825             */
00826           }
00827           if (dR < deltaRBest) {
00828             iJPTJetBest = iJPTJet;
00829             deltaRBest = dR;
00830           }
00831         }
00832         if (mTurnOnEverything.compare("yes")==0) {
00833           mRMatch->Fill (logPtGen, genJet.eta(), deltaRBest);
00834         }
00835         if (deltaRBest < mRThreshold) { // Matched
00836           fillMatchHists (genJet, (*jptJets) [iJPTJetBest]);
00837         }
00838       }
00839       //       else {
00840       //        unsigned iJPTJetBest = 0;
00841       //        double energyFractionBest = 0.;
00842       //        for (unsigned iJPTJet = 0; iJPTJet < jptJets->size(); ++iJPTJet) {
00843       //          double energyFraction = jetMatching.overlapEnergyFraction (genJetConstituents [iGenJet], 
00844       //                                                                     jptJetConstituents [iJPTJet]);
00845       //          if (energyFraction > energyFractionBest) {
00846       //            iJPTJetBest = iJPTJet;
00847       //            energyFractionBest = energyFraction;
00848       //          }
00849       //        }
00850       //        if (mTurnOnEverything.compare("yes")==0) {
00851       //          mGenJetMatchEnergyFraction->Fill (logPtGen, genJet.eta(), energyFractionBest);
00852       //        }
00853       //        if (energyFractionBest > mGenEnergyFractionThreshold) { // good enough
00854       //          double reverseEnergyFraction = jetMatching.overlapEnergyFraction (jptJetConstituents [iJPTJetBest], 
00855       //                                                                            genJetConstituents [iGenJet]);
00856       //          if (mTurnOnEverything.compare("yes")==0) {
00857       //            mReverseMatchEnergyFraction->Fill (logPtGen, genJet.eta(), reverseEnergyFraction);
00858       //          }
00859       //          if (reverseEnergyFraction > mReverseEnergyFractionThreshold) { // Matched
00860       //            fillMatchHists (genJet, (*jptJets) [iJPTJetBest]);
00861       //          }
00862       //        }
00863       //       } // else - mRThreshold
00864     }
00865   }
00866 }
00867 
00868 
00869 void JPTJetTester::fillMatchHists (const reco::GenJet& fGenJet, const reco::JPTJet& fJPTJet) {
00870   double logPtGen = log10 (fGenJet.pt());
00871   double PtGen = fGenJet.pt();
00872   double PtJpt = fJPTJet.pt();
00873   mMatchedGenJetsPt->Fill (logPtGen);
00874   mMatchedGenJetsEta->Fill (logPtGen, fGenJet.eta());
00875 
00876   double PtThreshold = 10.;
00877 
00878   if (mTurnOnEverything.compare("yes")==0) {
00879     mDeltaEta->Fill (logPtGen, fGenJet.eta(), fJPTJet.eta()-fGenJet.eta());
00880     mDeltaPhi->Fill (logPtGen, fGenJet.eta(), fJPTJet.phi()-fGenJet.phi());
00881     mEScale->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00882     mlinEScale->Fill (fGenJet.pt(), fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00883     mDeltaE->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()-fGenJet.energy());
00884 
00885     mEScaleFineBin->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00886   
00887     if (fGenJet.pt()>PtThreshold) {
00888       mEScale_pt10->Fill (logPtGen, fGenJet.eta(), fJPTJet.energy()/fGenJet.energy());
00889 
00890     }
00891 
00892   }
00893   if (fJPTJet.pt() > PtThreshold) {
00894     mDelEta->Fill (fGenJet.eta()-fJPTJet.eta());
00895     mDelPhi->Fill (fGenJet.phi()-fJPTJet.phi());
00896     mDelPt->Fill  ((fGenJet.pt()-fJPTJet.pt())/fGenJet.pt());
00897   }
00898 
00899   if (fabs(fGenJet.eta())<1.3) {
00900 
00901     mpTScaleB_s->Fill (log10(PtGen), PtJpt/PtGen);
00902     mpTScaleB_d->Fill (log10(PtGen), PtJpt/PtGen);
00903     if (PtGen>60.0 && PtGen<120.0) {
00904       mpTScale1DB_60_120->Fill (fJPTJet.pt()/fGenJet.pt());
00905     }
00906     if (PtGen>200.0 && PtGen<300.0) {
00907       mpTScale1DB_200_300->Fill (fJPTJet.pt()/fGenJet.pt());
00908     }
00909     if (PtGen>600.0 && PtGen<900.0) {
00910       mpTScale1DB_600_900->Fill (fJPTJet.pt()/fGenJet.pt());
00911     }
00912     if (PtGen>2700.0 && PtGen<3500.0) {
00913       mpTScale1DB_2700_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00914     }
00915   }
00916 
00917   if (fabs(fGenJet.eta())>1.3 && fabs(fGenJet.eta())<3.0) {
00918 
00919     mpTScaleE_s->Fill (log10(PtGen), PtJpt/PtGen);
00920     mpTScaleE_d->Fill (log10(PtGen), PtJpt/PtGen);
00921     if (PtGen>60.0 && PtGen<120.0) {
00922       mpTScale1DE_60_120->Fill (fJPTJet.pt()/fGenJet.pt());
00923     }
00924     if (PtGen>200.0 && PtGen<300.0) {
00925       mpTScale1DE_200_300->Fill (fJPTJet.pt()/fGenJet.pt());
00926     }
00927     if (PtGen>600.0 && PtGen<900.0) {
00928       mpTScale1DE_600_900->Fill (fJPTJet.pt()/fGenJet.pt());
00929     }
00930     if (PtGen>2700.0 && PtGen<3500.0) {
00931       mpTScale1DE_2700_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00932     }
00933   }
00934 
00935   if (fabs(fGenJet.eta())>3.0 && fabs(fGenJet.eta())<5.0) {
00936 
00937     mpTScaleF_s->Fill (log10(PtGen), PtJpt/PtGen);
00938     mpTScaleF_d->Fill (log10(PtGen), PtJpt/PtGen);
00939     if (PtGen>60.0 && PtGen<120.0) {
00940       mpTScale1DF_60_120->Fill (fJPTJet.pt()/fGenJet.pt());
00941     }
00942     if (PtGen>200.0 && PtGen<300.0) {
00943       mpTScale1DF_200_300->Fill (fJPTJet.pt()/fGenJet.pt());
00944     }
00945     if (PtGen>600.0 && PtGen<900.0) {
00946       mpTScale1DF_600_900->Fill (fJPTJet.pt()/fGenJet.pt());
00947     }
00948     if (PtGen>2700.0 && PtGen<3500.0) {
00949       mpTScale1DF_2700_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00950     }
00951   }
00952 
00953   if (fGenJet.pt()>60.0 && fGenJet.pt()<120.0) {
00954     mpTScale_60_120_s->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00955     mpTScale_60_120_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00956     mpTScale1D_60_120->Fill (fJPTJet.pt()/fGenJet.pt());
00957   }
00958 
00959   if (fGenJet.pt()>200.0 && fGenJet.pt()<300.0) {
00960     mpTScale_200_300_s->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00961     mpTScale_200_300_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00962     mpTScale1D_200_300->Fill (fJPTJet.pt()/fGenJet.pt());
00963   }
00964 
00965   if (fGenJet.pt()>600.0 && fGenJet.pt()<900.0) {
00966     mpTScale_600_900_s->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00967     mpTScale_600_900_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00968     mpTScale1D_600_900->Fill (fJPTJet.pt()/fGenJet.pt());
00969   }
00970 
00971   if (fGenJet.pt()>2700.0 && fGenJet.pt()<3500.0) {
00972     mpTScale_2700_3500_s->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00973     mpTScale_2700_3500_d->Fill (fGenJet.eta(),fJPTJet.pt()/fGenJet.pt());
00974     mpTScale1D_2700_3500->Fill (fJPTJet.pt()/fGenJet.pt());
00975   }
00976 
00977 
00978 
00979 }
00980 
00981 double JPTJetTester::getSumPt(const reco::TrackRefVector& tracks){
00982 
00983   double sumpt = 0.;
00984   
00985   for (reco::TrackRefVector::const_iterator itrack = tracks.begin(); itrack != tracks.end(); ++itrack){
00986     const reco::Track& track = **itrack;
00987     sumpt += track.pt(); 
00988   }
00989   
00990   return sumpt;
00991 
00992 }