ROOT  6.06/09
Reference Guide
TUnfoldSys.h
Go to the documentation of this file.
1 // Author: Stefan Schmitt
2 // DESY, 23/01/09
3 
4 // Version 17.1, bug fix with background uncertainty
5 //
6 // History:
7 // Version 17.0, possibility to specify an error matrix with SetInput
8 // Version 16.2, bug-fix with the calculation of background errors
9 // Version 16.1, parallel to changes in TUnfold
10 // Version 16.0, parallel to changes in TUnfold
11 // Version 15, fix bugs with uncorr. uncertainties, add backgnd subtraction
12 // Version 14, with changes in TUnfoldSys.cxx
13 // Version 13, support for systematic errors
14 
15 #ifndef ROOT_TUnfoldSys
16 #define ROOT_TUnfoldSys
17 
18 //////////////////////////////////////////////////////////////////////////
19 // //
20 // //
21 // TUnfoldSys, an extension of the class TUnfold to correct for //
22 // migration effects. It provides methods for background subtraction //
23 // and propagation of systematic uncertainties //
24 // //
25 // Citation: S.Schmitt, JINST 7 (2012) T10003 [arXiv:1205.6201] //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 /*
30  This file is part of TUnfold.
31 
32  TUnfold is free software: you can redistribute it and/or modify
33  it under the terms of the GNU General Public License as published by
34  the Free Software Foundation, either version 3 of the License, or
35  (at your option) any later version.
36 
37  TUnfold is distributed in the hope that it will be useful,
38  but WITHOUT ANY WARRANTY; without even the implied warranty of
39  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40  GNU General Public License for more details.
41 
42  You should have received a copy of the GNU General Public License
43  along with TUnfold. If not, see <http://www.gnu.org/licenses/>.
44 */
45 
46 #include "TUnfold.h"
47 
48 class TMap;
49 
50 
51 class TUnfoldSys : public TUnfold {
52  private:
53  void InitTUnfoldSys(void); // initialize all data members
54  protected:
55  TMatrixDSparse *fDAinRelSq; // Input: normalized errors from input matrix
56  TMatrixD* fDAinColRelSq; // Input: normalized column err.sq. (inp.matr.)
57  TMatrixD* fAoutside; // Input: underflow/overflow bins
58  TMap *fSysIn; // Input: correlated errors
59  TMap *fBgrIn; // Input: size of background sources
60  TMap *fBgrErrUncorrInSq; // Input: uncorr error squared from bgr sources
61  TMap *fBgrErrScaleIn; // Input: background sources correlated error
62  Double_t fDtau; // Input: error on tau
63  TMatrixD *fYData; // Input: fY prior to bgr subtraction
64  TMatrixDSparse *fVyyData; // Input: error on fY prior to bgr subtraction
65  TMatrixDSparse *fEmatUncorrX; // Result: syst.error from fDA2 on fX
66  TMatrixDSparse *fEmatUncorrAx; // Result: syst.error from fDA2 on fAx
67  TMap *fDeltaCorrX; // Result: syst.shift from fSysIn on fX
68  TMap *fDeltaCorrAx; // Result: syst.shift from fSysIn on fAx
69  TMatrixDSparse *fDeltaSysTau; // Result: systematic shift from tau
70  protected:
71  TUnfoldSys(void); // for derived classes
72  virtual void ClearResults(void); // clear all results
73  virtual void PrepareSysError(void); // common calculations for syst.errors
74  virtual TMatrixDSparse *PrepareUncorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2); // calculate uncorrelated error matrix
75  virtual TMatrixDSparse *PrepareCorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2,const TMatrixDSparse *dsys); // calculate correlated error matrix
76  void ScaleColumnsByVector(TMatrixDSparse *m,const TMatrixTBase<Double_t> *v) const; // scale columns of m by the corresponding rows of v
77  void VectorMapToHist(TH1 *hist_delta,const TMatrixDSparse *delta,const Int_t *binMap); // map and sum vector delta, save in hist_delta
78  void GetEmatrixFromVyy(const TMatrixDSparse *vyy,TH2 *ematrix,const Int_t *binMap,Bool_t clearEmat); // propagate error matrix vyy to the result
79  void DoBackgroundSubtraction(void);
82  public:
83  enum ESysErrMode { // meaning of the argument to AddSysError()
84  kSysErrModeMatrix=0, // matrix is an alternative to the default matrix, the errors are the difference to the original matrix
85  kSysErrModeShift=1, // matrix gives the absolute shifts
86  kSysErrModeRelative=2 // matrix gives the relative shifts
87  };
88  TUnfoldSys(const TH2 *hist_A, EHistMap histmap, ERegMode regmode = kRegModeSize,
89  EConstraint constraint=kEConstraintArea); // constructor
90  virtual ~ TUnfoldSys(void); // delete data members
91  void AddSysError(const TH2 *sysError,const char *name, EHistMap histmap,
92  ESysErrMode mode); // add a systematic error source
93  Bool_t GetDeltaSysSource(TH1 *hist_delta,const char *source,
94  const Int_t *binMap=0); // get systematic shifts from one systematic source
95  void SubtractBackground(const TH1 *hist_bgr,const char *name,
96  Double_t scale=1.0,
97  Double_t scale_error=0.0); // subtract background prior to unfolding
98  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
99  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
100  Bool_t GetDeltaSysBackgroundScale(TH1 *delta,const char *source,
101  const Int_t *binMap=0); // get correlated uncertainty induced by the scale uncertainty of a background source
102  void SetTauError(Double_t delta_tau); // set uncertainty on tau
103  Bool_t GetDeltaSysTau(TH1 *delta,const Int_t *binMap=0); // get correlated uncertainty from varying tau
104  void GetEmatrixSysUncorr(TH2 *ematrix,const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix contribution from uncorrelated errors on the matrix A
105  void GetEmatrixSysSource(TH2 *ematrix,const char *source,
106  const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from one systematic source
107  void GetEmatrixSysBackgroundUncorr(TH2 *ematrix,const char *source,
108  const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from uncorrelated error of one background source
109  void GetEmatrixSysBackgroundScale(TH2 *ematrix,const char *source,
110  const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from the scale error of one background source
111  void GetEmatrixSysTau(TH2 *ematrix,
112  const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from tau variation
113  void GetEmatrixInput(TH2 *ematrix,const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error contribution from input vector
114  void GetEmatrixTotal(TH2 *ematrix,const Int_t *binMap=0); // get total error including systematic,statistical,background,tau errors
115  void GetRhoItotal(TH1 *rhoi,const Int_t *binMap=0,TH2 *invEmat=0); // get global correlation coefficients including systematic,statistical,background,tau errors
116  Double_t GetChi2Sys(void); // get total chi**2 including all systematic errors
117  ClassDef(TUnfoldSys, TUnfold_CLASS_VERSION) //Unfolding with support for systematic error propagation
118 };
119 
120 #endif
void InitTUnfoldSys(void)
Definition: TUnfoldSys.cxx:551
TMatrixDSparse * fEmatUncorrX
Definition: TUnfoldSys.h:65
virtual void ClearResults(void)
Definition: TUnfoldSys.cxx:608
Double_t GetChi2Sys(void)
void GetEmatrixInput(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
TMap * fBgrErrScaleIn
Definition: TUnfoldSys.h:61
Bool_t GetDeltaSysSource(TH1 *hist_delta, const char *source, const Int_t *binMap=0)
Definition: TUnfoldSys.cxx:940
TMap * fBgrIn
Definition: TUnfoldSys.h:59
void VectorMapToHist(TH1 *hist_delta, const TMatrixDSparse *delta, const Int_t *binMap)
virtual TMatrixDSparse * PrepareCorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixDSparse *dsys)
Definition: TUnfoldSys.cxx:910
TMatrixDSparse * fDAinRelSq
Definition: TUnfoldSys.h:55
virtual void PrepareSysError(void)
Definition: TUnfoldSys.cxx:619
TUnfold is used to decompose a measurement y into several sources x given the measurement uncertainti...
Definition: TUnfoldSys.h:51
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetTauError(Double_t delta_tau)
Definition: TUnfoldSys.cxx:933
Double_t fDtau
Definition: TUnfoldSys.h:62
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)
Definition: TUnfoldSys.cxx:410
void GetEmatrixSysBackgroundUncorr(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
TMap * fSysIn
Definition: TUnfoldSys.h:58
#define ClassDef(name, id)
Definition: Rtypes.h:254
void GetEmatrixSysUncorr(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
Definition: TUnfoldSys.cxx:704
EHistMap
Definition: TUnfold.h:188
EConstraint
Definition: TUnfold.h:103
TMatrixDSparse * fDeltaSysTau
Definition: TUnfoldSys.h:69
void GetEmatrixSysBackgroundScale(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
void DoBackgroundSubtraction(void)
Definition: TUnfoldSys.cxx:300
TMatrixDSparse * GetSummedErrorMatrixXX(void)
TMatrixDSparse * GetSummedErrorMatrixYY(void)
ERegMode
Definition: TUnfold.h:107
TMap * fBgrErrUncorrInSq
Definition: TUnfoldSys.h:60
void GetEmatrixSysSource(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
Definition: TUnfoldSys.cxx:991
TMap * fDeltaCorrX
Definition: TUnfoldSys.h:67
TMap * fDeltaCorrAx
Definition: TUnfoldSys.h:68
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
SVector< double, 2 > v
Definition: Dict.h:5
virtual TMatrixDSparse * PrepareUncorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2)
Definition: TUnfoldSys.cxx:717
void GetEmatrixTotal(TH2 *ematrix, const Int_t *binMap=0)
TMarker * m
Definition: textangle.C:8
Bool_t GetDeltaSysTau(TH1 *delta, const Int_t *binMap=0)
Definition: TUnfoldSys.cxx:980
virtual ~TUnfoldSys(void)
Definition: TUnfoldSys.cxx:592
void SubtractBackground(const TH1 *hist_bgr, const char *name, Double_t scale=1.0, Double_t scale_error=0.0)
Definition: TUnfoldSys.cxx:441
TMatrixDSparse * fVyyData
Definition: TUnfoldSys.h:64
void GetEmatrixSysTau(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
double Double_t
Definition: RtypesCore.h:55
TMatrixD * fDAinColRelSq
Definition: TUnfoldSys.h:56
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
TUnfoldSys(void)
The TH1 histogram class.
Definition: TH1.h:80
TMatrixDSparse * fEmatUncorrAx
Definition: TUnfoldSys.h:66
#define TUnfold_CLASS_VERSION
Definition: TUnfold.h:96
#define name(a, b)
Definition: linkTestLib0.cpp:5
void AddSysError(const TH2 *sysError, const char *name, EHistMap histmap, ESysErrMode mode)
Definition: TUnfoldSys.cxx:217
TUnfold is used to decompose a measurement y into several sources x given the measurement uncertainti...
Definition: TUnfold.h:99
void ScaleColumnsByVector(TMatrixDSparse *m, const TMatrixTBase< Double_t > *v) const
TMatrixD * fYData
Definition: TUnfoldSys.h:63
void GetRhoItotal(TH1 *rhoi, const Int_t *binMap=0, TH2 *invEmat=0)
const Bool_t kTRUE
Definition: Rtypes.h:91
void GetEmatrixFromVyy(const TMatrixDSparse *vyy, TH2 *ematrix, const Int_t *binMap, Bool_t clearEmat)
Bool_t GetDeltaSysBackgroundScale(TH1 *delta, const char *source, const Int_t *binMap=0)
Definition: TUnfoldSys.cxx:958
TMatrixD * fAoutside
Definition: TUnfoldSys.h:57
void GetBackground(TH1 *bgr, const char *bgrSource=0, const Int_t *binMap=0, Int_t includeError=3, Bool_t clearHist=kTRUE) const
Definition: TUnfoldSys.cxx:480