New set of classes for B->J/psi->ee analysis and fit a la CDF (Carmelo, Giuseppe)
[u/mrichter/AliRoot.git] / CORRFW / AliCFUnfolding.h
CommitLineData
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
18class 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(Bool_t b=kTRUE) {fUseSmoothing=b;}
32 void Unfold();
33
34 THnSparse* GetResponse() const {return fResponse;}
35 THnSparse* GetInverseResponse() const {return fInverseResponse;}
36 THnSparse* GetPrior() const {return fPrior;}
37 THnSparse* GetOriginalPrior() const {return fOriginalPrior;}
38 THnSparse* GetEfficiency() const {return fEfficiency;}
39 THnSparse* GetUnfolded() const {return fUnfolded;}
40
41 private :
42
43 // user-related settings
44 THnSparse *fResponse; // Response matrix : dimensions must be 2N = 2 x (number of variables)
45 // first N dimensions must be filled with reconstructed values
46 // last N dimensions must be filled with generated values
47 THnSparse *fPrior; // This is the assumed generated distribution : dimensions must be N = number of variables
48 // it will be used at the first step
49 // then will be updated automatically at each iteration
50 THnSparse *fOriginalPrior; // This is the original prior distribution : will not be modified
51 THnSparse *fEfficiency; // Efficiency map : dimensions must be N = number of variables
52 // this map must be filled only with "true" values of the variables (should not include resolution effects)
53 THnSparse *fMeasured; // Measured spectrum to be unfolded : dimensions must be N = number of variables
54 Int_t fMaxNumIterations; // Maximum number of iterations to be performed
55 Int_t fNVariables; // Number of variables used in analysis spectra (pt, y, ...)
56 Double_t fMaxChi2; // Maximum Chi2 between unfolded and prior distributions.
57 Bool_t fUseSmoothing; // Smooth the unfolded sectrum at each iteration
58
59 // internal settings
60 THnSparse *fInverseResponse; // Inverse response matrix
61 THnSparse *fMeasuredEstimate; // Estimation of the measured (M) spectrum given the a priori (T) distribution
62 THnSparse *fConditional; // Matrix holding the conditional probabilities P(M|T)
63 THnSparse *fProjResponseInT; // Projection of the response matrix on TRUE axis
64 THnSparse *fUnfolded; // Unfolded spectrum
65 Int_t *fCoordinates2N; // Coordinates in 2N (measured,true) space
66 Int_t *fCoordinatesN_M; // Coordinates in measured space
67 Int_t *fCoordinatesN_T; // Coordinates in true space
68
69
70 // functions
71 void Init(); // initialisation of the internal settings
72 void GetCoordinates(); // gets a cell coordinates in Measured and True space
73 void CreateConditional(); // creates the conditional matrix from the response matrix
74 void CreateEstMeasured(); // creates the measured spectrum estimation from the conditional matrix and the prior distribution
75 void CreateInvResponse(); // creates the inverse response function (Bayes Theorem) from the conditional matrix and the prior distribution
76 void CreateUnfolded(); // creates the unfolded spectrum from the inverse response matrix and the measured distribution
77 void CreateFlatPrior(); // creates a flat a priori distribution in case the one given in the constructor is null
78 Double_t GetChi2(); // returns the chi2 between unfolded and prior spectra
79 void Smooth(); // smooth the unfolded spectrum using the neighbouring cells
80
81 ClassDef(AliCFUnfolding,0);
82};
83
84#endif