ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/plotGenTopM_fwk.C
Revision: 1.1
Committed: Sun Feb 7 23:24:37 2010 UTC (15 years, 2 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
add file

File Contents

# Content
1 #include "DataFormats/FWLite/interface/Handle.h"
2 #include "DataFormats/FWLite/interface/Event.h"
3 #include "TFile.h"
4 #include "TH1.h"
5 #include "TCanvas.h"
6 #include "TLegend.h"
7 #include "TLorentzVector.h"
8
9 #if !defined(__CINT__) && !defined(__MAKECINT__)
10 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
11 #endif
12
13 using namespace std;
14
15 void plotGenTopM_fwk()
16 {
17 TFile *file = TFile::Open("/tmp/PatSkim_1.root");
18
19 fwlite::Event ev(file);
20 unsigned int nevents = 0;
21
22 TH1F *h1 = new TH1F("h1","h1",100,50,250);
23
24 TH1F *hmttbar = new TH1F("hmttbar","m_{ttbar}",70,100,800);
25 TH1F *hpTttbar = new TH1F("hpTttbar","p_{T}(ttbar)",70,0,800);
26
27 for (ev.toBegin(); !ev.atEnd(); ++ev) {
28 ++nevents;
29
30 fwlite::Handle<reco::GenParticleCollection> src;
31 src.getByLabel(ev, "genParticles");
32
33 TLorentzVector top;
34 TLorentzVector topbar;
35
36 for ( int ip=0; ip< src->size(); ++ip ) {
37 reco::GenParticle p = src->at(ip);
38 if ( abs( p.pdgId() ) == 6 )
39 h1->Fill( p.mass() );
40
41 if ( p.pdgId() == 6 )
42 top.SetPxPyPzE( p.px(), p.py(), p.pz(), p.energy() );
43
44 if ( p.pdgId() == -6 )
45 topbar.SetPxPyPzE( p.px(), p.py(), p.pz(), p.energy() );
46 }
47
48 hmttbar->Fill( (top + topbar).M() );
49 hpTttbar->Fill( (top+ topbar).Pt() );
50
51 // if (nevents > 1000) break;
52
53 }
54
55 TCanvas *cv = new TCanvas("cv","cv",700,700);
56 h1->Draw();
57
58 TCanvas *cv2 = new TCanvas("cv2","cv2",700,700);
59 hmttbar->Draw();
60
61 TCanvas *cv3 = new TCanvas("cv3","cv3",700,700);
62 hpTttbar->Draw();
63
64 }
65