CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoJets/JetAnalyzers/src/DijetMass.cc

Go to the documentation of this file.
00001 // DijetMass.cc
00002 // Description:  Some Basic validation plots for jets.
00003 // Author: Robert M. Harris
00004 // Date:  30 - August - 2006
00005 // Kalanand Mishra (November 22, 2009): 
00006 //          Modified and cleaned up to work in 3.3.X
00007 // 
00008 #include "RecoJets/JetAnalyzers/interface/DijetMass.h"
00009 
00010 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00011 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00012 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00013 #include "DataFormats/JetReco/interface/CaloJet.h"
00014 #include "DataFormats/JetReco/interface/PFJet.h"
00015 #include "DataFormats/JetReco/interface/GenJet.h"
00016 #include "DataFormats/Math/interface/deltaR.h"
00017 #include "FWCore/Framework/interface/Event.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 #include <TROOT.h>
00020 #include <TSystem.h>
00021 #include <TFile.h>
00022 #include <TCanvas.h>
00023 #include <cmath>
00024 using namespace edm;
00025 using namespace reco;
00026 using namespace std;
00027 
00028 
00029 template<class Jet>
00030 DijetMass<Jet>::DijetMass( const edm::ParameterSet & cfg ) {
00031   PtHistMax =  cfg.getUntrackedParameter<double>( "PtHistMax", 3000.0);
00032   EtaMax    = cfg.getUntrackedParameter<double> ("EtaMax", 1.3);  
00033   histogramFile    = cfg.getUntrackedParameter<std::string>("HistoFileName", 
00034                                                             "DijetMassHistos.root");
00035 
00036   AKJets =  cfg.getParameter<std::string> ("AKJets"); 
00037   AKCorJets =  cfg.getParameter<std::string> ("AKCorrectedJets"); 
00038   ICJets =  cfg.getParameter<std::string> ("ICJets"); 
00039   ICCorJets =  cfg.getParameter<std::string> ("ICCorrectedJets"); 
00040   SCJets =  cfg.getParameter<std::string> ("SCJets"); 
00041   SCCorJets =  cfg.getParameter<std::string> ("SCCorrectedJets"); 
00042   KTJets =  cfg.getParameter<std::string> ("KTJets"); 
00043   KTCorJets =  cfg.getParameter<std::string> ("KTCorrectedJets"); 
00044 }
00045 
00046 template<class Jet>
00047 void DijetMass<Jet>::beginJob(  ) {
00048   cout << "DijetMass: Maximum bin edge for Pt Hists = " << PtHistMax << endl;
00049   numJets=2;
00050 
00051   //Initialize some stuff
00052   evtCount = 0;
00053 
00054   // Open the histogram file and book some associated histograms
00055   m_file=new TFile( histogramFile.c_str(),"RECREATE" ); 
00056   
00057   //Simple histos
00058   
00059   //AK unc
00060   ptAKunc  = TH1F("ptAKunc","p_{T} of leading Jets (AK)",50,0.0,PtHistMax);
00061   etaAKunc = TH1F("etaAKunc","#eta of leading Jets (AK)",23,-1.0,1.0);
00062   phiAKunc = TH1F("phiAKunc","#phi of leading Jets (AK)",72,-M_PI, M_PI);
00063   m2jAKunc = TH1F("m2jAKunc","Dijet Mass of leading Jets (AK)",100,0.0,2*PtHistMax);
00064 
00065 
00066   //AK cor
00067   ptAKcor  = TH1F("ptAKcor","p_{T} of leading Corrected Jets (AK)",50,0.0,PtHistMax);
00068   etaAKcor = TH1F("etaAKcor","#eta of leading Corrected Jets (AK)",23,-1.0,1.0);
00069   phiAKcor = TH1F("phiAKcor","#phi of leading Corrected Jets (AK)",72,-M_PI, M_PI);
00070   m2jAKcor = TH1F("m2jAKcor","Dijet Mass of leading Corrected Jets (AK)",100,0.0,2*PtHistMax);
00071 
00072   //IC unc
00073   ptICunc  = TH1F("ptICunc","p_{T} of leading Jets (IC)",50,0.0,PtHistMax);
00074   etaICunc = TH1F("etaICunc","#eta of leading Jets (IC)",23,-1.0,1.0);
00075   phiICunc = TH1F("phiICunc","#phi of leading Jets (IC)",72,-M_PI, M_PI);
00076   m2jICunc = TH1F("m2jICunc","Dijet Mass of leading Jets (IC)",100,0.0,2*PtHistMax);
00077 
00078 
00079   //IC cor
00080   ptICcor  = TH1F("ptICcor","p_{T} of leading Corrected Jets (IC)",50,0.0,PtHistMax);
00081   etaICcor = TH1F("etaICcor","#eta of leading Corrected Jets (IC)",23,-1.0,1.0);
00082   phiICcor = TH1F("phiICcor","#phi of leading Corrected Jets (IC)",72,-M_PI, M_PI);
00083   m2jICcor = TH1F("m2jICcor","Dijet Mass of leading Corrected Jets (IC)",100,0.0,2*PtHistMax);
00084 
00085   //KT unc
00086   ptKTunc  = TH1F("ptKTunc","p_{T} of leading Jets (KT)",50,0.0,PtHistMax);
00087   etaKTunc = TH1F("etaKTunc","#eta of leading Jets (KT)",23,-1.0,1.0);
00088   phiKTunc = TH1F("phiKTunc","#phi of leading Jets (KT)",72,-M_PI, M_PI);
00089   m2jKTunc = TH1F("m2jKTunc","Dijet Mass of leading Jets (KT)",100,0.0,2*PtHistMax);
00090 
00091 
00092   //KT cor
00093   ptKTcor  = TH1F("ptKTcor","p_{T} of leading Corrected Jets (KT)",50,0.0,PtHistMax);
00094   etaKTcor = TH1F("etaKTcor","#eta of leading Corrected Jets (KT)",23,-1.0,1.0);
00095   phiKTcor = TH1F("phiKTcor","#phi of leading Corrected Jets (KT)",72,-M_PI, M_PI);
00096   m2jKTcor = TH1F("m2jKTcor","Dijet Mass of leading Corrected Jets (KT)",100,0.0,2*PtHistMax);
00097 
00098   //SC unc
00099   ptSCunc  = TH1F("ptSCunc","p_{T} of leading Jets (SC)",50,0.0,PtHistMax);
00100   etaSCunc = TH1F("etaSCunc","#eta of leading Jets (SC)",23,-1.0,1.0);
00101   phiSCunc = TH1F("phiSCunc","#phi of leading Jets (SC)",72,-M_PI, M_PI);
00102   m2jSCunc = TH1F("m2jSCunc","Dijet Mass of leading Jets (SC)",100,0.0,2*PtHistMax);
00103 
00104   //SC cor
00105   ptSCcor  = TH1F("ptSCcor","p_{T} of leading Corrected Jets (SC)",50,0.0,PtHistMax);
00106   etaSCcor = TH1F("etaSCcor","#eta of leading Corrected Jets (SC)",23,-1.0,1.0);
00107   phiSCcor = TH1F("phiSCcor","#phi of leading Corrected Jets (SC)",72,-M_PI, M_PI);
00108   m2jSCcor = TH1F("m2jSCcor","Dijet Mass of leading Corrected Jets (SC)",100,0.0,2*PtHistMax);
00109 
00110 }
00111 
00112 
00113 
00114 template<class Jet>
00115 void DijetMass<Jet>::analyze( const Event& evt, const EventSetup& es ) {
00116 
00117   evtCount++;
00118   math::XYZTLorentzVector p4jet[2];
00119   int jetInd;
00120   Handle<JetCollection> Jets;
00121 
00122 
00123   //Fill Simple Histos
00124   typename JetCollection::const_iterator i_jet;
00125 
00126   //AK unc
00127   evt.getByLabel( AKJets, Jets );
00128   jetInd = 0;
00129   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
00130     p4jet[jetInd] = i_jet->p4();
00131     jetInd++;
00132   }
00133   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00134      m2jAKunc.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00135      ptAKunc.Fill( p4jet[0].Pt() ); ptAKunc.Fill( p4jet[1].Pt() );  
00136      etaAKunc.Fill( p4jet[0].eta() ); etaAKunc.Fill( p4jet[1].eta() );  
00137      phiAKunc.Fill( p4jet[0].phi() ); phiAKunc.Fill( p4jet[1].phi() );  
00138    }
00139 
00140 
00141   //AK corrected
00142   evt.getByLabel( AKCorJets, Jets );
00143   jetInd = 0;
00144   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
00145     p4jet[jetInd] = i_jet->p4();
00146     jetInd++;
00147   }
00148   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00149      m2jAKcor.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00150      ptAKcor.Fill( p4jet[0].Pt() ); ptAKcor.Fill( p4jet[1].Pt() );  
00151      etaAKcor.Fill( p4jet[0].eta() ); etaAKcor.Fill( p4jet[1].eta() );  
00152      phiAKcor.Fill( p4jet[0].phi() ); phiAKcor.Fill( p4jet[1].phi() );  
00153    }
00154 
00155 
00156   //IC unc
00157   evt.getByLabel( ICJets, Jets );
00158   jetInd = 0;
00159   for(  i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
00160     p4jet[jetInd] = i_jet->p4();
00161     jetInd++;
00162   }
00163   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00164      m2jICunc.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00165      ptICunc.Fill( p4jet[0].Pt() ); ptICunc.Fill( p4jet[1].Pt() );  
00166      etaICunc.Fill( p4jet[0].eta() ); etaICunc.Fill( p4jet[1].eta() );  
00167      phiICunc.Fill( p4jet[0].phi() ); phiICunc.Fill( p4jet[1].phi() );  
00168    }
00169 
00170 
00171   //IC corrected
00172   evt.getByLabel( ICCorJets, Jets );
00173   jetInd = 0;
00174   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
00175     p4jet[jetInd] = i_jet->p4();
00176     jetInd++;
00177   }
00178   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00179      m2jICcor.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00180      ptICcor.Fill( p4jet[0].Pt() ); ptICcor.Fill( p4jet[1].Pt() );  
00181      etaICcor.Fill( p4jet[0].eta() ); etaICcor.Fill( p4jet[1].eta() );  
00182      phiICcor.Fill( p4jet[0].phi() ); phiICcor.Fill( p4jet[1].phi() );  
00183    }
00184 
00185   //KT unc
00186   evt.getByLabel( KTJets, Jets );
00187   jetInd = 0;
00188   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++ i_jet ) {
00189     p4jet[jetInd] = i_jet->p4();
00190     jetInd++;
00191   }
00192   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00193      m2jKTunc.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00194      ptKTunc.Fill( p4jet[0].Pt() ); ptKTunc.Fill( p4jet[1].Pt() );  
00195      etaKTunc.Fill( p4jet[0].eta() ); etaKTunc.Fill( p4jet[1].eta() );  
00196      phiKTunc.Fill( p4jet[0].phi() ); phiKTunc.Fill( p4jet[1].phi() );  
00197    }
00198 
00199 
00200   //KT corrected
00201   evt.getByLabel( KTCorJets, Jets );
00202   jetInd = 0;
00203   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet ) {
00204     p4jet[jetInd] = i_jet->p4();
00205     jetInd++;
00206   }
00207   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00208      m2jKTcor.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00209      ptKTcor.Fill( p4jet[0].Pt() ); ptKTcor.Fill( p4jet[1].Pt() );  
00210      etaKTcor.Fill( p4jet[0].eta() ); etaKTcor.Fill( p4jet[1].eta() );  
00211      phiKTcor.Fill( p4jet[0].phi() ); phiKTcor.Fill( p4jet[1].phi() );  
00212    }
00213 
00214 
00215   //SC unc
00216   evt.getByLabel( SCJets, Jets );
00217   jetInd = 0;
00218   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet  ) {
00219     p4jet[jetInd] = i_jet->p4();
00220     jetInd++;
00221   }
00222   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00223      m2jSCunc.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00224      ptSCunc.Fill( p4jet[0].Pt() ); ptSCunc.Fill( p4jet[1].Pt() );  
00225      etaSCunc.Fill( p4jet[0].eta() ); etaSCunc.Fill( p4jet[1].eta() );  
00226      phiSCunc.Fill( p4jet[0].phi() ); phiSCunc.Fill( p4jet[1].phi() );  
00227    }
00228 
00229 
00230   //SC corrected
00231   evt.getByLabel( SCCorJets, Jets );
00232   jetInd = 0;
00233   for( i_jet = Jets->begin(); i_jet != Jets->end() && jetInd<2; ++i_jet ) {
00234     p4jet[jetInd] = i_jet->p4();
00235     jetInd++;
00236   }
00237   if(jetInd==2&&abs(p4jet[0].eta())<EtaMax &&abs(p4jet[1].eta())<EtaMax ){
00238      m2jSCcor.Fill( (p4jet[0]+p4jet[1]).mass() ); 
00239      ptSCcor.Fill( p4jet[0].Pt() ); ptSCcor.Fill( p4jet[1].Pt() );  
00240      etaSCcor.Fill( p4jet[0].eta() ); etaSCcor.Fill( p4jet[1].eta() );  
00241      phiSCcor.Fill( p4jet[0].phi() ); phiSCcor.Fill( p4jet[1].phi() );  
00242    }
00243 
00244 }
00245 
00246 template<class Jet>
00247 void DijetMass<Jet>::endJob() {
00248 
00249   //Write out the histogram file.
00250   m_file->cd(); 
00251 
00252   ptAKunc.Write();
00253   etaAKunc.Write();
00254   phiAKunc.Write();
00255   m2jAKunc.Write();
00256 
00257   ptAKcor.Write();
00258   etaAKcor.Write();
00259   phiAKcor.Write();
00260   m2jAKcor.Write();
00261 
00262   ptICunc.Write();
00263   etaICunc.Write();
00264   phiICunc.Write();
00265   m2jICunc.Write();
00266 
00267 
00268   ptICcor.Write();
00269   etaICcor.Write();
00270   phiICcor.Write();
00271   m2jICcor.Write();
00272 
00273   ptKTunc.Write();
00274   etaKTunc.Write();
00275   phiKTunc.Write();
00276   m2jKTunc.Write();
00277 
00278 
00279   ptKTcor.Write();
00280   etaKTcor.Write();
00281   phiKTcor.Write();
00282   m2jKTcor.Write();
00283 
00284   ptSCunc.Write();
00285   etaSCunc.Write();
00286   phiSCunc.Write();
00287   m2jSCunc.Write();
00288 
00289   ptSCcor.Write();
00290   etaSCcor.Write();
00291   phiSCcor.Write();
00292   m2jSCcor.Write();
00293 
00294   m_file->Close(); 
00295 }
00296 #include "FWCore/Framework/interface/MakerMacros.h"
00298 typedef DijetMass<CaloJet> DijetMassCaloJets;
00299 DEFINE_FWK_MODULE(DijetMassCaloJets);
00301 typedef DijetMass<GenJet> DijetMassGenJets;
00302 DEFINE_FWK_MODULE(DijetMassGenJets);
00304 typedef DijetMass<PFJet> DijetMassPFJets;
00305 DEFINE_FWK_MODULE(DijetMassPFJets);