Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BCAL_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/bcal_num_events
6 // hnamepath: /occupancy/bcal_adc_occ
7 // hnamepath: /occupancy/bcal_tdc_occ
8 //
9 // e-mail: davidl@jlab.org
10 // e-mail: elton@jlab.org
11 // e-mail: dalton@jlab.org
12 // e-mail: zisis@uregina.ca
13 // e-mail: tbritton@jlab.org
14 //
15 
16 {
17  // RootSpy saves the current directory and style before
18  // calling the macro and restores it after so it is OK to
19  // change them and not change them back.
20  TDirectory *savedir = gDirectory;
21  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
22  if(dir) dir->cd();
23 
24  TH2I *bcal_adc_occ = (TH2I*)gDirectory->FindObjectAny("bcal_adc_occ");
25  TH2I *bcal_tdc_occ = (TH2I*)gDirectory->FindObjectAny("bcal_tdc_occ");
26 
27  double Nevents = 1.0;
28  TH1I *bcal_num_events = (TH1I*)gDirectory->FindObjectAny("bcal_num_events");
29  if(bcal_num_events) Nevents = (double)bcal_num_events->GetBinContent(1);
30 
31  // Just for testing
32  if(gPad == NULL){
33  TCanvas *c1 = new TCanvas("c1");
34  c1->cd(0);
35  c1->Draw();
36  c1->Update();
37  }
38  if(!gPad) {savedir->cd(); return;}
39 
40  TCanvas *c1 = gPad->GetCanvas();
41  c1->cd(0);
42 
43  c1->Divide(2,1);
44 
45  TVirtualPad *pad1 = c1->cd(1);
46  pad1->SetTicks();
47  pad1->SetLeftMargin(0.15);
48  pad1->SetRightMargin(0.15);
49  if(bcal_adc_occ){
50  bcal_adc_occ->SetStats(0);
51  bcal_adc_occ->Draw("colz");
52  }
53 
54  TVirtualPad *pad2 = c1->cd(2);
55  pad2->SetTicks();
56  pad2->SetLeftMargin(0.15);
57  pad2->SetRightMargin(0.15);
58  if(bcal_tdc_occ){
59  bcal_tdc_occ->SetStats(0);
60  bcal_tdc_occ->Draw("colz");
61  }
62 
63  char str[256];
64  sprintf(str,"%0.0f events", Nevents);
65  TLatex lat(50.0, 26.5, str);
66  lat.SetTextAlign(22);
67  lat.SetTextSize(0.035);
68  lat.Draw();
69 
70 }
71 
72 
char str[256]
sprintf(text,"Post KinFit Cut")
TVirtualPad * pad1
static TH2I * bcal_tdc_occ
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
static TH1I * bcal_num_events
double Nevents
TDirectory * savedir
TDirectory * dir
Definition: bcal_hist_eff.C:31
TVirtualPad * pad2