UnfoldSVD.cxx
Go to the documentation of this file.
2 
3 #include "CAFAna/Core/Var.h"
4 
5 #include "TSVDUnfold.h"
6 
7 #include "TH2.h"
8 
9 namespace ana
10 {
11  //----------------------------------------------------------------------
13  int reg)
14  : fRT(rt), fReg(reg)
15  {
16  }
17 
18  //----------------------------------------------------------------------
20  {
21  }
22 
23  //----------------------------------------------------------------------
25  {
26  std::unique_ptr<TH1D> hReco(reco.ToTH1(reco.POT()));
27  std::unique_ptr<TH1D> hMCReco(fRT.UnWeighted().ToTH1(reco.POT()));
28  std::unique_ptr<TH1D> hMCTrue(fRT.WeightingVariable().ToTH1(reco.POT()));
29  std::unique_ptr<TH2D> hRT(fRT.ToTH2(reco.POT()));
30 
31  TSVDUnfold uf(hReco.get(), hMCReco.get(), hMCTrue.get(), hRT.get());
32 
33  std::unique_ptr<TH1D> h_unf(uf.Unfold(fReg));
34 
35  Eigen::ArrayXd ret(h_unf->GetNbinsX()+2);
36  for(int i = 0; i < h_unf->GetNbinsX()+2; ++i) ret[i] = h_unf->GetBinContent(i);
37  // Enforce matching normalization
38  ret *= reco.Integral(reco.POT())/ret.sum();
39 
40  return Spectrum(ret,
41  HistAxis(reco.GetLabels(), reco.GetBinnings()),
42  reco.POT(), reco.Livetime());
43  }
44 }
const std::vector< Binning > & GetBinnings() const
Definition: Spectrum.h:264
const ReweightableSpectrum & fRT
Definition: UnfoldSVD.h:25
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
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
Spectrum with the value of a second variable, allowing for reweighting
std::vector< double > Spectrum
Definition: Constants.h:741
double Integral(double exposure, double *err=0, EExposureType expotype=kPOT) const
Return total number of events scaled to pot.
Definition: Spectrum.cxx:249
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
virtual Spectrum Truth(const Spectrum &reco) override
Definition: UnfoldSVD.cxx:24
double POT() const
Definition: Spectrum.h:227
double fReg
Regularization strength.
Definition: UnfoldSVD.h:27
virtual ~UnfoldSVD()
Definition: UnfoldSVD.cxx:19
const std::vector< std::string > & GetLabels() const
Definition: Spectrum.h:263
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
Definition: Spectrum.h:230
UnfoldSVD(const ReweightableSpectrum &rt, int reg)
Definition: UnfoldSVD.cxx:12
TH2D * ToTH2(double pot) const