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