]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FLOW/AliFlowCommon/AliFlowCommonHistResults.cxx
Centrality selection with SPDouter clusters
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowCommonHistResults.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15  
16  /*************************************
17  *   AliFlowCommonHistResults:       *
18  *   class to organize the common    *
19  *   histograms for Flow Analysis    * 
20  *                                   * 
21  * authors: Naomi van der Kolk       *
22  *           (kolk@nikhef.nl)        *  
23  *          Raimond Snellings        *
24  *           (snelling@nikhef.nl)    * 
25  *          Ante Bilandzic           *
26  *           (anteb@nikhef.nl)       * 
27  * **********************************/
28
29 #include "Riostream.h"                 //needed as include
30 #include "AliFlowCommonConstants.h"    //needed as include
31 #include "AliFlowCommonHistResults.h"
32
33 #include "TString.h" 
34 #include "TH1D.h"   //needed as include
35 #include "TMath.h"  //needed as include
36 #include "TList.h"
37 #include "TBrowser.h"
38
39 class TH1F;
40 class AliFlowVector;
41 class AliFlowCommonHist;
42
43 ClassImp(AliFlowCommonHistResults)
44
45 //-----------------------------------------------------------------------
46
47   AliFlowCommonHistResults::AliFlowCommonHistResults(): 
48     TNamed(),
49     fHistIntFlow(NULL),//to be removed
50     fHistDiffFlow(NULL),//to be removed
51     fHistChi(NULL),//to be removed
52     fHistIntFlowRP(NULL),
53     fHistChiRP(NULL),
54     fHistDiffFlowPtRP(NULL),
55     fHistDiffFlowEtaRP(NULL),
56     fHistIntFlowPOI(NULL),
57     fHistChiPOI(NULL),
58     fHistDiffFlowPtPOI(NULL),
59     fHistDiffFlowEtaPOI(NULL), 
60     fHistList(NULL)
61 {
62   //default constructor
63
64
65 //-----------------------------------------------------------------------
66
67   AliFlowCommonHistResults::AliFlowCommonHistResults(const char *anInput, const char *title): 
68     TNamed(anInput,title),
69     fHistIntFlow(NULL),//to be removed
70     fHistDiffFlow(NULL),//to be removed
71     fHistChi(NULL),//to be removed
72     fHistIntFlowRP(NULL),
73     fHistChiRP(NULL),
74     fHistDiffFlowPtRP(NULL),
75     fHistDiffFlowEtaRP(NULL),
76     fHistIntFlowPOI(NULL),
77     fHistChiPOI(NULL),
78     fHistDiffFlowPtPOI(NULL),
79     fHistDiffFlowEtaPOI(NULL),  
80     fHistList(NULL)
81 {
82   //constructor creating histograms 
83   //Pt:
84   Int_t iNbinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
85   Double_t dPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();         
86   Double_t dPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
87   //eta:
88   Int_t iNbinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta();
89   Double_t dEtaMin = AliFlowCommonConstants::GetMaster()->GetEtaMin();       
90   Double_t dEtaMax = AliFlowCommonConstants::GetMaster()->GetEtaMax();
91   
92   TString name;
93
94
95   //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
96   //                                 !!!     to be removed    !!!
97   //integrated flow
98   name = "Flow_Integrated_";
99   name += anInput;
100   fHistIntFlow = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
101   fHistIntFlow ->SetXTitle("");
102   fHistIntFlow ->SetYTitle("V_{2}");
103
104   //differential flow
105   name = "Flow_Differential_Pt_";
106   name += anInput;
107   fHistDiffFlow = new TH1D(name.Data(), name.Data(),iNbinsPt,dPtMin,dPtMax);
108   fHistDiffFlow ->SetXTitle("P_{t}");
109   fHistDiffFlow ->SetYTitle("v_{2}");
110   
111   //Chi (needed for rebinning later on)
112   name = "Flow_Chi_";
113   name += anInput;
114   fHistChi = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
115   fHistChi ->SetXTitle("");
116   fHistChi ->SetYTitle("#Chi");
117   //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
118   
119   //integrated flow
120   name = "Flow_Integrated_RP_";
121   name += anInput;
122   fHistIntFlowRP = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
123   fHistIntFlowRP->SetLabelSize(0.06);
124   fHistIntFlowRP->SetLabelOffset(0.01);
125   (fHistIntFlowRP->GetXaxis())->SetBinLabel(1,"V_{2}");
126   
127   //Chi (needed for rebinning later on)
128   name = "Flow_Chi_RP_";
129   name += anInput;
130   fHistChiRP = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
131   fHistChiRP->SetLabelSize(0.06);
132   fHistChiRP->SetLabelOffset(0.01);
133   (fHistChiRP->GetXaxis())->SetBinLabel(1,"#chi");
134   
135   //differential flow (Pt)
136   name = "Flow_Differential_Pt_RP_";
137   name += anInput;
138   fHistDiffFlowPtRP = new TH1D(name.Data(), name.Data(),iNbinsPt,dPtMin,dPtMax);
139   fHistDiffFlowPtRP->SetXTitle("P_{t}");
140   fHistDiffFlowPtRP->SetYTitle("v_{2}");
141   
142   //differential flow (eta)
143   name = "Flow_Differential_Eta_RP_";
144   name += anInput;
145   fHistDiffFlowEtaRP = new TH1D(name.Data(), name.Data(),iNbinsEta,dEtaMin,dEtaMax);
146   fHistDiffFlowEtaRP->SetXTitle("#eta");
147   fHistDiffFlowEtaRP->SetYTitle("v_{2}");
148   
149   //integrated flow
150   name = "Flow_Integrated_POI_";
151   name += anInput;
152   fHistIntFlowPOI = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
153   fHistIntFlowPOI->SetLabelSize(0.06);
154   fHistIntFlowPOI->SetLabelOffset(0.01);
155   (fHistIntFlowPOI->GetXaxis())->SetBinLabel(1,"V_{2}");
156   
157   //Chi (needed for rebinning later on)
158   name = "Flow_Chi_POI_";
159   name += anInput;
160   fHistChiPOI = new TH1D(name.Data(), name.Data(),1,0.5,1.5);
161   fHistChiPOI->SetLabelSize(0.06);
162   fHistChiPOI->SetLabelOffset(0.01);
163   (fHistChiPOI->GetXaxis())->SetBinLabel(1,"#chi");
164   
165   //differential flow (Pt)
166   name = "Flow_Differential_Pt_POI_";
167   name += anInput;
168   fHistDiffFlowPtPOI = new TH1D(name.Data(), name.Data(),iNbinsPt,dPtMin,dPtMax);
169   fHistDiffFlowPtPOI->SetXTitle("P_{t}");
170   fHistDiffFlowPtPOI->SetYTitle("v_{2}");
171   
172   //differential flow (eta)
173   name = "Flow_Differential_Eta_POI_";
174   name += anInput;
175   fHistDiffFlowEtaPOI = new TH1D(name.Data(), name.Data(),iNbinsEta,dEtaMin,dEtaMax);
176   fHistDiffFlowEtaPOI->SetXTitle("#eta");
177   fHistDiffFlowEtaPOI->SetYTitle("v_{2}");
178   
179   //list of histograms
180   fHistList = new TList();
181   
182   
183   fHistList-> Add(fHistIntFlow);//to be removed
184   fHistList-> Add(fHistDiffFlow);//to be removed
185   fHistList-> Add(fHistChi);//to be removed
186   
187   
188   fHistList->Add(fHistIntFlowRP);
189   fHistList->Add(fHistChiRP);
190   fHistList->Add(fHistDiffFlowPtRP);
191   fHistList->Add(fHistDiffFlowEtaRP);
192   fHistList->Add(fHistIntFlowPOI);
193   fHistList->Add(fHistChiPOI);
194   fHistList->Add(fHistDiffFlowPtPOI);
195   fHistList->Add(fHistDiffFlowEtaPOI);  
196   
197  }
198
199 //----------------------------------------------------------------------- 
200
201 AliFlowCommonHistResults::~AliFlowCommonHistResults()
202 {
203   //deletes histograms
204   delete fHistIntFlow;//to be removed
205   delete fHistDiffFlow;//to be removed
206   delete fHistChi;//to be removed
207   delete fHistIntFlowRP;
208   delete fHistChiRP;
209   delete fHistDiffFlowPtRP;
210   delete fHistDiffFlowEtaRP;
211   delete fHistIntFlowPOI;
212   delete fHistChiPOI;
213   delete fHistDiffFlowPtPOI;
214   delete fHistDiffFlowEtaPOI;
215   delete fHistList;
216 }
217
218 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
219 //                                 !!!     to be removed    !!!
220 //----------------------------------------------------------------------- 
221
222 Bool_t AliFlowCommonHistResults::FillIntegratedFlow(Double_t aV, Double_t anError)
223 {
224   //Fill fHistIntFlow
225   fHistIntFlow -> SetBinContent(1,aV);
226   fHistIntFlow -> SetBinError(1,anError);
227
228   return kTRUE; 
229 }
230
231 //----------------------------------------------------------------------- 
232
233 Bool_t AliFlowCommonHistResults::FillDifferentialFlow(Int_t aBin, Double_t av, Double_t anError)
234 {
235   //Fill fHistDiffFlow
236   fHistDiffFlow ->SetBinContent(aBin,av); 
237   fHistDiffFlow ->SetBinError(aBin,anError);
238
239   return kTRUE; 
240 }
241
242 //----------------------------------------------------------------------- 
243
244 Bool_t AliFlowCommonHistResults::FillChi(Double_t aChi)
245 {
246   //Fill fHistChi
247   fHistChi -> SetBinContent(1,aChi);
248   
249   return kTRUE; 
250 }
251 //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
252
253 //----------------------------------------------------------------------- 
254
255 Bool_t AliFlowCommonHistResults::FillIntegratedFlowRP(Double_t aV, Double_t anError)
256 {
257   //Fill fHistIntFlowRP
258   fHistIntFlowRP->SetBinContent(1,aV);
259   fHistIntFlowRP->SetBinError(1,anError);
260
261   return kTRUE; 
262 }
263
264 //----------------------------------------------------------------------- 
265
266 Bool_t AliFlowCommonHistResults::FillChiRP(Double_t aChi)
267 {
268   //Fill fHistChiRP
269   fHistChiRP->SetBinContent(1,aChi);
270   
271   return kTRUE; 
272 }
273
274 //----------------------------------------------------------------------- 
275
276 Bool_t AliFlowCommonHistResults::FillDifferentialFlowPtRP(Int_t aBin, Double_t av, Double_t anError)
277 {
278   //Fill fHistDiffFlowPtRP
279   fHistDiffFlowPtRP->SetBinContent(aBin,av);
280   fHistDiffFlowPtRP->SetBinError(aBin,anError);
281
282   return kTRUE; 
283 }
284
285 //----------------------------------------------------------------------- 
286
287 Bool_t AliFlowCommonHistResults::FillDifferentialFlowEtaRP(Int_t aBin, Double_t av, Double_t anError)
288 {
289   //Fill fHistDiffFlowEtaRP
290   fHistDiffFlowEtaRP->SetBinContent(aBin,av);
291   fHistDiffFlowEtaRP->SetBinError(aBin,anError);
292
293   return kTRUE; 
294 }
295
296 //----------------------------------------------------------------------- 
297
298 Bool_t AliFlowCommonHistResults::FillIntegratedFlowPOI(Double_t aV, Double_t anError)
299 {
300   //Fill fHistIntFlowPOI
301   fHistIntFlowPOI->SetBinContent(1,aV);
302   fHistIntFlowPOI->SetBinError(1,anError);
303
304   return kTRUE; 
305 }
306
307 //----------------------------------------------------------------------- 
308
309 Bool_t AliFlowCommonHistResults::FillChiPOI(Double_t aChi)
310 {
311   //Fill fHistChiPOI
312   fHistChiPOI->SetBinContent(1,aChi);
313   
314   return kTRUE; 
315 }
316
317 //----------------------------------------------------------------------- 
318
319 Bool_t AliFlowCommonHistResults::FillDifferentialFlowPtPOI(Int_t aBin, Double_t av, Double_t anError)
320 {
321   //Fill fHistDiffFlowPtPOI
322   fHistDiffFlowPtPOI->SetBinContent(aBin,av);
323   fHistDiffFlowPtPOI->SetBinError(aBin,anError);
324
325   return kTRUE; 
326 }
327
328 //----------------------------------------------------------------------- 
329
330 Bool_t AliFlowCommonHistResults::FillDifferentialFlowEtaPOI(Int_t aBin, Double_t av, Double_t anError)
331 {
332   //Fill fHistDiffFlowEtaPOI
333   fHistDiffFlowEtaPOI->SetBinContent(aBin,av);
334   fHistDiffFlowEtaPOI->SetBinError(aBin,anError);
335
336   return kTRUE; 
337 }
338
339 //----------------------------------------------------------------------- 
340
341  Double_t AliFlowCommonHistResults::Merge(TCollection *aList)
342 {
343   //merge fuction
344   //cout<<"entering merge function"<<endl;
345   if (!aList) return 0;
346   if (aList->IsEmpty()) return 0; //no merging is needed
347
348   Int_t iCount = 0;
349   TIter next(aList); // list is supposed to contain only objects of the same type as this
350   AliFlowCommonHistResults *toMerge;
351   // make a temporary list
352   TList *pTemp = new TList();
353   while ((toMerge=(AliFlowCommonHistResults*)next())) {
354     pTemp->Add(toMerge->GetHistList()); 
355     iCount++;
356   }
357   // Now call merge for fHistList providing temp list
358   fHistList->Merge(pTemp);
359   // Cleanup
360   delete pTemp;
361     
362   //cout<<"Merged"<<endl;
363   return (double)iCount;
364     
365 }
366
367 //----------------------------------------------------------------------- 
368 void AliFlowCommonHistResults::Print(Option_t *option) const
369 {
370   //   -*-*-*-*-*Print some global quantities for this histogram collection class *-*-*-*-*-*-*-*
371   //             ===============================================
372   //   printf( "TH1.Print Name  = %s, Entries= %d, Total sum= %g\n",GetName(),Int_t(fEntries),GetSumOfWeights());
373   printf( "Class.Print Name = %s, Histogram list:\n",GetName());
374
375   if (fHistList) {  
376     fHistList->Print(option);
377   }
378   else
379     {
380       printf( "Empty histogram list \n");
381     }
382 }
383
384 //----------------------------------------------------------------------- 
385  void AliFlowCommonHistResults::Browse(TBrowser *b)
386 {
387
388   if (!b) return;
389   if (fHistList) b->Add(fHistList,"AliFlowCommonHistResultsList");
390 }
391
392
393
394