ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
plot_matscan.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file plot_matscan.C
1 void plot_matscan(const std::string &datfile, const int plot_theta = 0)
2 {
3  FILE *f = fopen(datfile.c_str(), "r");
4  if (!f)
5  {
6  cout << "file " << datfile << " cannot be opened" << endl;
7  return;
8  }
9  float theta;
10  float phi;
11  float path;
12  float x0;
13  float lamda0;
14  vector<float> thetavec;
15  vector<float> phivec;
16  vector<float> x0vec;
17  vector<float> lamda0vec;
18  float thetamin = 10000;
19  float thetamax = -10000;
20  float phimin = 10000;
21  float phimax = -10000;
22  float x0min = 100000;
23  float x0max = -100000;
24  float lamda0min = 100000;
25  float lamda0max = -100000;
26  while (fscanf(f, "%f %f %f %f %f", &theta, &phi, &path, &x0, &lamda0) != EOF)
27  {
28  cout << "theta: " << theta
29  << ", phi: " << phi
30  << ", path: " << path
31  << ", x0: " << x0
32  << ", lamda0: " << lamda0
33  << endl;
34  if (plot_theta == 2)
35  {
36  theta = (90 + theta) / 180. * M_PI;
37  theta = log(TMath::Tan(theta / 2.));
38  }
39  if (theta > thetamax)
40  {
41  thetamax = theta;
42  }
43  if (theta < thetamin)
44  {
45  thetamin = theta;
46  }
47  if (phi > phimax)
48  {
49  phimax = phi;
50  }
51  if (phi < phimin)
52  {
53  phimin = phi;
54  }
55  if (x0 > x0max)
56  {
57  x0max = x0;
58  }
59  if (x0 < x0min)
60  {
61  x0min = x0;
62  }
63  if (lamda0 > lamda0max)
64  {
65  lamda0max = lamda0;
66  }
67  if (lamda0 < lamda0min)
68  {
69  lamda0min = lamda0;
70  }
71  thetavec.push_back(theta);
72  phivec.push_back(phi);
73  x0vec.push_back(x0);
74  lamda0vec.push_back(lamda0);
75  }
76  float *thetaarr = new float[thetavec.size()];
77  float *phiarr = new float[phivec.size()];
78  float *x0arr = new float[x0vec.size()];
79  float *lamda0arr = new float[lamda0vec.size()];
80  for (int i = 0; i < phivec.size(); i++)
81  {
82  thetaarr[i] = thetavec[i];
83  phiarr[i] = phivec[i];
84  x0arr[i] = x0vec[i];
85  lamda0arr[i] = lamda0vec[i];
86  }
87  TCanvas *c = new TCanvas("c1", "material scan");
88  c->Divide(1, 2);
89  c->cd(1);
90  char htitlex[100];
91  char htitlelamda[100];
92  double xmin;
93  double xmax;
94  TGraph *gr = nullptr;
95  TGraph *grl = nullptr;
96 
97  if (plot_theta)
98  {
99  if (plot_theta == 1)
100  {
101  sprintf(htitlex, "x0 vs theta");
102  sprintf(htitlelamda, "lamda0 vs theta");
103  xmin = thetamin - 1;
104  xmax = thetamax + 1;
105  }
106  else
107  {
108  sprintf(htitlex, "x0 vs eta");
109  sprintf(htitlelamda, "lamda0 vs eta");
110  xmin = thetamin - 0.1;
111  xmax = thetamax + 0.1;
112  }
113 
114  gr = new TGraph(thetavec.size(), thetaarr, x0arr);
115  grl = new TGraph(thetavec.size(), thetaarr, lamda0arr);
116  }
117  else
118  {
119  sprintf(htitlex, "x0 vs phi");
120  sprintf(htitlelamda, "lamda0 vs phi");
121  xmin = phimin - 1;
122  xmax = phimax + 1;
123  gr = new TGraph(phivec.size(), phiarr, x0arr);
124  grl = new TGraph(phivec.size(), phiarr, lamda0arr);
125  }
126  TH2 *h2 = new TH2F("hx2", htitlex, 2, xmin, xmax, 2, 0, x0max + 0.1 * x0max);
127  h2->SetStats(kFALSE);
128  h2->Draw();
129  gr->SetMarkerStyle(21);
130  gr->SetMarkerSize(0.1);
131  gr->Draw("LP");
132  c->cd(2);
133  TH2 *hl2 = new TH2F("hlamda2", htitlelamda, 2, xmin, xmax, 2, 0, lamda0max + lamda0max / 10.);
134  hl2->SetStats(kFALSE);
135  hl2->Draw();
136  grl->SetMarkerStyle(21);
137  grl->SetMarkerSize(0.1);
138  grl->Draw("LP");
139  fclose(f);
140  return;
141 }
142 
143 void plot_matscan_tdr(const char *datfile, const int plot_theta = 0)
144 {
145  FILE *f = fopen(datfile, "r");
146  if (!f)
147  {
148  cout << "file " << datfile << " cannot be opened" << endl;
149  return;
150  }
151  float theta;
152  float phi;
153  float path;
154  float x0;
155  float lamda0;
156  vector<float> thetavec;
157  vector<float> phivec;
158  vector<float> x0vec;
159  vector<float> lamda0vec;
160  float thetamin = -1.10;
161  float thetamax = 1.1;
162  float phimin = 10000;
163  float phimax = -10000;
164  float x0min = 100000;
165  float x0max = -100000;
166  float lamda0min = 100000;
167  float lamda0max = -100000;
168  while (fscanf(f, "%f %f %f %f %f", &theta, &phi, &path, &x0, &lamda0) != EOF)
169  {
170  theta = (theta + 90) / 180. * M_PI;
171  theta = log(TMath::Tan(theta / 2.));
172  cout << "theta: " << theta
173  << ", phi: " << phi
174  << ", path: " << path
175  << ", x0: " << x0
176  << ", lamda0: " << lamda0
177  << endl;
178  if (phi > phimax)
179  {
180  phimax = phi;
181  }
182  if (phi < phimin)
183  {
184  phimin = phi;
185  }
186  if (x0 > x0max)
187  {
188  x0max = x0;
189  }
190  if (x0 < x0min)
191  {
192  x0min = x0;
193  }
194  if (lamda0 > lamda0max)
195  {
196  lamda0max = lamda0;
197  }
198  if (lamda0 < lamda0min)
199  {
200  lamda0min = lamda0;
201  }
202  thetavec.push_back(theta);
203  phivec.push_back(phi);
204  x0vec.push_back(x0);
205  lamda0vec.push_back(lamda0);
206  }
207  float *thetaarr = new float[thetavec.size()];
208  float *phiarr = new float[phivec.size()];
209  float *x0arr = new float[x0vec.size()];
210  float *lamda0arr = new float[lamda0vec.size()];
211  for (int i = 0; i < phivec.size(); i++)
212  {
213  thetaarr[i] = thetavec[i];
214  phiarr[i] = phivec[i];
215  x0arr[i] = x0vec[i];
216  lamda0arr[i] = lamda0vec[i];
217  }
218  TCanvas *c = new TCanvas("c1", "material scan");
219  char htitlex[100];
220  char htitlelamda[100];
221  char titlexaxis[100];
222  double xmin;
223  double xmax;
224  TGraph *gr = nullptr;
225  TGraph *grl = nullptr;
226 
227  if (plot_theta)
228  {
229  sprintf(htitlex, "x0 vs theta");
230  sprintf(htitlelamda, "");
231  sprintf(titlexaxis, "#eta");
232  xmin = thetamin;
233  xmax = thetamax;
234  gr = new TGraph(thetavec.size(), thetaarr, x0arr);
235  grl = new TGraph(thetavec.size(), thetaarr, lamda0arr);
236  }
237  else
238  {
239  sprintf(htitlex, "x0 vs phi");
240  sprintf(htitlelamda, "");
241  sprintf(titlexaxis, "#phi");
242  xmin = phimin - 1;
243  xmax = phimax + 1;
244  gr = new TGraph(phivec.size(), phiarr, x0arr);
245  grl = new TGraph(phivec.size(), phiarr, lamda0arr);
246  }
247  TH2 *hl2 = new TH2F("hlamda2", htitlelamda, 2, xmin, xmax, 2, 0, lamda0max + lamda0max / 10.);
248  hl2->SetStats(kFALSE);
249  hl2->GetXaxis()->SetTitle(titlexaxis);
250  hl2->GetXaxis()->SetTitleSize(0.05);
251  hl2->GetXaxis()->SetLabelSize(0.04);
252  hl2->GetXaxis()->SetTitleOffset(0.8);
253  hl2->GetYaxis()->SetTitle("#lambda_{0}");
254  hl2->GetYaxis()->SetTitleSize(0.05);
255  hl2->GetYaxis()->SetTitleOffset(0.6);
256  hl2->GetYaxis()->SetLabelSize(0.04);
257  hl2->Draw();
258  grl->SetMarkerStyle(21);
259  grl->SetMarkerSize(0.1);
260  grl->SetLineWidth(2);
261  grl->Draw("LP");
262  fclose(f);
263  return;
264 }