Functions | Variables
plot_resolution.C File Reference
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/LoadFromFile.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH2.h"
#include "TLegend.h"

Go to the source code of this file.

Functions

void Compare (const std::vector< TH1 * > &hs)
 
void reco_minus_true_panels (std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
 
void plot_2d (std::map< std::string, std::map< std::string, Spectrum * >> &plots)
 
void plot_2d_vars (std::map< std::string, std::map< std::string, Spectrum * >> &plots)
 
void plot (std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
 
void plot_diff (std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
 
void plot_resolution ()
 

Variables

const std::vector< std::stringress = {"2"}
 
const std::vector< intcols = {kRed}
 

Function Documentation

void Compare ( const std::vector< TH1 * > &  hs)

Definition at line 29 of file plot_resolution.C.

References make_syst_table_plots::h, and maxy.

Referenced by genie::flux::operator<<(), genie::AxialFormFactor::operator==(), genie::ELFormFactors::operator==(), genie::QELFormFactors::operator==(), genie::DISStructureFunc::operator==(), plot(), plot_diff(), and reco_minus_true_panels().

30 {
31  double maxy = 0;
32  TH1* bigh = 0;
33  for(TH1* h: hs){
34  h->Scale(1/h->Integral());
35  if(h->GetBinContent(h->GetMaximumBin()) > maxy){
36  maxy = h->GetBinContent(h->GetMaximumBin());
37  bigh = h;
38  }
39  }
40 
41  bigh->Draw("hist");
42  for(TH1* h: hs) h->Draw("hist same");
43 }
double maxy
void plot ( std::string  label,
std::map< std::string, std::map< std::string, Spectrum * >> &  plots,
bool  log 
)

Definition at line 184 of file plot_resolution.C.

References cols, Compare(), e, make_syst_table_plots::h, he, hh, calib::j, MECModelEnuComparisons::leg, plots, ana::Spectrum::POT(), ress, string, and ana::Spectrum::ToTH1().

Referenced by plot_resolution().

185 {
186  new TCanvas;
187 
188  TLegend* leg = new TLegend(.6, .6, .85, .85);
189  leg->SetFillStyle(0);
190 
191  std::vector<TH1*> hs;
192 
193  for(unsigned int j = 0; j < ress.size(); ++j){
194  const std::string res = ress[j];
195  Spectrum* h = plots[res][label+"h"];
196  TH1* hh = h->ToTH1(h->POT());
197  hh->SetLineColor(cols[j]);
198  hh->Scale(1/hh->Integral());
199  hh->Draw(j ? "hist same" : "hist");
200  hs.push_back(hh);
201  if(!log){
202  if(label == "dist") hh->GetXaxis()->SetRangeUser(0, 40);
203  if(label == "distnorm") hh->GetXaxis()->SetRangeUser(0, 5);
204  }
205  if(label == "distnorm") hh->GetYaxis()->SetTitle("Events / cm^{2}");
206 
207  leg->AddEntry(hh, ("HoughVertex "+res).c_str(), "l");
208  }
209 
210  Spectrum* e = plots[ress[0]][label+"e"];
211  TH1* he = e->ToTH1(e->POT());
212  if(!log){
213  if(label == "dist") he->GetXaxis()->SetRangeUser(0, 40);
214  if(label == "distnorm") he->GetXaxis()->SetRangeUser(0, 5);
215  }
216  if(label == "distnorm") he->GetYaxis()->SetTitle("Events / cm^{2}");
217  he->Scale(1/he->Integral());
218  he->Draw("hist same");
219  hs.push_back(he);
220  leg->AddEntry(he, "ElasticArms", "l");
221 
222  Compare(hs);
223 
224  leg->Draw();
225 
226  if(log){
227  gPad->SetLogy();
228 
229  gPad->Print(("plots/tot_"+label+"_log.png").c_str());
230  gPad->Print(("plots/tot_"+label+"_log.eps").c_str());
231  }
232  else{
233  gPad->Print(("plots/tot_"+label+".png").c_str());
234  gPad->Print(("plots/tot_"+label+".eps").c_str());
235  }
236 }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:176
void Compare(const std::vector< TH1 * > &hs)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
Definition: log.py:1
const char * label
const std::vector< int > cols
const std::vector< Plot > plots
const double j
Definition: BetheBloch.cxx:29
double he
Definition: runWimpSim.h:113
double POT() const
Definition: Spectrum.h:226
const std::vector< std::string > ress
Float_t e
Definition: plot.C:35
hh[ixs]
Definition: PlotSingle.C:6
enum BeamMode string
void plot_2d ( std::map< std::string, std::map< std::string, Spectrum * >> &  plots)

Definition at line 113 of file plot_resolution.C.

References plot_validation_datamc::c, make_syst_table_plots::h, plots, ana::Spectrum::POT(), ress, string, and ana::Spectrum::ToTH2().

Referenced by plot_resolution().

114 {
115 
116  for(std::string res: ress){
117  TCanvas* c = new TCanvas;//("c", "c", 800, 800);
118  c->Divide(2, 2);
119 
120  c->cd(1);
121  Spectrum* xd2d = plots[res]["xd2d"];
122  TH2* h = xd2d->ToTH2(xd2d->POT());
123  h->GetYaxis()->SetTitle("ElasticArms Reco - True X (cm)");
124  h->Draw("colz");
125  gPad->SetLogz();
126 
127  c->cd(2);
128  Spectrum* yd2d = plots[res]["yd2d"];
129  h = yd2d->ToTH2(yd2d->POT());
130  h->GetYaxis()->SetTitle("ElasticArms Reco - True Y (cm)");
131  h->Draw("colz");
132  gPad->SetLogz();
133 
134  c->cd(3);
135  Spectrum* zd2d = plots[res]["zd2d"];
136  h = zd2d->ToTH2(zd2d->POT());
137  h->GetYaxis()->SetTitle("ElasticArms Reco - True Z (cm)");
138  h->Draw("colz");
139  gPad->SetLogz();
140 
141  c->cd(0);
142  gPad->Print(("plots/vtx_compare"+res+".png").c_str());
143  gPad->Print(("plots/vtx_compare"+res+".eps").c_str());
144  }
145 }
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:193
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const std::vector< Plot > plots
double POT() const
Definition: Spectrum.h:226
const std::vector< std::string > ress
enum BeamMode string
void plot_2d_vars ( std::map< std::string, std::map< std::string, Spectrum * >> &  plots)

Definition at line 147 of file plot_resolution.C.

References plot_validation_datamc::c, make_syst_table_plots::h, plots, ana::Spectrum::POT(), ress, string, and ana::Spectrum::ToTH2().

Referenced by plot_resolution().

148 {
149 
150  for(std::string res: ress){
151  TCanvas* c = new TCanvas;//("c", "c", 800, 800);
152  c->Divide(2, 2);
153 
154  c->cd(1);
155  Spectrum* disth2d = plots[res]["disth2d"];
156  TH2* h = disth2d->ToTH2(disth2d->POT());
157  h->Draw("colz");
158  gPad->SetLogz();
159 
160  c->cd(2);
161  Spectrum* diste2d = plots[res]["diste2d"];
162  h = diste2d->ToTH2(diste2d->POT());
163  h->Draw("colz");
164  gPad->SetLogz();
165 
166  c->cd(3);
167  Spectrum* calh2d = plots[res]["calh2d"];
168  h = calh2d->ToTH2(calh2d->POT());
169  h->Draw("colz");
170  gPad->SetLogz();
171 
172  c->cd(4);
173  Spectrum* cale2d = plots[res]["cale2d"];
174  h = cale2d->ToTH2(cale2d->POT());
175  h->Draw("colz");
176  gPad->SetLogz();
177 
178  c->cd(0);
179  gPad->Print(("plots/vtx_distvar"+res+".png").c_str());
180  gPad->Print(("plots/vtx_distvar"+res+".eps").c_str());
181  }
182 }
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:193
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const std::vector< Plot > plots
double POT() const
Definition: Spectrum.h:226
const std::vector< std::string > ress
enum BeamMode string
void plot_diff ( std::map< std::string, std::map< std::string, Spectrum * >> &  plots,
bool  log 
)

Definition at line 238 of file plot_resolution.C.

References cols, Compare(), calib::j, MECModelEnuComparisons::leg, plots, ana::Spectrum::POT(), ress, string, and ana::Spectrum::ToTH1().

Referenced by plot_resolution().

239 {
240  new TCanvas;
241 
242  TLegend* leg = new TLegend(.6, .6, .85, .85);
243  leg->SetFillStyle(0);
244 
245  std::vector<TH1*> hs;
246 
247  for(unsigned int j = 0; j < ress.size(); ++j){
248  const std::string res = ress[j];
249  Spectrum* distdiffh = plots[res]["distdiff"];
250  TH1* hdistdiffh = distdiffh->ToTH1(distdiffh->POT());
251  hdistdiffh->SetLineColor(cols[j]);
252  hdistdiffh->Scale(1/hdistdiffh->Integral());
253  hdistdiffh->Draw(j ? "hist same" : "hist");
254  hs.push_back(hdistdiffh);
255  if(!log) hdistdiffh->GetXaxis()->SetRangeUser(-20, +20);
256 
257  leg->AddEntry(hdistdiffh, ("HoughVertex "+res).c_str(), "l");
258  }
259 
260  Compare(hs);
261 
262  leg->Draw();
263 
264  if(log){
265  gPad->SetLogy();
266 
267  gPad->Print("plots/dist_diff_log.png");
268  gPad->Print("plots/dist_diff_log.eps");
269  }
270  else{
271  gPad->Print("plots/dist_diff.png");
272  gPad->Print("plots/dist_diff.eps");
273  }
274 }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:176
void Compare(const std::vector< TH1 * > &hs)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
Definition: log.py:1
const std::vector< int > cols
const std::vector< Plot > plots
const double j
Definition: BetheBloch.cxx:29
double POT() const
Definition: Spectrum.h:226
const std::vector< std::string > ress
enum BeamMode string
void plot_resolution ( )

Definition at line 276 of file plot_resolution.C.

References plot_validation_datamc::fname, plot(), plot_2d(), plot_2d_vars(), plot_diff(), plots, reco_minus_true_panels(), runNovaSAM::release, ress, and string.

277 {
278  std::map<std::string, std::map<std::string, Spectrum*>> plots;
279 
280  // Set up to be able to compare scans over HoughVertex parameter
281  // SigmaZ
282  // Can be easily modified to scan over other parameters
283 
284  for(std::string res: ress){//{"0.5", "1", "2"}){
285  const std::string fname = "sigma."+res+".nonswap.root";
286 
287  for(std::string name: {"xdh", "ydh", "zdh", "xde", "yde", "zde",
288  "xd2d", "yd2d", "zd2d", "disth", "diste", "disth2d", "diste2d", "calh2d", "cale2d", "distnormh", "distnorme", "distdiff"}){
289  plots[res][name] = LoadFromFile<Spectrum>(fname, name).release();
290  }
291  }
292 
293  reco_minus_true_panels(plots, false);
294  reco_minus_true_panels(plots, true);
295 
296  plot_2d(plots);
297  plot_2d_vars(plots);
298 
299  plot("dist", plots, false);
300  plot("dist", plots, true);
301 
302  plot("distnorm", plots, false);
303  plot("distnorm", plots, true);
304 
305  plot_diff(plots, false);
306  plot_diff(plots, true);
307 }
const XML_Char * name
Definition: expat.h:151
void reco_minus_true_panels(std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
void plot_2d(std::map< std::string, std::map< std::string, Spectrum * >> &plots)
void plot_2d_vars(std::map< std::string, std::map< std::string, Spectrum * >> &plots)
const std::vector< Plot > plots
void plot_diff(std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
const std::vector< std::string > ress
void plot(std::string label, std::map< std::string, std::map< std::string, Spectrum * >> &plots, bool log)
enum BeamMode string
void reco_minus_true_panels ( std::map< std::string, std::map< std::string, Spectrum * >> &  plots,
bool  log 
)

Definition at line 45 of file plot_resolution.C.

References plot_validation_datamc::c, cols, Compare(), e, make_syst_table_plots::h, he, hh, MECModelEnuComparisons::i, calib::j, label, PandAna.Demos.pi0_spectra::labels, MECModelEnuComparisons::leg, plots, ana::Spectrum::POT(), ress, string, and ana::Spectrum::ToTH1().

Referenced by plot_resolution().

46 {
47  TCanvas* c = new TCanvas;
48  c->Divide(2, 2);
49 
50  const std::vector<std::string> labels = {"xd", "yd", "zd"};
51 
52  TLegend* leg = new TLegend(.1, .2, .9, .8);
53 
54  for(int i = 0; i < 3; ++i){
55  std::string label = labels[i];
56 
57  c->cd(i+1);
58 
59  std::vector<TH1*> hs;
60 
61  for(unsigned int j = 0; j < ress.size(); ++j){
62  const std::string res = ress[j];
63 
64  Spectrum* h = plots[res][label+"h"];
65  TH1* hh = h->ToTH1(h->POT());
66  hh->Scale(1/hh->Integral());
67  hh->SetLineColor(cols[j]);
68  hs.push_back(hh);
69  hh->Draw(j ? "hist same" : "hist");
70  if(!log) hh->GetXaxis()->SetRangeUser(-20, +20);
71 
72  if(i == 0){
73  leg->AddEntry(hh, ("HoughVertex "+res).c_str(), "l");
74  }
75  }
76 
77  Spectrum* e = plots[ress[0]][label+"e"];
78  TH1* he = e->ToTH1(e->POT());
79  if(!log) he->GetXaxis()->SetRangeUser(-20, +20);
80  hs.push_back(he);
81  he->Scale(1/he->Integral());
82  he->Draw("hist same");
83 
84  Compare(hs);
85 
86  if(i == 0){
87  leg->AddEntry(he, "ElasticArms", "l");
88  }
89  }
90 
91  c->cd(4);
92  leg->Draw();
93 
94  if(log){
95  c->cd(1);
96  gPad->SetLogy();
97  c->cd(2);
98  gPad->SetLogy();
99  c->cd(3);
100  gPad->SetLogy();
101  c->cd(0);
102 
103  gPad->Print("plots/vtx_res_log.png");
104  gPad->Print("plots/vtx_res_log.eps");
105  }
106  else{
107  c->cd(0);
108  gPad->Print("plots/vtx_res.png");
109  gPad->Print("plots/vtx_res.eps");
110  }
111 }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:176
void Compare(const std::vector< TH1 * > &hs)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
Definition: log.py:1
const char * label
const std::vector< int > cols
const std::vector< Plot > plots
const double j
Definition: BetheBloch.cxx:29
double he
Definition: runWimpSim.h:113
double POT() const
Definition: Spectrum.h:226
const std::vector< std::string > ress
Float_t e
Definition: plot.C:35
hh[ixs]
Definition: PlotSingle.C:6
enum BeamMode string

Variable Documentation

const std::vector<int> cols = {kRed}

Definition at line 26 of file plot_resolution.C.

Referenced by plot(), plot_diff(), and reco_minus_true_panels().

const std::vector<std::string> ress = {"2"}