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