Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
occupancy_online/CDC_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/cdc_num_events
6 // hnamepath: /occupancy/cdc_axes
7 // hnamepath: /occupancy/cdc_occ_ring_01
8 // hnamepath: /occupancy/cdc_occ_ring_02
9 // hnamepath: /occupancy/cdc_occ_ring_03
10 // hnamepath: /occupancy/cdc_occ_ring_04
11 // hnamepath: /occupancy/cdc_occ_ring_05
12 // hnamepath: /occupancy/cdc_occ_ring_06
13 // hnamepath: /occupancy/cdc_occ_ring_07
14 // hnamepath: /occupancy/cdc_occ_ring_08
15 // hnamepath: /occupancy/cdc_occ_ring_09
16 // hnamepath: /occupancy/cdc_occ_ring_10
17 // hnamepath: /occupancy/cdc_occ_ring_11
18 // hnamepath: /occupancy/cdc_occ_ring_12
19 // hnamepath: /occupancy/cdc_occ_ring_13
20 // hnamepath: /occupancy/cdc_occ_ring_14
21 // hnamepath: /occupancy/cdc_occ_ring_15
22 // hnamepath: /occupancy/cdc_occ_ring_16
23 // hnamepath: /occupancy/cdc_occ_ring_17
24 // hnamepath: /occupancy/cdc_occ_ring_18
25 // hnamepath: /occupancy/cdc_occ_ring_19
26 // hnamepath: /occupancy/cdc_occ_ring_20
27 // hnamepath: /occupancy/cdc_occ_ring_21
28 // hnamepath: /occupancy/cdc_occ_ring_22
29 // hnamepath: /occupancy/cdc_occ_ring_23
30 // hnamepath: /occupancy/cdc_occ_ring_24
31 // hnamepath: /occupancy/cdc_occ_ring_25
32 // hnamepath: /occupancy/cdc_occ_ring_26
33 // hnamepath: /occupancy/cdc_occ_ring_27
34 // hnamepath: /occupancy/cdc_occ_ring_28
35 //
36 // e-mail: davidl@jlab.org
37 // e-mail: njarvis@jlab.org
38 // e-mail: zihlmann@jlab.org
39 // e-mail: tbritton@jlab.org
40 //
41 
42 
43 {
44  // RootSpy saves the current directory and style before
45  // calling the macro and restores it after so it is OK to
46  // change them and not change them back.
47 
48  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
49  if(dir) dir->cd();
50 
51  double Nevents = 1.0;
52  TH1I *cdc_num_events = (TH1I*)gDirectory->FindObjectAny("cdc_num_events");
53  if(cdc_num_events) Nevents = (double)cdc_num_events->GetBinContent(1);
54  TH2D *cdc_axes = (TH2D *)gDirectory->FindObjectAny("cdc_axes");
55  if(!cdc_axes) return;
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) return;
65 
66  TCanvas *c1 = gPad->GetCanvas();
67  if(!c1) return;
68  c1->cd(0);
69 
70  // Draw axes
71  double minScale = 0.0, maxScale = 0.10;
72  cdc_axes->SetStats(0);
73  cdc_axes->Fill(100,100); // without this, the color ramp is not drawn
74  cdc_axes->GetZaxis()->SetRangeUser(minScale, maxScale);
75  cdc_axes->Draw("colz");
76 
77  // Draw inner and outer circles so we can see if outer ring is missing
78  TEllipse *e = new TEllipse(0.0, 0.0, 56.0, 56.0);
79  e->SetLineWidth(3);
80  e->Draw();
81  e = new TEllipse(0.0, 0.0, 9.55, 9.55);
82  e->SetLineWidth(2);
83  e->Draw();
84 
85  // Draw All rings
86  for(unsigned int iring=1; iring<=28; iring++){
87  char hname[256];
88  sprintf(hname, "cdc_occ_ring_%02d", iring);
89  TH1 *h = (TH1*)(dir->Get(hname));
90  if(h){
91  sprintf(hname, "cdc_occ_ring_norm_%02d", iring);
92  TH1 *hh = (TH1*)h->Clone(hname);
93  hh->Scale(1.0/Nevents);
94  hh->GetZaxis()->SetRangeUser(minScale, maxScale);
95  hh->SetStats(0);
96  hh->Draw("same col pol"); // draw remaining histos without overwriting color palette
97  }
98  }
99 
100  char str[256];
101  sprintf(str,"%g events", Nevents);
102  TLatex lat;
103  lat.SetTextAlign(22);
104  lat.SetTextSize(0.035);
105  lat.DrawLatex(0.0, 61.0, str);
106 
107 }
char str[256]
Float_t maxScale
sprintf(text,"Post KinFit Cut")
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TEllipse * e
static TH1I * cdc_num_events
double Nevents
TDirectory * dir
Definition: bcal_hist_eff.C:31
Float_t minScale