ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/drawTree.C
Revision: 1.1
Committed: Sat Jan 23 06:36:42 2010 UTC (15 years, 3 months ago) by jengbou
Content type: text/plain
Branch: MAIN
Log Message:
add file

File Contents

# User Rev Content
1 jengbou 1.1 void drawTree()
2     {
3     gROOT->SetStyle("CMS");
4    
5     TFile *f = new TFile("Run124023/LumiScan_Run124023LS039-096.root");
6     double x0 = 0.106379;
7     double y0 = 0.029332;
8    
9     TTree *t1 = (TTree*)f->Get("mytree");
10    
11     Double_t pt,d0,z0,phi0,eta,normchi2;
12     UInt_t nTotLayerMeas,nPixelLayerMeas;
13    
14     t1->SetBranchAddress("pt",&pt);
15     t1->SetBranchAddress("d0",&d0);
16     t1->SetBranchAddress("z0",&z0);
17     t1->SetBranchAddress("phi0",&phi0);
18     t1->SetBranchAddress("eta",&eta);
19     t1->SetBranchAddress("nTotLayerMeas",&nTotLayerMeas);
20     t1->SetBranchAddress("nPixelLayerMeas",&nPixelLayerMeas);
21     t1->SetBranchAddress("normchi2",&normchi2);
22    
23     //create one histogram
24     TH2D *hd0_phi = new TH2D("hd0_phi","d_{0} vs. #phi",32,-3.14,3.14,25,-0.3,0.5);
25    
26     Int_t nentries = (Int_t)t1->GetEntries();
27     for (Int_t i=0;i<nentries;i++) {
28     t1->GetEntry(i);
29     if (pt > 2.0
30     && nTotLayerMeas >= 6
31     // && nPixelLayerMeas >= 0
32     && normchi2 < 10.0
33     && fabs(d0) < 1.0
34     && fabs(eta) < 2.4
35     && fabs(z0) < 60
36     )
37     hd0_phi->Fill(phi0,d0);
38     }
39    
40     TF1 *f0 = new TF1("f0","[0]*sin(x-[1])",-3.14,3.14);
41     double amp = sqrt(x0*x0+y0*y0);
42     double ang = atan2(y0,x0);
43     f0->SetParameters(amp,ang);
44    
45     TCanvas *c1 = new TCanvas("c1","c1",756,600);
46     // hd0_phi->SetMarkerStyle(1);
47     // hd0_phi->SetMarkerSize(0.5);
48     hd0_phi->SetLineWidth(0.1);
49     hd0_phi->GetXaxis()->SetTitle("#phi [rad]");
50     hd0_phi->GetYaxis()->SetTitle("Impact Parameter [cm]");
51     hd0_phi->Draw("BOX");
52     f0->SetLineColor(4);
53     f0->Draw("sames");
54    
55     // TPaveText *ppt= new TPaveText(.35,.78,.7,.88,"NDC");
56     TPaveText *ppt= new TPaveText(.36,.68,.76,.82,"NDC");
57     ppt->AddText("CMS Preliminary 2009");
58     ppt->AddText("Run 124023 : #sqrt{s} = 900 GeV");
59     ppt->SetTextAlign(12);
60     ppt->SetTextFont(62);
61     ppt->SetTextSize(0.045);
62     ppt->SetBorderSize(0);
63     ppt->SetFillColor(0);
64     // ppt->SetFillStyle(0);
65     ppt->Draw();
66    
67     TLegend *l0 = new TLegend(0.38,0.54,0.58,0.66);
68     // TLegend *l0 = new TLegend(0.35,0.55,0.84,0.8);
69     l0->SetTextFont(62);
70     l0->SetFillColor(0);
71     // l0->SetFillStyle(0);
72     l0->AddEntry(hd0_phi," Data","f");
73     l0->AddEntry(f0," Fit","l");
74     l0->Draw();
75     // t1->SetMarkerColor(kRed);
76     // t1->Draw("d0:phi0","pt>1 && nTotLayerMeas>=6" && normchi2 < 10 && d0 < 1.0 && d0 > -1.0 && eta < 2.4 && eta > -2.4 && z0 < 60 && z0 > -60);
77     if (gROOT->IsBatch()) return;
78    
79     c1->Print("d0_phi.pdf");
80     }