ATLAS Offline Software
TRTCalib_StrawStatusPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
6 
7 #include <fstream>
8 #include <sstream>
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <string>
12 #include <iostream>
13 
14 #include <TNtuple.h>
15 #include <TFile.h>
16 #include <TH1F.h>
17 #include <TH2F.h>
18 #include <TStyle.h>
19 #include <TCanvas.h>
20 #include <TLatex.h>
21 #include <TError.h>
22 #include <TPad.h>
23 
24 
25 void print(char *figname, TCanvas *c1)
26 {
27 
28  char filename[1000];
29  sprintf(filename, "output/%s", figname);
30 
31  c1->Print(Form("%s.png", filename));
32  c1->Print(Form("%s.pdf", filename));
33  c1->Print(Form("%s.eps", filename));
34  c1->SaveAs("allPlots.pdf","pdf");
35  c1->Write(Form("%s", filename), TObject::kWriteDelete);
36  printf("Info in <TCanvas::Print>: %s has been saved and added to allPlots.pdf file\n", filename);
37 }
38 
40 
41  // read the content from a default txt file name into an ntuple
42  int run = 0;
43  TNtuple *ntuple = new TNtuple("ntuple", "data", "side:phi:straw:status:hits:occ:htocc:eff:lay");
44  gErrorIgnoreLevel = kWarning;
45 
46  int var[15];
47  double par[5];
48  int count = 0;
49 
50  std::ifstream in;
51  in.open("TRT_StrawStatusReport.txt");
52 
53  while (1)
54  {
55 
56  for (int i = 0; i < 5; i++){
57  in >> var[i];
58  }
59 
60  for (int i = 0; i < 3; i++){
61  in >> par[i];
62  }
63  in >> var[5];
64  if (!in.good()){
65  break;
66  }
67  count++;
68 
69  if (var[0] == 0)
70  {
71  run = var[4];
72  continue;
73  }
74  ntuple->Fill(var[0], var[1], var[2], var[3], var[4], par[0], par[1], par[2] * 100, var[5]);
75  }
76 
77  printf("read %d lines from file\n", count);
78  in.close();
79 
80  // make the efficiency distribution plot
81  TFile* myfile = new TFile("test.HIST.root","RECREATE");
82 
83  TCanvas *c1 = new TCanvas("c1", "This is the canvas test", 1200,800);
84  c1->SetLogy(1);
85  c1->SetTicks(1, 1);
86 
87  // set stat box size
88  gStyle->SetOptStat(10);
89  gStyle->SetStatY(0.98);
90  gStyle->SetStatX(0.9);
91  gStyle->SetStatW(0.15);
92  gStyle->SetStatH(0.1);
93 
94  c1->SaveAs("allPlots.pdf[");
95 
96  std::unique_ptr<TH1F> h1 = std::make_unique<TH1F>("h1", "", 101, 0., 101);
97  ntuple->Project("h1", "eff");
98  h1->GetXaxis()->SetTitle("Straw hit efficiency [%]");
99  h1->GetXaxis()->SetTitleSize(0.04);
100  h1->GetYaxis()->SetTitle("Number of straws");
101  h1->GetYaxis()->SetTitleSize(0.04);
102  h1->Draw();
103 
104  std::unique_ptr<TH1F> h1a = std::make_unique<TH1F>("h1a", "", 101, 0., 101);
105  ntuple->Project("h1a", "eff", "status>0");
106  h1a->SetFillStyle(1001);
107  h1a->SetFillColor(kOrange);
108  h1a->Draw("same");
109 
110  std::unique_ptr<TH1F> h1b = std::make_unique<TH1F>("h1b", "", 101, 0., 101);
111  ntuple->Project("h1b", "eff", "status==42");
112  h1b->SetFillStyle(1001);
113  h1b->SetFillColor(2);
114  h1b->Draw("same");
115 
116  gPad->RedrawAxis();
117 
118 
119  TLatex mytext;
120  mytext.SetTextAlign(21);
121  mytext.SetNDC();
122  mytext.SetTextSize(0.04);
123  mytext.SetTextFont(42);
124  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
125 
126  print(Form("strawHitEfficiency_%d", run), c1);
127 
128  h1.reset();
129  h1a.reset();
130  h1b.reset();
131 
132  // make the HT occupancy distribution plot
133  double htrange = 0.1;
134  std::unique_ptr<TH1F> hh1 = std::make_unique<TH1F>("hh1", "", 100, 0., htrange);
135  ntuple->Project("hh1", "htocc");
136 
137  hh1->GetXaxis()->SetTitle("Straw HT occupancy");
138  hh1->GetXaxis()->SetTitleSize(0.04);
139 
140  hh1->GetYaxis()->SetTitle("Number of straws");
141  hh1->GetYaxis()->SetTitleSize(0.04);
142 
143  hh1->SetBinContent(100, hh1->GetBinContent(100) + hh1->GetBinContent(101));
144  hh1->Draw();
145 
146  std::unique_ptr<TH1F> hh1a = std::make_unique<TH1F>("hh1a", "", 100, 0., htrange);
147  ntuple->Project("hh1a", "htocc", "status>0");
148  hh1a->SetFillStyle(1001);
149  hh1a->SetFillColor(kOrange);
150  hh1a->SetBinContent(100, hh1a->GetBinContent(100) + hh1a->GetBinContent(101));
151  hh1a->Draw("same");
152 
153  std::unique_ptr<TH1F> hh1b = std::make_unique<TH1F>("hh1b", "", 100, 0., htrange);
154  ntuple->Project("hh1b", "htocc", "status==52");
155  hh1b->SetFillStyle(1001);
156  hh1b->SetFillColor(2);
157  hh1b->SetBinContent(100, hh1b->GetBinContent(100) + hh1b->GetBinContent(101));
158  hh1b->Draw("same");
159 
160  gPad->RedrawAxis();
161 
162  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
163 
164  print(Form("strawHToccupancy_%d", run), c1);
165 
166  hh1.reset();
167  hh1a.reset();
168  hh1b.reset();
169 
170  gStyle->SetPalette(1);
171  c1->SetRightMargin(0.2);
172  c1->SetLogy(0);
173 
174  std::unique_ptr<TH1F> h7 = std::make_unique<TH1F>("h7", "", 100, 0, 10000);
175  ntuple->Draw("hits>>h7", "straw>=147&&straw<200&&eff>0.7");
176  double range = h7->GetMean();
177  h7.reset();
178 
179  std::unique_ptr<TH2F> h2 = std::make_unique<TH2F>("h2", "", 110, -0.5, 5481.5, 100, 0., range * 1.2);
180  ntuple->Project("h2", "hits:straw", "status==0");
181 
182  h2->GetXaxis()->SetTitle("Straw index");
183  h2->GetXaxis()->SetTitleSize(0.04);
184 
185  h2->GetYaxis()->SetTitleOffset(1.2);
186  h2->GetYaxis()->SetTitle("Number of hits on track");
187  h2->GetYaxis()->SetTitleSize(0.04);
188 
189  h2->GetZaxis()->SetTitleOffset(1.2);
190  h2->GetZaxis()->SetTitle("Number of straws");
191  h2->GetZaxis()->SetTitleSize(0.04);
192 
193  h2->Draw("colz");
194  ntuple->SetMarkerStyle(20);
195  ntuple->SetMarkerSize(0.8);
196  ntuple->SetMarkerColor(1);
197  ntuple->Draw("hits:straw", "status==52||status==51", "same");
198 
199  TLatex l;
200  l.SetTextSize(0.03);
201  l.DrawLatex(750, range * 1.1, "black points: straws excluded due to low / high HT occupancy");
202  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
203 
204  print(Form("numberOfHitsOnTrack_%d", run), c1);
205  h2.reset();
206 
207 
208 
209 
210  std::unique_ptr<TH2F> hh22 = std::make_unique<TH2F>("hh22", "", 5, -2.5, 2.5, 32, -0.5, 31.5);
211  ntuple->Project("hh22", "phi:side", "status>1");
212 
213  hh22->GetXaxis()->SetTitle("Detector side (athena numbering) Z");
214  hh22->GetXaxis()->SetTitleSize(0.04);
215 
216  hh22->GetYaxis()->SetTitleOffset(0.8);
217  hh22->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
218  hh22->GetYaxis()->SetTitleSize(0.04);
219 
220  hh22->GetZaxis()->SetTitle("Number of additional excluded straws");
221  hh22->GetZaxis()->SetTitleSize(0.04);
222 
223  hh22->Draw("colz");
224 
225  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
226  mytext.DrawLatex(0.23, 0.91, "Endcap || Barrel");
227  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
228  mytext.DrawLatex(0.67, 0.91, "Barrel || Endcap");
229 
230  print(Form("additionalExcludedStraws_%d", run), c1);
231  hh22.reset();
232 
233  std::unique_ptr<TH2F> h3 = std::make_unique<TH2F>("h3", "", 7, -3.5, 3.5, 32, -0.5, 31.5);
234  ntuple->Project("h3", "phi:side*(lay+1)/abs(side)", "status>1 && abs(side)==1");
235  h3->GetXaxis()->SetTitle("Barrel Module (athena numbering) Z");
236  h3->GetXaxis()->SetTitleSize(0.04);
237 
238  h3->GetYaxis()->SetTitleOffset(0.8);
239  h3->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
240  h3->GetYaxis()->SetTitleSize(0.04);
241 
242  h3->GetZaxis()->SetTitle("Number of additional excluded straws");
243  h3->GetZaxis()->SetTitleSize(0.04);
244 
245  h3->Draw("colz text");
246 
247  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
248  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
249 
250  print(Form("additionalExcludedStrawsBarrel_%d", run), c1);
251  h3.reset();
252 
253  std::unique_ptr<TH2F> h4 = std::make_unique<TH2F>("h4", "", 29, -14.5, 14.5, 32, -0.5, 31.5);
254  ntuple->Project("h4", "phi:side*(lay+1)/abs(side)", "status>1 && abs(side)==2");
255 
256  h4->GetXaxis()->SetTitle("Endcap Wheel (athena numbering) Z");
257  h4->GetXaxis()->SetTitleSize(0.04);
258 
259  h4->GetYaxis()->SetTitleOffset(0.8);
260  h4->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
261  h4->GetYaxis()->SetTitleSize(0.04);
262 
263  h4->GetZaxis()->SetTitle("Number of additional excluded straws");
264  h4->GetZaxis()->SetTitleSize(0.04);
265 
266  h4->Draw("colz text");
267 
268  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
269  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
270 
271  print(Form("additionalExcludedStrawsEndcap_%d", run), c1);
272  h4.reset();
273 
274  std::unique_ptr<TH2F> h5 = std::make_unique<TH2F>("h5", "", 7, -3.5, 3.5, 32, -0.5, 31.5);
275  ntuple->Project("h5", "phi:side*(lay+1)/abs(side)", "status == 12 && abs(side)==1");
276  if (h5->GetEntries() != 0)
277  {
278 
279  h5->GetXaxis()->SetTitle("Barrel Module (athena numbering) Z");
280  h5->GetXaxis()->SetTitleSize(0.04);
281 
282  h5->GetYaxis()->SetTitleOffset(0.8);
283  h5->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
284  h5->GetYaxis()->SetTitleSize(0.04);
285 
286  h5->GetZaxis()->SetTitle("Number of additional DEAD excluded straws");
287  h5->GetZaxis()->SetTitleSize(0.04);
288 
289  h5->Draw("colz text");
290 
291  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
292  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
293 
294  print(Form("additionalExcludedDEADStrawsBarrel_%d", run), c1);
295  }
296  h5.reset();
297 
298  std::unique_ptr<TH2F> h6 = std::make_unique<TH2F>("h6", "", 29, -14.5, 14.5, 32, -0.5, 31.5);
299  ntuple->Project("h6", "phi:side*(lay+1)/abs(side)", "status == 12 && abs(side)==2");
300  if (h6->GetEntries() != 0)
301  {
302 
303  h6->GetXaxis()->SetTitle("Endcap Module (athena numbering) Z");
304  h6->GetXaxis()->SetTitleSize(0.04);
305 
306  h6->GetYaxis()->SetTitleOffset(0.8);
307  h6->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
308  h6->GetYaxis()->SetTitleSize(0.04);
309 
310  h6->GetZaxis()->SetTitle("Number of additional DEAD excluded straws");
311  h6->GetZaxis()->SetTitleSize(0.04);
312 
313  h6->Draw("colz text");
314 
315  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
316  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
317 
318  print(Form("additionalExcludedDEADStrawsEndcap_%d", run), c1);
319  }
320  h6.reset();
321 
322  std::unique_ptr<TH2F> h55 = std::make_unique<TH2F>("h55", "", 7, -3.5, 3.5, 32, -0.5, 31.5);
323  ntuple->Project("h55", "phi:side*(lay+1)/abs(side)", "status == 11 && abs(side)==1");
324  if (h55->GetEntries() != 0)
325  {
326 
327  h55->GetXaxis()->SetTitle("Barrel Module (athena numbering) Z");
328  h55->GetXaxis()->SetTitleSize(0.04);
329 
330  h55->GetYaxis()->SetTitleOffset(0.8);
331  h55->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
332  h55->GetYaxis()->SetTitleSize(0.04);
333 
334  h55->GetZaxis()->SetTitle("Number of additional NOISY excluded straws");
335  h55->GetZaxis()->SetTitleSize(0.04);
336 
337  h55->Draw("colz text");
338 
339  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
340  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
341 
342  print(Form("additionalExcludedNOISYStrawsBarrel_%d", run), c1);
343  }
344  h55.reset();
345 
346 
347  std::unique_ptr<TH2F> h66 = std::make_unique<TH2F>("h66", "", 29, -14.5, 14.5, 32, -0.5, 31.5);
348  ntuple->Project("h66", "phi:side*(lay+1)/abs(side)", "status == 11 && abs(side)==2");
349  if (h66->GetEntries() != 0)
350  {
351 
352  h66->GetXaxis()->SetTitle("Endcap Module (athena numbering) Z");
353  h66->GetXaxis()->SetTitleSize(0.04);
354 
355  h66->GetYaxis()->SetTitleOffset(0.8);
356  h66->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
357  h66->GetYaxis()->SetTitleSize(0.04);
358 
359  h66->GetZaxis()->SetTitle("Number of additional NOISY excluded straws");
360  h66->GetZaxis()->SetTitleSize(0.04);
361 
362  h66->Draw("colz text");
363 
364  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
365  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
366 
367  print(Form("additionalExcludedNOISYStrawsEndcap_%d", run), c1);
368  }
369  h66.reset();
370 
371  std::unique_ptr<TH2F> h555 = std::make_unique<TH2F>("h555", "", 7, -3.5, 3.5, 32, -0.5, 31.5);
372  ntuple->Project("h555", "phi:side*(lay+1)/abs(side)", "status == 42 && abs(side)==1");
373  if (h555->GetEntries() != 0)
374  {
375 
376  h555->GetXaxis()->SetTitle("Barrel Module (athena numbering) Z");
377  h555->GetXaxis()->SetTitleSize(0.04);
378 
379  h555->GetYaxis()->SetTitleOffset(0.8);
380  h555->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
381  h555->GetYaxis()->SetTitleSize(0.04);
382 
383  h555->GetZaxis()->SetTitle("Number of additional LowEff excluded straws");
384  h555->GetZaxis()->SetTitleSize(0.04);
385 
386  h555->Draw("colz text");
387 
388  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
389  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
390 
391  print(Form("additionalExcludedLowEffStrawsBarrel_%d", run), c1);
392  }
393  h555.reset();
394 
395  std::unique_ptr<TH2F> h666 = std::make_unique<TH2F>("h666", "", 29, -14.5, 14.5, 32, -0.5, 31.5);
396  ntuple->Project("h666", "phi:side*(lay+1)/abs(side)", "status == 42 && abs(side)==2");
397  if (h666->GetEntries() != 0)
398  {
399 
400  h666->GetXaxis()->SetTitle("Endcap Module (athena numbering) Z");
401  h666->GetXaxis()->SetTitleSize(0.04);
402 
403  h666->GetYaxis()->SetTitleOffset(0.8);
404  h666->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
405  h666->GetYaxis()->SetTitleSize(0.04);
406 
407  h666->GetZaxis()->SetTitle("Number of additional LowEff excluded straws");
408  h666->GetZaxis()->SetTitleSize(0.04);
409 
410  h666->Draw("colz text");
411 
412  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
413  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
414 
415  print(Form("additionalExcludedLowEffStrawsEndcap_%d", run), c1);
416  }
417  h666.reset();
418 
419  std::unique_ptr<TH2F> h5555 = std::make_unique<TH2F>("h5555", "", 7, -3.5, 3.5, 32, -0.5, 31.5);
420  ntuple->Project("h5555", "phi:side*(lay+1)/abs(side)", "status > 50 && abs(side)==1");
421  if (h5555->GetEntries() != 0)
422  {
423 
424  h5555->GetXaxis()->SetTitle("Barrel Module (athena numbering) Z");
425  h5555->GetXaxis()->SetTitleSize(0.04);
426 
427  h5555->GetYaxis()->SetTitleOffset(0.8);
428  h5555->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
429  h5555->GetYaxis()->SetTitleSize(0.04);
430 
431  h5555->GetZaxis()->SetTitle("Number of additional BadHT excluded straws");
432  h5555->GetZaxis()->SetTitleSize(0.04);
433 
434  h5555->Draw("colz text");
435 
436  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
437  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
438 
439  print(Form("additionalExcludedBadHTStrawsBarrel_%d", run), c1);
440  }
441  h5555.reset();
442 
443  std::unique_ptr<TH2F> h6666 = std::make_unique<TH2F>("h6666", "", 29, -14.5, 14.5, 32, -0.5, 31.5);
444  ntuple->Project("h6666", "phi:side*(lay+1)/abs(side)", "status > 50 && abs(side)==2");
445  if (h6666->GetEntries() != 0)
446  {
447 
448  h6666->GetXaxis()->SetTitle("Endcap Module (athena numbering) Z");
449  h6666->GetXaxis()->SetTitleSize(0.04);
450 
451  h6666->GetYaxis()->SetTitleOffset(0.8);
452  h6666->GetYaxis()->SetTitle("Detector #phi (athena 0-31 range)");
453  h6666->GetYaxis()->SetTitleSize(0.04);
454 
455  h6666->GetZaxis()->SetTitle("Number of additional BadHT excluded straws");
456  h6666->GetZaxis()->SetTitleSize(0.04);
457 
458  h6666->Draw("colz text");
459 
460  mytext.DrawLatex(0.10, 0.02, Form("Run %d", run));
461  mytext.DrawLatex(0.45, 0.91, "#leftarrow C || A #rightarrow");
462 
463  print(Form("additionalExcludedBadHTStrawsEndcap_%d", run), c1);
464  }
465  h6666.reset();
466 
467  c1->SaveAs("allPlots.pdf]");
468  myfile->Write(0,TObject::kOverwrite);
469  myfile->Close();
470 
471  //delete new'ed objects
472  delete c1;
473  delete myfile;
474  return;
475 
476 }
477 
478 int main(){
480 }
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
extractSporadic.c1
c1
Definition: extractSporadic.py:134
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
lumiFormat.i
int i
Definition: lumiFormat.py:85
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
run
Definition: run.py:1
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
TRTCalib_StrawStatusReport
void TRTCalib_StrawStatusReport()
Definition: TRTCalib_StrawStatusPlots.cxx:39
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: TRTCalib_StrawStatusPlots.cxx:5
gErrorIgnoreLevel
int gErrorIgnoreLevel
main
int main()
Definition: TRTCalib_StrawStatusPlots.cxx:478
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
checker_macros.h
Define macros for attributes used to control the static checker.