Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ST_occupancy.C
Go to the documentation of this file.
1 
2 // The following are special comments used by RootSpy to know
3 // which histograms to fetch for the macro.
4 //
5 // hnamepath: /occupancy/st_num_events
6 // hnamepath: /occupancy/st_adc_occ
7 // hnamepath: /occupancy/st_tdc_occ
8 //
9 // e-mail: davidl@jlab.org
10 // e-mail: marki@jlab.org
11 // e-mail: tbritton@jlab.org
12 //
13 
14 {
15  // RootSpy saves the current directory and style before
16  // calling the macro and restores it after so it is OK to
17  // change them and not change them back.
18  TDirectory *savedir = gDirectory;
19  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
20  if(dir) dir->cd();
21 
22  double Nevents = 1.0;
23  TH1I *st_num_events = (TH1I*)gDirectory->FindObjectAny("st_num_events");
24  if(st_num_events) Nevents = (double)st_num_events->GetBinContent(1);
25 
26  TH1I *st_adc_occ = (TH1I*)gDirectory->FindObjectAny("st_adc_occ");
27  TH1I *st_tdc_occ = (TH1I*)gDirectory->FindObjectAny("st_tdc_occ");
28 
29  TLegend *legend_sa = new TLegend(0.1,0.85,0.3,0.9);
30  TLegend *legend_na = new TLegend(0.3,0.85,0.5,0.9);
31 
32  if(st_tdc_occ){
33  st_tdc_occ->SetBarWidth(0.5);
34  st_tdc_occ->SetBarOffset(0);
35  st_tdc_occ->SetFillColor(kGreen);
36  st_tdc_occ->SetStats(0);
37  st_tdc_occ->SetXTitle("Channel number");
38  st_tdc_occ->SetYTitle("fADC/TDC hit count");
39  st_tdc_occ->SetTitleSize(0.05,"X");
40  st_tdc_occ->GetXaxis()->CenterTitle();
41  st_tdc_occ->SetTitleSize(0.05,"Y");
42  st_tdc_occ->GetYaxis()->CenterTitle();
43  st_tdc_occ->GetYaxis()->SetRangeUser(0.0, st_tdc_occ->GetMaximum());
44  if(st_adc_occ)st_adc_occ->GetYaxis()->SetRangeUser(0.0, 1.05*st_tdc_occ->GetMaximum());
45  }
46 
47  if(st_adc_occ){
48  st_adc_occ->SetBarWidth(0.5);
49  st_adc_occ->SetBarOffset(0.5);
50  st_adc_occ->SetFillColor(kRed);
51  st_adc_occ->SetStats(0);
52  }
53 
54  legend_sa->AddEntry(st_adc_occ,"fADC","f");
55  legend_na->AddEntry(st_tdc_occ,"TDC","f");
56 
57  // Just for testing
58  if(gPad == NULL){
59  TCanvas *c1 = new TCanvas("c1");
60  c1->cd(0);
61  c1->Draw();
62  c1->Update();
63  }
64  if(!gPad) {savedir->cd(); return;}
65 
66  TCanvas *c1 = gPad->GetCanvas();
67  c1->cd(0);
68  c1->Clear();
69 
70  gPad->SetTicks();
71  gPad->SetGridy();
72  if(st_adc_occ) st_adc_occ->DrawCopy("BAR");
73  if(st_tdc_occ) st_tdc_occ->DrawCopy("BAR same");
74 
75  legend_sa->Draw();
76  legend_na->Draw();
77 
78  if(st_tdc_occ){
79  char str[256];
80  sprintf(str,"%0.0f events", Nevents);
81  TLatex lat(15.0, 1.07*st_tdc_occ->GetMaximum(), str);
82  lat.SetTextAlign(22);
83  lat.SetTextSize(0.035);
84  lat.Draw();
85  }
86 }
char str[256]
sprintf(text,"Post KinFit Cut")
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
static TH1I * st_num_events
double Nevents
TDirectory * savedir
TDirectory * dir
Definition: bcal_hist_eff.C:31