Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EdepPercent.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EdepPercent.C
1 void EdepPercentE()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
2 {
3  char infile[100];
4  //char *particles[2] = {"pi-","e-"};
5  int pz[10] = {1,2,4,8,12,16,32,40,50,90};
6  //int th[3] = {5,10,18};
7  int h1int[36];
8  // for (int i=0; i<10;i++)
9  // {
10  // for (int j=0; j<5; j++)
11  // {
12  // for (int k=0; k<3; k++)
13  // {
14  sprintf(infile, "e1out.root");
15  char hname [100];
16  sprintf(hname, "e1d");
17  TH1F *h1 = new TH1F(hname, "e1d", 100, 0, 1);
18  TFile *f = TFile::Open(infile);
19  gROOT->cd();
20  TNtuple *nt = (TNtuple *)f->Get("ed");
21  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
22  f->Close();
23  h1->Draw();
24  TFile *fout = TFile::Open("epercent.root","UPDATE");
25  h1->Write();
26  fout->Write();
27  cout << h1->Integral() << " " << hname << endl;
28  //fout->Write();
29  fout->Close();
30 
31  sprintf(infile, "e2out.root");
32  char hname [100];
33  sprintf(hname, "e2d");
34  TH1F *h1 = new TH1F(hname, "e2d", 100, 0, 1);
35  TFile *f = TFile::Open(infile);
36  gROOT->cd();
37  TNtuple *nt = (TNtuple *)f->Get("ed");
38  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
39  f->Close();
40  h1->Draw();
41  TFile *fout = TFile::Open("epercent.root","UPDATE");
42  h1->Write();
43  fout->Write();
44  cout << h1->Integral() << " " << hname << endl;
45  //fout->Write();
46  fout->Close();
47 
48  sprintf(infile, "e4out.root");
49  char hname [100];
50  sprintf(hname, "e4d");
51  TH1F *h1 = new TH1F(hname, "e4d", 100, 0, 1);
52  TFile *f = TFile::Open(infile);
53  gROOT->cd();
54  TNtuple *nt = (TNtuple *)f->Get("ed");
55  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG");
56  f->Close();
57  h1->Draw();
58  TFile *fout = TFile::Open("epercent.root","UPDATE");
59  h1->Write();
60  fout->Write();
61  cout << h1->Integral() << " " << hname << endl;
62  //fout->Write();
63  fout->Close();
64 
65  sprintf(infile, "e8out.root");
66  char hname [100];
67  sprintf(hname, "e8d");
68  TH1F *h1 = new TH1F(hname, "e8d", 100, 0, 1);
69  TFile *f = TFile::Open(infile);
70  gROOT->cd();
71  TNtuple *nt = (TNtuple *)f->Get("ed");
72  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
73  f->Close();
74  h1->Draw();
75  TFile *fout = TFile::Open("epercent.root","UPDATE");
76  h1->Write();
77  fout->Write();
78  cout << h1->Integral() << " " << hname << endl;
79  //fout->Write();
80  fout->Close();
81 
82  sprintf(infile, "e12out.root");
83  char hname [100];
84  sprintf(hname, "e12d");
85  TH1F *h1 = new TH1F(hname, "e12d", 100, 0, 1);
86  TFile *f = TFile::Open(infile);
87  gROOT->cd();
88  TNtuple *nt = (TNtuple *)f->Get("ed");
89  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
90  f->Close();
91  h1->Draw();
92  TFile *fout = TFile::Open("epercent.root","UPDATE");
93  h1->Write();
94  fout->Write();
95  cout << h1->Integral() << " " << hname << endl;
96  //fout->Write();
97  fout->Close();
98 
99  sprintf(infile, "e16out.root");
100  char hname [100];
101  sprintf(hname, "e16d");
102  TH1F *h1 = new TH1F(hname, "e16d", 100, 0, 1);
103  TFile *f = TFile::Open(infile);
104  gROOT->cd();
105  TNtuple *nt = (TNtuple *)f->Get("ed");
106  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
107  f->Close();
108  h1->Draw();
109  TFile *fout = TFile::Open("epercent.root","UPDATE");
110  h1->Write();
111  fout->Write();
112  cout << h1->Integral() << " " << hname << endl;
113  //fout->Write();
114  fout->Close();
115 
116  sprintf(infile, "e32out.root");
117  char hname [100];
118  sprintf(hname, "e32d");
119  TH1F *h1 = new TH1F(hname, "e32d", 100, 0, 1);
120  TFile *f = TFile::Open(infile);
121  gROOT->cd();
122  TNtuple *nt = (TNtuple *)f->Get("ed");
123  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
124  f->Close();
125  h1->Draw();
126  TFile *fout = TFile::Open("epercent.root","UPDATE");
127  h1->Write();
128  fout->Write();
129  cout << h1->Integral() << " " << hname << endl;
130  //fout->Write();
131  fout->Close();
132 
133  sprintf(infile, "e40out.root");
134  char hname [100];
135  sprintf(hname, "e40d");
136  TH1F *h1 = new TH1F(hname, "e40d", 100, 0, 1);
137  TFile *f = TFile::Open(infile);
138  gROOT->cd();
139  TNtuple *nt = (TNtuple *)f->Get("ed");
140  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
141  f->Close();
142  h1->Draw();
143  TFile *fout = TFile::Open("epercent.root","UPDATE");
144  h1->Write();
145  fout->Write();
146  cout << h1->Integral() << " " << hname << endl;
147  //fout->Write();
148  fout->Close();
149 
150  sprintf(infile, "e50out.root");
151  char hname [100];
152  sprintf(hname, "e50d");
153  TH1F *h1 = new TH1F(hname, "e50d", 100, 0, 1);
154  TFile *f = TFile::Open(infile);
155  gROOT->cd();
156  TNtuple *nt = (TNtuple *)f->Get("ed");
157  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
158  f->Close();
159  h1->Draw();
160  TFile *fout = TFile::Open("epercent.root","UPDATE");
161  h1->Write();
162  fout->Write();
163  cout << h1->Integral() << " " << hname << endl;
164  //fout->Write();
165  fout->Close();
166 
167  /* sprintf(infile, "e90out.root");
168  char hname [100];
169  sprintf(hname, "e90d");
170  TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
171  TFile *f = TFile::Open(infile);
172  gROOT->cd();
173  TNtuple *nt = (TNtuple *)f->Get("ed");
174  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
175  f->Close();
176  h1->Draw();
177  TFile *fout = TFile::Open("epercent.root","UPDATE");
178  h1->Write();
179  fout->Write();
180  cout << h1->Integral() << " " << hname << endl;
181  //fout->Write();
182  fout->Close();
183  */
184 
185 
186 
187 
188 // }
189  //}
190 // }
191 }
192 
193 
194 
195 
196 
197 
198 
199 
201 {
202  TFile *fin = TFile::Open("epercent.root");
203  gROOT->cd();
204  TH2 *h2 = new TH2F("htot","EMCAL",1,0,50,1,0,1);
205  gStyle->SetOptStat(0);
206  TMarker *spf = new TMarker();
207  spf->SetMarkerStyle(20);
208  spf->SetMarkerColor(4);
209  TCanvas *c1 = new TCanvas();
210  h2->Draw();
211 
212  char hname[100];
213  sprintf(hname, "e1d");
214  TH1 *h1 = (TH1F *) fin->Get(hname);
215  spf->DrawMarker(1, h1->GetMean(1));
216 
217  char hname[100];
218  sprintf(hname, "e2d");
219  TH1 *h1 = (TH1F *) fin->Get(hname);
220  spf->DrawMarker(2, h1->GetMean(1));
221 
222  char hname[100];
223  sprintf(hname, "e4d");
224  TH1 *h1 = (TH1F *) fin->Get(hname);
225  //int meanval = h1->GetMean(1);
226  spf->DrawMarker(4, h1->GetMean(1));
227 
228  char hname[100];
229  sprintf(hname, "e8d");
230  TH1 *h1 = (TH1F *) fin->Get(hname);
231  // int meanval = h1->GetMean(1);
232  spf->DrawMarker(8, h1->GetMean(1));
233 
234  char hname[100];
235  sprintf(hname, "e12d");
236  TH1 *h1 = (TH1F *) fin->Get(hname);
237  //int meanval = h1->GetMean(1);
238  spf->DrawMarker(12, h1->GetMean(1));
239 
240  char hname[100];
241  sprintf(hname, "e16d");
242  TH1 *h1 = (TH1F *) fin->Get(hname);
243  //int meanval = h1->GetMean(1);
244  spf->DrawMarker(16, h1->GetMean(1));
245 
246  char hname[100];
247  sprintf(hname, "e32d");
248  TH1 *h1 = (TH1F *) fin->Get(hname);
249  // int meanval = h1->GetMean(1);
250  spf->DrawMarker(32, h1->GetMean(1));
251 
252  char hname[100];
253  sprintf(hname, "e40d");
254  TH1 *h1 = (TH1F *) fin->Get(hname);
255  //int meanval = h1->GetMean(1);
256  spf->DrawMarker(40, h1->GetMean(1));
257 
258  char hname[100];
259  sprintf(hname, "e50d");
260  TH1 *h1 = (TH1F *) fin->Get(hname);
261  //int meanval = h1->GetMean(1);
262  spf->DrawMarker(50, h1->GetMean(1));
263 
264  /* char hname[100];
265  sprintf(hname, "e90d");
266  TH1 *h1 = (TH1F *) fin->Get(hname);
267  int meanval = h1->GetMean();
268  spf->DrawMarker(90, h1->GetMean(1));
269  */
270  fin->Close();
271 
272 
273 
274 
275 
276  /* //const int N = 50;
277  //int count = 0;
278  //int i1 = 1;
279  double temp1, temp2, temp3;
280  //double arr1[N];
281  //double arr2[N];
282  //double arr3[N];
283 char filename1[350], filename2[350], filename3[350];
284  // open the files
285 // while (i1<50) {
286  temp1 = 0.; temp2 = 0.; temp3 = 0.;
287  sprintf(filename1,"e8out.root");
288  TFile* f1 = new TFile(filename1,"READONLY");
289  if (!f1 || f1->IsZombie()) {
290  printf("Cannot open %s!", filename1);
291  return;
292  }
293  //f1->cd("folder1");
294  TH1D* h1 = (TH1D*)gDirectory->Get("histo");
295  if (!h1) {
296  printf("Cannot read histo!");
297  return;
298  }
299  h1->GetXaxis()->SetRangeUser(0.45,2);
300  temp1 = h1->Integral();
301  // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
302  // so just don't delete it, will be done by delete f1.
303  sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
304  TFile* f2 = new TFile(filename2,"READONLY");
305  if (!f2 || f2->IsZombie()) {
306  printf("Cannot open %s!", filename2);
307  return;
308  }
309  //f2->cd("folder1");
310  TH1D* h2 = (TH1D*)gDirectory->Get("histo");
311  h2->GetXaxis()->SetRangeUser(0.45,2);
312  temp2 = h2->Integral();
313  // h2->Delete(); - NO, see above
314  arr1[count] = temp1;
315  arr2[count] = temp2;
316  arr3[count] = temp3;
317  cout << temp1 << " " << temp2 << endl;
318  i1 += 5;
319 count += 1;
320 
321 delete f1;
322 delete f2;
323  */
324  }
325 
326 
327 void EdepPercentIH()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
328 {
329  char infile[100];
330  //char *particles[2] = {"pi-","e-"};
331  int pz[10] = {1,2,4,8,12,16,32,40,50,90};
332  //int th[3] = {5,10,18};
333  int h1int[36];
334  // for (int i=0; i<10;i++)
335  // {
336  // for (int j=0; j<5; j++)
337  // {
338  // for (int k=0; k<3; k++)
339  // {
340  sprintf(infile, "e1out.root");
341  char hname [100];
342  sprintf(hname, "HIe1d");
343  TH1F *h1 = new TH1F(hname, "HIe1d", 100, 0, 1);
344  TFile *f = TFile::Open(infile);
345  gROOT->cd();
346  TNtuple *nt = (TNtuple *)f->Get("ed");
347  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
348  f->Close();
349  h1->Draw();
350  TFile *fout = TFile::Open("epercent.root","UPDATE");
351  h1->Write();
352  fout->Write();
353  cout << h1->Integral() << " " << hname << endl;
354  //fout->Write();
355  fout->Close();
356 
357  sprintf(infile, "e2out.root");
358  char hname [100];
359  sprintf(hname, "HIe2d");
360  TH1F *h1 = new TH1F(hname, "HIe2d", 100, 0, 1);
361  TFile *f = TFile::Open(infile);
362  gROOT->cd();
363  TNtuple *nt = (TNtuple *)f->Get("ed");
364  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
365  f->Close();
366  h1->Draw();
367  TFile *fout = TFile::Open("epercent.root","UPDATE");
368  h1->Write();
369  fout->Write();
370  cout << h1->Integral() << " " << hname << endl;
371  //fout->Write();
372  fout->Close();
373 
374  sprintf(infile, "e4out.root");
375  char hname [100];
376  sprintf(hname, "HIe4d");
377  TH1F *h1 = new TH1F(hname, "HIe4d", 100, 0, 1);
378  TFile *f = TFile::Open(infile);
379  gROOT->cd();
380  TNtuple *nt = (TNtuple *)f->Get("ed");
381  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
382  f->Close();
383  h1->Draw();
384  TFile *fout = TFile::Open("epercent.root","UPDATE");
385  h1->Write();
386  fout->Write();
387  cout << h1->Integral() << " " << hname << endl;
388  //fout->Write();
389  fout->Close();
390 
391  sprintf(infile, "e8out.root");
392  char hname [100];
393  sprintf(hname, "HIe8d");
394  TH1F *h1 = new TH1F(hname, "HIe8d", 100, 0, 1);
395  TFile *f = TFile::Open(infile);
396  gROOT->cd();
397  TNtuple *nt = (TNtuple *)f->Get("ed");
398  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
399  f->Close();
400  h1->Draw();
401  TFile *fout = TFile::Open("epercent.root","UPDATE");
402  h1->Write();
403  fout->Write();
404  cout << h1->Integral() << " " << hname << endl;
405  //fout->Write();
406  fout->Close();
407 
408  sprintf(infile, "e12out.root");
409  char hname [100];
410  sprintf(hname, "HIe12d");
411  TH1F *h1 = new TH1F(hname, "HIe12d", 100, 0, 1);
412  TFile *f = TFile::Open(infile);
413  gROOT->cd();
414  TNtuple *nt = (TNtuple *)f->Get("ed");
415  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
416  f->Close();
417  h1->Draw();
418  TFile *fout = TFile::Open("epercent.root","UPDATE");
419  h1->Write();
420  fout->Write();
421  cout << h1->Integral() << " " << hname << endl;
422  //fout->Write();
423  fout->Close();
424 
425  sprintf(infile, "e16out.root");
426  char hname [100];
427  sprintf(hname, "HIe16d");
428  TH1F *h1 = new TH1F(hname, "HIe16d", 100, 0, 1);
429  TFile *f = TFile::Open(infile);
430  gROOT->cd();
431  TNtuple *nt = (TNtuple *)f->Get("ed");
432  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
433  f->Close();
434  h1->Draw();
435  TFile *fout = TFile::Open("epercent.root","UPDATE");
436  h1->Write();
437  fout->Write();
438  cout << h1->Integral() << " " << hname << endl;
439  //fout->Write();
440  fout->Close();
441 
442  sprintf(infile, "e32out.root");
443  char hname [100];
444  sprintf(hname, "HIe32d");
445  TH1F *h1 = new TH1F(hname, "HIe32d", 100, 0, 1);
446  TFile *f = TFile::Open(infile);
447  gROOT->cd();
448  TNtuple *nt = (TNtuple *)f->Get("ed");
449  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
450  f->Close();
451  h1->Draw();
452  TFile *fout = TFile::Open("epercent.root","UPDATE");
453  h1->Write();
454  fout->Write();
455  cout << h1->Integral() << " " << hname << endl;
456  //fout->Write();
457  fout->Close();
458 
459  sprintf(infile, "e40out.root");
460  char hname [100];
461  sprintf(hname, "HIe40d");
462  TH1F *h1 = new TH1F(hname, "HIe40d", 100, 0, 1);
463  TFile *f = TFile::Open(infile);
464  gROOT->cd();
465  TNtuple *nt = (TNtuple *)f->Get("ed");
466  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
467  f->Close();
468  h1->Draw();
469  TFile *fout = TFile::Open("epercent.root","UPDATE");
470  h1->Write();
471  fout->Write();
472  cout << h1->Integral() << " " << hname << endl;
473  //fout->Write();
474  fout->Close();
475 
476  sprintf(infile, "e50out.root");
477  char hname [100];
478  sprintf(hname, "HIe50d");
479  TH1F *h1 = new TH1F(hname, "HIe50d", 100, 0, 1);
480  TFile *f = TFile::Open(infile);
481  gROOT->cd();
482  TNtuple *nt = (TNtuple *)f->Get("ed");
483  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
484  f->Close();
485  h1->Draw();
486  TFile *fout = TFile::Open("epercent.root","UPDATE");
487  h1->Write();
488  fout->Write();
489  cout << h1->Integral() << " " << hname << endl;
490  //fout->Write();
491  fout->Close();
492 
493  /* sprintf(infile, "e90out.root");
494  char hname [100];
495  sprintf(hname, "e90d");
496  TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
497  TFile *f = TFile::Open(infile);
498  gROOT->cd();
499  TNtuple *nt = (TNtuple *)f->Get("ed");
500  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
501  f->Close();
502  h1->Draw();
503  TFile *fout = TFile::Open("epercent.root","UPDATE");
504  h1->Write();
505  fout->Write();
506  cout << h1->Integral() << " " << hname << endl;
507  //fout->Write();
508  fout->Close();
509  */
510 
511 
512 
513 
514 // }
515  //}
516 // }
517 }
518 
519 
520 
521 
522 
523 
524 
525 
527 {
528  TFile *fin = TFile::Open("epercent.root");
529  gROOT->cd();
530  TH2 *h2 = new TH2F("htot","Inner_HCAL",1,0,50,1,0,.1);
531  gStyle->SetOptStat(0);
532  TMarker *spf = new TMarker();
533  spf->SetMarkerStyle(20);
534  spf->SetMarkerColor(8);
535  TLine *rlin = new TLine();
536  rlin->SetLineColor(8);
537  rlin->SetLineStyle(1);
538  rlin->SetLineWidth(1);
539  TCanvas *c2 = new TCanvas();
540  h2->Draw();
541 
542  char hname[100];
543  sprintf(hname, "HIe1d");
544  TH1 *h1 = (TH1F *) fin->Get(hname);
545  spf->DrawMarker(1, h1->GetMean(1));
546  rlin->DrawLine(1,(h1->GetMean(1)-h1->GetRMS(1)),1,(h1->GetMean(1) + h1->GetRMS(1)));
547  char hname[100];
548  sprintf(hname, "HIe2d");
549  TH1 *h1 = (TH1F *) fin->Get(hname);
550  spf->DrawMarker(2, h1->GetMean(1));
551  rlin->DrawLine(2,(h1->GetMean(1)-h1->GetRMS(1)),2,(h1->GetMean(1) + h1->GetRMS(1)));
552  char hname[100];
553  sprintf(hname, "HIe4d");
554  TH1 *h1 = (TH1F *) fin->Get(hname);
555  //int meanval = h1->GetMean(1);
556  spf->DrawMarker(4, h1->GetMean(1));
557  rlin->DrawLine(4,(h1->GetMean(1)-h1->GetRMS(1)),4,(h1->GetMean(1) + h1->GetRMS(1)));
558  char hname[100];
559  sprintf(hname, "HIe8d");
560  TH1 *h1 = (TH1F *) fin->Get(hname);
561  // int meanval = h1->GetMean(1);
562  spf->DrawMarker(8, h1->GetMean(1));
563  rlin->DrawLine(8,(h1->GetMean(1)-h1->GetRMS(1)),8,(h1->GetMean(1) + h1->GetRMS(1)));
564  char hname[100];
565  sprintf(hname, "HIe12d");
566  TH1 *h1 = (TH1F *) fin->Get(hname);
567  //int meanval = h1->GetMean(1);
568  spf->DrawMarker(12, h1->GetMean(1));
569  rlin->DrawLine(12,(h1->GetMean(1)-h1->GetRMS(1)),12,(h1->GetMean(1) + h1->GetRMS(1)));
570  char hname[100];
571  sprintf(hname, "HIe16d");
572  TH1 *h1 = (TH1F *) fin->Get(hname);
573  //int meanval = h1->GetMean(1);
574  spf->DrawMarker(16, h1->GetMean(1));
575  rlin->DrawLine(16,(h1->GetMean(1)-h1->GetRMS(1)),16,(h1->GetMean(1) + h1->GetRMS(1)));
576 
577  char hname[100];
578  sprintf(hname, "HIe32d");
579  TH1 *h1 = (TH1F *) fin->Get(hname);
580  // int meanval = h1->GetMean(1);
581  spf->DrawMarker(32, h1->GetMean(1));
582  rlin->DrawLine(32,(h1->GetMean(1)-h1->GetRMS(1)),32,(h1->GetMean(1) + h1->GetRMS(1)));
583  char hname[100];
584  sprintf(hname, "HIe40d");
585  TH1 *h1 = (TH1F *) fin->Get(hname);
586  //int meanval = h1->GetMean(1);
587  spf->DrawMarker(40, h1->GetMean(1));
588  rlin->DrawLine(40,(h1->GetMean(1)-h1->GetRMS(1)),40,(h1->GetMean(1) + h1->GetRMS(1)));
589 
590  char hname[100];
591  sprintf(hname, "HIe50d");
592  TH1 *h1 = (TH1F *) fin->Get(hname);
593  //int meanval = h1->GetMean(1);
594  spf->DrawMarker(50, h1->GetMean(1));
595  rlin->DrawLine(50,(h1->GetMean(1)-h1->GetRMS(1)),50,(h1->GetMean(1) + h1->GetRMS(1)));
596 
597  /* char hname[100];
598  sprintf(hname, "e90d");
599  TH1 *h1 = (TH1F *) fin->Get(hname);
600  int meanval = h1->GetMean();
601  spf->DrawMarker(90, h1->GetMean(1));
602  */
603  fin->Close();
604 
605 
606 
607 
608 
609  /* //const int N = 50;
610  //int count = 0;
611  //int i1 = 1;
612  double temp1, temp2, temp3;
613  //double arr1[N];
614  //double arr2[N];
615  //double arr3[N];
616 char filename1[350], filename2[350], filename3[350];
617  // open the files
618 // while (i1<50) {
619  temp1 = 0.; temp2 = 0.; temp3 = 0.;
620  sprintf(filename1,"e8out.root");
621  TFile* f1 = new TFile(filename1,"READONLY");
622  if (!f1 || f1->IsZombie()) {
623  printf("Cannot open %s!", filename1);
624  return;
625  }
626  //f1->cd("folder1");
627  TH1D* h1 = (TH1D*)gDirectory->Get("histo");
628  if (!h1) {
629  printf("Cannot read histo!");
630  return;
631  }
632  h1->GetXaxis()->SetRangeUser(0.45,2);
633  temp1 = h1->Integral();
634  // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
635  // so just don't delete it, will be done by delete f1.
636  sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
637  TFile* f2 = new TFile(filename2,"READONLY");
638  if (!f2 || f2->IsZombie()) {
639  printf("Cannot open %s!", filename2);
640  return;
641  }
642  //f2->cd("folder1");
643  TH1D* h2 = (TH1D*)gDirectory->Get("histo");
644  h2->GetXaxis()->SetRangeUser(0.45,2);
645  temp2 = h2->Integral();
646  // h2->Delete(); - NO, see above
647  arr1[count] = temp1;
648  arr2[count] = temp2;
649  arr3[count] = temp3;
650  cout << temp1 << " " << temp2 << endl;
651  i1 += 5;
652 count += 1;
653 
654 delete f1;
655 delete f2;
656  */
657  }
658 
659 void EdepPercentOH()//(const char * particle = "e-", const int pz = 4, const int thickness = 18)
660 {
661  char infile[100];
662  //char *particles[2] = {"pi-","e-"};
663  int pz[10] = {1,2,4,8,12,16,32,40,50,90};
664  //int th[3] = {5,10,18};
665  int h1int[36];
666  // for (int i=0; i<10;i++)
667  // {
668  // for (int j=0; j<5; j++)
669  // {
670  // for (int k=0; k<3; k++)
671  // {
672  sprintf(infile, "e1out.root");
673  char hname [100];
674  sprintf(hname, "HOe1d");
675  TH1F *h1 = new TH1F(hname, "HOe1d", 100, 0, 1);
676  TFile *f = TFile::Open(infile);
677  gROOT->cd();
678  TNtuple *nt = (TNtuple *)f->Get("ed");
679  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
680  f->Close();
681  h1->Draw();
682  TFile *fout = TFile::Open("epercent.root","UPDATE");
683  h1->Write();
684  fout->Write();
685  cout << h1->Integral() << " " << hname << endl;
686  //fout->Write();
687  fout->Close();
688 
689  sprintf(infile, "e2out.root");
690  char hname [100];
691  sprintf(hname, "HOe2d");
692  TH1F *h1 = new TH1F(hname, "HOe2d", 100, 0, 1);
693  TFile *f = TFile::Open(infile);
694  gROOT->cd();
695  TNtuple *nt = (TNtuple *)f->Get("ed");
696  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
697  f->Close();
698  h1->Draw();
699  TFile *fout = TFile::Open("epercent.root","UPDATE");
700  h1->Write();
701  fout->Write();
702  cout << h1->Integral() << " " << hname << endl;
703  //fout->Write();
704  fout->Close();
705 
706  sprintf(infile, "e4out.root");
707  char hname [100];
708  sprintf(hname, "HOe4d");
709  TH1F *h1 = new TH1F(hname, "HOe4d", 100, 0, 1);
710  TFile *f = TFile::Open(infile);
711  gROOT->cd();
712  TNtuple *nt = (TNtuple *)f->Get("ed");
713  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
714  f->Close();
715  h1->Draw();
716  TFile *fout = TFile::Open("epercent.root","UPDATE");
717  h1->Write();
718  fout->Write();
719  cout << h1->Integral() << " " << hname << endl;
720  //fout->Write();
721  fout->Close();
722 
723  sprintf(infile, "e8out.root");
724  char hname [100];
725  sprintf(hname, "HOe8d");
726  TH1F *h1 = new TH1F(hname, "HOe8d", 100, 0, 1);
727  TFile *f = TFile::Open(infile);
728  gROOT->cd();
729  TNtuple *nt = (TNtuple *)f->Get("ed");
730  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
731  f->Close();
732  h1->Draw();
733  TFile *fout = TFile::Open("epercent.root","UPDATE");
734  h1->Write();
735  fout->Write();
736  cout << h1->Integral() << " " << hname << endl;
737  //fout->Write();
738  fout->Close();
739 
740  sprintf(infile, "e12out.root");
741  char hname [100];
742  sprintf(hname, "HOe12d");
743  TH1F *h1 = new TH1F(hname, "HOe12d", 100, 0, 1);
744  TFile *f = TFile::Open(infile);
745  gROOT->cd();
746  TNtuple *nt = (TNtuple *)f->Get("ed");
747  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
748  f->Close();
749  h1->Draw();
750  TFile *fout = TFile::Open("epercent.root","UPDATE");
751  h1->Write();
752  fout->Write();
753  cout << h1->Integral() << " " << hname << endl;
754  //fout->Write();
755  fout->Close();
756 
757  sprintf(infile, "e16out.root");
758  char hname [100];
759  sprintf(hname, "HOe16d");
760  TH1F *h1 = new TH1F(hname, "HOe16d", 100, 0, 1);
761  TFile *f = TFile::Open(infile);
762  gROOT->cd();
763  TNtuple *nt = (TNtuple *)f->Get("ed");
764  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
765  f->Close();
766  h1->Draw();
767  TFile *fout = TFile::Open("epercent.root","UPDATE");
768  h1->Write();
769  fout->Write();
770  cout << h1->Integral() << " " << hname << endl;
771  //fout->Write();
772  fout->Close();
773 
774  sprintf(infile, "e32out.root");
775  char hname [100];
776  sprintf(hname, "HOe32d");
777  TH1F *h1 = new TH1F(hname, "HOe32d", 100, 0, 1);
778  TFile *f = TFile::Open(infile);
779  gROOT->cd();
780  TNtuple *nt = (TNtuple *)f->Get("ed");
781  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
782  f->Close();
783  h1->Draw();
784  TFile *fout = TFile::Open("epercent.root","UPDATE");
785  h1->Write();
786  fout->Write();
787  cout << h1->Integral() << " " << hname << endl;
788  //fout->Write();
789  fout->Close();
790 
791  sprintf(infile, "e40out.root");
792  char hname [100];
793  sprintf(hname, "HOe40d");
794  TH1F *h1 = new TH1F(hname, "HOe40d", 100, 0, 1);
795  TFile *f = TFile::Open(infile);
796  gROOT->cd();
797  TNtuple *nt = (TNtuple *)f->Get("ed");
798  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
799  f->Close();
800  h1->Draw();
801  TFile *fout = TFile::Open("epercent.root","UPDATE");
802  h1->Write();
803  fout->Write();
804  cout << h1->Integral() << " " << hname << endl;
805  //fout->Write();
806  fout->Close();
807 
808  sprintf(infile, "e50out.root");
809  char hname [100];
810  sprintf(hname, "HOe50d");
811  TH1F *h1 = new TH1F(hname, "HOe50d", 100, 0, 1);
812  TFile *f = TFile::Open(infile);
813  gROOT->cd();
814  TNtuple *nt = (TNtuple *)f->Get("ed");
815  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
816  f->Close();
817  h1->Draw();
818  TFile *fout = TFile::Open("epercent.root","UPDATE");
819  h1->Write();
820  fout->Write();
821  cout << h1->Integral() << " " << hname << endl;
822  //fout->Write();
823  fout->Close();
824 
825  /* sprintf(infile, "e90out.root");
826  char hname [100];
827  sprintf(hname, "e90d");
828  TH1F *h1 = new TH1F(hname, "e90d", 100, 0, 90);
829  TFile *f = TFile::Open(infile);
830  gROOT->cd();
831  TNtuple *nt = (TNtuple *)f->Get("ed");
832  nt->Project(hname,"(EA+ES)/(EA+ES+HOA+HOS+HIA+HIS+BH+MAG)");
833  f->Close();
834  h1->Draw();
835  TFile *fout = TFile::Open("epercent.root","UPDATE");
836  h1->Write();
837  fout->Write();
838  cout << h1->Integral() << " " << hname << endl;
839  //fout->Write();
840  fout->Close();
841  */
842 
843 
844 
845 
846 // }
847  //}
848 // }
849 }
850 
851 
852 
853 
854 
855 void EdepPercentAnalyzerOH(const char *calo="HOe")
856 {
857  TFile *fin = TFile::Open("epercent.root");
858  gROOT->cd();
859  TH2 *h2 = new TH2F("htot","Outer_HCAL",1,0,50,1,0,.1);
860  gStyle->SetOptStat(0);
861  TMarker *spf = new TMarker();
862  spf->SetMarkerStyle(20);
863  spf->SetMarkerColor(11);
864  TLine *rlin = new TLine();
865  rlin->SetLineColor(3);
866  rlin->SetLineStyle(1);
867  rlin->SetLineWidth(1);
868  TCanvas *c3 = new TCanvas();
869  h2->Draw();
870 
871  char hname[100];
872  sprintf(hname, "HOe1d");
873  TH1 *h1 = (TH1F *) fin->Get(hname);
874  spf->DrawMarker(1, h1->GetMean(1));
875  rlin->DrawLine(1,(h1->GetMean(1)-h1->GetRMS(1)),1,(h1->GetMean(1) + h1->GetRMS(1)));
876  double hom1 = h1->GetMean(1);
877  double hor1 = h1->GetRMS(1);
878 
879  char hname[100];
880  sprintf(hname, "HOe2d");
881  TH1 *h1 = (TH1F *) fin->Get(hname);
882  spf->DrawMarker(2, h1->GetMean(1));
883  rlin->DrawLine(2,(h1->GetMean(1)-h1->GetRMS(1)),2,(h1->GetMean(1) + h1->GetRMS(1)));
884  double hom2 = h1->GetMean(1);
885  double hor2 = h1->GetRMS(1);
886 
887  char hname[100];
888  sprintf(hname, "HOe4d");
889  TH1 *h1 = (TH1F *) fin->Get(hname);
890  //int meanval = h1->GetMean(1);
891  spf->DrawMarker(4, h1->GetMean(1));
892  rlin->DrawLine(4,(h1->GetMean(1)-h1->GetRMS(1)),4,(h1->GetMean(1) + h1->GetRMS(1)));
893  double hom4 = h1->GetMean(1);
894  double hor4 = h1->GetRMS(1);
895 
896 
897  char hname[100];
898  sprintf(hname, "HOe8d");
899  TH1 *h1 = (TH1F *) fin->Get(hname);
900  // int meanval = h1->GetMean(1);
901  spf->DrawMarker(8, h1->GetMean(1));
902  rlin->DrawLine(8,(h1->GetMean(1)-h1->GetRMS(1)),8,(h1->GetMean(1) + h1->GetRMS(1)));
903  double hom8 = h1->GetMean(1);
904  double hor8 = h1->GetRMS(1);
905 
906 
907  char hname[100];
908  sprintf(hname, "HOe12d");
909  TH1 *h1 = (TH1F *) fin->Get(hname);
910  //int meanval = h1->GetMean(1);
911  spf->DrawMarker(12, h1->GetMean(1));
912  rlin->DrawLine(12,(h1->GetMean(1)-h1->GetRMS(1)),12,(h1->GetMean(1) + h1->GetRMS(1)));
913  double hom12 = h1->GetMean(1);
914  double hor12 = h1->GetRMS(1);
915 
916 
917  char hname[100];
918  sprintf(hname, "HOe16d");
919  TH1 *h1 = (TH1F *) fin->Get(hname);
920  //int meanval = h1->GetMean(1);
921  spf->DrawMarker(16, h1->GetMean(1));
922  rlin->DrawLine(16,(h1->GetMean(1)-h1->GetRMS(1)),16,(h1->GetMean(1) + h1->GetRMS(1)));
923  double hom16 = h1->GetMean(1);
924  double hor16 = h1->GetRMS(1);
925 
926 
927  char hname[100];
928  sprintf(hname, "HOe32d");
929  TH1 *h1 = (TH1F *) fin->Get(hname);
930  // int meanval = h1->GetMean(1);
931  spf->DrawMarker(32, h1->GetMean(1));
932  rlin->DrawLine(32,(h1->GetMean(1)-h1->GetRMS(1)),32,(h1->GetMean(1) + h1->GetRMS(1)));
933  double hom32 = h1->GetMean(1);
934  double hor32 = h1->GetRMS(1);
935 
936 
937  char hname[100];
938  sprintf(hname, "HOe40d");
939  TH1 *h1 = (TH1F *) fin->Get(hname);
940  //int meanval = h1->GetMean(1);
941  spf->DrawMarker(40, h1->GetMean(1));
942  rlin->DrawLine(40,(h1->GetMean(1)-h1->GetRMS(1)),40,(h1->GetMean(1) + h1->GetRMS(1)));
943  double hom40 = h1->GetMean(1);
944  double hor40 = h1->GetRMS(1);
945 
946 
947  char hname[100];
948  sprintf(hname, "%s50d",calo);
949  TH1 *h1 = (TH1F *) fin->Get(hname);
950  //int meanval = h1->GetMean(1);
951  spf->DrawMarker(50, h1->GetMean(1));
952  rlin->DrawLine(50,(h1->GetMean(1)-h1->GetRMS(1)),50,(h1->GetMean(1) + h1->GetRMS(1)));
953  double hom50 = h1->GetMean(1);
954  double hor50 = h1->GetRMS(1);
955 
956 
957  double x[9] = {1,2,4,8,12,16,32,40,50};
958  double y[9] = {hom1,hom2,hom4,hom8,hom12,hom16,hom32,hom40,hom50};
959  double xer[9] = {0};
960  double yer[9] = {hor1,hor2,hor4,hor8,hor12,hor16,hor32,hor40,hor50};
961  gr = new TGraphErrors(9,x,y,xer,yer);
962  gr->Draw("ALP");
963  gr->SetMarkerStyle(20);
964  gr->SetMarkerColor(2);
965 
966  /* char hname[100];
967  sprintf(hname, "e90d");
968  TH1 *h1 = (TH1F *) fin->Get(hname);
969  int meanval = h1->GetMean();
970  spf->DrawMarker(90, h1->GetMean(1));
971  */
972  fin->Close();
973 
974 
975 
976 
977 
978  /* //const int N = 50;
979  //int count = 0;
980  //int i1 = 1;
981  double temp1, temp2, temp3;
982  //double arr1[N];
983  //double arr2[N];
984  //double arr3[N];
985 char filename1[350], filename2[350], filename3[350];
986  // open the files
987 // while (i1<50) {
988  temp1 = 0.; temp2 = 0.; temp3 = 0.;
989  sprintf(filename1,"e8out.root");
990  TFile* f1 = new TFile(filename1,"READONLY");
991  if (!f1 || f1->IsZombie()) {
992  printf("Cannot open %s!", filename1);
993  return;
994  }
995  //f1->cd("folder1");
996  TH1D* h1 = (TH1D*)gDirectory->Get("histo");
997  if (!h1) {
998  printf("Cannot read histo!");
999  return;
1000  }
1001  h1->GetXaxis()->SetRangeUser(0.45,2);
1002  temp1 = h1->Integral();
1003  // h1->Delete(); - NO, use delete h1, but histograms are owned by files,
1004  // so just don't delete it, will be done by delete f1.
1005  sprintf(filename2,"/sphenix/user/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/e4out.root",1);
1006  TFile* f2 = new TFile(filename2,"READONLY");
1007  if (!f2 || f2->IsZombie()) {
1008  printf("Cannot open %s!", filename2);
1009  return;
1010  }
1011  //f2->cd("folder1");
1012  TH1D* h2 = (TH1D*)gDirectory->Get("histo");
1013  h2->GetXaxis()->SetRangeUser(0.45,2);
1014  temp2 = h2->Integral();
1015  // h2->Delete(); - NO, see above
1016  arr1[count] = temp1;
1017  arr2[count] = temp2;
1018  arr3[count] = temp3;
1019  cout << temp1 << " " << temp2 << endl;
1020  i1 += 5;
1021 count += 1;
1022 
1023 delete f1;
1024 delete f2;
1025  */
1026  }
1027 
1028 
1029 
1030 void EdepPercentSmall (const char *calo="HO", const char *part="e")
1031 {
1032  char infile[100];
1033  int pz[9] = {1,2,4,8,12,16,32,40,50};
1034  double x[9];
1035 
1036  for (int i=0; i<9; i++)
1037 {
1038  //x[i] = pz[i];
1039  sprintf(infile, "%s%dout.root",part, pz[i]);
1040  char hname [100];
1041  sprintf(hname, "%s%s%dd",calo,part,pz[i]);
1042  TH1F *h1 = new TH1F(hname, "", 100, 0, 1);
1043  TFile *f = TFile::Open(infile);
1044  gROOT->cd();
1045  TNtuple *nt = (TNtuple *)f->Get("ed");
1046  // char cal [100];
1047  // sprintf(cal,"%s",calo);
1048  if (calo == "HO")
1049  {
1050  nt->Project(hname,"(EA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1051  }
1052  else if(calo == "HI")
1053  {
1054  nt->Project(hname,"(EA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1055  }
1056  else if(calo == "E")
1057  {
1058  nt->Project(hname,"(EA+ES)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1059  }
1060  else if (calo == "MAG")
1061  {
1062  nt->Project(hname,"(MAG)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1063  }
1064  else if (calo == "BH")
1065  {
1066  nt->Project(hname,"(MAG)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
1067  }
1068  else
1069  {
1070  cout << "ERROR" << endl;
1071  }
1072  f->Close();
1073  h1->Draw();
1074  char fname [100];
1075  sprintf(fname, "%spercent.root",part);
1076  TFile *fout = TFile::Open(fname,"UPDATE");
1077  h1->Write();
1078  fout->Write();
1079  cout << h1->Integral() << " " << hname << " " << pz[i] << endl;
1080  //fout->Write();
1081  fout->Close();
1082  }
1083 
1084 }
1085 
1086 
1087 
1088 
1089 
1090 
1091 
1092 
1093 void EdepSmall(const char *calo="HOe")
1094 {
1095  int pz[9] = {1,2,4,8,12,16,32,40,50};
1096  double x[9];
1097  double y[9];
1098  double xer[9] = {0};
1099  double yer[9];
1100  char hname[100];
1101  TFile *fin = TFile::Open("epercent.root");
1102  gROOT->cd();
1103  for (int i=0; i<9; i++)
1104  {
1105  x[i] = pz[i];
1106  sprintf(hname,"%s%dd",calo,pz[i]);
1107 TH1 *h1 = (TH1F *) fin->Get(hname);
1108  y[i] = h1->GetMean(1);
1109  yer[i] = h1->GetRMS(1);
1110  }
1111  gr = new TGraphErrors(9,x,y,xer,yer);
1112  gr->Draw("ALP");
1113  gr->SetMarkerStyle(20);
1114  gr->SetMarkerColor(2);
1115  fin->Close();
1116 }
1117