ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/scripts/drawTree.C
Revision: 1.2
Committed: Tue Feb 16 04:50:16 2010 UTC (15 years, 2 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +54 -9 lines
Error occurred while calculating annotation data.
Log Message:
update

File Contents

# Content
1 void drawTree()
2 {
3 gROOT->SetStyle("CMS");
4
5 TFile *f = new TFile("Run124023/LumiScan_Run124023LS038-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,d0bs,z0,phi0,eta,normchi2;
12 UInt_t nTotLayerMeas,nPixelLayerMeas;
13
14 t1->SetBranchAddress("pt",&pt);
15 t1->SetBranchAddress("d0",&d0);
16 t1->SetBranchAddress("d0bs",&d0bs);
17 t1->SetBranchAddress("z0",&z0);
18 t1->SetBranchAddress("phi0",&phi0);
19 t1->SetBranchAddress("eta",&eta);
20 t1->SetBranchAddress("nTotLayerMeas",&nTotLayerMeas);
21 t1->SetBranchAddress("nPixelLayerMeas",&nPixelLayerMeas);
22 t1->SetBranchAddress("normchi2",&normchi2);
23
24 //create one histogram
25 TH2D *hd0_phi = new TH2D("hd0_phi","d_{0} vs. #phi",32,-3.14,3.14,40,-0.3,0.5);
26 TH2D *hd0bs_phi = new TH2D("hd0bs_phi","d_{0}(BS) vs. #phi",32,-3.14,3.14,50,-0.5,0.5);
27
28 Int_t nentries = (Int_t)t1->GetEntries();
29 for (Int_t i=0;i<nentries;i++) {
30 t1->GetEntry(i);
31 if (pt > 2.
32 && nTotLayerMeas >= 6
33 // && nPixelLayerMeas >= 0
34 && normchi2 < 10.0
35 && fabs(d0) < 1.0
36 && fabs(eta) < 2.4
37 && fabs(z0) < 60
38 ){
39 hd0_phi->Fill(phi0,d0);
40 hd0bs_phi->Fill(phi0,d0bs);
41 }
42 }
43
44 TF1 *f0 = new TF1("f0","[0]*sin(x-[1])",-3.14,3.14);
45 double amp = sqrt(x0*x0+y0*y0);
46 double ang = atan2(y0,x0);
47 f0->SetParameters(amp,ang);
48
49 TF1 *f1 = new TF1("f1","p0",-3.14,3.14);
50 f1->SetParameter(1,hd0bs_phi->GetMean());
51 // cout << "hd0_phi mean=" << hd0_phi->GetMean()<<endl;
52 // cout << "hd0bs_phi mean=" << hd0bs_phi->GetMean()<<endl;
53
54 TCanvas *c1 = new TCanvas("c1","c1",756,600);
55 // hd0_phi->SetMarkerStyle(1);
56 // hd0_phi->SetMarkerSize(0.5);
57 hd0_phi->SetLineWidth(0.1);
58 hd0_phi->GetXaxis()->SetTitle("#phi [rad]");
59 hd0_phi->GetYaxis()->SetTitle("Impact Parameter [cm]");
60 hd0_phi->Draw("BOX");
61 f0->SetLineColor(4);
62 f0->Draw("sames");
63
64 // TPaveText *ppt= new TPaveText(.35,.78,.7,.88,"NDC");
65 TPaveText *ppt= new TPaveText(.36,.68,.76,.82,"NDC");
66 ppt->AddText("CMS Preliminary 2009");
67 ppt->AddText("Run 124023 : #sqrt{s} = 900 GeV");
68 ppt->SetTextAlign(12);
69 ppt->SetTextFont(62);
70 ppt->SetTextSize(0.045);
71 ppt->SetBorderSize(0);
72 ppt->SetFillColor(0);
73 // ppt->SetFillStyle(0);
74 ppt->Draw();
75
76 TLegend *l0 = new TLegend(0.24,0.54,0.58,0.66);
77 // TLegend *l0 = new TLegend(0.35,0.55,0.84,0.8);
78 l0->SetTextFont(62);
79 l0->SetFillColor(0);
80 // l0->SetFillStyle(0);
81 l0->AddEntry(hd0_phi," Data","f");
82 l0->AddEntry(f0," Beam Fit: x_{0}=1.064, y_{0}=0.293 [mm]","l");
83 l0->Draw();
84 // t1->SetMarkerColor(kRed);
85 // 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);
86
87 c1->Print("d0_phi.pdf");
88
89
90 TCanvas *c2 = new TCanvas("c2","c2",756,600);
91 // hd0bs_phi->SetMarkerStyle(1);
92 // hd0bs_phi->SetMarkerSize(0.8);
93 hd0bs_phi->SetLineWidth(0.1);
94 hd0bs_phi->GetXaxis()->SetTitle("#phi [rad]");
95 hd0bs_phi->GetYaxis()->SetTitle("Impact Parameter [cm]");
96 hd0bs_phi->Draw("BOX");
97 // hd0bs_phi->Draw();
98 f1->SetLineColor(4);
99 f1->Draw("sames");
100
101 TPaveText *ppt= new TPaveText(.35,.78,.7,.88,"NDC");
102 TPaveText *ppt1= new TPaveText(.36,.68,.76,.82,"NDC");
103 ppt1->AddText("CMS Preliminary 2009");
104 ppt1->AddText("Run 124023 : #sqrt{s} = 900 GeV");
105 ppt1->SetTextAlign(12);
106 ppt1->SetTextFont(62);
107 ppt1->SetTextSize(0.045);
108 ppt1->SetBorderSize(0);
109 ppt1->SetFillColor(0);
110 // ppt1->SetFillStyle(0);
111 ppt1->Draw();
112
113 TLegend *l1 = new TLegend(0.24,0.54,0.58,0.66);
114 l1->SetTextFont(62);
115 l1->SetFillColor(0);
116 // l1->SetFillStyle(0);
117 l1->AddEntry(hd0bs_phi," Data (d_{0} w.r.t. Beam Spot)","f");
118 // l1->AddEntry(f1," Line","l");
119 l1->Draw();
120
121 if (gROOT->IsBatch()) return;
122
123 c2->Print("d0bs_phi.pdf");
124
125 }