CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/Physics/src/QcdHighPtDQM.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2010/01/04 14:46:10 $
00005  *  $Revision: 1.4 $
00006  *  \author S. Bolognesi, Eric - CERN
00007  */
00008 
00009 #include "DQM/Physics/src/QcdHighPtDQM.h"
00010 
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 
00016 #include "DQMServices/Core/interface/DQMStore.h"
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "FWCore/ServiceRegistry/interface/Service.h"
00019 
00020 #include "DataFormats/METReco/interface/CaloMET.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022 #include <vector>
00023 
00024 #include <string>
00025 #include <cmath>
00026 
00027 using namespace std;
00028 using namespace edm;
00029 using namespace reco;
00030 using namespace math;
00031 
00032 
00033 //Get Jets and MET (no MET plots yet pending converging w/JetMET group)
00034 
00035 QcdHighPtDQM::QcdHighPtDQM(const ParameterSet& iConfig): 
00036   jetLabel_(iConfig.getUntrackedParameter<edm::InputTag>("jetTag")),
00037   metLabel1_(iConfig.getUntrackedParameter<edm::InputTag>("metTag1")),  
00038   metLabel2_(iConfig.getUntrackedParameter<edm::InputTag>("metTag2")),  
00039   metLabel3_(iConfig.getUntrackedParameter<edm::InputTag>("metTag3")),  
00040   metLabel4_(iConfig.getUntrackedParameter<edm::InputTag>("metTag4"))
00041 {
00042 
00043 }
00044 
00045 QcdHighPtDQM::~QcdHighPtDQM() { 
00046   
00047 
00048 }
00049 
00050 
00051 void QcdHighPtDQM::beginJob() {
00052  
00053   theDbe = Service<DQMStore>().operator->();
00054 
00055   //Book MEs
00056  
00057   theDbe->setCurrentFolder("Physics/QcdHighPt");  
00058 
00059   MEcontainer_["dijet_mass"] = theDbe->book1D("dijet_mass", "dijet resonance invariant mass, barrel region", 100, 0, 1000);
00060   MEcontainer_["njets"] = theDbe->book1D("njets", "jet multiplicity", 10, 0, 10);
00061   MEcontainer_["etaphi"] = theDbe->book2D("etaphi", "eta/phi distribution", 83, -42, 42, 72, -M_PI, M_PI);
00062   MEcontainer_["njets30"] = theDbe->book1D("njets30", "jet multiplicity, pt > 30 GeV", 10, 0, 10);
00063 
00064   //book histograms for inclusive jet quantities
00065   MEcontainer_["inclusive_jet_pt"] = theDbe->book1D("inclusive_jet_pt", "inclusive jet Pt spectrum", 100, 0, 1000);
00066   MEcontainer_["inclusive_jet_pt_barrel"] = theDbe->book1D("inclusive_jet_pt_barrel", "inclusive jet Pt, eta < 1.3", 100, 0, 1000);
00067   MEcontainer_["inclusive_jet_pt_forward"] = theDbe->book1D("inclusive_jet_pt_forward", "inclusive jet Pt, 3.0 < eta < 5.0", 100, 0, 1000);
00068   MEcontainer_["inclusive_jet_pt_endcap"] = theDbe->book1D("inclusive_jet_pt_endcap", "inclusive jet Pt, 1.3 < eta < 3.0", 100, 0, 1000);
00069 
00070   //book histograms for leading jet quantities
00071   MEcontainer_["leading_jet_pt"] = theDbe->book1D("leading_jet_pt", "leading jet Pt", 100, 0, 1000);
00072   MEcontainer_["leading_jet_pt_barrel"] = theDbe->book1D("leading_jet_pt_barrel", "leading jet Pt, eta < 1.3", 100, 0, 1000);
00073   MEcontainer_["leading_jet_pt_forward"] = theDbe->book1D("leading_jet_pt_forward", "leading jet Pt, 3.0 < eta < 5.0", 100, 0, 1000);
00074   MEcontainer_["leading_jet_pt_endcap"] = theDbe->book1D("leading_jet_pt_endcap", "leading jet Pt, 1.3 < eta < 3.0", 100, 0, 1000);
00075 
00076   //book histograms for met over sum et and met over leading jet pt for various
00077   //flavors of MET
00078   MEcontainer_["movers_met"] = theDbe->book1D("movers_met", "MET over Sum ET for basic MET collection", 50, 0, 1);
00079   MEcontainer_["moverl_met"] = theDbe->book1D("moverl_met", "MET over leading jet Pt for basic MET collection", 50, 0, 2);
00080   
00081   MEcontainer_["movers_metho"] = theDbe->book1D("movers_metho", "MET over Sum ET for MET HO collection", 50, 0, 1);
00082   MEcontainer_["moverl_metho"] = theDbe->book1D("moverl_metho", "MET over leading jet Pt for MET HO collection", 50, 0, 2);
00083   
00084   MEcontainer_["movers_metnohf"] = theDbe->book1D("movers_metnohf", "MET over Sum ET for MET no HF collection", 50, 0, 1);
00085   MEcontainer_["moverl_metnohf"] = theDbe->book1D("moverl_metnohf", "MET over leading jet Pt for MET no HF collection", 50, 0, 2);
00086 
00087   MEcontainer_["movers_metnohfho"] = theDbe->book1D("movers_metnohfho", "MET over Sum ET for MET no HF HO collection", 50, 0, 1);
00088   MEcontainer_["moverl_metnohfho"] = theDbe->book1D("moverl_metnohfho", "MET over leading jet Pt for MET no HF HO collection", 50, 0, 2);
00089 
00090   //book histograms for EMF fraction for all jets and first 3 jets
00091   MEcontainer_["inclusive_jet_EMF"] = theDbe->book1D("inclusive_jet_EMF", "inclusive jet EMF", 50, -1, 1);
00092   MEcontainer_["leading_jet_EMF"] = theDbe->book1D("leading_jet_EMF", "leading jet EMF", 50, -1, 1);
00093   MEcontainer_["second_jet_EMF"] = theDbe->book1D("second_jet_EMF", "second jet EMF", 50, -1, 1);
00094   MEcontainer_["third_jet_EMF"] = theDbe->book1D("third_jet_EMF", "third jet EMF", 50, -1, 1);
00095   
00096 
00097 
00098 
00099 }
00100 
00101 void QcdHighPtDQM::endJob(void) {
00102 
00103 }
00104 
00105 // method to calculate MET over Sum ET from a particular MET collection
00106 float QcdHighPtDQM::movers(const CaloMETCollection &metcollection) {
00107 
00108   float metovers = 0;
00109   CaloMETCollection::const_iterator met_iter;
00110   for(met_iter = metcollection.begin(); met_iter!= metcollection.end(); ++met_iter)
00111     {
00112       float mex = met_iter->momentum().x();
00113       float mey = met_iter->momentum().y();
00114       float met = sqrt(mex*mex+mey*mey);
00115       float sumet = met_iter->sumEt();
00116       metovers = (met / sumet);
00117     }
00118   return metovers;
00119 }
00120 
00121 
00122 // method to calculate MET over Leading jet PT for a particular MET collection
00123 float QcdHighPtDQM::moverl(const CaloMETCollection &metcollection, float &ljpt) {
00124  float metoverl = 0;
00125  CaloMETCollection::const_iterator met_iter;
00126  for(met_iter = metcollection.begin(); met_iter!= metcollection.end(); ++met_iter)
00127    {
00128      float mex = met_iter->momentum().x();
00129      float mey = met_iter->momentum().y();
00130      float met = sqrt(mex*mex+mey*mey);
00131      metoverl = (met / ljpt);
00132    }
00133  return metoverl;
00134 }
00135 
00136 
00137 void QcdHighPtDQM::analyze(const Event& iEvent, const EventSetup& iSetup) {
00138   
00139   //Get Jets
00140   edm::Handle<CaloJetCollection> jetHandle;
00141   iEvent.getByLabel(jetLabel_,jetHandle);
00142   const CaloJetCollection & jets = *jetHandle;
00143   CaloJetCollection::const_iterator jet_iter;
00144 
00145   //Get MET collections
00146   edm::Handle<CaloMETCollection> metHandle;
00147   iEvent.getByLabel(metLabel1_, metHandle);
00148   const CaloMETCollection &met = *metHandle;
00149 
00150   edm::Handle<CaloMETCollection> metHOHandle;
00151   iEvent.getByLabel(metLabel2_, metHOHandle);
00152   const CaloMETCollection &metHO = *metHOHandle;
00153   
00154   edm::Handle<CaloMETCollection> metNoHFHandle;
00155   iEvent.getByLabel(metLabel3_, metNoHFHandle);
00156   const CaloMETCollection &metNoHF = *metNoHFHandle;
00157 
00158   edm::Handle<CaloMETCollection> metNoHFHOHandle;
00159   iEvent.getByLabel(metLabel4_, metNoHFHOHandle);
00160   const CaloMETCollection &metNoHFHO = *metNoHFHOHandle;
00161 
00162   //initialize leading jet value and jet multiplicity counter
00163   int njets = 0;
00164   int njets30 = 0;
00165   float leading_jetpt = 0;
00166   float leading_jeteta = 0;
00167 
00168   //initialize variables for picking out leading 2 barrel jets
00169   reco::CaloJet leadingbarreljet; 
00170   reco::CaloJet secondbarreljet;
00171   int nbarreljets = 0;
00172 
00173   //get bins in eta.  
00174   //Bins correspond to calotower regions.
00175 
00176   const float etabins[83] = {-5.191, -4.889, -4.716, -4.538, -4.363, -4.191, -4.013, -3.839, -3.664, -3.489, -3.314, -3.139, -2.964, -2.853, -2.650, -2.500, -2.322, -2.172, -2.043, -1.930, -1.830, -1.740, -1.653, -1.566, -1.479, -1.392, -1.305, -1.218, -1.131, -1.044, -.957, -.879, -.783, -.696, -.609, -.522, -.435, -.348, -.261, -.174, -.087, 0, .087, .174, .261, .348, .435, .522, .609, .696, .783, .879, .957, 1.044, 1.131, 1.218, 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 2.853, 2.964, 3.139, 3.314, 3.489, 3.664, 3.839, 4.013, 4.191, 4.363, 4.538, 4.889, 5.191};
00177 
00178   for(jet_iter = jets.begin(); jet_iter!= jets.end(); ++jet_iter){
00179     njets++;
00180   
00181     //get Jet stats
00182     float jet_pt = jet_iter->pt();
00183     float jet_eta = jet_iter->eta();
00184     float jet_phi = jet_iter->phi();
00185 
00186     //fill jet Pt and jet EMF
00187     MEcontainer_["inclusive_jet_pt"]->Fill(jet_pt);
00188     MEcontainer_["inclusive_jet_EMF"]->Fill(jet_iter->emEnergyFraction());
00189 
00190     // pick out up to the first 2 leading barrel jets
00191     // for use in calculating dijet mass in barrel region
00192     // also fill jet Pt histogram for barrel
00193 
00194     if(jet_eta <= 1.3){
00195       MEcontainer_["inclusive_jet_pt_barrel"]->Fill(jet_pt);
00196       if(nbarreljets == 0){
00197         leadingbarreljet = jets[(njets-1)];
00198         nbarreljets++;
00199       }
00200       else if(nbarreljets == 1){
00201         secondbarreljet = jets[(njets-1)];
00202         nbarreljets++;
00203       }
00204 
00205     }
00206 
00207     // fill jet Pt for endcap and forward regions
00208     else if(jet_eta <= 3.0 && jet_eta > 1.3){MEcontainer_["inclusive_jet_pt_endcap"]->Fill(jet_pt);}
00209 
00210     else if(jet_eta <= 5.0 && jet_eta > 3.0){MEcontainer_["inclusive_jet_pt_forward"]->Fill(jet_pt);}
00211 
00212 
00213     // count jet multiplicity for jets with Pt > 30
00214     if((jet_pt) > 30) njets30++;
00215 
00216     // check leading jet quantities
00217     if(jet_pt > leading_jetpt){
00218       leading_jetpt = jet_pt;
00219       leading_jeteta = jet_eta;
00220     }
00221 
00222     //fill eta-phi plot
00223     for (int eit = 0; eit < 81; eit++){
00224       for(int pit = 0; pit < 72; pit++){
00225         float low_eta = etabins[eit];
00226         float high_eta = etabins[eit+1];
00227         float low_phi = (-M_PI) + pit*(M_PI/36);
00228         float high_phi = low_phi + (M_PI/36);
00229         if(jet_eta > low_eta && jet_eta < high_eta && jet_phi > low_phi && jet_phi < high_phi){
00230           MEcontainer_["etaphi"]->Fill((eit - 41), jet_phi);}
00231 
00232 
00233       }
00234     }
00235   }
00236   
00237   // after iterating over all jets, fill leading jet quantity histograms 
00238   // and jet multiplicity histograms
00239 
00240   MEcontainer_["leading_jet_pt"]->Fill(leading_jetpt);
00241   
00242   if(leading_jeteta <= 1.3){MEcontainer_["leading_jet_pt_barrel"]->Fill(leading_jetpt);}
00243 
00244   else if(leading_jeteta <= 3.0 && leading_jeteta > 1.3){MEcontainer_["leading_jet_pt_endcap"]->Fill(leading_jetpt);}
00245 
00246   else if(leading_jeteta <= 5.0 && leading_jeteta > 3.0){MEcontainer_["leading_jet_pt_forward"]->Fill(leading_jetpt);}
00247 
00248   MEcontainer_["njets"]->Fill(njets);
00249 
00250   MEcontainer_["njets30"]->Fill(njets30);
00251 
00252   // fill MET over Sum ET and Leading jet PT for all MET flavors
00253   MEcontainer_["movers_met"]->Fill(movers(met));
00254   MEcontainer_["moverl_met"]->Fill(movers(met), leading_jetpt);
00255   MEcontainer_["movers_metho"]->Fill(movers(metHO));
00256   MEcontainer_["moverl_metho"]->Fill(movers(metHO), leading_jetpt);
00257   MEcontainer_["movers_metnohf"]->Fill(movers(metNoHF));
00258   MEcontainer_["moverl_metnohf"]->Fill(movers(metNoHF), leading_jetpt);
00259   MEcontainer_["movers_metnohfho"]->Fill(movers(metNoHFHO));
00260   MEcontainer_["moverl_metnohfho"]->Fill(movers(metNoHFHO), leading_jetpt);
00261   
00262 
00263   // fetch first 3 jet EMF
00264 
00265   if(jets.size() >= 1){
00266     MEcontainer_["leading_jet_EMF"]->Fill(jets[0].emEnergyFraction());
00267     if(jets.size() >=2){
00268       MEcontainer_["second_jet_EMF"]->Fill(jets[1].emEnergyFraction());    
00269       if(jets.size() >= 3){
00270         MEcontainer_["third_jet_EMF"]->Fill(jets[2].emEnergyFraction());
00271       }
00272     }
00273   }
00274 
00275   // if 2 nontrivial barrel jets, reconstruct dijet mass
00276 
00277   if(nbarreljets == 2){
00278     if(leadingbarreljet.energy() > 0 && secondbarreljet.energy() > 0){
00279       math::XYZTLorentzVector DiJet = leadingbarreljet.p4() + secondbarreljet.p4();
00280       float dijet_mass = DiJet.mass();
00281         MEcontainer_["dijet_mass"]->Fill(dijet_mass);
00282     }
00283   }
00284       
00285     
00286 }
00287 
00288 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299