refactoring multiplicity analysis
[u/mrichter/AliRoot.git] / PWG0 / multiplicity / AliMultiplicityCorrection.h
CommitLineData
3602328d 1/* $Id$ */
2
0a173978 3#ifndef ALIMULTIPLICITYCORRECTION_H
4#define ALIMULTIPLICITYCORRECTION_H
5
3602328d 6#include "TNamed.h"
0a173978 7
8//
9// class that contains the correction matrix and the functions for
10// correction the multiplicity spectrum
6d81c2de 11// implements a several unfolding methods: e.g. chi2 minimization and bayesian unfolding
0a173978 12//
13
14class TH1;
15class TH2;
16class TH1F;
17class TH2F;
18class TH3F;
3602328d 19class TF1;
20class TCollection;
0a173978 21
6d81c2de 22// defined here, because it does not seem possible to predeclare these (or i do not know how)
23// -->
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'
26
447c325d 27#include <TMatrixD.h>
28#include <TVectorD.h>
69b09e3b 29#include <AliPWG0Helper.h>
19442b86 30#include <AliUnfolding.h>
cfc19dd5 31
0a173978 32class AliMultiplicityCorrection : public TNamed {
33 public:
69b09e3b 34 enum EventType { kTrVtx = 0, kMB, kINEL, kNSD };
0b4bfd98 35 enum { kESDHists = 4, kMCHists = 5, kCorrHists = 8, kQualityRegions = 3 };
cfc19dd5 36
0a173978 37 AliMultiplicityCorrection();
38 AliMultiplicityCorrection(const Char_t* name, const Char_t* title);
39 virtual ~AliMultiplicityCorrection();
69b09e3b 40
41 static AliMultiplicityCorrection* Open(const char* fileName, const char* folderName = "Multiplicity");
0a173978 42
43 virtual Long64_t Merge(TCollection* list);
44
45 void FillMeasured(Float_t vtx, Int_t measured05, Int_t measured10, Int_t measured15, Int_t measured20);
69b09e3b 46 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);
0a173978 47
48 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);
49
0b4bfd98 50 Bool_t LoadHistograms(const Char_t* dir = 0);
144ff489 51 void SaveHistograms(const char* dir = 0);
0a173978 52 void DrawHistograms();
447c325d 53 void DrawComparison(const char* name, Int_t inputRange, Bool_t fullPhaseSpace, Bool_t normalizeESD, TH1* mcHist, Bool_t simple = kFALSE);
0a173978 54
6d81c2de 55 Int_t ApplyMinuitFit(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t check = kFALSE, TH1* initialConditions = 0);
44466df2 56
6d81c2de 57 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);
58
0f67a57c 59 static TH1* CalculateStdDev(TH1** results, Int_t max);
19442b86 60 TH1* StatisticalUncertainty(AliUnfolding::MethodType methodType, Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType, Bool_t randomizeMeasured, Bool_t randomizeResponse, TH1* compareTo = 0);
0a173978 61
19442b86 62 Int_t ApplyNBDFit(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType);
9ca6be09 63 void ApplyGaussianMethod(Int_t inputRange, Bool_t fullPhaseSpace);
64
cfc19dd5 65 void ApplyLaszloMethod(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType);
66
0a173978 67 TH2F* GetMultiplicityESD(Int_t i) { return fMultiplicityESD[i]; }
cfc19dd5 68 TH2F* GetMultiplicityVtx(Int_t i) { return fMultiplicityVtx[i]; }
69 TH2F* GetMultiplicityMB(Int_t i) { return fMultiplicityMB[i]; }
70 TH2F* GetMultiplicityINEL(Int_t i) { return fMultiplicityINEL[i]; }
69b09e3b 71 TH2F* GetMultiplicityNSD(Int_t i) { return fMultiplicityNSD[i]; }
cfc19dd5 72 TH2F* GetMultiplicityMC(Int_t i, EventType eventType);
0a173978 73 TH3F* GetCorrelation(Int_t i) { return fCorrelation[i]; }
dd701109 74 TH1F* GetMultiplicityESDCorrected(Int_t i) { return fMultiplicityESDCorrected[i]; }
0a173978 75
0b4bfd98 76 void SetMultiplicityESD(Int_t i, TH2F* hist) { fMultiplicityESD[i] = hist; }
77 void SetMultiplicityVtx(Int_t i, TH2F* hist) { fMultiplicityVtx[i] = hist; }
78 void SetMultiplicityMB(Int_t i, TH2F* hist) { fMultiplicityMB[i] = hist; }
cfc19dd5 79 void SetMultiplicityINEL(Int_t i, TH2F* hist) { fMultiplicityINEL[i] = hist; }
69b09e3b 80 void SetMultiplicityNSD(Int_t i, TH2F* hist) { fMultiplicityNSD[i] = hist; }
81 void SetMultiplicityMC(Int_t i, EventType eventType, TH2F* hist);
9ca6be09 82 void SetCorrelation(Int_t i, TH3F* hist) { fCorrelation[i] = hist; }
dd701109 83 void SetMultiplicityESDCorrected(Int_t i, TH1F* hist) { fMultiplicityESDCorrected[i] = hist; }
9ca6be09 84
3602328d 85 void SetGenMeasFromFunc(TF1* inputMC, Int_t id);
447c325d 86 TH2F* CalculateMultiplicityESD(TH1* inputMC, Int_t correlationMap);
3602328d 87
6d81c2de 88 void GetComparisonResults(Float_t* mc = 0, Int_t* mcLimit = 0, Float_t* residuals = 0, Float_t* ratioAverage = 0) const;
cfc19dd5 89
0b4bfd98 90 TH1* GetEfficiency(Int_t inputRange, EventType eventType);
69b09e3b 91 TH1* GetTriggerEfficiency(Int_t inputRange);
0b4bfd98 92
93 static void SetQualityRegions(Bool_t SPDStudy);
6d81c2de 94 Float_t GetQuality(Int_t region) const { return fQuality[region]; }
0b4bfd98 95
96 void FFT(Int_t dir, Int_t m, Double_t *x, Double_t *y);
0a173978 97
0b4bfd98 98 protected:
19442b86 99 void SetupCurrentHists(Int_t inputRange, Bool_t fullPhaseSpace, EventType eventType);
cfc19dd5 100
0b4bfd98 101 Float_t BayesCovarianceDerivate(Float_t matrixM[251][251], TH2* hResponse, Int_t k, Int_t i, Int_t r, Int_t u);
19442b86 102
7307d52c 103 TH1* fCurrentESD; //! current input esd
19442b86 104 TH2* fCurrentCorrelation; //! current correlation
7307d52c 105 TH1* fCurrentEfficiency; //! current efficiency
9ca6be09 106
69b09e3b 107 TH2F* fMultiplicityESD[kESDHists]; // multiplicity histogram: vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2 (0..3)
6d81c2de 108
69b09e3b 109 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)
110 TH2F* fMultiplicityMB[kMCHists]; // multiplicity histogram of triggered events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
111 TH2F* fMultiplicityINEL[kMCHists]; // multiplicity histogram of all (inelastic) events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
112 TH2F* fMultiplicityNSD[kMCHists]; // multiplicity histogram of NSD events : vtx vs multiplicity; array: |eta| < 0.5, 1.0, 1.5, 2, inf (0..4)
0a173978 113
cfc19dd5 114 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
6d81c2de 115
0a173978 116 TH1F* fMultiplicityESDCorrected[kCorrHists]; // corrected histograms
117
0f67a57c 118 Int_t fLastBinLimit; //! last bin limit, determined in SetupCurrentHists()
6d81c2de 119 Float_t fLastChi2MC; //! last Chi2 between MC and unfolded ESD (calculated in DrawComparison)
120 Int_t fLastChi2MCLimit; //! bin where the last chi2 breached a certain threshold, used to evaluate the multiplicity reach (calc. in DrawComparison)
121 Float_t fLastChi2Residuals; //! last Chi2 of the ESD and the folded unfolded ESD (calculated in DrawComparison)
122 Float_t fRatioAverage; //! last average of |ratio-1| where ratio = unfolded / mc (bin 2..150)
0b4bfd98 123
6d81c2de 124 static Int_t fgQualityRegionsB[kQualityRegions]; //! begin, given in multiplicity units
125 static Int_t fgQualityRegionsE[kQualityRegions]; //! end
126 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
cfc19dd5 127
0a173978 128 private:
129 AliMultiplicityCorrection(const AliMultiplicityCorrection&);
130 AliMultiplicityCorrection& operator=(const AliMultiplicityCorrection&);
131
69b09e3b 132 ClassDef(AliMultiplicityCorrection, 4);
0a173978 133};
134
135#endif
0f81f352 136