Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShortEdepPercent.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ShortEdepPercent.C
1 void EdepPercentSmall (const char *calo="HO", const char *part="e")
2 {
3  char infile[100];
4  int pz[9] = {1,2,4,8,12,16,32,40,50};
5  double x[9];
6 
7  for (int i=0; i<9; i++)
8 {
9  //x[i] = pz[i];
10  sprintf(infile, "%s%dout.root",part, pz[i]);
11  char hname [100];
12  sprintf(hname, "%s%s%dd",calo,part,pz[i]);
13  TH1F *h1 = new TH1F(hname, "", 100, 0, 1);
14  TFile *f = TFile::Open(infile);
15  gROOT->cd();
16  TNtuple *nt = (TNtuple *)f->Get("ed");
17  // char cal [100];
18  // sprintf(cal,"%s",calo);
19  if (calo == "HO")
20  {
21  nt->Project(hname,"(HOA+HOS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
22  }
23  else if(calo == "HI")
24  {
25  nt->Project(hname,"(HIA+HIS)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
26  }
27  else if(calo == "E")
28  {
29  nt->Project(hname,"(EA+ES)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
30  }
31  else if (calo == "MAG")
32  {
33  nt->Project(hname,"(MAG)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
34  }
35  else if (calo == "BH")
36  {
37  nt->Project(hname,"(BH)/(EA+ES+HIA+HIS+HOA+HOS+BH+MAG)");
38  }
39  else
40  {
41  cout << "ERROR" << endl;
42  }
43  f->Close();
44  h1->Draw();
45  char fname [100];
46  sprintf(fname, "%spercent.root",part);
47  TFile *fout = TFile::Open(fname,"UPDATE");
48  h1->Write();
49  fout->Write();
50  cout << h1->Integral() << " " << hname << " " << pz[i] << endl;
51  //fout->Write();
52  fout->Close();
53  }
54 }
55 void EdepSmall(const char *calo="HOe", const char *part = "e")
56 {
57  int pz[9] = {1,2,4,8,12,16,32,40,50};
58  double x[9];
59  double y[9];
60  double xer[9] = {0};
61  double yer[9];
62  char hname[100];
63  char fname[100];
64  sprintf(fname,"%spercent.root",part);
65  char area[100];
66  sprintf(area,"%s",calo);
67  TFile *fin = TFile::Open(fname);
68  gROOT->cd();
69  for (int i=0; i<9; i++)
70  {
71  x[i] = pz[i];
72  sprintf(hname,"%s%s%dd",calo,part,pz[i]);
73 TH1 *h1 = (TH1F *) fin->Get(hname);
74  y[i] = h1->GetMean(1);
75  yer[i] = h1->GetRMS(1);
76  }
77  gr = new TGraphErrors(9,x,y,xer,yer);
78  gr->SetTitle(area);
79  gr->Draw("ALP");
80  gr->SetMarkerStyle(20);
81  gr->SetMarkerColor(2);
82  fin->Close();
83 }