plot_quantbound_twosamples.C
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////
2 // plot_quantbound_twosamples.C //
3 // //
4 // print the quantile boundaries from two samples in the same canvas //
5 // fhc = true prints fhc and rhc boundaries with fhc colz background //
6 // uses rhc colz if fhc = false //
7 // //
8 // colzbkg = false prints the two boundaries but no colz background //
9 //////////////////////////////////////////////////////////////////////////
10 
11 #include "includes.h"
12 
13 using namespace ana;
14 
15 
16 void plot_quantbound_twosamples(bool fhc = true, bool colzbkg = true){
17 
20  std::string name_one, name_two;
21  Color_t color_one, color_two;
22  Style_t line_one = kSolid, line_two = kSolid;
23  int color_pal = kFuchsia;
24  //TColor::InvertPalette();
25 
26  if(fhc){
27  horn_one = "fhc"; name_one = "FHC";
28  horn_two = "rhc"; name_two = "RHC";
29  color_one = kBlue-7; color_two = kMagenta+1;
30  }
31  if(!fhc){
32  horn_one = "rhc"; name_one = "RHC";
33  horn_two = "fhc"; name_two = "FHC";
34  color_one = kMagenta+1; color_two = kBlue-7;
35  }
36 
37 
38  const int nBins= 19;
39  const int nQuant= 4;
40  std::string filename1 = "/nova/ana/nu_mu_ana/Ana2018/Quantiles/quantiles__" + horn_one + "_full__numu2018.root";
41  std::string filename2 = "/nova/ana/nu_mu_ana/Ana2018/Quantiles/quantiles__" + horn_two + "_full__numu2018.root";
42 
43  TFile* infile1= TFile::Open(pnfs2xrootd(filename1).c_str());
44  TFile* infile2= TFile::Open(pnfs2xrootd(filename2).c_str());
45  TH2* quanthist1 = (TH2*)infile1->Get("FDSpec2D");
46  TH2* quanthist2 = (TH2*)infile2->Get("FDSpec2D");
47  std::vector< std::vector<double> > QuantBounds1 = GetQuantileBins(quanthist1, kNumuCCOptimisedAxis, kHadEFracAxis, nQuant, 1);
48  std::vector< std::vector<double> > QuantBounds2 = GetQuantileBins(quanthist2, kNumuCCOptimisedAxis, kHadEFracAxis, nQuant, 1);
49 
50  std::vector< TH1* > hist_bound1;
51  std::vector< TH1* > hist_bound2;
52 
53  // fill histograms in different loops, otherwise script messes up
54  for(int thisQuant = 0; thisQuant < nQuant; thisQuant++){
55  TH1* h_temp1 = quanthist1->ProjectionX();
56  h_temp1-> Clear();
57  for(int bin = 1; bin <= nBins; bin++){
58  double bound1 = QuantBounds1[bin][thisQuant];
59  h_temp1-> SetBinContent(bin, bound1);
60  }
61  hist_bound1.push_back(h_temp1);
62  }
63  for(int thisQuant = 0; thisQuant < nQuant; thisQuant++){
64  TH1* h_temp2 = quanthist2->ProjectionX();
65  h_temp2-> Clear();
66  for(int bin = 1; bin <= nBins; bin++){
67  double bound2 = QuantBounds2[bin][thisQuant];
68  h_temp2-> SetBinContent(bin, bound2);
69  }
70  hist_bound2.push_back(h_temp2);
71  }
72 
73 
74  gStyle->SetPalette(color_pal);
75  gStyle->SetPadRightMargin(0.11);
76  new TCanvas("canvas");
77  gPad->SetFillStyle(0);
78  TH2* axes = new TH2F("axes", "", 20, 0.0, 5.0, 10, 0., 1.);
79  std::string name_colz;
80  if(colzbkg){
81  name_colz = "__colzbkg";
82  quanthist1-> Draw("colz");
83  quanthist1->GetYaxis()->SetTitle("E_{had} / E_{#nu}");
84  quanthist1->GetXaxis()->CenterTitle();
85  quanthist1->GetYaxis()->CenterTitle();
86  }
87  else{
88  axes->GetXaxis()->SetTitle("Reconstructed Neutrino Energy (GeV)");
89  axes->GetYaxis()->SetTitle("E_{had} / E_{#nu}");
90  axes->GetXaxis()->CenterTitle();
91  axes->GetYaxis()->CenterTitle();
92  axes->Draw();
93  }
94  for(int thisQuant = 1; thisQuant < nQuant; thisQuant++){
95  hist_bound1[thisQuant] -> SetLineColor(color_one);
96  hist_bound2[thisQuant] -> SetLineColor(color_two);
97  hist_bound1[thisQuant] -> SetLineStyle(line_one);
98  hist_bound2[thisQuant] -> SetLineStyle(line_two);
99  hist_bound1[thisQuant] -> Draw("hist same][");
100  hist_bound2[thisQuant] -> Draw("hist same][");
101  }
102 
103  TLegend *legend = new TLegend(0.15,0.70,0.30,0.85);
104  legend->AddEntry(hist_bound1[1], Form("%s", name_one.c_str()),"l");
105  legend->AddEntry(hist_bound2[1], Form("%s", name_two.c_str()),"l");
106  legend->SetTextSize(0.05); //no border for legend
107  legend->SetBorderSize(0); //no border for legend
108  legend->SetFillStyle(0); //fill colour is transparent
109  legend->Draw();
110  gPad->Update();
111 
112 
113  TString outname = "ndfd_quantiles__" + horn_one + "_" + horn_two + "_full__numu2018" + name_colz;
114  gPad-> Print(outname + ".pdf");
115  gPad-> Print(outname + ".png");
116 
117 }
tree Draw("slc.nhit")
int nBins
Definition: plotROC.py:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void plot_quantbound_twosamples(bool fhc=true, bool colzbkg=true)
hmean SetLineStyle(2)
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
std::vector< std::vector< double > > GetQuantileBins(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
Returns a 2D vector First index is the independentAxis bin number Second index is the high bin edge f...
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: Utilities.cxx:620
hmean SetLineColor(4)
float bin[41]
Definition: plottest35.C:14
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
cout<< "--"<< endl;for(Int_t iP=1;iP<=hyz->GetNbinsX();iP++){for(Int_t iC=1;iC<=hyz->GetNbinsY();iC++){if(hyv->GetBinContent(iP, iC)>-999){goal_hyv-> SetBinContent(iP, iC,-(dy[iP-1][iC-1]))
void Print(std::string prefix, std::string name, std::string suffix="")
Definition: nue_pid_effs.C:68
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const int nQuant
Definition: varsandcuts.h:4
std::string horn_one
Definition: saveFDMCHists.C:33
std::string horn_two
Definition: saveFDMCHists.C:34