Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CCAL_occupancy.C
Go to the documentation of this file.
1 //
2 // Guidance: --------------------------------------------
3 //
4 // End Guidance: ----------------------------------------
5 //
6 //
7 //
8 // The following are special comments used by RootSpy to know
9 // which histograms to fetch for the macro.
10 //
11 // hnamepath: /occupancy/ccal_occ
12 // hnamepath: /occupancy/ccal_num_events
13 //
14 // e-mail: davidl@jlab.org
15 // e-mail: staylor@jlab.org
16 // e-mail: somov@jlab.org
17 // e-mail: tbritton@jlab.org
18 //
19 
20 {
21  // RootSpy saves the current directory and style before
22  // calling the macro and restores it after so it is OK to
23  // change them and not change them back.
24  TDirectory *savedir = gDirectory;
25  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
26  if(dir) dir->cd();
27 
28  TH2I *ccal_occ = (TH2I*)gDirectory->FindObjectAny("ccal_occ");
29  TH1I *ccal_num_events = (TH1I*)gDirectory->FindObjectAny("ccal_num_events");
30 
31  double Nevents = 1.0;
32  if(ccal_num_events) Nevents = (double)ccal_num_events->GetBinContent(1);
33 
34  TLegend *legend_sa = new TLegend(0.1,0.85,0.3,0.9);
35  if(ccal_occ)legend_sa->AddEntry(ccal_occ, "fADC","f");
36 
37  // Just for testing
38  if(gPad == NULL){
39  TCanvas *c1 = new TCanvas("c1");
40  c1->cd(0);
41  c1->Draw();
42  c1->Update();
43  }
44  if(!gPad) {savedir->cd(); return;}
45 
46  TCanvas *c1 = gPad->GetCanvas();
47  c1->cd(0);
48  c1->Clear();
49 
50  gPad->SetTicks();
51  gPad->SetGrid();
52  gPad->SetRightMargin(2.0);
53  gPad->SetLeftMargin(2.0);
54  if(ccal_occ){
55  ccal_occ->SetStats(0);
56  TH1* h = ccal_occ->DrawCopy("colz");
57  h->Scale(1./Nevents);
58  h->GetZaxis()->SetRangeUser(0.0001, 0.25);
59 
60  char str[256];
61  sprintf(str,"%0.0f events", Nevents);
62  TLatex lat(30.0, 61.75, str);
63  lat.SetTextAlign(22);
64  lat.SetTextSize(0.035);
65  lat.Draw();
66  }
67 
68  legend_sa->Draw();
69 
70 }
char str[256]
sprintf(text,"Post KinFit Cut")
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
double Nevents
TDirectory * savedir
TDirectory * dir
Definition: bcal_hist_eff.C:31