Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HistMacro_Trigger.C
Go to the documentation of this file.
1 //
2 // NOTE: The L1GTPRate histo now comes from the
3 // occupancy_online plugin since it should see many
4 // more sync events.
5 //
6 // Guidance: --------------------------------------------
7 //
8 // This page includes a mixture of low-level and high-level
9 // information. Values in the table regarding numbers of
10 // triggers can be highly sensitive to calibration. They
11 // also may be slightly different between Amporphous and
12 // diamond radiators. If the values differ by more than
13 // around 20% from the reference, try hitting the "Reset"
14 // button to see if they improve with new statistics.
15 //
16 // If you have concerns about the values in the table or
17 // any of the plots looking significantly different than
18 // the reference, please contact one of:
19 //
20 // Run Coordinator: (757) 383-5542
21 //
22 // David Lawrence: x5567 (office)
23 // 746-6697 (cell)
24 // 595-1302 (home)
25 //
26 // End Guidance: ----------------------------------------
27 //
28 // hnamepath: /occupancy/L1GTPRate
29 // hnamepath: /occupancy/L1livetime
30 // hnamepath: /highlevel/BCALVsFCAL_TrigBit1
31 // hnamepath: /highlevel/L1bits_gtp
32 // hnamepath: /highlevel/L1bits_fp
33 // hnamepath: /highlevel/NumTriggers
34 //
35 // e-mail: davidl@jlab.org
36 // e-mail: staylor@jlab.org
37 // e-mail: sdobbs@jlab.org
38 // e-mail: tbritton@jlab.org
39 //
40 
41 {
42  TDirectory *locTopDirectory = gDirectory;
43 
44 
45  // Grab remaining histos from highlevel directory
46  TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("highlevel");
47  if(!locDirectory)
48  return;
49  locDirectory->cd();
50 
51  TH2* locHist_BCALVsFCAL_TrigBit1 = (TH2*)gDirectory->Get("BCALVsFCAL_TrigBit1");
52  TH1* locHist_L1bits_gtp = (TH1*)gDirectory->Get("L1bits_gtp");
53  TH1* locHist_L1bits_fp = (TH1*)gDirectory->Get("L1bits_fp");
54  TH2* locHist_NumTriggers = (TH2*)gDirectory->Get("NumTriggers");
55 
56  // Grab a couple of histos from occupancy directory
57  locDirectory = (TDirectory*)locTopDirectory->FindObjectAny("occupancy");
58  TH2* locHist_L1GTPRate = NULL;
59  TH1* locHist_L1livetime = NULL;
60  if(locDirectory){
61  locHist_L1GTPRate = (TH2*)locDirectory->Get("L1GTPRate");
62  locHist_L1livetime = (TH1*)locDirectory->Get("L1livetime");
63  }
64 
65  //Get/Make Canvas
66  TCanvas *locCanvas = NULL;
67  if(TVirtualPad::Pad() == NULL)
68  locCanvas = new TCanvas("Kinematics", "Kinematics", 1200, 900); //for testing
69  else
70  locCanvas = gPad->GetCanvas();
71  locCanvas->Divide(3, 1);
72 
73  TLatex latex;
74  latex.SetTextSize(0.04);
75  char str[256];
76 
77  // -------------- Left --------------
78  locCanvas->cd(1);
79  gPad->SetTicks();
80  gPad->SetGrid();
81  if(locHist_L1GTPRate != NULL)
82  {
83  locHist_L1GTPRate->GetXaxis()->SetTitleSize(0.05);
84  locHist_L1GTPRate->GetYaxis()->SetTitleSize(0.04);
85  locHist_L1GTPRate->GetXaxis()->SetLabelSize(0.05);
86  locHist_L1GTPRate->GetYaxis()->SetLabelSize(0.05);
87  locHist_L1GTPRate->SetStats(0);
88  locHist_L1GTPRate->Draw("colz");
89 
90  sprintf(str, "from %d sync events", (uint32_t)locHist_L1GTPRate->GetEntries()/8);
91  latex.DrawLatex(1.0, 101.0, str);
92  }
93 
94  // -------------- Middle --------------
95 
96  // Hadronic trigger rate stats
97  locCanvas->cd(0);
98  if(locHist_NumTriggers){
99  TPad *pad = (TPad*)gDirectory->FindObjectAny("trigpad1");
100  if(!pad) pad = new TPad("trigpad1", "", 0.33, 0.45, 0.66, 0.95);
101  pad->Draw();
102  pad->cd();
103 
104  TLatex latex;
105  latex.SetTextSize(0.05);
106  latex.SetTextAlign(31);
107 
108  latex.DrawLatex(0.5, 0.9, "trig 1");
109  latex.DrawLatex(0.7, 0.9, "trig 3");
110  latex.DrawLatex(0.9, 0.9, "trig 4");
111 
112  latex.DrawLatex(0.3, 0.70, "Triggers");
113 
114  latex.DrawLatex(0.3, 0.50, "Hadronic");
115  latex.DrawLatex(0.3, 0.45, "triggers");
116 
117  latex.DrawLatex(0.3, 0.30, "Hadronic");
118  latex.DrawLatex(0.3, 0.25, "triggers in");
119  latex.DrawLatex(0.3, 0.20, "coh. peak");
120 
121  TLine line;
122  line.SetLineWidth(3.0);
123  line.SetLineColor(kGray+2);
124  line.DrawLine(0.05, 0.40, 0.95, 0.40);
125  line.DrawLine(0.05, 0.60, 0.95, 0.60);
126  line.DrawLine(0.05, 0.80, 0.95, 0.80);
127  line.DrawLine(0.55, 0.15, 0.55, 0.95);
128  line.DrawLine(0.75, 0.15, 0.75, 0.95);
129 
130  latex.SetTextSize(0.04);
131  latex.SetTextAlign(21);
132  char str[256];
133  TH2* h = locHist_NumTriggers;
134 
135  // trig 1
136  sprintf(str, "%4.3g", h->GetBinContent(1,1));
137  latex.DrawLatex(0.45, 0.725, str);
138  sprintf(str, "%4.3g", h->GetBinContent(1,3));
139  latex.DrawLatex(0.45, 0.500, str);
140  sprintf(str, "%4.3g", h->GetBinContent(1,4));
141  latex.DrawLatex(0.45, 0.275, str);
142 
143  // trig 3
144  sprintf(str, "%4.3g", h->GetBinContent(3,1));
145  latex.DrawLatex(0.65, 0.725, str);
146  sprintf(str, "%4.3g", h->GetBinContent(3,3));
147  latex.DrawLatex(0.65, 0.500, str);
148  sprintf(str, "%4.3g", h->GetBinContent(3,4));
149  latex.DrawLatex(0.65, 0.275, str);
150 
151  // trig 4
152  sprintf(str, "%4.3g", h->GetBinContent(4,1));
153  latex.DrawLatex(0.85, 0.725, str);
154  sprintf(str, "%4.3g", h->GetBinContent(4,3));
155  latex.DrawLatex(0.85, 0.500, str);
156  sprintf(str, "%4.3g", h->GetBinContent(4,4));
157  latex.DrawLatex(0.85, 0.275, str);
158 
159  latex.SetTextSize(0.05);
160  latex.SetTextColor(kRed);
161 
162  TLatex latex2;
163  latex2.SetTextSize(0.035);
164  latex2.SetTextAlign(21);
165  latex2.SetTextColor(kRed+2);
166 
167  double all_trigs = h->GetBinContent(33,1);
168 
169  // trig 1
170  double Ntrig1 = h->GetBinContent(1,1);
171  sprintf(str, "(%4.1f%%)", Ntrig1/all_trigs*100.0);
172  latex.DrawLatex(0.45, 0.675, str);
173  latex2.DrawLatex(0.45, 0.635, "of all trigs");
174  sprintf(str, "(%4.1f%%)", h->GetBinContent(1,3)/Ntrig1*100.0);
175  latex.DrawLatex(0.45, 0.450, str);
176  latex2.DrawLatex(0.45, 0.410, "of trig 1's");
177  sprintf(str, "(%4.1f%%)", h->GetBinContent(1,4)/Ntrig1*100.0);
178  latex.DrawLatex(0.45, 0.225, str);
179  latex2.DrawLatex(0.45, 0.185, "of trig 1's");
180 
181  // trig 3
182  double Ntrig3 = h->GetBinContent(3,1);
183  sprintf(str, "(%4.1f%%)", Ntrig3/all_trigs*100.0);
184  latex.DrawLatex(0.65, 0.675, str);
185  latex2.DrawLatex(0.65, 0.635, "of all trigs");
186  sprintf(str, "(%4.1f%%)", h->GetBinContent(3,3)/Ntrig3*100.0);
187  latex.DrawLatex(0.65, 0.450, str);
188  latex2.DrawLatex(0.65, 0.410, "of trig 3's");
189  sprintf(str, "(%4.1f%%)", h->GetBinContent(3,4)/Ntrig3*100.0);
190  latex.DrawLatex(0.65, 0.225, str);
191  latex2.DrawLatex(0.65, 0.185, "of trig 3's");
192 
193  // trig 4
194  double Ntrig4 = h->GetBinContent(4,1);
195  sprintf(str, "(%4.1f%%)", Ntrig4/all_trigs*100.0);
196  latex.DrawLatex(0.85, 0.675, str);
197  latex2.DrawLatex(0.85, 0.635, "of all trigs");
198  sprintf(str, "(%4.1f%%)", h->GetBinContent(4,3)/Ntrig4*100.0);
199  latex.DrawLatex(0.85, 0.450, str);
200  latex2.DrawLatex(0.85, 0.410, "of trig 4's");
201  sprintf(str, "(%4.1f%%)", h->GetBinContent(4,4)/Ntrig4*100.0);
202  latex.DrawLatex(0.85, 0.225, str);
203  latex2.DrawLatex(0.85, 0.185, "of trig 4's");
204 
205  }
206 
207  // BCAL vs. FCAL for Trig bit 1
208  locCanvas->cd(0);
209  if(locHist_BCALVsFCAL_TrigBit1 != NULL)
210  {
211  TPad *pad = (TPad*)gDirectory->FindObjectAny("trigpad2");
212  if(!pad) pad = new TPad("trigpad2", "", 0.33, 0.0, 0.66, 0.5);
213  pad->Draw();
214  pad->cd();
215 
216  gPad->SetTicks();
217  gPad->SetGrid();
218  gPad->SetLeftMargin(0.2);
219 
220  locHist_BCALVsFCAL_TrigBit1->GetXaxis()->SetTitleSize(0.05);
221  locHist_BCALVsFCAL_TrigBit1->GetYaxis()->SetTitleSize(0.04);
222  locHist_BCALVsFCAL_TrigBit1->SetStats(0);
223  locHist_BCALVsFCAL_TrigBit1->GetYaxis()->SetTitleOffset(2.0);
224  locHist_BCALVsFCAL_TrigBit1->Draw("colz");
225 
226  sprintf(str, "%d entries", (uint32_t)locHist_BCALVsFCAL_TrigBit1->GetEntries());
227  latex.DrawLatex(500.0, 50000.0*1.01, str);
228 
229  gPad->SetLogz();
230  gPad->Update();
231  }
232 
233  // -------------- Right --------------
234  locCanvas->cd(0);
235  if(locHist_L1bits_gtp!=NULL && locHist_L1bits_fp!=NULL)
236  {
237  TPad *pad = (TPad*)gDirectory->FindObjectAny("trigpad3");
238  if(!pad) pad = new TPad("trigpad1", "", 0.66, 0.5, 1.0, 1.0);
239  pad->Draw();
240  pad->cd();
241 
242  gPad->SetTicks();
243  gPad->SetGrid();
244 
245  double max_gtp = locHist_L1bits_gtp->GetMaximum();
246  double max_fp = locHist_L1bits_fp->GetMaximum();
247  double max = (max_gtp>max_fp) ? max_gtp:max_fp;
248 
249  locHist_L1bits_gtp->GetYaxis()->SetRangeUser(1.0, max*2.0);
250  locHist_L1bits_gtp->GetXaxis()->SetRangeUser(0.0, 17.0);
251 
252  locHist_L1bits_gtp->GetXaxis()->SetTitleSize(0.05);
253  locHist_L1bits_gtp->GetYaxis()->SetTitleSize(0.04);
254  locHist_L1bits_gtp->SetStats(0);
255 
256  locHist_L1bits_gtp->SetLineColor(kBlack);
257  locHist_L1bits_gtp->SetBarOffset(0.15);
258  locHist_L1bits_gtp->SetBarWidth(0.35);
259  locHist_L1bits_fp->SetBarOffset(0.5);
260  locHist_L1bits_fp->SetBarWidth(0.35);
261 
262  locHist_L1bits_gtp->SetFillColor(kOrange);
263  locHist_L1bits_fp->SetFillColor(kRed-4);
264 
265  locHist_L1bits_gtp->Draw("bar");
266  locHist_L1bits_fp->Draw("bar same");
267 
268  TLegend *legend_gtp = new TLegend(0.5,0.85,0.7,0.9);
269  TLegend *legend_fp = new TLegend(0.7,0.85,0.9,0.9);
270  legend_gtp->AddEntry(locHist_L1bits_gtp,"GTP","f");
271  legend_fp->AddEntry(locHist_L1bits_fp,"FP","f");
272  legend_gtp->Draw();
273  legend_fp->Draw();
274 
275  gPad->SetLogy();
276  gPad->Update();
277  }
278 
279  locCanvas->cd(0);
280  if(locHist_L1livetime!=NULL)
281  {
282  TPad *pad = (TPad*)gDirectory->FindObjectAny("trigpad4");
283  if(!pad) pad = new TPad("trigpad4", "", 0.66, 0.0, 1.0, 0.5);
284  pad->Draw();
285  pad->cd();
286 
287  gPad->SetTicks();
288  gPad->SetGrid();
289 
290  locHist_L1livetime->SetLineColor(kGreen-3);
291  locHist_L1livetime->SetFillColor(kGreen);
292  locHist_L1livetime->SetFillStyle(3001);
293  locHist_L1livetime->Draw();
294  gPad->SetLogy();
295  gPad->Update();
296 
297  // Move stats box
298  TPaveStats *ps = (TPaveStats*)locHist_L1livetime->FindObject("stats");
299  if(ps){
300  ps->SetX1NDC(0.15);
301  ps->SetX2NDC(0.45);
302  ps->SetY1NDC(0.65);
303  ps->SetY2NDC(0.85);
304  ps->Draw();
305  }
306  }
307 }
char str[256]
TPad * pad
Definition: psc_mon.C:73
sprintf(text,"Post KinFit Cut")
TH2 * locHist_NumTriggers
TH2 * locHist_L1GTPRate
TH1 * locHist_L1bits_gtp
TDirectory * locTopDirectory
Definition: HistMacro_p4pi.C:2
TDirectory * locDirectory
TH1 * locHist_L1livetime
TH1 * locHist_L1bits_fp
TCanvas * locCanvas
TH2 * locHist_BCALVsFCAL_TrigBit1