4d4ae0f03be9dc45c21e8fa15f9d424fc5b7ed04
[u/mrichter/AliRoot.git] / PWGCF / EBYE / BalanceFunctions / AliBalancePsi.h
1 #ifndef ALIBALANCEPSI_H
2 #define ALIBALANCEPSI_H
3 /*  See cxx source for full Copyright notice */
4
5
6 /* $Id: AliBalancePsi.h 54125 2012-01-24 21:07:41Z miweber $ */
7
8 //-------------------------------------------------------------------------
9 //                          Class AliBalancePsi
10 //   This is the class for the Balance Function writ Psi analysis
11 //
12 //    Origin: Panos Christakoglou, Nikhef, Panos.Christakoglou@cern.ch
13 //-------------------------------------------------------------------------
14 // test
15 #include <vector>
16 #include <TObject.h>
17 #include "TString.h"
18 #include "TH2D.h"
19
20 #include "AliTHn.h"
21
22 using std::vector;
23
24 #define ANALYSIS_TYPES  7
25 #define MAXIMUM_NUMBER_OF_STEPS 1024
26 #define MAXIMUM_STEPS_IN_PSI 360
27
28 class TH1D;
29 class TH2D;
30 class TH3D;
31
32 const Int_t kTrackVariablesSingle = 3;       // track variables in histogram (event class, pTtrig, vertexZ)
33 const Int_t kTrackVariablesPair   = 6;       // track variables in histogram (event class, dEta, dPhi, pTtrig, ptAssociated, vertexZ)
34 const TString gBFPsiAnalysisType[ANALYSIS_TYPES] = {"y","eta","qlong","qout","qside","qinv","phi"};
35
36 class AliBalancePsi : public TObject {
37  public:
38   enum EAnalysisType {
39     kRapidity = 0, 
40     kEta      = 1, 
41     kQlong    = 2, 
42     kQout     = 3, 
43     kQside    = 4, 
44     kQinv     = 5, 
45     kPhi      = 6 
46   };
47
48   AliBalancePsi();
49   AliBalancePsi(const AliBalancePsi& balance);
50   ~AliBalancePsi();
51
52   void SetCentralityIdentifier(const char* centralityId) {
53     fCentralityId = centralityId;}
54   
55   void SetAnalysisLevel(const char* analysisLevel) {
56     fAnalysisLevel = analysisLevel;}
57   void SetShuffle(Bool_t shuffle) {fShuffle = shuffle;}
58   void SetCentralityInterval(Double_t cStart, Double_t cStop)  { fCentStart = cStart; fCentStop = cStop;};
59   void SetEventClass(TString receivedEventClass){ fEventClass = receivedEventClass; } 
60   void SetDeltaEtaMax(Double_t receivedDeltaEtaMax){ fDeltaEtaMax = receivedDeltaEtaMax; }
61   void SetVertexZBinning(Bool_t receivedVertexBinning=kTRUE){ fVertexBinning = receivedVertexBinning; }
62
63   void InitHistograms(void);
64
65   const char* GetAnalysisLevel() {return fAnalysisLevel.Data();}
66   Int_t GetNumberOfAnalyzedEvent() {return fAnalyzedEvents;}
67
68   void CalculateBalance(Double_t gReactionPlane, 
69                         TObjArray* particles,
70                         TObjArray* particlesMixed,
71                         Float_t bSign,
72                         Double_t kMultorCent = -100,
73                         Double_t vertexZ = 0);
74   
75   TH2D   *GetCorrelationFunction(TString type,
76                                  Double_t psiMin, Double_t psiMax,
77                                  Double_t vertexZMin=-1,
78                                  Double_t vertexZMax=-1,
79                                  Double_t ptTriggerMin=-1.,
80                                  Double_t ptTriggerMax=-1.,
81                                  Double_t ptAssociatedMin=-1.,
82                                  Double_t ptAssociatedMax=-1,
83                                  AliBalancePsi *bMixed=NULL);
84   TH2D   *GetCorrelationFunctionPN(Double_t psiMin, Double_t psiMax,
85                                    Double_t vertexZMin=-1,
86                                    Double_t vertexZMax=-1,
87                                    Double_t ptTriggerMin=-1.,
88                                    Double_t ptTriggerMax=-1.,
89                                    Double_t ptAssociatedMin=-1.,
90                                    Double_t ptAssociatedMax=-1);
91   TH2D   *GetCorrelationFunctionNP(Double_t psiMin, Double_t psiMax,
92                                    Double_t vertexZMin=-1,
93                                    Double_t vertexZMax=-1,
94                                    Double_t ptTriggerMin=-1.,
95                                    Double_t ptTriggerMax=-1.,
96                                    Double_t ptAssociatedMin=-1.,
97                                    Double_t ptAssociatedMax=-1);
98   TH2D   *GetCorrelationFunctionPP(Double_t psiMin, Double_t psiMax,
99                                    Double_t vertexZMin=-1,
100                                    Double_t vertexZMax=-1,
101                                    Double_t ptTriggerMin=-1.,
102                                    Double_t ptTriggerMax=-1.,
103                                    Double_t ptAssociatedMin=-1.,
104                                    Double_t ptAssociatedMax=-1);
105   TH2D   *GetCorrelationFunctionNN(Double_t psiMin, Double_t psiMax,
106                                    Double_t vertexZMin=-1,
107                                    Double_t vertexZMax=-1,
108                                    Double_t ptTriggerMin=-1.,
109                                    Double_t ptTriggerMax=-1.,
110                                    Double_t ptAssociatedMin=-1.,
111                                    Double_t ptAssociatedMax=-1);  
112   TH2D   *GetCorrelationFunctionChargeIndependent(Double_t psiMin, Double_t psiMax,
113                                                   Double_t vertexZMin=-1,
114                                                   Double_t vertexZMax=-1,
115                                                   Double_t ptTriggerMin=-1.,
116                                                   Double_t ptTriggerMax=-1.,
117                                                   Double_t ptAssociatedMin=-1.,
118                                                   Double_t ptAssociatedMax=-1);
119
120   AliTHn *GetHistNp() {return fHistP;}
121   AliTHn *GetHistNn() {return fHistN;}
122   AliTHn *GetHistNpn() {return fHistPN;}
123   AliTHn *GetHistNnp() {return fHistNP;}
124   AliTHn *GetHistNpp() {return fHistPP;}
125   AliTHn *GetHistNnn() {return fHistNN;}
126
127   void SetHistNp(AliTHn *gHist) {
128     fHistP = gHist; }//fHistP->FillParent(); fHistP->DeleteContainers();}
129   void SetHistNn(AliTHn *gHist) {
130     fHistN = gHist; }//fHistN->FillParent(); fHistN->DeleteContainers();}
131   void SetHistNpn(AliTHn *gHist) {
132     fHistPN = gHist; }//fHistPN->FillParent(); fHistPN->DeleteContainers();}
133   void SetHistNnp(AliTHn *gHist) {
134     fHistNP = gHist; }//fHistNP->FillParent(); fHistNP->DeleteContainers();}
135   void SetHistNpp(AliTHn *gHist) {
136     fHistPP = gHist; }//fHistPP->FillParent(); fHistPP->DeleteContainers();}
137   void SetHistNnn(AliTHn *gHist) {
138     fHistNN = gHist; }//fHistNN->FillParent(); fHistNN->DeleteContainers();}
139
140   TH1D *GetBalanceFunctionHistogram(Int_t iVariableSingle,
141                                     Int_t iVariablePair,
142                                     Double_t psiMin, Double_t psiMax,
143                                     Double_t vertexZMin=-1,
144                                     Double_t vertexZMax=-1,
145                                     Double_t ptTriggerMin=-1.,
146                                     Double_t ptTriggerMax=-1.,
147                                     Double_t ptAssociatedMin=-1.,
148                                     Double_t ptAssociatedMax=-1);   //
149
150   TH1D *GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
151                                             Int_t iVariablePair,
152                                             Double_t psiMin, Double_t psiMax,
153                                             Double_t vertexZMin=-1,
154                                             Double_t vertexZMax=-1,
155                                             Double_t ptTriggerMin=-1.,
156                                             Double_t ptTriggerMax=-1.,
157                                             Double_t ptAssociatedMin=-1.,
158                                             Double_t ptAssociatedMax=-1,
159                                             AliBalancePsi *bfMix=NULL);
160
161   TH2D *GetBalanceFunctionDeltaEtaDeltaPhi(Double_t psiMin, Double_t psiMax,
162                                            Double_t vertexZMin=-1,
163                                            Double_t vertexZMax=-1,
164                                            Double_t ptTriggerMin=-1.,
165                                            Double_t ptTriggerMax=-1.,
166                                            Double_t ptAssociatedMin=-1.,
167                                            Double_t ptAssociatedMax=-1);   
168   
169   TH2D *GetBalanceFunctionDeltaEtaDeltaPhi2pMethod(Double_t psiMin, Double_t psiMax,
170                                                    Double_t vertexZMin=-1,
171                                                    Double_t vertexZMax=-1,
172                                                    Double_t ptTriggerMin=-1.,
173                                                    Double_t ptTriggerMax=-1.,
174                                                    Double_t ptAssociatedMin=-1.,
175                                                    Double_t ptAssociatedMax=-1.,
176                                                    AliBalancePsi *bfMix=NULL);
177
178   TH1D *GetBalanceFunction1DFrom2D2pMethod(Bool_t bPhi,
179                                            Double_t psiMin, Double_t psiMax,
180                                            Double_t vertexZMin=-1,
181                                            Double_t vertexZMax=-1,
182                                            Double_t ptTriggerMin=-1.,
183                                            Double_t ptTriggerMax=-1.,
184                                            Double_t ptAssociatedMin=-1.,
185                                            Double_t ptAssociatedMax=-1.,
186                                            AliBalancePsi *bfMix=NULL);
187
188   Bool_t GetMomentsAnalytical(Int_t fVariable, TH1D* gHist, Bool_t kUseZYAM,
189                               Double_t &mean, Double_t &meanError,
190                               Double_t &sigma, Double_t &sigmaError,
191                               Double_t &skewness, Double_t &skewnessError,
192                               Double_t &kurtosis, Double_t &kurtosisError);
193   
194   TH2D *GetQAHistHBTbefore() {return fHistHBTbefore;}
195   TH2D *GetQAHistHBTafter() {return fHistHBTafter;}
196   TH3D *GetQAHistConversionbefore() {return fHistConversionbefore;}
197   TH3D *GetQAHistConversionafter() {return fHistConversionafter;}
198   TH2D *GetQAHistPsiMinusPhi() {return fHistPsiMinusPhi;}
199   TH3D *GetQAHistResonancesBefore() {return fHistResonancesBefore;}
200   TH3D *GetQAHistResonancesRho() {return fHistResonancesRho;}
201   TH3D *GetQAHistResonancesK0() {return fHistResonancesK0;}
202   TH3D *GetQAHistResonancesLambda() {return fHistResonancesLambda;}
203   TH3D *GetQAHistQbefore() {return fHistQbefore;}
204   TH3D *GetQAHistQafter() {return fHistQafter;}
205
206   void UseResonancesCut() {fResonancesCut = kTRUE;}
207   void UseHBTCut(Double_t setHBTCutValue = 0.02) {
208     fHBTCut = kTRUE; fHBTCutValue = setHBTCutValue;}
209   void UseConversionCut(Double_t setInvMassCutConversion = 0.04) {
210     fConversionCut = kTRUE; fInvMassCutConversion = setInvMassCutConversion; }
211   void UseMomentumDifferenceCut(Double_t gDeltaPtCutMin) {
212     fQCut = kTRUE; fDeltaPtMin = gDeltaPtCutMin;}
213
214  private:
215   Float_t GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign); 
216
217   Bool_t fShuffle; //shuffled balance function object
218   TString fAnalysisLevel; //ESD, AOD or MC
219   Int_t fAnalyzedEvents; //number of events that have been analyzed
220
221   TString fCentralityId;//Centrality identifier to be used for the histo naming
222
223   Double_t fCentStart;
224   Double_t fCentStop;
225
226   AliTHn *fHistP; //N+
227   AliTHn *fHistN; //N-
228   AliTHn *fHistPN; //N+-
229   AliTHn *fHistNP; //N-+
230   AliTHn *fHistPP; //N++
231   AliTHn *fHistNN; //N--
232
233   //QA histograms
234   TH2D *fHistHBTbefore; // Delta Eta vs. Delta Phi before HBT inspired cuts
235   TH2D *fHistHBTafter; // Delta Eta vs. Delta Phi after HBT inspired cuts
236   TH3D *fHistConversionbefore; // 3D histogram (Deta,Dphi,Invmass) before Conversion cuts
237   TH3D *fHistConversionafter; // 3D histogram (Deta,Dphi,Invmass) before Conversion cuts
238   TH2D *fHistPsiMinusPhi;// psi - phi QA histogram
239   TH3D *fHistResonancesBefore; // 3D histogram (Deta,Dphi,Invmass) before resonance cuts
240   TH3D *fHistResonancesRho;    // 3D histogram (Deta,Dphi,Invmass) after removing rho 
241   TH3D *fHistResonancesK0;     // 3D histogram (Deta,Dphi,Invmass) after removing rho, K0 
242   TH3D *fHistResonancesLambda; // 3D histogram (Deta,Dphi,Invmass) after removing rho, K0, and Lambda
243   TH3D *fHistQbefore; // Delta Eta vs. Delta Phi before cut on momentum difference
244   TH3D *fHistQafter; // Delta Eta vs. Delta Phi after cut on momentum difference
245
246   Double_t fPsiInterval;// interval in Psi-phi1
247   Double_t fDeltaEtaMax;// maximum delta eta for output THnSparse
248
249   Bool_t fResonancesCut;//resonances cut
250   Bool_t fHBTCut;//cut for two-track efficiency (like HBT group)
251   Double_t fHBTCutValue;// value for two-track efficiency cut (default = 0.02 from dphicorrelations)
252   Bool_t fConversionCut;//conversion cut
253   Double_t fInvMassCutConversion;//invariant mass for conversion cut
254   Bool_t fQCut;//cut on momentum difference to suppress femtoscopic effect correlations
255   Double_t fDeltaPtMin;//delta pt cut: minimum value
256   Bool_t fVertexBinning;//use vertex z binning in AliTHn
257
258   TString fEventClass;
259
260   AliBalancePsi & operator=(const AliBalancePsi & ) {return *this;}
261
262   ClassDef(AliBalancePsi, 2)
263 };
264
265 #endif