Public Member Functions | Public Attributes | List of all members
ana::ResolutionScan Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-25/NDAna/nuebarcc_inc/Analysis/NeutrinoEnergyEstimator/NuebarEnergyEstimatorHelper.h"

Public Member Functions

 ResolutionScan (TFile *fin, bool _is_shifted, bool _is_flat, std::string _fit_name, std::string _xvar)
 
void MakePlot (std::string dir, TFile *fout)
 
TH1D * MeanScan ()
 
TH1D * RMSScan ()
 
std::string GetXVar ()
 
bool IsShifted ()
 
std::string GetFit ()
 

Public Attributes

Spectrumspec
 
TH2D * hist
 
double POT
 
bool is_shifted
 
bool is_flat
 
std::string fit_name
 
std::string xvar
 
std::string spec_name
 
std::vector< TH1D * > cols
 

Detailed Description

Definition at line 101 of file NuebarEnergyEstimatorHelper.h.

Constructor & Destructor Documentation

ana::ResolutionScan::ResolutionScan ( TFile *  fin,
bool  _is_shifted,
bool  _is_flat,
std::string  _fit_name,
std::string  _xvar 
)
inline

Definition at line 104 of file NuebarEnergyEstimatorHelper.h.

References cols, ana::InteractionSpectra::fit_name, analysePickle::hist, MECModelEnuComparisons::i, ana::InteractionSpectra::is_flat, ana::InteractionSpectra::is_shifted, ana::Spectrum::LoadFrom(), ana::InteractionSpectra::POT, ana::InteractionSpectra::spec_name, and ana::UniqueName().

107  : is_shifted(_is_shifted),
108  is_flat(_is_flat),
109  fit_name(_fit_name),
110  xvar(_xvar)
111  {
112  spec_name = "res_scan_" + xvar + fit_name;
113  spec_name += (is_shifted) ? "_shifted" : "";
114  spec_name += (is_flat) ? "_flat" : "_shape";
115  spec = Spectrum::LoadFrom(fin, spec_name).release();
116  POT = spec->POT();
117  hist = (TH2D*) spec->ToTH2(POT);
118  for(int i = 1; i < hist->GetNbinsX()+1; i++) {
119  cols.push_back(hist->ProjectionY(UniqueName().c_str(), i, i));
120  }
121  }
TString fin
Definition: Style.C:24
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:165
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
double POT() const
Definition: Spectrum.h:227
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29

Member Function Documentation

std::string ana::ResolutionScan::GetFit ( )
inline

Definition at line 192 of file NuebarEnergyEstimatorHelper.h.

References ana::InteractionSpectra::fit_name.

192 {return fit_name;}
std::string ana::ResolutionScan::GetXVar ( )
inline

Definition at line 190 of file NuebarEnergyEstimatorHelper.h.

190 {return xvar;}
bool ana::ResolutionScan::IsShifted ( )
inline
void ana::ResolutionScan::MakePlot ( std::string  dir,
TFile *  fout 
)
inline

Definition at line 123 of file NuebarEnergyEstimatorHelper.h.

References plot_validation_datamc::c, MECModelEnuComparisons::g, analysePickle::hist, ana::InteractionSpectra::is_flat, ana::InteractionSpectra::is_shifted, kRed, ana::InteractionSpectra::spec_name, string, plotROC::title, and tmp.

124  {
125  gStyle->SetPalette(kBlueYellow);
126  TDirectory* tmp = gDirectory;
127  std::string title = "Resolution Scan " + xvar + "(";
128  title += is_shifted ? "shifted/" : "noshift/";
129  title += is_flat ? "flat)" : "shape)";
130  hist->SetTitle(title.c_str());
131  hist->GetXaxis()->SetTitle(xvar.c_str());
132  hist->GetYaxis()->SetTitle("(Reco - True) / True #nu Energy");
133 
134  TGraph* g = new TGraph();
135  g->SetPoint(0, -1, 0);
136  g->SetPoint(1, 11, 0);
137  g->SetLineColor(kRed);
138  g->SetLineStyle(7);
139  g->SetLineWidth(3);
140 
141  TH1D* hMean = MeanScan();
142  hMean->SetLineColor(kCyan);
143 
144  TCanvas* c = new TCanvas();
145  c->cd();
146  hist->Draw("colz");
147  hMean->Draw("same el");
148  g->Draw("same");
149  fout->cd();
150  c->SaveAs((dir + spec_name + ".pdf").c_str());
151  c->Write((dir + spec_name).c_str());
152  delete c;
153  tmp->cd();
154  }
enum BeamMode kRed
Float_t tmp
Definition: plot.C:36
TDirectory * dir
Definition: macro.C:5
enum BeamMode string
TH1D* ana::ResolutionScan::MeanScan ( )
inline

Definition at line 156 of file NuebarEnergyEstimatorHelper.h.

References cols, analysePickle::hist, MECModelEnuComparisons::i, extractScale::mean, runNovaSAM::ret, extractScale::rms, std::sqrt(), and ana::UniqueName().

157  {
158  TH1D* ret = new TH1D(UniqueName().c_str(),
159  "",
160  hist->GetNbinsX(),
161  hist->GetXaxis()->GetBinLowEdge(1),
162  hist->GetXaxis()->GetBinUpEdge(hist->GetNbinsX()));
163  for(int i = 1; i < ret->GetNbinsX()+1; i++) {
164  double mean = cols[i-1]->GetMean();
165  double rms = cols[i-1]->GetRMS();
166  int N = cols[i-1]->GetEntries();
167  if(mean != 0) {
168  ret->SetBinContent(i, mean);
169  ret->SetBinError(i, rms/sqrt(N));
170  }
171  }
172  return ret;
173  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
TH1D* ana::ResolutionScan::RMSScan ( )
inline

Definition at line 175 of file NuebarEnergyEstimatorHelper.h.

References cols, analysePickle::hist, MECModelEnuComparisons::i, runNovaSAM::ret, extractScale::rms, and ana::UniqueName().

176  {
177  TH1D* ret = new TH1D(UniqueName().c_str(),
178  "",
179  hist->GetNbinsX(),
180  hist->GetXaxis()->GetBinLowEdge(1),
181  hist->GetXaxis()->GetBinUpEdge(hist->GetNbinsX()));
182  for(int i = 1; i < ret->GetNbinsX()+1; i++) {
183  double rms = cols[i-1]->GetRMS();
184  ret->SetBinContent(i, rms);
185  ret->SetBinError(i, 0);
186  }
187  return ret;
188  }
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29

Member Data Documentation

std::vector<TH1D*> ana::ResolutionScan::cols

Definition at line 202 of file NuebarEnergyEstimatorHelper.h.

std::string ana::ResolutionScan::fit_name

Definition at line 199 of file NuebarEnergyEstimatorHelper.h.

TH2D* ana::ResolutionScan::hist

Definition at line 195 of file NuebarEnergyEstimatorHelper.h.

bool ana::ResolutionScan::is_flat

Definition at line 198 of file NuebarEnergyEstimatorHelper.h.

bool ana::ResolutionScan::is_shifted

Definition at line 197 of file NuebarEnergyEstimatorHelper.h.

double ana::ResolutionScan::POT

Definition at line 196 of file NuebarEnergyEstimatorHelper.h.

Spectrum* ana::ResolutionScan::spec

Definition at line 194 of file NuebarEnergyEstimatorHelper.h.

std::string ana::ResolutionScan::spec_name

Definition at line 201 of file NuebarEnergyEstimatorHelper.h.

std::string ana::ResolutionScan::xvar

Definition at line 200 of file NuebarEnergyEstimatorHelper.h.


The documentation for this class was generated from the following file: