Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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   void SetCustomBinning(TString receivedCustomBinning) { fCustomBinning = receivedCustomBinning; }
63
64   void InitHistograms(void);
65
66   const char* GetAnalysisLevel() {return fAnalysisLevel.Data();}
67   Int_t GetNumberOfAnalyzedEvent() {return fAnalyzedEvents;}
68
69   void CalculateBalance(Double_t gReactionPlane, 
70                         TObjArray* particles,
71                         TObjArray* particlesMixed,
72                         Float_t bSign,
73                         Double_t kMultorCent = -100,
74                         Double_t vertexZ = 0);
75   
76   TH2D   *GetCorrelationFunction(TString type,
77                                  Double_t psiMin, Double_t psiMax,
78                                  Double_t vertexZMin=-1,
79                                  Double_t vertexZMax=-1,
80                                  Double_t ptTriggerMin=-1.,
81                                  Double_t ptTriggerMax=-1.,
82                                  Double_t ptAssociatedMin=-1.,
83                                  Double_t ptAssociatedMax=-1,
84                                  AliBalancePsi *bMixed=NULL);
85   TH2D   *GetCorrelationFunctionPN(Double_t psiMin, Double_t psiMax,
86                                    Double_t vertexZMin=-1,
87                                    Double_t vertexZMax=-1,
88                                    Double_t ptTriggerMin=-1.,
89                                    Double_t ptTriggerMax=-1.,
90                                    Double_t ptAssociatedMin=-1.,
91                                    Double_t ptAssociatedMax=-1);
92   TH2D   *GetCorrelationFunctionNP(Double_t psiMin, Double_t psiMax,
93                                    Double_t vertexZMin=-1,
94                                    Double_t vertexZMax=-1,
95                                    Double_t ptTriggerMin=-1.,
96                                    Double_t ptTriggerMax=-1.,
97                                    Double_t ptAssociatedMin=-1.,
98                                    Double_t ptAssociatedMax=-1);
99   TH2D   *GetCorrelationFunctionPP(Double_t psiMin, Double_t psiMax,
100                                    Double_t vertexZMin=-1,
101                                    Double_t vertexZMax=-1,
102                                    Double_t ptTriggerMin=-1.,
103                                    Double_t ptTriggerMax=-1.,
104                                    Double_t ptAssociatedMin=-1.,
105                                    Double_t ptAssociatedMax=-1);
106   TH2D   *GetCorrelationFunctionNN(Double_t psiMin, Double_t psiMax,
107                                    Double_t vertexZMin=-1,
108                                    Double_t vertexZMax=-1,
109                                    Double_t ptTriggerMin=-1.,
110                                    Double_t ptTriggerMax=-1.,
111                                    Double_t ptAssociatedMin=-1.,
112                                    Double_t ptAssociatedMax=-1);  
113   TH2D   *GetCorrelationFunctionChargeIndependent(Double_t psiMin, Double_t psiMax,
114                                                   Double_t vertexZMin=-1,
115                                                   Double_t vertexZMax=-1,
116                                                   Double_t ptTriggerMin=-1.,
117                                                   Double_t ptTriggerMax=-1.,
118                                                   Double_t ptAssociatedMin=-1.,
119                                                   Double_t ptAssociatedMax=-1);
120
121   AliTHn *GetHistNp() {return fHistP;}
122   AliTHn *GetHistNn() {return fHistN;}
123   AliTHn *GetHistNpn() {return fHistPN;}
124   AliTHn *GetHistNnp() {return fHistNP;}
125   AliTHn *GetHistNpp() {return fHistPP;}
126   AliTHn *GetHistNnn() {return fHistNN;}
127
128   void SetHistNp(AliTHn *gHist) {
129     fHistP = gHist; }//fHistP->FillParent(); fHistP->DeleteContainers();}
130   void SetHistNn(AliTHn *gHist) {
131     fHistN = gHist; }//fHistN->FillParent(); fHistN->DeleteContainers();}
132   void SetHistNpn(AliTHn *gHist) {
133     fHistPN = gHist; }//fHistPN->FillParent(); fHistPN->DeleteContainers();}
134   void SetHistNnp(AliTHn *gHist) {
135     fHistNP = gHist; }//fHistNP->FillParent(); fHistNP->DeleteContainers();}
136   void SetHistNpp(AliTHn *gHist) {
137     fHistPP = gHist; }//fHistPP->FillParent(); fHistPP->DeleteContainers();}
138   void SetHistNnn(AliTHn *gHist) {
139     fHistNN = gHist; }//fHistNN->FillParent(); fHistNN->DeleteContainers();}
140
141   TH1D *GetBalanceFunctionHistogram(Int_t iVariableSingle,
142                                     Int_t iVariablePair,
143                                     Double_t psiMin, Double_t psiMax,
144                                     Double_t vertexZMin=-1,
145                                     Double_t vertexZMax=-1,
146                                     Double_t ptTriggerMin=-1.,
147                                     Double_t ptTriggerMax=-1.,
148                                     Double_t ptAssociatedMin=-1.,
149                                     Double_t ptAssociatedMax=-1);   //
150
151   TH1D *GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
152                                             Int_t iVariablePair,
153                                             Double_t psiMin, Double_t psiMax,
154                                             Double_t vertexZMin=-1,
155                                             Double_t vertexZMax=-1,
156                                             Double_t ptTriggerMin=-1.,
157                                             Double_t ptTriggerMax=-1.,
158                                             Double_t ptAssociatedMin=-1.,
159                                             Double_t ptAssociatedMax=-1,
160                                             AliBalancePsi *bfMix=NULL);
161
162   TH2D *GetBalanceFunctionDeltaEtaDeltaPhi(Double_t psiMin, Double_t psiMax,
163                                            Double_t vertexZMin=-1,
164                                            Double_t vertexZMax=-1,
165                                            Double_t ptTriggerMin=-1.,
166                                            Double_t ptTriggerMax=-1.,
167                                            Double_t ptAssociatedMin=-1.,
168                                            Double_t ptAssociatedMax=-1);   
169   
170   TH2D *GetBalanceFunctionDeltaEtaDeltaPhi2pMethod(Double_t psiMin, Double_t psiMax,
171                                                    Double_t vertexZMin=-1,
172                                                    Double_t vertexZMax=-1,
173                                                    Double_t ptTriggerMin=-1.,
174                                                    Double_t ptTriggerMax=-1.,
175                                                    Double_t ptAssociatedMin=-1.,
176                                                    Double_t ptAssociatedMax=-1.,
177                                                    AliBalancePsi *bfMix=NULL);
178
179   TH1D *GetBalanceFunction1DFrom2D2pMethod(Bool_t bPhi,
180                                            Double_t psiMin, Double_t psiMax,
181                                            Double_t vertexZMin=-1,
182                                            Double_t vertexZMax=-1,
183                                            Double_t ptTriggerMin=-1.,
184                                            Double_t ptTriggerMax=-1.,
185                                            Double_t ptAssociatedMin=-1.,
186                                            Double_t ptAssociatedMax=-1.,
187                                            AliBalancePsi *bfMix=NULL);
188
189   Bool_t GetMomentsAnalytical(Int_t fVariable, TH1D* gHist, Bool_t kUseZYAM,
190                               Double_t &mean, Double_t &meanError,
191                               Double_t &sigma, Double_t &sigmaError,
192                               Double_t &skewness, Double_t &skewnessError,
193                               Double_t &kurtosis, Double_t &kurtosisError);
194   
195   TH2D *GetQAHistHBTbefore() {return fHistHBTbefore;}
196   TH2D *GetQAHistHBTafter() {return fHistHBTafter;}
197   TH3D *GetQAHistConversionbefore() {return fHistConversionbefore;}
198   TH3D *GetQAHistConversionafter() {return fHistConversionafter;}
199   TH2D *GetQAHistPsiMinusPhi() {return fHistPsiMinusPhi;}
200   TH3D *GetQAHistResonancesBefore() {return fHistResonancesBefore;}
201   TH3D *GetQAHistResonancesRho() {return fHistResonancesRho;}
202   TH3D *GetQAHistResonancesK0() {return fHistResonancesK0;}
203   TH3D *GetQAHistResonancesLambda() {return fHistResonancesLambda;}
204   TH3D *GetQAHistQbefore() {return fHistQbefore;}
205   TH3D *GetQAHistQafter() {return fHistQafter;}
206
207   void UseResonancesCut() {fResonancesCut = kTRUE;}
208   void UseHBTCut(Double_t setHBTCutValue = 0.02) {
209     fHBTCut = kTRUE; fHBTCutValue = setHBTCutValue;}
210   void UseConversionCut(Double_t setInvMassCutConversion = 0.04) {
211     fConversionCut = kTRUE; fInvMassCutConversion = setInvMassCutConversion; }
212   void UseMomentumDifferenceCut(Double_t gDeltaPtCutMin) {
213     fQCut = kTRUE; fDeltaPtMin = gDeltaPtCutMin;}
214
215   // related to customized binning of output AliTHn
216   Bool_t    IsUseVertexBinning() { return fVertexBinning; }
217   TString   GetBinningString()   { return fBinningString; }
218   Double_t* GetBinning(const char* configuration, const char* tag, Int_t& nBins);
219
220  private:
221   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); 
222
223   Bool_t fShuffle; //shuffled balance function object
224   TString fAnalysisLevel; //ESD, AOD or MC
225   Int_t fAnalyzedEvents; //number of events that have been analyzed
226
227   TString fCentralityId;//Centrality identifier to be used for the histo naming
228
229   Double_t fCentStart;
230   Double_t fCentStop;
231
232   AliTHn *fHistP; //N+
233   AliTHn *fHistN; //N-
234   AliTHn *fHistPN; //N+-
235   AliTHn *fHistNP; //N-+
236   AliTHn *fHistPP; //N++
237   AliTHn *fHistNN; //N--
238
239   //QA histograms
240   TH2D *fHistHBTbefore; // Delta Eta vs. Delta Phi before HBT inspired cuts
241   TH2D *fHistHBTafter; // Delta Eta vs. Delta Phi after HBT inspired cuts
242   TH3D *fHistConversionbefore; // 3D histogram (Deta,Dphi,Invmass) before Conversion cuts
243   TH3D *fHistConversionafter; // 3D histogram (Deta,Dphi,Invmass) before Conversion cuts
244   TH2D *fHistPsiMinusPhi;// psi - phi QA histogram
245   TH3D *fHistResonancesBefore; // 3D histogram (Deta,Dphi,Invmass) before resonance cuts
246   TH3D *fHistResonancesRho;    // 3D histogram (Deta,Dphi,Invmass) after removing rho 
247   TH3D *fHistResonancesK0;     // 3D histogram (Deta,Dphi,Invmass) after removing rho, K0 
248   TH3D *fHistResonancesLambda; // 3D histogram (Deta,Dphi,Invmass) after removing rho, K0, and Lambda
249   TH3D *fHistQbefore; // Delta Eta vs. Delta Phi before cut on momentum difference
250   TH3D *fHistQafter; // Delta Eta vs. Delta Phi after cut on momentum difference
251
252   Double_t fPsiInterval;// interval in Psi-phi1
253   Double_t fDeltaEtaMax;// maximum delta eta for output THnSparse
254
255   Bool_t fResonancesCut;//resonances cut
256   Bool_t fHBTCut;//cut for two-track efficiency (like HBT group)
257   Double_t fHBTCutValue;// value for two-track efficiency cut (default = 0.02 from dphicorrelations)
258   Bool_t fConversionCut;//conversion cut
259   Double_t fInvMassCutConversion;//invariant mass for conversion cut
260   Bool_t fQCut;//cut on momentum difference to suppress femtoscopic effect correlations
261   Double_t fDeltaPtMin;//delta pt cut: minimum value
262   Bool_t fVertexBinning;//use vertex z binning in AliTHn
263   TString fCustomBinning;//for setting customized binning
264   TString fBinningString;//final binning string
265
266   TString fEventClass;
267
268   AliBalancePsi & operator=(const AliBalancePsi & ) {return *this;}
269
270   ClassDef(AliBalancePsi, 2)
271 };
272
273 #endif