Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IntegralLoop.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file IntegralLoop.C
1 void EdepPercentSmall ()//const char *part="e")//,int nevent = 1000)
2 {
3  char infile[100];
4  int pz[9] = {1,2,4,8,12,16,32,40,50};
5  double x[9];
6  double means[9] = {0};
7  double y[9];
8  double mval = 0;
9  int lastbincont = 0;
10  bool lastbin = false;
11  int var = 11;
12  double intnum[1000] = {0};
13  double varnum[1000] = {0};
14  int i = 0;
15 
16  // for (int i=0; i<9; i++)
17  //{
18  //x[i] = pz[i];
19  //y[i] = means[i];
20  sprintf(infile, "/sphenix/user/jpinkenburg/ShowerSize/ntuple/anti_neutron_eta0_50GeV.root");
21  char hname [100];
22  sprintf(hname, "anti_neutron50");
23  TH1F *h1 = new TH1F(hname, hname, 8000, 0, 2);
24  TFile *f = TFile::Open(infile);
25  gROOT->cd();
26  TNtuple *nt = (TNtuple *)f->Get("de");
27  nt->Project(hname,"dtotal","(ID<=2)*edep","",100000);
28  //h1->Draw();
29  /* for (int j = 1000; j>0; j--)
30  {
31  if (lastbin == false)
32  {
33  if (h1->GetBinContent(j) == 0)
34  {
35  cout << j << endl;
36  }
37  else
38  {
39  lastbin = true;
40  lastbincont = (j/1000)*3.5;
41  }
42  }
43  else
44  {
45  j=0;
46  }
47  }
48  char revhname[100];
49  sprintf(revhname,"%s%dGeV",part,pz[i]);
50 
51  TH1F *h4 = new TH1F(revhname,revhname,10000,0,lastbincont);
52  nt->Project(revhname,"dtotal","(ID<=2)*edep","");
53  */f->Close();
54  h1->Draw();
55 
56  while (var <= 8001)
57  {
58  intnum[i] = h1->Integral(1,var);
59  varnum[i] = .005*(i+1);
60  var+=11;
61  i++;
62  }
63 
64  /* mval = h1->Integral();
65  // cout << "mval " << mval << endl;
66  cout << "mval_supposed_to_be " << h4->Integral() << endl;
67  means[i] += mval;
68  mval = 0;
69  cout << "6" << endl;
70  */
71  char fname [100];
72  sprintf(fname, "anti_neutron_ThinBins.root");
73  TFile *fout = TFile::Open(fname,"UPDATE");
74  h1->Write();
75  fout->Write();
76  // cout << h1->Integral() << " " << hname << " " << pz[i] << endl;
77  TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,4,1,0,50);
78  gStyle->SetOptStat(0);
79  TMarker *mean = new TMarker();
80  mean->SetMarkerStyle(20);
81  mean->SetMarkerColor(3);
82  TCanvas *c2 = new TCanvas("c2","stupid graph",1);
83  //double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
84  TGraph *gr = new TGraph((i+1),varnum,intnum);
85  gr->Draw("AC*");
86  fout->Write();
87  fout->Close();
88  // }
89  /* TFile *f1 = TFile::Open("anti_neutronShowerEdepPercent.root");
90  gROOT->cd();
91  TH2 *h2 = new TH2F("meanvals","anti_neutron",1,0,1,1,0,.01);
92  gStyle->SetOptStat(0);
93  TMarker *mean = new TMarker();
94  mean->SetMarkerStyle(20);
95  mean->SetMarkerColor(3);
96  TMarker *test = new TMarker();
97  test->SetMarkerStyle(20);
98  test->SetMarkerColor(5);
99  TCanvas *c2 = new TCanvas("c2","stupid graph",1);
100  double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
101  TGraph *gr = new TGraph(9,dtot,means);
102  gr->Draw("AC*");
103 
104  h2->Draw();
105 
106  test->DrawMarker(0.5,0.005);
107  mean->DrawMarker(0,0);
108  double dtot[9] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9};
109  double z[9];
110  // cout << "bflmv" << meanval[0] << endl;
111  for (int i=0;i<9;i++)
112  {
113  // sprintf(
114  cout << "coming" << endl;
115  z[i] = dtot[i];
116  // mean->DrawMarker(0,0);
117  // test->DrawMarker(dtot[i],.005);
118  cout << "meanval" << " " << dtot[i] << endl;
119  cout << "means" << " " << means[i] << endl;
120  // cout << means[i] << endl;
121  }
122  char fname [100];
123  sprintf(fname, "%sShowerEdepPercent.root",part);
124  TFile *fout = TFile::Open(fname,"UPDATE");
125  h2->Draw();
126  // h2->Write();
127  // fout->Write();
128  fout->Close();
129  f1->Close();
130  */
131 }
132 void EdepSmall(const char *calo="HOe", const char *part = "e")
133 {
134  int pz[9] = {1,2,4,8,12,16,32,40,50};
135  double x[9];
136  double y[9];
137  double xer[9] = {0};
138  double yer[9];
139  char hname[100];
140  char fname[100];
141  sprintf(fname,"%sShowerEdepPercent.root",part);
142  char area[100];
143  sprintf(area,"%s",calo);
144  TFile *fin = TFile::Open(fname);
145  gROOT->cd();
146  for (int i=0; i<9; i++)
147  {
148  x[i] = pz[i];
149  sprintf(hname,"%s%s%dd",calo,part,pz[i]);
150 TH1 *h1 = (TH1F *) fin->Get(hname);
151  y[i] = h1->GetMean(1);
152  yer[i] = h1->GetRMS(1);
153  }
154  gr = new TGraphErrors(9,x,y,xer,yer);
155  gr->SetTitle(area);
156  gr->Draw("ALP");
157  gr->SetMarkerStyle(20);
158  gr->SetMarkerColor(2);
159  fin->Close();
160 }