ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Jeng/tools/plotXsec.C
Revision: 1.2
Committed: Fri Jan 7 21:54:06 2011 UTC (14 years, 3 months ago) by jengbou
Content type: text/plain
Branch: MAIN
CVS Tags: gregj-20110223, gregj-20110205, gregj-20110114, gregj-20110107
Changes since 1.1: +8 -8 lines
Log Message:
update and add files

File Contents

# Content
1 #include "TCanvas.h"
2 #include "TFile.h"
3 #include "TH1.h"
4 #include "TH2.h"
5 #include "TGraphAsymmErrors.h"
6 #include "TLatex.h"
7 #include "TLegend.h"
8 #include "TStyle.h"
9 #include "TLine.h"
10 #include "TBox.h"
11 #include "TMarker.h"
12 #include "TopStyle/tdrstyle.C"
13 #include "TopStyle/CMSTopStyle.cc"
14 #include <map>
15 #include <vector>
16 #include <sstream>
17 #include <iostream>
18
19 using namespace std;
20
21 bool overwriteAll = false;
22
23 void plotXsec() {
24 CMSTopStyle style;
25 setTDRStyle();
26 style.setupICHEPv1();
27 std::map<TString,TGraph*> gmap;
28 std::vector<TLatex*> tvect;
29
30 gStyle->SetPadTopMargin(0.08);
31 gStyle->SetPadLeftMargin(0.05);
32 //gStyle->SetMarkerStyle(24);
33 gStyle->SetTextFont(62);
34
35 TCanvas *c1 = new TCanvas("c1","x-sec summary",200,10,800,700);
36
37 int nbinsx_ = 35;
38 double xmin_ = 0., xmax_ = 350.;
39 double ymin_ = 0.5,ymax_ = 5.;
40
41 TH2 *hr = new TH2F("frame","",nbinsx_,xmin_,xmax_,1,ymin_,ymax_);
42 hr->GetXaxis()->CenterTitle(kTRUE);
43 hr->SetXTitle("#sigma (pp #rightarrow t#bar{t}) [pb]");
44 hr->GetXaxis()->SetTitleOffset(0.95);
45 //hr->SetYTitle("Experiments");
46 gPad->SetTicks(1,0);
47 hr->GetXaxis()->SetNdivisions(115);
48 hr->GetXaxis()->SetLabelSize(0.04);
49 //hr->GetYaxis()->SetNdivisions(101);
50 hr->GetYaxis()->SetBinLabel(1,"");
51 hr->Draw();
52
53 gmap["th_band"] = new TGraph(2);
54 gmap["th_band"]->SetFillColor(5);
55 gmap["th_band"]->SetFillStyle(3005);
56 gmap["th_band"]->SetLineColor(5);
57 gmap["th_band"]->SetMarkerStyle(24);
58 // gmap["th_band"]->SetLineWidth(3634);
59 // gmap["th_band"]->SetPoint(0,189.,0.5);
60 // gmap["th_band"]->SetPoint(1,189.,4.5);
61 // gmap["th_band"]->Draw("");
62
63 const Int_t np = 4;
64 Int_t iColor[np] = {1,2,9,4};
65 Int_t iMark [np] = {20,21,22,23};
66
67 Float_t nexp[np] = {1,2,3,4};
68 Float_t xsec[np] = {157.5,145.0,194.0,158.1}; // x-sec
69 Float_t stath[np] = { 0. , 31. , 72. , 12. }; // stat err high
70 Float_t statl[np] = { 0. , 31. , 72. , 12. }; // stat err low
71 Float_t systh[np] = { 23.2, 42. , 24. , 35. }; // syst err high
72 Float_t systl[np] = { 24.4, 27. , 24. , 35. }; // syst err low
73 Float_t lumi[np] = { 0. , 0. , 21. , 17. }; // lumi err
74
75 Float_t errh[np];
76 Float_t errl[np];
77 for (int i = 0; i < np; ++i) {
78 errh[i] = sqrt(stath[i]*stath[i] + systh[i]*systh[i]);
79 errl[i] = sqrt(statl[i]*statl[i] + systl[i]*systl[i]);
80 }
81 Float_t err0[np] = {0.,0.,0.,0.};
82
83 // Theory prediction
84 TBox* th_band = new TBox(157.5-24.4,ymin_ + 0.1,157.5+23.2,ymax_ - 0.1);
85 th_band->SetFillColor(5);
86 //th_band->SetFillStyle(3005);
87 th_band->Draw("same");
88
89 gPad->RedrawAxis();
90
91 gmap["Summary"] = new TGraphAsymmErrors(np,xsec,nexp,errl,errh,err0,err0);
92 //gmap["Summary"]->SetLineColor(kBlue);
93 gmap["Summary"]->SetLineWidth(2);
94 gmap["Summary"]->SetMarkerColor(kBlue);
95 gmap["Summary"]->SetMarkerSize(1.1);
96 // gmap["Summary"]->SetMarkerStyle(20);
97 gmap["Summary"]->Draw("sameP");
98 for (int i = 0; i < np; ++i) {
99 TMarker *m = new TMarker(xsec[i],nexp[i],iMark[i]);
100 m->SetMarkerSize(2);
101 m->SetMarkerColor(iColor[i]);
102 m->Draw();
103 }
104
105 TLatex *header0 = new TLatex(xmin_ + 10,ymax_+0.1,"CMS Preliminary"); //header->SetTextColor(1);
106 header0->SetTextSize(0.034);
107 header0->Draw();
108
109 TLatex *header1 = new TLatex(0.8*xmax_,ymax_+0.1,"December 2010"); //header->SetTextColor(1);
110 header1->SetTextSize(0.028);
111 header1->Draw();
112
113 tvect.push_back(new TLatex(xmin_+10,nexp[0]+0.1,"Theory (MCFM)"));
114 tvect.push_back(new TLatex(xmin_+10,nexp[1]+0.1,"ATLAS Combined (L = 3 pb^{-1})"));
115 tvect.push_back(new TLatex(xmin_+10,nexp[2]+0.1,"CMS Dilepton (L = 3 pb^{-1})"));
116 TLatex* myTxt0 = new TLatex(xmin_+10,nexp[3]+0.1,"CMS #mu+Jets (L = 36 pb^{-1})");
117 myTxt0->SetTextColor(iColor[3]);
118 tvect.push_back(myTxt0);
119
120 TString xsec_[np];
121 for (int i = 0; i < np; ++i){
122 std::ostringstream ss_[6];
123 ss_[0].precision(1); ss_[0].setf(ios::fixed,ios::floatfield);
124 ss_[0] << xsec[i];
125 xsec_[i] = ss_[0].str();
126 // Stat
127 if ( stath[i] > 0.) {
128 if (stath[i] == statl[i]) {
129 ss_[1] << stath[i];
130 xsec_[i] = xsec_[i] + " #pm " + ss_[1].str() + " (stat.)";
131 }
132 else {
133 ss_[1] << stath[i];
134 ss_[2] << statl[i];
135 xsec_[i] = xsec_[i] + " #splitline{+" + ss_[1].str() + "}{- " + ss_[2].str() + "} (stat.)";
136 }
137 }
138 // Syst
139 if ( systh[i] > 0.) {
140 if (systh[i] == systl[i]) {
141 ss_[3] << systh[i];
142 xsec_[i] = xsec_[i] + " #pm " + ss_[3].str() + " (syst.)";
143 }
144 else {
145 ss_[3] << systh[i];
146 ss_[4] << systl[i];
147 xsec_[i] = xsec_[i] + " #splitline{+" + ss_[3].str() + "}{- " + ss_[4].str() + "} (syst.)";
148 }
149 }
150 // Lumi
151 if ( lumi[i] > 0.) {
152 ss_[5] << lumi[i];
153 xsec_[i] = xsec_[i] + " #pm " + ss_[5].str() + " (lumi.)";
154 }
155 }
156
157 tvect.push_back(new TLatex((xmax_-xmin_)*0.6,nexp[0]+0.1,xsec_[0]));
158 tvect.push_back(new TLatex((xmax_-xmin_)*0.6,nexp[1]+0.1,xsec_[1]));
159 tvect.push_back(new TLatex((xmax_-xmin_)*0.6,nexp[2]+0.1,xsec_[2]));
160 TLatex *myTxt1 = new TLatex((xmax_-xmin_)*0.6,nexp[3]+0.1,xsec_[3]);
161 myTxt1->SetTextColor(iColor[3]);
162 tvect.push_back(myTxt1);
163
164 for (unsigned int i = 0; i < tvect.size(); i++) {
165 if (i < np) tvect[i]->SetX((xmax_-xmin_)*0.05);
166 tvect[i]->SetTextSize(0.024);
167 //tvect[i]->SetTextAlign(11);
168 tvect[i]->Draw();
169 }
170
171 TLegend *leg0 = new TLegend(0.6,0.82,0.9,0.9);
172 leg0->SetFillColor(0);
173 leg0->SetFillStyle(0);
174 // leg0->AddEntry(th_band,"MCFM (m_{top} = 172.5 GeV/c^{2})","f");
175 leg0->AddEntry(th_band,"MCFM","f");
176 leg0->Draw();
177
178 gPad->Update();
179
180 std::cout << "\nSave plots? (y/n)" << std::endl;
181 char incmd;
182 if (overwriteAll) incmd='y';
183 else cin.get(incmd);
184 if (incmd != 'y' && incmd != 'Y') return;
185
186 c1->SaveAs("Summary_Xsec_new.pdf");
187 c1->SaveAs("Summary_Xsec_new.png");
188
189 return;
190 }