TUnfoldSys.h

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: TUnfoldSys.h 37440 2010-12-09 15:13:46Z moneta $
00002 // Author: Stefan Schmitt
00003 // DESY, 23/01/09
00004 
00005 //  Version 16, parallel to changes in TUnfold
00006 //
00007 //  History:
00008 //     Version 15, fix bugs with uncorr. uncertainties, add backgnd subtraction
00009 //     Version 14, with changes in TUnfoldSys.cxx
00010 //     Version 13, support for systematic errors
00011 
00012 #ifndef ROOT_TUnfoldSys
00013 #define ROOT_TUnfoldSys
00014 
00015 #include <TUnfold.h>
00016 
00017 class TMap;
00018 
00019 class TUnfoldSys : public TUnfold {
00020  private:
00021    void InitTUnfoldSys(void);     // initialize all data members
00022  protected:
00023    TMatrixDSparse *fDAinRelSq;  // Input: normalized errors from input matrix
00024    TMatrixD* fDAinColRelSq;     // Input: normalized column err.sq. (inp.matr.)
00025    TMatrixD* fAoutside;         // Input: underflow/overflow bins
00026    TMap *fSysIn;                // Input: correlated errors
00027    TMap *fBgrIn;                // Input: size of background sources
00028    TMap *fBgrErrUncorrIn;       // Input: uncorrelated error from bgr sources
00029    TMap *fBgrErrCorrIn;         // Input: background sources correlated error
00030    Double_t fDtau;              // Input: error on tau
00031    TMatrixD *fYData;            // Input: fY prior to bgr subtraction
00032    TMatrixDSparse *fVyyData;    // Input: error on fY prior to bgr subtraction
00033    TMatrixDSparse *fEmatUncorrX;      // Result: syst.error from fDA2 on fX
00034    TMatrixDSparse *fEmatUncorrAx;     // Result: syst.error from fDA2 on fAx
00035    TMap *fDeltaCorrX;           // Result: syst.shift from fSysIn on fX
00036    TMap *fDeltaCorrAx;          // Result: syst.shift from fSysIn on fAx
00037    TMatrixDSparse *fDeltaSysTau; // Result: systematic shift from tau
00038  protected:
00039    TUnfoldSys(void);            // for derived classes
00040    virtual void ClearResults(void);     // clear all results
00041    virtual void PrepareSysError(void); // common calculations for syst.errors
00042    virtual TMatrixDSparse *PrepareUncorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2); // calculate uncorrelated error matrix
00043    virtual TMatrixDSparse *PrepareCorrEmat(const TMatrixDSparse *m1,const TMatrixDSparse *m2,const TMatrixDSparse *dsys); // calculate correlated error matrix
00044    void ScaleColumnsByVector(TMatrixDSparse *m,const TMatrixTBase<Double_t> *v) const; // scale columns of m by the corresponding rows of v
00045    void VectorMapToHist(TH1 *hist_delta,const TMatrixDSparse *delta,const Int_t  *binMap); // map and sum vector delta, save in hist_delta
00046    void GetEmatrixFromVyy(const TMatrixDSparse *vyy,TH2 *ematrix,const Int_t *binMap,Bool_t clearEmat); // propagate error matrix vyy to the result
00047    void DoBackgroundSubtraction(void);
00048  public:
00049    enum ESysErrMode { // meaning of the argument to AddSysError()
00050      kSysErrModeMatrix=0, // matrix is an alternative to the default matrix, the errors are the difference to the original matrix
00051      kSysErrModeShift=1, // matrix gives the absolute shifts
00052      kSysErrModeRelative=2 // matrix gives the relative shifts
00053    };
00054    TUnfoldSys(const TH2 *hist_A, EHistMap histmap, ERegMode regmode = kRegModeSize,
00055              EConstraint constraint=kEConstraintNone);      // constructor
00056    virtual ~ TUnfoldSys(void);    // delete data members
00057    void AddSysError(const TH2 *sysError,const char *name, EHistMap histmap,
00058                     ESysErrMode mode); // add a systematic error source
00059    void GetDeltaSysSource(TH1 *hist_delta,const char *source,
00060                           const Int_t *binMap=0); // get systematic shifts from one systematic source
00061    void SubtractBackground(const TH1 *hist_bgr,const char *name,
00062                            Double_t scale=1.0,
00063                            Double_t scale_error=0.0); // subtract background prior to unfolding
00064    virtual Int_t SetInput(const TH1 *hist_y,Double_t scaleBias=0.0,Double_t oneOverZeroError=0.0); // define input consistently in case of background subtraction
00065    void GetDeltaSysBackgroundScale(TH1 *delta,const char *source,
00066                                 const Int_t *binMap=0); // get correlated uncertainty induced by the scale uncertainty of a background source
00067    void SetTauError(Double_t delta_tau); // set uncertainty on tau
00068    void GetDeltaSysTau(TH1 *delta,const Int_t *binMap=0); // get correlated uncertainty from varying tau
00069    void GetEmatrixSysUncorr(TH2 *ematrix,const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix contribution from uncorrelated errors on the matrix A
00070    void GetEmatrixSysSource(TH2 *ematrix,const char *source,
00071                             const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from one systematic source
00072    void GetEmatrixSysBackgroundUncorr(TH2 *ematrix,const char *source,
00073                                    const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from uncorrelated error of one background source
00074    void GetEmatrixSysBackgroundScale(TH2 *ematrix,const char *source,
00075                                   const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from the scale error of one background source
00076    void GetEmatrixSysTau(TH2 *ematrix,
00077                       const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error matrix from tau variation
00078    void GetEmatrixInput(TH2 *ematrix,const Int_t *binMap=0,Bool_t clearEmat=kTRUE); // get error contribution from input vector
00079    void GetEmatrixTotal(TH2 *ematrix,const Int_t *binMap=0); // get total error including systematic,statistical,background,tau errors
00080    Double_t GetChi2Sys(void); // get total chi**2 including all systematic errors
00081 
00082    ClassDef(TUnfoldSys, 0) //Unfolding with support for systematic error propagation
00083 };
00084 
00085 #endif

Generated on Tue Jul 5 14:22:59 2011 for ROOT_528-00b_version by  doxygen 1.5.1