Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUnfoldSys.h
Go to the documentation of this file.
1// Author: Stefan Schmitt
2// DESY, 23/01/09
3
4// Version 17.9, parallel to changes in TUnfold
5//
6// History:
7// Version 17.8, parallel to changes in TUnfold
8// Version 17.7, bug fix in GetBackground()
9// Version 17.6, with updated doxygen comments
10// Version 17.5, bug fixes in TUnfold fix problem with GetEmatrixSysUncorr
11// Version 17.4, in parallel to changes in TUnfoldBinning
12// Version 17.3, in parallel to changes in TUnfoldBinning
13// Version 17.2, add methods to find back systematic and background sources
14// Version 17.1, bug fix with background uncertainty
15// Version 17.0, possibility to specify an error matrix with SetInput
16// Version 16.2, bug-fix with the calculation of background errors
17// Version 16.1, parallel to changes in TUnfold
18// Version 16.0, parallel to changes in TUnfold
19// Version 15, fix bugs with uncorr. uncertainties, add backgnd subtraction
20// Version 14, with changes in TUnfoldSys.cxx
21// Version 13, support for systematic errors
22
23#ifndef ROOT_TUnfoldSys
24#define ROOT_TUnfoldSys
25
26//////////////////////////////////////////////////////////////////////////
27// //
28// //
29// TUnfoldSys, an extension of the class TUnfold to correct for //
30// migration effects. It provides methods for background subtraction //
31// and propagation of systematic uncertainties //
32// //
33// Citation: S.Schmitt, JINST 7 (2012) T10003 [arXiv:1205.6201] //
34// //
35//////////////////////////////////////////////////////////////////////////
36
37/*
38 This file is part of TUnfold.
39
40 TUnfold is free software: you can redistribute it and/or modify
41 it under the terms of the GNU General Public License as published by
42 the Free Software Foundation, either version 3 of the License, or
43 (at your option) any later version.
44
45 TUnfold is distributed in the hope that it will be useful,
46 but WITHOUT ANY WARRANTY; without even the implied warranty of
47 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 GNU General Public License for more details.
49
50 You should have received a copy of the GNU General Public License
51 along with TUnfold. If not, see <http://www.gnu.org/licenses/>.
52*/
53
54#include <TMap.h>
55#include <TSortedList.h>
56#include "TUnfold.h"
57
58
59class TUnfoldSys : public TUnfold {
60 private:
61 void InitTUnfoldSys(void); // initialize all data members
62 protected:
63 /// Input: normalized errors from input matrix
65 /// Input: normalized column err.sq. (inp.matr.)
67 /// Input: underflow/overflow bins
69 /// Input: correlated errors
71 /// Input: size of background sources
73 /// Input: uncorr error squared from bgr sources
75 /// Input: background sources correlated error
77 /// Input: error on tau
79 /// Input: fY prior to bgr subtraction
81 /// Input: error on fY prior to bgr subtraction
83 /// Result: syst.error from fDA2 on fX
85 /// Result: syst.error from fDA2 on fAx
87 /// Result: syst.shift from fSysIn on fX
89 /// Result: syst.shift from fSysIn on fAx
91 /// Result: systematic shift from tau
93 protected:
94 void ClearResults(void) override; // clear all results
95 virtual void PrepareSysError(void); // common calculations for syst.errors
96 virtual TMatrixDSparse *PrepareUncorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2); // calculate uncorrelated error matrix
97 virtual TMatrixDSparse *PrepareCorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2,const TMatrixDSparse *dsys); // calculate correlated error matrix
98 void ScaleColumnsByVector(TMatrixDSparse *m,const TMatrixTBase<Double_t> *v) const; // scale columns of m by the corresponding rows of v
99 void VectorMapToHist(TH1 *hist_delta,const TMatrixDSparse *delta,const Int_t *binMap); // map and sum vector delta, save in hist_delta
100 void GetEmatrixFromVyy(const TMatrixDSparse *vyy,TH2 *ematrix,const Int_t *binMap,Bool_t clearEmat); // propagate error matrix vyy to the result
101 void DoBackgroundSubtraction(void);
104 public:
105 /// type of matrix specified with AddSysError()
107 /// matrix is an alternative to the default matrix, the errors are the difference to the original matrix
109 /// matrix gives the absolute shifts
111 /// matrix gives the relative shifts
113 };
114 TUnfoldSys(const TH2 *hist_A, EHistMap histmap, ERegMode regmode = kRegModeSize,
115 EConstraint constraint=kEConstraintArea); // constructor
116 TUnfoldSys(void); // for derived classes
117 ~ TUnfoldSys(void) override; // delete data members
118 void AddSysError(const TH2 *sysError,const char *name, EHistMap histmap,
119 ESysErrMode mode); // add a systematic error source
120 void SubtractBackground(const TH1 *hist_bgr,const char *name,
121 Double_t scale=1.0,
122 Double_t scale_error=0.0); // subtract background prior to unfolding
123 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 consistently in case of background subtraction
124 void SetTauError(Double_t delta_tau); // set uncertainty on tau
125 TSortedList *GetBgrSources(void) const; // get names of background sources
126 TSortedList *GetSysSources(void) const; // get names of systematic sources
127 void GetBackground(TH1 *bgr,const char *bgrSource=nullptr,const Int_t *binMap=nullptr,Int_t includeError=3,Bool_t clearHist=kTRUE) const; // get background as histogram
128 void GetEmatrixSysBackgroundUncorr(TH2 *ematrix,const char *source,
129 const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error matrix from uncorrelated error of one background source
130 void GetEmatrixSysBackgroundScale(TH2 *ematrix,const char *source,
131 const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error matrix from the scale error of one background source
132 Bool_t GetDeltaSysBackgroundScale(TH1 *delta,const char *source,
133 const Int_t *binMap=nullptr); // get correlated uncertainty induced by the scale uncertainty of a background source
134 void GetEmatrixSysUncorr(TH2 *ematrix,const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error matrix contribution from uncorrelated errors on the matrix A
135 void GetEmatrixSysSource(TH2 *ematrix,const char *source,
136 const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error matrix from one systematic source
137 Bool_t GetDeltaSysSource(TH1 *hist_delta,const char *source,
138 const Int_t *binMap=nullptr); // get systematic shifts from one systematic source
139 void GetEmatrixSysTau(TH2 *ematrix,
140 const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error matrix from tau variation
141 Bool_t GetDeltaSysTau(TH1 *delta,const Int_t *binMap=nullptr); // get correlated uncertainty from varying tau
142 void GetEmatrixInput(TH2 *ematrix,const Int_t *binMap=nullptr,Bool_t clearEmat=kTRUE); // get error contribution from input vector
143 void GetEmatrixTotal(TH2 *ematrix,const Int_t *binMap=nullptr); // get total error including systematic,statistical,background,tau errors
144 void GetRhoItotal(TH1 *rhoi,const Int_t *binMap=nullptr,TH2 *invEmat=nullptr); // get global correlation coefficients including systematic,statistical,background,tau errors
145 Double_t GetChi2Sys(void); // get total chi**2 including all systematic errors
146 ClassDefOverride(TUnfoldSys, TUnfold_CLASS_VERSION) //Unfolding with support for systematic error propagation
147};
148
149#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
#define TUnfold_CLASS_VERSION
Definition TUnfold.h:105
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
Service class for 2-D histogram classes.
Definition TH2.h:30
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
TMatrixTBase.
A sorted doubly linked list.
Definition TSortedList.h:28
An algorithm to unfold distributions from detector to truth level, with background subtraction and pr...
Definition TUnfoldSys.h:59
TMatrixD * fAoutside
Input: underflow/overflow bins.
Definition TUnfoldSys.h:68
TMatrixDSparse * fDAinRelSq
Input: normalized errors from input matrix.
Definition TUnfoldSys.h:64
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.
Definition TUnfoldSys.h:90
TMatrixD * fYData
Input: fY prior to bgr subtraction.
Definition TUnfoldSys.h:80
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.
Definition TUnfoldSys.h:82
TMatrixDSparse * fEmatUncorrAx
Result: syst.error from fDA2 on fAx.
Definition TUnfoldSys.h:86
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.
Definition TUnfoldSys.h:78
ESysErrMode
type of matrix specified with AddSysError()
Definition TUnfoldSys.h:106
@ kSysErrModeRelative
matrix gives the relative shifts
Definition TUnfoldSys.h:112
@ kSysErrModeMatrix
matrix is an alternative to the default matrix, the errors are the difference to the original matrix
Definition TUnfoldSys.h:108
@ kSysErrModeShift
matrix gives the absolute shifts
Definition TUnfoldSys.h:110
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.
Definition TUnfoldSys.h:84
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.
Definition TUnfoldSys.h:72
TMap * fDeltaCorrX
Result: syst.shift from fSysIn on fX.
Definition TUnfoldSys.h:88
TSortedList * GetSysSources(void) const
Get a new list of all systematic uuncertainty sources.
TMatrixD * fDAinColRelSq
Input: normalized column err.sq. (inp.matr.)
Definition TUnfoldSys.h:66
TMatrixDSparse * fDeltaSysTau
Result: systematic shift from tau.
Definition TUnfoldSys.h:92
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.
Definition TUnfoldSys.h:74
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.
Definition TUnfoldSys.h:76
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.
Definition TUnfoldSys.h:70
An algorithm to unfold distributions from detector to truth level.
Definition TUnfold.h:107
EConstraint
type of extra constraint
Definition TUnfold.h:113
@ kEConstraintArea
enforce preservation of the area
Definition TUnfold.h:119
ERegMode
choice of regularisation scheme
Definition TUnfold.h:123
@ kRegModeSize
regularise the amplitude of the output distribution
Definition TUnfold.h:129
EHistMap
arrangement of axes for the response matrix (TH2 histogram)
Definition TUnfold.h:143
TMarker m
Definition textangle.C:8