Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GammaNeutronEnergy.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GammaNeutronEnergy.C
1 void EdepPercentSmall (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
2 {
3  cout << "TEST VII" << endl;
4  char infile[100];
5  int pz[9] = {1,2,4,8,12,16,32,40,50};
6  double x[9];
7  double means[9] = {0};
8  double y[9];
9  double mval = 0;
10  int lastbincont = 0;
11  bool lastbin = false;
12  int var = 11;
13  double intnum[1000] = {0};
14  double varnum[1000] = {0};
15  char *part[] = {"anti_neutron"};
16  int i = 0;
17  int w =4;
18  //TCanvas *c3 = new TCanvas("TresGraphitos","stupid graph",1);
19  // TH1F *h4 = new TH1F("histo","histo",1000,0,.5);
20  //TH2F *h3 = new TH2F("HistoGraph","HistoGraph",1000,0,.55,1000,0,1.2);
21  // TMarker *grmark = new TMarker();
22  // TCanvas *c19 = new TCanvas();
23  // h3->Draw();
24  for (int q=0; q<1; q++)
25  {
26  for (int w=0; w<9;w++)
27  {
28  cout << "TEST VI" << endl;
29  char ffile[100];
30  sprintf(ffile,"/phenix/u/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/HistoBaseFiles/%s_ThinBins.root", part[q]);
31  TFile *f = TFile::Open(ffile);
32  char hname[100];
33  sprintf(hname,"%s%dd",part[q],pz[w]);
34  TH1F *h1 = (TH1F *)f->Get(hname);
35  var = 11;
36  i = 0;
37  while (var <= 8001)
38  {
39 
40  if (i<1000)
41  {
42  varnum[i] = .005*(i);
43  intnum[i] = (h1->Integral(1,var))/(h1->Integral());
44  i++;
45  }
46  var+=10;
47  }
48  varnum[0] = 0;
49  intnum[0] = 0;
50  char fname [100];
51  sprintf(fname, "Gamma_Neutron_Energy_Graphs.root");
52  TFile *fout = TFile::Open(fname,"UPDATE");
53  // h1->Write();
54  //fout->Write();
55  f->Close();
56  //char hname[100];
57  //sprintf(hname,"%s%dGeV",part[q],pz[w]);
58  // cout << h1->Integral() << " " << hname << " " << pz[i] << endl;
59  //TH2 *h2 = new TH2F("hname","hname",1,0,5,1,0,1.2);
60  gStyle->SetOptStat(0);
61 
62 
63  TMarker *mean = new TMarker();
64  mean->SetMarkerStyle(20);
65  mean->SetMarkerColor(3);
66  char canvname[100];
67  sprintf(canvname,"%s%d",part[q],pz[w]);
68  //TCanvas *c3 = new TCanvas(canvname,"stupid graph",1);
69  //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
70  cout << "TEST V" << endl;
71  TGraph *gr = new TGraph((i-2),varnum,intnum);
72  char gtitle[100];
73  sprintf(gtitle,"%s%dGeV;ConeSize;Percentage of Energy Deposited",part[q],pz[w]);
74  char gname[100];
75  sprintf(gname,"%s%dGeV",part[q],pz[w]);
76  cout << intnum[50] << " " << varnum[50] << endl;
77  gr->SetTitle(gtitle);
78  gr->SetName(gname);
79  gr->SetMarkerStyle(20);
80  if (part[q] == "anti_neutron")
81  {
82  gr->SetMarkerColor(4);
83  }
84  else if (part[q] == "neutron")
85  {
86  gr->SetMarkerColor(2);
87  }
88  else if (part[q] == "gamma")
89  {
90  gr->SetMarkerColor(3);
91  }
92  else
93  {
94  cout << "idiot" << endl;
95  }
96  gr->SetMaximum(1.2);
97  //h2->Draw();
98  //gr->Draw("A*");
99  //gr->Draw("ALP")
100  //c3->DrawFrame(0,0,0.5,1.2);
101  // gr->PaintGrapHist((i-1),varnum,intnum,"chopt");
102  // gr->SetHistogram(h4);
103  //h4->Write();
104  gr->Write();
105  cout << "TEST 1" << endl;
106  // TH2F *h3 = (TH2F *) "HistoGraph";
107  cout << "TEST II" << endl;
108 
109  cout << "TEST III" << endl;
110  //h3->Write();
111  cout << "TEST IV" << endl;
112  //double x;
113  //double y;
114  //gr()->GetPoint(
115 
116  fout->Write();
117  fout->Close();
118  // gr->Close();
119  for (int a=0;a<1000;a++)
120  {
121  intnum[a] = 0;
122  varnum[a] = 0;
123  }
124 
125  }
126  }
127 
128  /* int engy[2] = {2,50};
129  for (int j=2;j<2;j++)
130  {
131  cout << "TEST VIII" << endl;
132  TFile *fhist = TFile::Open("PosterHistos.root");
133  cout << "TEST IX" << endl;
134  // char anhtotname[300];
135  //sprintf(anhtotname,"anti_neutron%dGeV;ConeSize;Percentage of Energy Deposited",pz[j]);
136  // auto h32 = (TH2F*)fhist->Get(anhtotname);
137  char nhtotname[300];
138  sprintf(nhtotname,"neutron%dGeV;ConeSize;Percentage of Energy Deposited",engy[j]);
139  auto h12 = (TH2F*)fhist->Get(nhtotname);
140  cout << "TEST X" << endl;
141  char ghtotname[300];
142  sprintf(ghtotname,"gamma%dGeV;ConeSize;Percentage of Energy Deposited",engy[j]);
143  auto h22 = (TH2F*)fhist->Get(ghtotname);
144  cout << "TEST XI" << endl;
145  TCanvas *c12 = new TCanvas();
146  cout << "TEST XII" << endl;
147  // h32->Draw();
148  cout << "TEST XIII" << endl;
149  h12->Draw();
150  h22->Draw("PMC same");
151  cout <<"TEST XIV" << endl;
152  fhist->Close();
153  cout << "DONE" << endl;
154  }
155  TCanvas *c123 = new TCanvas();
156  TFile *ff = TFile::Open("PosterHistos.root");
157  auto h101 = (TH2F*)ff->Get("gamma1GeV;ConeSize;Percentage of Energy Deposited");
158  h101->Draw();
159  ff->Close();
160  for (int o=0;o<8;o++)
161  {
162  TFile *f_all = TFile::Open("PosterHistos.root");
163  char aname[200];
164  sprintf(aname,"gamma%dGeV;ConeSize;Percentage of Energy Deposited",pz[(o+1)]);
165  auto h100 = (TH2F*)f_all->Get(aname);
166  h100->Draw("PMC same");
167  f_all->Close();
168 
169  }
170  */
171 }
172 
173 
174 void ThreeGraphs (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
175 {
176 
177  char infile[100];
178  int pz[9] = {1,2,4,8,12,16,32,40,50};
179  double x[9];
180  double means[9] = {0};
181  double y[9];
182  double mval = 0;
183  int lastbincont = 0;
184  bool lastbin = false;
185  int var = 11;
186  double intnum[1000] = {0};
187  double varnum[1000] = {0};
188  char *part[] = {"gamma","neutron","anti_neutron"};
189  int i = 0;
190 TGraph *gr = new TGraph();
191 
192  for (int q=0; q<3; q++)
193  {
194  // for (int w=0; w<9;w++)
195  // {
196  char ffile[100];
197  sprintf(ffile,"%s_ThinBins.root", part[q]);
198  TFile *f = TFile::Open(ffile);
199  char hname[100];
200  sprintf(hname,"%s12d",part[q]/*,pz[w]*/);
201  TH1F *h1 = (TH1F *)f->Get(hname);
202  var = 11;
203  i = 0;
204  while (var <= 8001)
205  {
206 
207  if (i<100)
208  {
209  varnum[i] = .005*(i+1);
210  intnum[i] = (h1->Integral(1,var))/(h1->Integral());
211  }
212  var+=10;
213  i++;
214  }
215  /* mval = h1->Integral();
216  // cout << "mval " << mval << endl;
217  cout << "mval_supposed_to_be " << h4->Integral() << endl;
218  means[i] += mval;
219  mval = 0;
220  cout << "6" << endl;
221  */
222 
223  char fname [100];
224  sprintf(fname, "PosterHistos.root");
225 y TFile *fout = TFile::Open(fname,"UPDATE");
226  h1->Write();
227  //fout->Write();
228  f->Close();
229  // cout << h1->Integral() << " " << hname << " " << pz[i] << endl;
230  //char canvname[100];
231  // sprintf(canvname,"%s12",part[q]/*,pz[w]*/);
232 
233  // TCanvas *c3 = new TCanvas("3Graphs","stupid graph",1);
234  TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,4,1,0,50);
235  gStyle->SetOptStat(0);
236  TMarker *mean = new TMarker();
237  mean->SetMarkerStyle(20);
238  mean->SetMarkerColor(3);
239  //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
240  // TGraph *gr = TGraph((i-1),varnum,intnum);
241  gr->TGraph((i-1),varnum,intnum);
242  char gname[100];
243  sprintf(gname,"12GeV;xtitle;ytitle"/*,part[q]/*,pz[w]*/);
244  gr->SetTitle(gname);
245  gr->SetName(gname);
246  gr->Draw("A*");
247  // gr->Write();
248  // c3->Update();
249  //c3->Modified();
250  // fout->Write();
251  // fout->Close();
252  // gr->Close();
253  for (int a=0;a<1000;a++)
254  {
255  intnum[a] = 0;
256  varnum[a] = 0;
257  }
258  // }
259  // }
260  }
261  fout->Write();
262  fout->Close();
263 }
264 
265 
266 
267 
268 
269 void StupidGraphs (/*TH1 *h1*/)//const char *part="e")//,int nevent = 1000)
270 {
271  TFile *fin = TFile::Open("PosterHistos.root");
272  gROOT->cd();
273  TH2 *h2 = new TH2F("DumbGraph","TresLines",1,0,10,1,0,50);
274  gStyle->SetOptStat(0);
275  TMarker *spf = new TMarker();
276  spf->SetMarkerStyle(20);
277  spf->SetMarkerColor(4);
278  TCanvas *c1 = new TCanvas();
279  h2->Draw();
280  double x;
281  double y;
282 
283  char hname[100];
284  sprintf(hname, "meanvals");
285  TH2 *gr = (TH2F *) fin->Get(hname);
286  cout << "herro" << endl;
287  cout << gr()->GetPoint(1,x,y) << endl;
288 //spf->DrawMarker();
289 
290 }
291 
292