00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TUnfoldBinning
00014 #define ROOT_TUnfoldBinning
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "TUnfold.h"
00045 #include <iostream>
00046 #include <TNamed.h>
00047 #include <TObjArray.h>
00048 #include <TObjString.h>
00049 #include <TAxis.h>
00050 #include <TF1.h>
00051
00052 #define TUnfoldBinning TUnfoldBinningV17
00053
00054 class TUnfoldBinningV17 : public TNamed {
00055 protected:
00056
00057 TUnfoldBinningV17 *parentNode;
00058
00059 TUnfoldBinningV17 *childNode;
00060
00061 TUnfoldBinningV17 *nextNode;
00062
00063 TUnfoldBinningV17 *prevNode;
00064
00065 TObjArray *fAxisList;
00066
00067 TObjArray *fAxisLabelList;
00068
00069 Int_t fHasUnderflow;
00070
00071 Int_t fHasOverflow;
00072
00073 Int_t fDistributionSize;
00074
00075 Int_t fFirstBin;
00076
00077 Int_t fLastBin;
00078
00079 TObject *fBinFactorFunction;
00080
00081 Double_t fBinFactorConstant;
00082 public:
00083
00084 enum {
00085
00086 MAXDIM=32
00087 };
00088 TUnfoldBinningV17(const char *name=0,Int_t nBins=0,const char *binNames=0);
00089 TUnfoldBinningV17(const TAxis &axis,Int_t includeUnderflow,Int_t includeOverflow);
00090 TUnfoldBinningV17 *AddBinning
00091 (TUnfoldBinningV17 *binning);
00092 TUnfoldBinningV17 *AddBinning(const char *name,Int_t nBins=0,const char *binNames=0);
00093 Bool_t AddAxis(const char *name,Int_t nBins,const Double_t *binBorders,
00094 Bool_t hasUnderflow,Bool_t hasOverflow);
00095 Bool_t AddAxis(const char *name,Int_t nBins,Double_t xMin,Double_t xMax,
00096 Bool_t hasUnderflow,Bool_t hasOverflow);
00097 Bool_t AddAxis(const TAxis &axis,Bool_t includeUnderflow,Bool_t includeOverflow);
00098 virtual ~TUnfoldBinningV17(void);
00099 void PrintStream(std::ostream &out,Int_t indent=0,int debug=0) const;
00100 void SetBinFactorFunction(Double_t normalisation,TF1 *userFunc=0);
00101
00102
00103
00104 inline TUnfoldBinningV17 const *GetChildNode(void) const { return childNode; }
00105
00106 inline TUnfoldBinningV17 const *GetPrevNode(void) const { return prevNode; }
00107
00108 inline TUnfoldBinningV17 const *GetNextNode(void) const { return nextNode; }
00109
00110 inline TUnfoldBinningV17 const *GetParentNode(void) const { return parentNode; }
00111 TUnfoldBinningV17 const *FindNode(char const *name) const;
00112
00113 TUnfoldBinningV17 const *GetRootNode(void) const;
00114
00115
00116 Int_t GetTH1xNumberOfBins(Bool_t originalAxisBinning=kTRUE,const char *axisSteering=0) const;
00117 TH1 *CreateHistogram(const char *histogramName,Bool_t originalAxisBinning=kFALSE,Int_t **binMap=0,const char *histogramTitle=0,const char *axisSteering=0) const;
00118 TH2D *CreateErrorMatrixHistogram(const char *histogramName,Bool_t originalAxisBinning,Int_t **binMap=0,const char *histogramTitle=0,const char *axisSteering=0) const;
00119 static TH2D *CreateHistogramOfMigrations(TUnfoldBinningV17 const *xAxis,
00120 TUnfoldBinningV17 const *yAxis,
00121 char const *histogramName,
00122 Bool_t originalXAxisBinning=kFALSE,
00123 Bool_t originalYAxisBinning=kFALSE,
00124 char const *histogramTitle=0);
00125 TH1 *ExtractHistogram(const char *histogramName,const TH1 *globalBins,const TH2 *globalBinsEmatrix=0,Bool_t originalAxisBinning=kTRUE,const char *axisSteering=0) const;
00126
00127 Int_t *CreateEmptyBinMap(void) const;
00128 void SetBinMapEntry(Int_t *binMap,Int_t globalBin,Int_t destBin) const;
00129 Int_t FillBinMap1D(Int_t *binMap,const char *axisSteering,
00130 Int_t firstBinX) const;
00131
00132 Int_t GetGlobalBinNumber(Double_t x) const;
00133 Int_t GetGlobalBinNumber(Double_t x,Double_t y) const;
00134 Int_t GetGlobalBinNumber(Double_t x,Double_t y,Double_t z) const;
00135 Int_t GetGlobalBinNumber(Double_t x0,Double_t x1,Double_t x2,Double_t x3) const;
00136 Int_t GetGlobalBinNumber(Double_t x0,Double_t x1,Double_t x2,Double_t x3,Double_t x4) const;
00137 Int_t GetGlobalBinNumber(Double_t x0,Double_t x1,Double_t x2,Double_t x3,Double_t x4,Double_t x5) const;
00138 Int_t GetGlobalBinNumber(const Double_t *x,Int_t *isBelow=0,Int_t *isAbove=0) const;
00139
00140 inline Int_t GetStartBin(void) const { return fFirstBin; }
00141
00142 inline Int_t GetEndBin(void) const { return fLastBin; }
00143 virtual Bool_t IsBinFactorGlobal(void) const;
00144 Double_t GetGlobalFactor(void) const;
00145
00146
00147 TString GetBinName(Int_t iBin) const;
00148 Double_t GetBinSize(Int_t iBin) const;
00149 virtual Double_t GetBinFactor(Int_t iBin) const;
00150 void GetBinUnderflowOverflowStatus(Int_t iBin,Int_t *uStatus,Int_t *oStatus) const;
00151 Int_t GetBinNeighbours(Int_t globalBin,Int_t axis,
00152 Int_t *prev,Double_t *distPrev,
00153 Int_t *next,Double_t *distNext,
00154 Bool_t isPeriodic=kFALSE) const;
00155
00156
00157 inline Int_t GetDistributionNumberOfBins(void) const { return fDistributionSize; }
00158
00159 inline Int_t GetDistributionDimension(void) const { return fAxisList->GetEntriesFast(); }
00160 virtual Double_t GetDistributionAverageBinSize(Int_t axis,Bool_t includeUnderflow, Bool_t includeOverflow) const;
00161
00162 inline TVectorD const *GetDistributionBinning(Int_t axis) const {
00163 return (TVectorD const *)fAxisList->At(axis); }
00164
00165 inline TString GetDistributionAxisLabel(Int_t axis) const {
00166 return ((TObjString * const)fAxisLabelList->At(axis))->GetString(); }
00167
00168 virtual Double_t GetDistributionUnderflowBinWidth(Int_t axis) const;
00169 virtual Double_t GetDistributionOverflowBinWidth(Int_t axis) const;
00170 virtual Double_t GetDistributionBinCenter(Int_t axis,Int_t bin) const;
00171 Bool_t HasUnconnectedBins(void) const;
00172 const TObjString *GetUnconnectedBinName(Int_t bin) const;
00173
00174 Bool_t HasUnderflow(int axis) const { return fHasUnderflow & (1<<axis); }
00175
00176 Bool_t HasOverflow(int axis) const { return fHasOverflow & (1<<axis); }
00177 void DecodeAxisSteering(const char *axisSteering,const char *options,
00178 Int_t *isOptionGiven) const;
00179 protected:
00180
00181 TUnfoldBinningV17 *GetRootNode(void);
00182 void Initialize(Int_t nBins);
00183 Int_t UpdateFirstLastBin(Bool_t startWithRootNode=kTRUE);
00184 TUnfoldBinningV17 const *ToAxisBins(Int_t globalBin,Int_t *axisBins) const;
00185 Int_t ToGlobalBin(Int_t const *axisBins,Int_t *isBelow=0,Int_t *isAbove=0) const;
00186 TString BuildHistogramTitle(const char *histogramName,const char *histogramTitle,
00187 Int_t const *axisList) const;
00188 TString BuildHistogramTitle2D(const char *histogramName,const char *histogramTitle,
00189 Int_t xAxis,const TUnfoldBinningV17 *yAxisBinning,Int_t yAxis) const;
00190 Int_t GetTHxxBinning(Int_t maxDim,Int_t *axisBins,Int_t *axisList,const char *axisSteering) const;
00191 Int_t GetTHxxBinningSingleNode(Int_t maxDim,Int_t *axisBins,Int_t *axisList,const char *axisSteering) const;
00192 Int_t GetTHxxBinsRecursive(const char *axisSteering) const;
00193 const TUnfoldBinningV17 *GetNonemptyNode(void) const;
00194 Int_t *CreateBinMap(const TH1 *hist,Int_t nDim,const Int_t *axisList,const char *axisSteering) const;
00195 Int_t FillBinMapRecursive(Int_t startBin,const char *axisSteering,
00196 Int_t *binMap) const;
00197 Int_t FillBinMapSingleNode(const TH1 *hist,Int_t startBin,Int_t nDim,const Int_t *axisList,const char *axisSteering,Int_t *binMap) const;
00198 void SetBinFactor(Double_t normalisation,TObject *factors);
00199
00200 ClassDef(TUnfoldBinningV17, TUnfold_CLASS_VERSION)
00201 };
00202
00203 #endif