CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQMOffline/JetMET/src/PFJetAnalyzer.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2012/04/12 15:42:58 $
00005  *  $Revision: 1.24 $
00006  *  \author F. Chlebana - Fermilab
00007  */
00008 
00009 #include "DQMOffline/JetMET/interface/PFJetAnalyzer.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 
00012 #include "DataFormats/JetReco/interface/PFJet.h"
00013 
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 
00016 #include <string>
00017 using namespace edm;
00018 
00019 
00020 PFJetAnalyzer::PFJetAnalyzer(const edm::ParameterSet& pSet) {
00021 
00022   parameters = pSet;
00023   _leadJetFlag = 0;
00024   _JetLoPass   = 0;
00025   _JetHiPass   = 0;
00026   _ptThreshold = 5.;
00027   _asymmetryThirdJetCut = 30.;
00028   _balanceThirdJetCut   = 0.2;
00029   _LooseCHFMin = -999.;
00030   _LooseNHFMax = -999.;
00031   _LooseCEFMax = -999.;
00032   _LooseNEFMax = -999.;
00033   _TightCHFMin = -999.;
00034   _TightNHFMax = -999.;
00035   _TightCEFMax = -999.;
00036   _TightNEFMax = -999.;
00037   _ThisCHFMin = -999.;
00038   _ThisNHFMax = -999.;
00039   _ThisCEFMax = -999.;
00040   _ThisNEFMax = -999.;
00041 
00042 }
00043 
00044 
00045 PFJetAnalyzer::~PFJetAnalyzer() { }
00046 
00047 
00048 void PFJetAnalyzer::beginJob(DQMStore * dbe) {
00049 
00050   metname = "pFJetAnalyzer";
00051 
00052   LogTrace(metname)<<"[PFJetAnalyzer] Parameters initialization";
00053   //dbe->setCurrentFolder("JetMET/Jet/PFJets");//old version, now name set to source, which 
00054   //can be set for each instance of PFJetAnalyzer called inside JetMETAnalyzer. Useful, e.g., to 
00055   //name differently the dir for all jets and cleaned jets 
00056   dbe->setCurrentFolder("JetMET/Jet/"+_source);
00057   // dbe->setCurrentFolder("JetMET/Jet/PFJets");
00058                         
00059   jetME = dbe->book1D("jetReco", "jetReco", 3, 1, 4);
00060   jetME->setBinLabel(2,"PFJets",1);
00061 
00062   // monitoring of eta parameter
00063   etaBin = parameters.getParameter<int>("etaBin");
00064   etaMin = parameters.getParameter<double>("etaMin");
00065   etaMax = parameters.getParameter<double>("etaMax");
00066 
00067   // monitoring of phi paramater
00068   phiBin = parameters.getParameter<int>("phiBin");
00069   phiMin = parameters.getParameter<double>("phiMin");
00070   phiMax = parameters.getParameter<double>("phiMax");
00071 
00072   // monitoring of the transverse momentum
00073   ptBin = parameters.getParameter<int>("ptBin");
00074   ptMin = parameters.getParameter<double>("ptMin");
00075   ptMax = parameters.getParameter<double>("ptMax");
00076 
00077   // 
00078   eBin = parameters.getParameter<int>("eBin");
00079   eMin = parameters.getParameter<double>("eMin");
00080   eMax = parameters.getParameter<double>("eMax");
00081 
00082   // 
00083   pBin = parameters.getParameter<int>("pBin");
00084   pMin = parameters.getParameter<double>("pMin");
00085   pMax = parameters.getParameter<double>("pMax");
00086 
00087   _ptThreshold = parameters.getParameter<double>("ptThreshold");
00088   _asymmetryThirdJetCut = parameters.getParameter<double>("asymmetryThirdJetCut");
00089   _balanceThirdJetCut   = parameters.getParameter<double>("balanceThirdJetCut");
00090 
00091   _TightCHFMin = parameters.getParameter<double>("TightCHFMin");
00092   _TightNHFMax = parameters.getParameter<double>("TightNHFMax");
00093   _TightCEFMax = parameters.getParameter<double>("TightCEFMax");
00094   _TightNEFMax = parameters.getParameter<double>("TightNEFMax");
00095   _LooseCHFMin = parameters.getParameter<double>("LooseCHFMin");
00096   _LooseNHFMax = parameters.getParameter<double>("LooseNHFMax");
00097   _LooseCEFMax = parameters.getParameter<double>("LooseCEFMax");
00098   _LooseNEFMax = parameters.getParameter<double>("LooseNEFMax");
00099 
00100   fillpfJIDPassFrac  = parameters.getParameter<int>("fillpfJIDPassFrac");
00101   makedijetselection = parameters.getParameter<int>("makedijetselection");
00102 
00103   _ThisCHFMin = parameters.getParameter<double>("ThisCHFMin");
00104   _ThisNHFMax = parameters.getParameter<double>("ThisNHFMax");
00105   _ThisCEFMax = parameters.getParameter<double>("ThisCEFMax");
00106   _ThisNEFMax = parameters.getParameter<double>("ThisNEFMax");
00107 
00108   // Generic Jet Parameters
00109   mPt                      = dbe->book1D("Pt",  "Pt", ptBin, ptMin, ptMax);
00110   mEta                     = dbe->book1D("Eta", "Eta", etaBin, etaMin, etaMax);
00111   mPhi                     = dbe->book1D("Phi", "Phi", phiBin, phiMin, phiMax);
00112   mConstituents            = dbe->book1D("Constituents", "# of constituents", 50, 0, 100);
00113   mHFrac                   = dbe->book1D("HFrac", "HFrac", 120, -0.1, 1.1);
00114   mEFrac                   = dbe->book1D("EFrac", "EFrac", 120, -0.1, 1.1);
00115 
00116 
00117   // Book NPV profiles
00118   //----------------------------------------------------------------------------
00119   mPt_profile           = dbe->bookProfile("Pt_profile",           "pt",                nbinsPV, PVlow, PVup,  ptBin,  ptMin,  ptMax);
00120   mEta_profile          = dbe->bookProfile("Eta_profile",          "eta",               nbinsPV, PVlow, PVup, etaBin, etaMin, etaMax);
00121   mPhi_profile          = dbe->bookProfile("Phi_profile",          "phi",               nbinsPV, PVlow, PVup, phiBin, phiMin, phiMax);
00122   mConstituents_profile = dbe->bookProfile("Constituents_profile", "# of constituents", nbinsPV, PVlow, PVup,     50,      0,    100);
00123   mHFrac_profile        = dbe->bookProfile("HFrac_profile",        "Hfrac",             nbinsPV, PVlow, PVup,    120,   -0.1,    1.1);
00124   mEFrac_profile        = dbe->bookProfile("EFrac_profile",        "Efrac",             nbinsPV, PVlow, PVup,    120,   -0.1,    1.1);
00125 
00126 
00127   // Set NPV profiles x-axis title
00128   //----------------------------------------------------------------------------
00129   mPt_profile          ->setAxisTitle("nvtx",1);
00130   mEta_profile         ->setAxisTitle("nvtx",1);
00131   mPhi_profile         ->setAxisTitle("nvtx",1);
00132   mConstituents_profile->setAxisTitle("nvtx",1);
00133   mHFrac_profile       ->setAxisTitle("nvtx",1);
00134   mEFrac_profile       ->setAxisTitle("nvtx",1);
00135 
00136 
00137   //mE                       = dbe->book1D("E", "E", eBin, eMin, eMax);
00138   //mP                       = dbe->book1D("P", "P", pBin, pMin, pMax);
00139   //mMass                    = dbe->book1D("Mass", "Mass", 100, 0, 25);
00140   //
00141   mPhiVSEta                = dbe->book2D("PhiVSEta", "PhiVSEta", 50, etaMin, etaMax, 24, phiMin, phiMax);
00142   
00143   if(makedijetselection!=1) {
00144     mPt_1                    = dbe->book1D("Pt1", "Pt1", 50, 0, 100);
00145     mPt_2                    = dbe->book1D("Pt2", "Pt2", 60, 0, 300);  
00146     mPt_3                    = dbe->book1D("Pt3", "Pt3", 100, 0, 5000);
00147     
00148     // Low and high pt trigger paths
00149     mPt_Lo                  = dbe->book1D("Pt_Lo", "Pt (Pass Low Pt Jet Trigger)", 20, 0, 100);
00150     //mEta_Lo                 = dbe->book1D("Eta_Lo", "Eta (Pass Low Pt Jet Trigger)", etaBin, etaMin, etaMax);
00151     mPhi_Lo                 = dbe->book1D("Phi_Lo", "Phi (Pass Low Pt Jet Trigger)", phiBin, phiMin, phiMax);
00152     
00153     mPt_Hi                  = dbe->book1D("Pt_Hi", "Pt (Pass Hi Pt Jet Trigger)", 100, 0, 300);
00154     mEta_Hi                 = dbe->book1D("Eta_Hi", "Eta (Pass Hi Pt Jet Trigger)", etaBin, etaMin, etaMax);
00155     mPhi_Hi                 = dbe->book1D("Phi_Hi", "Phi (Pass Hi Pt Jet Trigger)", phiBin, phiMin, phiMax);
00156     
00157     mNJets                   = dbe->book1D("NJets", "number of jets", 100, 0, 100);
00158     
00159     mCHFracVSeta_lowPt= dbe->bookProfile("CHFracVSeta_lowPt","CHFracVSeta_lowPt",etaBin, etaMin, etaMax,0.,1.2);
00160     mNHFracVSeta_lowPt= dbe->bookProfile("NHFracVSeta_lowPt","NHFracVSeta_lowPt",etaBin, etaMin, etaMax,0.,1.2);
00161     mPhFracVSeta_lowPt= dbe->bookProfile("PhFracVSeta_lowPt","PhFracVSeta_lowPt",etaBin, etaMin, etaMax,0.,1.2);
00162     mElFracVSeta_lowPt= dbe->bookProfile("ElFracVSeta_lowPt","ElFracVSeta_lowPt",etaBin, etaMin, etaMax,0.,1.2);
00163     mMuFracVSeta_lowPt= dbe->bookProfile("MuFracVSeta_lowPt","MuFracVSeta_lowPt",etaBin, etaMin, etaMax,0.,1.2);
00164     mCHFracVSeta_mediumPt= dbe->bookProfile("CHFracVSeta_mediumPt","CHFracVSeta_mediumPt",etaBin, etaMin, etaMax,0.,1.2);
00165     mNHFracVSeta_mediumPt= dbe->bookProfile("NHFracVSeta_mediumPt","NHFracVSeta_mediumPt",etaBin, etaMin, etaMax,0.,1.2);
00166     mPhFracVSeta_mediumPt= dbe->bookProfile("PhFracVSeta_mediumPt","PhFracVSeta_mediumPt",etaBin, etaMin, etaMax,0.,1.2);
00167     mElFracVSeta_mediumPt= dbe->bookProfile("ElFracVSeta_mediumPt","ElFracVSeta_mediumPt",etaBin, etaMin, etaMax,0.,1.2);
00168     mMuFracVSeta_mediumPt= dbe->bookProfile("MuFracVSeta_mediumPt","MuFracVSeta_mediumPt",etaBin, etaMin, etaMax,0.,1.2);
00169     mCHFracVSeta_highPt= dbe->bookProfile("CHFracVSeta_highPt","CHFracVSeta_highPt",etaBin, etaMin, etaMax,0.,1.2);
00170     mNHFracVSeta_highPt= dbe->bookProfile("NHFracVSeta_highPt","NHFracVSeta_highPt",etaBin, etaMin, etaMax,0.,1.2);
00171     mPhFracVSeta_highPt= dbe->bookProfile("PhFracVSeta_highPt","PhFracVSeta_highPt",etaBin, etaMin, etaMax,0.,1.2);
00172     mElFracVSeta_highPt= dbe->bookProfile("ElFracVSeta_highPt","ElFracVSeta_highPt",etaBin, etaMin, etaMax,0.,1.2);
00173     mMuFracVSeta_highPt= dbe->bookProfile("MuFracVSeta_highPt","MuFracVSeta_highPt",etaBin, etaMin, etaMax,0.,1.2);
00174     
00175     //mPt_Barrel_Lo            = dbe->book1D("Pt_Barrel_Lo", "Pt Barrel (Pass Low Pt Jet Trigger)", 20, 0, 100);
00176     //mPhi_Barrel_Lo           = dbe->book1D("Phi_Barrel_Lo", "Phi Barrel (Pass Low Pt Jet Trigger)", phiBin, phiMin, phiMax);
00177     mConstituents_Barrel     = dbe->book1D("Constituents_Barrel", "Constituents Barrel", 50, 0, 100);
00178     mHFrac_Barrel            = dbe->book1D("HFrac_Barrel", "HFrac Barrel", 100, 0, 1);
00179     mEFrac_Barrel            = dbe->book1D("EFrac_Barrel", "EFrac Barrel", 110, -0.05, 1.05);
00180     
00181     //mPt_EndCap_Lo            = dbe->book1D("Pt_EndCap_Lo", "Pt EndCap (Pass Low Pt Jet Trigger)", 20, 0, 100);
00182     //mPhi_EndCap_Lo           = dbe->book1D("Phi_EndCap_Lo", "Phi EndCap (Pass Low Pt Jet Trigger)", phiBin, phiMin, phiMax);
00183     mConstituents_EndCap     = dbe->book1D("Constituents_EndCap", "Constituents EndCap", 50, 0, 100);
00184     mHFrac_EndCap            = dbe->book1D("HFrac_Endcap", "HFrac EndCap", 100, 0, 1);
00185     mEFrac_EndCap            = dbe->book1D("EFrac_Endcap", "EFrac EndCap", 110, -0.05, 1.05);
00186     
00187     //mPt_Forward_Lo           = dbe->book1D("Pt_Forward_Lo", "Pt Forward (Pass Low Pt Jet Trigger)", 20, 0, 100);
00188     //mPhi_Forward_Lo          = dbe->book1D("Phi_Forward_Lo", "Phi Forward (Pass Low Pt Jet Trigger)", phiBin, phiMin, phiMax);
00189     mConstituents_Forward    = dbe->book1D("Constituents_Forward", "Constituents Forward", 50, 0, 100);
00190     mHFrac_Forward           = dbe->book1D("HFrac_Forward", "HFrac Forward", 100, 0, 1);
00191     mEFrac_Forward           = dbe->book1D("EFrac_Forward", "EFrac Forward", 110, -0.05, 1.05);
00192     
00193     mPt_Barrel_Hi            = dbe->book1D("Pt_Barrel_Hi", "Pt Barrel (Pass Hi Pt Jet Trigger)", 60, 0, 300);
00194     mPhi_Barrel_Hi           = dbe->book1D("Phi_Barrel_Hi", "Phi Barrel (Pass Hi Pt Jet Trigger)", phiBin, phiMin, phiMax);
00195     //mConstituents_Barrel_Hi  = dbe->book1D("Constituents_Barrel_Hi", "Constituents Barrel (Pass Hi Pt Jet Trigger)", 50, 0, 100);
00196     //mHFrac_Barrel_Hi         = dbe->book1D("HFrac_Barrel_Hi", "HFrac Barrel (Pass Hi Pt Jet Trigger)", 100, 0, 1);
00197     
00198     mPt_EndCap_Hi            = dbe->book1D("Pt_EndCap_Hi", "Pt EndCap (Pass Hi Pt Jet Trigger)", 60, 0, 300);
00199     mPhi_EndCap_Hi           = dbe->book1D("Phi_EndCap_Hi", "Phi EndCap (Pass Hi Pt Jet Trigger)", phiBin, phiMin, phiMax);
00200     //mConstituents_EndCap_Hi  = dbe->book1D("Constituents_EndCap_Hi", "Constituents EndCap (Pass Hi Pt Jet Trigger)", 50, 0, 100);
00201     //mHFrac_EndCap_Hi         = dbe->book1D("HFrac_EndCap_Hi", "HFrac EndCap (Pass Hi Pt Jet Trigger)", 100, 0, 1);
00202 
00203     mPt_Forward_Hi           = dbe->book1D("Pt_Forward_Hi", "Pt Forward (Pass Hi Pt Jet Trigger)", 60, 0, 300);
00204     mPhi_Forward_Hi          = dbe->book1D("Phi_Forward_Hi", "Phi Forward (Pass Hi Pt Jet Trigger)", phiBin, phiMin, phiMax);
00205     //mConstituents_Forward_Hi = dbe->book1D("Constituents_Forward_Hi", "Constituents Forward (Pass Hi Pt Jet Trigger)", 50, 0, 100);
00206     //mHFrac_Forward_Hi        = dbe->book1D("HFrac_Forward_Hi", "HFrac Forward (Pass Hi Pt Jet Trigger)", 100, 0, 1);
00207 
00208     mPhi_Barrel              = dbe->book1D("Phi_Barrel", "Phi_Barrel", phiBin, phiMin, phiMax);
00209     //mE_Barrel                = dbe->book1D("E_Barrel", "E_Barrel", eBin, eMin, eMax);
00210     mPt_Barrel               = dbe->book1D("Pt_Barrel", "Pt_Barrel", ptBin, ptMin, ptMax);
00211     // energy fractions
00212     mCHFrac_lowPt_Barrel     = dbe->book1D("CHFrac_lowPt_Barrel", "CHFrac_lowPt_Barrel", 120, -0.1, 1.1);
00213     mNHFrac_lowPt_Barrel     = dbe->book1D("NHFrac_lowPt_Barrel", "NHFrac_lowPt_Barrel", 120, -0.1, 1.1);
00214     mPhFrac_lowPt_Barrel     = dbe->book1D("PhFrac_lowPt_Barrel", "PhFrac_lowPt_Barrel", 120, -0.1, 1.1);
00215     mElFrac_lowPt_Barrel     = dbe->book1D("ElFrac_lowPt_Barrel", "ElFrac_lowPt_Barrel", 120, -0.1, 1.1);
00216     mMuFrac_lowPt_Barrel     = dbe->book1D("MuFrac_lowPt_Barrel", "MuFrac_lowPt_Barrel", 120, -0.1, 1.1);
00217     mCHFrac_mediumPt_Barrel  = dbe->book1D("CHFrac_mediumPt_Barrel", "CHFrac_mediumPt_Barrel", 120, -0.1, 1.1);
00218     mNHFrac_mediumPt_Barrel  = dbe->book1D("NHFrac_mediumPt_Barrel", "NHFrac_mediumPt_Barrel", 120, -0.1, 1.1);
00219     mPhFrac_mediumPt_Barrel  = dbe->book1D("PhFrac_mediumPt_Barrel", "PhFrac_mediumPt_Barrel", 120, -0.1, 1.1);
00220     mElFrac_mediumPt_Barrel  = dbe->book1D("ElFrac_mediumPt_Barrel", "ElFrac_mediumPt_Barrel", 120, -0.1, 1.1);
00221     mMuFrac_mediumPt_Barrel  = dbe->book1D("MuFrac_mediumPt_Barrel", "MuFrac_mediumPt_Barrel", 120, -0.1, 1.1);
00222     mCHFrac_highPt_Barrel    = dbe->book1D("CHFrac_highPt_Barrel", "CHFrac_highPt_Barrel", 120, -0.1, 1.1);
00223     mNHFrac_highPt_Barrel    = dbe->book1D("NHFrac_highPt_Barrel", "NHFrac_highPt_Barrel", 120, -0.1, 1.1);
00224     mPhFrac_highPt_Barrel    = dbe->book1D("PhFrac_highPt_Barrel", "PhFrac_highPt_Barrel", 120, -0.1, 1.1);
00225     mElFrac_highPt_Barrel    = dbe->book1D("ElFrac_highPt_Barrel", "ElFrac_highPt_Barrel", 120, -0.1, 1.1);
00226     mMuFrac_highPt_Barrel    = dbe->book1D("MuFrac_highPt_Barrel", "MuFrac_highPt_Barrel", 120, -0.1, 1.1);
00227     //energies
00228     mCHEn_lowPt_Barrel     = dbe->book1D("CHEn_lowPt_Barrel", "CHEn_lowPt_Barrel", ptBin, ptMin, ptMax);
00229     mNHEn_lowPt_Barrel     = dbe->book1D("NHEn_lowPt_Barrel", "NHEn_lowPt_Barrel", ptBin, ptMin, ptMax);
00230     mPhEn_lowPt_Barrel     = dbe->book1D("PhEn_lowPt_Barrel", "PhEn_lowPt_Barrel", ptBin, ptMin, ptMax);
00231     mElEn_lowPt_Barrel     = dbe->book1D("ElEn_lowPt_Barrel", "ElEn_lowPt_Barrel", ptBin, ptMin, ptMax);
00232     mMuEn_lowPt_Barrel     = dbe->book1D("MuEn_lowPt_Barrel", "MuEn_lowPt_Barrel", ptBin, ptMin, ptMax);
00233     mCHEn_mediumPt_Barrel  = dbe->book1D("CHEn_mediumPt_Barrel", "CHEn_mediumPt_Barrel", ptBin, ptMin, ptMax);
00234     mNHEn_mediumPt_Barrel  = dbe->book1D("NHEn_mediumPt_Barrel", "NHEn_mediumPt_Barrel", ptBin, ptMin, ptMax);
00235     mPhEn_mediumPt_Barrel  = dbe->book1D("PhEn_mediumPt_Barrel", "PhEn_mediumPt_Barrel", ptBin, ptMin, ptMax);
00236     mElEn_mediumPt_Barrel  = dbe->book1D("ElEn_mediumPt_Barrel", "ElEn_mediumPt_Barrel", ptBin, ptMin, ptMax);
00237     mMuEn_mediumPt_Barrel  = dbe->book1D("MuEn_mediumPt_Barrel", "MuEn_mediumPt_Barrel", ptBin, ptMin, ptMax);
00238     mCHEn_highPt_Barrel    = dbe->book1D("CHEn_highPt_Barrel", "CHEn_highPt_Barrel", ptBin, ptMin, ptMax);
00239     mNHEn_highPt_Barrel    = dbe->book1D("NHEn_highPt_Barrel", "NHEn_highPt_Barrel", ptBin, ptMin, ptMax);
00240     mPhEn_highPt_Barrel    = dbe->book1D("PhEn_highPt_Barrel", "PhEn_highPt_Barrel", ptBin, ptMin, ptMax);
00241     mElEn_highPt_Barrel    = dbe->book1D("ElEn_highPt_Barrel", "ElEn_highPt_Barrel", ptBin, ptMin, ptMax);
00242     mMuEn_highPt_Barrel    = dbe->book1D("MuEn_highPt_Barrel", "MuEn_highPt_Barrel", ptBin, ptMin, ptMax);
00243     //multiplicities
00244     mChMultiplicity_lowPt_Barrel    = dbe->book1D("ChMultiplicity_lowPt_Barrel", "ChMultiplicity_lowPt_Barrel", 30,0,30);
00245     mNeuMultiplicity_lowPt_Barrel   = dbe->book1D("NeuMultiplicity_lowPt_Barrel", "NeuMultiplicity_lowPt_Barrel", 30,0,30);
00246     mMuMultiplicity_lowPt_Barrel    = dbe->book1D("MuMultiplicity_lowPt_Barrel", "MuMultiplicity_lowPt_Barrel", 30,0,30);
00247     mChMultiplicity_mediumPt_Barrel    = dbe->book1D("ChMultiplicity_mediumPt_Barrel", "ChMultiplicity_mediumPt_Barrel", 30,0,30);
00248     mNeuMultiplicity_mediumPt_Barrel   = dbe->book1D("NeuMultiplicity_mediumPt_Barrel", "NeuMultiplicity_mediumPt_Barrel", 30,0,30);
00249     mMuMultiplicity_mediumPt_Barrel    = dbe->book1D("MuMultiplicity_mediumPt_Barrel", "MuMultiplicity_mediumPt_Barrel", 30,0,30);
00250     mChMultiplicity_highPt_Barrel    = dbe->book1D("ChMultiplicity_highPt_Barrel", "ChMultiplicity_highPt_Barrel", 30,0,30);
00251     mNeuMultiplicity_highPt_Barrel   = dbe->book1D("NeuMultiplicity_highPt_Barrel", "NeuMultiplicity_highPt_Barrel", 30,0,30);
00252     mMuMultiplicity_highPt_Barrel    = dbe->book1D("MuMultiplicity_highPt_Barrel", "MuMultiplicity_highPt_Barrel", 30,0,30);
00253     //
00254     mCHFracVSpT_Barrel= dbe->bookProfile("CHFracVSpT_Barrel","CHFracVSpT_Barrel",ptBin, ptMin, ptMax,0.,1.2);
00255     mNHFracVSpT_Barrel= dbe->bookProfile("NHFracVSpT_Barrel","NHFracVSpT_Barrel",ptBin, ptMin, ptMax,0.,1.2);
00256     mPhFracVSpT_Barrel= dbe->bookProfile("PhFracVSpT_Barrel","PhFracVSpT_Barrel",ptBin, ptMin, ptMax,0.,1.2);
00257     mElFracVSpT_Barrel= dbe->bookProfile("ElFracVSpT_Barrel","ElFracVSpT_Barrel",ptBin, ptMin, ptMax,0.,1.2);
00258     mMuFracVSpT_Barrel= dbe->bookProfile("MuFracVSpT_Barrel","MuFracVSpT_Barrel",ptBin, ptMin, ptMax,0.,1.2);
00259     mCHFracVSpT_EndCap= dbe->bookProfile("CHFracVSpT_EndCap","CHFracVSpT_EndCap",ptBin, ptMin, ptMax,0.,1.2);
00260     mNHFracVSpT_EndCap= dbe->bookProfile("NHFracVSpT_EndCap","NHFracVSpT_EndCap",ptBin, ptMin, ptMax,0.,1.2);
00261     mPhFracVSpT_EndCap= dbe->bookProfile("PhFracVSpT_EndCap","PhFracVSpT_EndCap",ptBin, ptMin, ptMax,0.,1.2);
00262     mElFracVSpT_EndCap= dbe->bookProfile("ElFracVSpT_EndCap","ElFracVSpT_EndCap",ptBin, ptMin, ptMax,0.,1.2);
00263     mMuFracVSpT_EndCap= dbe->bookProfile("MuFracVSpT_EndCap","MuFracVSpT_EndCap",ptBin, ptMin, ptMax,0.,1.2);
00264     mHFHFracVSpT_Forward= dbe->bookProfile("HFHFracVSpT_Forward","HFHFracVSpT_Forward",ptBin, ptMin, ptMax,0.,1.2);
00265     mHFEFracVSpT_Forward= dbe->bookProfile("HFEFracVSpT_Forward","HFEFracVSpT_Forward",ptBin, ptMin, ptMax,0.,1.2);
00266 
00267     mPhi_EndCap              = dbe->book1D("Phi_EndCap", "Phi_EndCap", phiBin, phiMin, phiMax);
00268     //mE_EndCap                = dbe->book1D("E_EndCap", "E_EndCap", eBin, eMin, eMax);
00269     mPt_EndCap               = dbe->book1D("Pt_EndCap", "Pt_EndCap", ptBin, ptMin, ptMax);
00270     //energy fractions
00271     mCHFrac_lowPt_EndCap     = dbe->book1D("CHFrac_lowPt_EndCap", "CHFrac_lowPt_EndCap", 120, -0.1, 1.1);
00272     mNHFrac_lowPt_EndCap     = dbe->book1D("NHFrac_lowPt_EndCap", "NHFrac_lowPt_EndCap", 120, -0.1, 1.1);
00273     mPhFrac_lowPt_EndCap     = dbe->book1D("PhFrac_lowPt_EndCap", "PhFrac_lowPt_EndCap", 120, -0.1, 1.1);
00274     mElFrac_lowPt_EndCap     = dbe->book1D("ElFrac_lowPt_EndCap", "ElFrac_lowPt_EndCap", 120, -0.1, 1.1);
00275     mMuFrac_lowPt_EndCap     = dbe->book1D("MuFrac_lowPt_EndCap", "MuFrac_lowPt_EndCap", 120, -0.1, 1.1);
00276     mCHFrac_mediumPt_EndCap  = dbe->book1D("CHFrac_mediumPt_EndCap", "CHFrac_mediumPt_EndCap", 120, -0.1, 1.1);
00277     mNHFrac_mediumPt_EndCap  = dbe->book1D("NHFrac_mediumPt_EndCap", "NHFrac_mediumPt_EndCap", 120, -0.1, 1.1);
00278     mPhFrac_mediumPt_EndCap  = dbe->book1D("PhFrac_mediumPt_EndCap", "PhFrac_mediumPt_EndCap", 120, -0.1, 1.1);
00279     mElFrac_mediumPt_EndCap  = dbe->book1D("ElFrac_mediumPt_EndCap", "ElFrac_mediumPt_EndCap", 120, -0.1, 1.1);
00280     mMuFrac_mediumPt_EndCap  = dbe->book1D("MuFrac_mediumPt_EndCap", "MuFrac_mediumPt_EndCap", 120, -0.1, 1.1);
00281     mCHFrac_highPt_EndCap    = dbe->book1D("CHFrac_highPt_EndCap", "CHFrac_highPt_EndCap", 120, -0.1, 1.1);
00282     mNHFrac_highPt_EndCap    = dbe->book1D("NHFrac_highPt_EndCap", "NHFrac_highPt_EndCap", 120, -0.1, 1.1);
00283     mPhFrac_highPt_EndCap    = dbe->book1D("PhFrac_highPt_EndCap", "PhFrac_highPt_EndCap", 120, -0.1, 1.1);
00284     mElFrac_highPt_EndCap    = dbe->book1D("ElFrac_highPt_EndCap", "ElFrac_highPt_EndCap", 120, -0.1, 1.1);
00285     mMuFrac_highPt_EndCap    = dbe->book1D("MuFrac_highPt_EndCap", "MuFrac_highPt_EndCap", 120, -0.1, 1.1);
00286     //energies
00287     mCHEn_lowPt_EndCap     = dbe->book1D("CHEn_lowPt_EndCap", "CHEn_lowPt_EndCap", ptBin, ptMin, ptMax);
00288     mNHEn_lowPt_EndCap     = dbe->book1D("NHEn_lowPt_EndCap", "NHEn_lowPt_EndCap", ptBin, ptMin, ptMax);
00289     mPhEn_lowPt_EndCap     = dbe->book1D("PhEn_lowPt_EndCap", "PhEn_lowPt_EndCap", ptBin, ptMin, ptMax);
00290     mElEn_lowPt_EndCap     = dbe->book1D("ElEn_lowPt_EndCap", "ElEn_lowPt_EndCap", ptBin, ptMin, ptMax);
00291     mMuEn_lowPt_EndCap     = dbe->book1D("MuEn_lowPt_EndCap", "MuEn_lowPt_EndCap", ptBin, ptMin, ptMax);
00292     mCHEn_mediumPt_EndCap  = dbe->book1D("CHEn_mediumPt_EndCap", "CHEn_mediumPt_EndCap", ptBin, ptMin, ptMax);
00293     mNHEn_mediumPt_EndCap  = dbe->book1D("NHEn_mediumPt_EndCap", "NHEn_mediumPt_EndCap", ptBin, ptMin, ptMax);
00294     mPhEn_mediumPt_EndCap  = dbe->book1D("PhEn_mediumPt_EndCap", "PhEn_mediumPt_EndCap", ptBin, ptMin, ptMax);
00295     mElEn_mediumPt_EndCap  = dbe->book1D("ElEn_mediumPt_EndCap", "ElEn_mediumPt_EndCap", ptBin, ptMin, ptMax);
00296     mMuEn_mediumPt_EndCap  = dbe->book1D("MuEn_mediumPt_EndCap", "MuEn_mediumPt_EndCap", ptBin, ptMin, ptMax);
00297     mCHEn_highPt_EndCap    = dbe->book1D("CHEn_highPt_EndCap", "CHEn_highPt_EndCap", ptBin, ptMin, ptMax);
00298     mNHEn_highPt_EndCap    = dbe->book1D("NHEn_highPt_EndCap", "NHEn_highPt_EndCap", ptBin, ptMin, ptMax);
00299     mPhEn_highPt_EndCap    = dbe->book1D("PhEn_highPt_EndCap", "PhEn_highPt_EndCap", ptBin, ptMin, ptMax);
00300     mElEn_highPt_EndCap    = dbe->book1D("ElEn_highPt_EndCap", "ElEn_highPt_EndCap", ptBin, ptMin, ptMax);
00301     mMuEn_highPt_EndCap    = dbe->book1D("MuEn_highPt_EndCap", "MuEn_highPt_EndCap", ptBin, ptMin, ptMax);
00302     //multiplicities
00303     mChMultiplicity_lowPt_EndCap    = dbe->book1D("ChMultiplicity_lowPt_EndCap", "ChMultiplicity_lowPt_EndCap", 30,0,30);
00304     mNeuMultiplicity_lowPt_EndCap   = dbe->book1D("NeuMultiplicity_lowPt_EndCap", "NeuMultiplicity_lowPt_EndCap", 30,0,30);
00305     mMuMultiplicity_lowPt_EndCap    = dbe->book1D("MuMultiplicity_lowPt_EndCap", "MuMultiplicity_lowPt_EndCap", 30,0,30);
00306     mChMultiplicity_mediumPt_EndCap    = dbe->book1D("ChMultiplicity_mediumPt_EndCap", "ChMultiplicity_mediumPt_EndCap", 30,0,30);
00307     mNeuMultiplicity_mediumPt_EndCap   = dbe->book1D("NeuMultiplicity_mediumPt_EndCap", "NeuMultiplicity_mediumPt_EndCap", 30,0,30);
00308     mMuMultiplicity_mediumPt_EndCap    = dbe->book1D("MuMultiplicity_mediumPt_EndCap", "MuMultiplicity_mediumPt_EndCap", 30,0,30);
00309     mChMultiplicity_highPt_EndCap    = dbe->book1D("ChMultiplicity_highPt_EndCap", "ChMultiplicity_highPt_EndCap", 30,0,30);
00310     mNeuMultiplicity_highPt_EndCap   = dbe->book1D("NeuMultiplicity_highPt_EndCap", "NeuMultiplicity_highPt_EndCap", 30,0,30);
00311     mMuMultiplicity_highPt_EndCap    = dbe->book1D("MuMultiplicity_highPt_EndCap", "MuMultiplicity_highPt_EndCap", 30,0,30);
00312 
00313     mPhi_Forward             = dbe->book1D("Phi_Forward", "Phi_Forward", phiBin, phiMin, phiMax);
00314     //mE_Forward               = dbe->book1D("E_Forward", "E_Forward", eBin, eMin, eMax);
00315     mPt_Forward              = dbe->book1D("Pt_Forward", "Pt_Forward", ptBin, ptMin, ptMax);
00316     //energy fraction
00317     mHFEFrac_lowPt_Forward    = dbe->book1D("HFEFrac_lowPt_Forward", "HFEFrac_lowPt_Forward", 120, -0.1, 1.1);
00318     mHFHFrac_lowPt_Forward    = dbe->book1D("HFHFrac_lowPt_Forward", "HFHFrac_lowPt_Forward", 120, -0.1, 1.1);
00319     mHFEFrac_mediumPt_Forward = dbe->book1D("HFEFrac_mediumPt_Forward", "HFEFrac_mediumPt_Forward", 120, -0.1, 1.1);
00320     mHFHFrac_mediumPt_Forward = dbe->book1D("HFHFrac_mediumPt_Forward", "HFHFrac_mediumPt_Forward", 120, -0.1, 1.1);
00321     mHFEFrac_highPt_Forward   = dbe->book1D("HFEFrac_highPt_Forward", "HFEFrac_highPt_Forward", 120, -0.1, 1.1);
00322     mHFHFrac_highPt_Forward   = dbe->book1D("HFHFrac_highPt_Forward", "HFHFrac_highPt_Forward", 120, -0.1, 1.1);
00323     //energies
00324     mHFEEn_lowPt_Forward    = dbe->book1D("HFEEn_lowPt_Forward", "HFEEn_lowPt_Forward", ptBin, ptMin, ptMax);
00325     mHFHEn_lowPt_Forward    = dbe->book1D("HFHEn_lowPt_Forward", "HFHEn_lowPt_Forward", ptBin, ptMin, ptMax);
00326     mHFEEn_mediumPt_Forward = dbe->book1D("HFEEn_mediumPt_Forward", "HFEEn_mediumPt_Forward", ptBin, ptMin, ptMax);
00327     mHFHEn_mediumPt_Forward = dbe->book1D("HFHEn_mediumPt_Forward", "HFHEn_mediumPt_Forward", ptBin, ptMin, ptMax);
00328     mHFEEn_highPt_Forward   = dbe->book1D("HFEEn_highPt_Forward", "HFEEn_highPt_Forward", ptBin, ptMin, ptMax);
00329     mHFHEn_highPt_Forward   = dbe->book1D("HFHEn_highPt_Forward", "HFHEn_highPt_Forward", ptBin, ptMin, ptMax);
00330     //multiplicities
00331     mChMultiplicity_lowPt_Forward     = dbe->book1D("ChMultiplicity_lowPt_Forward", "ChMultiplicity_lowPt_Forward", 30,0,30);
00332     mNeuMultiplicity_lowPt_Forward    = dbe->book1D("NeuMultiplicity_lowPt_Forward", "NeuMultiplicity_lowPt_Forward", 30,0,30);
00333     mMuMultiplicity_lowPt_Forward     = dbe->book1D("MuMultiplicity_lowPt_Forward", "MuMultiplicity_lowPt_Forward", 30,0,30);
00334     mChMultiplicity_mediumPt_Forward  = dbe->book1D("ChMultiplicity_mediumPt_Forward", "ChMultiplicity_mediumPt_Forward", 30,0,30);
00335     mNeuMultiplicity_mediumPt_Forward = dbe->book1D("NeuMultiplicity_mediumPt_Forward", "NeuMultiplicity_mediumPt_Forward", 30,0,30);
00336     mMuMultiplicity_mediumPt_Forward  = dbe->book1D("MuMultiplicity_mediumPt_Forward", "MuMultiplicity_mediumPt_Forward", 30,0,30);
00337     mChMultiplicity_highPt_Forward    = dbe->book1D("ChMultiplicity_highPt_Forward", "ChMultiplicity_highPt_Forward", 30,0,30);
00338     mNeuMultiplicity_highPt_Forward   = dbe->book1D("NeuMultiplicity_highPt_Forward", "NeuMultiplicity_highPt_Forward", 30,0,30);
00339     mMuMultiplicity_highPt_Forward    = dbe->book1D("MuMultiplicity_highPt_Forward", "MuMultiplicity_highPt_Forward", 30,0,30);
00340 
00341 
00342 
00343     // Leading Jet Parameters
00344     mEtaFirst                = dbe->book1D("EtaFirst", "EtaFirst", 100, -5, 5);
00345     mPhiFirst                = dbe->book1D("PhiFirst", "PhiFirst", 70, -3.5, 3.5);
00346     //mEFirst                  = dbe->book1D("EFirst", "EFirst", 100, 0, 1000);
00347     mPtFirst                 = dbe->book1D("PtFirst", "PtFirst", 100, 0, 500);
00348     if(fillpfJIDPassFrac==1) {
00349       mLooseJIDPassFractionVSeta= dbe->bookProfile("LooseJIDPassFractionVSeta","LooseJIDPassFractionVSeta",etaBin, etaMin, etaMax,0.,1.2);
00350       mLooseJIDPassFractionVSpt= dbe->bookProfile("LooseJIDPassFractionVSpt","LooseJIDPassFractionVSpt",ptBin, ptMin, ptMax,0.,1.2);
00351       mTightJIDPassFractionVSeta= dbe->bookProfile("TightJIDPassFractionVSeta","TightJIDPassFractionVSeta",etaBin, etaMin, etaMax,0.,1.2);
00352       mTightJIDPassFractionVSpt= dbe->bookProfile("TightJIDPassFractionVSpt","TightJIDPassFractionVSpt",ptBin, ptMin, ptMax,0.,1.2);
00353     }
00354   }
00355 
00356 
00357   mChargedHadronEnergy = dbe->book1D("mChargedHadronEnergy", "charged HAD energy",    100, 0, 100);
00358   mNeutralHadronEnergy = dbe->book1D("mNeutralHadronEnergy", "neutral HAD energy",    100, 0, 100);
00359   mChargedEmEnergy     = dbe->book1D("mChargedEmEnergy ",    "charged EM energy ",    100, 0, 100);
00360   mChargedMuEnergy     = dbe->book1D("mChargedMuEnergy",     "charged Mu energy",     100, 0, 100);
00361   mNeutralEmEnergy     = dbe->book1D("mNeutralEmEnergy",     "neutral EM energy",     100, 0, 100);
00362   mChargedMultiplicity = dbe->book1D("mChargedMultiplicity", "charged multiplicity ", 100, 0, 100);
00363   mNeutralMultiplicity = dbe->book1D("mNeutralMultiplicity", "neutral multiplicity",  100, 0, 100);
00364   mMuonMultiplicity    = dbe->book1D("mMuonMultiplicity",    "muon multiplicity",     100, 0, 100);
00365 
00366   
00367   // Book NPV profiles
00368   //----------------------------------------------------------------------------
00369   mChargedHadronEnergy_profile = dbe->bookProfile("mChargedHadronEnergy_profile", "charged HAD energy",   nbinsPV, PVlow, PVup, 100, 0, 100);
00370   mNeutralHadronEnergy_profile = dbe->bookProfile("mNeutralHadronEnergy_profile", "neutral HAD energy",   nbinsPV, PVlow, PVup, 100, 0, 100);
00371   mChargedEmEnergy_profile     = dbe->bookProfile("mChargedEmEnergy_profile",     "charged EM energy",    nbinsPV, PVlow, PVup, 100, 0, 100);
00372   mChargedMuEnergy_profile     = dbe->bookProfile("mChargedMuEnergy_profile",     "charged Mu energy",    nbinsPV, PVlow, PVup, 100, 0, 100);
00373   mNeutralEmEnergy_profile     = dbe->bookProfile("mNeutralEmEnergy_profile",     "neutral EM energy",    nbinsPV, PVlow, PVup, 100, 0, 100);
00374   mChargedMultiplicity_profile = dbe->bookProfile("mChargedMultiplicity_profile", "charged multiplicity", nbinsPV, PVlow, PVup, 100, 0, 100);
00375   mNeutralMultiplicity_profile = dbe->bookProfile("mNeutralMultiplicity_profile", "neutral multiplicity", nbinsPV, PVlow, PVup, 100, 0, 100);
00376   mMuonMultiplicity_profile    = dbe->bookProfile("mMuonMultiplicity_profile",    "muon multiplicity",    nbinsPV, PVlow, PVup, 100, 0, 100);
00377 
00378   if (makedijetselection != 1) {
00379     mNJets_profile = dbe->bookProfile("NJets_profile", "number of jets", nbinsPV, PVlow, PVup, 100, 0, 100);
00380   }
00381 
00382 
00383   // Set NPV profiles x-axis title
00384   //----------------------------------------------------------------------------
00385   mChargedHadronEnergy_profile->setAxisTitle("nvtx",1);
00386   mNeutralHadronEnergy_profile->setAxisTitle("nvtx",1);
00387   mChargedEmEnergy_profile    ->setAxisTitle("nvtx",1);
00388   mChargedMuEnergy_profile    ->setAxisTitle("nvtx",1);
00389   mNeutralEmEnergy_profile    ->setAxisTitle("nvtx",1);
00390   mChargedMultiplicity_profile->setAxisTitle("nvtx",1);
00391   mNeutralMultiplicity_profile->setAxisTitle("nvtx",1);
00392   mMuonMultiplicity_profile   ->setAxisTitle("nvtx",1);
00393 
00394   if (makedijetselection != 1) {
00395     mNJets_profile->setAxisTitle("nvtx",1);
00396   }
00397 
00398 
00399   //__________________________________________________
00400   mNeutralFraction     = dbe->book1D("NeutralFraction","Neutral Fraction",100,0,1);
00401   //}
00402   
00403   mDPhi                = dbe->book1D("DPhi", "dPhi btw the two leading jets", 100, 0., acos(-1.));
00404   
00405   if(makedijetselection==1) {
00406     mDijetAsymmetry                   = dbe->book1D("DijetAsymmetry", "DijetAsymmetry", 100, -1., 1.);
00407     mDijetBalance                     = dbe->book1D("DijetBalance",   "DijetBalance",   100, -2., 2.);
00408     if (fillpfJIDPassFrac==1) {
00409       mLooseJIDPassFractionVSeta  = dbe->bookProfile("LooseJIDPassFractionVSeta","LooseJIDPassFractionVSeta",50, -3., 3.,0.,1.2);
00410       mLooseJIDPassFractionVSpt   = dbe->bookProfile("LooseJIDPassFractionVSpt","LooseJIDPassFractionVSpt",ptBin, ptMin, ptMax,0.,1.2);
00411       mTightJIDPassFractionVSeta  = dbe->bookProfile("TightJIDPassFractionVSeta","TightJIDPassFractionVSeta",50, -3., 3.,0.,1.2);
00412       mTightJIDPassFractionVSpt   = dbe->bookProfile("TightJIDPassFractionVSpt","TightJIDPassFractionVSpt",ptBin, ptMin, ptMax,0.,1.2);
00413       
00414     }
00415   }
00416   
00417 }
00418 
00419 void PFJetAnalyzer::endJob() {
00420   
00421 }
00422 
00423 void PFJetAnalyzer::analyze(const edm::Event&            iEvent,
00424                             const edm::EventSetup&       iSetup,
00425                             const reco::PFJetCollection& pfJets,
00426                             const int                    numPV)
00427 {
00428   int numofjets=0;
00429   double  fstPhi=0.;
00430   double  sndPhi=0.;
00431   double  diff = 0.;
00432   double  corr = 0.;
00433   double  dphi = -999. ;
00434 
00435   bool Thiscleaned=false; 
00436   bool Loosecleaned=false; 
00437   bool Tightcleaned=false; 
00438   bool ThisCHFcleaned=false;
00439   bool LooseCHFcleaned=false;
00440   bool TightCHFcleaned=false;
00441 
00442   srand( iEvent.id().event() % 10000);
00443 
00444 
00445   if (makedijetselection == 1) {
00446     //Dijet selection - careful: the pT is uncorrected!
00447     //if(makedijetselection==1 && pfJets.size()>=2){
00448     if(pfJets.size()>=2){
00449       double  dphiDJ = -999. ;
00450 
00451       bool LoosecleanedFirstJet =false; 
00452       bool LoosecleanedSecondJet=false; 
00453       bool TightcleanedFirstJet =false; 
00454       bool TightcleanedSecondJet=false; 
00455       bool LooseCHFcleanedFirstJet =false;
00456       bool LooseCHFcleanedSecondJet=false;
00457       bool TightCHFcleanedFirstJet =false;
00458       bool TightCHFcleanedSecondJet=false;
00459 
00460       //both jets pass pt threshold
00461       if ((pfJets.at(0)).pt() > _ptThreshold && (pfJets.at(1)).pt() > _ptThreshold ) {
00462         if(fabs((pfJets.at(0)).eta())<3. && fabs((pfJets.at(1)).eta())<3. ){
00463           //calculate dphi
00464           dphiDJ = fabs((pfJets.at(0)).phi()-(pfJets.at(1)).phi());
00465           if (dphiDJ > 3.14) dphiDJ=fabs(dphiDJ -6.28 );
00466           //fill DPhi histo (before cutting)
00467           if (mDPhi) mDPhi->Fill (dphiDJ);
00468           //dphi cut
00469           if(fabs(dphiDJ)>2.1){
00470             //first jet
00471             LooseCHFcleanedFirstJet=true;
00472             TightCHFcleanedFirstJet=true;
00473             if((pfJets.at(0).chargedHadronEnergy()/pfJets.at(0).energy())<=_LooseCHFMin && fabs(pfJets.at(0).eta())<2.4) LooseCHFcleanedFirstJet=false; //apply CHF>0 only if |eta|<2.4
00474             if((pfJets.at(0).chargedHadronEnergy()/pfJets.at(0).energy())<=_TightCHFMin && fabs(pfJets.at(0).eta())<2.4) TightCHFcleanedFirstJet=false; //apply CHF>0 only if |eta|<2.4
00475             if(LooseCHFcleanedFirstJet && (pfJets.at(0).neutralHadronEnergy()/pfJets.at(0).energy())<_LooseNHFMax && (pfJets.at(0).chargedEmEnergy()/pfJets.at(0).energy())<_LooseCEFMax && (pfJets.at(0).neutralEmEnergy()/pfJets.at(0).energy())<_LooseNEFMax) LoosecleanedFirstJet=true;
00476             if(TightCHFcleanedFirstJet && (pfJets.at(0).neutralHadronEnergy()/pfJets.at(0).energy())<_TightNHFMax && (pfJets.at(0).chargedEmEnergy()/pfJets.at(0).energy())<_TightCEFMax && (pfJets.at(0).neutralEmEnergy()/pfJets.at(0).energy())<_TightNEFMax) TightcleanedFirstJet=true;
00477 
00478             //second jet
00479             LooseCHFcleanedSecondJet=true;
00480             TightCHFcleanedSecondJet=true;
00481             if((pfJets.at(1).chargedHadronEnergy()/pfJets.at(1).energy())<=_LooseCHFMin && fabs(pfJets.at(1).eta())<2.4) LooseCHFcleanedSecondJet=false; //apply CHF>0 only if |eta|<2.4
00482             if((pfJets.at(1).chargedHadronEnergy()/pfJets.at(1).energy())<=_TightCHFMin && fabs(pfJets.at(1).eta())<2.4) TightCHFcleanedSecondJet=false; //apply CHF>0 only if |eta|<2.4
00483             if(LooseCHFcleanedSecondJet && (pfJets.at(1).neutralHadronEnergy()/pfJets.at(1).energy())<_LooseNHFMax && (pfJets.at(1).chargedEmEnergy()/pfJets.at(1).energy())<_LooseCEFMax && (pfJets.at(1).neutralEmEnergy()/pfJets.at(1).energy())<_LooseNEFMax) LoosecleanedSecondJet=true;
00484             if(TightCHFcleanedSecondJet && (pfJets.at(1).neutralHadronEnergy()/pfJets.at(1).energy())<_TightNHFMax && (pfJets.at(1).chargedEmEnergy()/pfJets.at(1).energy())<_TightCEFMax && (pfJets.at(1).neutralEmEnergy()/pfJets.at(1).energy())<_TightNEFMax) TightcleanedSecondJet=true;
00485       
00486             if(fillpfJIDPassFrac==1) {
00487               //fill the profile for jid efficiency 
00488               if(LoosecleanedFirstJet) {
00489                 mLooseJIDPassFractionVSeta->Fill(pfJets.at(0).eta(),1.);
00490                 mLooseJIDPassFractionVSpt->Fill(pfJets.at(0).pt(),1.);
00491               } else {
00492                 mLooseJIDPassFractionVSeta->Fill(pfJets.at(0).eta(),0.);
00493                 mLooseJIDPassFractionVSpt->Fill(pfJets.at(0).pt(),0.);
00494               }
00495               if(TightcleanedFirstJet) {
00496                 mTightJIDPassFractionVSeta->Fill(pfJets.at(0).eta(),1.);
00497                 mTightJIDPassFractionVSpt->Fill(pfJets.at(0).pt(),1.);
00498               } else {
00499                 mTightJIDPassFractionVSeta->Fill(pfJets.at(0).eta(),0.);
00500                 mTightJIDPassFractionVSpt->Fill(pfJets.at(0).pt(),0.);
00501               }
00502 
00503               if(LoosecleanedSecondJet) {
00504                 mLooseJIDPassFractionVSeta->Fill(pfJets.at(1).eta(),1.);
00505                 mLooseJIDPassFractionVSpt->Fill(pfJets.at(1).pt(),1.);
00506               } else {
00507                 mLooseJIDPassFractionVSeta->Fill(pfJets.at(1).eta(),0.);
00508                 mLooseJIDPassFractionVSpt->Fill(pfJets.at(1).pt(),0.);
00509               }
00510               if(TightcleanedSecondJet) {
00511                 mTightJIDPassFractionVSeta->Fill(pfJets.at(1).eta(),1.);
00512                 mTightJIDPassFractionVSpt->Fill(pfJets.at(1).pt(),1.);
00513               } else {
00514                 mTightJIDPassFractionVSeta->Fill(pfJets.at(1).eta(),0.);
00515                 mTightJIDPassFractionVSpt->Fill(pfJets.at(1).pt(),0.);
00516               }
00517             }
00518             
00519             if(LoosecleanedFirstJet && LoosecleanedSecondJet) {
00520               //Filling variables for first jet
00521               if (mPt)   mPt->Fill (pfJets.at(0).pt());
00522               if (mEta)  mEta->Fill (pfJets.at(0).eta());
00523               if (mPhi)  mPhi->Fill (pfJets.at(0).phi());
00524               if (mPhiVSEta) mPhiVSEta->Fill(pfJets.at(0).eta(),pfJets.at(0).phi());
00525               
00526               if (mConstituents) mConstituents->Fill (pfJets.at(0).nConstituents());
00527               if (mHFrac)        mHFrac->Fill (pfJets.at(0).chargedHadronEnergyFraction()+pfJets.at(0).neutralHadronEnergyFraction());
00528               if (mEFrac)        mEFrac->Fill (pfJets.at(0).chargedEmEnergyFraction() +pfJets.at(0).neutralEmEnergyFraction());
00529               
00530               //if (mE) mE->Fill (pfJets.at(0).energy());
00531               //if (mP) mP->Fill (pfJets.at(0).p());
00532               //if (mMass) mMass->Fill (pfJets.at(0).mass());
00533             
00534               if (mChargedHadronEnergy)  mChargedHadronEnergy->Fill (pfJets.at(0).chargedHadronEnergy());
00535               if (mNeutralHadronEnergy)  mNeutralHadronEnergy->Fill (pfJets.at(0).neutralHadronEnergy());
00536               if (mChargedEmEnergy) mChargedEmEnergy->Fill(pfJets.at(0).chargedEmEnergy());
00537               if (mChargedMuEnergy) mChargedMuEnergy->Fill (pfJets.at(0).chargedMuEnergy ());
00538               if (mNeutralEmEnergy) mNeutralEmEnergy->Fill(pfJets.at(0).neutralEmEnergy());
00539               if (mChargedMultiplicity ) mChargedMultiplicity->Fill(pfJets.at(0).chargedMultiplicity());
00540               if (mNeutralMultiplicity ) mNeutralMultiplicity->Fill(pfJets.at(0).neutralMultiplicity());
00541               if (mMuonMultiplicity )mMuonMultiplicity->Fill (pfJets.at(0). muonMultiplicity());
00542               //_______________________________________________________
00543               if (mNeutralFraction) mNeutralFraction->Fill (pfJets.at(0).neutralMultiplicity()/pfJets.at(0).nConstituents());
00544 
00545 
00546               //Filling variables for second jet
00547               if (mPt)   mPt->Fill (pfJets.at(1).pt());
00548               if (mEta)  mEta->Fill (pfJets.at(1).eta());
00549               if (mPhi)  mPhi->Fill (pfJets.at(1).phi());
00550               if (mPhiVSEta) mPhiVSEta->Fill(pfJets.at(1).eta(),pfJets.at(1).phi());
00551               
00552               if (mConstituents) mConstituents->Fill (pfJets.at(1).nConstituents());
00553               if (mHFrac)        mHFrac->Fill (pfJets.at(1).chargedHadronEnergyFraction()+pfJets.at(1).neutralHadronEnergyFraction());
00554               if (mEFrac)        mEFrac->Fill (pfJets.at(1).chargedEmEnergyFraction() +pfJets.at(1).neutralEmEnergyFraction());
00555               
00556               //if (mE) mE->Fill (pfJets.at(1).energy());
00557               //if (mP) mP->Fill (pfJets.at(1).p());
00558               //if (mMass) mMass->Fill (pfJets.at(1).mass());
00559             
00560               if (mChargedHadronEnergy)  mChargedHadronEnergy->Fill (pfJets.at(1).chargedHadronEnergy());
00561               if (mNeutralHadronEnergy)  mNeutralHadronEnergy->Fill (pfJets.at(1).neutralHadronEnergy());
00562               if (mChargedEmEnergy) mChargedEmEnergy->Fill(pfJets.at(1).chargedEmEnergy());
00563               if (mChargedMuEnergy) mChargedMuEnergy->Fill (pfJets.at(1).chargedMuEnergy ());
00564               if (mNeutralEmEnergy) mNeutralEmEnergy->Fill(pfJets.at(1).neutralEmEnergy());
00565               if (mChargedMultiplicity ) mChargedMultiplicity->Fill(pfJets.at(1).chargedMultiplicity());
00566               if (mNeutralMultiplicity ) mNeutralMultiplicity->Fill(pfJets.at(1).neutralMultiplicity());
00567               if (mMuonMultiplicity )mMuonMultiplicity->Fill (pfJets.at(1). muonMultiplicity());
00568               //_______________________________________________________
00569               if (mNeutralFraction) mNeutralFraction->Fill (pfJets.at(1).neutralMultiplicity()/pfJets.at(1).nConstituents());
00570 
00571 
00572               // Fill NPV profiles
00573               //----------------------------------------------------------------
00574               for (int iJet=0; iJet<2; iJet++) {
00575 
00576                 if (mPt_profile)           mPt_profile          ->Fill(numPV, pfJets.at(iJet).pt());
00577                 if (mEta_profile)          mEta_profile         ->Fill(numPV, pfJets.at(iJet).eta());
00578                 if (mPhi_profile)          mPhi_profile         ->Fill(numPV, pfJets.at(iJet).phi());
00579                 if (mConstituents_profile) mConstituents_profile->Fill(numPV, pfJets.at(iJet).nConstituents());
00580                 if (mHFrac_profile)        mHFrac_profile       ->Fill(numPV, pfJets.at(iJet).chargedHadronEnergyFraction() + pfJets.at(iJet).neutralHadronEnergyFraction());
00581                 if (mEFrac_profile)        mEFrac_profile       ->Fill(numPV, pfJets.at(iJet).chargedEmEnergyFraction()     + pfJets.at(iJet).neutralEmEnergyFraction());
00582               
00583                 if (mChargedHadronEnergy_profile) mChargedHadronEnergy_profile->Fill(numPV, pfJets.at(iJet).chargedHadronEnergy());
00584                 if (mNeutralHadronEnergy_profile) mNeutralHadronEnergy_profile->Fill(numPV, pfJets.at(iJet).neutralHadronEnergy());
00585                 if (mChargedEmEnergy_profile)     mChargedEmEnergy_profile    ->Fill(numPV, pfJets.at(iJet).chargedEmEnergy());
00586                 if (mChargedMuEnergy_profile)     mChargedMuEnergy_profile    ->Fill(numPV, pfJets.at(iJet).chargedMuEnergy());
00587                 if (mNeutralEmEnergy_profile)     mNeutralEmEnergy_profile    ->Fill(numPV, pfJets.at(iJet).neutralEmEnergy());
00588                 if (mChargedMultiplicity_profile) mChargedMultiplicity_profile->Fill(numPV, pfJets.at(iJet).chargedMultiplicity());
00589                 if (mNeutralMultiplicity_profile) mNeutralMultiplicity_profile->Fill(numPV, pfJets.at(iJet).neutralMultiplicity());
00590                 if (mMuonMultiplicity_profile)    mMuonMultiplicity_profile   ->Fill(numPV, pfJets.at(iJet).muonMultiplicity());
00591               }
00592 
00593 
00594             }// loose cleaned jets 1 and 2
00595           }// fabs dphi < 2.1
00596         }// fabs eta < 3
00597       }// pt jets > threshold
00598       //now do the dijet balance and asymmetry calculations
00599       if (fabs(pfJets.at(0).eta() < 1.4)) {
00600         double pt_dijet = (pfJets.at(0).pt() + pfJets.at(1).pt())/2;
00601 
00602         double dPhi = fabs((pfJets.at(0)).phi()-(pfJets.at(1)).phi());
00603         if (dPhi > 3.14) dPhi=fabs(dPhi -6.28 );
00604         
00605         if (dPhi > 2.7) {
00606           double pt_probe;
00607           double pt_barrel;
00608           int jet1, jet2;
00609 
00610           int randJet = rand() % 2;
00611 
00612           if (fabs(pfJets.at(1).eta() < 1.4)) {
00613             if (randJet) {
00614               jet1 = 0;
00615               jet2 = 1;
00616             }
00617             else {
00618               jet1 = 1;
00619               jet2 = 0;
00620             }
00621           
00622             /***Di-Jet Asymmetry****
00623              * leading jets eta < 1.4
00624              * leading jets dphi > 2.7
00625              * pt_third jet < threshold
00626              * A = (pt_1 - pt_2)/(pt_1 + pt_2)
00627              * jets 1 and two are randomly ordered
00628              */
00629             bool thirdJetCut = true;
00630             for (unsigned int third = 2; third < pfJets.size(); ++third) 
00631               if (pfJets.at(third).pt() > _asymmetryThirdJetCut) 
00632                 thirdJetCut = false;
00633             if (thirdJetCut) {
00634               double dijetAsymmetry = (pfJets.at(jet1).pt() - pfJets.at(jet2).pt()) / (pfJets.at(jet1).pt() + pfJets.at(jet2).pt());
00635               mDijetAsymmetry->Fill(dijetAsymmetry);
00636             }// end restriction on third jet pt in asymmetry calculation
00637               
00638           }
00639           else {
00640             jet1 = 0;
00641             jet2 = 1;
00642           }
00643           
00644           pt_barrel = pfJets.at(jet1).pt();
00645           pt_probe  = pfJets.at(jet2).pt();
00646           
00647           //dijet balance cuts
00648           /***Di-Jet Balance****
00649            * pt_dijet = (pt_probe+pt_barrel)/2
00650            * leading jets dphi > 2.7
00651            * reject evnets where pt_third/pt_dijet > 0.2
00652            * pv selection
00653            * B = (pt_probe - pt_barrel)/pt_dijet
00654            * select probe randomly from 2 jets if both leading jets are in the barrel
00655            */
00656           bool thirdJetCut = true;
00657           for (unsigned int third = 2; third < pfJets.size(); ++third) 
00658             if (pfJets.at(third).pt()/pt_dijet > _balanceThirdJetCut) 
00659               thirdJetCut = false;
00660           if (thirdJetCut) {
00661             double dijetBalance = (pt_probe - pt_barrel) / pt_dijet;
00662             mDijetBalance->Fill(dijetBalance);
00663           }// end restriction on third jet pt ratio in balance calculation
00664         }// dPhi > 2.7
00665       }// leading jet eta cut for asymmetry and balance calculations
00666     }// jet size >= 2
00667   } // do dijet selection
00668   else{
00669     for (reco::PFJetCollection::const_iterator jet = pfJets.begin(); jet!=pfJets.end(); ++jet){
00670       LogTrace(metname)<<"[JetAnalyzer] Analyze PFJet";
00671  
00672       Thiscleaned=false;
00673       Loosecleaned=false;
00674       Tightcleaned=false;
00675 
00676       if (jet == pfJets.begin()) {
00677         fstPhi = jet->phi();
00678         _leadJetFlag = 1;
00679       } else {
00680         _leadJetFlag = 0;
00681       }
00682 
00683       if (jet == (pfJets.begin()+1)) sndPhi = jet->phi();
00684       //  if (jet->pt() < _ptThreshold) return;
00685       if (jet->pt() > _ptThreshold) {
00686         numofjets++ ;
00687         jetME->Fill(2);
00688             
00689         //calculate the jetID
00690         ThisCHFcleaned=true;
00691         LooseCHFcleaned=true;
00692         TightCHFcleaned=true;
00693         if((jet->chargedHadronEnergy()/jet->energy())<=_ThisCHFMin && fabs(jet->eta())<2.4) ThisCHFcleaned=false; //apply CHF>0 only if |eta|<2.4
00694         if((jet->chargedHadronEnergy()/jet->energy())<=_LooseCHFMin && fabs(jet->eta())<2.4) LooseCHFcleaned=false; //apply CHF>0 only if |eta|<2.4
00695         if((jet->chargedHadronEnergy()/jet->energy())<=_TightCHFMin && fabs(jet->eta())<2.4) TightCHFcleaned=false; //apply CHF>0 only if |eta|<2.4
00696         if(ThisCHFcleaned && (jet->neutralHadronEnergy()/jet->energy())<_ThisNHFMax && (jet->chargedEmEnergy()/jet->energy())<_ThisCEFMax && (jet->neutralEmEnergy()/jet->energy())<_ThisNEFMax) Thiscleaned=true;
00697         if(LooseCHFcleaned && (jet->neutralHadronEnergy()/jet->energy())<_LooseNHFMax && (jet->chargedEmEnergy()/jet->energy())<_LooseCEFMax && (jet->neutralEmEnergy()/jet->energy())<_LooseNEFMax) Loosecleaned=true;
00698         if(TightCHFcleaned && (jet->neutralHadronEnergy()/jet->energy())<_TightNHFMax && (jet->chargedEmEnergy()/jet->energy())<_TightCEFMax && (jet->neutralEmEnergy()/jet->energy())<_TightNEFMax) Tightcleaned=true;
00699       
00700         if(fillpfJIDPassFrac==1) {
00701           //fill the profile for jid efficiency 
00702           if(Loosecleaned) {
00703             mLooseJIDPassFractionVSeta->Fill(jet->eta(),1.);
00704             mLooseJIDPassFractionVSpt->Fill(jet->pt(),1.);
00705           } else {
00706             mLooseJIDPassFractionVSeta->Fill(jet->eta(),0.);
00707             mLooseJIDPassFractionVSpt->Fill(jet->pt(),0.);
00708           }
00709           if(Tightcleaned) {
00710             mTightJIDPassFractionVSeta->Fill(jet->eta(),1.);
00711             mTightJIDPassFractionVSpt->Fill(jet->pt(),1.);
00712           } else {
00713             mTightJIDPassFractionVSeta->Fill(jet->eta(),0.);
00714             mTightJIDPassFractionVSpt->Fill(jet->pt(),0.);
00715           }
00716         }
00717       
00718         if(!Thiscleaned) continue;
00719       
00720         // Leading jet
00721         // Histograms are filled once per event
00722         if (_leadJetFlag == 1) { 
00723         
00724           if (mEtaFirst) mEtaFirst->Fill (jet->eta());
00725           if (mPhiFirst) mPhiFirst->Fill (jet->phi());
00726           //if (mEFirst)   mEFirst->Fill (jet->energy());
00727           if (mPtFirst)  mPtFirst->Fill (jet->pt());
00728         }
00729       
00730         // --- Passed the low pt jet trigger (no longer used)
00731         if (_JetLoPass == 1) {
00732         /*  if (fabs(jet->eta()) <= 1.3) {
00733             if (mPt_Barrel_Lo)           mPt_Barrel_Lo->Fill(jet->pt());
00734             if (mEta_Lo)          mEta_Lo->Fill(jet->eta());
00735             if (mPhi_Barrel_Lo)          mPhi_Barrel_Lo->Fill(jet->phi());
00736           }
00737           if ( (fabs(jet->eta()) > 1.3) && (fabs(jet->eta()) <= 3) ) {
00738             if (mPt_EndCap_Lo)           mPt_EndCap_Lo->Fill(jet->pt());
00739             if (mEta_Lo)          mEta_Lo->Fill(jet->eta());
00740             if (mPhi_EndCap_Lo)          mPhi_EndCap_Lo->Fill(jet->phi());
00741           }
00742           if (fabs(jet->eta()) > 3.0) {
00743             if (mPt_Forward_Lo)           mPt_Forward_Lo->Fill(jet->pt());
00744             if (mEta_Lo)          mEta_Lo->Fill(jet->eta());
00745             if (mPhi_Forward_Lo)          mPhi_Forward_Lo->Fill(jet->phi());
00746           }*/
00747           //if (mEta_Lo) mEta_Lo->Fill (jet->eta());
00748           if (mPhi_Lo) mPhi_Lo->Fill (jet->phi());
00749           if (mPt_Lo)  mPt_Lo->Fill (jet->pt());
00750         }
00751       
00752         // --- Passed the high pt jet trigger
00753         if (_JetHiPass == 1) {
00754           if (fabs(jet->eta()) <= 1.3) {
00755             if (mPt_Barrel_Hi && jet->pt()>100.)           mPt_Barrel_Hi->Fill(jet->pt());
00756             if (mEta_Hi && jet->pt()>100.)          mEta_Hi->Fill(jet->eta());
00757             if (mPhi_Barrel_Hi)          mPhi_Barrel_Hi->Fill(jet->phi());
00758             //if (mConstituents_Barrel_Hi) mConstituents_Barrel_Hi->Fill(jet->nConstituents()); 
00759             //if (mHFrac_Barrel_Hi)        mHFrac_Barrel_Hi->Fill(jet->chargedHadronEnergyFraction()+jet->neutralHadronEnergyFraction());       
00760           }
00761           if ( (fabs(jet->eta()) > 1.3) && (fabs(jet->eta()) <= 3) ) {
00762             if (mPt_EndCap_Hi && jet->pt()>100.)           mPt_EndCap_Hi->Fill(jet->pt());
00763             if (mEta_Hi && jet->pt()>100.)          mEta_Hi->Fill(jet->eta());
00764             if (mPhi_EndCap_Hi)          mPhi_EndCap_Hi->Fill(jet->phi());
00765             //if (mConstituents_EndCap_Hi) mConstituents_EndCap_Hi->Fill(jet->nConstituents()); 
00766             //if (mHFrac_EndCap_Hi)        mHFrac_EndCap_Hi->Fill(jet->chargedHadronEnergyFraction()+jet->neutralHadronEnergyFraction());       
00767           }
00768           if (fabs(jet->eta()) > 3.0) {
00769             if (mPt_Forward_Hi && jet->pt()>100.)           mPt_Forward_Hi->Fill(jet->pt());
00770             if (mEta_Hi && jet->pt()>100.)          mEta_Hi->Fill(jet->eta());
00771             if (mPhi_Forward_Hi)          mPhi_Forward_Hi->Fill(jet->phi());
00772             //if (mConstituents_Forward_Hi) mConstituents_Forward_Hi->Fill(jet->nConstituents());       
00773             //if (mHFrac_Forward_Hi)        mHFrac_Forward_Hi->Fill(jet->chargedHadronEnergyFraction()+jet->neutralHadronEnergyFraction());     
00774           }
00775         
00776           if (mEta_Hi && jet->pt()>100.) mEta_Hi->Fill (jet->eta());
00777           if (mPhi_Hi) mPhi_Hi->Fill (jet->phi());
00778           if (mPt_Hi)  mPt_Hi->Fill (jet->pt());
00779         }
00780       
00781         if (mPt)   mPt->Fill (jet->pt());
00782         if (mPt_1) mPt_1->Fill (jet->pt());
00783         if (mPt_2) mPt_2->Fill (jet->pt());
00784         if (mPt_3) mPt_3->Fill (jet->pt());
00785         if (mEta)  mEta->Fill (jet->eta());
00786         if (mPhi)  mPhi->Fill (jet->phi());
00787         if (mPhiVSEta) mPhiVSEta->Fill(jet->eta(),jet->phi());
00788       
00789         if (mConstituents) mConstituents->Fill (jet->nConstituents());
00790         if (mHFrac)        mHFrac->Fill (jet->chargedHadronEnergyFraction()+jet->neutralHadronEnergyFraction());
00791         if (mEFrac)        mEFrac->Fill (jet->chargedEmEnergyFraction() +jet->neutralEmEnergyFraction());
00792       
00793         if (jet->pt()<= 50) {
00794           if (mCHFracVSeta_lowPt) mCHFracVSeta_lowPt->Fill(jet->eta(),jet->chargedHadronEnergyFraction());
00795           if (mNHFracVSeta_lowPt) mNHFracVSeta_lowPt->Fill(jet->eta(),jet->neutralHadronEnergyFraction());
00796           if (mPhFracVSeta_lowPt) mPhFracVSeta_lowPt->Fill(jet->eta(),jet->neutralEmEnergyFraction());
00797           if (mElFracVSeta_lowPt) mElFracVSeta_lowPt->Fill(jet->eta(),jet->chargedEmEnergyFraction());
00798           if (mMuFracVSeta_lowPt) mMuFracVSeta_lowPt->Fill(jet->eta(),jet->chargedMuEnergyFraction());
00799         }
00800         if (jet->pt()>50. && jet->pt()<=140.) {
00801           if (mCHFracVSeta_mediumPt) mCHFracVSeta_mediumPt->Fill(jet->eta(),jet->chargedHadronEnergyFraction());
00802           if (mNHFracVSeta_mediumPt) mNHFracVSeta_mediumPt->Fill(jet->eta(),jet->neutralHadronEnergyFraction());
00803           if (mPhFracVSeta_mediumPt) mPhFracVSeta_mediumPt->Fill(jet->eta(),jet->neutralEmEnergyFraction());
00804           if (mElFracVSeta_mediumPt) mElFracVSeta_mediumPt->Fill(jet->eta(),jet->chargedEmEnergyFraction());
00805           if (mMuFracVSeta_mediumPt) mMuFracVSeta_mediumPt->Fill(jet->eta(),jet->chargedMuEnergyFraction());
00806         }
00807         if (jet->pt()>140.) {
00808           if (mCHFracVSeta_highPt) mCHFracVSeta_highPt->Fill(jet->eta(),jet->chargedHadronEnergyFraction());
00809           if (mNHFracVSeta_highPt) mNHFracVSeta_highPt->Fill(jet->eta(),jet->neutralHadronEnergyFraction());
00810           if (mPhFracVSeta_highPt) mPhFracVSeta_highPt->Fill(jet->eta(),jet->neutralEmEnergyFraction());
00811           if (mElFracVSeta_highPt) mElFracVSeta_highPt->Fill(jet->eta(),jet->chargedEmEnergyFraction());
00812           if (mMuFracVSeta_highPt) mMuFracVSeta_highPt->Fill(jet->eta(),jet->chargedMuEnergyFraction());
00813         }
00814 
00815         if (fabs(jet->eta()) <= 1.3) {
00816           if (mPt_Barrel)   mPt_Barrel->Fill (jet->pt());
00817           if (mPhi_Barrel)  mPhi_Barrel->Fill (jet->phi());
00818           //if (mE_Barrel)    mE_Barrel->Fill (jet->energy());
00819     if (mConstituents_Barrel)    mConstituents_Barrel->Fill(jet->nConstituents());      
00820     if (mHFrac_Barrel)           mHFrac_Barrel->Fill(jet->chargedHadronEnergyFraction() + jet->neutralHadronEnergyFraction() );
00821     if (mEFrac_Barrel)           mEFrac->Fill (jet->chargedEmEnergyFraction() + jet->neutralEmEnergyFraction());        
00822           //fractions
00823           if (jet->pt()<=50.) {
00824             if (mCHFrac_lowPt_Barrel) mCHFrac_lowPt_Barrel->Fill(jet->chargedHadronEnergyFraction());
00825             if (mNHFrac_lowPt_Barrel) mNHFrac_lowPt_Barrel->Fill(jet->neutralHadronEnergyFraction());
00826             if (mPhFrac_lowPt_Barrel) mPhFrac_lowPt_Barrel->Fill(jet->neutralEmEnergyFraction());
00827             if (mElFrac_lowPt_Barrel) mElFrac_lowPt_Barrel->Fill(jet->chargedEmEnergyFraction());
00828             if (mMuFrac_lowPt_Barrel) mMuFrac_lowPt_Barrel->Fill(jet->chargedMuEnergyFraction());
00829             //
00830             if (mCHEn_lowPt_Barrel) mCHEn_lowPt_Barrel->Fill(jet->chargedHadronEnergy());
00831             if (mNHEn_lowPt_Barrel) mNHEn_lowPt_Barrel->Fill(jet->neutralHadronEnergy());
00832             if (mPhEn_lowPt_Barrel) mPhEn_lowPt_Barrel->Fill(jet->neutralEmEnergy());
00833             if (mElEn_lowPt_Barrel) mElEn_lowPt_Barrel->Fill(jet->chargedEmEnergy());
00834             if (mMuEn_lowPt_Barrel) mMuEn_lowPt_Barrel->Fill(jet->chargedMuEnergy());
00835           }
00836           if (jet->pt()>50. && jet->pt()<=140.) {
00837             if (mCHFrac_mediumPt_Barrel) mCHFrac_mediumPt_Barrel->Fill(jet->chargedHadronEnergyFraction());
00838             if (mNHFrac_mediumPt_Barrel) mNHFrac_mediumPt_Barrel->Fill(jet->neutralHadronEnergyFraction());
00839             if (mPhFrac_mediumPt_Barrel) mPhFrac_mediumPt_Barrel->Fill(jet->neutralEmEnergyFraction());
00840             if (mElFrac_mediumPt_Barrel) mElFrac_mediumPt_Barrel->Fill(jet->chargedEmEnergyFraction());
00841             if (mMuFrac_mediumPt_Barrel) mMuFrac_mediumPt_Barrel->Fill(jet->chargedMuEnergyFraction());
00842             //
00843             if (mCHEn_mediumPt_Barrel) mCHEn_mediumPt_Barrel->Fill(jet->chargedHadronEnergy());
00844             if (mNHEn_mediumPt_Barrel) mNHEn_mediumPt_Barrel->Fill(jet->neutralHadronEnergy());
00845             if (mPhEn_mediumPt_Barrel) mPhEn_mediumPt_Barrel->Fill(jet->neutralEmEnergy());
00846             if (mElEn_mediumPt_Barrel) mElEn_mediumPt_Barrel->Fill(jet->chargedEmEnergy());
00847             if (mMuEn_mediumPt_Barrel) mMuEn_mediumPt_Barrel->Fill(jet->chargedMuEnergy());
00848           }
00849           if (jet->pt()>140.) {
00850             if (mCHFrac_highPt_Barrel) mCHFrac_highPt_Barrel->Fill(jet->chargedHadronEnergyFraction());
00851             if (mNHFrac_highPt_Barrel) mNHFrac_highPt_Barrel->Fill(jet->neutralHadronEnergyFraction());
00852             if (mPhFrac_highPt_Barrel) mPhFrac_highPt_Barrel->Fill(jet->neutralEmEnergyFraction());
00853             if (mElFrac_highPt_Barrel) mElFrac_highPt_Barrel->Fill(jet->chargedEmEnergyFraction());
00854             if (mMuFrac_highPt_Barrel) mMuFrac_highPt_Barrel->Fill(jet->chargedMuEnergyFraction());
00855             //
00856             if (mCHEn_highPt_Barrel) mCHEn_highPt_Barrel->Fill(jet->chargedHadronEnergy());
00857             if (mNHEn_highPt_Barrel) mNHEn_highPt_Barrel->Fill(jet->neutralHadronEnergy());
00858             if (mPhEn_highPt_Barrel) mPhEn_highPt_Barrel->Fill(jet->neutralEmEnergy());
00859             if (mElEn_highPt_Barrel) mElEn_highPt_Barrel->Fill(jet->chargedEmEnergy());
00860             if (mMuEn_highPt_Barrel) mMuEn_highPt_Barrel->Fill(jet->chargedMuEnergy());
00861           }
00862           if(mChMultiplicity_lowPt_Barrel)  mChMultiplicity_lowPt_Barrel->Fill(jet->chargedMultiplicity());
00863           if(mNeuMultiplicity_lowPt_Barrel)  mNeuMultiplicity_lowPt_Barrel->Fill(jet->neutralMultiplicity());
00864           if(mMuMultiplicity_lowPt_Barrel)  mMuMultiplicity_lowPt_Barrel->Fill(jet->muonMultiplicity());
00865           if(mChMultiplicity_mediumPt_Barrel)  mChMultiplicity_mediumPt_Barrel->Fill(jet->chargedMultiplicity());
00866           if(mNeuMultiplicity_mediumPt_Barrel)  mNeuMultiplicity_mediumPt_Barrel->Fill(jet->neutralMultiplicity());
00867           if(mMuMultiplicity_mediumPt_Barrel)  mMuMultiplicity_mediumPt_Barrel->Fill(jet->muonMultiplicity());
00868           if(mChMultiplicity_highPt_Barrel)  mChMultiplicity_highPt_Barrel->Fill(jet->chargedMultiplicity());
00869           if(mNeuMultiplicity_highPt_Barrel)  mNeuMultiplicity_highPt_Barrel->Fill(jet->neutralMultiplicity());
00870           if(mMuMultiplicity_highPt_Barrel)  mMuMultiplicity_highPt_Barrel->Fill(jet->muonMultiplicity());
00871           //
00872           if (mCHFracVSpT_Barrel) mCHFracVSpT_Barrel->Fill(jet->pt(),jet->chargedHadronEnergyFraction());
00873           if (mNHFracVSpT_Barrel) mNHFracVSpT_Barrel->Fill(jet->pt(),jet->neutralHadronEnergyFraction());
00874           if (mPhFracVSpT_Barrel) mPhFracVSpT_Barrel->Fill(jet->pt(),jet->neutralEmEnergyFraction());
00875           if (mElFracVSpT_Barrel) mElFracVSpT_Barrel->Fill(jet->pt(),jet->chargedEmEnergyFraction());
00876           if (mMuFracVSpT_Barrel) mMuFracVSpT_Barrel->Fill(jet->pt(),jet->chargedMuEnergyFraction());
00877         }
00878         if ( (fabs(jet->eta()) > 1.3) && (fabs(jet->eta()) <= 3) ) {
00879           if (mPt_EndCap)   mPt_EndCap->Fill (jet->pt());
00880           if (mPhi_EndCap)  mPhi_EndCap->Fill (jet->phi());
00881           //if (mE_EndCap)    mE_EndCap->Fill (jet->energy());
00882     if (mConstituents_EndCap)    mConstituents_EndCap->Fill(jet->nConstituents());      
00883     if (mHFrac_EndCap)           mHFrac_EndCap->Fill(jet->chargedHadronEnergyFraction() + jet->neutralHadronEnergyFraction());
00884     if (mEFrac_EndCap)           mEFrac->Fill (jet->chargedEmEnergyFraction() + jet->neutralEmEnergyFraction());
00885           //fractions
00886           if (jet->pt()<=50.) {
00887             if (mCHFrac_lowPt_EndCap) mCHFrac_lowPt_EndCap->Fill(jet->chargedHadronEnergyFraction());
00888             if (mNHFrac_lowPt_EndCap) mNHFrac_lowPt_EndCap->Fill(jet->neutralHadronEnergyFraction());
00889             if (mPhFrac_lowPt_EndCap) mPhFrac_lowPt_EndCap->Fill(jet->neutralEmEnergyFraction());
00890             if (mElFrac_lowPt_EndCap) mElFrac_lowPt_EndCap->Fill(jet->chargedEmEnergyFraction());
00891             if (mMuFrac_lowPt_EndCap) mMuFrac_lowPt_EndCap->Fill(jet->chargedMuEnergyFraction());
00892             //
00893             if (mCHEn_lowPt_EndCap) mCHEn_lowPt_EndCap->Fill(jet->chargedHadronEnergy());
00894             if (mNHEn_lowPt_EndCap) mNHEn_lowPt_EndCap->Fill(jet->neutralHadronEnergy());
00895             if (mPhEn_lowPt_EndCap) mPhEn_lowPt_EndCap->Fill(jet->neutralEmEnergy());
00896             if (mElEn_lowPt_EndCap) mElEn_lowPt_EndCap->Fill(jet->chargedEmEnergy());
00897             if (mMuEn_lowPt_EndCap) mMuEn_lowPt_EndCap->Fill(jet->chargedMuEnergy());
00898           }
00899           if (jet->pt()>50. && jet->pt()<=140.) {
00900             if (mCHFrac_mediumPt_EndCap) mCHFrac_mediumPt_EndCap->Fill(jet->chargedHadronEnergyFraction());
00901             if (mNHFrac_mediumPt_EndCap) mNHFrac_mediumPt_EndCap->Fill(jet->neutralHadronEnergyFraction());
00902             if (mPhFrac_mediumPt_EndCap) mPhFrac_mediumPt_EndCap->Fill(jet->neutralEmEnergyFraction());
00903             if (mElFrac_mediumPt_EndCap) mElFrac_mediumPt_EndCap->Fill(jet->chargedEmEnergyFraction());
00904             if (mMuFrac_mediumPt_EndCap) mMuFrac_mediumPt_EndCap->Fill(jet->chargedMuEnergyFraction());
00905             //
00906             if (mCHEn_mediumPt_EndCap) mCHEn_mediumPt_EndCap->Fill(jet->chargedHadronEnergy());
00907             if (mNHEn_mediumPt_EndCap) mNHEn_mediumPt_EndCap->Fill(jet->neutralHadronEnergy());
00908             if (mPhEn_mediumPt_EndCap) mPhEn_mediumPt_EndCap->Fill(jet->neutralEmEnergy());
00909             if (mElEn_mediumPt_EndCap) mElEn_mediumPt_EndCap->Fill(jet->chargedEmEnergy());
00910             if (mMuEn_mediumPt_EndCap) mMuEn_mediumPt_EndCap->Fill(jet->chargedMuEnergy());
00911           }
00912           if (jet->pt()>140.) {
00913             if (mCHFrac_highPt_EndCap) mCHFrac_highPt_EndCap->Fill(jet->chargedHadronEnergyFraction());
00914             if (mNHFrac_highPt_EndCap) mNHFrac_highPt_EndCap->Fill(jet->neutralHadronEnergyFraction());
00915             if (mPhFrac_highPt_EndCap) mPhFrac_highPt_EndCap->Fill(jet->neutralEmEnergyFraction());
00916             if (mElFrac_highPt_EndCap) mElFrac_highPt_EndCap->Fill(jet->chargedEmEnergyFraction());
00917             if (mMuFrac_highPt_EndCap) mMuFrac_highPt_EndCap->Fill(jet->chargedMuEnergyFraction());
00918             //
00919             if (mCHEn_highPt_EndCap) mCHEn_highPt_EndCap->Fill(jet->chargedHadronEnergy());
00920             if (mNHEn_highPt_EndCap) mNHEn_highPt_EndCap->Fill(jet->neutralHadronEnergy());
00921             if (mPhEn_highPt_EndCap) mPhEn_highPt_EndCap->Fill(jet->neutralEmEnergy());
00922             if (mElEn_highPt_EndCap) mElEn_highPt_EndCap->Fill(jet->chargedEmEnergy());
00923             if (mMuEn_highPt_EndCap) mMuEn_highPt_EndCap->Fill(jet->chargedMuEnergy());
00924           }
00925           if(mChMultiplicity_lowPt_EndCap)  mChMultiplicity_lowPt_EndCap->Fill(jet->chargedMultiplicity());
00926           if(mNeuMultiplicity_lowPt_EndCap)  mNeuMultiplicity_lowPt_EndCap->Fill(jet->neutralMultiplicity());
00927           if(mMuMultiplicity_lowPt_EndCap)  mMuMultiplicity_lowPt_EndCap->Fill(jet->muonMultiplicity());
00928           if(mChMultiplicity_mediumPt_EndCap)  mChMultiplicity_mediumPt_EndCap->Fill(jet->chargedMultiplicity());
00929           if(mNeuMultiplicity_mediumPt_EndCap)  mNeuMultiplicity_mediumPt_EndCap->Fill(jet->neutralMultiplicity());
00930           if(mMuMultiplicity_mediumPt_EndCap)  mMuMultiplicity_mediumPt_EndCap->Fill(jet->muonMultiplicity());
00931           if(mChMultiplicity_highPt_EndCap)  mChMultiplicity_highPt_EndCap->Fill(jet->chargedMultiplicity());
00932           if(mNeuMultiplicity_highPt_EndCap)  mNeuMultiplicity_highPt_EndCap->Fill(jet->neutralMultiplicity());
00933           if(mMuMultiplicity_highPt_EndCap)  mMuMultiplicity_highPt_EndCap->Fill(jet->muonMultiplicity());
00934           //
00935           if (mCHFracVSpT_EndCap) mCHFracVSpT_EndCap->Fill(jet->pt(),jet->chargedHadronEnergyFraction());
00936           if (mNHFracVSpT_EndCap) mNHFracVSpT_EndCap->Fill(jet->pt(),jet->neutralHadronEnergyFraction());
00937           if (mPhFracVSpT_EndCap) mPhFracVSpT_EndCap->Fill(jet->pt(),jet->neutralEmEnergyFraction());
00938           if (mElFracVSpT_EndCap) mElFracVSpT_EndCap->Fill(jet->pt(),jet->chargedEmEnergyFraction());
00939           if (mMuFracVSpT_EndCap) mMuFracVSpT_EndCap->Fill(jet->pt(),jet->chargedMuEnergyFraction());
00940         }
00941         if (fabs(jet->eta()) > 3.0) {
00942           if (mPt_Forward)   mPt_Forward->Fill (jet->pt());
00943           if (mPhi_Forward)  mPhi_Forward->Fill (jet->phi());
00944           //if (mE_Forward)    mE_Forward->Fill (jet->energy());
00945     if (mConstituents_Forward)    mConstituents_Forward->Fill(jet->nConstituents());    
00946     if (mHFrac_Forward)           mHFrac_Forward->Fill(jet->chargedHadronEnergyFraction() + jet->neutralHadronEnergyFraction());        
00947     if (mEFrac_Forward)           mEFrac->Fill (jet->chargedEmEnergyFraction() + jet->neutralEmEnergyFraction());
00948           //fractions
00949           if (jet->pt()<=50.) {
00950             if(mHFEFrac_lowPt_Forward) mHFEFrac_lowPt_Forward->Fill(jet->HFEMEnergyFraction());
00951             if(mHFHFrac_lowPt_Forward) mHFHFrac_lowPt_Forward->Fill(jet->HFHadronEnergyFraction());
00952             //
00953             if(mHFEEn_lowPt_Forward) mHFEEn_lowPt_Forward->Fill(jet->HFEMEnergy());
00954             if(mHFHEn_lowPt_Forward) mHFHEn_lowPt_Forward->Fill(jet->HFHadronEnergy());
00955           }
00956           if (jet->pt()>50. && jet->pt()<=140.) {
00957             if(mHFEFrac_mediumPt_Forward) mHFEFrac_mediumPt_Forward->Fill(jet->HFEMEnergyFraction());
00958             if(mHFHFrac_mediumPt_Forward) mHFHFrac_mediumPt_Forward->Fill(jet->HFHadronEnergyFraction());
00959             //
00960             if(mHFEEn_mediumPt_Forward) mHFEEn_mediumPt_Forward->Fill(jet->HFEMEnergy());
00961             if(mHFHEn_mediumPt_Forward) mHFHEn_mediumPt_Forward->Fill(jet->HFHadronEnergy());
00962           }
00963           if (jet->pt()>140.) {
00964             if(mHFEFrac_highPt_Forward) mHFEFrac_highPt_Forward->Fill(jet->HFEMEnergyFraction());
00965             if(mHFHFrac_highPt_Forward) mHFHFrac_highPt_Forward->Fill(jet->HFHadronEnergyFraction());
00966             //
00967             if(mHFEEn_highPt_Forward) mHFEEn_highPt_Forward->Fill(jet->HFEMEnergy());
00968             if(mHFHEn_highPt_Forward) mHFHEn_highPt_Forward->Fill(jet->HFHadronEnergy());
00969           }
00970           if(mChMultiplicity_lowPt_Forward)  mChMultiplicity_lowPt_Forward->Fill(jet->chargedMultiplicity());
00971           if(mNeuMultiplicity_lowPt_Forward)  mNeuMultiplicity_lowPt_Forward->Fill(jet->neutralMultiplicity());
00972           if(mMuMultiplicity_lowPt_Forward)  mMuMultiplicity_lowPt_Forward->Fill(jet->muonMultiplicity());
00973           if(mChMultiplicity_mediumPt_Forward)  mChMultiplicity_mediumPt_Forward->Fill(jet->chargedMultiplicity());
00974           if(mNeuMultiplicity_mediumPt_Forward)  mNeuMultiplicity_mediumPt_Forward->Fill(jet->neutralMultiplicity());
00975           if(mMuMultiplicity_mediumPt_Forward)  mMuMultiplicity_mediumPt_Forward->Fill(jet->muonMultiplicity());
00976           if(mChMultiplicity_highPt_Forward)  mChMultiplicity_highPt_Forward->Fill(jet->chargedMultiplicity());
00977           if(mNeuMultiplicity_highPt_Forward)  mNeuMultiplicity_highPt_Forward->Fill(jet->neutralMultiplicity());
00978           if(mMuMultiplicity_highPt_Forward)  mMuMultiplicity_highPt_Forward->Fill(jet->muonMultiplicity());
00979           if(mHFHFracVSpT_Forward) mHFHFracVSpT_Forward->Fill(jet->pt(),jet->HFHadronEnergyFraction());
00980           if(mHFEFracVSpT_Forward) mHFEFracVSpT_Forward->Fill(jet->pt(),jet->HFEMEnergyFraction());
00981         }
00982         //if (mE) mE->Fill (jet->energy());
00983         //if (mP) mP->Fill (jet->p());
00984         //if (mMass) mMass->Fill (jet->mass());
00985             
00986         if (mChargedHadronEnergy)  mChargedHadronEnergy->Fill (jet->chargedHadronEnergy());
00987         if (mNeutralHadronEnergy)  mNeutralHadronEnergy->Fill (jet->neutralHadronEnergy());
00988         if (mChargedEmEnergy) mChargedEmEnergy->Fill(jet->chargedEmEnergy());
00989         if (mChargedMuEnergy) mChargedMuEnergy->Fill (jet->chargedMuEnergy ());
00990         if (mNeutralEmEnergy) mNeutralEmEnergy->Fill(jet->neutralEmEnergy());
00991         if (mChargedMultiplicity ) mChargedMultiplicity->Fill(jet->chargedMultiplicity());
00992         if (mNeutralMultiplicity ) mNeutralMultiplicity->Fill(jet->neutralMultiplicity());
00993         if (mMuonMultiplicity )mMuonMultiplicity->Fill (jet-> muonMultiplicity());
00994         //_______________________________________________________
00995         if (mNeutralFraction) mNeutralFraction->Fill (jet->neutralMultiplicity()/jet->nConstituents());
00996 
00997 
00998         // Fill NPV profiles
00999         //----------------------------------------------------------------------
01000         if (mPt_profile)           mPt_profile          ->Fill(numPV, jet->pt());
01001         if (mEta_profile)          mEta_profile         ->Fill(numPV, jet->eta());
01002         if (mPhi_profile)          mPhi_profile         ->Fill(numPV, jet->phi());
01003         if (mConstituents_profile) mConstituents_profile->Fill(numPV, jet->nConstituents());
01004         if (mHFrac_profile)        mHFrac_profile       ->Fill(numPV, jet->chargedHadronEnergyFraction() + jet->neutralHadronEnergyFraction());
01005         if (mEFrac_profile)        mEFrac_profile       ->Fill(numPV, jet->chargedEmEnergyFraction()     + jet->neutralEmEnergyFraction());
01006 
01007         if (mChargedHadronEnergy_profile) mChargedHadronEnergy_profile->Fill(numPV, jet->chargedHadronEnergy());
01008         if (mNeutralHadronEnergy_profile) mNeutralHadronEnergy_profile->Fill(numPV, jet->neutralHadronEnergy());
01009         if (mChargedEmEnergy_profile)     mChargedEmEnergy_profile    ->Fill(numPV, jet->chargedEmEnergy());
01010         if (mChargedMuEnergy_profile)     mChargedMuEnergy_profile    ->Fill(numPV, jet->chargedMuEnergy ());
01011         if (mNeutralEmEnergy_profile)     mNeutralEmEnergy_profile    ->Fill(numPV, jet->neutralEmEnergy());
01012         if (mChargedMultiplicity_profile) mChargedMultiplicity_profile->Fill(numPV, jet->chargedMultiplicity());
01013         if (mNeutralMultiplicity_profile) mNeutralMultiplicity_profile->Fill(numPV, jet->neutralMultiplicity());
01014         if (mMuonMultiplicity_profile)    mMuonMultiplicity_profile   ->Fill(numPV, jet->muonMultiplicity());
01015 
01016 
01017         //calculate correctly the dphi
01018         if(numofjets>1) {
01019           diff = fabs(fstPhi - sndPhi);
01020           corr = 2*acos(-1.) - diff;
01021           if(diff < acos(-1.)) { 
01022             dphi = diff; 
01023           } else { 
01024             dphi = corr;
01025           }
01026         } // numofjets>1
01027       } // JetPt>_ptThreshold
01028     } // PF jet loop
01029     if (mNJets)   mNJets->Fill (numofjets);
01030     if (mDPhi)    mDPhi->Fill (dphi);
01031 
01032 
01033     if (mNJets_profile) mNJets_profile->Fill(numPV, numofjets);
01034 
01035 
01036   } // non dijet selection
01037 }