Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FCAL_occupancy.C
Go to the documentation of this file.
1 //
2 // Guidance: --------------------------------------------
3 //
4 // Single channels may show low or no number of entries in occupancy plots
5 // during normal operation. This could number anywhere from 0 to ~20
6 // channels, with slow time dependency (0-3 channels/day). These channels are
7 // expected to be randomly spread around the FCAL, and may or may not also
8 // line up with yellow/red status on the FCAL HV GUI. Any behavior other than
9 // what's described here should be reported to FCAL experts.
10 //
11 // End Guidance: ----------------------------------------
12 //
13 //
14 //
15 // The following are special comments used by RootSpy to know
16 // which histograms to fetch for the macro.
17 //
18 // hnamepath: /occupancy/fcal_occ
19 // hnamepath: /occupancy/fcal_num_events
20 //
21 // e-mail: davidl@jlab.org
22 // e-mail: gleasonc@jlab.org
23 // e-mail: shepherd@jlab.org
24 // e-mail: tbritton@jlab.org
25 //
26 
27 {
28  // RootSpy saves the current directory and style before
29  // calling the macro and restores it after so it is OK to
30  // change them and not change them back.
31  TDirectory *savedir = gDirectory;
32  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
33  if(dir) dir->cd();
34 
35  TH2I *fcal_occ = (TH2I*)gDirectory->FindObjectAny("fcal_occ");
36  TH1I *fcal_num_events = (TH1I*)gDirectory->FindObjectAny("fcal_num_events");
37 
38  double Nevents = 1.0;
39  if(fcal_num_events) Nevents = (double)fcal_num_events->GetBinContent(1);
40 
41  TLegend *legend_sa = new TLegend(0.1,0.85,0.3,0.9);
42  if(fcal_occ)legend_sa->AddEntry(fcal_occ, "fADC","f");
43 
44  // Just for testing
45  if(gPad == NULL){
46  TCanvas *c1 = new TCanvas("c1");
47  c1->cd(0);
48  c1->Draw();
49  c1->Update();
50  }
51  if(!gPad) {savedir->cd(); return;}
52 
53  TCanvas *c1 = gPad->GetCanvas();
54  c1->cd(0);
55  c1->Clear();
56 
57  gPad->SetTicks();
58  gPad->SetGrid();
59  gPad->SetRightMargin(2.0);
60  gPad->SetLeftMargin(2.0);
61  if(fcal_occ){
62  fcal_occ->SetStats(0);
63  TH1* h = fcal_occ->DrawCopy("colz");
64  h->Scale(1./Nevents);
65  h->GetZaxis()->SetRangeUser(0.0001, 0.25);
66 
67  char str[256];
68  sprintf(str,"%0.0f events", Nevents);
69  TLatex lat(30.0, 61.75, str);
70  lat.SetTextAlign(22);
71  lat.SetTextSize(0.035);
72  lat.Draw();
73  }
74 
75  legend_sa->Draw();
76 
77 }
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