]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/Base/AliUEHistograms.cxx
31bb775af2766f591e8b4bedba079a9b1aec91f9
[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) : 
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   fEfficiencyCorrection(0),
63   fCorrectTriggers(kFALSE),
64   fSelectCharge(0),
65   fTriggerSelectCharge(0),
66   fTriggerRestrictEta(-1),
67   fEtaOrdering(kFALSE),
68   fCutConversions(kFALSE),
69   fCutResonances(kFALSE),
70   fOnlyOneEtaSide(0),
71   fWeightPerEvent(kFALSE),
72   fRunNumber(0),
73   fMergeCount(1)
74 {
75   // Constructor
76   //
77   // the string histograms defines which histograms are created:
78   //    1 = NumberDensitypT
79   //    2 = SumpT
80   //    3 = NumberDensityPhi
81   //    4 = NumberDensityPhiCentrality (other multiplicity for Pb)
82   
83   AliLog::SetClassDebugLevel("AliCFContainer", -1);
84   AliLog::SetClassDebugLevel("AliCFGridSparse", -3);
85
86   fTwoTrackDistancePt[0] = 0;
87   fTwoTrackDistancePt[1] = 0;
88   
89   TString histogramsStr(histograms);
90   
91   if (histogramsStr.Contains("1"))
92     fNumberDensitypT = new AliUEHist("NumberDensitypT");
93   if (histogramsStr.Contains("2"))
94     fSumpT = new AliUEHist("SumpT");
95   
96   if (histogramsStr.Contains("3"))
97     fNumberDensityPhi = new AliUEHist("NumberDensityPhi");
98   else if (histogramsStr.Contains("4RC"))
99     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityCourse");
100   else if (histogramsStr.Contains("4R"))
101     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentrality");
102   else if (histogramsStr.Contains("4"))
103     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityTTR");
104   else if (histogramsStr.Contains("5RC"))
105     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtxCourse");
106   else if (histogramsStr.Contains("5R"))
107     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtx");
108   else if (histogramsStr.Contains("5"))
109     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtxTTR");
110   else if (histogramsStr.Contains("6RC"))
111     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtx10Course");
112   else if (histogramsStr.Contains("6R"))
113     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtx10");
114   else if (histogramsStr.Contains("6"))
115     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentralityVtx10TTR");
116   
117   // do not add this hists to the directory
118   Bool_t oldStatus = TH1::AddDirectoryStatus();
119   TH1::AddDirectory(kFALSE);
120   
121   if (!histogramsStr.Contains("4") && !histogramsStr.Contains("5") && !histogramsStr.Contains("6"))
122   {
123     fCorrelationpT  = new TH2F("fCorrelationpT", ";p_{T,lead} (MC);p_{T,lead} (RECO)", 200, 0, 50, 200, 0, 50);
124     fCorrelationEta = new TH2F("fCorrelationEta", ";#eta_{lead} (MC);#eta_{T,lead} (RECO)", 200, -1, 1, 200, -1, 1);
125     fCorrelationPhi = new TH2F("fCorrelationPhi", ";#varphi_{lead} (MC);#varphi_{T,lead} (RECO)", 200, 0, TMath::TwoPi(), 200, 0, TMath::TwoPi());
126   }
127   else
128   {
129     fCorrelationpT  = new TH2F("fCorrelationpT", ";Centrality;p_{T} (RECO)", 100, 0, 100.001, 200, 0, 50);
130     fCorrelationEta = new TH2F("fCorrelationEta", ";Centrality;#eta (RECO)", 100, 0, 100.001, 200, -5, 5);
131     fCorrelationPhi = new TH2F("fCorrelationPhi", ";Centrality;#varphi (RECO)", 100, 0, 100.001, 200, 0, TMath::TwoPi());
132   }
133   
134   fCorrelationR =   new TH2F("fCorrelationR", ";R;p_{T,lead} (MC)", 200, 0, 2, 200, 0, 50);
135   fCorrelationLeading2Phi = new TH2F("fCorrelationLeading2Phi", ";#Delta #varphi;p_{T,lead} (MC)", 200, -TMath::Pi(), TMath::Pi(), 200, 0, 50);
136   fCorrelationMultiplicity = new TH2F("fCorrelationMultiplicity", ";MC tracks;Reco tracks", 100, -0.5, 99.5, 100, -0.5, 99.5);
137   fYields = new TH3F("fYields", ";centrality;pT;eta", 100, 0, 100, 40, 0, 20, 100, -1, 1);
138
139   if (!histogramsStr.Contains("4") && !histogramsStr.Contains("5") && !histogramsStr.Contains("6"))
140   {
141     fEventCount = new TH2F("fEventCount", ";step;event type;count", AliUEHist::fgkCFSteps+2, -2.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
142     fEventCount->GetYaxis()->SetBinLabel(1, "ND");
143     fEventCount->GetYaxis()->SetBinLabel(2, "SD");
144     fEventCount->GetYaxis()->SetBinLabel(3, "DD");
145   }
146   else
147   {
148     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());
149   }
150   
151   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);
152   fEventCountDifferential->GetZaxis()->SetBinLabel(1, "ND");
153   fEventCountDifferential->GetZaxis()->SetBinLabel(2, "SD");
154   fEventCountDifferential->GetZaxis()->SetBinLabel(3, "DD");
155   
156   fVertexContributors = new TH1F("fVertexContributors", ";contributors;count", 100, -0.5, 99.5);
157   
158   if (fNumberDensityPhi)
159   {
160     fCentralityDistribution = new TH1F("fCentralityDistribution", ";centrality;count", fNumberDensityPhi->GetEventHist()->GetNBins(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray());
161     fCentralityCorrelation = new TH2F("fCentralityCorrelation", ";centrality;multiplicity", 101, 0, 101, 200, 0, 4000);
162   }
163   
164   fITSClusterMap = new TH3F("fITSClusterMap", "; its cluster map; centrality; pT", 256, -0.5, 255.5, 20, 0, 100.001, 100, 0, 20);
165   
166   fControlConvResoncances = new TH2F("fControlConvResoncances", ";id;delta mass", 3, -0.5, 2.5, 100, -0.1, 0.1);
167   
168   TH1::AddDirectory(oldStatus);
169 }
170
171 //_____________________________________________________________________________
172 AliUEHistograms::AliUEHistograms(const AliUEHistograms &c) :
173   TNamed(fName, fTitle),
174   fNumberDensitypT(0),
175   fSumpT(0),
176   fNumberDensityPhi(0),
177   fCorrelationpT(0),
178   fCorrelationEta(0),
179   fCorrelationPhi(0),
180   fCorrelationR(0),
181   fCorrelationLeading2Phi(0),
182   fCorrelationMultiplicity(0),
183   fYields(0),
184   fEventCount(0),
185   fEventCountDifferential(0),
186   fVertexContributors(0),
187   fCentralityDistribution(0),
188   fCentralityCorrelation(0),
189   fITSClusterMap(0),
190   fControlConvResoncances(0),
191   fEfficiencyCorrection(0),
192   fCorrectTriggers(kFALSE),
193   fSelectCharge(0),
194   fTriggerSelectCharge(0),
195   fTriggerRestrictEta(-1),
196   fEtaOrdering(kFALSE),
197   fCutConversions(kFALSE),
198   fCutResonances(kFALSE),
199   fOnlyOneEtaSide(0),
200   fWeightPerEvent(kFALSE),
201   fRunNumber(0),
202   fMergeCount(1)
203 {
204   //
205   // AliUEHistograms copy constructor
206   //
207
208   fTwoTrackDistancePt[0] = 0;
209   fTwoTrackDistancePt[1] = 0;
210
211   ((AliUEHistograms &) c).Copy(*this);
212 }
213
214 //____________________________________________________________________
215 AliUEHistograms::~AliUEHistograms()
216 {
217   // Destructor
218   
219   DeleteContainers();
220 }
221
222 void AliUEHistograms::DeleteContainers()
223 {
224   if (fNumberDensitypT)
225   {
226     delete fNumberDensitypT;
227     fNumberDensitypT = 0;
228   }
229   
230   if (fSumpT)
231   {
232     delete fSumpT;
233     fSumpT = 0;
234   }
235   
236   if (fNumberDensityPhi)
237   {
238     delete fNumberDensityPhi;
239     fNumberDensityPhi = 0;
240   }
241   
242   if (fCorrelationpT)
243   {
244     delete fCorrelationpT;
245     fCorrelationpT = 0;
246   }
247   
248   if (fCorrelationEta)
249   {
250     delete fCorrelationEta;
251     fCorrelationEta = 0;
252   }
253   
254   if (fCorrelationPhi)
255   {
256     delete fCorrelationPhi;
257     fCorrelationPhi = 0;
258   }
259   
260   if (fCorrelationR)
261   {
262     delete fCorrelationR;
263     fCorrelationR = 0;
264   }
265
266   if (fCorrelationLeading2Phi)
267   {
268     delete fCorrelationLeading2Phi;
269     fCorrelationLeading2Phi = 0;
270   }
271   
272   if (fCorrelationMultiplicity)
273   {
274     delete fCorrelationMultiplicity;
275     fCorrelationMultiplicity = 0;
276   }
277   
278   if (fYields)
279   {
280     delete fYields;
281     fYields = 0;
282   }
283   
284   if (fEventCount)
285   {
286     delete fEventCount;
287     fEventCount = 0;
288   }
289
290   if (fEventCountDifferential)
291   {
292     delete fEventCountDifferential;
293     fEventCountDifferential = 0;
294   }
295   
296   if (fVertexContributors)
297   {
298     delete fVertexContributors;
299     fVertexContributors = 0;
300   }
301   
302   if (fCentralityDistribution)
303   {
304     delete fCentralityDistribution;
305     fCentralityDistribution = 0;
306   }
307   
308   if (fCentralityCorrelation)
309   {
310     delete fCentralityCorrelation;
311     fCentralityCorrelation = 0;
312   }
313   
314   if (fITSClusterMap)
315   {
316     delete fITSClusterMap;
317     fITSClusterMap = 0;
318   }
319   
320   for (Int_t i=0; i<2; i++)
321     if (fTwoTrackDistancePt[i])
322     {
323       delete fTwoTrackDistancePt[i];
324       fTwoTrackDistancePt[i] = 0;
325     }
326     
327   if (fControlConvResoncances)
328   {
329     delete fControlConvResoncances;
330     fControlConvResoncances = 0;
331   }
332     
333   if (fEfficiencyCorrection)
334   {
335     delete fEfficiencyCorrection;
336     fEfficiencyCorrection = 0;
337   }
338 }
339
340 AliUEHist* AliUEHistograms::GetUEHist(Int_t id)
341 {
342   // returns AliUEHist object, useful for loops
343   
344   switch (id)
345   {
346     case 0: return fNumberDensitypT; break;
347     case 1: return fSumpT; break;
348     case 2: return fNumberDensityPhi; break;
349   }
350   
351   return 0;
352 }
353
354 //____________________________________________________________________
355 Int_t AliUEHistograms::CountParticles(TList* list, Float_t ptMin)
356 {
357   // counts the number of particles in the list with a pT above ptMin
358   // TODO eta cut needed here?
359   
360   Int_t count = 0;
361   for (Int_t j=0; j<list->GetEntries(); j++)
362     if (((AliVParticle*) list->At(j))->Pt() > ptMin)
363       count++;
364       
365   return count;
366 }
367   
368 //____________________________________________________________________
369 void AliUEHistograms::Fill(Int_t eventType, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* toward, TList* away, TList* min, TList* max)
370 {
371   // fills the UE event histograms
372   //
373   // 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
374   
375   // if leading is not set, just fill event statistics
376   if (leading)
377   {
378     Int_t multiplicity = 0;
379     
380     // TODO configurable?
381     Float_t ptMin = 0.15;
382     if (leading->Pt() > ptMin)
383       multiplicity++;
384     
385     multiplicity += CountParticles(toward, ptMin);
386     multiplicity += CountParticles(away, ptMin);
387     multiplicity += CountParticles(min, ptMin);
388     multiplicity += CountParticles(max, ptMin);
389      
390     FillRegion(AliUEHist::kToward, zVtx, step, leading, toward, multiplicity);
391     FillRegion(AliUEHist::kAway,   zVtx, step, leading, away, multiplicity);
392     FillRegion(AliUEHist::kMin,    zVtx, step, leading, min, multiplicity);
393     FillRegion(AliUEHist::kMax,    zVtx, step, leading, max, multiplicity);
394  
395     Double_t vars[3];
396     vars[0] = leading->Pt();
397     vars[1] = multiplicity;
398     vars[2] = zVtx;
399     for (Int_t i=0; i<fgkUEHists; i++)
400       if (GetUEHist(i))
401         GetUEHist(i)->GetEventHist()->Fill(vars, step);
402   
403     fEventCountDifferential->Fill(leading->Pt(), step, eventType);
404   }
405   
406   FillEvent(eventType, step);
407 }
408   
409 //____________________________________________________________________
410 void AliUEHistograms::FillRegion(AliUEHist::Region region, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* list, Int_t multiplicity)
411 {
412   // loops over AliVParticles in list and fills the given region at the given step
413   //
414   // See also Fill(...)
415
416   for (Int_t i=0; i<list->GetEntries(); i++)
417   {
418     AliVParticle* particle = (AliVParticle*) list->At(i);
419     
420     Double_t vars[6];
421     vars[0] = particle->Eta();
422     vars[1] = particle->Pt();
423     vars[2] = leading->Pt();
424     vars[3] = multiplicity;
425     vars[4] = leading->Phi() - particle->Phi();
426     if (vars[4] > 1.5 * TMath::Pi()) 
427       vars[4] -= TMath::TwoPi();
428     if (vars[4] < -0.5 * TMath::Pi())
429       vars[4] += TMath::TwoPi();
430     vars[5] = zVtx;
431     
432     if (fNumberDensitypT)
433       fNumberDensitypT->GetTrackHist(region)->Fill(vars, step);
434       
435     if (fSumpT)
436       fSumpT->GetTrackHist(region)->Fill(vars, step, particle->Pt());
437     
438     // fill all in toward region (is anyway as function of delta phi!)
439     if (fNumberDensityPhi)
440       fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step);
441   }
442 }
443
444 //____________________________________________________________________
445 void AliUEHistograms::Fill(AliVParticle* leadingMC, AliVParticle* leadingReco)
446 {
447   // fills the correlation histograms
448   
449   if (leadingMC)
450   {
451     fCorrelationpT->Fill(leadingMC->Pt(), leadingReco->Pt());
452     if (leadingMC->Pt() > 0.5)
453     {
454       fCorrelationEta->Fill(leadingMC->Eta(), leadingReco->Eta());
455       fCorrelationPhi->Fill(leadingMC->Phi(), leadingReco->Phi());
456     }
457     
458     Float_t phiDiff = leadingMC->Phi() - leadingReco->Phi();
459     if (phiDiff > TMath::Pi())
460       phiDiff -= TMath::TwoPi();
461     if (phiDiff < -TMath::Pi())
462       phiDiff += TMath::TwoPi();
463       
464     Float_t etaDiff = leadingMC->Eta() - leadingReco->Eta();
465     
466     fCorrelationR->Fill(TMath::Sqrt(phiDiff * phiDiff + etaDiff * etaDiff), leadingMC->Pt());
467     fCorrelationLeading2Phi->Fill(phiDiff, leadingMC->Pt());
468   }
469   else
470   {
471     fCorrelationpT->Fill(1.0, leadingReco->Pt());
472     if (leadingReco->Pt() > 0.5)
473     {
474       fCorrelationEta->Fill(0.0, leadingReco->Eta());
475       fCorrelationPhi->Fill(0.0, leadingReco->Phi());
476     }
477   }
478 }
479
480 //____________________________________________________________________
481 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)
482 {
483   // fills the fNumberDensityPhi histogram
484   //
485   // this function need a list of AliVParticles which contain the particles/tracks to be filled
486   //
487   // if mixed is non-0, mixed events are filled, the trigger particle is from particles, the associated from mixed
488   // if weight < 0, then the pt of the associated particle is filled as weight
489   
490   Bool_t fillpT = kFALSE;
491   if (weight < 0)
492     fillpT = kTRUE;
493   
494   if (twoTrackEfficiencyCut && !fTwoTrackDistancePt[0])
495   {
496     // do not add this hists to the directory
497     Bool_t oldStatus = TH1::AddDirectoryStatus();
498     TH1::AddDirectory(kFALSE);
499
500     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);
501     fTwoTrackDistancePt[1] = (TH3F*) fTwoTrackDistancePt[0]->Clone("fTwoTrackDistancePt[1]");
502
503     TH1::AddDirectory(oldStatus);
504   }
505
506   // Eta() is extremely time consuming, therefore cache it for the inner loop here:
507   TObjArray* input = (mixed) ? mixed : particles;
508   TArrayF eta(input->GetEntriesFast());
509   for (Int_t i=0; i<input->GetEntriesFast(); i++)
510     eta[i] = ((AliVParticle*) input->At(i))->Eta();
511   
512   // if particles is not set, just fill event statistics
513   if (particles)
514   {
515     Int_t jMax = particles->GetEntriesFast();
516     if (mixed)
517       jMax = mixed->GetEntriesFast();
518     
519     TH1* triggerWeighting = 0;
520     if (fWeightPerEvent)
521     {
522       TAxis* axis = fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->GetGrid(0)->GetGrid()->GetAxis(2);
523       triggerWeighting = new TH1F("triggerWeighting", "", axis->GetNbins(), axis->GetXbins()->GetArray());
524     
525       for (Int_t i=0; i<particles->GetEntriesFast(); i++)
526       {
527         AliVParticle* triggerParticle = (AliVParticle*) particles->At(i);
528         
529         // some optimization
530         Float_t triggerEta = triggerParticle->Eta();
531
532         if (fTriggerRestrictEta > 0 && TMath::Abs(triggerEta) > fTriggerRestrictEta)
533           continue;
534
535         if (fOnlyOneEtaSide != 0)
536         {
537           if (fOnlyOneEtaSide * triggerEta < 0)
538             continue;
539         }
540         
541         if (fTriggerSelectCharge != 0)
542           if (triggerParticle->Charge() * fTriggerSelectCharge < 0)
543             continue;
544         
545         triggerWeighting->Fill(triggerParticle->Pt());
546       }
547 //       new TCanvas; triggerWeighting->Draw();
548     }
549     
550     for (Int_t i=0; i<particles->GetEntriesFast(); i++)
551     {
552       AliVParticle* triggerParticle = (AliVParticle*) particles->At(i);
553       
554       // some optimization
555       Float_t triggerEta = triggerParticle->Eta();
556       
557       if (fTriggerRestrictEta > 0 && TMath::Abs(triggerEta) > fTriggerRestrictEta)
558         continue;
559
560       if (fOnlyOneEtaSide != 0)
561       {
562         if (fOnlyOneEtaSide * triggerEta < 0)
563           continue;
564       }
565       
566       if (fTriggerSelectCharge != 0)
567         if (triggerParticle->Charge() * fTriggerSelectCharge < 0)
568           continue;
569
570       if (!mixed)
571       {
572         // QA
573         fCorrelationpT->Fill(centrality, triggerParticle->Pt());
574         fCorrelationEta->Fill(centrality, triggerEta);
575         fCorrelationPhi->Fill(centrality, triggerParticle->Phi());
576         fYields->Fill(centrality, triggerParticle->Pt(), triggerEta);
577 /*        if (dynamic_cast<AliAODTrack*>(triggerParticle))
578           fITSClusterMap->Fill(((AliAODTrack*) triggerParticle)->GetITSClusterMap(), centrality, triggerParticle->Pt());*/
579       }
580         
581       for (Int_t j=0; j<jMax; j++)
582       {
583         if (!mixed && i == j)
584           continue;
585       
586         AliVParticle* particle = 0;
587         if (!mixed)
588           particle = (AliVParticle*) particles->At(j);
589         else
590           particle = (AliVParticle*) mixed->At(j);
591         
592         // check if both particles point to the same element (does not occur for mixed events, but if subsets are mixed within the same event for cross-checks)
593         if (mixed && triggerParticle == particle)
594           continue;
595         
596         if (particle->Pt() > triggerParticle->Pt())
597           continue;
598           
599         if (fSelectCharge > 0)
600         {
601           // skip like sign
602           if (fSelectCharge == 1 && particle->Charge() * triggerParticle->Charge() > 0)
603             continue;
604             
605           // skip unlike sign
606           if (fSelectCharge == 2 && particle->Charge() * triggerParticle->Charge() < 0)
607             continue;
608         }
609         
610         if (fEtaOrdering)
611         {
612           if (triggerEta < 0 && eta[j] < triggerEta)
613             continue;
614           if (triggerEta > 0 && eta[j] > triggerEta)
615             continue;
616         }
617
618         // conversions
619         if (fCutConversions && particle->Charge() * triggerParticle->Charge() < 0)
620         {
621           Float_t mass = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.510e-3, 0.510e-3);
622           
623           fControlConvResoncances->Fill(0.0, mass);
624
625           if (mass < 0.04*0.04) 
626             continue;
627         }
628         
629         // K0s
630         if (fCutResonances && particle->Charge() * triggerParticle->Charge() < 0)
631         {
632           Float_t mass = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.1396);
633           
634           const Float_t kK0smass = 0.4976;
635           
636           fControlConvResoncances->Fill(1, mass - kK0smass*kK0smass);
637
638           if (mass > (kK0smass-0.02)*(kK0smass-0.02) && mass < (kK0smass+0.02)*(kK0smass+0.02))
639             continue;
640         }
641         
642         // Lambda
643         if (fCutResonances && particle->Charge() * triggerParticle->Charge() < 0)
644         {
645           Float_t mass1 = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.1396, 0.9383);
646           Float_t mass2 = GetInvMassSquared(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), particle->Pt(), eta[j], particle->Phi(), 0.9383, 0.1396);
647           
648           const Float_t kLambdaMass = 1.115;
649
650           fControlConvResoncances->Fill(2, mass1 - kLambdaMass*kLambdaMass);
651           fControlConvResoncances->Fill(2, mass2 - kLambdaMass*kLambdaMass);
652
653           if ((mass1 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass1 < (kLambdaMass+0.02)*(kLambdaMass+0.02)) || 
654               (mass2 > (kLambdaMass-0.02)*(kLambdaMass-0.02) && mass2 < (kLambdaMass+0.02)*(kLambdaMass+0.02)))
655             continue;
656         }
657
658         if (twoTrackEfficiencyCut)
659         {
660           // the variables & cuthave been developed by the HBT group 
661           // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
662
663           Float_t phi1 = triggerParticle->Phi();
664           Float_t pt1 = triggerParticle->Pt();
665           Float_t charge1 = triggerParticle->Charge();
666             
667           Float_t phi2 = particle->Phi();
668           Float_t pt2 = particle->Pt();
669           Float_t charge2 = particle->Charge();
670               
671           Float_t deta = triggerEta - eta[j];
672               
673           // optimization
674           if (TMath::Abs(deta) < twoTrackEfficiencyCutValue * 2.5 * 3)
675           {
676             // check first boundaries to see if is worth to loop and find the minimum
677             Float_t dphistar1 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 0.8, bSign);
678             Float_t dphistar2 = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, 2.5, bSign);
679             
680             const Float_t kLimit = twoTrackEfficiencyCutValue * 3;
681
682             Float_t dphistarminabs = 1e5;
683             Float_t dphistarmin = 1e5;
684             if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0)
685             {
686               for (Double_t rad=0.8; rad<2.51; rad+=0.01) 
687               {
688                 Float_t dphistar = GetDPhiStar(phi1, pt1, charge1, phi2, pt2, charge2, rad, bSign);
689
690                 Float_t dphistarabs = TMath::Abs(dphistar);
691                 
692                 if (dphistarabs < dphistarminabs)
693                 {
694                   dphistarmin = dphistar;
695                   dphistarminabs = dphistarabs;
696                 }
697               }
698               
699               fTwoTrackDistancePt[0]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
700               
701               if (dphistarminabs < twoTrackEfficiencyCutValue && TMath::Abs(deta) < twoTrackEfficiencyCutValue)
702               {
703 //              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);
704                 continue;
705               }
706
707               fTwoTrackDistancePt[1]->Fill(deta, dphistarmin, TMath::Abs(pt1 - pt2));
708             }
709           }
710         }
711         
712         Double_t vars[6];
713         vars[0] = triggerEta - eta[j];
714         vars[1] = particle->Pt();
715         vars[2] = triggerParticle->Pt();
716         vars[3] = centrality;
717         vars[4] = triggerParticle->Phi() - particle->Phi();
718         if (vars[4] > 1.5 * TMath::Pi()) 
719           vars[4] -= TMath::TwoPi();
720         if (vars[4] < -0.5 * TMath::Pi())
721           vars[4] += TMath::TwoPi();
722         vars[5] = zVtx;
723         
724         if (fillpT)
725           weight = particle->Pt();
726         
727         Double_t useWeight = weight;
728         if (fEfficiencyCorrection && applyEfficiency)
729         {
730           Int_t effVars[4];
731           
732           // associated particle
733           effVars[0] = fEfficiencyCorrection->GetAxis(0)->FindBin(eta[j]);
734           effVars[1] = fEfficiencyCorrection->GetAxis(1)->FindBin(vars[1]); //pt
735           effVars[2] = fEfficiencyCorrection->GetAxis(2)->FindBin(vars[3]); //centrality
736           effVars[3] = fEfficiencyCorrection->GetAxis(3)->FindBin(vars[5]); //zVtx
737           
738 //        Printf("%d %d %d %d %f", effVars[0], effVars[1], effVars[2], effVars[3], fEfficiencyCorrection->GetBinContent(effVars));
739           
740           useWeight *= fEfficiencyCorrection->GetBinContent(effVars);
741           
742           // trigger particle
743           if (fCorrectTriggers)
744           {
745             effVars[0] = fEfficiencyCorrection->GetAxis(0)->FindBin(triggerEta);
746             effVars[1] = fEfficiencyCorrection->GetAxis(1)->FindBin(vars[2]); //pt
747             useWeight *= fEfficiencyCorrection->GetBinContent(effVars);
748           }
749         }
750         
751         if (fWeightPerEvent)
752         {
753           Int_t weightBin = triggerWeighting->GetXaxis()->FindBin(vars[2]);
754 //        Printf("Using weight %f", triggerWeighting->GetBinContent(weightBin));
755           useWeight /= triggerWeighting->GetBinContent(weightBin);
756         }
757     
758         // fill all in toward region and do not use the other regions
759         fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step, useWeight);
760         
761 //      Printf("%.2f %.2f --> %.2f", triggerEta, eta[j], vars[0]);
762       }
763  
764       if (firstTime)
765       {
766         // once per trigger particle
767         Double_t vars[3];
768         vars[0] = triggerParticle->Pt();
769         vars[1] = centrality;
770         vars[2] = zVtx;
771
772         Double_t useWeight = 1;
773         if (fEfficiencyCorrection && applyEfficiency && fCorrectTriggers)
774         {
775           Int_t effVars[4];
776           
777           // trigger particle
778           effVars[0] = fEfficiencyCorrection->GetAxis(0)->FindBin(triggerEta);
779           effVars[1] = fEfficiencyCorrection->GetAxis(1)->FindBin(vars[0]); //pt
780           effVars[2] = fEfficiencyCorrection->GetAxis(2)->FindBin(vars[1]); //centrality
781           effVars[3] = fEfficiencyCorrection->GetAxis(3)->FindBin(vars[2]); //zVtx
782           useWeight *= fEfficiencyCorrection->GetBinContent(effVars);
783         }
784         
785         fNumberDensityPhi->GetEventHist()->Fill(vars, step, useWeight);
786       }
787     }
788     
789     if (triggerWeighting)
790     {
791       delete triggerWeighting;
792       triggerWeighting = 0;
793     }
794   }
795   
796   fCentralityDistribution->Fill(centrality);
797   fCentralityCorrelation->Fill(centrality, particles->GetEntriesFast());
798   FillEvent(centrality, step);
799 }
800   
801 //____________________________________________________________________
802 void AliUEHistograms::FillTrackingEfficiency(TObjArray* mc, TObjArray* recoPrim, TObjArray* recoAll, TObjArray* fake, Int_t particleType, Double_t centrality, Double_t zVtx)
803 {
804   // fills the tracking efficiency objects
805   //
806   // mc: all primary MC particles
807   // recoPrim: reconstructed primaries (again MC particles)
808   // recoAll: reconstructed (again MC particles)
809   // particleType is: 0 for pion, 1 for kaon, 2 for proton, 3 for others
810  
811   for (Int_t step=0; step<4; step++)
812   {
813     TObjArray* list = mc;
814     if (step == 1)
815       list = recoPrim;
816     else if (step == 2)
817       list = recoAll;
818     else if (step == 3)
819       list = fake;
820     
821     if (!list)
822       continue;
823
824     for (Int_t i=0; i<list->GetEntriesFast(); i++)
825     {
826       AliVParticle* particle = (AliVParticle*) list->At(i);
827       Double_t vars[5];
828       vars[0] = particle->Eta();
829       vars[1] = particle->Pt();
830       vars[2] = particleType;
831       vars[3] = centrality;
832       vars[4] = zVtx;
833       
834       for (Int_t j=0; j<fgkUEHists; j++)
835         if (GetUEHist(j))
836           GetUEHist(j)->GetTrackHistEfficiency()->Fill(vars, step);
837     }
838   }
839 }
840
841 //____________________________________________________________________
842 void AliUEHistograms::FillFakePt(TObjArray* fake, Double_t centrality)
843 {
844   TObjArray* tracksReco = (TObjArray*) fake->At(0);
845   TObjArray* tracksMC = (TObjArray*) fake->At(1);
846   
847   if (tracksReco->GetEntriesFast() != tracksMC->GetEntriesFast())
848     AliFatal(Form("Inconsistent arrays: %d vs %d", tracksReco->GetEntriesFast(), tracksMC->GetEntriesFast()));
849   
850   for (Int_t i=0; i<tracksReco->GetEntriesFast(); i++)
851   {
852     AliVParticle* particle1 = (AliVParticle*) tracksReco->At(i);
853     AliVParticle* particle2 = (AliVParticle*) tracksMC->At(i);
854     Double_t vars[3];
855     vars[0] = particle1->Pt();
856     vars[1] = particle2->Pt();
857     vars[2] = centrality;
858     for (Int_t j=0; j<fgkUEHists; j++)
859       if (GetUEHist(j))
860         GetUEHist(j)->GetMCRecoPtCorrelation()->Fill(vars[0],vars[1],vars[2]);
861   }
862 }
863
864 //____________________________________________________________________
865 void AliUEHistograms::FillEvent(Int_t eventType, Int_t step)
866 {
867   // fills the number of events at the given step and the given enty type
868   //
869   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
870   
871   fEventCount->Fill(step, eventType);
872 }
873
874 //____________________________________________________________________
875 void AliUEHistograms::FillEvent(Double_t centrality, Int_t step)
876 {
877   // fills the number of events at the given step and the given centrality
878   //
879   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
880   
881   fEventCount->Fill(step, centrality);
882 }
883
884 //____________________________________________________________________
885 void AliUEHistograms::SetEtaRange(Float_t etaMin, Float_t etaMax)
886 {
887   // sets eta min and max for all contained AliUEHist classes
888   
889   for (Int_t i=0; i<fgkUEHists; i++)
890     if (GetUEHist(i))
891       GetUEHist(i)->SetEtaRange(etaMin, etaMax);
892 }
893
894 //____________________________________________________________________
895 void AliUEHistograms::SetPtRange(Float_t ptMin, Float_t ptMax)
896 {
897   // sets pT min and max for all contained AliUEHist classes
898   
899   for (Int_t i=0; i<fgkUEHists; i++)
900     if (GetUEHist(i))
901       GetUEHist(i)->SetPtRange(ptMin, ptMax);
902 }
903
904 //____________________________________________________________________
905 void AliUEHistograms::SetZVtxRange(Float_t min, Float_t max)
906 {
907   // sets pT min and max for all contained AliUEHist classes
908   
909   for (Int_t i=0; i<fgkUEHists; i++)
910     if (GetUEHist(i))
911       GetUEHist(i)->SetZVtxRange(min, max);
912 }
913
914 //____________________________________________________________________
915 void AliUEHistograms::SetContaminationEnhancement(TH1F* hist)
916 {
917   // sets the contamination enhancement histogram in all contained AliUEHist classes
918   
919   for (Int_t i=0; i<fgkUEHists; i++)
920     if (GetUEHist(i))
921       GetUEHist(i)->SetContaminationEnhancement(hist);
922 }  
923
924 //____________________________________________________________________
925 void AliUEHistograms::SetCombineMinMax(Bool_t flag)
926 {
927   // sets pT min and max for all contained AliUEHist classes
928   
929   for (Int_t i=0; i<fgkUEHists; i++)
930     if (GetUEHist(i))
931       GetUEHist(i)->SetCombineMinMax(flag);
932 }
933
934 //____________________________________________________________________
935 void AliUEHistograms::SetTrackEtaCut(Float_t value)
936 {
937   // sets track eta cut for all contained AliUEHist classes
938   
939   for (Int_t i=0; i<fgkUEHists; i++)
940     if (GetUEHist(i))
941       GetUEHist(i)->SetTrackEtaCut(value);
942 }
943
944 //____________________________________________________________________
945 void AliUEHistograms::Correct(AliUEHistograms* corrections)
946 {
947   // corrects the contained histograms by calling AliUEHist::Correct
948   
949   for (Int_t i=0; i<fgkUEHists; i++)
950     if (GetUEHist(i))
951       GetUEHist(i)->Correct(corrections->GetUEHist(i));
952 }
953
954 //____________________________________________________________________
955 AliUEHistograms &AliUEHistograms::operator=(const AliUEHistograms &c)
956 {
957   // assigment operator
958
959   DeleteContainers();
960
961   if (this != &c)
962     ((AliUEHistograms &) c).Copy(*this);
963
964   return *this;
965 }
966
967 //____________________________________________________________________
968 void AliUEHistograms::Copy(TObject& c) const
969 {
970   // copy function
971
972   AliUEHistograms& target = (AliUEHistograms &) c;
973
974   if (fNumberDensitypT)
975     target.fNumberDensitypT = dynamic_cast<AliUEHist*> (fNumberDensitypT->Clone());
976
977   if (fSumpT)
978     target.fSumpT = dynamic_cast<AliUEHist*> (fSumpT->Clone());
979
980   if (fNumberDensityPhi)
981     target.fNumberDensityPhi = dynamic_cast<AliUEHist*> (fNumberDensityPhi->Clone());
982
983   if (fCorrelationpT)
984     target.fCorrelationpT = dynamic_cast<TH2F*> (fCorrelationpT->Clone());
985
986   if (fCorrelationEta)
987     target.fCorrelationEta = dynamic_cast<TH2F*> (fCorrelationEta->Clone());
988
989   if (fCorrelationPhi)
990     target.fCorrelationPhi = dynamic_cast<TH2F*> (fCorrelationPhi->Clone());
991
992   if (fCorrelationR)
993     target.fCorrelationR = dynamic_cast<TH2F*> (fCorrelationR->Clone());
994
995   if (fCorrelationLeading2Phi)
996     target.fCorrelationLeading2Phi = dynamic_cast<TH2F*> (fCorrelationLeading2Phi->Clone());
997
998   if (fCorrelationMultiplicity)
999     target.fCorrelationMultiplicity = dynamic_cast<TH2F*> (fCorrelationMultiplicity->Clone());
1000   
1001   if (fYields)
1002     target.fYields = dynamic_cast<TH3F*> (fYields->Clone());
1003   
1004   if (fEventCount)
1005     target.fEventCount = dynamic_cast<TH2F*> (fEventCount->Clone());
1006
1007   if (fEventCountDifferential)
1008     target.fEventCountDifferential = dynamic_cast<TH3F*> (fEventCountDifferential->Clone());
1009     
1010   if (fVertexContributors)
1011     target.fVertexContributors = dynamic_cast<TH1F*> (fVertexContributors->Clone());
1012
1013   if (fCentralityDistribution)
1014     target.fCentralityDistribution = dynamic_cast<TH1F*> (fCentralityDistribution->Clone());
1015     
1016   if (fCentralityCorrelation)
1017     target.fCentralityCorrelation = dynamic_cast<TH2F*> (fCentralityCorrelation->Clone());
1018
1019   if (fITSClusterMap)
1020     target.fITSClusterMap = dynamic_cast<TH3F*> (fITSClusterMap->Clone());
1021   
1022   if (fControlConvResoncances)
1023     target.fControlConvResoncances = dynamic_cast<TH2F*> (fControlConvResoncances->Clone());
1024   
1025   for (Int_t i=0; i<2; i++)
1026     if (fTwoTrackDistancePt[i])
1027       target.fTwoTrackDistancePt[i] = dynamic_cast<TH3F*> (fTwoTrackDistancePt[i]->Clone());
1028
1029   if (fEfficiencyCorrection)
1030     target.fEfficiencyCorrection = dynamic_cast<THnF*> (fEfficiencyCorrection->Clone());
1031     
1032   target.fSelectCharge = fSelectCharge;
1033   target.fTriggerSelectCharge = fTriggerSelectCharge;
1034   target.fTriggerRestrictEta = fTriggerRestrictEta;
1035   target.fEtaOrdering = fEtaOrdering;
1036   target.fCutConversions = fCutConversions;
1037   target.fCutResonances = fCutResonances;
1038   target.fOnlyOneEtaSide = fOnlyOneEtaSide;
1039   target.fWeightPerEvent = fWeightPerEvent;
1040   target.fRunNumber = fRunNumber;
1041   target.fMergeCount = fMergeCount;
1042   target.fCorrectTriggers = fCorrectTriggers;
1043 }
1044
1045 //____________________________________________________________________
1046 Long64_t AliUEHistograms::Merge(TCollection* list)
1047 {
1048   // Merge a list of AliUEHistograms objects with this (needed for
1049   // PROOF). 
1050   // Returns the number of merged objects (including this).
1051
1052   if (!list)
1053     return 0;
1054   
1055   if (list->IsEmpty())
1056     return 1;
1057
1058   TIterator* iter = list->MakeIterator();
1059   TObject* obj;
1060
1061   // collections of objects
1062   const Int_t kMaxLists = 19;
1063   TList* lists[kMaxLists];
1064   
1065   for (Int_t i=0; i<kMaxLists; i++)
1066     lists[i] = new TList;
1067   
1068   Int_t count = 0;
1069   while ((obj = iter->Next())) {
1070     
1071     AliUEHistograms* entry = dynamic_cast<AliUEHistograms*> (obj);
1072     if (entry == 0) 
1073       continue;
1074
1075     if (entry->fNumberDensitypT)
1076       lists[0]->Add(entry->fNumberDensitypT);
1077     if (entry->fSumpT)
1078       lists[1]->Add(entry->fSumpT);
1079     if (entry->fNumberDensityPhi)
1080       lists[2]->Add(entry->fNumberDensityPhi);
1081     lists[3]->Add(entry->fCorrelationpT);
1082     lists[4]->Add(entry->fCorrelationEta);
1083     lists[5]->Add(entry->fCorrelationPhi);
1084     lists[6]->Add(entry->fCorrelationR);
1085     lists[7]->Add(entry->fCorrelationLeading2Phi);
1086     lists[8]->Add(entry->fCorrelationMultiplicity);
1087     lists[9]->Add(entry->fEventCount);
1088     lists[10]->Add(entry->fEventCountDifferential);
1089     lists[11]->Add(entry->fVertexContributors);
1090     lists[12]->Add(entry->fCentralityDistribution);
1091     lists[13]->Add(entry->fITSClusterMap);
1092     if (entry->fTwoTrackDistancePt[0])
1093       lists[14]->Add(entry->fTwoTrackDistancePt[0]);
1094     if (entry->fTwoTrackDistancePt[1])
1095       lists[15]->Add(entry->fTwoTrackDistancePt[1]);
1096     if (entry->fCentralityCorrelation)
1097       lists[16]->Add(entry->fCentralityCorrelation);
1098     if (entry->fYields)
1099       lists[17]->Add(entry->fYields);
1100     if (entry->fControlConvResoncances)
1101       lists[18]->Add(entry->fControlConvResoncances);
1102
1103     fMergeCount += entry->fMergeCount;
1104
1105     count++;
1106   }
1107     
1108   if (fNumberDensitypT)
1109     fNumberDensitypT->Merge(lists[0]);
1110   if (fSumpT)
1111     fSumpT->Merge(lists[1]);
1112   if (fNumberDensityPhi)
1113     fNumberDensityPhi->Merge(lists[2]);
1114   fCorrelationpT->Merge(lists[3]);
1115   fCorrelationEta->Merge(lists[4]);
1116   fCorrelationPhi->Merge(lists[5]);
1117   fCorrelationR->Merge(lists[6]);
1118   fCorrelationLeading2Phi->Merge(lists[7]);
1119   fCorrelationMultiplicity->Merge(lists[8]);
1120   fEventCount->Merge(lists[9]);
1121   fEventCountDifferential->Merge(lists[10]);
1122   fVertexContributors->Merge(lists[11]);
1123   fCentralityDistribution->Merge(lists[12]);
1124   fITSClusterMap->Merge(lists[13]);
1125   if (fTwoTrackDistancePt[0] && lists[14]->GetEntries() > 0)
1126     fTwoTrackDistancePt[0]->Merge(lists[14]);
1127   if (fTwoTrackDistancePt[1] && lists[15]->GetEntries() > 0)
1128     fTwoTrackDistancePt[1]->Merge(lists[15]);
1129   if (fCentralityCorrelation)
1130     fCentralityCorrelation->Merge(lists[16]);
1131   if (fYields && lists[17]->GetEntries() > 0)
1132     fYields->Merge(lists[17]);
1133   if (fControlConvResoncances && lists[18]->GetEntries() > 0)
1134     fControlConvResoncances->Merge(lists[18]);
1135   
1136   for (Int_t i=0; i<kMaxLists; i++)
1137     delete lists[i];
1138   
1139   return count+1;
1140 }
1141
1142 void AliUEHistograms::CopyReconstructedData(AliUEHistograms* from)
1143 {
1144   // copies those histograms extracted from ESD to this object
1145   
1146   for (Int_t i=0; i<fgkUEHists; i++)
1147     if (GetUEHist(i))
1148       GetUEHist(i)->CopyReconstructedData(from->GetUEHist(i));
1149 }
1150
1151 void AliUEHistograms::DeepCopy(AliUEHistograms* from)
1152 {
1153   // copies the entries of this object's members from the object <from> to this object
1154
1155   for (Int_t i=0; i<fgkUEHists; i++)
1156     if (GetUEHist(i) && from->GetUEHist(i))
1157       GetUEHist(i)->DeepCopy(from->GetUEHist(i));
1158 }
1159
1160 void AliUEHistograms::ExtendTrackingEfficiency(Bool_t verbose)
1161 {
1162   // delegates to AliUEHists
1163
1164   for (Int_t i=0; i<fgkUEHists; i++)
1165     if (GetUEHist(i))
1166       GetUEHist(i)->ExtendTrackingEfficiency(verbose);
1167 }
1168
1169 void AliUEHistograms::Scale(Double_t factor)
1170 {
1171   // scales all contained histograms by the given factor
1172   
1173   for (Int_t i=0; i<fgkUEHists; i++)
1174     if (GetUEHist(i))
1175       GetUEHist(i)->Scale(factor);
1176       
1177   TList list;
1178   list.Add(fCorrelationpT);
1179   list.Add(fCorrelationEta);
1180   list.Add(fCorrelationPhi);
1181   list.Add(fCorrelationR);
1182   list.Add(fCorrelationLeading2Phi);
1183   list.Add(fCorrelationMultiplicity);
1184   list.Add(fYields);
1185   list.Add(fEventCount);
1186   list.Add(fEventCountDifferential);
1187   list.Add(fVertexContributors);
1188   list.Add(fCentralityDistribution);
1189   list.Add(fCentralityCorrelation);
1190   list.Add(fITSClusterMap);
1191   list.Add(fTwoTrackDistancePt[0]);
1192   list.Add(fTwoTrackDistancePt[1]);
1193   list.Add(fControlConvResoncances);
1194   
1195   for (Int_t i=0; i<list.GetEntries(); i++)
1196     ((TH1*) list.At(i))->Scale(factor);
1197 }
1198
1199 void AliUEHistograms::Reset()
1200 {
1201   // delegates to AliUEHists
1202
1203   for (Int_t i=0; i<fgkUEHists; i++)
1204     if (GetUEHist(i))
1205       GetUEHist(i)->Reset();
1206 }
1207
1208 Float_t AliUEHistograms::GetInvMassSquared(Float_t pt1, Float_t eta1, Float_t phi1, Float_t pt2, Float_t eta2, Float_t phi2, Float_t m0_1, Float_t m0_2)
1209 {
1210   // calculate inv mass squared
1211   // same can be achieved, but with more computing time with
1212   /*TLorentzVector photon, p1, p2;
1213   p1.SetPtEtaPhiM(triggerParticle->Pt(), triggerEta, triggerParticle->Phi(), 0.510e-3);
1214   p2.SetPtEtaPhiM(particle->Pt(), eta[j], particle->Phi(), 0.510e-3);
1215   photon = p1+p2;
1216   photon.M()*/
1217   
1218   Float_t tantheta1 = 1e10;
1219   
1220   if (eta1 < -1e-10 || eta1 > 1e-10)
1221     tantheta1 = 2 * TMath::Exp(-eta1) / ( 1 - TMath::Exp(-2*eta1));
1222   
1223   Float_t tantheta2 = 1e10;
1224   if (eta2 < -1e-10 || eta2 > 1e-10)
1225     tantheta2 = 2 * TMath::Exp(-eta2) / ( 1 - TMath::Exp(-2*eta2));
1226   
1227   Float_t e1squ = m0_1 * m0_1 + pt1 * pt1 * (1.0 + 1.0 / tantheta1 / tantheta1);
1228   Float_t e2squ = m0_2 * m0_2 + pt2 * pt2 * (1.0 + 1.0 / tantheta2 / tantheta2);
1229   
1230   Float_t mass2 = m0_1 * m0_1 + m0_2 * m0_2 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( pt1 * pt2 * ( TMath::Cos(phi1 - phi2) + 1.0 / tantheta1 / tantheta2 ) ) );
1231   
1232   return mass2;
1233 }