]>
Commit | Line | Data |
---|---|---|
c0b10ad4 | 1 | |
2 | #ifndef ALICFUNFOLDING_H | |
3 | #define ALICFUNFOLDING_H | |
4 | ||
5 | //--------------------------------------------------------------------// | |
6 | // // | |
7 | // AliCFUnfolding Class // | |
8 | // Class to handle general unfolding procedure // | |
9 | // For the moment only bayesian unfolding is supported // | |
10 | // The next steps are to add chi2 minimisation and weighting methods // | |
11 | // // | |
12 | // Author : renaud.vernet@cern.ch // | |
13 | //--------------------------------------------------------------------// | |
14 | ||
15 | #include "TNamed.h" | |
16 | #include "THnSparse.h" | |
17 | ||
85b6bda9 | 18 | class TF1; |
19 | ||
c0b10ad4 | 20 | class AliCFUnfolding : public TNamed { |
21 | ||
22 | public : | |
23 | AliCFUnfolding(); | |
24 | AliCFUnfolding(const Char_t* name, const Char_t* title, const Int_t nVar, | |
25 | const THnSparse* response, const THnSparse* efficiency, const THnSparse* measured, const THnSparse* prior=0x0); | |
26 | AliCFUnfolding(const AliCFUnfolding& c); | |
27 | AliCFUnfolding& operator= (const AliCFUnfolding& c); | |
28 | ~AliCFUnfolding(); | |
29 | ||
30 | void SetMaxNumberOfIterations(Int_t n) {fMaxNumIterations=n;} | |
31 | void SetMaxChi2(Double_t val) {fMaxChi2=val;} | |
32 | void SetMaxChi2PerDOF(Double_t val); | |
85b6bda9 | 33 | void UseSmoothing(TF1* fcn=0x0, Option_t* opt="iremn") { // if fcn=0x0 then smooth using neighbouring bins |
34 | fUseSmoothing=kTRUE; // this function must NOT be used if fNVariables > 3 | |
35 | fSmoothFunction=fcn; // the option "opt" is used if "fcn" is specified | |
36 | fSmoothOption=opt; | |
37 | } | |
38 | ||
c0b10ad4 | 39 | void Unfold(); |
40 | ||
41 | THnSparse* GetResponse() const {return fResponse;} | |
42 | THnSparse* GetInverseResponse() const {return fInverseResponse;} | |
43 | THnSparse* GetPrior() const {return fPrior;} | |
44 | THnSparse* GetOriginalPrior() const {return fOriginalPrior;} | |
45 | THnSparse* GetEfficiency() const {return fEfficiency;} | |
46 | THnSparse* GetUnfolded() const {return fUnfolded;} | |
85b6bda9 | 47 | THnSparse* GetEstMeasured() const {return fMeasuredEstimate;} |
48 | THnSparse* GetConditional() const {return fConditional;} | |
49 | TF1* GetSmoothFunction() const {return fSmoothFunction;} | |
c0b10ad4 | 50 | |
51 | private : | |
52 | ||
53 | // user-related settings | |
54 | THnSparse *fResponse; // Response matrix : dimensions must be 2N = 2 x (number of variables) | |
85b6bda9 | 55 | // dimensions 0 -> N-1 must be filled with reconstructed values |
56 | // dimensions N -> 2N-1 must be filled with generated values | |
c0b10ad4 | 57 | THnSparse *fPrior; // This is the assumed generated distribution : dimensions must be N = number of variables |
58 | // it will be used at the first step | |
59 | // then will be updated automatically at each iteration | |
c0b10ad4 | 60 | THnSparse *fEfficiency; // Efficiency map : dimensions must be N = number of variables |
61 | // this map must be filled only with "true" values of the variables (should not include resolution effects) | |
62 | THnSparse *fMeasured; // Measured spectrum to be unfolded : dimensions must be N = number of variables | |
63 | Int_t fMaxNumIterations; // Maximum number of iterations to be performed | |
64 | Int_t fNVariables; // Number of variables used in analysis spectra (pt, y, ...) | |
65 | Double_t fMaxChi2; // Maximum Chi2 between unfolded and prior distributions. | |
66 | Bool_t fUseSmoothing; // Smooth the unfolded sectrum at each iteration | |
85b6bda9 | 67 | TF1 *fSmoothFunction; // Function used to smooth the unfolded spectrum |
68 | Option_t *fSmoothOption; // Option to use during the fit (with fSmoothFunction) ; default is "iremn" | |
c0b10ad4 | 69 | |
70 | // internal settings | |
85b6bda9 | 71 | THnSparse *fOriginalPrior; // This is the original prior distribution : will not be modified |
c0b10ad4 | 72 | THnSparse *fInverseResponse; // Inverse response matrix |
73 | THnSparse *fMeasuredEstimate; // Estimation of the measured (M) spectrum given the a priori (T) distribution | |
74 | THnSparse *fConditional; // Matrix holding the conditional probabilities P(M|T) | |
75 | THnSparse *fProjResponseInT; // Projection of the response matrix on TRUE axis | |
76 | THnSparse *fUnfolded; // Unfolded spectrum | |
77 | Int_t *fCoordinates2N; // Coordinates in 2N (measured,true) space | |
78 | Int_t *fCoordinatesN_M; // Coordinates in measured space | |
79 | Int_t *fCoordinatesN_T; // Coordinates in true space | |
80 | ||
81 | ||
82 | // functions | |
85b6bda9 | 83 | void Init(); // initialisation of the internal settings |
84 | void GetCoordinates(); // gets a cell coordinates in Measured and True space | |
85 | void CreateConditional(); // creates the conditional matrix from the response matrix | |
86 | void CreateEstMeasured(); // creates the measured spectrum estimation from the conditional matrix and the prior distribution | |
87 | void CreateInvResponse(); // creates the inverse response function (Bayes Theorem) from the conditional matrix and the prior distribution | |
88 | void CreateUnfolded(); // creates the unfolded spectrum from the inverse response matrix and the measured distribution | |
89 | void CreateFlatPrior(); // creates a flat a priori distribution in case the one given in the constructor is null | |
90 | Double_t GetChi2(); // returns the chi2 between unfolded and prior spectra | |
91 | Short_t Smooth(); // function calling smoothing methods | |
92 | Short_t SmoothUsingNeighbours(); // smoothes the unfolded spectrum using the neighbouring cells | |
93 | Short_t SmoothUsingFunction(); // smoothes the unfolded spectrum using a fit function | |
c0b10ad4 | 94 | |
95 | ClassDef(AliCFUnfolding,0); | |
96 | }; | |
97 | ||
98 | #endif |