00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ROOT_TUnfold
00027 #define ROOT_TUnfold
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #include <TH1D.h>
00061 #include <TH2D.h>
00062 #include <TObject.h>
00063 #include <TArrayI.h>
00064 #include <TSpline.h>
00065 #include <TMatrixDSparse.h>
00066 #include <TMatrixD.h>
00067 #include <TObjArray.h>
00068
00069 #define TUnfold_VERSION "V16.0"
00070
00071 class TUnfold : public TObject {
00072 private:
00073 void InitTUnfold(void);
00074 public:
00075 enum EConstraint {
00076 kEConstraintNone =0,
00077 kEConstraintArea =1
00078 };
00079 enum ERegMode {
00080 kRegModeNone = 0,
00081 kRegModeSize = 1,
00082 kRegModeDerivative = 2,
00083 kRegModeCurvature = 3,
00084 kRegModeMixed = 4
00085 };
00086 protected:
00087 TMatrixDSparse * fA;
00088 TMatrixDSparse *fLsquared;
00089 TMatrixDSparse *fVyy;
00090 TMatrixD *fY;
00091 TMatrixD *fX0;
00092 Double_t fTauSquared;
00093 Double_t fBiasScale;
00094 TArrayI fXToHist;
00095 TArrayI fHistToX;
00096 TArrayD fSumOverY;
00097 EConstraint fConstraint;
00098 ERegMode fRegMode;
00099 private:
00100 TMatrixD *fX;
00101 TMatrixDSparse *fVxx;
00102 TMatrixDSparse *fVxxInv;
00103 TMatrixDSparse *fAx;
00104 Double_t fChi2A;
00105 Double_t fLXsquared;
00106 Double_t fRhoMax;
00107 Double_t fRhoAvg;
00108 Int_t fNdf;
00109 TMatrixDSparse *fDXDAM[2];
00110 TMatrixDSparse *fDXDAZ[2];
00111 TMatrixDSparse *fDXDtauSquared;
00112 TMatrixDSparse *fDXDY;
00113 TMatrixDSparse *fEinv;
00114 TMatrixDSparse *fE;
00115 protected:
00116 TUnfold(void);
00117 virtual Double_t DoUnfold(void);
00118 virtual void ClearResults(void);
00119
00120 TMatrixDSparse *MultiplyMSparseM(const TMatrixDSparse *a,const TMatrixD *b) const;
00121 TMatrixDSparse *MultiplyMSparseMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const;
00122 TMatrixDSparse *MultiplyMSparseTranspMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const;
00123 TMatrixDSparse *MultiplyMSparseMSparseTranspVector
00124 (const TMatrixDSparse *m1,const TMatrixDSparse *m2,
00125 const TMatrixTBase<Double_t> *v) const;
00126 TMatrixD *InvertMSparse(const TMatrixDSparse *A) const;
00127 static Bool_t InvertMConditioned(TMatrixD *A);
00128 void AddMSparse(TMatrixDSparse *dest,Double_t f,const TMatrixDSparse *src);
00129 TMatrixDSparse *CreateSparseMatrix(Int_t nrow,Int_t ncol,Int_t nele,Int_t *row,Int_t *col,Double_t *data) const;
00130 inline Int_t GetNx(void) const {
00131 return fA->GetNcols();
00132 }
00133 inline Int_t GetNy(void) const {
00134 return fA->GetNrows();
00135 }
00136 void ErrorMatrixToHist(TH2 *ematrix,const TMatrixDSparse *emat,const Int_t *binMap,
00137 Bool_t doClear) const;
00138 inline const TMatrixDSparse *GetDXDY(void) const { return fDXDY; }
00139 inline const TMatrixDSparse *GetDXDAM(int i) const { return fDXDAM[i]; }
00140 inline const TMatrixDSparse *GetDXDAZ(int i) const { return fDXDAZ[i]; }
00141 inline const TMatrixDSparse *GetDXDtauSquared(void) const { return fDXDtauSquared; }
00142 inline const TMatrixDSparse *GetAx(void) const { return fAx; }
00143 inline const TMatrixDSparse *GetEinv(void) const { return fEinv; }
00144 inline const TMatrixDSparse *GetE(void) const { return fE; }
00145 inline const TMatrixDSparse *GetVxx(void) const { return fVxx; }
00146 inline const TMatrixDSparse *GetVxxInv(void) const { return fVxxInv; }
00147 inline const TMatrixD *GetX(void) const { return fX; }
00148 static void DeleteMatrix(TMatrixD **m);
00149 static void DeleteMatrix(TMatrixDSparse **m);
00150 public:
00151 enum EHistMap {
00152 kHistMapOutputHoriz = 0,
00153 kHistMapOutputVert = 1
00154 };
00155
00156 TUnfold(const TH2 *hist_A, EHistMap histmap,
00157 ERegMode regmode = kRegModeSize,
00158 EConstraint constraint=kEConstraintArea);
00159 virtual ~ TUnfold(void);
00160 static const char*GetTUnfoldVersion(void);
00161 void SetBias(const TH1 *bias);
00162 void SetConstraint(EConstraint constraint);
00163 Int_t RegularizeSize(int bin, Double_t scale = 1.0);
00164 Int_t RegularizeDerivative(int left_bin, int right_bin, Double_t scale = 1.0);
00165 Int_t RegularizeCurvature(int left_bin, int center_bin, int right_bin, Double_t scale_left = 1.0, Double_t scale_right = 1.0);
00166 Int_t RegularizeBins(int start, int step, int nbin, ERegMode regmode);
00167 Int_t RegularizeBins2D(int start_bin, int step1, int nbin1, int step2, int nbin2, ERegMode regmode);
00168 Double_t DoUnfold(Double_t tau,
00169 const TH1 *hist_y, Double_t scaleBias=0.0);
00170 virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0,Double_t oneOverZeroError=0.0);
00171 virtual Double_t DoUnfold(Double_t tau);
00172 virtual Int_t ScanLcurve(Int_t nPoint,Double_t tauMin,
00173 Double_t tauMax,TGraph **lCurve,
00174 TSpline **logTauX=0,TSpline **logTauY=0);
00175 TH1D *GetOutput(const char *name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00176 TH1D *GetBias(const char *name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00177 TH1D *GetFoldedOutput(const char *name,const char *title, Double_t y0 = 0.0, Double_t y1 = 0.0) const;
00178 TH1D *GetInput(const char *name,const char *title, Double_t y0 = 0.0, Double_t y1 = 0.0) const;
00179 TH2D *GetRhoIJ(const char *name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00180 TH2D *GetEmatrix(const char*name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00181 TH1D *GetRhoI(const char*name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00182 TH2D *GetLsquared(const char*name,const char *title, Double_t x0 = 0.0, Double_t x1 = 0.0) const;
00183
00184 void GetOutput(TH1 *output,const Int_t *binMap=0) const;
00185 void GetEmatrix(TH2 *ematrix,const Int_t *binMap=0) const;
00186 Double_t GetRhoI(TH1 *rhoi,TH2 *ematrixinv=0,const Int_t *binMap=0) const;
00187 void GetRhoIJ(TH2 *rhoij,const Int_t *binMap=0) const;
00188 Double_t GetTau(void) const;
00189 inline Double_t GetRhoMax(void) const { return fRhoMax; }
00190 inline Double_t GetRhoAvg(void) const { return fRhoAvg; }
00191 inline Double_t GetChi2A(void) const { return fChi2A; }
00192 Double_t GetChi2L(void) const;
00193 virtual Double_t GetLcurveX(void) const;
00194 virtual Double_t GetLcurveY(void) const;
00195 inline Int_t GetNdf(void) const { return fNdf; }
00196 Int_t GetNpar(void) const;
00197
00198 ClassDef(TUnfold, 0)
00199 };
00200
00201 #endif