Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawTPCIntegratedCharge.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrawTPCIntegratedCharge.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 
19 // const TString infile = "data/TPCIntegratedCharge_AuAu0-4fm_200kHz.root",
20 // const TString disc = "Au+Au 0-7%C Triggered + 200 kHz collision" //
21 // const TString infile = "data/TPCIntegratedCharge_AuAu0-12fm_170kHz.root",
22  const TString infile = "/sphenix/user/jinhuang/TPC/Multiplicity/AuAu200MB_170kHz_Iter2/AuAu200MB_170kHz_Iter2_SUM.xml_TPCIntegratedCharge.root",
23  const TString disc = "Au+Au MB Triggered + 170 kHz collision" //
24 )
25 {
27  gStyle->SetOptStat(0);
28  gStyle->SetOptFit(1111);
29  TVirtualFitter::SetDefaultFitter("Minuit2");
30 
31  _file0 = new TFile(infile);
32  assert(_file0->IsOpen());
33  description = disc;
34 
35  vector<int> layers;
36  layers.push_back(1);
37  layers.push_back(16);
38  layers.push_back(17);
39  layers.push_back(32);
40  layers.push_back(33);
41  layers.push_back(48);
42 
43  Check();
44 
45  ChargePerLayer(layers);
46 }
47 
48 void ChargePerLayer(vector<int> layers)
49 {
50  assert(_file0);
51 
52  TH2 *hLayerCellCharge = (TH2 *) _file0->GetObjectChecked("hLayerCellCharge", "TH2");
53  assert(hLayerCellCharge);
54 
55  TH1 *chargePDFs[100000];
56  TH1 *chargeCDFs[100000];
57 
58  Color_t colors[] = {kPink + 2, kRed + 2, kSpring + 2, kGreen + 2, kAzure + 2, kBlue + 2};
59 
60  for (int i = 0; i < layers.size(); ++i)
61  {
62  Color_t color = colors[i];
63 
64  const int layer = layers[i];
65  TH1 *chargePDF = hLayerCellCharge->ProjectionY(Form("hLayerCellCharge_PDF_Layer%d", layer), layer, layer);
66  chargePDF->Sumw2();
67 
68  chargePDF->SetMarkerStyle(kFullCircle);
69  chargePDF->SetMarkerColor(color);
70  chargePDF->SetLineColor(color);
71 
72  chargePDF->Scale(1 / chargePDF->Integral(0, -1));
73 
74  TH1 *chargeCDF = chargePDF->Clone(Form("hLayerCellCharge_CDF_Layer%d", layer));
75  for (int bin = chargeCDF->GetNbinsX() + 1; bin >= 0; --bin)
76  {
77  double cdf = 0;
78  double cdf_err = 0;
79  cdf = chargePDF->IntegralAndError(bin, -1, cdf_err);
80 
81  chargeCDF->SetBinContent(bin, cdf);
82  chargeCDF->SetBinError(bin, cdf_err);
83  }
84 
85  chargePDF->Rebin(10);
86 
87  chargePDFs[i] = (chargePDF);
88  chargeCDFs[i] = chargeCDF;
89  }
90 
91  TCanvas *c1 = new TCanvas("ChargePerLayer", "ChargePerLayer", 1800, 960);
92  c1->Divide(2, 1);
93  int idx = 1;
94  TPad *p;
95 
96  p = (TPad *) c1->cd(idx++);
97  c1->Update();
98  p->SetLogy();
99 
100  p->DrawFrame(0, 1e-4, 610, 1, ";Charge [fC];Probability/bin");
101 
102  TLegend *leg = new TLegend(.17, .8, .93, .93);
103  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation, CD-1 configuration", "");
104  leg->AddEntry("", description, "");
105  leg->AddEntry("", "TPC charge PDF per FEE chan. over 13 us drift window", "");
106  leg->Draw();
107 
108  leg = new TLegend(.55, .5, .93, .75);
109  for (int i = 0; i < layers.size(); ++i)
110  {
111  chargePDFs[i]->Draw("same");
112 
113  TString performance = Form("Layer #%d: <Q> = %.0f fC", layers[i], chargePDFs[i]->GetMean());
114  cout << "ChargePerLayer : " << performance << endl;
115  leg->AddEntry(chargePDFs[i], performance, "lp");
116  }
117 
118  leg->Draw();
119 
120  p = (TPad *) c1->cd(idx++);
121  c1->Update();
122  p->SetLogy();
123  p->DrawFrame(0, 1e-3, 610, 1, ";Charge Threshold [fC];Probability[Q > Charge Threshold]");
124 
125  TLegend *leg = new TLegend(.17, .8, .93, .93);
126  leg->AddEntry("", "#it{#bf{sPHENIX}} Simulation, CD-1 configuration", "");
127  leg->AddEntry("", description, "");
128  leg->AddEntry("", "TPC charge CCDF per FEE chan. over 13 us drift window", "");
129  leg->Draw();
130 
131  leg = new TLegend(.2, .2, .65, .4);
132  for (int i = 0; i < layers.size(); ++i)
133  {
134  chargeCDFs[i]->Draw("same");
135 
136  TString cdf_desk = Form("Layer #%d: P[Q>300fC] = %.1f%%",
137  layers[i],
138  100 * chargeCDFs[i]->GetBinContent(chargeCDFs[i]->FindBin(300)));
139  cout << "ChargePerLayer : " << cdf_desk << endl;
140  leg->AddEntry(chargeCDFs[i], cdf_desk, "lp");
141  }
142  leg->Draw();
143 
144  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
145 }
146 
147 void Check()
148 {
149  assert(_file0);
150 
151  TCanvas *c1 = new TCanvas("Check", "Check", 1800, 960);
152  c1->Divide(3, 2);
153  int idx = 1;
154  TPad *p;
155 
156  p = (TPad *) c1->cd(idx++);
157  c1->Update();
158  p->SetLogy();
159 
160  TH1 *hNormalization = (TH1 *) _file0->GetObjectChecked("hNormalization", "TH1");
161  assert(hNormalization);
162 
163  hNormalization->Draw();
164 
165  p = (TPad *) c1->cd(idx++);
166  c1->Update();
167  p->SetLogz();
168 
169  TH2 *hLayerCellHit = (TH2 *) _file0->GetObjectChecked("hLayerCellHit", "TH2");
170  assert(hLayerCellHit);
171 
172  hLayerCellHit->Draw("colz");
173 
174  TProfile *hLayerCellHit_px = hLayerCellHit->ProfileX();
175  hLayerCellHit_px->Draw("same");
176 
177  p = (TPad *) c1->cd(idx++);
178  c1->Update();
179  p->SetLogz();
180 
181  TH2 *hLayerCellCharge = (TH2 *) _file0->GetObjectChecked("hLayerCellCharge", "TH2");
182  assert(hLayerCellCharge);
183 
184  hLayerCellCharge->Draw("colz");
185 
186  p = (TPad *) c1->cd(idx++);
187  c1->Update();
188  p->SetLogz();
189 
190  TH2 *hLayerSumCellHit = (TH2 *) _file0->GetObjectChecked("hLayerSumCellHit", "TH2");
191  assert(hLayerSumCellHit);
192 
193  hLayerSumCellHit->Draw("colz");
194 
195  p = (TPad *) c1->cd(idx++);
196  c1->Update();
197  p->SetLogz();
198 
199  TH2 *hLayerSumCellCharge = (TH2 *) _file0->GetObjectChecked("hLayerSumCellCharge", "TH2");
200  assert(hLayerSumCellCharge);
201 
202  hLayerSumCellCharge->Draw("colz");
203 
204  SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
205 }