makePlots.C
Go to the documentation of this file.
1 //Currently, script is setup to make average correlation graph vs number of iterations for pi^{0} kinetic energy.
2 
3 #include <vector>
4 #include <string>
5 
6 #include "TF1.h"
7 #include "TH1.h"
8 #include "TFile.h"
9 #include "TGraph.h"
10 #include "TGraphErrors.h"
11 #include "TTree.h"
12 #include "TCanvas.h"
13 #include "TLegend.h"
14 #include "rootlogon.C"
15 
16 
17 void makePlots()
18 {
19 
20  TFile* file = new TFile("/nova/ana/users/kalra/tmva/SystOptimisation/Unfolding/RootFilesFor_UnfoldingMetrics_UseInMakePlotsMacro/ForPi0KE/UnfoldingMetricsEnergy.root");
21 
22 
23  int iIter = 100;
24  int iSyst = 79;
25 
26  float fChiSq[iIter];
27  float fCor[iIter];
28  float fBias[iIter];
29  float fCoverage[iIter];
30 
31  float fChiSqErr[iIter];
32  float fCorErr[iIter];
33  float fBiasErr[iIter];
34  float fCoverageErr[iIter];
35 
36 
37  TGraph* hChiSqCov[iSyst];
38  TGraph* hAverageCor[iSyst];
39  TGraph* hBias[iSyst];
40  TGraph* hCoverage[iSyst];
41 
42 
43  for(int i = 0; i < iSyst; i++){
44  char biasname[50];
45  char coveragename[50];
46  char chi2name[50];
47  char correlationname[50];
48  sprintf(biasname, "%s_%i_bias", "unf_RecopiKE", i);
49  sprintf(coveragename, "%s_%i_coverage", "unf_RecopiKE", i);
50  sprintf(chi2name, "%s_%i_chi", "unf_RecopiKE", i);
51  sprintf(correlationname, "%s_%i_correlation", "unf_RecopiKE", i);
52 
53  // sprintf(biasname, "%s_%i_bias", "unf_RecopiCOS", i);
54  // sprintf(coveragename, "%s_%i_coverage", "unf_RecopiCOS", i);
55  //sprintf(chi2name, "%s_%i_chi", "unf_RecopiCOS", i);
56  //sprintf(correlationname, "%s_%i_correlation", "unf_RecopiCOS", i);
57 
58  hChiSqCov[i] = (TGraph*)file->Get(chi2name);
59  hAverageCor[i] = (TGraph*)file->Get(correlationname);
60  hBias[i] = (TGraph*)file->Get(biasname);
61  hCoverage[i] = (TGraph*)file->Get(coveragename);
62  }
63 
64  for(int j = 0; j < iIter; j++){
65  TH1F* hChi2Holder = new TH1F("hChi2Holder",";#chi^{2};Count",100,0,200);
66  TH1F* hCorrel = new TH1F("hCorrel",";Correlation;Count",100,0,1);
67  TH1F* hBiasHolder = new TH1F("hBiasHolder",";Bias;Count",100,-10,10);
68  TH1F* hCoverHolder = new TH1F("hCoverHolder",";Coverage;Count",100,0,1);
69 
70  for(int i = 0; i < iSyst; i++){
71  Double_t x;
72  Double_t y;
73 
74  hChiSqCov[i]->GetPoint(j,x,y);
75  hChi2Holder->Fill(y);
76 
77  hAverageCor[i]->GetPoint(j,x,y);
78  //std::cout << x << "\t" << y << std::endl;
79  hCorrel->Fill(y);
80 
81  hBias[i]->GetPoint(j,x,y);
82  hBiasHolder->Fill(y);
83 
84  hCoverage[i]->GetPoint(j,x,y);
85  hCoverHolder->Fill(y);
86  }
87 
88  fChiSq[j] = (float)hChi2Holder->GetMean();
89  fCor[j] = (float)hCorrel->GetMean();
90  fBias[j] = (float)hBiasHolder->GetMean();
91  fCoverage[j] = (float)hCoverHolder->GetMean();
92 
93  fChiSqErr[j] = (float)hChi2Holder->GetRMS();
94  fCorErr[j] = (float)hCorrel->GetRMS();
95  fBiasErr[j] = (float)hBiasHolder->GetRMS();
96  fCoverageErr[j] = (float)hCoverHolder->GetRMS();
97 
98  }
99 
100  float xArray[100] = {0};
101  for(int i = 0; i < iIter; i++){
102  xArray[i] = i+1;
103  }
104  float xArrayErr[100] = {0};
105 
106  for(int i = 0; i < iIter; i++){
107  std::cout << i << ": " << fChiSq[i] << "\t"
108  << fCor[i] << "\t" << fBias[i] << "\t"
109  << fCoverage[i] << "\t" << std::endl;
110  }
111  TGraphErrors* hCoverageFinal =
112  new TGraphErrors(100, xArray, fCoverage, xArrayErr, fCoverageErr);
113 
114  TGraphErrors* hChiSqFinal =
115  new TGraphErrors(100, xArray, fChiSq, xArrayErr, fChiSqErr);
116 
117  TGraphErrors* hCorrelationFinal =
118  new TGraphErrors(100, xArray, fCor, xArrayErr, fCorErr);
119 
120  TGraphErrors* hBiasFinal =
121  new TGraphErrors(100, xArray, fBias, xArrayErr, fBiasErr);
122 
123 
124 
125  TH1F* hFrame1 = new TH1F("hFrame1", ";Iterations; #chi^{2}",
126  500,0,100);
127  for(int ibin = 0; ibin < hFrame1->GetSize(); ibin++)
128  hFrame1->SetBinContent(ibin,-100);
129 
130 
131  TH1F* hFrame2 = new TH1F("hFrame2", ";Iterations; Average Correlation",
132  500,0,100);
133  for(int ibin = 0; ibin < hFrame1->GetSize(); ibin++)
134  hFrame2->SetBinContent(ibin,-100);
135 
136  TH1F* hFrame3 = new TH1F("hFrame3", ";Iterations; Average Bias",
137  500,0,100);
138  for(int ibin = 0; ibin < hFrame1->GetSize(); ibin++)
139  hFrame3->SetBinContent(ibin,-100);
140 
141  TH1F* hFrame4 = new TH1F("hFrame4", ";Iterations; Average Coverage",
142  500,0,100);
143  for(int ibin = 0; ibin < hFrame1->GetSize(); ibin++)
144  hFrame4->SetBinContent(ibin,-100);
145 
146 
147  hFrame1->GetXaxis()->CenterTitle();
148  hFrame1->GetYaxis()->CenterTitle();
149 
150  hFrame2->GetXaxis()->CenterTitle();
151  hFrame2->GetYaxis()->CenterTitle();
152  hFrame3->GetXaxis()->CenterTitle();
153  hFrame3->GetYaxis()->CenterTitle();
154  hFrame4->GetXaxis()->CenterTitle();
155  hFrame4->GetYaxis()->CenterTitle();
156 
157 
158  TCanvas* c1 = new TCanvas("c1","c1");
159  hChiSqFinal->SetMarkerStyle(7);
160  hFrame1->GetYaxis()->SetRangeUser(0,110);
161  hFrame1->Draw();
162  hChiSqFinal->Draw("PL same");
163  c1->SaveAs("unf_RecopiKETuned_chisq_averaged.pdf");
164 
165  TCanvas* c2 = new TCanvas("c2","c2");
166  hBiasFinal->SetMarkerStyle(7);
167  hFrame3->GetYaxis()->SetRangeUser(0,0.03);
168  hFrame3->Draw();
169  hBiasFinal->Draw("PL same");
170  c2->SaveAs("unf_RecopiKETuned_bias_averaged.pdf");
171 
172  TCanvas* c3 = new TCanvas("c3","c3");
173  hCorrelationFinal->SetMarkerStyle(7);
174  hFrame2->GetYaxis()->SetRangeUser(0,1.0);
175  hFrame2->Draw();
176  hCorrelationFinal->Draw("PL same");
177  c3->SaveAs("unf_RecopiKETuned_correlation_averaged.pdf");
178 
179  TCanvas* c4 = new TCanvas("c4","c4");
180  hCoverageFinal->SetMarkerStyle(7);
181  hFrame4->GetYaxis()->SetRangeUser(0,1.0);
182  hFrame4->Draw();
183  hCoverageFinal->Draw("PL same");
184  c4->SaveAs("unf_RecopiKETuned_coverage_averaged.pdf");
185 
186 
187  // file->Close();
188 
189 }
void makePlots()
Definition: makePlots.C:17
c2
Definition: demo5.py:33
const double j
Definition: BetheBloch.cxx:29
OStream cout
Definition: OStream.cxx:6
TFile * file
Definition: cellShifts.C:17
c1
Definition: demo5.py:24