Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ana::RecoReweight Class Reference

Extrapolates using reco-over-reco method. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-25/CAFAna/Extrap/ModularExtrapComponent.h"

Inheritance diagram for ana::RecoReweight:
ana::ModularExtrapComponent

Public Member Functions

 RecoReweight (SpectrumLoaderBase &ndloader, const HistAxis &axis, const Cut &fdcut, const SystShifts &shiftMC, const Var &weight, std::string label, std::string latex, const Cut &ndcut, const IDecomp &decomposition, const DecompResult dr, const Cut &ndflavor, SpectrumLoaderBase &fdloader, const Cut &fdflavors, SpectrumLoaderBase &extrafdloaderswap=kNullLoader, SpectrumLoaderBase &extrafdloadertau=kNullLoader)
 
 ~RecoReweight ()
 
OscillatableSpectrum Eval () const override
 Core extrapolation math. More...
 
void SaveTo (TDirectory *dir, const std::string &name) const override
 
void SavePlots (TDirectory *dir, double potFD) const override
 
TH1 * OptimalBinning (double potMCFD, double potMCND) const
 Uses MC spectra and target MC stats to estimate optimal binning. More...
 
TH1 * OptimalBinningFit (double potMCFD, double potMCND) const
 Fits gaussians to FD and ND MC to estimate optimal binning. More...
 
const IDecompGetDecomp () const override
 
const OscillatableSpectrumReturn () const
 Interface so that result of Eval() is called only once and cached. More...
 

Static Public Member Functions

static std::unique_ptr< RecoReweightLoadFrom (TDirectory *dir, const std::string &name)
 
static TH1 * OptimalBinningHelper (TH1 *, TH1 *)
 
static void SetQuiet (bool quiet=true)
 

Static Protected Member Functions

static Spectrum GetDecompResult (const IDecomp &, DecompResult)
 Helper function to pick out single Spectrum from a decomposition. More...
 
static std::string DRToString (DecompResult)
 Helper function to turn a DecompResult into a string (for storage). More...
 
static DecompResult StringToDR (std::string)
 Helper function to turn a string into a DecompResult (for loading). More...
 
static Ratio FormSmartRatio (const Spectrum &num, const Spectrum &denom, std::string component, std::string location, const Spectrum &mult)
 Form Ratio, but be aware of zero division. More...
 
static void ComparisonPlot (Spectrum mc, Spectrum notMC, double pot, std::string notMCLabel, int notMCColor, std::string latex, std::string title, std::string saveAs, bool restrictRange=false)
 

Private Member Functions

 RecoReweight (Spectrum recoND, OscillatableSpectrum trueToRecoFD, const IDecomp &decomp, const DecompResult decompRes, std::string label, std::string latex)
 

Private Attributes

Spectrum fRecoND
 
OscillatableSpectrum fTrueToRecoFD
 
const IDecompfDecomp
 
bool fOwnDecomp
 
const DecompResult fDecompRes
 
std::string fLabel
 
std::string fLatex
 

Friends

class ModularExtrap
 

Detailed Description

Extrapolates using reco-over-reco method.

Definition at line 176 of file ModularExtrapComponent.h.

Constructor & Destructor Documentation

ana::RecoReweight::RecoReweight ( SpectrumLoaderBase ndloader,
const HistAxis axis,
const Cut fdcut,
const SystShifts shiftMC,
const Var weight,
std::string  label,
std::string  latex,
const Cut ndcut,
const IDecomp decomposition,
const DecompResult  dr,
const Cut ndflavor,
SpectrumLoaderBase fdloader,
const Cut fdflavors,
SpectrumLoaderBase extrafdloaderswap = kNullLoader,
SpectrumLoaderBase extrafdloadertau = kNullLoader 
)

Definition at line 336 of file ModularExtrapComponent.cxx.

References ana::SpectrumLoaderBase::AddReweightableSpectrum(), fTrueToRecoFD, ana::_HistAxis< T >::GetVar1D(), ana::kTrueE, and ana::weight.

Referenced by LoadFrom().

353  : fRecoND(ndloader, axis, ndcut && ndflavor, shiftMC, weight),
354  fTrueToRecoFD(fdloader, axis, fdcut && fdflavors, shiftMC, weight),
355  fDecomp(&decomposition),
356  fOwnDecomp(false),
357  fDecompRes(dr),
358  fLabel(label),
359  fLatex(latex)
360  {
361  extrafdloaderswap.AddReweightableSpectrum(
362  fTrueToRecoFD, axis.GetVar1D(), kTrueE, fdcut && fdflavors, shiftMC, weight);
363  extrafdloadertau.AddReweightableSpectrum(
364  fTrueToRecoFD, axis.GetVar1D(), kTrueE, fdcut && fdflavors, shiftMC, weight);
365  }
void latex(double x, double y, std::string txt, double ang=0, int align=22, double size=0.042)
const Var weight
const DecompResult fDecompRes
const char * label
OscillatableSpectrum fTrueToRecoFD
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
ana::RecoReweight::~RecoReweight ( )

Definition at line 367 of file ModularExtrapComponent.cxx.

References fDecomp, and fOwnDecomp.

368  {
369  if(fOwnDecomp) delete fDecomp;
370  }
ana::RecoReweight::RecoReweight ( Spectrum  recoND,
OscillatableSpectrum  trueToRecoFD,
const IDecomp decomp,
const DecompResult  decompRes,
std::string  label,
std::string  latex 
)
inlineprivate

Definition at line 213 of file ModularExtrapComponent.h.

220  : fRecoND(recoND), fTrueToRecoFD(trueToRecoFD),
221  fDecomp(&decomp), fOwnDecomp(false), fDecompRes(decompRes),
222  fLabel(label), fLatex(latex) {}
void latex(double x, double y, std::string txt, double ang=0, int align=22, double size=0.042)
const DecompResult fDecompRes
const char * label
OscillatableSpectrum fTrueToRecoFD

Member Function Documentation

void ana::ModularExtrapComponent::ComparisonPlot ( Spectrum  mc,
Spectrum  notMC,
double  pot,
std::string  notMCLabel,
int  notMCColor,
std::string  latex,
std::string  title,
std::string  saveAs,
bool  restrictRange = false 
)
staticprotectedinherited

Definition at line 17 of file ModularExtrapComponentPlot.cxx.

References plot_validation_datamc::c, kRed, make_mec_shifts_plots::legend, and ana::Spectrum::ToTH1().

Referenced by ana::FluxReweight::SavePlots(), ana::TruthReweight::SavePlots(), and SavePlots().

27  {
28  TH1* histMC( mc.ToTH1(pot) );
29  TH1* histNotMC( notMC.ToTH1(pot) );
30  histMC->SetLineColor( kRed );
31  histNotMC->SetLineColor( notMCColor );
32  TCanvas c;
33  histMC->SetMaximum( 1.5 * histMC->GetMaximum() );
34  if (restrictRange) histMC->GetXaxis()->SetRangeUser( 0.5, 3.5);
35  histMC->SetTitle( (latex+" "+title).c_str() );
36  histMC->Draw("hist");
37  histNotMC->Draw("same");
38  TLegend legend( .15, .7, .4, .85 );
39  legend.SetTextSize(0.05);
40  legend.AddEntry( histNotMC, notMCLabel.c_str() );
41  legend.AddEntry( histMC, "MC" );
42  legend.SetFillStyle(0);
43  legend.Draw();
44  histMC->Write( (TString)"MC"+saveAs.c_str());
45  histNotMC->Write( (TString)notMCLabel.c_str() + saveAs.c_str());
46 
47  c.Write( saveAs.c_str() );
48  delete histMC;
49  delete histNotMC;
50  }
void latex(double x, double y, std::string txt, double ang=0, int align=22, double size=0.042)
enum BeamMode kRed
#define pot
std::string ana::ModularExtrapComponent::DRToString ( DecompResult  dr)
staticprotectedinherited

Helper function to turn a DecompResult into a string (for storage).

Definition at line 98 of file ModularExtrapComponent.cxx.

References ana::assert(), ana::NC, ana::NCbar, ana::NCtot, ana::nue, ana::nuebar, ana::numu, and ana::numubar.

Referenced by ana::TruthReweight::SaveTo(), and SaveTo().

100  {
101  switch (dr){
102  case DecompResult::nue : return "Nue";
103  case DecompResult::numu : return "Numu";
104  case DecompResult::nuebar : return "NueBar";
105  case DecompResult::numubar : return "NumuBar";
106  case DecompResult::NC : return "NC";
107  case DecompResult::NCbar : return "NCbar";
108  case DecompResult::NCtot : return "NCtot";
109  }
110  assert( 0 && "Bad DecompResult" );
111  }
assert(nhit_max >=nhit_nbins)
OscillatableSpectrum ana::RecoReweight::Eval ( ) const
overridevirtual

Core extrapolation math.

Implements ana::ModularExtrapComponent.

Definition at line 372 of file ModularExtrapComponent.cxx.

References fDecomp, fDecompRes, fLabel, ana::ModularExtrapComponent::FormSmartRatio(), fRecoND, fTrueToRecoFD, ana::ModularExtrapComponent::GetDecompResult(), fillBadChanDBTables::result, ana::ReweightableSpectrum::ReweightToRecoSpectrum(), and ana::OscillatableSpectrum::Unoscillated().

373  {
374 
375  //Copy to local variable because reweighting is in-place
376  OscillatableSpectrum result(fTrueToRecoFD);
377 
378  //Get ND data from Decomp
379  Spectrum decompresult(GetDecompResult(*fDecomp,fDecompRes));
380 
381  //Compute Data/MC Ratio
382  Ratio dataMC = FormSmartRatio(
383  decompresult, fRecoND,
384  fLabel, "MC ND Reco",
386 
387  // Multiply by Data/MC Ratio and add in FD truth information
388  result.ReweightToRecoSpectrum( fTrueToRecoFD.Unoscillated() * dataMC );
389 
390  return result;
391 
392  }
const DecompResult fDecompRes
OscillatableSpectrum fTrueToRecoFD
std::vector< float > Spectrum
Definition: Constants.h:610
static Spectrum GetDecompResult(const IDecomp &, DecompResult)
Helper function to pick out single Spectrum from a decomposition.
static Ratio FormSmartRatio(const Spectrum &num, const Spectrum &denom, std::string component, std::string location, const Spectrum &mult)
Form Ratio, but be aware of zero division.
Ratio ana::ModularExtrapComponent::FormSmartRatio ( const Spectrum num,
const Spectrum denom,
std::string  component,
std::string  location,
const Spectrum mult 
)
staticprotectedinherited

Form Ratio, but be aware of zero division.

Necessary because root thinks n/0==0, so we lose events when low stats cause empty bins. If zero division occurs, ratio is set to 1 and warning is issued. If numerator is 0 and ratio will be multiplied by 0 later, the warning is suppressed.

Definition at line 130 of file ModularExtrapComponent.cxx.

References ana::assert(), bin, hadd_many_files::counter, ana::ModularExtrapComponent::DivByZeroCounter::fBins, ana::ModularExtrapComponent::fQuiet, ana::Spectrum::GetBinnings(), ana::Spectrum::GetEigen(), and ana::Spectrum::GetLabels().

Referenced by ana::FluxReweight::Eval(), ana::TruthReweight::Eval(), and Eval().

136  {
137  const Eigen::ArrayXd numa = num.GetEigen(1e20);
138  const Eigen::ArrayXd denoma = denom.GetEigen(1e20);
139  const Eigen::ArrayXd multa = mult.GetEigen(1e20);
140 
141  Eigen::ArrayXd ratioa = numa;
142  ratioa.setZero();
143 
144  assert( (numa.size() == denoma.size()) && "Bin Mismatch" );
145  assert( (numa.size() == multa.size()) && "Bin Mismatch" );
146 
147  static DivByZeroCounter counter;
148  for (int bin = 0; bin < numa.size(); ++bin)
149  {
150  if ( denoma[bin] != 0 ){
151  ratioa[bin] = numa[bin] / denoma[bin];
152  } else {
153  ratioa[bin] = 1;
154  if ( numa[bin] != 0
155  || multa[bin] != 0 )
156  counter.fBins.insert(std::make_tuple(component, location, bin));
157  }
158  }
159 
160  return Ratio( std::move(ratioa), num.GetLabels(), num.GetBinnings() );
161  }
#define location
float bin[41]
Definition: plottest35.C:14
int num
Definition: f2_nu.C:119
assert(nhit_max >=nhit_nbins)
const IDecomp* ana::RecoReweight::GetDecomp ( ) const
inlineoverridevirtual

Implements ana::ModularExtrapComponent.

Definition at line 209 of file ModularExtrapComponent.h.

209 {return fDecomp;}
Spectrum ana::ModularExtrapComponent::GetDecompResult ( const IDecomp decomp,
DecompResult  dr 
)
staticprotectedinherited

Helper function to pick out single Spectrum from a decomposition.

Definition at line 80 of file ModularExtrapComponent.cxx.

References ana::IDecomp::AntiNueComponent(), ana::IDecomp::AntiNumuComponent(), ana::assert(), ana::NC, ana::IDecomp::NCAntiComponent(), ana::NCbar, ana::IDecomp::NCComponent(), ana::NCtot, ana::IDecomp::NCTotalComponent(), ana::nue, ana::nuebar, ana::IDecomp::NueComponent(), ana::numu, ana::numubar, and ana::IDecomp::NumuComponent().

Referenced by ana::TruthReweight::Eval(), Eval(), ana::TruthReweight::SavePlots(), and SavePlots().

83  {
84  switch (dr){
85  case DecompResult::nue : return decomp.NueComponent();
86  case DecompResult::numu : return decomp.NumuComponent();
87  case DecompResult::nuebar : return decomp.AntiNueComponent();
88  case DecompResult::numubar : return decomp.AntiNumuComponent();
89  case DecompResult::NCtot : return decomp.NCTotalComponent();
90  case DecompResult::NCbar : return decomp.NCAntiComponent();
91  case DecompResult::NC : return decomp.NCComponent();
92  }
93  assert( 0 && "Bad DecompResult" );
94  }
assert(nhit_max >=nhit_nbins)
std::unique_ptr< RecoReweight > ana::RecoReweight::LoadFrom ( TDirectory *  dir,
const std::string name 
)
static

Definition at line 416 of file ModularExtrapComponent.cxx.

References ana::assert(), dir, fOwnDecomp, label, latex(), ana::OscillatableSpectrum::LoadFrom(), ana::Spectrum::LoadFrom(), ana::LoadFrom< IDecomp >(), RecoReweight(), runNovaSAM::release, runNovaSAM::ret, and ana::ModularExtrapComponent::StringToDR().

Referenced by ana::LoadFrom< ModularExtrapComponent >().

417  {
418  dir = dir->GetDirectory(name.c_str()); // switch to subdir
419  assert(dir);
420 
421  assert(dir->GetDirectory("RecoND"));
422  assert(dir->GetDirectory("TrueToRecoFD"));
423  assert(dir->GetDirectory("Decomp"));
424  TObjString* dr = (TObjString*)dir->Get("DecompRes");
425  assert(dr);
426  TObjString* label = (TObjString*)dir->Get("Label");
427  TObjString* latex = (TObjString*)dir->Get("Latex");
428  assert(label);
429  assert(latex);
430 
432  *(Spectrum::LoadFrom(dir, "RecoND")),
433  *(OscillatableSpectrum::LoadFrom(dir, "TrueToRecoFD")),
434  *(ana::LoadFrom<IDecomp>(dir, "Decomp")).release(),
435  StringToDR(dr->GetString().Data()),
436  label->GetString().Data(),
437  latex->GetString().Data()
438  );
439  // We know we have the only copy because we just loaded it
440  ret->fOwnDecomp = true;
441  delete dr;
442  delete label;
443  delete latex;
444  delete dir;
445  return std::unique_ptr<RecoReweight>(ret);
446  }
static std::unique_ptr< OscillatableSpectrum > LoadFrom(TDirectory *dir, const std::string &name)
const XML_Char * name
Definition: expat.h:151
void latex(double x, double y, std::string txt, double ang=0, int align=22, double size=0.042)
static DecompResult StringToDR(std::string)
Helper function to turn a string into a DecompResult (for loading).
const char * label
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
RecoReweight(SpectrumLoaderBase &ndloader, const HistAxis &axis, const Cut &fdcut, const SystShifts &shiftMC, const Var &weight, std::string label, std::string latex, const Cut &ndcut, const IDecomp &decomposition, const DecompResult dr, const Cut &ndflavor, SpectrumLoaderBase &fdloader, const Cut &fdflavors, SpectrumLoaderBase &extrafdloaderswap=kNullLoader, SpectrumLoaderBase &extrafdloadertau=kNullLoader)
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
std::unique_ptr< IDecomp > LoadFrom< IDecomp >(TDirectory *dir, const std::string &label)
Definition: IDecomp.cxx:53
TH1 * ana::RecoReweight::OptimalBinning ( double  potMCFD,
double  potMCND 
) const

Uses MC spectra and target MC stats to estimate optimal binning.

Definition at line 235 of file ModularExtrapComponentPlot.cxx.

References fd, and nd.

238  {
239 
240  TH1* fd = fTrueToRecoFD.Unoscillated().ToTH1(potMCFD);
241  TH1* nd = fRecoND.ToTH1(potMCND);
242 
243  TH1* ob = OptimalBinningHelper( fd, nd );
244 
245  delete fd;
246  delete nd;
247 
248  return ob;
249 
250  }
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:148
OscillatableSpectrum fTrueToRecoFD
static TH1 * OptimalBinningHelper(TH1 *, TH1 *)
TH1 * ana::RecoReweight::OptimalBinningFit ( double  potMCFD,
double  potMCND 
) const

Fits gaussians to FD and ND MC to estimate optimal binning.

Definition at line 254 of file ModularExtrapComponentPlot.cxx.

References fd, nd, and ana::UniqueName().

257  {
258 
259  TH1* fd = fTrueToRecoFD.Unoscillated().ToTH1(potMCFD);
260  TH1* nd = fRecoND.ToTH1(potMCND);
261 
262  const double lower( fd->GetXaxis()->GetXmin() );
263  const double upper( fd->GetXaxis()->GetXmax() );
264 
265  TF1* fdGauss = new TF1( UniqueName().c_str() ,"gaus(0)", lower, upper );
266  TF1* ndGauss = new TF1( UniqueName().c_str() ,"gaus(0)", lower, upper );
267 
268  fdGauss->SetParameters( 100., 2., .5 );
269  ndGauss->SetParameters( 100., 2., .5 );
270 
271  fd->Fit( fdGauss, "WW" );
272  nd->Fit( ndGauss, "WW" );
273 
274  TH1* fdFine = new TH1D(UniqueName().c_str(),"fdFine",100,lower,upper);
275  TH1* ndFine = new TH1D(UniqueName().c_str(),"ndFine",100,lower,upper);
276 
277  fdFine->Eval(fdGauss);
278  ndFine->Eval(ndGauss);
279 
280  const double binScale = fdFine->GetBinWidth(1) / fd->GetBinWidth(1);
281 
282  fdFine->Scale(binScale);
283  ndFine->Scale(binScale);
284 
285  TH1* ob(OptimalBinningHelper(fdFine,ndFine));
286 
287  delete fd;
288  delete nd;
289  return ob;
290 
291  }
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:148
OscillatableSpectrum fTrueToRecoFD
static TH1 * OptimalBinningHelper(TH1 *, TH1 *)
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
TH1 * ana::RecoReweight::OptimalBinningHelper ( TH1 *  fd,
TH1 *  nd 
)
static

Definition at line 295 of file ModularExtrapComponentPlot.cxx.

References ana::assert(), bin, boost::math::isfinite(), nbins, cet::pow(), and ratio().

296  {
297 
298  TH1* ob( (TH1*)fd->Clone() );
299 
300  int nbins = fd->GetNbinsX();
301  assert( (nbins == nd->GetNbinsX()) && "Bin Mismatch" );
302 
303  for (int bin(1); bin<=nbins; ++bin)
304  {
305  double invdensFD( fd->GetBinWidth(bin) / fd->GetBinContent(bin) );
306  double invdensND( nd->GetBinWidth(bin) / nd->GetBinContent(bin) );
307  double ratio( fd->GetBinContent(bin) / nd->GetBinContent(bin) );
308  double ratioPrev( fd->GetBinContent(bin-1) / nd->GetBinContent(bin-1) );
309  double ratioNext( fd->GetBinContent(bin+1) / nd->GetBinContent(bin+1) );
310  double deltaRatio( ratioNext - ratioPrev );
311  double deltaVar( fd->GetBinCenter(bin+1) - fd->GetBinCenter(bin-1) );
312  double invslope( deltaVar / deltaRatio );
313  double widthCubed( 6. * ( ratio*ratio * invslope*invslope )
314  * ( invdensFD + invdensND ) );
315  double optbin( pow(widthCubed, 1./3.) );
316  if ( std::isfinite(optbin) ) ob->SetBinContent( bin, optbin );
317  else ob->SetBinContent( bin, 0. );
318  }
319  ob->SetBinContent( 0, 0. );
320  ob->SetBinContent( nbins+1, 0. );
321 
322  return ob;
323 
324  }
bool isfinite(const stan::math::var &v)
TH1 * ratio(TH1 *h1, TH1 *h2)
constexpr T pow(T x)
Definition: pow.h:75
const int nbins
Definition: cellShifts.C:15
float bin[41]
Definition: plottest35.C:14
assert(nhit_max >=nhit_nbins)
const OscillatableSpectrum & ana::ModularExtrapComponent::Return ( ) const
inherited

Interface so that result of Eval() is called only once and cached.

Definition at line 68 of file ModularExtrapComponent.cxx.

References ana::ModularExtrapComponent::Eval(), ana::ModularExtrapComponent::fCache, and ana::ModularExtrapComponent::fEvaluated.

Referenced by ana::FluxReweight::SavePlots(), ana::TruthReweight::SavePlots(), and SavePlots().

69  {
70  if (!fEvaluated)
71  {
72  fCache = Eval();
73  fEvaluated = true;
74  }
75  return fCache;
76  }
virtual OscillatableSpectrum Eval() const =0
Core extrapolation math.
void ana::RecoReweight::SavePlots ( TDirectory *  dir,
double  potFD 
) const
overridevirtual

Implements ana::ModularExtrapComponent.

Definition at line 152 of file ModularExtrapComponentPlot.cxx.

References ana::ModularExtrapComponent::ComparisonPlot(), ana::ModularExtrapComponent::GetDecompResult(), kBlue, kRed, ana::Spectrum::POT(), ana::ModularExtrapComponent::Return(), tmp, and ana::Spectrum::ToTH1().

153  {
154  TDirectory* tmp = gDirectory;
155  dir->cd();
156 
157  Spectrum fdMCReco( fTrueToRecoFD.Unoscillated() );
158  Spectrum fdExtReco( Return().Unoscillated() );
159 
160  Spectrum decompresult( GetDecompResult(*fDecomp,fDecompRes) );
161  double potND( decompresult.POT() );
162 
164  fRecoND, decompresult, potND,
165  "Data", kBlack, fLatex, "ND Reco Spectrum", "ND" );
166 
168  fdMCReco, fdExtReco, potFD,
169  "Extrapolated", kBlue, fLatex, "FD Reco Spectrum", "FD" );
170 
171  TH1* histDvMCND( (decompresult/fRecoND).ToTH1() );
172  TH1* histEvMCFD( (fdExtReco / fdMCReco).ToTH1() );
173  histDvMCND->SetLineColor( kRed );
174  histEvMCFD->SetLineColor( kBlue );
175  histEvMCFD->SetLineWidth( 4 );
176  histEvMCFD->SetLineStyle( 2 );
177  TCanvas cDvMC;
178  histDvMCND->SetMaximum( 1.5 * histDvMCND->GetMaximum() );
179  histDvMCND->SetTitle( (fLatex+" Data/MC Ratio").c_str() );
180  histDvMCND->GetYaxis()->SetTitle("Ratio");
181  histDvMCND->Draw("hist");
182  histEvMCFD->Draw("same""hist");
183  TLegend legendDvMC( .15, .7, .4, .85 );
184  legendDvMC.SetTextSize(0.05);
185  legendDvMC.AddEntry( histEvMCFD, "FD (Extrapolated)" );
186  legendDvMC.AddEntry( histDvMCND, "ND" );
187  legendDvMC.SetFillStyle(0);
188  legendDvMC.Draw();
189  cDvMC.Write("DataOverMC");
190  delete histDvMCND;
191  delete histEvMCFD;
192 
193  TH1* histFoNMC( (fdMCReco/fRecoND).ToTH1() );
194  TH1* histFoNDE( (fdExtReco/decompresult).ToTH1() );
195  histFoNMC->SetLineColor( kRed );
196  histFoNDE->SetLineColor( kBlue );
197  histFoNDE->SetLineWidth( 4 );
198  histFoNDE->SetLineStyle( 2 );
199  TCanvas cFoN;
200  histFoNMC->SetMaximum( 1.5 * histFoNMC->GetMaximum() );
201  histFoNMC->SetTitle( (fLatex+" Far/Near Ratio").c_str() );
202  histFoNMC->GetYaxis()->SetTitle("Ratio");
203  histFoNMC->Draw("hist");
204  histFoNDE->Draw("same""hist");
205  TLegend legendFoN( .15, .7, .4, .85 );
206  legendFoN.SetTextSize(0.05);
207  legendFoN.AddEntry( histFoNDE, "Extrapolation/Data" );
208  legendFoN.AddEntry( histFoNMC, "MC" );
209  legendFoN.SetFillStyle(0);
210  legendFoN.Draw();
211  cFoN.Write("FarOverNear");
212  delete histFoNMC;
213  delete histFoNDE;
214 
215  TH1* histNDDat = decompresult.ToTH1(potND);
216  TH1* histFDExt = fdExtReco.ToTH1(potFD);
217  TH1* histNDMC = fRecoND.ToTH1(potND);
218  TH1* histFDMC = fdMCReco.ToTH1(potFD);
219 
220  histNDDat->Write("NDDat");
221  histFDExt->Write("FDExt");
222  histNDMC->Write("NDMC");
223  histFDMC->Write("FDMC");
224 
225  delete histNDDat;
226  delete histFDExt;
227  delete histNDMC;
228  delete histFDMC;
229 
230  tmp->cd();
231  }
enum BeamMode kRed
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:148
const OscillatableSpectrum & Return() const
Interface so that result of Eval() is called only once and cached.
const DecompResult fDecompRes
Float_t tmp
Definition: plot.C:36
OscillatableSpectrum fTrueToRecoFD
std::vector< float > Spectrum
Definition: Constants.h:610
static Spectrum GetDecompResult(const IDecomp &, DecompResult)
Helper function to pick out single Spectrum from a decomposition.
TDirectory * dir
Definition: macro.C:5
enum BeamMode kBlue
static void ComparisonPlot(Spectrum mc, Spectrum notMC, double pot, std::string notMCLabel, int notMCColor, std::string latex, std::string title, std::string saveAs, bool restrictRange=false)
void ana::RecoReweight::SaveTo ( TDirectory *  dir,
const std::string name 
) const
overridevirtual

Implements ana::ModularExtrapComponent.

Definition at line 394 of file ModularExtrapComponent.cxx.

References dir, ana::ModularExtrapComponent::DRToString(), fDecomp, fDecompRes, fLabel, fLatex, fRecoND, fTrueToRecoFD, ana::IDecomp::SaveTo(), ana::OscillatableSpectrum::SaveTo(), ana::Spectrum::SaveTo(), tmp, and Write().

395  {
396  TDirectory* tmp = gDirectory;
397 
398  dir = dir->mkdir(name.c_str()); // switch to subdir
399  dir->cd();
400 
401  TObjString("RecoReweight").Write("type");
402  fRecoND.SaveTo(dir, "RecoND");
403  fTrueToRecoFD.SaveTo(dir, "TrueToRecoFD");
404  fDecomp->SaveTo(dir, "Decomp");
405  TObjString(DRToString(fDecompRes).c_str()).Write("DecompRes");
406  TObjString(fLabel.c_str()).Write("Label");
407  TObjString(fLatex.c_str()).Write("Latex");
408 
409  dir->Write();
410  delete dir;
411 
412  tmp->cd();
413  }
const XML_Char * name
Definition: expat.h:151
static std::string DRToString(DecompResult)
Helper function to turn a DecompResult into a string (for storage).
const DecompResult fDecompRes
Float_t tmp
Definition: plot.C:36
OscillatableSpectrum fTrueToRecoFD
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
TDirectory * dir
Definition: macro.C:5
virtual void SaveTo(TDirectory *dir, const std::string &name) const =0
void SaveTo(TDirectory *dir, const std::string &name) const
gm Write()
static void ana::ModularExtrapComponent::SetQuiet ( bool  quiet = true)
inlinestaticinherited
DecompResult ana::ModularExtrapComponent::StringToDR ( std::string  str)
staticprotectedinherited

Helper function to turn a string into a DecompResult (for loading).

Definition at line 115 of file ModularExtrapComponent.cxx.

References ana::assert(), ana::NC, ana::NCbar, ana::NCtot, ana::nue, ana::nuebar, ana::numu, and ana::numubar.

Referenced by ana::TruthReweight::LoadFrom(), and LoadFrom().

117  {
118  if (str=="Nue") return DecompResult::nue;
119  else if (str=="Numu") return DecompResult::numu;
120  else if (str=="NueBar") return DecompResult::nuebar;
121  else if (str=="NumuBar") return DecompResult::numubar;
122  else if (str=="NC") return DecompResult::NC;
123  else if (str=="NCbar") return DecompResult::NCbar;
124  else if (str=="NCtot") return DecompResult::NCtot;
125  else assert( 0 && "Bad DecompResult String" );
126  }
assert(nhit_max >=nhit_nbins)

Friends And Related Function Documentation

friend class ModularExtrap
friend

Definition at line 211 of file ModularExtrapComponent.h.

Member Data Documentation

const IDecomp* ana::RecoReweight::fDecomp
private

Definition at line 226 of file ModularExtrapComponent.h.

Referenced by Eval(), SaveTo(), and ~RecoReweight().

const DecompResult ana::RecoReweight::fDecompRes
private

Definition at line 228 of file ModularExtrapComponent.h.

Referenced by Eval(), and SaveTo().

std::string ana::RecoReweight::fLabel
private

Definition at line 229 of file ModularExtrapComponent.h.

Referenced by Eval(), and SaveTo().

std::string ana::RecoReweight::fLatex
private

Definition at line 230 of file ModularExtrapComponent.h.

Referenced by SaveTo().

bool ana::RecoReweight::fOwnDecomp
private

Definition at line 227 of file ModularExtrapComponent.h.

Referenced by LoadFrom(), and ~RecoReweight().

Spectrum ana::RecoReweight::fRecoND
private

Definition at line 224 of file ModularExtrapComponent.h.

Referenced by Eval(), and SaveTo().

OscillatableSpectrum ana::RecoReweight::fTrueToRecoFD
private

Definition at line 225 of file ModularExtrapComponent.h.

Referenced by Eval(), RecoReweight(), and SaveTo().


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