CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoJets/JetAnalyzers/interface/DijetRatio.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DijetRatio
00004 // Class:      DijetRatio
00005 // 
00013 //
00014 // Original Author:  Manoj Jha
00015 //         Created:  Thu Apr 12 15:04:37 CDT 2007
00016 // Kalanand Mishra (November 22, 2009): 
00017 //        Modified and cleaned up to work in 3.3.X
00018 //
00019 //
00020 
00021 // system include files
00022 #ifndef DIJETRATIO_HH
00023 #define DIJETRATIO_HH
00024 
00025 #include <memory>
00026 #include <string>
00027 #include <iostream>
00028 #include <map>
00029 #include <algorithm>
00030 
00031 // user include files
00032 #include "FWCore/Framework/interface/Frameworkfwd.h"
00033 #include "FWCore/Framework/interface/EDAnalyzer.h"
00034 #include "FWCore/Framework/interface/Event.h"
00035 #include "FWCore/Framework/interface/MakerMacros.h"
00036 
00037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00038 #include "DataFormats/Common/interface/Ref.h"
00039 #include "DataFormats/JetReco/interface/Jet.h"
00040 #include "DataFormats/TrackReco/interface/Track.h"
00041 
00042 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00043 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00044 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00045 #include "DataFormats/JetReco/interface/CaloJet.h"
00046 #include "DataFormats/JetReco/interface/PFJet.h"
00047 #include "DataFormats/JetReco/interface/GenJet.h"
00048 #include "CLHEP/Vector/LorentzVector.h"
00049 
00050 #include "TFile.h"
00051 #include "TH1.h"
00052 #include "TH2.h"
00053 
00054 const int histoSize = 5;
00055 
00056 //Histo Initializations
00057 inline void hInit(TH1F* hJet[], const char* name){
00058   int const binSize = 35;
00059   float massBin[binSize+1] = { 100, 113, 132, 153, 176, 201, 
00060                                229, 259, 292, 327, 366, 400, 
00061                                453, 501, 553, 609, 669, 733, 
00062                                802, 875, 954, 1038, 1127, 1222, 
00063                                1323, 1431, 1546, 1667, 1796, 1934,
00064                                2079, 2233, 2396, 2569, 2752,3000};
00065 
00066 
00067   // (jetEta1 > 0 && jetEta1 < 0.7),  (jetEta2 > 0 && jetEta2 < 0.7 )
00068   std::string tit = std::string(name) + "_Eta_innerEtaCut_outerEtaCut";
00069   hJet[0] =  new TH1F(tit.c_str(), "DiJet Mass", binSize, massBin);     
00070 
00071 
00072   // (jetEta1 > 0.7 && jetEta1 < 1.3),  (jetEta2 > 0.7 && jetEta2 < 1.3 )
00073   tit = std::string(name) + "_Eta_0_innerEtaCut";
00074   hJet[1] =  new TH1F(tit.c_str(), "DiJet Mass", binSize, massBin);             
00075 
00076   tit = std::string(name) + "_LeadJetEta";
00077   hJet[2] =  new TH1F(tit.c_str(), "1^{st} Leading Jet #eta", 120, -6., 6.);
00078   tit = std::string(name) + "_SecondJetEta";
00079   hJet[3] =  new TH1F(tit.c_str(), "2^{nd} Leading Jet #eta", 120, -6., 6.);
00080   tit = std::string(name) + "_numEvents";
00081   hJet[4] =  new TH1F(tit.c_str(), "No. of events", 10, 0.,10.);
00082    
00083   return ;
00084 }
00085 
00086 
00087 
00088 template <class R>
00089 void histoFill(TH1F* jetHisto[], edm::Handle<R> jetsRec, double eta1, double eta2)
00090 {
00091   //For no. of events
00092   jetHisto[4]->Fill(1.);
00093 
00094   if ((*jetsRec).size() >=2){
00095     double px1 = (*jetsRec)[0].px(); 
00096     double py1 = (*jetsRec)[0].py(); 
00097     double pz1 = (*jetsRec)[0].pz(); 
00098     double e1 = (*jetsRec)[0].energy(); 
00099     double jetEta1 = (*jetsRec)[0].eta(); 
00100     jetHisto[2]->Fill(jetEta1);
00101            
00102     double px2 = (*jetsRec)[1].px(); 
00103     double py2 = (*jetsRec)[1].py(); 
00104     double pz2 = (*jetsRec)[1].pz(); 
00105     double e2 = (*jetsRec)[1].energy(); 
00106     double jetEta2 = (*jetsRec)[1].eta();
00107     jetHisto[3]->Fill(jetEta2);
00108 
00109     CLHEP::HepLorentzVector v1(px1,py1,pz1,e1);    
00110     CLHEP::HepLorentzVector v2(px2,py2,pz2,e2);    
00111     CLHEP::HepLorentzVector v(0.,0.,0.,0.);        
00112     v = v1 + v2; 
00113     float mass = v.m();
00114 
00115     if ( fabs(jetEta1) > 0.0 &&  fabs(jetEta1) < eta1) 
00116       if ( fabs(jetEta2) > 0.0 &&  fabs(jetEta2) < eta1) 
00117         jetHisto[0]->Fill(mass);
00118            
00119     if ( fabs(jetEta1) > eta1 && fabs(jetEta1) < eta2) 
00120       if ( fabs(jetEta2) > eta1 && fabs(jetEta2) < eta2)
00121         jetHisto[1]->Fill(mass);
00122           
00123   }
00124 }//histoFill
00125 
00126 
00127 //
00128 // class decleration
00129 //
00130 template<class Jet>
00131 class DijetRatio : public edm::EDAnalyzer {
00132 public:
00133   explicit DijetRatio(const edm::ParameterSet&);
00134   ~DijetRatio();
00135 
00136 
00137   typedef std::vector<Jet> JetCollection;
00138   virtual void beginJob() ;
00139   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00140   virtual void endJob() ;
00141 
00142 
00143   // ----------member data ---------------------------
00144   std::string fOutputFileName ;
00145      
00146   // names of modules, producing object collections
00147   std::string m_Mid5CorRecJetsSrc;
00148   std::string m_Mid5CaloJetsSrc;
00149 
00150   // eta limit 
00151   double  m_eta3;  // eta limit for numerator
00152   double  m_eta4;  // eta limit for denominator
00153   
00154   //Jet Kinematics for leading Jet
00155   static  const int hisotNumber = 10;
00156   
00157   TH1F*  hCalo[hisotNumber];
00158   TH1F*  hCor[hisotNumber];
00159      
00160   // Root file for saving histo
00161   TFile*      hOutputFile ;
00162 };
00163 
00164 #endif
00165