100 TString msg =
"All histograms must have equal dimension.\n";
105 msg +=
"Please start again!";
107 Fatal(
"Init", msg,
"%s" );
156 TString msg =
"All histograms must have equal dimension.\n";
162 msg +=
"Please start again!";
164 Fatal(
"Init", msg,
"%s" );
179fNormalize (other.fNormalize),
181fDHist (other.fDHist),
182fSVHist (other.fSVHist),
190fToyhisto (other.fToyhisto),
191fToymat (other.fToymat),
192fToyMode (other.fToyMode),
193fMatToyMode (other.fMatToyMode)
275 for (
Int_t i=0; i<
fNdim; i++) CSVM(i,i) = 1/CSV(i);
278 TMatrixD mCinv = (CVort*CSVM)*CUort;
287 for(
int i=0; i<
fNdim; i++){
294 for(
int i=0; i<
fNdim; i++){
295 for(
int j=0; j<
fNdim; j++){
297 vbtmp(i) += QT(i,j)*vb(j)/BSV(i);
301 mAtmp(i,j) += QT(i,
m)*mA(
m,j)/BSV(i);
337 if (ASV(i)<ASV(0)*eps) sreg = ASV(0)*eps;
339 vdz(i) = sreg/(sreg*sreg + ASV(k)*ASV(k));
340 Z(i,i) = vdz(i)*vdz(i);
346 TMatrixD W = mCinv*Vort*Z*VortT*mCinv;
354 Xtau(i,j) = vxini(i) * vxini(j) * W(i,j);
358 a += mA(
m,i)*mA(
m,j);
360 if(vxini(i) && vxini(j))
361 Xinv(i,j) =
a/vxini(i)/vxini(j);
375 Xtau *= 1./scale/scale;
387 Info(
"Unfold",
"Unfolding param: %i",k+1 );
388 Info(
"Unfold",
"Curvature of weight distribution: %f",
GetCurvature( vw, mCurv ) );
392 for(
int i=1; i<=
fNdim; i++){
393 h->SetBinContent(i,0.);
394 h->SetBinError(i,0.);
414 unfcov->
SetTitle(
"Toy covariance matrix");
415 for(
int i=1; i<=
fNdim; i++)
416 for(
int j=1; j<=
fNdim; j++)
429 if (L(iPar,iPar) > 0.0) L(iPar,iPar) =
TMath::Sqrt(L(iPar,iPar));
430 else L(iPar,iPar) = 0.0;
435 for (
Int_t k=0; k<iPar; k++) L(iPar,jPar) -= L(k,iPar)*L(k,jPar);
436 if (L(iPar,iPar)!=0.) L(iPar,jPar) /= L(iPar,iPar);
437 else L(iPar,jPar) = 0;
450 for (
int i=1; i<=ntoys; i++) {
460 for (
int j=1; j<=
fNdim; j++) {
478 for (
int i=1; i<=ntoys; i++) {
488 for (
int j=1; j<=
fNdim; j++) {
520 unfcov->
SetTitle(
"Toy covariance matrix");
521 for(
int i=1; i<=
fNdim; i++)
522 for(
int j=1; j<=
fNdim; j++)
532 for (
int i=1; i<=ntoys; i++) {
553 for (
int i=1; i<=ntoys; i++) {
676 if (vec2(i) != 0) quot(i) = vec1(i) / vec2(i);
678 if (zero) quot(i) = 0;
679 else quot(i) = vec1(i);
693 if (vec(i) != 0) quotmat(i,j) = mat(i,j) / vec(i);
695 if (zero) quotmat(i,j) = 0;
696 else quotmat(i,j) = mat(i,j);
709 for (
Int_t i=0; i<vec1.
GetNrows(); i++) res(i) = vec1(i) * vec2(i);
718 return vec*(curv*vec);
733 if (
fDdim == 0)
for (
Int_t i=0; i<ndim; i++) tC(i,i) = 1;
734 else if (
fDdim == 1) {
735 for (
Int_t i=0; i<ndim; i++) {
736 if (i < ndim-1) tC(i,i+1) = 1.0;
740 else if (
fDdim == 2) {
741 for (
Int_t i=0; i<ndim; i++) {
742 if (i > 0) tC(i,i-1) = 1.0;
743 if (i < ndim-1) tC(i,i+1) = 1.0;
747 tC(ndim-1,ndim-1) = -1.0;
749 else if (
fDdim == 3) {
750 for (
Int_t i=1; i<ndim-2; i++) {
758 for (
Int_t i=0; i<ndim; i++) {
759 if (i > 0) tC(i,i-1) = -4.0;
760 if (i < ndim-1) tC(i,i+1) = -4.0;
761 if (i > 1) tC(i,i-2) = 1.0;
762 if (i < ndim-2) tC(i,i+2) = 1.0;
766 tC(ndim-1,ndim-1) = 2.0;
768 tC(ndim-2,ndim-1) = -3.0;
770 tC(ndim-1,ndim-2) = -3.0;
772 tC(ndim-2,ndim-2) = 6.0;
774 else if (
fDdim == 5) {
775 for (
Int_t i=2; i < ndim-3; i++) {
784 else if (
fDdim == 6) {
785 for (
Int_t i = 3; i < ndim - 3; i++) {
797 for (
Int_t i=0; i<ndim; i++) tC(i,i) = tC(i,i) + eps;
800 for (
Int_t i=0; i<ndim; i++) {
801 for (
Int_t j=0; j<ndim; j++) {
802 for (
Int_t k=0; k<ndim; k++) {
803 tCurv(i,j) = tCurv(i,j) + tC(k,i)*tC(k,j);
852 for (
UInt_t in=0; in<nn; in++)
for (
UInt_t jn=0; jn<nn; jn++) matwork(in,jn) = 0;
855 for (
UInt_t in=0; in<nn; in++) {
857 matwork[in][in] = mat[ipos[in]][ipos[in]];
858 for (
UInt_t jn=in+1; jn<nn; jn++) {
859 matwork[in][jn] = mat[ipos[in]][ipos[jn]];
860 matwork[jn][in] = matwork[in][jn];
868 for (
UInt_t i=0; i<
n; i++)
for (
UInt_t j=0; j<
n; j++) mat[i][j] = 0;
871 for (
UInt_t in=0; in<nn; in++) {
872 mat[ipos[in]][ipos[in]] = matwork[in][in];
873 for (
UInt_t jn=in+1; jn<nn; jn++) {
874 mat[ipos[in]][ipos[jn]] = matwork[in][jn];
875 mat[ipos[jn]][ipos[in]] = mat[ipos[in]][ipos[jn]];
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Single Value Decomposition class.
const TVectorD & GetSig()
1-D histogram with a double per channel (see TH1 documentation)}
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual Int_t GetNbinsX() const
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
2-D histogram with a double per channel (see TH1 documentation)}
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
TMatrixTSym< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant Notice that the LU decomposition is used instead of B...
TMatrixT< Element > & Transpose(const TMatrixT< Element > &source)
Transpose matrix source.
Mother of all ROOT objects.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Random number generator class based on M.
virtual void SetSeed(ULong_t seed=0)
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
SVD Approach to Data Unfolding.
TH1D * GetSV() const
Returns singular values vector.
TH2D * GetBCov() const
Returns the covariance matrix.
TH1D * fSVHist
Distribution of d (for checking regularization)
TH2D * GetXtau() const
Returns the computed regularized covariance matrix corresponding to total uncertainties on measured s...
Bool_t fToyMode
Toy MC detector response matrix.
static void V2H(const TVectorD &vec, TH1D &histo)
Fill vector into 1D histogram.
static void H2M(const TH2D *histo, TMatrixD &mat)
Fill 2D histogram into matrix.
static void RegularisedSymMatInvert(TMatrixDSym &mat, Double_t eps=1e-3)
naive regularised inversion cuts off small elements
static TVectorD CompProd(const TVectorD &vec1, const TVectorD &vec2)
Multiply entries of two vectors.
static void M2H(const TMatrixD &mat, TH2D &histo)
Fill 2D histogram into matrix.
Bool_t fMatToyMode
Internal switch for covariance matrix propagation.
TSVDUnfold(const TH1D *bdat, const TH1D *bini, const TH1D *xini, const TH2D *Adet)
Alternative constructor User provides data and MC test spectra, as well as detector response matrix,...
Bool_t fNormalize
Derivative for curvature matrix.
TH1D * Unfold(Int_t kreg)
Perform the unfolding with regularisation parameter kreg.
Double_t ComputeChiSquared(const TH1D &truspec, const TH1D &unfspec)
Helper routine to compute chi-squared between distributions using the computed inverse of the covaria...
TH2D * fToymat
Toy MC histogram.
static Double_t GetCurvature(const TVectorD &vec, const TMatrixD &curv)
Compute curvature of vector.
const TH1D * fBdat
Computed inverse of covariance matrix.
static TMatrixD MatDivVec(const TMatrixD &mat, const TVectorD &vec, Int_t zero=0)
Divide matrix entries by vector.
virtual ~TSVDUnfold()
Destructor.
TH2D * fXinv
Computed regularized covariance matrix.
static TVectorD VecDiv(const TVectorD &vec1, const TVectorD &vec2, Int_t zero=0)
Divide entries of two vectors.
void FillCurvatureMatrix(TMatrixD &tCurv, TMatrixD &tC) const
TH1D * GetD() const
Returns d vector (for choosing appropriate regularisation)
TH2D * fXtau
Distribution of singular values.
TH1D * fDHist
Regularisation parameter.
static void H2Verr(const TH1D *histo, TVectorD &vec)
Fill 1D histogram errors into vector.
Int_t fDdim
Truth and reconstructed dimensions.
TH2D * GetUnfoldCovMatrix(const TH2D *cov, Int_t ntoys, Int_t seed=1)
Determine for given input error matrix covariance matrix of unfolded spectrum from toy simulation giv...
TH2D * GetAdetCovMatrix(Int_t ntoys, Int_t seed=1)
Determine covariance matrix of unfolded spectrum from finite statistics in response matrix using pseu...
TH2D * GetXinv() const
Returns the computed inverse of the covariance matrix.
static void H2V(const TH1D *histo, TVectorD &vec)
Fill 1D histogram into vector.
Int_t fKReg
Normalize unfolded spectrum to 1.
Element Sum() const
Compute sum of elements.
Double_t Sqrt(Double_t x)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)