Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RF_TPOL_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/rf_occ
6 // hnamepath: /occupancy/tpol_occ
7 // hnamepath: /occupancy/rf_num_events
8 //
9 // e-mail: davidl@jlab.org
10 // e-mail: dugger@jlab.org
11 // e-mail: scole@jlab.org
12 // e-mail: tbritton@jlab.org
13 //
14 
15 {
16  // RootSpy saves the current directory and style before
17  // calling the macro and restores it after so it is OK to
18  // change them and not change them back.
19  TDirectory *savedir = gDirectory;
20  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
21  if(dir) dir->cd();
22 
23  TH2I *rf_occ = (TH2I*)gDirectory->FindObjectAny("rf_occ");
24  TH2I *tpol_occ = (TH2I*)gDirectory->FindObjectAny("tpol_occ");
25  TH1I *rf_num_events = (TH1I*)gDirectory->FindObjectAny("rf_num_events");
26 
27  double Nevents = 1.0;
28  if(rf_num_events) Nevents = (double)rf_num_events->GetBinContent(1);
29 
30  TLegend *legend_sa = new TLegend(0.1,0.85,0.3,0.9);
31  legend_sa->AddEntry(rf_occ, "TDC","f");
32 
33  // Just for testing
34  if(gPad == NULL){
35  TCanvas *c1 = new TCanvas("c1");
36  c1->cd(0);
37  c1->Draw();
38  c1->Update();
39  }
40  if(!gPad) {savedir->cd(); return;}
41 
42  TCanvas *c1 = gPad->GetCanvas();
43  c1->cd(0);
44  c1->Clear();
45 
46  c1->Divide(1,2);
47 
48  TVirtualPad *pad1 = c1->cd(1);
49  pad1->SetTicks();
50  pad1->SetGrid();
51  if(rf_occ){
52 
53  // Draw axes
54  //TH1D *rf_axes = (TH1D *)dir->Get("rf_axes");
55  //if(!rf_axes) rf_axes = (TH1D*)rf_occ->Clone("rf_axes");
56 
57  //rf_axes->SetStats(0);
58  //rf_axes->GetYaxis()->SetRangeUser(0.0, 1.05*rf_occ->GetMaximum());
59  //rf_axes->Draw();
60  rf_occ->SetStats(0);
61  rf_occ->SetFillColor(kBlue);
62  rf_occ->SetLineColor(kBlack);
63  rf_occ->SetLineWidth(5);
64  rf_occ->Draw("HIST");
65 
66  char str[256];
67  sprintf(str,"%0.0f events", Nevents);
68  TLatex lat(2.5, 1.075*rf_occ->GetMaximum(), str);
69  lat.SetTextAlign(22);
70  lat.SetTextSize(0.035);
71  lat.Draw();
72 
73  legend_sa->Draw();
74  }
75 
76  TVirtualPad *pad2 = c1->cd(2);
77  pad2->SetTicks();
78  pad2->SetGrid();
79  if(tpol_occ){
80  tpol_occ->SetFillColor(kOrange);
81  tpol_occ->SetLineWidth(5);
82  tpol_occ->SetLineColor(kBlack);
83  double max = tpol_occ->GetBinContent(10)*1.5;
84  tpol_occ->GetYaxis()->SetRangeUser(0., max);
85  tpol_occ->Draw("HIST");
86  }
87 
88 }
char str[256]
sprintf(text,"Post KinFit Cut")
TVirtualPad * pad1
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
double Nevents
TDirectory * savedir
TDirectory * dir
Definition: bcal_hist_eff.C:31
TVirtualPad * pad2