Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_comparisons_clusters.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plot_comparisons_clusters.C
1 #include <TH2D.h>
2 #include <TFile.h>
3 #include <TF1.h>
4 #include <TF2.h>
5 #include <TGraph.h>
6 #include <TCanvas.h>
7 #include <TROOT.h>
8 #include <TStyle.h>
9 #include <TLegend.h>
10 #include <TLatex.h>
11 #include <TLine.h>
12 #include <TColor.h>
13 
14 #include "sPhenixStyle.C"
15 
17 {
18 
20 
21  /*
22  gROOT->SetStyle("Plain");
23  gStyle->SetOptStat(0);
24  gStyle->SetOptFit(0);
25  gStyle->SetOptTitle(0);
26  */
27 
28  static const int NCONFIGS = 2;
29 
30  TFile *fin[NCONFIGS];
31  int tpc_layer[NCONFIGS][4];
32 
33  char label[NCONFIGS][500];
34 
35  fin[0] = new TFile("root_files/pileup_fix_inner16_200khz_cluster_resolution_out.root");
36  fin[1] = new TFile("root_files/pileup_fix_inner16_100khz_cluster_resolution_out.root");
37 
38  sprintf(label[0], "NeCF4_400 16 inner layers 200 kHz");
39  sprintf(label[1], "NeCF4_400 16 inner layers 100 kHz");
40 
41  /*
42  // 8 inner layers
43  tpc_layer[0][0] = 7; // 1st layer in TPC - inner radius 30 cm, center = 30.625
44  tpc_layer[0][1] = 15; // 1st layer of mid TPC - inner radius 40 cm, center = 40.625
45  tpc_layer[0][2] = 31; // 1st layer of outer TPC - inner radius 60 cm, center = 60.625
46  tpc_layer[0][3] = 46; // last layer of outer TPC - inner radius 78.75 cm, center = 79.375
47  */
48 
49  // 16 inner layers
50  tpc_layer[0][0] = 7; // 1st layer in TPC - inner radius 30 cm, center = 30.3125
51  tpc_layer[0][1] = 23; // 1st layer of mid TPC - inner radius 40 cm, center = 40.625
52  tpc_layer[0][2] = 39; // 1st layer of outer TPC - inner radius 60 cm, center = 60.625
53  tpc_layer[0][3] = 54; // last layer of outer TPC - inner radius 78.75 cm, center 79.375
54 
55  // 16 inner layers
56  tpc_layer[1][0] = 7; // 1st layer in TPC - inner radius 30 cm, center = 30.3125
57  tpc_layer[1][1] = 23; // 1st layer of mid TPC - inner radius 40 cm, center = 40.625
58  tpc_layer[1][2] = 39; // 1st layer of outer TPC - inner radius 60 cm, center = 60.625
59  tpc_layer[1][3] = 54; // last layer of outer TPC - inner radius 78.75 cm, center 79.375
60 
61  double layer_radius[4] = {30.0, 40.0, 60.0, 79.0};
62 
63  bool use_last_inner = true;
64  if(use_last_inner)
65  {
66  tpc_layer[0][1] = 22; // last layer of inner TPC - inner radius 38.75 cm, center = 39.375
67  tpc_layer[1][1] = 22; // last layer of inner TPC - inner radius 39.375, center = 39.6875
68  layer_radius[1] = 39.0;
69  }
70 
71  TGraph *gzsize[4][NCONFIGS];
72  TGraph *gocc[4][NCONFIGS];
73 
74  int col[4] = {kRed, kBlue, kBlack, kViolet};
75 
76  for(int i=0;i<NCONFIGS;i++)
77  {
78  if(!fin[i])
79  {
80  cout << "Did not find file " << i << " quit!" << endl;
81  exit(1);
82  }
83 
84  for(int ilayer = 0;ilayer < 4; ilayer++)
85  {
86  int layer = tpc_layer[i][ilayer];
87  char name1[500];
88  sprintf(name1,"goccz%i",layer);
89  cout << "Fetching object " << name1 << " for layer " << layer << " from file " << i << endl;
90  fin[i]->GetObject(name1,gzsize[ilayer][i]);
91  char name2[500];
92  sprintf(name2,"gocc_clus%i",layer);
93  cout << "Fetching object " << name2 << " for layer " << layer << " from file " << i << endl;
94  fin[i]->GetObject(name2,gocc[ilayer][i]);
95 
96  if(!gzsize[ilayer][i])
97  {
98  cout << "Failed to find gzsize named " << name1 << endl;
99  exit(1);
100  }
101  if(!gocc[ilayer][i])
102  {
103  cout << "Failed to find gocc named " << name2 << endl;
104  exit(1);
105  }
106  }
107  }
108 
109  // Plot Z size
110  //=========
111 
112  double hmaxz[4] = {3.5, 3.5, 3.5, 3.5};
113 
114  TCanvas *cz = new TCanvas("cz","cz",50,50,1200,800);
115  cz->Divide(2,2);
116 
117  TH1F *hdz = new TH1F("hdz","hdz",100, -110.0, 110.0);
118  hdz->SetMinimum(0.0);
119  hdz->GetXaxis()->SetTitle("Z (cm)");
120  hdz->GetXaxis()->SetTitleOffset(1.15);
121  hdz->GetYaxis()->SetTitle("Cluster Z size");
122  hdz->GetYaxis()->SetTitleOffset(1.3);
123 
124  for(int ilayer = 0;ilayer<4;ilayer++)
125  {
126  cz->cd(ilayer+1);
127 
128  hdz->SetMaximum(hmaxz[ilayer]);
129  hdz->DrawCopy();
130  for(int i=0;i<NCONFIGS;i++)
131  {
132  gzsize[ilayer][i]->SetMarkerColor(col[i]);
133 
134  if(i==0)
135  gzsize[ilayer][i]->Draw("p");
136  else
137  gzsize[ilayer][i]->Draw("same p");
138  }
139 
140  char label[500];
141  sprintf(label,"radius = %.1f cm",layer_radius[ilayer]);
142  TLatex *l3 = new TLatex(0.25,0.25,label);
143  l3->SetNDC(1);
144  l3->Draw();
145  }
146 
147  // Plot occupancy
148  //=============
149  //double hmax[4] = {0.3, 0.25, 0.15, 0.10};
150  double hmax[4] = {0.45, 0.35, 0.25, 0.18};
151 
152  TCanvas *cocc = new TCanvas("cocc","cocc",50,50,1200,800);
153  cocc->Divide(2,2);
154 
155  TH1F *hd = new TH1F("hd","hd",100, -110.0, 110.0);
156  hd->SetMinimum(0.0);
157  hd->GetXaxis()->SetTitle("Z (cm)");
158  hd->GetXaxis()->SetTitleOffset(1.15);
159  hd->GetYaxis()->SetTitle("Cluster occupancy");
160  hd->GetYaxis()->SetTitleOffset(1.3);
161 
162  for(int ilayer = 0;ilayer<4;ilayer++)
163  {
164  cocc->cd(ilayer+1);
165 
166  hd->SetMaximum(hmax[ilayer]);
167  hd->DrawCopy();
168  for(int i=0;i<NCONFIGS;i++)
169  {
170  gocc[ilayer][i]->SetMarkerColor(col[i]);
171 
172  if(i==0)
173  gocc[ilayer][i]->Draw("p");
174  else
175  gocc[ilayer][i]->Draw("same p");
176  }
177  char label[500];
178  sprintf(label,"radius = %.1f cm",layer_radius[ilayer]);
179  TLatex *l3 = new TLatex(0.25,0.25,label);
180  l3->SetNDC(1);
181  l3->Draw();
182  }
183 
184  TLegend *lpd = new TLegend(0.20, 0.70, 0.9, 0.90, "", "NDC");
185  lpd->SetBorderSize(1);
186  lpd->SetFillColor(0);
187  lpd->SetFillStyle(0);
188  for(int i=0;i<NCONFIGS;i++)
189  {
190  lpd->AddEntry(gocc[0][i],label[i], "p");
191  }
192  cocc->cd(4);
193  lpd->Draw();
194 
195  cz->cd(4);
196  lpd->Draw();
197 
198  cout << "Done" << endl;
199 }
200 
201