CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
draw_txt.cxx
Go to the documentation of this file.
1/*
2 this script is used to draw graph with data from file
3*/
4#include <fstream>
5#include <iostream>
6#include <cmath>
7using namespace std;
8
10{
11 const int nfile = 5;
12 double momentum[nfile] = {150, 200, 300, 500, 1000};
13 double sigma[nfile][25] = {0};
14 double error[nfile][25] = {0};
15
16 int l(0),i,file,last(-1);
17 double s(0),e(0);
18 string strcom;
19 ifstream fin("log",ios::in);
20 //std::getline(fin, strcom);
21 //fin >> l >> s >> e;
22 //cout<<l<<" "<<s<<" "<<e<<endl;
23 while(std::getline(fin, strcom)){
24 fin >> l >> s >> e;
25 if(l == last)continue;
26 if(l==0)i=0;
27 sigma[file][i] = s;
28 error[file][i] = e;
29 //cout<<l<<" "<<s<<" "<<e<<endl;
30 //cout<<i<<" "<<sigma[file][i]<<" "<<error[file][i]<<endl;
31 i++;
32 if(l==24)file++;
33 last = l;
34 //cout<<l<<" "<<s<<" "<<e<<endl;
35 }
36///*
37 stringstream ssname;
38 string sname;
39 const char * name;
40 TAxis *x_axis,*y_axis;
41 TGraphErrors *gr_sigma_pt;
42 TCanvas *c_pt = new TCanvas("sigma_pt","sigma_pt",2500,2500 );
43 c_pt->Divide(5,5);
44 for(int i=0;i<25;i++){
45 TGraphErrors *gr_sigma_pt = new TGraphErrors();
46 for(int file=0;file<nfile;file++){
47 //cout<<i<<" "<<sigma[file][i]<<" "<<error[file][i]<<endl;
48 gr_sigma_pt->SetPoint(file,momentum[file],sigma[file][i]);
49 gr_sigma_pt->SetPointError(file,0,error[file][i]);
50 }
51 c_pt->cd(i+1);
52 gr_sigma_pt->Draw("APLsame");
53 gr_sigma_pt->SetMarkerStyle(20);
54 gr_sigma_pt->SetMarkerSize(1.0);
55 gr_sigma_pt->SetMarkerColor(3);
56 gr_sigma_pt->SetLineColor(3);
57 x_axis = gr_sigma_pt->GetXaxis();
58 y_axis = gr_sigma_pt->GetYaxis();
59 x_axis->SetTitle("transverse momentum (MeV)");
60 x_axis->CenterTitle();
61 x_axis->SetTitleSize(0.05);
62 x_axis->SetLabelSize(0.04);
63 x_axis->SetTitleOffset(1.05);
64 y_axis->SetTitle("#sigma (cm)");
65 y_axis->CenterTitle();
66 y_axis->SetTitleSize(0.05);
67 y_axis->SetLabelSize(0.04);
68 //y_axis->SetTitleOffset(1.05);
69 ssname.str("");
70 if(i<3){ssname <<"layer"<<i+1;}
71 else if(i<15){ssname <<"layer"<<i+6;}
72 else if(i<22){ssname <<"layer"<<i+22;}
73 else if(i==22){ssname <<"1~3layer";}
74 else if(i==23){ssname <<"9~20layer";}
75 else if(i==24){ssname <<"37~43layer";}
76 //if(l<=3){ssname <<"layer "<<l;cut=1;}
77 //else if(l<=15){ssname <<"layer "<<l+5;cut=1;}
78 //else if(l<=22){ssname <<"layer "<<l+21;cut=1;}
79 //else if(l==23){ssname <<"1~3 layer";cut=1;}
80 //else if(l==24){ssname <<"9~20 layer";cut=1;}
81 //else if(l==25){ssname <<"37~43 layer";cut=1;}
82 sname = ssname.str();
83 name = sname.c_str();
84 gr_sigma_pt->SetTitle(name);
85 }
86 c_pt->SaveAs("sigma_pt.png");
87 c_pt->SaveAs("sigma_pt.pdf");
88 c_pt->SaveAs("sigma_pt.eps");
89 TCanvas *c_pt_layer = new TCanvas("sigma_pt_layer","sigma_pt_layer",1000,1000 );
90 TLegend* leg = new TLegend(0.30,0.60,0.60,0.88);
91 for(int file=0;file<nfile;file++){
92 TGraphErrors *gr_sigma_pt_layer = new TGraphErrors();
93 for(int i=0;i<22;i++){
94 int layer;
95 if(i<3){layer = i+1;}
96 else if(i<15){layer = i+6;}
97 else if(i<22){layer = i+22;}
98 //cout<<i<<" "<<layer<<" "<<sigma[file][i]<<endl;
99 gr_sigma_pt_layer->SetPoint(i,layer,sigma[file][i]);
100 gr_sigma_pt_layer->SetPointError(i,0,error[file][i]);
101 }
102 if(file==0)gr_sigma_pt_layer->Draw("APLsame");
103 else gr_sigma_pt_layer->Draw("PLsame");
104 gr_sigma_pt_layer->SetMarkerStyle(20);
105 gr_sigma_pt_layer->SetMarkerSize(1.0);
106 gr_sigma_pt_layer->SetMarkerColor(file+1);
107 gr_sigma_pt_layer->SetLineColor(file+1);
108 x_axis = gr_sigma_pt_layer->GetXaxis();
109 y_axis = gr_sigma_pt_layer->GetYaxis();
110 x_axis->SetTitle("layer");
111 x_axis->CenterTitle();
112 x_axis->SetTitleSize(0.05);
113 x_axis->SetLabelSize(0.04);
114 x_axis->SetTitleOffset(1.05);
115 y_axis->SetTitle("#sigma (cm)");
116 y_axis->CenterTitle();
117 y_axis->SetTitleSize(0.05);
118 y_axis->SetLabelSize(0.04);
119 //y_axis->SetTitleOffset(1.05);
120 //ssname.str("");
121 //if(i<3){ssname <<"layer"<<i+1;}
122 //else if(i<15){ssname <<"layer"<<i+6;}
123 //else if(i<22){ssname <<"layer"<<i+22;}
124 //else if(i==22){ssname <<"1~3layer";}
125 //else if(i==23){ssname <<"9~20layer";}
126 //else if(i==24){ssname <<"37~43layer";}
127 //if(l<=3){ssname <<"layer "<<l;cut=1;}
128 //else if(l<=15){ssname <<"layer "<<l+5;cut=1;}
129 //else if(l<=22){ssname <<"layer "<<l+21;cut=1;}
130 //else if(l==23){ssname <<"1~3 layer";cut=1;}
131 //else if(l==24){ssname <<"9~20 layer";cut=1;}
132 //else if(l==25){ssname <<"37~43 layer";cut=1;}
133 //sname = ssname.str();
134 //name = sname.c_str();
135 ssname.str("");
136 ssname <<momentum[file]<<"MeV";
137 sname = ssname.str();
138 name = sname.c_str();
139 gr_sigma_pt_layer->SetTitle("sigma_layer");
140 leg->AddEntry(gr_sigma_pt_layer,name,"pl");
141
142 }
143 leg->Draw();
144 leg->SetFillColor(kWhite);
145 leg->SetLineColor(kWhite);
146 c_pt_layer->SaveAs("sigma_pt_layer.png");
147 c_pt_layer->SaveAs("sigma_pt_layer.pdf");
148 c_pt_layer->SaveAs("sigma_pt_layer.eps");
149//*/
150}
151/*
152int draw_txt()
153{
154 const int nfile = 5;
155 const char *file[nfile] = {
156 "/root/test/hough150MeV/points/1point_per_bin/peak_rate",
157 "/root/test/hough150MeV/points/5point_per_bin/peak_rate",
158 "/root/test/hough150MeV/points/10point_per_bin/peak_rate",
159 "/root/test/hough150MeV/points/20point_per_bin/peak_rate",
160 "/root/test/hough150MeV/points/50point_per_bin/peak_rate"
161 };
162
163 int point[nfile] = {1,5,10,20,50};
164 stringstream ssname;
165 string sname;
166 const char * name;
167 TAxis *x_axis,*y_axis;
168 TCanvas *c_pt_layer = new TCanvas("bin_height","bin_height",1000,1000 );
169 TLegend* leg = new TLegend(0.60,0.60,0.88,0.88);
170 for(int ff =0;ff<nfile;ff++){
171 //for(int ff =0;ff<1;ff++){
172 TGraphErrors *gr_bin_height = new TGraphErrors();
173 int bin,last,i(0);
174 double height,err;
175 string strcom;
176 ifstream fin(file[ff],ios::in);
177 std::getline(fin, strcom);
178 std::getline(fin, strcom);
179 //fin >> bin >> height >> err;
180 while(std::getline(fin, strcom)){
181 fin >> bin >> height >> err;
182 if(bin == last)continue;
183 cout<<bin<<" "<<height<<" "<<err<<endl;
184 gr_bin_height->SetPoint(i,bin,height);
185 gr_bin_height->SetPointError(i,0,err);
186 last = bin;
187 i++;
188 }
189
190 ///*
191 if(ff==0){
192 gr_bin_height->Draw("APLsame");
193 gr_bin_height->SetMinimum(0.0);
194 gr_bin_height->SetMaximum(1.20);
195 x_axis = gr_bin_height->GetXaxis();
196 y_axis = gr_bin_height->GetYaxis();
197 x_axis->SetTitle("peak height");
198 x_axis->CenterTitle();
199 x_axis->SetTitleSize(0.05);
200 x_axis->SetLabelSize(0.04);
201 x_axis->SetTitleOffset(1.05);
202 y_axis->SetTitle("bin number");
203 y_axis->CenterTitle();
204 y_axis->SetTitleSize(0.05);
205 y_axis->SetLabelSize(0.04);
206 }
207 else gr_bin_height->Draw("PLsame");
208 gr_bin_height->SetMarkerStyle(20);
209 gr_bin_height->SetMarkerSize(1.0);
210 gr_bin_height->SetMarkerColor(ff+1);
211 gr_bin_height->SetLineColor(ff+1);
212 ssname.str("");
213 ssname <<point[ff]<<"point per bin";
214 sname = ssname.str();
215 name = sname.c_str();
216 leg->AddEntry(gr_bin_height,name,"pl");
217 //gr_bin_height->SetTitle("sigma_layer");
218
219 }
220 leg->Draw();
221 leg->SetFillColor(kWhite);
222 leg->SetLineColor(kWhite);
223 c_pt_layer->SaveAs("hit_rate_of_peak.png");
224 c_pt_layer->SaveAs("hit_rate_of_peak.pdf");
225 c_pt_layer->SaveAs("hit_rate_of_peak.eps");
226 //*/
227//}
228//*/
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
XmlRpcServer s
Definition: HelloServer.cpp:11
int draw_txt()
Definition: draw_txt.cxx:9