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