]>
Commit | Line | Data |
---|---|---|
1 | /* $Id$ */ | |
2 | ||
3 | #ifndef ALIUNFOLDING_H | |
4 | #define ALIUNFOLDING_H | |
5 | ||
6 | // | |
7 | // class that implements several unfolding methods | |
8 | // I.e. chi2 minimization and bayesian unfolding | |
9 | // The whole class is static and not thread-safe (due to the fact that MINUIT unfolding is not thread-safe) | |
10 | // | |
11 | ||
12 | // TMatrixD, TVectorD defined here, because it does not seem possible to predeclare these (or i do not know how) | |
13 | // --> | |
14 | // $ROOTSYS/include/TVectorDfwd.h:21: conflicting types for `typedef struct TVectorT<Double_t> TVectorD' | |
15 | // PWG0/AliUnfolding.h:21: previous declaration as `struct TVectorD' | |
16 | ||
17 | #include "TObject.h" | |
18 | #include <TMatrixD.h> | |
19 | #include <TVectorD.h> | |
20 | ||
21 | class TH1; | |
22 | class TH2; | |
23 | class TF1; | |
24 | ||
25 | class AliUnfolding : public TObject | |
26 | { | |
27 | public: | |
28 | enum RegularizationType { kNone = 0, kPol0, kPol1, kLog, kEntropy, kCurvature }; | |
29 | enum MethodType { kInvalid = -1, kChi2Minimization = 0, kBayesian = 1, kFunction = 2}; | |
30 | ||
31 | virtual ~AliUnfolding() {}; | |
32 | ||
33 | static void SetUnfoldingMethod(MethodType methodType); | |
34 | static void SetCreateOverflowBin(Float_t overflowBinLimit); | |
35 | static void SetSkipBinsBegin(Int_t nBins); | |
36 | static void SetNbins(Int_t nMeasured, Int_t nUnfolded); | |
37 | static void SetChi2Regularization(RegularizationType type, Float_t weight); | |
38 | static void SetMinuitStepSize(Float_t stepSize) { fgMinuitStepSize = stepSize; } | |
39 | static void SetNormalizeInput(Bool_t flag) { fgNormalizeInput = flag; } | |
40 | static void SetBayesianParameters(Float_t smoothing, Int_t nIterations); | |
41 | static void SetFunction(TF1* function); | |
42 | static void SetDebug(Bool_t flag) { fgDebug = flag; } | |
43 | ||
44 | static Int_t Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check = kFALSE); | |
45 | ||
46 | protected: | |
47 | AliUnfolding() {}; | |
48 | ||
49 | static Int_t UnfoldWithMinuit(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check); | |
50 | static Int_t UnfoldWithBayesian(TH2* correlation, TH1* aEfficiency, TH1* measured, TH1* initialConditions, TH1* aResult); | |
51 | static Int_t UnfoldWithFunction(TH2* correlation, TH1* efficiency, TH1* measured, TH1* /* initialConditions */, TH1* aResult); | |
52 | ||
53 | static void DrawGuess(Double_t *params); | |
54 | static void CreateOverflowBin(TH2* correlation, TH1* measured); | |
55 | static void SetStaticVariables(TH2* correlation, TH1* measured); | |
56 | ||
57 | static Double_t RegularizationPol0(TVectorD& params); | |
58 | static Double_t RegularizationPol1(TVectorD& params); | |
59 | static Double_t RegularizationTotalCurvature(TVectorD& params); | |
60 | static Double_t RegularizationEntropy(TVectorD& params); | |
61 | static Double_t RegularizationLog(TVectorD& params); | |
62 | ||
63 | static void Chi2Function(Int_t&, Double_t*, Double_t& chi2, Double_t *params, Int_t); | |
64 | static void TF1Function(Int_t& unused1, Double_t* unused2, Double_t& chi2, Double_t *params, Int_t unused3); | |
65 | ||
66 | // static variable to be accessed by MINUIT | |
67 | static TMatrixD* fgCorrelationMatrix; // contains fCurrentCorrelation in matrix form | |
68 | static TMatrixD* fgCorrelationCovarianceMatrix; // contains the errors of fCurrentESD | |
69 | static TVectorD* fgCurrentESDVector; // contains fCurrentESD | |
70 | static TVectorD* fgEntropyAPriori; // a-priori distribution for entropy regularization | |
71 | ||
72 | static TF1* fgFitFunction; // fit function | |
73 | ||
74 | // --- configuration params follow --- | |
75 | static MethodType fgMethodType; // unfolding method to be used | |
76 | static Int_t fgMaxParams; // bins in unfolded histogram = number of fit params | |
77 | static Int_t fgMaxInput; // bins in measured histogram | |
78 | static Float_t fgOverflowBinLimit; // to fix fluctuations at high multiplicities, all entries above the limit are summarized in one bin | |
79 | ||
80 | static RegularizationType fgRegularizationType; // regularization that is used during Chi2 method | |
81 | static Float_t fgRegularizationWeight; // factor for regularization term | |
82 | static Int_t fgSkipBinsBegin; // (optional) skip the given number of bins in the regularization | |
83 | static Float_t fgMinuitStepSize; // (usually not needed to be changed) step size in minimization | |
84 | static Bool_t fgNormalizeInput; // normalize input spectrum | |
85 | ||
86 | static Float_t fgBayesianSmoothing; // smoothing parameter (0 = no smoothing) | |
87 | static Int_t fgBayesianIterations; // number of iterations in Bayesian method | |
88 | ||
89 | static Bool_t fgDebug; // debug flag | |
90 | // --- end of configuration --- | |
91 | ||
92 | private: | |
93 | AliUnfolding(const AliUnfolding&); | |
94 | AliUnfolding& operator=(const AliUnfolding&); | |
95 | ||
96 | ClassDef(AliUnfolding, 0); | |
97 | }; | |
98 | ||
99 | #endif | |
100 |