DecorrelateMatrix.C
Go to the documentation of this file.
1 // quick piece of code to decorrelate a covariance matrix
2 // basically entirely stolen from Jeremy H, thanks Jeremy!
3 
4 #include "DecorrelateMatrix.h"
5 
7 
8  TFile* infile = new TFile("/pnfs/nova/persistent/analysis/nux/nus20/selection/covmx.root", "read");
9  TMatrixD* inmat = (TMatrixD*)infile->Get("fraccovmx");
10 
11  size_t ndbins = ana::kNCNDBinning.NBins();
12  size_t fdbins = ana::kNCFDBinning.NBins();
13 
14  std::vector<double> decorrnd = DecorrelateND(inmat, ndbins, fdbins);
15  std::vector<double> decorrfd = DecorrelateFD(inmat, ndbins, fdbins);
16 
17  std::vector<double> decorrerr = decorrnd;
18  for (int i = 0; i < decorrfd.size(); ++i){
19  decorrerr.push_back(decorrfd.at(i));
20  }
21 
22  TMatrixD outMat(ndbins+fdbins, ndbins+fdbins);
23  for (int i = 0; i < ndbins+fdbins; ++i){
24  outMat(i,i) = decorrerr.at(i);
25  }
26 
27  TFile* decorrFile = new TFile("decorr.root", "recreate");
28  decorrFile->cd();
29  outMat.Write("decorrerr");
30 
31 }
std::vector< double > DecorrelateND(TMatrixD *inmat, int ndbins, int fdbins)
void DecorrelateFD()
Definition: DecorrelateFD.C:8
void DecorrelateMatrix()
string infile
const Binning kNCNDBinning
NC custom binning.
Definition: Binning.cxx:104
int NBins() const
Definition: Binning.h:29
const Binning kNCFDBinning
Definition: Binning.cxx:105