Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ST_online_tracking/ST_Monitoring_Eff.C
Go to the documentation of this file.
1 // File: ST_Monitoring_Efficiency.C
2 // Last Modified: 05/27/2015
3 // Creator: Mahmoud Kamel mkame006@fiu.edu
4 // Purpose: Displaying histograms for online monitoring purposes
6  // Define the directory that contains the histograms
7  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("st_tracking");
8  if(dir) dir->cd();
9  // Grab 1D histograms
10  TH1D *MacropEff = (TH1D*)dir->FindObjectAny("MacropEff");
11  TH1D *MacropEff_adc = (TH1D*)dir->FindObjectAny("MacropEff_adc");
12  TH1D *h_phi_sec_pred_hit_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_pred_hit_cntr");
13  TH1D *h_phi_sec_hit_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_hit_cntr");
14  TH1D *h_phi_sec_adc_cntr = (TH1D*)dir->FindObjectAny("h_phi_sec_adc_cntr");
15 
16  // get Binomial errors in an efficiency plot
17  // hit object efficiency
18  h_phi_sec_hit_cntr->Sumw2();
19  h_phi_sec_pred_hit_cntr->Sumw2();
20  MacropEff->Sumw2();
21  MacropEff->Divide(h_phi_sec_hit_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");
22 
23  // adc efficiency
24  h_phi_sec_adc_cntr->Sumw2();
25  MacropEff_adc->Sumw2();
26  MacropEff_adc->Divide(h_phi_sec_adc_cntr,h_phi_sec_pred_hit_cntr,1,1,"B");
27 
28  //Create the canvas
29  if(gPad == NULL)
30  {
31  TCanvas *c1 = new TCanvas("c1","Start Counter 1D Histograms", 200, 10, 600, 480);
32  c1->cd(0);
33  c1->Draw();
34  c1->Update();
35  }
36  if(!gPad) return;
37  TCanvas *c1 = gPad->GetCanvas();
38  c1->Divide(2,1);
39  // ST ADC Efficiency histogram
40  c1->cd(1);
41  gStyle->SetOptStat(0);
42  gStyle->SetErrorX(0);
43  gPad->SetTicks();
44  gPad->SetGrid();
45  if (MacropEff_adc) {
46  MacropEff_adc->Draw("E1");
47  MacropEff_adc->SetMarkerStyle(21);
48  MacropEff_adc->SetMarkerSize(1.5);
49  MacropEff_adc->SetMarkerColor(4.0);
50  MacropEff_adc->SetAxisRange(0., 1.,"Y");
51  MacropEff_adc->GetYaxis()->SetTitleOffset(1.26);
52  Double_t TWA_adc=0;
53  Double_t sumE_adc=0;
54  Double_t Final_adc=0;
55  Double_t error_adc=0.;
56  Double_t BC_adc=0.;
57  Double_t WA_adc=0.;
58  //Double_t Final_adc=0.;
59  for (int i = 0; i < 30; i++)
60  {
61  error_adc = MacropEff_adc->GetBinError(i+2);
62  sumE_adc = sumE_adc + error_adc;
63  BC_adc = MacropEff_adc->GetBinContent(i+2);
64  WA_adc = BC_adc*error_adc;
65  TWA_adc = TWA_adc + WA_adc ;
66  Final_adc = TWA_adc/sumE_adc;
67  // cout << "error_adc = "<< error_adc << endl;
68  // cout << "BC_adc = "<< BC_adc << endl;
69  // cout << "Final_adc = "<< Final_adc << endl;
70  }
71  TLine *line = new TLine(1,Final_adc,30,Final_adc);
72  line->SetLineWidth(3);
73  line->SetLineColor(2);
74  //Write the eff value on the histogram
75  char tFinal_adc[40];
76  char terror_adc[40];
77  sprintf(tFinal_adc,"ADC Efficiency (%%) = %g",Final_adc*100);
78  sprintf(terror_adc,"ADC Efficiency error (%%) = %g",error_adc*100);
79  line->Draw();
80  TPaveLabel *p = new TPaveLabel(0.3,0.6,0.7,0.7,tFinal_adc,"brNDC");
81  p->Draw();
82  TPaveLabel *p1 = new TPaveLabel(0.3,0.5,0.7,0.6,terror_adc,"brNDC");
83  p1->Draw();
84  }
85  // ST Hit Efficiency histogram
86  c1->cd(2);
87  gPad->SetTicks();
88  gPad->SetGrid();
89  if (MacropEff) {
90  MacropEff->Draw("E1");
91  MacropEff->SetMarkerStyle(21);
92  MacropEff->SetMarkerSize(1.5);
93  MacropEff->SetMarkerColor(4.0);
94  MacropEff->SetAxisRange(0., 1.,"Y");
95  MacropEff->GetYaxis()->SetTitleOffset(1.26);
96  Double_t TWA=0;
97  Double_t sumE=0;
98  Double_t Final=0;
99  Double_t error=0.;
100  Double_t BC=0.;
101  Double_t WA=0.;
102  //Double_t Final=0.;
103  for (int i = 0; i < 30; i++)
104  {
105  error = MacropEff->GetBinError(i+2);
106  sumE = sumE+error;
107  BC = MacropEff->GetBinContent(i+2);
108  WA = BC*error;
109  TWA = TWA + WA ;
110  Final = TWA/sumE;
111  // cout << "error = "<< error << endl;
112  // cout << "BC = "<< BC << endl;
113  // cout << "Final = "<< Final << endl;
114  }
115  TLine *line = new TLine(1,Final,30,Final);
116  line->SetLineWidth(3);
117  line->SetLineColor(2);
118  //Write the eff value on the histogram
119  char tFinal[40];
120  char terror[40];
121  sprintf(tFinal,"Hit Efficiency (%%) = %g",Final*100);
122  sprintf(terror,"Hit Efficiency error (%%) = %g",error*100);
123  line->Draw();
124  TPaveLabel *p = new TPaveLabel(0.3,0.6,0.7,0.7,tFinal,"brNDC");
125  p->Draw();
126  TPaveLabel *p1 = new TPaveLabel(0.3,0.5,0.7,0.6,terror,"brNDC");
127  p1->Draw();
128  }
129 }
sprintf(text,"Post KinFit Cut")
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TDirectory * dir
Definition: bcal_hist_eff.C:31