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