Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawTPCDataStreamEmulator.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrawTPCDataStreamEmulator.C
1 
2 #include <TFile.h>
3 #include <TGraphAsymmErrors.h>
4 #include <TGraphErrors.h>
5 #include <TH2.h>
6 #include <TLatex.h>
7 #include <TLegend.h>
8 #include <TString.h>
9 #include <TTree.h>
10 #include <cassert>
11 #include <cmath>
12 #include "SaveCanvas.C"
13 #include "sPhenixStyle.C"
14 
15 TFile *_file0 = NULL;
16 TString description;
17 
18 void DataRate()
19 {
20  assert(_file0);
21  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
22  assert(hNormalization);
23 
24  TCanvas *c1 = new TCanvas("DataRate", "DataRate", 1700, 960);
25  c1->Divide(1, 1);
26  int idx = 1;
27  TPad *p;
28 
29  p = (TPad *) c1->cd(idx++);
30  c1->Update();
31  p->SetRightMargin(.15);
32  // p->SetLogy();
33 
34  TH1 *hDataSize = (TH1 *) _file0->GetObjectChecked("hDataSize", "TH1");
35  assert(hDataSize);
36 
37  TH1 *h = (TH1 *) hDataSize->DrawClone();
38  h->Sumw2();
39  h->Scale(1. / hNormalization->GetBinContent(1));
40  h->SetTitle(";TPC Event Size [Byte];Probability / bin");
41 
42  // h->Rebin(100);
43  // h->GetXaxis()->SetRangeUser(0,5e6);
44  h->Rebin(100);
45  h->GetXaxis()->SetRangeUser(0, 20e6);
46 
47  h->GetYaxis()->SetRangeUser(0, .05);
48 
49  TLegend *leg = new TLegend(.2, .7, .8, .92);
50  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
51  leg->AddEntry("", description, "");
52  leg->AddEntry("", Form("<Event size> = %.1f MB (before compression)", hDataSize->GetMean() / 1e6), "");
53  leg->AddEntry("", Form("Data rate = %.0f Gbps (15 kHz trig., LZO compression)", hDataSize->GetMean() * 8 * .6 * 15e3 / 1e9), "");
54  leg->Draw();
55 
56  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
57 }
58 
59 TH1 *MakeCDF(TH1 *h)
60 {
61  assert(h);
62 
63  TH1 *hCDF = (TH1 *) h->Clone(TString("CDF") + h->GetName());
64  hCDF->SetDirectory(NULL);
65 
66  double integral = 0;
67 
68  for (int bin = h->GetNbinsX() + 1; bin >= 0; --bin)
69  {
70  integral += h->GetBinContent(bin);
71  hCDF->SetBinContent(bin, integral);
72  }
73 
74  for (int bin = h->GetNbinsX() + 1; bin >= 0; --bin)
75  {
76  hCDF->SetBinContent(bin, hCDF->GetBinContent(bin) / integral);
77  hCDF->SetBinError(bin, 0);
78  }
79 
80  return hCDF;
81 }
82 
84 {
85  assert(_file0);
86  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
87  assert(hNormalization);
88 
89  TH2 *hFEEDataSize = (TH2 *) _file0->GetObjectChecked("hFEEDataSize", "TH2");
90  assert(hFEEDataSize);
91 
92  Color_t linecolors[] = {kBlack, kRed + 2, kBlue + 2, kGreen + 2, kBlack};
93 
94  // Save raw
95  TCanvas *c = new TCanvas("FEEDataSize_raw", "FEEDataSize_raw", 1900, 760);
96  c->Divide(3, 1);
97  int idx = 1;
98  TPad *p;
99  for (int module = 1; module <= 3; module++)
100  {
101  p = (TPad *) c->cd(idx++);
102  c->Update();
103  p->SetRightMargin(.15);
104 
105  TString name = Form("hFEEDataSize_module%d", module);
106 
107  (TH1 *) hFEEDataSize->ProjectionX(name, module, module)->DrawClone("");
108  }
109  SaveCanvas(c, TString(_file0->GetName()) + TString(c->GetName()), kTRUE);
110 
111  // Plot
112  TCanvas *c1 = new TCanvas("FEEDataSize", "FEEDataSize", 1900, 760);
113  c1->Divide(2, 1);
114  idx = 1;
115 
116  p = (TPad *) c1->cd(idx++);
117  c1->Update();
118  p->SetRightMargin(.15);
119  TH1 *frame = p->DrawFrame(0, 0, 50e3, .8e6);
120  frame->SetTitle(";TPC FELIX Per-Drift Data Size [Byte];Count");
121  frame->GetXaxis()->SetNdivisions(15, 5, 1, true);
122 
123  TLegend *leg = new TLegend(.2, .6, .85, .92);
124 
125  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
126  leg->AddEntry("", description, "");
127 
128  p = (TPad *) c1->cd(idx++);
129  c1->Update();
130  p->SetRightMargin(.15);
131  frame = p->DrawFrame(0, 1e-5, 50e3, 1);
132  frame->SetTitle(";TPC FELIX Per-Drift Data Size [Byte];CCDF");
133  frame->GetXaxis()->SetNdivisions(15, 5, 1, true);
134  p->SetLogy();
135 
136  for (int module = 1; module <= 3; module++)
137  {
138  p = (TPad *) c1->cd(1);
139  c1->Update();
140 
141  TString name = Form("hFEEDataSize_module%d", module);
142 
143  TH1 *h_FEE_raw = (TH1 *) hFEEDataSize->ProjectionX(name, module, module);
144  TH1 *h_FEE = (TH1 *) h_FEE_raw->DrawClone("same");
145  h_FEE->Sumw2();
146  h_FEE->Rebin(100);
147 
148  h_FEE->SetLineColor(linecolors[module]);
149  h_FEE->SetMarkerColor(linecolors[module]);
150 
151  leg->AddEntry(h_FEE, Form("Module%d: <Data/Drift/FEE> = %.1f kB", module, h_FEE->GetMean() / 1e3), "lp");
152 
153  p = (TPad *) c1->cd(2);
154  c1->Update();
155 
156  h_FEE = MakeCDF(h_FEE_raw);
157  h_FEE->SetLineColor(linecolors[module]);
158  h_FEE->Draw("same");
159  h_FEE->GetXaxis()->SetRangeUser(0, 1e6);
160  }
161 
162  p = (TPad *) c1->cd(1);
163  leg->Draw();
164 
165  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
166 }
167 
169 {
170  assert(_file0);
171  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
172  assert(hNormalization);
173 
174  TH1 *hSectorDataSize = (TH1 *) _file0->GetObjectChecked("hSectorDataSize", "TH1");
175  assert(hSectorDataSize);
176 
177  // Save raw
178  TCanvas *c = new TCanvas("SectorDataSize_raw", "SectorDataSize_raw", 1000, 760);
179  TH1 *h = (TH1 *) hSectorDataSize->DrawClone();
180  SaveCanvas(c, TString(_file0->GetName()) + TString(c->GetName()), kTRUE);
181 
182  //plot
183  TCanvas *c1 = new TCanvas("SectorDataSize", "SectorDataSize", 2000, 760);
184  c1->Divide(2, 1);
185  int idx = 1;
186  TPad *p;
187 
188  p = (TPad *) c1->cd(idx++);
189  c1->Update();
190  p->SetRightMargin(.15);
191  // p->SetLogy();
192 
193  h = (TH1 *) hSectorDataSize->DrawClone();
194  h->Sumw2();
195  // h->Scale(1. / hNormalization->GetBinContent(1) / 24);
196  h->SetTitle(";TPC FELIX Per-DriftWindow Data Size [Byte];Count");
197 
198  h->Rebin(100);
199  // h->GetXaxis()->SetRangeUser(0,5e6);
200  // h->Rebin(20);
201  h->GetXaxis()->SetRangeUser(0, 2e6);
202 
203  // h->GetYaxis()->SetRangeUser(0, .5);
204 
205  TLegend *leg = new TLegend(.35, .7, .85, .92);
206  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
207  leg->AddEntry("", description, "");
208  leg->AddEntry("", Form("<Data/Drift Window/FELIX> = %.2f MB", hSectorDataSize->GetMean() / 1e6), "");
209  leg->Draw();
210 
211  p = (TPad *) c1->cd(idx++);
212  c1->Update();
213  p->SetRightMargin(.15);
214  p->SetLogy();
215 
216  h = MakeCDF(hSectorDataSize);
217  h->Draw();
218  h->SetTitle(";TPC FELIX Per-Drift Data Size [Byte];CCDF");
219 
220  h->GetXaxis()->SetRangeUser(0, 1e6);
221 
222  // h->GetYaxis()->SetRangeUser(0, .5);
223 
224  // TLegend *leg = new TLegend(.2, .7, .8, .92);
225  // leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
226  // leg->AddEntry("", description, "");
227  // leg->AddEntry("", Form("<Event size> = %.1f MB (before compression)", hDataSize->GetMean() / 1e6), "");
228  // leg->AddEntry("", Form("Data rate = %.0f Gbps (15 kHz trig., LZO compression)", hDataSize->GetMean() * 8 * .6 * 15e3 / 1e9), "");
229  // leg->Draw();
230 
231  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
232 }
233 
234 void dNdeta()
235 {
236  assert(_file0);
237  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
238  assert(hNormalization);
239 
240  TCanvas *c1 = new TCanvas("dNdeta", "dNdeta", 1800, 960);
241  c1->Divide(1, 1);
242  int idx = 1;
243  TPad *p;
244 
245  p = (TPad *) c1->cd(idx++);
246  c1->Update();
247  // p->SetLogy();
248 
249  TH1 *hNChEta = (TH1 *) _file0->GetObjectChecked("hNChEta", "TH1");
250  assert(hNChEta);
251 
252  TH1 *h = (TH1 *) hNChEta->DrawClone();
253  h->Sumw2();
254  h->Rebin(10);
255  h->Scale(1. / hNormalization->GetBinContent(2));
256  h->Scale(1. / h->GetXaxis()->GetBinWidth(1));
257  h->SetTitle(";#eta;dN_{Ch}/d#eta");
258 
259  TLegend *leg = new TLegend(.3, .25, .8, .45);
260  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
261  leg->AddEntry("", description, "");
262  leg->AddEntry("", "dN_{Ch}/d#eta, sHIJING to Geant4 input", "");
263  leg->Draw();
264 
265  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
266 }
267 
269 {
270  assert(_file0);
271 
272  TCanvas *c1 = new TCanvas("ChargeCheck", "ChargeCheck", 1800, 960);
273  c1->Divide(1, 1);
274  int idx = 1;
275  TPad *p;
276 
277  p = (TPad *) c1->cd(idx++);
278  c1->Update();
279  p->SetRightMargin(.2);
280 
281  TH2 *hLayerZBinADC = (TH2 *) _file0->GetObjectChecked("hLayerZBinADC", "TH2");
282  assert(hLayerZBinADC);
283 
284  hLayerZBinADC->Draw("colz");
285 
286  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
287 }
288 
290 {
291  assert(_file0);
292 
293  TCanvas *c1 = new TCanvas("WaveletCheck", "WaveletCheck", 1800, 960);
294  c1->Divide(1, 1);
295  int idx = 1;
296  TPad *p;
297 
298  p = (TPad *) c1->cd(idx++);
299  c1->Update();
300  p->SetLogz();
301  p->SetRightMargin(.15);
302 
303  TH2 *hLayerWaveletSize = (TH2 *) _file0->GetObjectChecked("hLayerWaveletSize", "TH2");
304  assert(hLayerWaveletSize);
305 
306  hLayerWaveletSize->GetYaxis()->SetRangeUser(0, 260);
307  hLayerWaveletSize->Draw("colz");
308 
309  p = (TPad *) c1->cd(idx++);
310  c1->Update();
311  p->SetLogy();
312 
313  hLayerWaveletSize->ProjectionY()->Draw();
314 
315  TLegend *leg = new TLegend(.2, .7, .8, .92);
316  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
317  leg->AddEntry("", description, "");
318  leg->Draw();
319  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
320 }
321 
322 void Check1()
323 {
324  assert(_file0);
325 
326  TCanvas *c1 = new TCanvas("Check1", "Check1", 1800, 960);
327  c1->Divide(3, 2);
328  int idx = 1;
329  TPad *p;
330 
331  p = (TPad *) c1->cd(idx++);
332  c1->Update();
333  p->SetLogy();
334 
335  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
336  assert(hNormalization);
337 
338  hNormalization->Draw();
339 
340  p = (TPad *) c1->cd(idx++);
341  c1->Update();
342  p->SetLogy();
343  p->SetRightMargin(.1);
344 
345  TH1 *hDataSize = (TH1 *) _file0->GetObjectChecked("hDataSize", "TH1");
346  assert(hDataSize);
347 
348  TH1 *h = (TH1 *) hDataSize->DrawClone();
349  h->Rebin(400);
350 
351  p = (TPad *) c1->cd(idx++);
352  c1->Update();
353  p->SetLogy();
354 
355  TH1 *hWavelet = (TH1 *) _file0->GetObjectChecked("hWavelet", "TH1");
356  assert(hWavelet);
357 
358  h = (TH1 *) hWavelet->DrawClone();
359  h->Rebin(400);
360 
361  p = (TPad *) c1->cd(idx++);
362  c1->Update();
363  p->SetLogz();
364  p->SetRightMargin(.15);
365 
366  TH2 *hLayerWaveletSize = (TH2 *) _file0->GetObjectChecked("hLayerWaveletSize", "TH2");
367  assert(hLayerWaveletSize);
368 
369  hLayerWaveletSize->Draw("colz");
370 
371  p = (TPad *) c1->cd(idx++);
372  c1->Update();
373  // p->SetLogy();
374 
375  TH1 *hNChEta = (TH1 *) _file0->GetObjectChecked("hNChEta", "TH1");
376  assert(hNChEta);
377 
378  hNChEta->DrawClone();
379 
380  p = (TPad *) c1->cd(idx++);
381  c1->Update();
382  // p->SetLogy();
383 
384  hNChEta = (TH1 *) _file0->GetObjectChecked("hNChEta", "TH1");
385  assert(hNChEta);
386 
387  h = (TH1 *) hNChEta->DrawClone();
388  h->Sumw2();
389  h->Rebin(100);
390  h->Scale(1. / hNormalization->GetBinContent(1));
391 
392  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
393 }
394 
395 void Occupancy()
396 {
397  assert(_file0);
398 
399  TCanvas *c1 = new TCanvas("Occupancy", "Occupancy", 1800, 960);
400  // c1->Divide(3, 2);
401  int idx = 1;
402  TPad *p;
403 
404  p = (TPad *) c1->cd(idx++);
405  c1->Update();
406  p->SetLogz();
407  p->SetRightMargin(.15);
408 
409  TH2 *hLayerHit = (TH2 *) _file0->GetObjectChecked("hLayerHit", "TH2");
410  assert(hLayerHit);
411 
412  hLayerHit->GetYaxis()->SetRangeUser(0, 260);
413  hLayerHit->Draw("colz");
414 
415  hLayerHit->ProfileY()->Draw("same");
416 
417  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
418 }
419 
420 void Check2()
421 {
422  assert(_file0);
423 
424  TCanvas *c1 = new TCanvas("Check2", "Check2", 1800, 960);
425  c1->Divide(3, 2);
426  int idx = 1;
427  TPad *p;
428 
429  p = (TPad *) c1->cd(idx++);
430  c1->Update();
431  p->SetLogz();
432  p->SetRightMargin(.15);
433 
434  TH2 *hLayerHit = (TH2 *) _file0->GetObjectChecked("hLayerHit", "TH2");
435  assert(hLayerHit);
436 
437  hLayerHit->GetYaxis()->SetRangeUser(0, 260);
438  hLayerHit->Draw("colz");
439 
440  p = (TPad *) c1->cd(idx++);
441  c1->Update();
442  p->SetLogz();
443  p->SetRightMargin(.15);
444 
445  TH2 *hLayerDataSize = (TH2 *) _file0->GetObjectChecked("hLayerDataSize", "TH2");
446  assert(hLayerDataSize);
447 
448  hLayerDataSize->Draw("colz");
449 
450  p = (TPad *) c1->cd(idx++);
451  c1->Update();
452  p->SetRightMargin(.15);
453  // p->SetLogz();
454 
455  TH2 *hLayerSumHit = (TH2 *) _file0->GetObjectChecked("hLayerSumHit", "TH2");
456  assert(hLayerSumHit);
457 
458  hLayerSumHit->Draw("colz");
459 
460  p = (TPad *) c1->cd(idx++);
461  c1->Update();
462  p->SetRightMargin(.15);
463  // p->SetLogz();
464 
465  TH2 *hLayerSumDataSize = (TH2 *) _file0->GetObjectChecked("hLayerSumDataSize", "TH2");
466  assert(hLayerSumDataSize);
467 
468  hLayerSumDataSize->Draw("colz");
469 
470  p = (TPad *) c1->cd(idx++);
471  c1->Update();
472  p->SetRightMargin(.15);
473  // p->SetLogz();
474 
475  TH2 *hLayerZBinHit = (TH2 *) _file0->GetObjectChecked("hLayerZBinHit", "TH2");
476  assert(hLayerZBinHit);
477 
478  hLayerZBinHit->Draw("colz");
479 
480  p = (TPad *) c1->cd(idx++);
481  c1->Update();
482  p->SetRightMargin(.15);
483  // p->SetLogz();
484 
485  TH2 *hLayerZBinADC = (TH2 *) _file0->GetObjectChecked("hLayerZBinADC", "TH2");
486  assert(hLayerZBinADC);
487 
488  hLayerZBinADC->Draw("colz");
489  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
490 }
491 
493  // const TString infile = "data/TPCIntegratedCharge_AuAu0-4fm_200kHz.root",
494  // const TString disc = "Au+Au 0-7%C Triggered + 200 kHz collision" //
495  // const TString infile = "data/TPCDataStreamEmulator_AuAu0-12fm_170kHz_2.root",
496  // const TString disc = "Au+Au 0-12fm Triggered + 170 kHz collision" //
497  // const TString infile = "data/TPCDataStreamEmulator_AuAu0-14.7fm_0kHz_1.root",
498  // const TString disc = "Au+Au 0-14.7fm Triggered + No pileup collision" //
499  // const TString infile = "data/TPCDataStreamEmulator_AuAu0-14.7fm_170kHz_1.root",
500  // const TString infile = "/sphenix/user/jinhuang/TPC/Multiplicity/AuAu200MB_170kHz_Iter2/AuAu200MB_170kHz_Iter2_SUM.xml_TPCDataStreamEmulator.root",
501  // const TString disc = "Au+Au 0-20fm Triggered + 170 kHz collision" //
502  // const TString infile = "/sphenix/user/jinhuang/TPC/Multiplicity/AuAu200MB_170kHz_Stream_Iter3/AuAu200MB_170kHz_Stream_Iter3_SUM.xml_TPCDataStreamEmulator.root",
503 // const TString infile = "/sphenix/user/jinhuang/TPC/TPCMLDataInterface//170kHz_RandomTimeFrame_Iter2/170kHz_RandomTimeFrame_Iter2_SUM.xml_TPCMLDataInterface.root",
504 // const TString disc = "Au+Au 0-20fm 170 kHz collision in 13#mus" //
505  const TString infile = "/sphenix/user/jinhuang/TPC/TPCMLDataInterface/AuAu200_170kHz_MB_Iter2/AuAu200_170kHz_MB_Iter2_SUM.xml_TPCMLDataInterface.root",
506  const TString disc = "Au+Au 170 kHz collision + M.B. in 13#mus"
507  // const TString infile = "/sphenix/user/jinhuang/TPC/TPCMLDataInterface/AuAu200_170kHz_10C_Iter2/AuAu200_170kHz_10C_Iter2_SUM.xml_TPCMLDataInterface.root",
508 // const TString disc = "Au+Au 0-20fm 170 kHz + 10%C collision in 13#mus" //
509  // const TString infile = "data/TPCDataStreamEmulator_AuAu0-12fm_0kHz.root",
510  // const TString disc = "Au+Au MB Triggered + 0 kHz collision" //
511 )
512 {
513  SetsPhenixStyle();
514  gStyle->SetOptStat(0);
515  gStyle->SetOptFit(1111);
516  TVirtualFitter::SetDefaultFitter("Minuit2");
517 
518  _file0 = new TFile(infile);
519  assert(_file0->IsOpen());
520  description = disc;
521 
522  WaveletCheck();
523  DataRate();
524 // SectorDataSize();
525 // FEEDataSize();
526  Occupancy();
527  //
528  dNdeta();
529  ChargeCheck();
530  //
531  Check1();
532  Check2();
533 }