169 DeleteMatrix(&fDAinRelSq);
170 DeleteMatrix(&fDAinColRelSq);
172 delete fBgrErrUncorrInSq;
173 delete fBgrErrScaleIn;
178 DeleteMatrix(&fYData);
179 DeleteMatrix(&fVyyData);
205 :
TUnfold(hist_A,histmap,regmode,constraint)
228 for (
Int_t ibiny = 0; ibiny <=
GetNy()+1; ibiny++) {
238 (*fDAinColRelSq)(ix,0) += normerr_sq;
247 }
else if(ibiny==
GetNy()+1) {
256 rowDAinRelSq[da_nonzero]=ibiny-1;
257 colDAinRelSq[da_nonzero] = ix;
258 dataDAinRelSq[da_nonzero] = normerr_sq;
259 if(dataDAinRelSq[da_nonzero]>0.0) da_nonzero++;
265 rowDAinRelSq,colDAinRelSq,dataDAinRelSq);
269 delete[] rowDAinRelSq;
270 delete[] colDAinRelSq;
271 delete[] dataDAinRelSq;
297 Error(
"AddSysError",
"Source %s given twice, ignoring 2nd call.\n",
name);
313 for(
Int_t loop=0;loop<2;loop++) {
314 for (
Int_t ibiny = 0; ibiny <=
GetNy()+1; ibiny++) {
325 if((ibiny>0)&&(ibiny<=
GetNy())) {
327 }
else if(ibiny==0) {
328 z0=(*fAoutside)(ix,0);
330 z0=(*fAoutside)(ix,1);
342 if((ibiny>0)&&(ibiny<=
GetNy())) {
348 data[nmax]=z/
sum-aCopy(ibiny-1,ix);
352 if(
data[nmax] != 0.0) nmax++;
360 "source %s has no influence and has not been added.\n",
name);
363 nmax,rows,cols,
data);
392 Warning(
"DoBackgroundSubtraction",
393 "inverse error matrix from user input,"
394 " not corrected for background");
402 for(key=bgrPtr.
Next();key;key=bgrPtr.
Next()) {
405 (*fY)(i,0) -= (*bgr)(i,0);
417 for(
Int_t i=0;i<ny;i++) {
420 for(
Int_t i=0;i<ny;i++) {
421 for(
Int_t k=vyydata_rows[i];k<vyydata_rows[i+1];k++) {
422 if(vyydata_data[k]>0.0) {
424 usedBin[vyydata_cols[k]]++;
431 for(key=bgrErrUncorrSqPtr.
Next();key;
432 key=bgrErrUncorrSqPtr.
Next()) {
434 for(
Int_t yi=0;yi<ny;yi++) {
435 if(!usedBin[yi])
continue;
436 vyy(yi,yi) +=(*bgrerruncorrSquared)(yi,0);
443 for(key=bgrErrScalePtr.
Next();key;key=bgrErrScalePtr.
Next()) {
445 for(
Int_t yi=0;yi<ny;yi++) {
446 if(!usedBin[yi])
continue;
447 for(
Int_t yj=0;yj<ny;yj++) {
448 if(!usedBin[yj])
continue;
449 vyy(yi,yj) +=(*bgrerrscale)(yi,0)* (*bgrerrscale)(yj,0);
462 Fatal(
"DoBackgroundSubtraction",
"No input vector defined");
468 const TH2 *hist_vyy_inv)
524 Error(
"SubtractBackground",
"Source %s given twice, ignoring 2nd call.\n",
532 (*bgrErrUncSq)(row,0) =
534 (*bgrErrCorr)(row,0) = scale_error*bgr->
GetBinContent(row+1);
542 Info(
"SubtractBackground",
543 "Background subtraction prior to setting input data");
566(
TH1 *bgrHist,
const char *bgrSource,
const Int_t *binMap,
576 for(key=bgrPtr.
Next();key;key=bgrPtr.
Next()) {
578 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
581 Int_t destBin=binMap[i+1];
588 if(includeError &1) {
590 for(key=bgrErrUncorrSqPtr.
Next();key;key=bgrErrUncorrSqPtr.
Next()) {
592 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
595 Int_t destBin=binMap[i+1];
598 ((*bgrerruncorrSquared)(i,0)+
603 if(includeError & 2) {
605 for(key=bgrErrScalePtr.
Next();key;key=bgrErrScalePtr.
Next()) {
607 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
610 Int_t destBin=binMap[i+1];
611 bgrHist->
SetBinError(destBin,hypot((*bgrerrscale)(i,0),
1028 const Int_t *binMap)
1037 return delta !=
nullptr;
1055(
TH1 *hist_delta,
const char *source,
const Int_t *binMap)
1230(
TH2 *ematrix,
const char *source,
const Int_t *binMap,
Bool_t clearEmat)
1286 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1311 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1346 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1380 if(vdy_rows[i+1]>vdy_rows[i]) {
1381 r += vdy_data[vdy_rows[i]] * dy(i,0);
1430 if((
m->GetNcols() !=
v->GetNrows())||(
v->GetNcols()!=1)) {
1431 Fatal(
"ScaleColumnsByVector error",
1432 "matrix cols/vector rows %d!=%d OR vector cols %d !=1\n",
1433 m->GetNcols(),
v->GetNrows(),
v->GetNcols());
1435 const Int_t *rows_m=
m->GetRowIndexArray();
1436 const Int_t *cols_m=
m->GetColIndexArray();
1442 for(
Int_t i=0;i<
m->GetNrows();i++) {
1443 for(
Int_t index_m=rows_m[i];index_m<rows_m[i+1];index_m++) {
1444 Int_t j=cols_m[index_m];
1445 Int_t index_v=rows_v[j];
1446 if(index_v<rows_v[j+1]) {
1447 data_m[index_m] *= data_v[index_v];
1449 data_m[index_m] =0.0;
1454 for(
Int_t i=0;i<
m->GetNrows();i++) {
1455 for(
Int_t index_m=rows_m[i];index_m<rows_m[i+1];index_m++) {
1456 Int_t j=cols_m[index_m];
1457 data_m[index_m] *= (*v)(j,0);
1483 for(
Int_t i=0;i<nbin+2;i++) {
1490 for(
Int_t i=0;i<binMapSize;i++) {
1491 Int_t destBinI=binMap ? binMap[i] : i;
1493 if((destBinI>=0)&&(destBinI<nbin+2)&&(srcBinI>=0)) {
1495 if(
index<delta_rows[srcBinI+1]) {
1496 c[destBinI]+=delta_data[
index];
1501 for(
Int_t i=0;i<nbin+2;i++) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char mode
TMatrixTSparse< Double_t > TMatrixDSparse
TMatrixT< Double_t > TMatrixD
virtual Int_t GetEntries() const
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
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.
Service class for 2-D histogram classes.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
TObject * Next() override
Returns the next key from a map.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
void Add(TObject *obj) override
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
TObject * FindObject(const char *keyname) const override
Check if a (key,value) pair exists with keyname as name of the key.
void Clear(Option_t *option="") override
Remove all (key,value) pairs from the map.
const Int_t * GetRowIndexArray() const override
const Int_t * GetColIndexArray() const override
const Element * GetMatrixArray() const override
Collectable string class.
const TString & GetString() const
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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.
Class used by TMap to store (key,value) pairs.
A sorted doubly linked list.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
An algorithm to unfold distributions from detector to truth level, with background subtraction and pr...
TMatrixD * fAoutside
Input: underflow/overflow bins.
TMatrixDSparse * fDAinRelSq
Input: normalized errors from input matrix.
TMatrixDSparse * GetSummedErrorMatrixXX(void)
determine total error matrix on the vector x
void GetEmatrixSysTau(TH2 *ematrix, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
covariance matrix contribution from error on regularisation parameter
Double_t GetChi2Sys(void)
calculate total chi**2 including all systematic errors
void GetEmatrixTotal(TH2 *ematrix, const Int_t *binMap=nullptr)
Get total error matrix, summing up all contributions.
void VectorMapToHist(TH1 *hist_delta, const TMatrixDSparse *delta, const Int_t *binMap)
map delta to hist_delta, possibly summing up bins
void ScaleColumnsByVector(TMatrixDSparse *m, const TMatrixTBase< Double_t > *v) const
scale columns of a matrix by the corresponding rows of a vector
void GetEmatrixSysBackgroundScale(TH2 *ematrix, const char *source, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
covariance contribution from background normalisation uncertainty
TMap * fDeltaCorrAx
Result: syst.shift from fSysIn on fAx.
TMatrixD * fYData
Input: fY prior to bgr subtraction.
void GetRhoItotal(TH1 *rhoi, const Int_t *binMap=nullptr, TH2 *invEmat=nullptr)
Get global correlatiocn coefficients, summing up all contributions.
void GetEmatrixFromVyy(const TMatrixDSparse *vyy, TH2 *ematrix, const Int_t *binMap, Bool_t clearEmat)
propagate an error matrix on the input vector to the unfolding result
void GetBackground(TH1 *bgr, const char *bgrSource=nullptr, const Int_t *binMap=nullptr, Int_t includeError=3, Bool_t clearHist=kTRUE) const
get background into a histogram
void InitTUnfoldSys(void)
TMatrixDSparse * fVyyData
Input: error on fY prior to bgr subtraction.
TMatrixDSparse * fEmatUncorrAx
Result: syst.error from fDA2 on fAx.
Bool_t GetDeltaSysBackgroundScale(TH1 *delta, const char *source, const Int_t *binMap=nullptr)
correlated one-sigma shifts from background normalisation uncertainty
void DoBackgroundSubtraction(void)
perform background subtraction
TMatrixDSparse * GetSummedErrorMatrixYY(void)
determine total error matrix on the vector Ax
Double_t fDtau
Input: error on tau.
ESysErrMode
type of matrix specified with AddSysError()
@ kSysErrModeRelative
matrix gives the relative shifts
@ kSysErrModeMatrix
matrix is an alternative to the default matrix, the errors are the difference to the original matrix
@ kSysErrModeShift
matrix gives the absolute shifts
virtual TMatrixDSparse * PrepareUncorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2)
propagate uncorrelated systematic errors to a covariance matrix
Bool_t GetDeltaSysTau(TH1 *delta, const Int_t *binMap=nullptr)
correlated one-sigma shifts from shifting tau
Bool_t GetDeltaSysSource(TH1 *hist_delta, const char *source, const Int_t *binMap=nullptr)
correlated one-sigma shifts correspinding to a given systematic uncertainty
void GetEmatrixInput(TH2 *ematrix, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
covariance matrix contribution from input measurement uncertainties
TMatrixDSparse * fEmatUncorrX
Result: syst.error from fDA2 on fX.
void SubtractBackground(const TH1 *hist_bgr, const char *name, Double_t scale=1.0, Double_t scale_error=0.0)
Specify a source of background.
void ClearResults(void) override
Clear all data members which depend on the unfolding results.
TMap * fBgrIn
Input: size of background sources.
TMap * fDeltaCorrX
Result: syst.shift from fSysIn on fX.
TSortedList * GetSysSources(void) const
Get a new list of all systematic uuncertainty sources.
TMatrixD * fDAinColRelSq
Input: normalized column err.sq. (inp.matr.)
TMatrixDSparse * fDeltaSysTau
Result: systematic shift from tau.
void AddSysError(const TH2 *sysError, const char *name, EHistMap histmap, ESysErrMode mode)
Specify a correlated systematic uncertainty.
void SetTauError(Double_t delta_tau)
Specify an uncertainty on tau.
TMap * fBgrErrUncorrInSq
Input: uncorr error squared from bgr sources.
TUnfoldSys(void)
only for use by root streamer or derived classes
virtual void PrepareSysError(void)
Matrix calculations required to propagate systematic errors.
Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0, Double_t oneOverZeroError=0.0, const TH2 *hist_vyy=nullptr, const TH2 *hist_vyy_inv=nullptr) override
Define input data for subsequent calls to DoUnfold(tau)
void GetEmatrixSysSource(TH2 *ematrix, const char *source, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
covariance contribution from a systematic variation of the response matrix
void GetEmatrixSysBackgroundUncorr(TH2 *ematrix, const char *source, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
covariance contribution from background uncorrelated uncertainty
void GetEmatrixSysUncorr(TH2 *ematrix, const Int_t *binMap=nullptr, Bool_t clearEmat=kTRUE)
Covariance contribution from uncorrelated uncertainties of the response matrix.
TMap * fBgrErrScaleIn
Input: background sources correlated error.
TSortedList * GetBgrSources(void) const
Get a new list of all background sources.
virtual TMatrixDSparse * PrepareCorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixDSparse *dsys)
propagate correlated systematic shift to an output vector
TMap * fSysIn
Input: correlated errors.
An algorithm to unfold distributions from detector to truth level.
TArrayI fHistToX
mapping of histogram bins to matrix indices
TMatrixDSparse * MultiplyMSparseM(const TMatrixDSparse *a, const TMatrixD *b) const
multiply sparse matrix and a non-sparse matrix
TMatrixDSparse * MultiplyMSparseTranspMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
multiply a transposed Sparse matrix with another Sparse matrix
TMatrixDSparse * MultiplyMSparseMSparseTranspVector(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixTBase< Double_t > *v) const
calculate a sparse matrix product M1*V*M2T where the diagonal matrix V is given by a vector
TMatrixDSparse * CreateSparseMatrix(Int_t nrow, Int_t ncol, Int_t nele, Int_t *row, Int_t *col, Double_t *data) const
create a sparse matrix, given the nonzero elements
const TMatrixDSparse * GetDXDAM(int i) const
matrix contributions of the derivative dx/dA
Int_t GetNy(void) const
returns the number of measurement bins
const TMatrixDSparse * GetDXDtauSquared(void) const
vector of derivative dx/dtauSquared, using internal bin counting
static void DeleteMatrix(TMatrixD **m)
delete matrix and invalidate pointer
void ClearHistogram(TH1 *h, Double_t x=0.) const
Initialize bin contents and bin errors for a given histogram.
Int_t GetNx(void) const
returns internal number of output (truth) matrix rows
const TMatrixDSparse * GetDXDAZ(int i) const
vector contributions of the derivative dx/dA
EConstraint
type of extra constraint
TMatrixDSparse * fVyy
covariance matrix Vyy corresponding to y
const TMatrixDSparse * GetVyyInv(void) const
inverse of covariance matrix of the data y
TArrayD fSumOverY
truth vector calculated from the non-normalized response matrix
ERegMode
choice of regularisation scheme
void ErrorMatrixToHist(TH2 *ematrix, const TMatrixDSparse *emat, const Int_t *binMap, Bool_t doClear) const
add up an error matrix, also respecting the bin mapping
TArrayI fXToHist
mapping of matrix indices to histogram bins
const TMatrixDSparse * GetAx(void) const
vector of folded-back result
TMatrixD * fY
input (measured) data y
TMatrixDSparse * InvertMSparseSymmPos(const TMatrixDSparse *A, Int_t *rank) const
get the inverse or pseudo-inverse of a positive, sparse matrix
Double_t fTauSquared
regularisation parameter tau squared
virtual void ClearResults(void)
reset all results
void GetEmatrix(TH2 *ematrix, const Int_t *binMap=nullptr) const
get output covariance matrix, possibly cumulated over several bins
TMatrixDSparse * MultiplyMSparseMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
multiply two sparse matrices
EHistMap
arrangement of axes for the response matrix (TH2 histogram)
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
void AddMSparse(TMatrixDSparse *dest, Double_t f, const TMatrixDSparse *src) const
add a sparse matrix, scaled by a factor, to another scaled matrix
const TMatrixDSparse * GetVxx(void) const
covariance matrix of the result
Double_t GetRhoIFromMatrix(TH1 *rhoi, const TMatrixDSparse *eOrig, const Int_t *binMap, TH2 *invEmat) const
const TMatrixDSparse * GetDXDY(void) const
matrix of derivatives dx/dy
TMatrixDSparse * fA
response matrix A
virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0, Double_t oneOverZeroError=0.0, const TH2 *hist_vyy=nullptr, const TH2 *hist_vyy_inv=nullptr)
Define input data for subsequent calls to DoUnfold(tau)
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
static uint64_t sum(uint64_t i)