dcd080a9e20d51ef6e1db488ebcc45d2447514c2
[u/mrichter/AliRoot.git] / PWGCF / EBYE / BalanceFunctions / AliBalanceEventMixing.h
1 #ifndef ALIBALANCEEVENTMIXING_H
2 #define ALIBALANCEEVENTMIXING_H
3 /*  See cxx source for full Copyright notice */
4
5
6 //-------------------------------------------------------------------------
7 //                          Class AliBalanceEventMixing
8 //   This is the class for the Balance Function analysis
9 //
10 //    Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
11 //    Modified: Michael Weber, m.weber@cern.ch
12 //-------------------------------------------------------------------------
13
14 #include <TObject.h>
15 #include "TString.h"
16
17 #define ANALYSIS_TYPES  7
18 #define MAXIMUM_NUMBER_OF_STEPS 1024
19
20 class TGraphErrors;
21 class TH1D;
22 class TH2D;
23
24 class AliBalanceEventMixing : public TObject {
25  public:
26   enum EAnalysisType {
27     kRapidity = 0, 
28     kEta      = 1, 
29     kQlong    = 2, 
30     kQout     = 3, 
31     kQside    = 4, 
32     kQinv     = 5, 
33     kPhi      = 6 
34   };
35
36   AliBalanceEventMixing();
37   AliBalanceEventMixing(const AliBalanceEventMixing& balance);
38   ~AliBalanceEventMixing();
39
40   void SetCentralityIdentifier(const char* centralityId) {
41     fCentralityId = centralityId;}
42   
43   void SetAnalysisLevel(const char* analysisLevel) {
44     fAnalysisLevel = analysisLevel;}
45   void SetShuffle(Bool_t shuffle) {bShuffle = shuffle;}
46   void SetInterval(Int_t iAnalysisType, Double_t p1Start, Double_t p1Stop,
47                    Int_t ibins, Double_t p2Start, Double_t p2Stop);
48   void SetCentralityInterval(Double_t cStart, Double_t cStop)  { fCentStart = cStart; fCentStop = cStop;};
49   void SetNp(Int_t analysisType, Double_t NpSet)   { fNp[analysisType] = NpSet; }
50   void SetNn(Int_t analysisType, Double_t NnSet)   { fNn[analysisType] = NnSet; }
51   void SetNpp(Int_t analysisType, Int_t ibin, Double_t NppSet) { if(ibin > -1 && ibin < MAXIMUM_NUMBER_OF_STEPS) fNpp[analysisType][ibin] = NppSet; }
52   void SetNpn(Int_t analysisType, Int_t ibin, Double_t NpnSet) { if(ibin > -1 && ibin < MAXIMUM_NUMBER_OF_STEPS) fNpn[analysisType][ibin] = NpnSet; }
53   void SetNnp(Int_t analysisType, Int_t ibin, Double_t NnpSet) { if(ibin > -1 && ibin < MAXIMUM_NUMBER_OF_STEPS) fNnp[analysisType][ibin] = NnpSet; }
54   void SetNnn(Int_t analysisType, Int_t ibin, Double_t NnnSet) { if(ibin > -1 && ibin < MAXIMUM_NUMBER_OF_STEPS) fNnn[analysisType][ibin] = NnnSet; }
55
56   void InitHistograms(void);
57
58   const char* GetAnalysisLevel() {return fAnalysisLevel.Data();}
59   Int_t GetNumberOfAnalyzedEvent() {return fAnalyzedEvents;}
60
61   Int_t GetNumberOfBins(Int_t ibin) {return fNumberOfBins[ibin];}
62   Double_t GetP1Start(Int_t ibin){return fP1Start[ibin];}
63   Double_t GetP1Stop(Int_t ibin){return fP1Stop[ibin];}   
64   Double_t GetP2Start(Int_t ibin){return fP2Start[ibin];}
65   Double_t GetP2Stop(Int_t ibin){return fP2Stop[ibin];}    
66  
67   Double_t GetNp(Int_t analysisType) const { return 1.0*fNp[analysisType]; }
68   Double_t GetNn(Int_t analysisType) const { return 1.0*fNn[analysisType]; }
69   Double_t GetNnn(Int_t analysisType, Int_t p2) const { 
70     return 1.0*fNnn[analysisType][p2]; }
71   Double_t GetNpp(Int_t analysisType, Int_t p2) const { 
72     return 1.0*fNpp[analysisType][p2]; }
73   Double_t GetNpn(Int_t analysisType, Int_t p2) const { 
74     return 1.0*fNpn[analysisType][p2]; }  
75   Double_t GetNnp(Int_t analysisType, Int_t p2) const { 
76     return 1.0*fNnp[analysisType][p2]; }
77
78   void CalculateBalance(Float_t fCentrality, vector<Double_t> **chargeVector,Int_t iMainTrack = -1);
79   
80   Double_t GetBalance(Int_t a, Int_t p2);
81   Double_t GetError(Int_t a, Int_t p2);
82
83   TH2D *GetHistNp(Int_t iAnalysisType) { return fHistP[iAnalysisType];}
84   TH2D *GetHistNn(Int_t iAnalysisType) { return fHistN[iAnalysisType];}
85   TH2D *GetHistNpn(Int_t iAnalysisType) { return fHistPN[iAnalysisType];}
86   TH2D *GetHistNnp(Int_t iAnalysisType) { return fHistNP[iAnalysisType];}
87   TH2D *GetHistNpp(Int_t iAnalysisType) { return fHistPP[iAnalysisType];}
88   TH2D *GetHistNnn(Int_t iAnalysisType) { return fHistNN[iAnalysisType];}
89
90   void PrintAnalysisSettings();
91   TGraphErrors *DrawBalance(Int_t fAnalysisType);
92
93   void SetHistNp(Int_t iAnalysisType, TH2D *gHist) { 
94     fHistP[iAnalysisType] = gHist;}
95   void SetHistNn(Int_t iAnalysisType, TH2D *gHist) { 
96     fHistN[iAnalysisType] = gHist;}
97   void SetHistNpn(Int_t iAnalysisType, TH2D *gHist) { 
98     fHistPN[iAnalysisType] = gHist;}
99   void SetHistNnp(Int_t iAnalysisType, TH2D *gHist) { 
100     fHistNP[iAnalysisType] = gHist;}
101   void SetHistNpp(Int_t iAnalysisType, TH2D *gHist) { 
102     fHistPP[iAnalysisType] = gHist;}
103   void SetHistNnn(Int_t iAnalysisType, TH2D *gHist) { 
104     fHistNN[iAnalysisType] = gHist;}
105
106   TH1D *GetBalanceFunctionHistogram(Int_t iAnalysisType,Double_t centrMin, Double_t centrMax, Double_t etaWindow = -1);
107   void PrintResults(Int_t iAnalysisType, TH1D *gHist);
108
109  private:
110   Bool_t bShuffle; //shuffled balance function object
111   TString fAnalysisLevel; //ESD, AOD or MC
112   Int_t fAnalyzedEvents; //number of events that have been analyzed
113
114   TString fCentralityId;//Centrality identifier to be used for the histo naming
115
116   Int_t fNumberOfBins[ANALYSIS_TYPES];//number of bins of the analyzed interval
117   Double_t fP1Start[ANALYSIS_TYPES];
118   Double_t fP1Stop[ANALYSIS_TYPES];
119   Double_t fP2Start[ANALYSIS_TYPES];
120   Double_t fP2Stop[ANALYSIS_TYPES];
121   Double_t fP2Step[ANALYSIS_TYPES]; 
122   Double_t fCentStart;
123   Double_t fCentStop;
124
125         
126   Double_t fNnn[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //N(--)
127   Double_t fNpp[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //N(++)
128   Double_t fNpn[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //N(+-)
129   Double_t fNnp[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //N(-+)
130   Double_t fNn[ANALYSIS_TYPES], fNp[ANALYSIS_TYPES]; //number of pos./neg. inside the analyzed interval
131   
132   Double_t fB[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //BF matrix
133   Double_t ferror[ANALYSIS_TYPES][MAXIMUM_NUMBER_OF_STEPS]; //error of the BF
134   
135   TH2D *fHistP[ANALYSIS_TYPES]; //N+
136   TH2D *fHistN[ANALYSIS_TYPES]; //N-
137   TH2D *fHistPN[ANALYSIS_TYPES]; //N+-
138   TH2D *fHistNP[ANALYSIS_TYPES]; //N-+
139   TH2D *fHistPP[ANALYSIS_TYPES]; //N++
140   TH2D *fHistNN[ANALYSIS_TYPES]; //N--
141
142   AliBalanceEventMixing & operator=(const AliBalanceEventMixing & ) {return *this;}
143
144   ClassDef(AliBalanceEventMixing, 1)
145 };
146
147 #endif