]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/Base/AliUEHistograms.cxx
double counting with own unique IDs
[u/mrichter/AliRoot.git] / PWGCF / Correlations / Base / AliUEHistograms.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 /* $Id: AliUEHistograms.cxx 20164 2007-08-14 15:31:50Z morsch $ */
17
18 //
19 //
20 // encapsulates several AliUEHist objects for a full UE analysis plus additional control histograms
21 //
22 //
23 // Author: Jan Fiete Grosse-Oetringhaus, Sara Vallero
24
25 #include "AliUEHistograms.h"
26
27 #include "AliCFContainer.h"
28 #include "AliVParticle.h"
29 #include "AliAODTrack.h"
30
31 #include "TList.h"
32 #include "TCanvas.h"
33 #include "TH2F.h"
34 #include "TH1F.h"
35 #include "TH3F.h"
36 #include "TMath.h"
37 #include "TLorentzVector.h"
38
39 ClassImp(AliUEHistograms)
40
41 const Int_t AliUEHistograms::fgkUEHists = 3;
42
43 AliUEHistograms::AliUEHistograms(const char* name, const char* histograms, const char* binning) : 
44   TNamed(name, name),
45   fNumberDensitypT(0),
46   fSumpT(0),
47   fNumberDensityPhi(0),
48   fCorrelationpT(0),
49   fCorrelationEta(0),
50   fCorrelationPhi(0),
51   fCorrelationR(0),
52   fCorrelationLeading2Phi(0),
53   fCorrelationMultiplicity(0),
54   fYields(0),
55   fEventCount(0),
56   fEventCountDifferential(0),
57   fVertexContributors(0),
58   fCentralityDistribution(0),
59   fCentralityCorrelation(0),
60   fITSClusterMap(0),
61   fControlConvResoncances(0),
62   fEfficiencyCorrectionTriggers(0),
63   fEfficiencyCorrectionAssociated(0),
64   fSelectCharge(0),
65   fTriggerSelectCharge(0),
66   fAssociatedSelectCharge(0),
67   fTriggerRestrictEta(-1),
68   fEtaOrdering(kFALSE),
69   fCutConversions(kFALSE),
70   fCutResonances(kFALSE),
71   fOnlyOneEtaSide(0),
72   fWeightPerEvent(kFALSE),
73   fPtOrder(kTRUE),
74   fRunNumber(0),
75   fMergeCount(1)
76 {
77   // Constructor
78   //
79   // the string histograms defines which histograms are created:
80   //    1 = NumberDensitypT
81   //    2 = SumpT
82   //    3 = NumberDensityPhi
83   //    4 = NumberDensityPhiCentrality (other multiplicity for Pb)
84   
85   AliLog::SetClassDebugLevel("AliCFContainer", -1);
86   AliLog::SetClassDebugLevel("AliCFGridSparse", -3);
87
88   fTwoTrackDistancePt[0] = 0;
89   fTwoTrackDistancePt[1] = 0;
90   
91   TString histogramsStr(histograms);
92   
93   TString defaultBinningStr;
94   defaultBinningStr = "eta: -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0\n"
95     "p_t_assoc: 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 8.0\n"
96     "p_t_leading: 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 14.5, 15.0, 15.5, 16.0, 16.5, 17.0, 17.5, 18.0, 18.5, 19.0, 19.5, 20.0, 20.5, 21.0, 21.5, 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, 27.0, 27.5, 28.0, 28.5, 29.0, 29.5, 30.0, 30.5, 31.0, 31.5, 32.0, 32.5, 33.0, 33.5, 34.0, 34.5, 35.0, 35.5, 36.0, 36.5, 37.0, 37.5, 38.0, 38.5, 39.0, 39.5, 40.0, 40.5, 41.0, 41.5, 42.0, 42.5, 43.0, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0, 47.5, 48.0, 48.5, 49.0, 49.5, 50.0\n"
97     "p_t_leading_course: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0\n"
98     "p_t_eff: 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0\n"
99     "vertex_eff: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n"
100   ;
101
102   if (histogramsStr.Contains("4") || histogramsStr.Contains("5") || histogramsStr.Contains("6")) // Dphi Corr
103   {
104     if (histogramsStr.Contains("C"))
105       defaultBinningStr += "multiplicity: 0, 20, 40, 60, 80, 100.1\n"; // course
106     else
107       defaultBinningStr += "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n";
108
109     if (histogramsStr.Contains("5"))
110       defaultBinningStr += "vertex: -7, -5, -3, -1, 1, 3, 5, 7\n";
111     else
112       defaultBinningStr += "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n";
113     
114     if (histogramsStr.Contains("R"))
115       defaultBinningStr += "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, 0.0, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n" // this binning starts at -pi/2 and is modulo 3 
116         "delta_eta: -2.4, -2.3, -2.2, -2.1, -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0,2.1, 2.2, 2.3, 2.4\n"
117       ;
118     else // for TTR studies
119       defaultBinningStr += "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, -0.043633, -0.021817, 0.0, 0.021817, 0.043633, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n"
120         "delta_eta: -2.0, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, -0.05, -0.025, 0, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0\n"
121       ;
122   }
123   else // UE
124     defaultBinningStr += "multiplicity: -0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 200.0\n"
125       "delta_phi: -1.570796, -1.483530, -1.396263, -1.308997, -1.221730, -1.134464, -1.047198, -0.959931, -0.872665, -0.785398, -0.698132, -0.610865, -0.523599, -0.436332, -0.349066, -0.261799, -0.174533, -0.087266, 0.0, 0.087266, 0.174533, 0.261799, 0.349066, 0.436332, 0.523599, 0.610865, 0.698132, 0.785398, 0.872665, 0.959931, 1.047198, 1.134464, 1.221730, 1.308997, 1.396263, 1.483530, 1.570796, 1.658063, 1.745329, 1.832596, 1.919862, 2.007129, 2.094395, 2.181662, 2.268928, 2.356194, 2.443461, 2.530727, 2.617994, 2.705260, 2.792527, 2.879793, 2.967060, 3.054326, 3.141593, 3.228859, 3.316126, 3.403392, 3.490659, 3.577925, 3.665191, 3.752458, 3.839724, 3.926991, 4.014257, 4.101524, 4.188790, 4.276057, 4.363323, 4.450590, 4.537856, 4.625123, 4.712389\n"
126       "vertex: -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10\n"
127     ;
128
129   // combine customBinning with defaultBinningStr -> use customBinning where available and otherwise defaultBinningStr
130   TString customBinning(binning);
131   TString binningStr;
132
133   TObjArray* lines = defaultBinningStr.Tokenize("\n");
134   for (Int_t i=0; i<lines->GetEntriesFast(); i++)
135   {
136     TString line(lines->At(i)->GetName());
137     TString tag = line(0, line.Index(":")+1);
138     if (!customBinning.BeginsWith(tag) && !customBinning.Contains(TString("\n") + tag))
139       binningStr += line + "\n";
140     else
141       Printf("Using custom binning for %s", tag.Data());
142   }
143   delete lines;
144   binningStr += customBinning;
145
146   if (histogramsStr.Contains("1"))
147     fNumberDensitypT = new AliUEHist("NumberDensitypT", binningStr);
148   if (histogramsStr.Contains("2"))
149     fSumpT = new AliUEHist("SumpT", binningStr);
150   
151   if (histogramsStr.Contains("3"))
152     fNumberDensityPhi = new AliUEHist("NumberDensityPhi", binningStr);
153   else if (histogramsStr.Contains("4"))
154     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentrality", binningStr);
155   else if (histogramsStr.Contains("5") || histogramsStr.Contains("6"))
156     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtx", binningStr);
157   
158   // do not add this hists to the directory
159   Bool_t oldStatus = TH1::AddDirectoryStatus();
160   TH1::AddDirectory(kFALSE);
161   
162   if (!histogramsStr.Contains("4") && !histogramsStr.Contains("5") && !histogramsStr.Contains("6"))
163   {
164     fCorrelationpT  = new TH2F("fCorrelationpT", ";p_{T,lead} (MC);p_{T,lead} (RECO)", 200, 0, 50, 200, 0, 50);
165     fCorrelationEta = new TH2F("fCorrelationEta", ";#eta_{lead} (MC);#eta_{T,lead} (RECO)", 200, -1, 1, 200, -1, 1);
166     fCorrelationPhi = new TH2F("fCorrelationPhi", ";#varphi_{lead} (MC);#varphi_{T,lead} (RECO)", 200, 0, TMath::TwoPi(), 200, 0, TMath::TwoPi());
167   }
168   else
169   {
170     fCorrelationpT  = new TH2F("fCorrelationpT", ";Centrality;p_{T} (RECO)", 100, 0, 100.001, 200, 0, 50);
171     fCorrelationEta = new TH2F("fCorrelationEta", ";Centrality;#eta (RECO)", 100, 0, 100.001, 200, -5, 5);
172     fCorrelationPhi = new TH2F("fCorrelationPhi", ";Centrality;#varphi (RECO)", 100, 0, 100.001, 200, 0, TMath::TwoPi());
173   }
174   
175   fCorrelationR =   new TH2F("fCorrelationR", ";R;p_{T,lead} (MC)", 200, 0, 2, 200, 0, 50);
176   fCorrelationLeading2Phi = new TH2F("fCorrelationLeading2Phi", ";#Delta #varphi;p_{T,lead} (MC)", 200, -TMath::Pi(), TMath::Pi(), 200, 0, 50);
177   fCorrelationMultiplicity = new TH2F("fCorrelationMultiplicity", ";MC tracks;Reco tracks", 100, -0.5, 99.5, 100, -0.5, 99.5);
178   fYields = new TH3F("fYields", ";centrality;pT;eta", 100, 0, 100, 40, 0, 20, 100, -1, 1);
179
180   if (!histogramsStr.Contains("4") && !histogramsStr.Contains("5") && !histogramsStr.Contains("6"))
181   {
182     fEventCount = new TH2F("fEventCount", ";step;event type;count", AliUEHist::fgkCFSteps+2, -2.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
183     fEventCount->GetYaxis()->SetBinLabel(1, "ND");
184     fEventCount->GetYaxis()->SetBinLabel(2, "SD");
185     fEventCount->GetYaxis()->SetBinLabel(3, "DD");
186   }
187   else
188   {
189     fEventCount = new TH2F("fEventCount", ";step;centrality;count", AliUEHist::fgkCFSteps+2, -2.5, -0.5 + AliUEHist::fgkCFSteps, fNumberDensityPhi->GetEventHist()->GetNBins(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray());
190   }
191   
192   fEventCountDifferential = new TH3F("fEventCountDifferential", ";p_{T,lead};step;event type", 100, 0, 50, AliUEHist::fgkCFSteps, -0.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
193   fEventCountDifferential->GetZaxis()->SetBinLabel(1, "ND");
194   fEventCountDifferential->GetZaxis()->SetBinLabel(2, "SD");
195   fEventCountDifferential->GetZaxis()->SetBinLabel(3, "DD");
196   
197   fVertexContributors = new TH1F("fVertexContributors", ";contributors;count", 100, -0.5, 99.5);
198   
199   if (fNumberDensityPhi)
200   {
201     fCentralityDistribution = new TH1F("fCentralityDistribution", ";centrality;count", fNumberDensityPhi->GetEventHist()->GetNBins(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray());
202     fCentralityCorrelation = new TH2F("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 200, 0, 4000);
203   }
204   
205   fITSClusterMap = new TH3F("fITSClusterMap", "; its cluster map; centrality; pT", 256, -0.5, 255.5, 20, 0, 100.001, 100, 0, 20);
206   
207   fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1);
208   
209   TH1::AddDirectory(oldStatus);
210 }
211
212 //_____________________________________________________________________________
213 AliUEHistograms::AliUEHistograms(const AliUEHistograms &c) :
214   TNamed(fName, fTitle),
215   fNumberDensitypT(0),
216   fSumpT(0),
217   fNumberDensityPhi(0),
218   fCorrelationpT(0),
219   fCorrelationEta(0),
220   fCorrelationPhi(0),
221   fCorrelationR(0),
222   fCorrelationLeading2Phi(0),
223   fCorrelationMultiplicity(0),
224   fYields(0),
225   fEventCount(0),
226   fEventCountDifferential(0),
227   fVertexContributors(0),
228   fCentralityDistribution(0),
229   fCentralityCorrelation(0),
230   fITSClusterMap(0),
231   fControlConvResoncances(0),
232   fEfficiencyCorrectionTriggers(0),
233   fEfficiencyCorrectionAssociated(0),
234   fSelectCharge(0),
235   fTriggerSelectCharge(0),
236   fAssociatedSelectCharge(0),
237   fTriggerRestrictEta(-1),
238   fEtaOrdering(kFALSE),
239   fCutConversions(kFALSE),
240   fCutResonances(kFALSE),
241   fOnlyOneEtaSide(0),
242   fWeightPerEvent(kFALSE),
243   fPtOrder(kTRUE),
244   fRunNumber(0),
245   fMergeCount(1)
246 {
247   //
248   // AliUEHistograms copy constructor
249   //
250
251   fTwoTrackDistancePt[0] = 0;
252   fTwoTrackDistancePt[1] = 0;
253
254   ((AliUEHistograms &) c).Copy(*this);
255 }
256
257 //____________________________________________________________________
258 AliUEHistograms::~AliUEHistograms()
259 {
260   // Destructor
261   
262   DeleteContainers();
263 }
264
265 void AliUEHistograms::DeleteContainers()
266 {
267   if (fNumberDensitypT)
268   {
269     delete fNumberDensitypT;
270     fNumberDensitypT = 0;
271   }
272   
273   if (fSumpT)
274   {
275     delete fSumpT;
276     fSumpT = 0;
277   }
278   
279   if (fNumberDensityPhi)
280   {
281     delete fNumberDensityPhi;
282     fNumberDensityPhi = 0;
283   }
284   
285   if (fCorrelationpT)
286   {
287     delete fCorrelationpT;
288     fCorrelationpT = 0;
289   }
290   
291   if (fCorrelationEta)
292   {
293     delete fCorrelationEta;
294     fCorrelationEta = 0;
295   }
296   
297   if (fCorrelationPhi)
298   {
299     delete fCorrelationPhi;
300     fCorrelationPhi = 0;
301   }
302   
303   if (fCorrelationR)
304   {
305     delete fCorrelationR;
306     fCorrelationR = 0;
307   }
308
309   if (fCorrelationLeading2Phi)
310   {
311     delete fCorrelationLeading2Phi;
312     fCorrelationLeading2Phi = 0;
313   }
314   
315   if (fCorrelationMultiplicity)
316   {
317     delete fCorrelationMultiplicity;
318     fCorrelationMultiplicity = 0;
319   }
320   
321   if (fYields)
322   {
323     delete fYields;
324     fYields = 0;
325   }
326   
327   if (fEventCount)
328   {
329     delete fEventCount;
330     fEventCount = 0;
331   }
332
333   if (fEventCountDifferential)
334   {
335     delete fEventCountDifferential;
336     fEventCountDifferential = 0;
337   }
338   
339   if (fVertexContributors)
340   {
341     delete fVertexContributors;
342     fVertexContributors = 0;
343   }
344   
345   if (fCentralityDistribution)
346   {
347     delete fCentralityDistribution;
348     fCentralityDistribution = 0;
349   }
350   
351   if (fCentralityCorrelation)
352   {
353     delete fCentralityCorrelation;
354     fCentralityCorrelation = 0;
355   }
356   
357   if (fITSClusterMap)
358   {
359     delete fITSClusterMap;
360     fITSClusterMap = 0;
361   }
362   
363   for (Int_t i=0; i<2; i++)
364     if (fTwoTrackDistancePt[i])
365     {
366       delete fTwoTrackDistancePt[i];
367       fTwoTrackDistancePt[i] = 0;
368     }
369     
370   if (fControlConvResoncances)
371   {
372     delete fControlConvResoncances;
373     fControlConvResoncances = 0;
374   }
375     
376   if (fEfficiencyCorrectionTriggers)
377   {
378     delete fEfficiencyCorrectionTriggers;
379     fEfficiencyCorrectionTriggers = 0;
380   }
381   
382   if (fEfficiencyCorrectionAssociated)
383   {
384     delete fEfficiencyCorrectionAssociated;
385     fEfficiencyCorrectionAssociated = 0;
386   }
387 }
388
389 AliUEHist* AliUEHistograms::GetUEHist(Int_t id)
390 {
391   // returns AliUEHist object, useful for loops
392   
393   switch (id)
394   {
395     case 0: return fNumberDensitypT; break;
396     case 1: return fSumpT; break;
397     case 2: return fNumberDensityPhi; break;
398   }
399   
400   return 0;
401 }
402
403 //____________________________________________________________________
404 Int_t AliUEHistograms::CountParticles(TList* list, Float_t ptMin)
405 {
406   // counts the number of particles in the list with a pT above ptMin
407   // TODO eta cut needed here?
408   
409   Int_t count = 0;
410   for (Int_t j=0; j<list->GetEntries(); j++)
411     if (((AliVParticle*) list->At(j))->Pt() > ptMin)
412       count++;
413       
414   return count;
415 }
416   
417 //____________________________________________________________________
418 void AliUEHistograms::Fill(Int_t eventType, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* toward, TList* away, TList* min, TList* max)
419 {
420   // fills the UE event histograms
421   //
422   // this function needs the leading (track or jet or ...) and four lists of AliVParticles which contain the particles/tracks to be filled in the four regions
423   
424   // if leading is not set, just fill event statistics
425   if (leading)
426   {
427     Int_t multiplicity = 0;
428     
429     // TODO configurable?
430     Float_t ptMin = 0.15;
431     if (leading->Pt() > ptMin)
432       multiplicity++;
433     
434     multiplicity += CountParticles(toward, ptMin);
435     multiplicity += CountParticles(away, ptMin);
436     multiplicity += CountParticles(min, ptMin);
437     multiplicity += CountParticles(max, ptMin);
438      
439     FillRegion(AliUEHist::kToward, zVtx, step, leading, toward, multiplicity);
440     FillRegion(AliUEHist::kAway,   zVtx, step, leading, away, multiplicity);
441     FillRegion(AliUEHist::kMin,    zVtx, step, leading, min, multiplicity);
442     FillRegion(AliUEHist::kMax,    zVtx, step, leading, max, multiplicity);
443  
444     Double_t vars[3];
445     vars[0] = leading->Pt();
446     vars[1] = multiplicity;
447     vars[2] = zVtx;
448     for (Int_t i=0; i<fgkUEHists; i++)
449       if (GetUEHist(i))
450         GetUEHist(i)->GetEventHist()->Fill(vars, step);
451   
452     fEventCountDifferential->Fill(leading->Pt(), step, eventType);
453   }
454   
455   FillEvent(eventType, step);
456 }
457   
458 //____________________________________________________________________
459 void AliUEHistograms::FillRegion(AliUEHist::Region region, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* list, Int_t multiplicity)
460 {
461   // loops over AliVParticles in list and fills the given region at the given step
462   //
463   // See also Fill(...)
464
465   for (Int_t i=0; i<list->GetEntries(); i++)
466   {
467     AliVParticle* particle = (AliVParticle*) list->At(i);
468     
469     Double_t vars[6];
470     vars[0] = particle->Eta();
471     vars[1] = particle->Pt();
472     vars[2] = leading->Pt();
473     vars[3] = multiplicity;
474     vars[4] = leading->Phi() - particle->Phi();
475     if (vars[4] > 1.5 * TMath::Pi()) 
476       vars[4] -= TMath::TwoPi();
477     if (vars[4] < -0.5 * TMath::Pi())
478       vars[4] += TMath::TwoPi();
479     vars[5] = zVtx;
480     
481     if (fNumberDensitypT)
482       fNumberDensitypT->GetTrackHist(region)->Fill(vars, step);
483       
484     if (fSumpT)
485       fSumpT->GetTrackHist(region)->Fill(vars, step, particle->Pt());
486     
487     // fill all in toward region (is anyway as function of delta phi!)
488     if (fNumberDensityPhi)
489       fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step);
490   }
491 }
492
493 //____________________________________________________________________
494 void AliUEHistograms::Fill(AliVParticle* leadingMC, AliVParticle* leadingReco)
495 {
496   // fills the correlation histograms
497   
498   if (leadingMC)
499   {
500     fCorrelationpT->Fill(leadingMC->Pt(), leadingReco->Pt());
501     if (leadingMC->Pt() > 0.5)
502     {
503       fCorrelationEta->Fill(leadingMC->Eta(), leadingReco->Eta());
504       fCorrelationPhi->Fill(leadingMC->Phi(), leadingReco->Phi());
505     }
506     
507     Float_t phiDiff = leadingMC->Phi() - leadingReco->Phi();
508     if (phiDiff > TMath::Pi())
509       phiDiff -= TMath::TwoPi();
510     if (phiDiff < -TMath::Pi())
511       phiDiff += TMath::TwoPi();
512       
513     Float_t etaDiff = leadingMC->Eta() - leadingReco->Eta();
514     
515     fCorrelationR->Fill(TMath::Sqrt(phiDiff * phiDiff + etaDiff * etaDiff), leadingMC->Pt());
516     fCorrelationLeading2Phi->Fill(phiDiff, leadingMC->Pt());
517   }
518   else
519   {
520     fCorrelationpT->Fill(1.0, leadingReco->Pt());
521     if (leadingReco->Pt() > 0.5)
522     {
523       fCorrelationEta->Fill(0.0, leadingReco->Eta());
524       fCorrelationPhi->Fill(0.0, leadingReco->Phi());
525     }
526   }
527 }
528
529 //____________________________________________________________________
530 void AliUEHistograms::FillCorrelations(Double_t centrality, Float_t zVtx, AliUEHist::CFStep step, TObjArray* particles, TObjArray* mixed, Float_t weight, Bool_t firstTime, Bool_t twoTrackEfficiencyCut, Float_t bSign, Float_t twoTrackEfficiencyCutValue, Bool_t applyEfficiency)
531 {
532   // fills the fNumberDensityPhi histogram
533   //
534   // this function need a list of AliVParticles which contain the particles/tracks to be filled
535   //
536   // if mixed is non-0, mixed events are filled, the trigger particle is from particles, the associated from mixed
537   // if weight < 0, then the pt of the associated particle is filled as weight
538   
539   Bool_t fillpT = kFALSE;
540   if (weight < 0)
541     fillpT = kTRUE;
542   
543   if (twoTrackEfficiencyCut && !fTwoTrackDistancePt[0])
544   {
545     // do not add this hists to the directory
546     Bool_t oldStatus = TH1::AddDirectoryStatus();
547     TH1::AddDirectory(kFALSE);
548
549     fTwoTrackDistancePt[0] = new TH3F("fTwoTrackDistancePt[0]", ";#Delta#eta;#Delta#varphi^{*}_{min};#Delta p_{T}", 100, -0.15, 0.15, 100, -0.05, 0.05, 20, 0, 10);
550     fTwoTrackDistancePt[1] = (TH3F*) fTwoTrackDistancePt[0]->Clone("fTwoTrackDistancePt[1]");
551
552     TH1::AddDirectory(oldStatus);
553   }
554
555   // Eta() is extremely time consuming, therefore cache it for the inner loop here:
556   TObjArray* input = (mixed) ? mixed : particles;
557   TArrayF eta(input->GetEntriesFast());
558   for (Int_t i=0; i<input->GetEntriesFast(); i++)
559     eta[i] = ((AliVParticle*) input->UncheckedAt(i))->Eta();
560   
561   // list needed to prevent double counting
562   // contains 1 if list element in list <particles> is also contained in <mixed> 
563   TArrayC* existsInMixed = 0;
564   if (mixed && !fPtOrder)
565   {
566     existsInMixed = new TArrayC(particles->GetEntriesFast());
567     for (Int_t i=0; i<particles->GetEntriesFast(); i++)
568     {
569       if (mixed->Contains(particles->UncheckedAt(i)))
570         (*existsInMixed)[i] = 1;
571       else
572         (*existsInMixed)[i] = 0;
573     }
574   }
575   
576   // if particles is not set, just fill event statistics
577   if (particles)
578   {
579     Int_t jMax = particles->GetEntriesFast();
580     if (mixed)
581       jMax = mixed->GetEntriesFast();
582     
583     TH1* triggerWeighting = 0;
584     if (fWeightPerEvent)
585     {
586       TAxis* axis = fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->GetGrid(0)->GetGrid()->GetAxis(2);
587       triggerWeighting = new TH1F("triggerWeighting", "", axis->GetNbins(), axis->GetXbins()->GetArray());
588     
589       for (Int_t i=0; i<particles->GetEntriesFast(); i++)
590       {
591         AliVParticle* triggerParticle = (AliVParticle*) particles->UncheckedAt(i);
592         
593         // some optimization
594         Float_t triggerEta = triggerParticle->Eta();
595
596         if (fTriggerRestrictEta > 0 && TMath::Abs(triggerEta) > fTriggerRestrictEta)
597           continue;
598
599         if (fOnlyOneEtaSide != 0)
600         {
601           if (fOnlyOneEtaSide * triggerEta < 0)
602             continue;
603         }
604         
605         if (fTriggerSelectCharge != 0)
606           if (triggerParticle->Charge() * fTriggerSelectCharge < 0)
607             continue;
608         
609         triggerWeighting->Fill(triggerParticle->Pt());
610       }
611 //       new TCanvas; triggerWeighting->Draw();
612     }
613     
614     for (Int_t i=0; i<particles->GetEntriesFast(); i++)
615     {
616       AliVParticle* triggerParticle = (AliVParticle*) particles->UncheckedAt(i);
617       
618       // some optimization
619       Float_t triggerEta = triggerParticle->Eta();
620       
621       if (fTriggerRestrictEta > 0 && TMath::Abs(triggerEta) > fTriggerRestrictEta)
622         continue;
623
624       if (fOnlyOneEtaSide != 0)
625       {
626         if (fOnlyOneEtaSide * triggerEta < 0)
627           continue;
628       }
629       
630       if (fTriggerSelectCharge != 0)
631         if (triggerParticle->Charge() * fTriggerSelectCharge < 0)
632           continue;
633         
634       for (Int_t j=0; j<jMax; j++)
635       {
636         if (!mixed && i == j)
637           continue;
638       
639         AliVParticle* particle = 0;
640         if (!mixed)
641           particle = (AliVParticle*) particles->UncheckedAt(j);
642         else
643           particle = (AliVParticle*) mixed->UncheckedAt(j);
644         
645         // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event)
646         if (mixed && triggerParticle == particle)
647           continue;
648         
649         if (fPtOrder)
650         {
651           if (particle->Pt() >= triggerParticle->Pt())
652             continue;
653         }
654         else
655         {
656           // if we do not use the pt ordering, we have to prevent double counting in a different way
657           // if the trigger particle is also part of the associated particle list, the pT ordering condition is applied anyway
658           if (!mixed || (*existsInMixed)[i] != 0)
659             if (particle->Pt() >= triggerParticle->Pt())
660             {
661 //            Printf("Skipping %d %d", i, j);
662               continue;
663             }
664         }
665         
666         if (fAssociatedSelectCharge != 0)
667           if (particle->Charge() * fAssociatedSelectCharge < 0)
668             continue;
669
670         if (fSelectCharge > 0)
671         {
672           // skip like sign
673           if (fSelectCharge == 1 && particle->Charge() * triggerParticle->Charge() > 0)
674             continue;
675             
676           // skip unlike sign
677           if (fSelectCharge == 2 && particle->Charge() * triggerParticle->Charge() < 0)
678             continue;
679         }
680         
681         if (fEtaOrdering)
682         {
683           if (triggerEta < 0 && eta[j] < triggerEta)
684             continue;
685           if (triggerEta > 0 && eta[j] > triggerEta)
686             continue;
687         }
688
689         // conversions
690         if (fCutConversions && particle->Charge() * triggerParticle->Charge() < 0)
691         {
692           Float_t mass = GetInvMassSquaredCheap(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.510e-3, 0.510e-3);
693           
694           if (mass < 0.1)
695           {
696             mass = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.510e-3, 0.510e-3);
697             
698             fControlConvResoncances->Fill(0.0, mass);
699
700             if (mass < 0.04*0.04) 
701               continue;
702           }
703         }
704         
705         // K0s
706         if (fCutResonances && particle->Charge() * triggerParticle->Charge() < 0)
707         {
708           Float_t mass = GetInvMassSquaredCheap(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.1396);
709           
710           const Float_t kK0smass = 0.4976;
711           
712           if (TMath::Abs(mass - kK0smass*kK0smass) < 0.1)
713           {
714             mass = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.1396);
715             
716             fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass);
717
718             if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02))
719               continue;
720           }
721         }
722         
723         // Lambda
724         if (fCutResonances && particle->Charge() * triggerParticle->Charge() < 0)
725         {
726           Float_t mass1 = GetInvMassSquaredCheap(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.9383);
727           Float_t mass2 = GetInvMassSquaredCheap(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.9383, 0.1396);
728           
729           const Float_t kLambdaMass = 1.115;
730
731           if (TMath::Abs(mass1 - kLambdaMass*kLambdaMass) < 0.1)
732           {
733             mass1 = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.9383);
734
735             fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass);
736             
737             if (mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
738               continue;
739           }
740           if (TMath::Abs(mass2 - kLambdaMass*kLambdaMass) < 0.1)
741           {
742             mass2 = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.9383, 0.1396);
743
744             fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass);
745
746             if (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02))
747               continue;
748           }
749         }
750
751         if (twoTrackEfficiencyCut)
752         {
753           // the variables & cuthave been developed by the HBT group 
754           // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
755
756           Float_t phi1 = triggerParticle->Phi();
757           Float_t pt1 = triggerParticle->Pt();
758           Float_t charge1 = triggerParticle->Charge();
759             
760           Float_t phi2 = particle->Phi();
761           Float_t pt2 = particle->Pt();
762           Float_t charge2 = particle->Charge();
763               
764           Float_t deta = triggerEta - eta[j];
765               
766           // optimization
767           if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3)
768           {
769             // check first boundaries to see if is worth to loop and find the minimum
770             Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
771             Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
772             
773             const Float_t kLimit = twoTrackEfficiencyCutValue * 3;
774
775             Float_t dphistarminabs = 1e5;
776             Float_t dphistarmin = 1e5;
777             if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
778             {
779               for (Double_t rad=0.8; rad<2.51; rad+=0.01) 
780               {
781                 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
782
783                 Float_t dphistarabs = TMath::Abs(dphistar);
784                 
785                 if (dphistarabs < dphistarminabs)
786                 {
787                   dphistarmin = dphistar;
788                   dphistarminabs = dphistarabs;
789                 }
790               }
791               
792               fTwoTrackDistancePt[0]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
793               
794               if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue)
795               {
796 //              Printf("Removed track pair %d %d with %f %f %f %f %f %f %f %f %f", i, j, deta, dphistarminabs, phi1, pt1, charge1, phi2, pt2, charge2, bSign);
797                 continue;
798               }
799
800               fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
801             }
802           }
803         }
804         
805         Double_t vars[6];
806         vars[0] = triggerEta - eta[j];
807         vars[1] = particle->Pt();
808         vars[2] = triggerParticle->Pt();
809         vars[3] = centrality;
810         vars[4] = triggerParticle->Phi() - particle->Phi();
811         if (vars[4] > 1.5 * TMath::Pi()) 
812           vars[4] -= TMath::TwoPi();
813         if (vars[4] < -0.5 * TMath::Pi())
814           vars[4] += TMath::TwoPi();
815         vars[5] = zVtx;
816         
817         if (fillpT)
818           weight = particle->Pt();
819         
820         Double_t useWeight = weight;
821         if (applyEfficiency)
822         {
823           if (fEfficiencyCorrectionAssociated)
824           {
825             Int_t effVars[4];
826             // associated particle
827             effVars[0] = fEfficiencyCorrectionAssociated->GetAxis(0)->FindBin(eta[j]);
828             effVars[1] = fEfficiencyCorrectionAssociated->GetAxis(1)->FindBin(vars[1]); //pt
829             effVars[2] = fEfficiencyCorrectionAssociated->GetAxis(2)->FindBin(vars[3]); //centrality
830             effVars[3] = fEfficiencyCorrectionAssociated->GetAxis(3)->FindBin(vars[5]); //zVtx
831             
832             //    Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrectionAssociated->GetBinContent(effVars));
833           
834             useWeight *= fEfficiencyCorrectionAssociated->GetBinContent(effVars);
835           }
836           if (fEfficiencyCorrectionTriggers)
837           {
838             Int_t effVars[4];
839
840             effVars[0] = fEfficiencyCorrectionTriggers->GetAxis(0)->FindBin(triggerEta);
841             effVars[1] = fEfficiencyCorrectionTriggers->GetAxis(1)->FindBin(vars[2]); //pt
842             effVars[2] = fEfficiencyCorrectionTriggers->GetAxis(2)->FindBin(vars[3]); //centrality
843             effVars[3] = fEfficiencyCorrectionTriggers->GetAxis(3)->FindBin(vars[5]); //zVtx
844             useWeight *= fEfficiencyCorrectionTriggers->GetBinContent(effVars);
845           }
846         }
847
848         if (fWeightPerEvent)
849         {
850           Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[2]);
851 //        Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
852           useWeight /= triggerWeighting->GetBinContent(weightBin);
853         }
854     
855         // fill all in toward region and do not use the other regions
856         fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step, useWeight);
857
858 //      Printf("%.2f %.2f --> %.2f", triggerEta, eta[j], vars[0]);
859       }
860  
861       if (firstTime)
862       {
863         // once per trigger particle
864         Double_t vars[3];
865         vars[0] = triggerParticle->Pt();
866         vars[1] = centrality;
867         vars[2] = zVtx;
868
869         Double_t useWeight = 1;
870         if (fEfficiencyCorrectionTriggers && applyEfficiency)
871         {
872           Int_t effVars[4];
873           
874           // trigger particle
875           effVars[0] = fEfficiencyCorrectionTriggers->GetAxis(0)->FindBin(triggerEta);
876           effVars[1] = fEfficiencyCorrectionTriggers->GetAxis(1)->FindBin(vars[0]); //pt
877           effVars[2] = fEfficiencyCorrectionTriggers->GetAxis(2)->FindBin(vars[1]); //centrality
878           effVars[3] = fEfficiencyCorrectionTriggers->GetAxis(3)->FindBin(vars[2]); //zVtx
879           useWeight *= fEfficiencyCorrectionTriggers->GetBinContent(effVars);
880         }
881         if (fWeightPerEvent)
882         {
883           // leads effectively to a filling of one entry per filled trigger particle pT bin
884           Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[0]);
885 //        Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
886           useWeight /= triggerWeighting->GetBinContent(weightBin);
887         }
888         
889         fNumberDensityPhi->GetEventHist()->Fill(vars, step, useWeight);
890
891         // QA
892         fCorrelationpT->Fill(centrality, triggerParticle->Pt());
893         fCorrelationEta->Fill(centrality, triggerEta);
894         fCorrelationPhi->Fill(centrality, triggerParticle->Phi());
895         fYields->Fill(centrality, triggerParticle->Pt(), triggerEta);
896
897 /*        if (dynamic_cast<AliAODTrack*>(triggerParticle))
898           fITSClusterMap->Fill(((AliAODTrack*) triggerParticle)->GetITSClusterMap(), centrality, triggerParticle->Pt());*/
899       }
900     }
901     
902     if (triggerWeighting)
903     {
904       delete triggerWeighting;
905       triggerWeighting = 0;
906     }
907   }
908   
909   delete existsInMixed;
910   
911   fCentralityDistribution->Fill(centrality);
912   fCentralityCorrelation->Fill(centrality, particles->GetEntriesFast());
913   FillEvent(centrality, step);
914 }
915   
916 //____________________________________________________________________
917 void AliUEHistograms::FillTrackingEfficiency(TObjArray* mc, TObjArray* recoPrim, TObjArray* recoAll, TObjArray* recoPrimPID, TObjArray* recoAllPID, TObjArray* fake, Int_t particleType, Double_t centrality, Double_t zVtx)
918 {
919   // fills the tracking efficiency objects
920   //
921   // mc: all primary MC particles
922   // recoPrim: reconstructed primaries (again MC particles)
923   // recoAll: reconstructed (again MC particles)
924   // recoPrim: reconstructed primaries with checks on PID (again MC particles)
925   // recoAll: reconstructed with checks on PID (again MC particles)
926   // particleType is: 0 for pion, 1 for kaon, 2 for proton, 3 for others
927  
928   for (Int_t step=0; step<6; step++)
929   {
930     TObjArray* list = mc;
931     if (step == 1)
932       list = recoPrim;
933     else if (step == 2)
934       list = recoAll;
935     else if (step == 3)
936       list = recoPrimPID;
937     else if (step == 4)
938       list = recoAllPID;
939     else if (step == 5)
940       list = fake;
941     
942     if (!list)
943       continue;
944
945     for (Int_t i=0; i<list->GetEntriesFast(); i++)
946     {
947       AliVParticle* particle = (AliVParticle*) list->UncheckedAt(i);
948       Double_t vars[5];
949       vars[0] = particle->Eta();
950       vars[1] = particle->Pt();
951       vars[2] = particleType;
952       vars[3] = centrality;
953       vars[4] = zVtx;
954       
955       for (Int_t j=0; j<fgkUEHists; j++)
956         if (GetUEHist(j))
957           GetUEHist(j)->GetTrackHistEfficiency()->Fill(vars, step);
958     }
959   }
960 }
961
962 //____________________________________________________________________
963 void AliUEHistograms::FillFakePt(TObjArray* fake, Double_t centrality)
964 {
965   TObjArray* tracksReco = (TObjArray*) fake->At(0);
966   TObjArray* tracksMC = (TObjArray*) fake->At(1);
967   
968   if (tracksReco->GetEntriesFast() != tracksMC->GetEntriesFast())
969     AliFatal(Form("Inconsistent arrays: %d vs %d", tracksReco->GetEntriesFast(), tracksMC->GetEntriesFast()));
970   
971   for (Int_t i=0; i<tracksReco->GetEntriesFast(); i++)
972   {
973     AliVParticle* particle1 = (AliVParticle*) tracksReco->At(i);
974     AliVParticle* particle2 = (AliVParticle*) tracksMC->At(i);
975     Double_t vars[3];
976     vars[0] = particle1->Pt();
977     vars[1] = particle2->Pt();
978     vars[2] = centrality;
979     for (Int_t j=0; j<fgkUEHists; j++)
980       if (GetUEHist(j))
981         GetUEHist(j)->GetMCRecoPtCorrelation()->Fill(vars[0],vars[1],vars[2]);
982   }
983 }
984
985 //____________________________________________________________________
986 void AliUEHistograms::FillEvent(Int_t eventType, Int_t step)
987 {
988   // fills the number of events at the given step and the given enty type
989   //
990   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
991   
992   fEventCount->Fill(step, eventType);
993 }
994
995 //____________________________________________________________________
996 void AliUEHistograms::FillEvent(Double_t centrality, Int_t step)
997 {
998   // fills the number of events at the given step and the given centrality
999   //
1000   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
1001   
1002   fEventCount->Fill(step, centrality);
1003 }
1004
1005 //____________________________________________________________________
1006 void AliUEHistograms::SetEtaRange(Float_t etaMin, Float_t etaMax)
1007 {
1008   // sets eta min and max for all contained AliUEHist classes
1009   
1010   for (Int_t i=0; i<fgkUEHists; i++)
1011     if (GetUEHist(i))
1012       GetUEHist(i)->SetEtaRange(etaMin, etaMax);
1013 }
1014
1015 //____________________________________________________________________
1016 void AliUEHistograms::SetPtRange(Float_t ptMin, Float_t ptMax)
1017 {
1018   // sets pT min and max for all contained AliUEHist classes
1019   
1020   for (Int_t i=0; i<fgkUEHists; i++)
1021     if (GetUEHist(i))
1022       GetUEHist(i)->SetPtRange(ptMin, ptMax);
1023 }
1024
1025 //____________________________________________________________________
1026 void AliUEHistograms::SetPartSpecies(Int_t species)
1027 {
1028   // sets PartSpecie for all contained AliUEHist classes
1029   
1030   for (Int_t i=0; i<fgkUEHists; i++)
1031     if (GetUEHist(i))
1032       GetUEHist(i)->SetPartSpecies(species);
1033 }
1034
1035 //____________________________________________________________________
1036 void AliUEHistograms::SetZVtxRange(Float_t min, Float_t max)
1037 {
1038   // sets pT min and max for all contained AliUEHist classes
1039   
1040   for (Int_t i=0; i<fgkUEHists; i++)
1041     if (GetUEHist(i))
1042       GetUEHist(i)->SetZVtxRange(min, max);
1043 }
1044
1045 //____________________________________________________________________
1046 void AliUEHistograms::SetContaminationEnhancement(TH1F* hist)
1047 {
1048   // sets the contamination enhancement histogram in all contained AliUEHist classes
1049   
1050   for (Int_t i=0; i<fgkUEHists; i++)
1051     if (GetUEHist(i))
1052       GetUEHist(i)->SetContaminationEnhancement(hist);
1053 }  
1054
1055 //____________________________________________________________________
1056 void AliUEHistograms::SetCombineMinMax(Bool_t flag)
1057 {
1058   // sets pT min and max for all contained AliUEHist classes
1059   
1060   for (Int_t i=0; i<fgkUEHists; i++)
1061     if (GetUEHist(i))
1062       GetUEHist(i)->SetCombineMinMax(flag);
1063 }
1064
1065 //____________________________________________________________________
1066 void AliUEHistograms::SetTrackEtaCut(Float_t value)
1067 {
1068   // sets track eta cut for all contained AliUEHist classes
1069   
1070   for (Int_t i=0; i<fgkUEHists; i++)
1071     if (GetUEHist(i))
1072       GetUEHist(i)->SetTrackEtaCut(value);
1073 }
1074
1075 //____________________________________________________________________
1076 void AliUEHistograms::SetWeightPerEvent(Bool_t flag)
1077 {
1078   // sets fWeightPerEvent for all contained AliUEHist classes
1079   
1080   fWeightPerEvent = flag;
1081   
1082   for (Int_t i=0; i<fgkUEHists; i++)
1083     if (GetUEHist(i))
1084       GetUEHist(i)->SetWeightPerEvent(fWeightPerEvent);
1085 }
1086
1087 //____________________________________________________________________
1088 void AliUEHistograms::Correct(AliUEHistograms* corrections)
1089 {
1090   // corrects the contained histograms by calling AliUEHist::Correct
1091   
1092   for (Int_t i=0; i<fgkUEHists; i++)
1093     if (GetUEHist(i))
1094       GetUEHist(i)->Correct(corrections->GetUEHist(i));
1095 }
1096
1097 //____________________________________________________________________
1098 AliUEHistograms &AliUEHistograms::operator=(const AliUEHistograms &c)
1099 {
1100   // assigment operator
1101
1102   DeleteContainers();
1103
1104   if (this != &c)
1105     ((AliUEHistograms &) c).Copy(*this);
1106
1107   return *this;
1108 }
1109
1110 //____________________________________________________________________
1111 void AliUEHistograms::Copy(TObject& c) const
1112 {
1113   // copy function
1114
1115   AliUEHistograms& target = (AliUEHistograms &) c;
1116
1117   if (fNumberDensitypT)
1118     target.fNumberDensitypT = dynamic_cast<AliUEHist*> (fNumberDensitypT->Clone());
1119
1120   if (fSumpT)
1121     target.fSumpT = dynamic_cast<AliUEHist*> (fSumpT->Clone());
1122
1123   if (fNumberDensityPhi)
1124     target.fNumberDensityPhi = dynamic_cast<AliUEHist*> (fNumberDensityPhi->Clone());
1125
1126   if (fCorrelationpT)
1127     target.fCorrelationpT = dynamic_cast<TH2F*> (fCorrelationpT->Clone());
1128
1129   if (fCorrelationEta)
1130     target.fCorrelationEta = dynamic_cast<TH2F*> (fCorrelationEta->Clone());
1131
1132   if (fCorrelationPhi)
1133     target.fCorrelationPhi = dynamic_cast<TH2F*> (fCorrelationPhi->Clone());
1134
1135   if (fCorrelationR)
1136     target.fCorrelationR = dynamic_cast<TH2F*> (fCorrelationR->Clone());
1137
1138   if (fCorrelationLeading2Phi)
1139     target.fCorrelationLeading2Phi = dynamic_cast<TH2F*> (fCorrelationLeading2Phi->Clone());
1140
1141   if (fCorrelationMultiplicity)
1142     target.fCorrelationMultiplicity = dynamic_cast<TH2F*> (fCorrelationMultiplicity->Clone());
1143   
1144   if (fYields)
1145     target.fYields = dynamic_cast<TH3F*> (fYields->Clone());
1146   
1147   if (fEventCount)
1148     target.fEventCount = dynamic_cast<TH2F*> (fEventCount->Clone());
1149
1150   if (fEventCountDifferential)
1151     target.fEventCountDifferential = dynamic_cast<TH3F*> (fEventCountDifferential->Clone());
1152     
1153   if (fVertexContributors)
1154     target.fVertexContributors = dynamic_cast<TH1F*> (fVertexContributors->Clone());
1155
1156   if (fCentralityDistribution)
1157     target.fCentralityDistribution = dynamic_cast<TH1F*> (fCentralityDistribution->Clone());
1158     
1159   if (fCentralityCorrelation)
1160     target.fCentralityCorrelation = dynamic_cast<TH2F*> (fCentralityCorrelation->Clone());
1161
1162   if (fITSClusterMap)
1163     target.fITSClusterMap = dynamic_cast<TH3F*> (fITSClusterMap->Clone());
1164   
1165   if (fControlConvResoncances)
1166     target.fControlConvResoncances = dynamic_cast<TH2F*> (fControlConvResoncances->Clone());
1167   
1168   for (Int_t i=0; i<2; i++)
1169     if (fTwoTrackDistancePt[i])
1170       target.fTwoTrackDistancePt[i] = dynamic_cast<TH3F*> (fTwoTrackDistancePt[i]->Clone());
1171
1172   if (fEfficiencyCorrectionTriggers)
1173     target.fEfficiencyCorrectionTriggers = dynamic_cast<THnF*> (fEfficiencyCorrectionTriggers->Clone());
1174  
1175  if (fEfficiencyCorrectionAssociated)
1176     target.fEfficiencyCorrectionAssociated = dynamic_cast<THnF*> (fEfficiencyCorrectionAssociated->Clone());
1177     
1178   target.fSelectCharge = fSelectCharge;
1179   target.fTriggerSelectCharge = fTriggerSelectCharge;
1180   target.fAssociatedSelectCharge = fAssociatedSelectCharge;
1181   target.fTriggerRestrictEta = fTriggerRestrictEta;
1182   target.fEtaOrdering = fEtaOrdering;
1183   target.fCutConversions = fCutConversions;
1184   target.fCutResonances = fCutResonances;
1185   target.fOnlyOneEtaSide = fOnlyOneEtaSide;
1186   target.fWeightPerEvent = fWeightPerEvent;
1187   target.fRunNumber = fRunNumber;
1188   target.fMergeCount = fMergeCount;
1189   target.fWeightPerEvent = fWeightPerEvent;
1190   target.fPtOrder = fPtOrder;
1191 }
1192
1193 //____________________________________________________________________
1194 Long64_t AliUEHistograms::Merge(TCollection* list)
1195 {
1196   // Merge a list of AliUEHistograms objects with this (needed for
1197   // PROOF). 
1198   // Returns the number of merged objects (including this).
1199
1200   if (!list)
1201     return 0;
1202   
1203   if (list->IsEmpty())
1204     return 1;
1205
1206   TIterator* iter = list->MakeIterator();
1207   TObject* obj;
1208
1209   // collections of objects
1210   const Int_t kMaxLists = 19;
1211   TList* lists[kMaxLists];
1212   
1213   for (Int_t i=0; i<kMaxLists; i++)
1214     lists[i] = new TList;
1215   
1216   Int_t count = 0;
1217   while ((obj = iter->Next())) {
1218     
1219     AliUEHistograms* entry = dynamic_cast<AliUEHistograms*> (obj);
1220     if (entry == 0) 
1221       continue;
1222
1223     if (entry->fNumberDensitypT)
1224       lists[0]->Add(entry->fNumberDensitypT);
1225     if (entry->fSumpT)
1226       lists[1]->Add(entry->fSumpT);
1227     if (entry->fNumberDensityPhi)
1228       lists[2]->Add(entry->fNumberDensityPhi);
1229     lists[3]->Add(entry->fCorrelationpT);
1230     lists[4]->Add(entry->fCorrelationEta);
1231     lists[5]->Add(entry->fCorrelationPhi);
1232     lists[6]->Add(entry->fCorrelationR);
1233     lists[7]->Add(entry->fCorrelationLeading2Phi);
1234     lists[8]->Add(entry->fCorrelationMultiplicity);
1235     lists[9]->Add(entry->fEventCount);
1236     lists[10]->Add(entry->fEventCountDifferential);
1237     lists[11]->Add(entry->fVertexContributors);
1238     lists[12]->Add(entry->fCentralityDistribution);
1239     lists[13]->Add(entry->fITSClusterMap);
1240     if (entry->fTwoTrackDistancePt[0])
1241       lists[14]->Add(entry->fTwoTrackDistancePt[0]);
1242     if (entry->fTwoTrackDistancePt[1])
1243       lists[15]->Add(entry->fTwoTrackDistancePt[1]);
1244     if (entry->fCentralityCorrelation)
1245       lists[16]->Add(entry->fCentralityCorrelation);
1246     if (entry->fYields)
1247       lists[17]->Add(entry->fYields);
1248     if (entry->fControlConvResoncances)
1249       lists[18]->Add(entry->fControlConvResoncances);
1250
1251     fMergeCount += entry->fMergeCount;
1252
1253     count++;
1254   }
1255     
1256   if (fNumberDensitypT)
1257     fNumberDensitypT->Merge(lists[0]);
1258   if (fSumpT)
1259     fSumpT->Merge(lists[1]);
1260   if (fNumberDensityPhi)
1261     fNumberDensityPhi->Merge(lists[2]);
1262   fCorrelationpT->Merge(lists[3]);
1263   fCorrelationEta->Merge(lists[4]);
1264   fCorrelationPhi->Merge(lists[5]);
1265   fCorrelationR->Merge(lists[6]);
1266   fCorrelationLeading2Phi->Merge(lists[7]);
1267   fCorrelationMultiplicity->Merge(lists[8]);
1268   fEventCount->Merge(lists[9]);
1269   fEventCountDifferential->Merge(lists[10]);
1270   fVertexContributors->Merge(lists[11]);
1271   fCentralityDistribution->Merge(lists[12]);
1272   fITSClusterMap->Merge(lists[13]);
1273   if (fTwoTrackDistancePt[0] && lists[14]->GetEntries() > 0)
1274     fTwoTrackDistancePt[0]->Merge(lists[14]);
1275   if (fTwoTrackDistancePt[1] && lists[15]->GetEntries() > 0)
1276     fTwoTrackDistancePt[1]->Merge(lists[15]);
1277   if (fCentralityCorrelation)
1278     fCentralityCorrelation->Merge(lists[16]);
1279   if (fYields && lists[17]->GetEntries() > 0)
1280     fYields->Merge(lists[17]);
1281   if (fControlConvResoncances && lists[18]->GetEntries() > 0)
1282     fControlConvResoncances->Merge(lists[18]);
1283   
1284   for (Int_t i=0; i<kMaxLists; i++)
1285     delete lists[i];
1286   
1287   return count+1;
1288 }
1289
1290 void AliUEHistograms::CopyReconstructedData(AliUEHistograms* from)
1291 {
1292   // copies those histograms extracted from ESD to this object
1293   
1294   for (Int_t i=0; i<fgkUEHists; i++)
1295     if (GetUEHist(i))
1296       GetUEHist(i)->CopyReconstructedData(from->GetUEHist(i));
1297 }
1298
1299 void AliUEHistograms::DeepCopy(AliUEHistograms* from)
1300 {
1301   // copies the entries of this object's members from the object <from> to this object
1302
1303   for (Int_t i=0; i<fgkUEHists; i++)
1304     if (GetUEHist(i) && from->GetUEHist(i))
1305       GetUEHist(i)->DeepCopy(from->GetUEHist(i));
1306 }
1307
1308 void AliUEHistograms::ExtendTrackingEfficiency(Bool_t verbose)
1309 {
1310   // delegates to AliUEHists
1311
1312   for (Int_t i=0; i<fgkUEHists; i++)
1313     if (GetUEHist(i))
1314       GetUEHist(i)->ExtendTrackingEfficiency(verbose);
1315 }
1316
1317 void AliUEHistograms::Scale(Double_t factor)
1318 {
1319   // scales all contained histograms by the given factor
1320   
1321   for (Int_t i=0; i<fgkUEHists; i++)
1322     if (GetUEHist(i))
1323       GetUEHist(i)->Scale(factor);
1324       
1325   TList list;
1326   list.Add(fCorrelationpT);
1327   list.Add(fCorrelationEta);
1328   list.Add(fCorrelationPhi);
1329   list.Add(fCorrelationR);
1330   list.Add(fCorrelationLeading2Phi);
1331   list.Add(fCorrelationMultiplicity);
1332   list.Add(fYields);
1333   list.Add(fEventCount);
1334   list.Add(fEventCountDifferential);
1335   list.Add(fVertexContributors);
1336   list.Add(fCentralityDistribution);
1337   list.Add(fCentralityCorrelation);
1338   list.Add(fITSClusterMap);
1339   list.Add(fTwoTrackDistancePt[0]);
1340   list.Add(fTwoTrackDistancePt[1]);
1341   list.Add(fControlConvResoncances);
1342   
1343   for (Int_t i=0; i<list.GetEntries(); i++)
1344     ((TH1*) list.At(i))->Scale(factor);
1345 }
1346
1347 void AliUEHistograms::Reset()
1348 {
1349   // delegates to AliUEHists
1350
1351   for (Int_t i=0; i<fgkUEHists; i++)
1352     if (GetUEHist(i))
1353       GetUEHist(i)->Reset();
1354 }