CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/TopQuarkAnalysis/Examples/plugins/TopGenEventAnalyzer.cc

Go to the documentation of this file.
00001 #include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"
00002 #include "TopQuarkAnalysis/Examples/plugins/TopGenEventAnalyzer.h"
00003  
00004 TopGenEventAnalyzer::TopGenEventAnalyzer(const edm::ParameterSet& cfg):
00005   inputGenEvent_(cfg.getParameter<edm::InputTag>("genEvent"))
00006 { 
00007   edm::Service<TFileService> fs;
00008   nLep_      = fs->make<TH1F>("nLep",      "N(Lepton)",     5,   0.,   5.);
00009   topPt_     = fs->make<TH1F>("topPt",     "pt (top)",    100,   0., 500.);
00010   topEta_    = fs->make<TH1F>("topEta",    "eta(top)",     40,  -5.,   5.);
00011   topPhi_    = fs->make<TH1F>("topPhi",    "phi(top)",     60, -3.5,  3.5);
00012   topBarPt_  = fs->make<TH1F>("topBarPt",  "pt (topBar)", 100,   0., 500.);
00013   topBarEta_ = fs->make<TH1F>("topBarEta", "eta(topBar)",  40,  -5.,   5.);
00014   topBarPhi_ = fs->make<TH1F>("topBarPhi", "phi(topBar)",  60, -3.5,  3.5);
00015   ttbarPt_   = fs->make<TH1F>("ttbarPt",   "pt (ttbar)",  100,   0., 500.);
00016   ttbarEta_  = fs->make<TH1F>("ttbarEta",  "eta(ttbar)",   40,  -5.,   5.);
00017   ttbarPhi_  = fs->make<TH1F>("ttbarPhi",  "phi(ttbar)",   60, -3.5,  3.5);
00018   prodChan_  = fs->make<TH1F>("prodChan",  "production mode", 3, 0, 3);
00019   prodChan_->GetXaxis()->SetBinLabel(1, "gg"   );
00020   prodChan_->GetXaxis()->SetBinLabel(2, "qqbar");
00021   prodChan_->GetXaxis()->SetBinLabel(3, "other");
00022 }
00023 
00024 TopGenEventAnalyzer::~TopGenEventAnalyzer()
00025 {
00026 }
00027 
00028 void
00029 TopGenEventAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& setup)
00030 {
00031   edm::Handle<TtGenEvent> genEvent;
00032   evt.getByLabel(inputGenEvent_, genEvent);
00033 
00034   if(!genEvent->isTtBar())
00035     return;
00036 
00037   if(genEvent->fromGluonFusion())
00038     prodChan_->Fill("gg", 1);
00039   else if(genEvent->fromQuarkAnnihilation())
00040     prodChan_->Fill("qqbar", 1);
00041   else
00042     prodChan_->Fill("other", 1);
00043 
00044   // fill BR's
00045   nLep_  ->Fill(genEvent->numberOfLeptons());
00046 
00047   //fill top kinematic
00048   topPt_    ->Fill(genEvent->top   ()->pt ());
00049   topEta_   ->Fill(genEvent->top   ()->eta());
00050   topPhi_   ->Fill(genEvent->top   ()->phi());
00051   topBarPt_ ->Fill(genEvent->topBar()->pt ());
00052   topBarEta_->Fill(genEvent->topBar()->eta());
00053   topBarPhi_->Fill(genEvent->topBar()->phi());
00054 
00055   //fill ttbar kinematics
00056   ttbarPt_ ->Fill(genEvent->topPair()->pt() );
00057   ttbarEta_->Fill(genEvent->topPair()->eta());
00058   ttbarPhi_->Fill(genEvent->topPair()->phi());
00059 }
00060 
00061 void TopGenEventAnalyzer::beginJob()
00062 {  
00063 } 
00064 
00065 void TopGenEventAnalyzer::endJob()
00066 {
00067 }