Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bcal_hist_eff_summary.C
Go to the documentation of this file.
1 #include <TRandom.h>
2 #include <iostream>
3 #include <fstream>
4 
6 {
7 // read in histograms plotting BCAL efficiencies and print history to file.
8 //
9 
10 gROOT->Reset();
11 //TTree *Bfield = (TTree *) gROOT->FindObject("Bfield");
12 gStyle->SetPalette(1,0);
13 gStyle->SetOptStat(kFALSE);
14 // gStyle->SetOptStat(11111111);
15 gStyle->SetPadRightMargin(0.15);
16 gStyle->SetPadLeftMargin(0.15);
17 gStyle->SetPadBottomMargin(0.15);
18 //
19 
20  char string[256];
21  Int_t j,jj;
22  Int_t ndx;
23  // Int_t npts=7; // run 1506
24  // Int_t npts=42; // run 2400
25  // Int_t npts=423; // run 2439
26  // Int_t npts=205; // run 2439
27  Int_t npts=18; // run 2179
28 
29  // define history histogram
30 
31  Double_t xmin=0;
32  Double_t xmax=npts;
33  //Double_t ymin=0.5;
34  // Double_t ymax=1.1;
35  Double_t ymin=0.;
36  Double_t ymax=1.2;
37  TH1F *hsummary_layer1 = new TH1F("hsummary_layer1","Summary layer 1",npts,xmin,xmax);
38  TH1F *hsummary_layer2 = new TH1F("hsummary_layer2","Summary layer 2",npts,xmin,xmax);
39  TH1F *hsummary_layer3 = new TH1F("hsummary_layer3","Summary layer 3",npts,xmin,xmax);
40  TH1F *hsummary_layer4 = new TH1F("hsummary_layer4","Summary layer 4",npts,xmin,xmax);
41 
42  TH1F *hsummary2_layer1 = new TH1F("hsummary2_layer1","Summary layer 1",npts,xmin,xmax);
43  TH1F *hsummary2_layer2 = new TH1F("hsummary2_layer2","Summary layer 2",npts,xmin,xmax);
44  TH1F *hsummary2_layer3 = new TH1F("hsummary2_layer3","Summary layer 3",npts,xmin,xmax);
45  TH1F *hsummary2_layer4 = new TH1F("hsummary2_layer4","Summary layer 4",npts,xmin,xmax);
46 
47  // read histograms from file
48 
49  for (ndx=0; ndx < npts; ndx++) {
50 
51  sprintf(string,"hd_rawdata_002179_%03d_.root",ndx);
52 
53 
54  // if (ndx == 1) continue; // run 1506
55  /*if (ndx == 2) continue;
56  if (ndx == 6) continue;
57  if (ndx == 12) continue;;
58  if (ndx == 39) continue;*/
59 
60  /*if (ndx == 10) continue; // file #3 is empty
61  if (ndx == 92) continue; // file #3 is empty
62  if (ndx == 95) continue; // file #3 is empty
63  if (ndx == 141) continue; // file #3 is empty
64  if (ndx == 176) continue; // file #3 is empty
65  if (ndx == 225) continue; // file #3 is empty
66  if (ndx == 226) continue; // file #3 is empty
67  if (ndx == 227) continue; // file #3 is empty
68  if (ndx >= 230 && ndx<=254 ) continue; // file #3 is empty
69  if (ndx == 257) continue; // file #3 is empty
70  if (ndx == 258) continue; // file #3 is empty
71  if (ndx == 260) continue; // file #3 is empty
72  if (ndx == 262) continue; // file #3 is empty
73  if (ndx == 264) continue; // file #3 is empty
74  if (ndx == 278) continue; // file #3 is empty
75  if (ndx == 281) continue; // file #3 is empty
76  if (ndx == 284) continue; // file #3 is empty
77  if (ndx == 285) continue; // file #3 is empty
78  if (ndx == 286) continue; // file #3 is empty
79  if (ndx == 287) continue; // file #3 is empty
80  if (ndx == 289) continue; // file #3 is empty
81  if (ndx == 290) continue; // file #3 is empty
82  if (ndx == 291) continue; // file #3 is empty
83  if (ndx == 293) continue; // file #3 is empty
84  if (ndx == 294) continue; // file #3 is empty
85  if (ndx == 295) continue; // file #3 is empty
86  if (ndx == 298) continue; // file #3 is empty
87  if (ndx == 299) continue; // file #3 is empty
88  if (ndx == 304) continue; // file #3 is empty
89  if (ndx == 306) continue; // file #3 is empty*/
90 
91  TFile *in=NULL;
92  in = new TFile(string,"read");
93  if (!in) {
94  printf ("Histogram input filename=%s does not open\n",string);
95  continue;
96  }
97  else {
98  printf ("Histogram input filename=%s OK\n",string);
99  }
100 
101  // cd into bcal_eff directory
102  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("bcal_eff");
103  if(dir) dir->cd();
104 
105  TH1F *h1eff_eff= NULL;
106  h1eff_eff = (TH1F*)gDirectory->FindObjectAny("h1eff_eff");
107  TH1F *h1eff_cellideff = (TH1F*)gDirectory->FindObjectAny("h1eff_cellideff");
108  TH1F *h1eff2_eff2 = (TH1F*)gDirectory->FindObjectAny("h1eff2_eff2");
109  TH1F *h1eff2_cellideff2 = (TH1F*)gDirectory->FindObjectAny("h1eff2_cellideff2");
110 
111  if ( (h1eff_eff == NULL) || (h1eff_eff->GetEntries() <=0)) continue;
112 
113  // retrieving information from the histogram
114 
115  Int_t ndim = h1eff_eff->GetNbinsX();
116  Double_t xlo = h1eff_eff->GetBinLowEdge(1);
117  Double_t width = h1eff_eff->GetBinWidth(1);
118  Double_t xhi = xlo + width*ndim;
119  printf ("\nbcal_hist_eff_summary: ndx=%d, ndim=%d, xlo=%f, width=%f, xhi=%d\n\n",ndx,ndim,xlo,width,xhi);
120 
121  for(j=0;j<ndim;j++) {
122  Double_t xbin = xlo + j*width;
123  Double_t content = h1eff_eff->GetBinContent(j+1);
124  Double_t error = h1eff_eff->GetBinError(j+1);
125  printf ("j=%d, xbin=%f, content=%f\n",j,xbin,content);
126 
127  // fill summary histogram
128 
129  if (j == 1) {
130  hsummary_layer1->SetBinContent(ndx+1,content);
131  hsummary_layer1->SetBinError(ndx+1,error);
132  }
133  if (j == 2) {
134  hsummary_layer2->SetBinContent(ndx+1,content);
135  hsummary_layer2->SetBinError(ndx+1,error);
136  }
137  if (j == 3) {
138  hsummary_layer3->SetBinContent(ndx+1,content);
139  hsummary_layer3->SetBinError(ndx+1,error);
140  }
141  if (j == 4) {
142  hsummary_layer4->SetBinContent(ndx+1,content);
143  hsummary_layer4->SetBinError(ndx+1,error);
144  }
145 
146  }
147 
148 
149 
150  // retrieving information from the histogram
151 
152  ndim = h1eff2_eff2->GetNbinsX();
153  xlo = h1eff2_eff2->GetBinLowEdge(1);
154  width = h1eff2_eff2->GetBinWidth(1);
155  xhi = xlo + width*ndim;
156  printf ("\nbcal_hist_eff2_summary: ndx=%d, ndim=%d, xlo=%f, width=%f, xhi=%f\n\n",ndx,ndim,xlo,width,xhi);
157 
158  for(j=0;j<ndim;j++) {
159  Double_t xbin = xlo + j*width;
160  Double_t content = h1eff2_eff2->GetBinContent(j+1);
161  Double_t error = h1eff2_eff2->GetBinError(j+1);
162  printf ("j=%d, xbin=%f, content=%f\n",j,xbin,content);
163 
164  // fill summary histogram
165 
166  if (j == 1) {
167  hsummary2_layer1->SetBinContent(ndx+1,content);
168  hsummary2_layer1->SetBinError(ndx+1,error);
169  }
170  if (j == 2) {
171  hsummary2_layer2->SetBinContent(ndx+1,content);
172  hsummary2_layer2->SetBinError(ndx+1,error);
173  }
174  if (j == 3) {
175  hsummary2_layer3->SetBinContent(ndx+1,content);
176  hsummary2_layer3->SetBinError(ndx+1,error);
177  }
178  if (j == 4) {
179  hsummary2_layer4->SetBinContent(ndx+1,content);
180  hsummary2_layer4->SetBinError(ndx+1,error);
181  }
182 
183  }
184 
185  in->Close();
186 
187  } // end loop over histogram files
188 
189  //
190  TCanvas *c1 = new TCanvas("c1","c1 bcal_hist_eff_summary ",200,10,700,700);
191  c1->SetBorderMode(0);
192  c1->SetFillColor(0);
193 
194  c1->SetGridx();
195  c1->SetGridy();
196  c1->SetBorderMode(0);
197  c1->SetFillColor(0);
198 
199  TLegend *leg = new TLegend(0.6,0.8,0.85,0.95);
200  leg->AddEntry(hsummary_layer1,"Layer 1","p");
201  leg->AddEntry(hsummary_layer2,"Layer 2","p");
202  leg->AddEntry(hsummary_layer3,"Layer 3","p");
203  leg->AddEntry(hsummary_layer4,"Layer 4","p");
204 
205  hsummary_layer1->SetTitle("");
206  //hsummary_layer1->GetXaxis()->SetRangeUser(xmin,xmax);
207  hsummary_layer1->GetYaxis()->SetRangeUser(ymin,ymax);
208  hsummary_layer1->GetXaxis()->SetTitleSize(0.05);
209  hsummary_layer1->GetYaxis()->SetTitleSize(0.05);
210  hsummary_layer1->GetXaxis()->SetTitle("File Number");
211  hsummary_layer1->GetYaxis()->SetTitle("Efficiency Clusters");
212  hsummary_layer1->SetLineColor(2);
213  hsummary_layer1->SetMarkerColor(2);
214  hsummary_layer1->SetMarkerStyle(20);
215  hsummary_layer1->Draw("p");
216 
217  hsummary_layer2->SetLineColor(4);
218  hsummary_layer2->SetMarkerColor(4);
219  hsummary_layer2->SetMarkerStyle(20);
220  hsummary_layer2->Draw("samep");
221 
222  hsummary_layer3->SetLineColor(1);
223  hsummary_layer3->SetMarkerColor(1);
224  hsummary_layer3->SetMarkerStyle(20);
225  hsummary_layer3->Draw("samep");
226 
227  hsummary_layer4->SetLineColor(3);
228  hsummary_layer4->SetMarkerColor(3);
229  hsummary_layer4->SetMarkerStyle(20);
230  hsummary_layer4->Draw("samep");
231 
232  sprintf(string,"hd_rawdata_002179");
233  printf ("Histogram input filename=%s\n",string);
234  TLatex *t1 = new TLatex(0.15,0.92,string);
235  t1->SetNDC();
236  t1->SetTextSize(0.03);
237  t1->Draw();
238 
239  leg->Draw();
240 
241  //
242  TCanvas *c2 = new TCanvas("c2","c2 bcal_hist_eff_summary ",200,10,700,700);
243  c2->SetBorderMode(0);
244  c2->SetFillColor(0);
245 
246  c2->SetGridx();
247  c2->SetGridy();
248  c2->SetBorderMode(0);
249  c2->SetFillColor(0);
250 
251  leg = new TLegend(0.6,0.80,0.85,0.95);
252  leg->AddEntry(hsummary2_layer1,"Layer 1","p");
253  leg->AddEntry(hsummary2_layer2,"Layer 2","p");
254  leg->AddEntry(hsummary2_layer3,"Layer 3","p");
255  leg->AddEntry(hsummary2_layer4,"Layer 4","p");
256 
257  hsummary2_layer1->SetTitle("");
258  //hsummary2_layer1->GetXaxis()->SetRangeUser(xmin,xmax);
259  hsummary2_layer1->GetYaxis()->SetRangeUser(ymin,ymax);
260  hsummary2_layer1->GetXaxis()->SetTitleSize(0.05);
261  hsummary2_layer1->GetYaxis()->SetTitleSize(0.05);
262  hsummary2_layer1->GetXaxis()->SetTitle("File Number");
263  hsummary2_layer1->GetYaxis()->SetTitle("Efficiency Enhanced Hits");
264  hsummary2_layer1->SetLineColor(2);
265  hsummary2_layer1->SetMarkerColor(2);
266  hsummary2_layer1->SetMarkerStyle(20);
267  hsummary2_layer1->Draw("p");
268 
269  hsummary2_layer2->SetLineColor(4);
270  hsummary2_layer2->SetMarkerColor(4);
271  hsummary2_layer2->SetMarkerStyle(20);
272  hsummary2_layer2->Draw("samep");
273 
274  hsummary2_layer3->SetLineColor(1);
275  hsummary2_layer3->SetMarkerColor(1);
276  hsummary2_layer3->SetMarkerStyle(20);
277  hsummary2_layer3->Draw("samep");
278 
279  hsummary2_layer4->SetLineColor(3);
280  hsummary2_layer4->SetMarkerColor(3);
281  hsummary2_layer4->SetMarkerStyle(20);
282  hsummary2_layer4->Draw("samep");
283 
284  sprintf(string,"hd_rawdata_002179");
285  printf ("Histogram input filename=%s\n",string);
286  t1 = new TLatex(0.15,0.92,string);
287  t1->SetNDC();
288  t1->SetTextSize(0.03);
289  t1->Draw();
290 
291  leg->Draw();
292 
293 
294 
295  sprintf(string,"bcal_hist_eff_summary_002179.pdf(");
296  c1->SaveAs(string);
297 
298  sprintf(string,"bcal_hist_eff_summary_002179.pdf)");
299  c2->SaveAs(string);
300 
301 }
302 
TH1F * h1eff2_cellideff2
Definition: bcal_hist_eff.C:40
sprintf(text,"Post KinFit Cut")
TH1F * h1eff2_eff2
Definition: bcal_hist_eff.C:39
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TLegend * leg
Definition: DIRC_digihit.C:58
Double_t c2[2][NMODULES]
Definition: tw_corr.C:69
void bcal_hist_eff_summary(void)
TLatex * t1
TH1F * h1eff_cellideff
Definition: bcal_hist_eff.C:38
TH1F * h1eff_eff
Definition: bcal_hist_eff.C:37
Double_t ymin
Definition: bcal_hist_eff.C:89
Double_t ymax
Definition: bcal_hist_eff.C:91
Int_t ndx
TDirectory * dir
Definition: bcal_hist_eff.C:31
printf("string=%s", string)