Functions | Variables
genie_plot_utils.h File Reference
#include "TH1D.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TStyle.h"
#include "TLine.h"
#include "TLegend.h"
#include "TLatex.h"
#include <iostream>

Go to the source code of this file.

Functions

TCanvas * RatioPlot (std::string name, std::vector< TH1D * > topHistos, std::vector< TString > topOption, std::vector< TH1D * > bottomHistos, std::vector< TString > bottomOption, double min=0.3, double max=1.7, std::vector< double > ls={0.8, 1, 1.2})
 
void zeroRatio (TH1D *h)
 
TCanvas * QuickUnivRatioPlot (std::string name, TH1D *hNom, std::vector< TH1D * > others)
 
void drawCoverLines (TH1D *hist)
 
void drawBinLines (std::vector< int > width)
 
void drawLabels (std::vector< std::string > labels)
 
TCanvas * SplitPlot (std::string name, std::vector< TH1D * > topHistos, std::vector< TH1D * > bottomHistos)
 

Variables

std::vector< intaxis_widths = {6,8,6,8}
 
std::vector< std::stringaxis_labels_fv
 
std::vector< std::stringaxis_labels
 

Function Documentation

void drawBinLines ( std::vector< int width)

Definition at line 186 of file genie_plot_utils.h.

References bins, MECModelEnuComparisons::i, calib::j, and PandAna.Demos.demo0::loc.

186  {
187  TLine *lone = new TLine();
188  const int bins = 20;
189 
190  double loc = 0;
191  for(unsigned int i = 0;i < width.size();++i){
192  for(int j = 0;j < width[i];++j){
193  loc+=bins;
194  if(j == width[i]-1 && i != width.size()-1){
195  lone->SetLineWidth(3);
196  lone->DrawLine(loc,gPad->GetUymin(),loc,gPad->GetUymax());
197  continue;
198  }
199  lone->SetLineWidth(1);
200  lone->DrawLine(loc,gPad->GetUymin(),loc,gPad->GetUymax());
201  }
202  }
203 }
const double j
Definition: BetheBloch.cxx:29
const Binning bins
void drawCoverLines ( TH1D *  hist)

Definition at line 169 of file genie_plot_utils.h.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, makeTrainCVSamples::int, and submit_syst::x.

169  {
170  TLine *lone = new TLine();
171 
172  std::vector<double> coverage = {0.9,0.95,0.99,0.999,0.9999};
173  std::vector<int> coverageBins;
174  for(unsigned int i = 0;i < coverage.size();++i) coverageBins.push_back(hist->FindFirstBinAbove(coverage[i]));
175 
176  std::cout<<"Coverage & PCs \\\\"<<std::endl;
177  for(unsigned int i = 0;i < coverage.size();++i){
178  double x = hist->GetBinCenter(coverageBins[i]);
179  lone->DrawLine(x,gPad->GetUymin(),x,gPad->GetUymax());
180 
181  std::cout<<100*coverage[i]<<"\\% & "<<(int)(x+0.5)<<" \\\\"<<std::endl;
182  }
183 
184 }
OStream cout
Definition: OStream.cxx:6
void drawLabels ( std::vector< std::string labels)

Definition at line 205 of file genie_plot_utils.h.

References MECModelEnuComparisons::i, art::left(), art::right(), and top.

206 {
207  double left = gPad->GetLeftMargin();
208  double right = 1-gPad->GetRightMargin();
209  double top = 1-gPad->GetTopMargin();
210  double bottom = gPad->GetBottomMargin();
211 
212  TLatex *tLabel = new TLatex();
213  tLabel->SetTextSize(0.025);
214  tLabel->SetTextAlign(12);
215  tLabel->SetTextSize(1./30);
216  tLabel->SetNDC();
217  tLabel->SetTextAngle(-90);
218 
219  double center=0;
220  for(unsigned int i = 0;i < labels.size();++i){
221  center = left+(right-left)*(1+2*i)/(labels.size()*2);
222  tLabel->DrawLatex(center, 0.95*bottom, labels[i].c_str());
223  }
224 }
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
TGeoVolume * top
Definition: make_fe_box.C:9
TCanvas* QuickUnivRatioPlot ( std::string  name,
TH1D *  hNom,
std::vector< TH1D * >  others 
)

Definition at line 147 of file genie_plot_utils.h.

References plot_validation_datamc::Clone(), make_syst_table_plots::h, MECModelEnuComparisons::i, RatioPlot(), and zeroRatio().

147  {
148  std::vector<TH1D*> h0;
149  std::vector<TString> h0opt;
150  std::vector<TH1D*> hRat;
151  std::vector<TString> hRatopt;
152 
153  h0.push_back(hNom);
154  h0opt.push_back("hist");
155  for(unsigned int i = 0;i < others.size();++i){
156  //others[i]->SetLineColor(kGray);
157  h0.push_back(others[i]);
158  h0opt.push_back("hist");
159  TH1D* h = (TH1D*)others[i]->Clone("h");
160  h->Divide(hNom);
161  zeroRatio(h);
162  hRat.push_back(h);
163  hRatopt.push_back("hist");
164  }
165 
166  return RatioPlot(name,h0,h0opt,hRat,hRatopt);
167 }
const XML_Char * name
Definition: expat.h:151
TCanvas * RatioPlot(std::string name, std::vector< TH1D * > topHistos, std::vector< TString > topOption, std::vector< TH1D * > bottomHistos, std::vector< TString > bottomOption, double min=0.3, double max=1.7, std::vector< double > ls={0.8, 1, 1.2})
void zeroRatio(TH1D *h)
TCanvas* RatioPlot ( std::string  name,
std::vector< TH1D * >  topHistos,
std::vector< TString >  topOption,
std::vector< TH1D * >  bottomHistos,
std::vector< TString >  bottomOption,
double  min = 0.3,
double  max = 1.7,
std::vector< double >  ls = {0.8,1,1.2} 
)

Definition at line 54 of file genie_plot_utils.h.

60  {0.8,1,1.2})
61 {
62  gStyle->SetTitleStyle(0);
63  TCanvas *c = new TCanvas(name.c_str(), "canvas", 1000, 700);
64  //define top and bottom pads
65  TPad* p1 = new TPad("p1", "p1", 0, 0, 1, 1);
66  TPad* p2 = new TPad("p2", "p2", 0, 0, 1, 1);
67  p1->SetNumber(1);
68  p2->SetNumber(2);
69  p1->SetBottomMargin(.55);
70  p2->SetTopMargin(.45);
71  p2->SetBottomMargin(.35);
72 
73  for(auto p:{p1,p2}){
74  p->SetFillStyle(0);
75  p->Draw();
76  }
77 
78  // format histograms
79  auto h1 = (TH1D*) topHistos[0]->Clone();
80  auto h3 = (TH1D*) bottomHistos[0]->Clone();
81 
82  for(auto & h:{h1,h3}){
83  h->SetStats(0);
84 
85  h->GetYaxis()->SetTitleSize(26);
86  h->GetYaxis()->SetTitleFont(43);
87  h->GetYaxis()->SetTitleOffset(1.3);
88  h->GetYaxis()->SetLabelFont(43);
89  h->GetYaxis()->CenterTitle();
90 
91  h->GetXaxis()->SetTitleOffset(1.2);
92  h->GetXaxis()->SetTitleSize(28);
93  h->GetXaxis()->SetTitleFont(43);
94  h->GetXaxis()->SetLabelFont(43);
95  h->GetXaxis()->CenterTitle();
96  }
97 
98  h1->GetYaxis()->SetLabelSize(18);
99 
100  h1->GetXaxis()->SetLabelSize(0);
101  h1->GetXaxis()->SetTitleSize(0);
102 
103  h3->SetTitle("");
104  h3->GetYaxis()->SetTitle("Ratio");
105  h3->GetYaxis()->SetRangeUser(min,max);
106  h3->GetYaxis()->SetLabelSize(15);
107  h3->GetYaxis()->SetDecimals();
108  h3->GetYaxis()->CenterTitle();
109 
110  h3->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
111  h3->GetXaxis()->SetLabelSize(0);
112 
113  p1->cd();
114 
115  h1->Draw(topOption[0]);
116 
117  for(unsigned int ii = 1; ii < topHistos.size(); ++ii) {
118  topHistos[ii]->Draw("same "+topOption[ii]);
119  }
120  h1->Draw("same "+topOption[0]);
121 
122  p1->RedrawAxis(); //white histograms cover axes
123 
124  p2->cd();
125  h3->Draw(bottomOption[0]);
126  for(unsigned int ii = 1; ii < bottomHistos.size(); ++ii){
127  bottomHistos[ii]->Draw("same " + bottomOption[ii]);
128  }
129  //h3->Draw("same " + bottomOption[0]);
130 
131  TLine *lone = new TLine();
132  lone->SetLineStyle(3);
133  lone->SetLineColor(kGray+3);
134  p2->Update();
135  for(unsigned int i = 0;i < ls.size();++i) lone->DrawLine(p2->GetUxmin(),ls[i],p2->GetUxmax(),ls[i]);
136  p2->RedrawAxis();
137 
138  return c;
139 }
const XML_Char * name
Definition: expat.h:151
TH1F * h3
Definition: berger.C:36
const char * p
Definition: xmltok.h:285
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
TH1F * h1
def ls(target="")
Definition: g4zmq.py:69
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
TCanvas* SplitPlot ( std::string  name,
std::vector< TH1D * >  topHistos,
std::vector< TH1D * >  bottomHistos 
)

Definition at line 226 of file genie_plot_utils.h.

References plot_validation_datamc::c, plot_validation_datamc::Clone(), make_syst_table_plots::h, h1, h3, and plot_validation_datamc::p1.

229 {
230  gStyle->SetTitleStyle(0);
231  TCanvas *c = new TCanvas(name.c_str(), "canvas", 1000, 700);
232  //define top and bottom pads
233  TPad* p1 = new TPad("p1", "p1", 0, 0, 1, 1);
234  TPad* p2 = new TPad("p2", "p2", 0, 0, 1, 1);
235  p1->SetNumber(1);
236  p2->SetNumber(2);
237  p1->SetBottomMargin(.5);
238  p2->SetTopMargin(.5);
239 
240  for(auto p:{p1,p2}){
241  p->SetFillStyle(0);
242  p->Draw();
243  }
244 
245  // format histograms
246  auto h1 = (TH1D*) topHistos[0]->Clone();
247  auto h3 = (TH1D*) bottomHistos[0]->Clone();
248 
249  for(auto & h:{h1,h3}){
250  h->SetStats(0);
251 
252  h->GetYaxis()->SetTitleSize(26);
253  h->GetYaxis()->SetTitleFont(43);
254  h->GetYaxis()->SetTitleOffset(1.3);
255  h->GetYaxis()->SetLabelFont(43);
256  h->GetYaxis()->CenterTitle();
257  h->GetYaxis()->SetRangeUser(0.75,1.25);
258 
259  h->GetXaxis()->SetTitleOffset(1.2);
260  h->GetXaxis()->SetTitleSize(28);
261  h->GetXaxis()->SetTitleFont(43);
262  h->GetXaxis()->SetLabelFont(43);
263  h->GetXaxis()->CenterTitle();
264  }
265 
266  h1->GetYaxis()->SetTitle("Shift");
267  h1->GetYaxis()->SetLabelSize(18);
268 
269  h1->GetXaxis()->SetLabelSize(0);
270  h1->GetXaxis()->SetTitleSize(0);
271 
272  h3->SetTitle("");
273  h3->GetYaxis()->SetTitle("Shift");
274  h3->GetYaxis()->SetLabelSize(15);
275  h3->GetYaxis()->SetDecimals();
276  h3->GetYaxis()->CenterTitle();
277 
278  h3->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
279  h3->GetXaxis()->SetLabelSize(0);
280 
281  p1->cd();
282 
283  h1->Draw("hist");
284 
285  for(unsigned int ii = 1; ii < topHistos.size(); ++ii) {
286  topHistos[ii]->Draw("hist same");
287  }
288  h1->Draw("hist same");
289 
290  p1->RedrawAxis(); //white histograms cover axes
291 
292  p2->cd();
293  h3->Draw("hist");
294  for(unsigned int ii = 1; ii < bottomHistos.size(); ++ii){
295  bottomHistos[ii]->Draw("hist same");
296  }
297  h3->Draw("hist same");
298 
299  TLine *lone = new TLine();
300  lone->SetLineStyle(3);
301  lone->SetLineColor(kGray+3);
302  p2->Update();
303  //for(unsigned int i = 0;i < ls.size();++i) lone->DrawLine(p2->GetUxmin(),ls[i],p2->GetUxmax(),ls[i]);
304  p2->RedrawAxis();
305 
306  return c;
307 }
const XML_Char * name
Definition: expat.h:151
TH1F * h3
Definition: berger.C:36
const char * p
Definition: xmltok.h:285
TH1F * h1
void zeroRatio ( TH1D *  h)

Definition at line 141 of file genie_plot_utils.h.

References MECModelEnuComparisons::i.

141  {
142  for(int i = 1;i <= h->GetNbinsX();++i){
143  if(h->GetBinContent(i) == 0) h->SetBinContent(i,1);
144  }
145 }

Variable Documentation

std::vector<std::string> axis_labels
Initial value:
= {
"N_{#mu}#nu_{#muQE}",
"N_{#mu}#nu_{#mu}",
"N_{#mu}NC",
"N_{e}#nu_{eQE}",
"N_{e}#nu_{e}",
"N_{e}#nu_{#mu}",
"N_{e}NC",
"F_{#mu}#nu_{#muQE}/N_{#mu}#nu_{#muQE}",
"F_{#mu}#nu_{#mu}/N_{#mu}#nu_{#mu}",
"F_{#mu}NC",
"F_{e}#nu_{eQE}/N_{#mu}#nu_{#muQE}",
"F_{e}#nu_{e}/N_{#mu}#nu_{#mu}",
"F_{e}#nu_{#mu}/N_{e}#nu_{#mu}",
"F_{e}NC/N_{e}NC"
}

Definition at line 34 of file genie_plot_utils.h.

std::vector<std::string> axis_labels_fv
Initial value:
= {
"N_{#mu}#nu_{#muQE}",
"N_{#mu}#nu_{#mu}",
"N_{#mu}NC",
"N_{e}#nu_{eQE}",
"N_{e}#nu_{e}",
"N_{e}#nu_{#mu}",
"N_{e}NC",
"F_{#mu}#nu_{#muQE}",
"F_{#mu}#nu_{#mu}",
"F_{#mu}NC",
"F_{e}#nu_{eQE}",
"F_{e}#nu_{e}",
"F_{e}#nu_{#mu}",
"F_{e}NC"
}

Definition at line 14 of file genie_plot_utils.h.

std::vector<int> axis_widths = {6,8,6,8}

Definition at line 13 of file genie_plot_utils.h.