Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TAGGER_occupancy.C
Go to the documentation of this file.
1 //
2 // Guidance: --------------------------------------------
3 //
4 // This shows the tagger microscope (top) and hodoscope(bottom)
5 // occupancies.
6 //
7 // Please note that for amorphous radiator running there will be
8 // 3 channels in the upper plot of fADC values around colun 82
9 // that are nearly twice as high as its neighbors. This effect
10 // is not as pronounced for the diamond radiator which is shown
11 // in the reference plot. This is expected and should be ignored.
12 //
13 // For all other issues contact:
14 //
15 // Alex Barnes - microscope: <see white board>
16 //
17 // Nathan Sparks - hodoscope: <see white board>
18 //
19 // Run Coordinator: (757) 383-5542
20 //
21 // David Lawrence: x5567 (office)
22 // 746-6697 (cell)
23 // 595-1302 (home)
24 //
25 // End Guidance: ----------------------------------------
26 //
27 //
28 // The following are special comments used by RootSpy to know
29 // which histograms to fetch for the macro.
30 //
31 // hnamepath: /occupancy/tag_num_events
32 // hnamepath: /occupancy/tagh_adc_occ
33 // hnamepath: /occupancy/tagh_tdc_occ
34 // hnamepath: /occupancy/tagm_adc_occ
35 // hnamepath: /occupancy/tagm_tdc_occ
36 //
37 // e-mail: davidl@jlab.org
38 // e-mail: aebarnes@jlab.org
39 // e-mail: somov@jlab.org
40 // e-mail: richard.t.jones@uconn.edu
41 // e-mail: tbritton@jlab.org
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  TDirectory *savedir = gDirectory;
48  TDirectory *dir = (TDirectory*)gDirectory->FindObjectAny("occupancy");
49  if(dir) dir->cd();
50 
51  double Nevents = 1.0;
52  TH1I *tag_num_events = (TH1I*)gDirectory->FindObjectAny("tag_num_events");
53  if(tag_num_events) Nevents = (double)tag_num_events->GetBinContent(1);
54 
55  TH2I *tagh_adc_occ = (TH2I*)gDirectory->FindObjectAny("tagh_adc_occ");
56  TH2I *tagh_tdc_occ = (TH2I*)gDirectory->FindObjectAny("tagh_tdc_occ");
57  TH2I *tagm_adc_occ = (TH2I*)gDirectory->FindObjectAny("tagm_adc_occ");
58  TH2I *tagm_tdc_occ = (TH2I*)gDirectory->FindObjectAny("tagm_tdc_occ");
59 
60  TLegend *legend_sa = new TLegend(0.1,0.85,0.3,0.9);
61  TLegend *legend_na = new TLegend(0.3,0.85,0.5,0.9);
62 
63  TLegend *legend_s = new TLegend(0.1,0.85,0.3,0.9);
64  TLegend *legend_n = new TLegend(0.3,0.85,0.5,0.9);
65 
66  if(tagh_tdc_occ){
67  tagh_tdc_occ->SetBarWidth(0.5);
68  tagh_tdc_occ->SetBarOffset(0);
69  tagh_tdc_occ->SetFillColor(kBlack);
70  tagh_tdc_occ->SetStats(0);
71  tagh_tdc_occ->SetTitle("TAGH column occupancy");
72  tagh_tdc_occ->SetXTitle("Column number");
73  tagh_tdc_occ->SetYTitle("fADC/TDC occupancy");
74  tagh_tdc_occ->SetTitleSize(0.05,"X");
75  tagh_tdc_occ->GetXaxis()->CenterTitle();
76  tagh_tdc_occ->SetTitleSize(0.05,"Y");
77  tagh_tdc_occ->GetYaxis()->CenterTitle();
78  }
79 
80  if(tagh_adc_occ){
81  tagh_adc_occ->SetBarWidth(0.5);
82  tagh_adc_occ->SetBarOffset(0.5);
83  tagh_adc_occ->SetFillColor(kGreen);
84  tagh_adc_occ->SetStats(0);
85  tagh_adc_occ->SetTitle("TAGH column occupancy");
86  tagh_adc_occ->SetXTitle("Column number");
87  tagh_adc_occ->SetYTitle("fADC/TDC occupancy");
88  tagh_adc_occ->SetTitleSize(0.05,"X");
89  tagh_adc_occ->GetXaxis()->CenterTitle();
90  tagh_adc_occ->SetTitleSize(0.05,"Y");
91  tagh_adc_occ->GetYaxis()->CenterTitle();
92  }
93 
94  legend_sa->AddEntry(tagh_adc_occ,"fADC","f");
95  legend_na->AddEntry(tagh_tdc_occ,"TDC","f");
96 
97  if(tagm_tdc_occ){
98  tagm_tdc_occ->SetBarWidth(0.5);
99  tagm_tdc_occ->SetBarOffset(0);
100  tagm_tdc_occ->SetFillColor(kMagenta);
101  tagm_tdc_occ->SetStats(0);
102  tagm_tdc_occ->SetTitle("TAGM column occupancy");
103  tagm_tdc_occ->SetXTitle("Column number");
104  tagm_tdc_occ->SetYTitle("fADC/TDC occupancy");
105  tagm_tdc_occ->SetTitleSize(0.05,"X");
106  tagm_tdc_occ->GetXaxis()->CenterTitle();
107  tagm_tdc_occ->SetTitleSize(0.05,"Y");
108  tagm_tdc_occ->GetYaxis()->CenterTitle();
109  }
110 
111  if(tagm_adc_occ){
112  tagm_adc_occ->SetBarWidth(0.5);
113  tagm_adc_occ->SetBarOffset(0.5);
114  tagm_adc_occ->SetFillColor(kBlue);
115  tagm_adc_occ->SetStats(0);
116  tagm_adc_occ->SetTitle("TAGM column occupancy");
117  tagm_adc_occ->SetXTitle("Column number");
118  tagm_adc_occ->SetYTitle("fADC/TDC occupancy");
119  tagm_adc_occ->SetTitleSize(0.05,"X");
120  tagm_adc_occ->GetXaxis()->CenterTitle();
121  tagm_adc_occ->SetTitleSize(0.05,"Y");
122  tagm_adc_occ->GetYaxis()->CenterTitle();
123  }
124 
125  legend_s->AddEntry(tagm_adc_occ,"fADC","f");
126  legend_n->AddEntry(tagm_tdc_occ,"TDC","f");
127 
128  char nevents_str[256];
129  sprintf(nevents_str,"%0.0f events", Nevents);
130  TLatex lat;
131  lat.SetTextAlign(22);
132  lat.SetTextSize(0.035);
133 
134  // Just for testing
135  if(gPad == NULL){
136  TCanvas *c1 = new TCanvas("c1");
137  c1->cd(0);
138  c1->Draw();
139  c1->Update();
140  }
141  if(!gPad) {savedir->cd(); return;}
142 
143  TCanvas *c1 = gPad->GetCanvas();
144  c1->cd(0);
145  c1->Clear();
146 
147  c1->Divide(1,2);
148 
149  // ----------------- TAGM ----------------------
150  TVirtualPad *pad1 = c1->cd(1);
151  pad1->SetTicks();
152  pad1->SetGridy();
153  double ymax = 1.0;
154  if(tagm_adc_occ) ymax = tagm_adc_occ->GetMaximum();
155  if(tagm_tdc_occ){
156  if(tagm_tdc_occ->GetMaximum() > ymax) ymax = tagm_tdc_occ->GetMaximum();
157  }
158  if(tagm_adc_occ){
159  tagm_adc_occ->GetYaxis()->SetRangeUser(0.0, 1.05*ymax);
160  tagm_adc_occ->Draw("BAR");
161  }
162  if(tagm_tdc_occ){
163  tagm_tdc_occ->GetYaxis()->SetRangeUser(0.0, 1.05*ymax);
164  tagm_tdc_occ->Draw( tagm_adc_occ==NULL ? "BAR":"BAR same" );
165  }
166 
167  legend_s->Draw();
168  legend_n->Draw();
169  lat.DrawLatex(85.0, 1.075*ymax, nevents_str);
170 
171  // ----------------- TAGH ----------------------
172  pad1 = c1->cd(2);
173  pad1->SetTicks();
174  pad1->SetGridy();
175  ymax = 1.0;
176  if(tagh_adc_occ) ymax = tagh_adc_occ->GetMaximum();
177  if(tagh_tdc_occ){
178  if(tagh_tdc_occ->GetMaximum() > ymax) ymax = tagh_tdc_occ->GetMaximum();
179  }
180  if(tagh_adc_occ){
181  tagh_adc_occ->GetYaxis()->SetRangeUser(0.0, 1.05*ymax);
182  tagh_adc_occ->Draw("BAR");
183  }
184  if(tagh_tdc_occ){
185  tagh_tdc_occ->GetYaxis()->SetRangeUser(0.0, 1.05*ymax);
186  tagh_tdc_occ->Draw( tagh_adc_occ==NULL ? "BAR":"BAR same" );
187  }
188 
189  legend_sa->Draw();
190  legend_na->Draw();
191  lat.DrawLatex(225.0, 1.075*ymax, nevents_str);
192 
193 }
194 
195 
sprintf(text,"Post KinFit Cut")
TVirtualPad * pad1
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
char nevents_str[256]
Definition: FDC_occupancy.C:45
double Nevents
TDirectory * savedir
Double_t ymax
Definition: bcal_hist_eff.C:91
TDirectory * dir
Definition: bcal_hist_eff.C:31