20 assert(regStrength >= 0);
23 std::cout <<
"UnfoldTikhonov: must use 1D reco axis. This is not a fundamental limitation. The code could be improved relatively easily." << std::endl;
30 const unsigned int Nreco = recoVsTrue.
GetBinnings()[0].NBins();
31 const unsigned int Ntrue = recoVsTrue.
GetBinnings()[1].NBins();
34 Eigen::MatrixXd M(Nreco, Ntrue);
36 TH2D*
m = recoVsTrue.
ToTH2(1);
37 for(
unsigned int j = 0; j < Ntrue; ++j){
39 for(
unsigned int i = 0; i < Nreco; ++i){
40 const double mij = m->GetBinContent(i+1, j+1);
46 if(tot != 0)
for(
unsigned int i = 0; i < Nreco; ++i) M(i, j) /= tot;
52 Eigen::VectorXd
y(Nreco);
53 for(
unsigned int i = 0; i < Nreco; ++i) y[i] = hy->GetBinContent(i+1);
59 Eigen::MatrixXd P = Eigen::MatrixXd::Zero(Ntrue, Ntrue);
60 for(
unsigned int i = 1; i+1 < Ntrue; ++i){
62 P(i, i-1) = P(i, i+1) = 1;
75 const Eigen::MatrixXd lhs = M.transpose()*M + regStrength*P.transpose()*P;
76 const Eigen::VectorXd rhs = M.transpose()*
y;
79 Eigen::ColPivHouseholderQR<Eigen::MatrixXd> dec(lhs);
80 const Eigen::VectorXd ret = dec.solve(rhs);
86 for(
unsigned int i = 0; i < Ntrue; ++i) hret->SetBinContent(i+1, ret[i]);
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.
Spectrum with the value of a second variable, allowing for reweighting
process_name opflashCryoW ana
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
Representation of a spectrum in any variable, with associated POT.
Spectrum UnfoldTikhonov(const Spectrum &reco, const ReweightableSpectrum &recoVsTrue, double regStrength)
Unfolding using Tikhonov regularization (penalizing true spectra with large second derivatives) ...
process_name standard_reco_uboone reco
process_name opflash particleana ie ie y
std::vector< Binning > GetBinnings() const
static void Delete(TH1D *&h)
Prevent histograms being added to the current directory.
double Livetime() const
Seconds. For informational purposes only. No calculations use this.
BEGIN_PROLOG could also be cout
unsigned int NDimensions() const
Spectrum WeightingVariable() const
TH2D * ToTH2(double pot) const