ATLAS Offline Software
Loading...
Searching...
No Matches
TRTCalib_StrawStatusPlots.cxx File Reference
#include "CxxUtils/checker_macros.h"
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <TNtuple.h>
#include <TFile.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TLatex.h>
#include <TError.h>
#include <TPad.h>

Go to the source code of this file.

Functions

void print (char *figname, TCanvas *c1)
void TRTCalib_StrawStatusReport ()
int main ()

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Function Documentation

◆ main()

int main ( )

Definition at line 479 of file TRTCalib_StrawStatusPlots.cxx.

479 {
481}
void TRTCalib_StrawStatusReport()

◆ print()

void print ( char * figname,
TCanvas * c1 )

Definition at line 26 of file TRTCalib_StrawStatusPlots.cxx.

27{
28
29 char filename[1000];
30 sprintf(filename, "output/%s", figname);
31
32 c1->Print(Form("%s.png", filename));
33 c1->Print(Form("%s.pdf", filename));
34 c1->Print(Form("%s.eps", filename));
35 c1->SaveAs("allPlots.pdf","pdf");
36 c1->Write(Form("%s", filename), TObject::kWriteDelete);
37 printf("Info in <TCanvas::Print>: %s has been saved and added to allPlots.pdf file\n", filename);
38}

◆ TRTCalib_StrawStatusReport()

void TRTCalib_StrawStatusReport ( )

Definition at line 40 of file TRTCalib_StrawStatusPlots.cxx.

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

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 5 of file TRTCalib_StrawStatusPlots.cxx.