]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdEta/AliMultiplicityCorrection.h
AliPWG0depHelper: function to find mother among the primaries
[u/mrichter/AliRoot.git] / PWG0 / dNdEta / AliMultiplicityCorrection.h
1 /* $Id$ */
2
3 #ifndef ALIMULTIPLICITYCORRECTION_H
4 #define ALIMULTIPLICITYCORRECTION_H
5
6 #include "TNamed.h"
7
8 //
9 // class that contains the correction matrix and the functions for
10 // correction the multiplicity spectrum
11 //
12
13 class TH1;
14 class TH2;
15 class TH1F;
16 class TH2F;
17 class TH3F;
18 class TF1;
19 class TCollection;
20
21 #include <TMatrixD.h>
22 #include <TVectorD.h>
23
24 class AliMultiplicityCorrection : public TNamed {
25   public:
26     enum EventType { kTrVtx = 0, kMB, kINEL };
27     enum RegularizationType { kNone = 0, kPol0, kPol1, kEntropy, kCurvature, kTest };
28
29     AliMultiplicityCorrection();
30     AliMultiplicityCorrection(const Char_t* name, const Char_t* title);
31     virtual ~AliMultiplicityCorrection();
32
33     virtual Long64_t Merge(TCollection* list);
34
35     void FillMeasured(Float_t vtx, Int_t measured05, Int_t measured10, Int_t measured15, Int_t measured20);
36     void FillGenerated(Float_t vtx, Bool_t triggered, Bool_t vertex, Int_t generated05, Int_t generated10, Int_t generated15, Int_t generated20, Int_t generatedAll);
37
38     void FillCorrection(Float_t vtx, Int_t generated05, Int_t generated10, Int_t generated15, Int_t generated20, Int_t generatedAll, Int_t measured05, Int_t measured10, Int_t measured15, Int_t measured20);
39
40     Bool_t LoadHistograms(const Char_t* dir);
41     void SaveHistograms();
42     void DrawHistograms();
43     void DrawComparison(const char* name, Int_t inputRange, Bool_t fullPhaseSpace, Bool_t normalizeESD, TH1* mcHist, Bool_t simple = kFALSE);
44
45     Int_t ApplyMinuitFit(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t check = kFALSE, TH1* inputDist = 0);
46     void SetRegularizationParameters(RegularizationType type, Float_t weight);
47
48     void ApplyNBDFit(Int_t inputRange, Bool_t fullPhaseSpace);
49
50     void ApplyBayesianMethod(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Float_t regPar = 0.1, Int_t nIterations = 15, TH1* inputDist = 0);
51
52     void ApplyGaussianMethod(Int_t inputRange, Bool_t fullPhaseSpace);
53
54     void ApplyLaszloMethod(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType);
55
56     TH2F* GetMultiplicityESD(Int_t i) { return fMultiplicityESD[i]; }
57     TH2F* GetMultiplicityVtx(Int_t i) { return fMultiplicityVtx[i]; }
58     TH2F* GetMultiplicityMB(Int_t i) { return fMultiplicityMB[i]; }
59     TH2F* GetMultiplicityINEL(Int_t i) { return fMultiplicityINEL[i]; }
60     TH2F* GetMultiplicityMC(Int_t i, EventType eventType);
61     TH3F* GetCorrelation(Int_t i) { return fCorrelation[i]; }
62     TH1F* GetMultiplicityESDCorrected(Int_t i) { return fMultiplicityESDCorrected[i]; }
63
64     void SetMultiplicityESD(Int_t i, TH2F* hist)  { fMultiplicityESD[i] = hist; }
65     void SetMultiplicityVtx(Int_t i, TH2F* hist)  { fMultiplicityVtx[i] = hist; }
66     void SetMultiplicityMB(Int_t i, TH2F* hist)   { fMultiplicityMB[i] = hist; }
67     void SetMultiplicityINEL(Int_t i, TH2F* hist) { fMultiplicityINEL[i] = hist; }
68     void SetCorrelation(Int_t i, TH3F* hist) { fCorrelation[i] = hist; }
69     void SetMultiplicityESDCorrected(Int_t i, TH1F* hist) { fMultiplicityESDCorrected[i] = hist; }
70
71     void SetGenMeasFromFunc(TF1* inputMC, Int_t id);
72     TH2F* CalculateMultiplicityESD(TH1* inputMC, Int_t correlationMap);
73
74     static void NormalizeToBinWidth(TH1* hist);
75     static void NormalizeToBinWidth(TH2* hist);
76
77     void GetComparisonResults(Float_t* mc, Int_t* mcLimit, Float_t* residuals);
78
79   protected:
80     enum { kESDHists = 4, kMCHists = 5, kCorrHists = 8 };
81
82     static const Int_t fgMaxParams;  // bins in unfolded histogram = number of fit params
83     static const Int_t fgMaxInput;   // bins in measured histogram
84
85     static Double_t RegularizationPol0(TVectorD& params);
86     static Double_t RegularizationPol1(TVectorD& params);
87     static Double_t RegularizationTotalCurvature(TVectorD& params);
88     static Double_t RegularizationEntropy(TVectorD& params);
89     static Double_t RegularizationTest(TVectorD& params);
90
91     static void MinuitFitFunction(Int_t&, Double_t*, Double_t& chi2, Double_t *params, Int_t);
92     static void MinuitNBD(Int_t& unused1, Double_t* unused2, Double_t& chi2, Double_t *params, Int_t unused3);
93
94     void SetupCurrentHists(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t createBigBin);
95
96     Float_t BayesCovarianceDerivate(Float_t matrixM[251][251], TH2* hResponse, TH1* fCurrentEfficiency, Int_t k, Int_t i, Int_t r, Int_t u);
97
98     static TH1* fCurrentESD;         // static variable to be accessed by MINUIT
99     static TH1* fCurrentCorrelation; // static variable to be accessed by MINUIT
100     static TH1* fCurrentEfficiency;  // static variable to be accessed by MINUIT
101
102     static TMatrixD* fCorrelationMatrix;            // contains fCurrentCorrelation in matrix form
103     static TMatrixD* fCorrelationCovarianceMatrix;  // contains the errors of fCurrentESD
104     static TVectorD* fCurrentESDVector;             // contains fCurrentESD
105     static TVectorD* fEntropyAPriori;               // a-priori distribution for entropy regularization
106
107     static TF1* fNBD;   // negative binomial distribution
108
109     static RegularizationType fRegularizationType; // regularization that is used during Chi2 method
110     static Float_t fRegularizationWeight;          // factor for regularization term
111
112     TH2F* fMultiplicityESD[kESDHists]; // multiplicity histogram: vtx vs multiplicity; array: |eta| < 0.5, 1, 1.5, 2 (0..3)
113     TH2F* fMultiplicityVtx[kMCHists];  // multiplicity histogram of events that have a reconstructed vertex : vtx vs multiplicity; array: |eta| < 0.5, 1, 1.5, 2, inf (0..4)
114     TH2F* fMultiplicityMB[kMCHists];   // multiplicity histogram of triggered events                        : vtx vs multiplicity; array: |eta| < 0.5, 1, 1.5, 2, inf (0..4)
115     TH2F* fMultiplicityINEL[kMCHists]; // multiplicity histogram of all (inelastic) events                  : vtx vs multiplicity; array: |eta| < 0.5, 1, 1.5, 2, inf (0..4)
116
117     TH3F* fCorrelation[kCorrHists];              // vtx vs. (gene multiplicity (trig+vtx)) vs. (meas multiplicity); array: |eta| < 0.5, 1, 1.5, 2 (0..3 and 4..7), the first corrects to the eta range itself, the second to full phase space
118     TH1F* fMultiplicityESDCorrected[kCorrHists]; // corrected histograms
119
120     Float_t fLastChi2MC;        // last Chi2 between MC and unfolded ESD (calculated in DrawComparison)
121     Int_t   fLastChi2MCLimit;   // bin where the last chi2 breached a certain threshold, used to evaluate the multiplicity reach (calc. in DrawComparison)
122     Float_t fLastChi2Residuals; // last Chi2 of the ESD and the folded unfolded ESD (calculated in DrawComparison)
123
124  private:
125     AliMultiplicityCorrection(const AliMultiplicityCorrection&);
126     AliMultiplicityCorrection& operator=(const AliMultiplicityCorrection&);
127
128   ClassDef(AliMultiplicityCorrection, 1);
129 };
130
131 #endif
132