3 #ifndef ALIMULTIPLICITYCORRECTION_H
4 #define ALIMULTIPLICITYCORRECTION_H
9 // class that contains the correction matrix and the functions for
10 // correction the multiplicity spectrum
11 // implements a several unfolding methods: e.g. chi2 minimization and bayesian unfolding
22 // defined here, because it does not seem possible to predeclare these (or i do not know how)
24 // $ROOTSYS/include/TVectorDfwd.h:21: conflicting types for `typedef struct TVectorT<Double_t> TVectorD'
25 // PWG0/dNdEta/AliMultiplicityCorrection.h:21: previous declaration as `struct TVectorD'
29 #include <AliPWG0Helper.h>
31 class AliMultiplicityCorrection : public TNamed {
33 enum EventType { kTrVtx = 0, kMB, kINEL, kNSD };
34 enum RegularizationType { kNone = 0, kPol0, kPol1, kLog, kEntropy, kCurvature };
35 enum MethodType { kChi2Minimization = 0, kBayesian = 1 };
36 enum { kESDHists = 4, kMCHists = 5, kCorrHists = 8, kQualityRegions = 3 };
38 AliMultiplicityCorrection();
39 AliMultiplicityCorrection(const Char_t* name, const Char_t* title);
40 virtual ~AliMultiplicityCorrection();
42 static AliMultiplicityCorrection* Open(const char* fileName, const char* folderName = "Multiplicity");
44 virtual Long64_t Merge(TCollection* list);
46 void FillMeasured(Float_t vtx, Int_t measured05, Int_t measured10, Int_t measured15, Int_t measured20);
47 void FillGenerated(Float_t vtx, Bool_t triggered, Bool_t vertex, AliPWG0Helper::MCProcessType processType, Int_t generated05, Int_t generated10, Int_t generated15, Int_t generated20, Int_t generatedAll);
49 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);
51 Bool_t LoadHistograms(const Char_t* dir = 0);
52 void SaveHistograms(const char* dir = 0);
53 void DrawHistograms();
54 void DrawComparison(const char* name, Int_t inputRange, Bool_t fullPhaseSpace, Bool_t normalizeESD, TH1* mcHist, Bool_t simple = kFALSE);
56 Int_t ApplyMinuitFit(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t check = kFALSE, TH1* initialConditions = 0);
58 static void SetRegularizationParameters(RegularizationType type, Float_t weight, Int_t minuitParams = -1);
59 static void SetBayesianParameters(Float_t smoothing, Int_t nIterations);
60 static void SetCreateBigBin(Bool_t flag) { fgCreateBigBin = flag; }
62 void ApplyNBDFit(Int_t inputRange, Bool_t fullPhaseSpace);
64 void ApplyBayesianMethod(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Float_t regPar = 1, Int_t nIterations = 100, TH1* initialConditions = 0, Bool_t determineError = kTRUE);
66 static TH1* CalculateStdDev(TH1** results, Int_t max);
67 TH1* StatisticalUncertainty(MethodType methodType, Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t randomizeMeasured, Bool_t randomizeResponse, TH1* compareTo = 0);
69 void ApplyGaussianMethod(Int_t inputRange, Bool_t fullPhaseSpace);
71 void ApplyLaszloMethod(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType);
73 TH2F* GetMultiplicityESD(Int_t i) { return fMultiplicityESD[i]; }
74 TH2F* GetMultiplicityVtx(Int_t i) { return fMultiplicityVtx[i]; }
75 TH2F* GetMultiplicityMB(Int_t i) { return fMultiplicityMB[i]; }
76 TH2F* GetMultiplicityINEL(Int_t i) { return fMultiplicityINEL[i]; }
77 TH2F* GetMultiplicityNSD(Int_t i) { return fMultiplicityNSD[i]; }
78 TH2F* GetMultiplicityMC(Int_t i, EventType eventType);
79 TH3F* GetCorrelation(Int_t i) { return fCorrelation[i]; }
80 TH1F* GetMultiplicityESDCorrected(Int_t i) { return fMultiplicityESDCorrected[i]; }
82 void SetMultiplicityESD(Int_t i, TH2F* hist) { fMultiplicityESD[i] = hist; }
83 void SetMultiplicityVtx(Int_t i, TH2F* hist) { fMultiplicityVtx[i] = hist; }
84 void SetMultiplicityMB(Int_t i, TH2F* hist) { fMultiplicityMB[i] = hist; }
85 void SetMultiplicityINEL(Int_t i, TH2F* hist) { fMultiplicityINEL[i] = hist; }
86 void SetMultiplicityNSD(Int_t i, TH2F* hist) { fMultiplicityNSD[i] = hist; }
87 void SetMultiplicityMC(Int_t i, EventType eventType, TH2F* hist);
88 void SetCorrelation(Int_t i, TH3F* hist) { fCorrelation[i] = hist; }
89 void SetMultiplicityESDCorrected(Int_t i, TH1F* hist) { fMultiplicityESDCorrected[i] = hist; }
91 void SetGenMeasFromFunc(TF1* inputMC, Int_t id);
92 TH2F* CalculateMultiplicityESD(TH1* inputMC, Int_t correlationMap);
94 void GetComparisonResults(Float_t* mc = 0, Int_t* mcLimit = 0, Float_t* residuals = 0, Float_t* ratioAverage = 0) const;
96 TH1* GetEfficiency(Int_t inputRange, EventType eventType);
97 TH1* GetTriggerEfficiency(Int_t inputRange);
99 static void SetQualityRegions(Bool_t SPDStudy);
100 Float_t GetQuality(Int_t region) const { return fQuality[region]; }
102 void FFT(Int_t dir, Int_t m, Double_t *x, Double_t *y);
105 static const Int_t fgkMaxParams; //! bins in unfolded histogram = number of fit params
106 static const Int_t fgkMaxInput; //! bins in measured histogram
108 static Double_t RegularizationPol0(TVectorD& params);
109 static Double_t RegularizationPol1(TVectorD& params);
110 static Double_t RegularizationTotalCurvature(TVectorD& params);
111 static Double_t RegularizationEntropy(TVectorD& params);
112 static Double_t RegularizationLog(TVectorD& params);
114 static void MinuitFitFunction(Int_t&, Double_t*, Double_t& chi2, Double_t *params, Int_t);
115 static void MinuitNBD(Int_t& unused1, Double_t* unused2, Double_t& chi2, Double_t *params, Int_t unused3);
117 static void DrawGuess(Double_t *params);
119 void SetupCurrentHists(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t createBigBin);
121 Float_t BayesCovarianceDerivate(Float_t matrixM[251][251], TH2* hResponse, Int_t k, Int_t i, Int_t r, Int_t u);
122 static Int_t UnfoldWithBayesian(TH1* correlation, TH1* aEfficiency, TH1* measured, TH1* initialConditions, TH1* aResult, Float_t regPar, Int_t nIterations);
123 static Int_t UnfoldWithMinuit(TH1* correlation, TH1* aEfficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check);
125 TH1* fCurrentESD; //! current input esd
126 TH1* fCurrentCorrelation; //! current correlation
127 TH1* fCurrentEfficiency; //! current efficiency
129 // static variable to be accessed by MINUIT
130 static TMatrixD* fgCorrelationMatrix; //! contains fCurrentCorrelation in matrix form
131 static TMatrixD* fgCorrelationCovarianceMatrix; //! contains the errors of fCurrentESD
132 static TVectorD* fgCurrentESDVector; //! contains fCurrentESD
133 static TVectorD* fgEntropyAPriori; //! a-priori distribution for entropy regularization
135 static TF1* fgNBD; //! negative binomial distribution
137 // configuration params follow
138 static RegularizationType fgRegularizationType; //! regularization that is used during Chi2 method
139 static Float_t fgRegularizationWeight; //! factor for regularization term
140 static Bool_t fgCreateBigBin; //! to fix fluctuations at high multiplicities, all entries above a certain limit are summarized in one bin
141 static Int_t fgNParamsMinuit; //! number of parameters minuit uses for unfolding (todo: to be merged w/ fgkMaxParams that has to be const. for the moment)
143 static Float_t fgBayesianSmoothing; //! smoothing parameter (0 = no smoothing)
144 static Int_t fgBayesianIterations; //! number of iterations in Bayesian method
145 // end of configuration
147 TH2F* fMultiplicityESD[kESDHists]; // multiplicity histogram: vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2 (0..3)
149 TH2F* fMultiplicityVtx[kMCHists]; // multiplicity histogram of events that have a reconstructed vertex : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
150 TH2F* fMultiplicityMB[kMCHists]; // multiplicity histogram of triggered events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
151 TH2F* fMultiplicityINEL[kMCHists]; // multiplicity histogram of all (inelastic) events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
152 TH2F* fMultiplicityNSD[kMCHists]; // multiplicity histogram of NSD events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
154 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
156 TH1F* fMultiplicityESDCorrected[kCorrHists]; // corrected histograms
158 Int_t fLastBinLimit; //! last bin limit, determined in SetupCurrentHists()
159 Float_t fLastChi2MC; //! last Chi2 between MC and unfolded ESD (calculated in DrawComparison)
160 Int_t fLastChi2MCLimit; //! bin where the last chi2 breached a certain threshold, used to evaluate the multiplicity reach (calc. in DrawComparison)
161 Float_t fLastChi2Residuals; //! last Chi2 of the ESD and the folded unfolded ESD (calculated in DrawComparison)
162 Float_t fRatioAverage; //! last average of |ratio-1| where ratio = unfolded / mc (bin 2..150)
164 static Int_t fgQualityRegionsB[kQualityRegions]; //! begin, given in multiplicity units
165 static Int_t fgQualityRegionsE[kQualityRegions]; //! end
166 Float_t fQuality[kQualityRegions]; //! stores the quality of the last comparison (calculated in DrawComparison). Contains 3 values that are averages of (MC - unfolded) / e(MC) in 3 regions, these are defined in fQualityRegionB,E
169 AliMultiplicityCorrection(const AliMultiplicityCorrection&);
170 AliMultiplicityCorrection& operator=(const AliMultiplicityCorrection&);
172 ClassDef(AliMultiplicityCorrection, 4);