]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/JetTasks/AliUEHistograms.cxx
3767136a5471af810e12a2886dc5b533e905fc94
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / 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 "TH2F.h"
33 #include "TH1F.h"
34 #include "TH3F.h"
35 #include "TMath.h"
36
37 ClassImp(AliUEHistograms)
38
39 const Int_t AliUEHistograms::fgkUEHists = 3;
40
41 AliUEHistograms::AliUEHistograms(const char* name, const char* histograms) : 
42   TNamed(name, name),
43   fNumberDensitypT(0),
44   fSumpT(0),
45   fNumberDensityPhi(0),
46   fCorrelationpT(0),
47   fCorrelationEta(0),
48   fCorrelationPhi(0),
49   fCorrelationR(0),
50   fCorrelationLeading2Phi(0),
51   fCorrelationMultiplicity(0),
52   fEventCount(0),
53   fEventCountDifferential(0),
54   fVertexContributors(0),
55   fCentralityDistribution(0),
56   fITSClusterMap(0),
57   fSelectCharge(0),
58   fRunNumber(0)
59 {
60   // Constructor
61   //
62   // the string histograms defines which histograms are created:
63   //    1 = NumberDensitypT
64   //    2 = SumpT
65   //    3 = NumberDensityPhi
66   //    4 = NumberDensityPhiCentrality (other multiplicity for Pb)
67   
68   TString histogramsStr(histograms);
69   
70   if (histogramsStr.Contains("1"))
71     fNumberDensitypT = new AliUEHist("NumberDensitypT");
72   if (histogramsStr.Contains("2"))
73     fSumpT = new AliUEHist("SumpT");
74   
75   if (histogramsStr.Contains("3"))
76     fNumberDensityPhi = new AliUEHist("NumberDensityPhi");
77   else if (histogramsStr.Contains("4"))
78     fNumberDensityPhi = new AliUEHist("NumberDensityPhiCentrality");
79   
80   // do not add this hists to the directory
81   Bool_t oldStatus = TH1::AddDirectoryStatus();
82   TH1::AddDirectory(kFALSE);
83   
84   if (!histogramsStr.Contains("4"))
85   {
86     fCorrelationpT  = new TH2F("fCorrelationpT", ";p_{T,lead} (MC);p_{T,lead} (RECO)", 200, 0, 50, 200, 0, 50);
87     fCorrelationEta = new TH2F("fCorrelationEta", ";#eta_{lead} (MC);#eta_{T,lead} (RECO)", 200, -1, 1, 200, -1, 1);
88     fCorrelationPhi = new TH2F("fCorrelationPhi", ";#phi_{lead} (MC);#phi_{T,lead} (RECO)", 200, 0, TMath::TwoPi(), 200, 0, TMath::TwoPi());
89   }
90   else
91   {
92     fCorrelationpT  = new TH2F("fCorrelationpT", ";Centrality;p_{T} (RECO)", 100, 0, 100.001, 200, 0, 50);
93     fCorrelationEta = new TH2F("fCorrelationEta", ";Centrality;#eta (RECO)", 100, 0, 100.001, 200, -1, 1);
94     fCorrelationPhi = new TH2F("fCorrelationPhi", ";Centrality;#phi (RECO)", 100, 0, 100.001, 200, 0, TMath::TwoPi());
95   }
96   
97   fCorrelationR =   new TH2F("fCorrelationR", ";R;p_{T,lead} (MC)", 200, 0, 2, 200, 0, 50);
98   fCorrelationLeading2Phi = new TH2F("fCorrelationLeading2Phi", ";#Delta #phi;p_{T,lead} (MC)", 200, -TMath::Pi(), TMath::Pi(), 200, 0, 50);
99   fCorrelationMultiplicity = new TH2F("fCorrelationMultiplicity", ";MC tracks;Reco tracks", 100, -0.5, 99.5, 100, -0.5, 99.5);
100   
101   if (!histogramsStr.Contains("4"))
102   {
103     fEventCount = new TH2F("fEventCount", ";step;event type;count", AliUEHist::fgkCFSteps+2, -2.5, -0.5 + AliUEHist::fgkCFSteps, 3, -0.5, 2.5);
104     fEventCount->GetYaxis()->SetBinLabel(1, "ND");
105     fEventCount->GetYaxis()->SetBinLabel(2, "SD");
106     fEventCount->GetYaxis()->SetBinLabel(3, "DD");
107   }
108   else
109   {
110     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());
111   }
112   
113   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);
114   fEventCountDifferential->GetZaxis()->SetBinLabel(1, "ND");
115   fEventCountDifferential->GetZaxis()->SetBinLabel(2, "SD");
116   fEventCountDifferential->GetZaxis()->SetBinLabel(3, "DD");
117   
118   fVertexContributors = new TH1F("fVertexContributors", ";contributors;count", 100, -0.5, 99.5);
119   
120   if (fNumberDensityPhi)
121     fCentralityDistribution = new TH1F("fCentralityDistribution", ";;count", fNumberDensityPhi->GetEventHist()->GetNBins(1), fNumberDensityPhi->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray());
122   
123   fITSClusterMap = new TH3F("fITSClusterMap", "; its cluster map; centrality; pT", 256, -0.5, 255.5, 20, 0, 100.001, 100, 0, 20);
124   
125   TH1::AddDirectory(oldStatus);
126 }
127
128 //_____________________________________________________________________________
129 AliUEHistograms::AliUEHistograms(const AliUEHistograms &c) :
130   TNamed(fName, fTitle),
131   fNumberDensitypT(0),
132   fSumpT(0),
133   fNumberDensityPhi(0),
134   fCorrelationpT(0),
135   fCorrelationEta(0),
136   fCorrelationPhi(0),
137   fCorrelationR(0),
138   fCorrelationLeading2Phi(0),
139   fCorrelationMultiplicity(0),
140   fEventCount(0),
141   fEventCountDifferential(0),
142   fVertexContributors(0),
143   fCentralityDistribution(0),
144   fITSClusterMap(0),
145   fSelectCharge(0),
146   fRunNumber(0)
147 {
148   //
149   // AliUEHistograms copy constructor
150   //
151
152   ((AliUEHistograms &) c).Copy(*this);
153 }
154
155 //____________________________________________________________________
156 AliUEHistograms::~AliUEHistograms()
157 {
158   // Destructor
159   
160   if (fNumberDensitypT)
161   {
162     delete fNumberDensitypT;
163     fNumberDensitypT = 0;
164   }
165   
166   if (fSumpT)
167   {
168     delete fSumpT;
169     fSumpT = 0;
170   }
171   
172   if (fNumberDensityPhi)
173   {
174     delete fNumberDensityPhi;
175     fNumberDensityPhi = 0;
176   }
177   
178   if (fCorrelationpT)
179   {
180     delete fCorrelationpT;
181     fCorrelationpT = 0;
182   }
183   
184   if (fCorrelationEta)
185   {
186     delete fCorrelationEta;
187     fCorrelationEta = 0;
188   }
189   
190   if (fCorrelationPhi)
191   {
192     delete fCorrelationPhi;
193     fCorrelationPhi = 0;
194   }
195   
196   if (fCorrelationR)
197   {
198     delete fCorrelationR;
199     fCorrelationR = 0;
200   }
201
202   if (fCorrelationLeading2Phi)
203   {
204     delete fCorrelationLeading2Phi;
205     fCorrelationLeading2Phi = 0;
206   }
207   
208   if (fCorrelationMultiplicity)
209   {
210     delete fCorrelationMultiplicity;
211     fCorrelationMultiplicity = 0;
212   }
213   
214   if (fEventCount)
215   {
216     delete fEventCount;
217     fEventCount = 0;
218   }
219
220   if (fEventCountDifferential)
221   {
222     delete fEventCountDifferential;
223     fEventCountDifferential = 0;
224   }
225   
226   if (fVertexContributors)
227   {
228     delete fVertexContributors;
229     fVertexContributors = 0;
230   }
231   
232   if (fCentralityDistribution)
233   {
234     delete fCentralityDistribution;
235     fCentralityDistribution = 0;
236   }
237   
238   if (fITSClusterMap)
239   {
240     delete fITSClusterMap;
241     fITSClusterMap = 0;
242   }
243 }
244
245 AliUEHist* AliUEHistograms::GetUEHist(Int_t id)
246 {
247   // returns AliUEHist object, useful for loops
248   
249   switch (id)
250   {
251     case 0: return fNumberDensitypT; break;
252     case 1: return fSumpT; break;
253     case 2: return fNumberDensityPhi; break;
254   }
255   
256   return 0;
257 }
258
259 //____________________________________________________________________
260 Int_t AliUEHistograms::CountParticles(TList* list, Float_t ptMin)
261 {
262   // counts the number of particles in the list with a pT above ptMin
263   // TODO eta cut needed here?
264   
265   Int_t count = 0;
266   for (Int_t j=0; j<list->GetEntries(); j++)
267     if (((AliVParticle*) list->At(j))->Pt() > ptMin)
268       count++;
269       
270   return count;
271 }
272   
273 //____________________________________________________________________
274 void AliUEHistograms::Fill(Int_t eventType, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* toward, TList* away, TList* min, TList* max)
275 {
276   // fills the UE event histograms
277   //
278   // 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
279   
280   // if leading is not set, just fill event statistics
281   if (leading)
282   {
283     Int_t multiplicity = 0;
284     
285     // TODO configurable?
286     Float_t ptMin = 0.15;
287     if (leading->Pt() > ptMin)
288       multiplicity++;
289     
290     multiplicity += CountParticles(toward, ptMin);
291     multiplicity += CountParticles(away, ptMin);
292     multiplicity += CountParticles(min, ptMin);
293     multiplicity += CountParticles(max, ptMin);
294      
295     FillRegion(AliUEHist::kToward, zVtx, step, leading, toward, multiplicity);
296     FillRegion(AliUEHist::kAway,   zVtx, step, leading, away, multiplicity);
297     FillRegion(AliUEHist::kMin,    zVtx, step, leading, min, multiplicity);
298     FillRegion(AliUEHist::kMax,    zVtx, step, leading, max, multiplicity);
299  
300     Double_t vars[3];
301     vars[0] = leading->Pt();
302     vars[1] = multiplicity;
303     vars[2] = zVtx;
304     for (Int_t i=0; i<fgkUEHists; i++)
305       if (GetUEHist(i))
306         GetUEHist(i)->GetEventHist()->Fill(vars, step);
307   
308     fEventCountDifferential->Fill(leading->Pt(), step, eventType);
309   }
310   
311   FillEvent(eventType, step);
312 }
313   
314 //____________________________________________________________________
315 void AliUEHistograms::FillRegion(AliUEHist::Region region, Float_t zVtx, AliUEHist::CFStep step, AliVParticle* leading, TList* list, Int_t multiplicity)
316 {
317   // loops over AliVParticles in list and fills the given region at the given step
318   //
319   // See also Fill(...)
320
321   for (Int_t i=0; i<list->GetEntries(); i++)
322   {
323     AliVParticle* particle = (AliVParticle*) list->At(i);
324     
325     Double_t vars[6];
326     vars[0] = particle->Eta();
327     vars[1] = particle->Pt();
328     vars[2] = leading->Pt();
329     vars[3] = multiplicity;
330     vars[4] = leading->Phi() - particle->Phi();
331     if (vars[4] > 1.5 * TMath::Pi()) 
332       vars[4] -= TMath::TwoPi();
333     if (vars[4] < -0.5 * TMath::Pi())
334       vars[4] += TMath::TwoPi();
335     vars[5] = zVtx;
336     
337     if (fNumberDensitypT)
338       fNumberDensitypT->GetTrackHist(region)->Fill(vars, step);
339       
340     if (fSumpT)
341       fSumpT->GetTrackHist(region)->Fill(vars, step, particle->Pt());
342     
343     // fill all in toward region (is anyway as function of delta phi!)
344     if (fNumberDensityPhi)
345       fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step);
346   }
347 }
348
349 //____________________________________________________________________
350 void AliUEHistograms::Fill(AliVParticle* leadingMC, AliVParticle* leadingReco)
351 {
352   // fills the correlation histograms
353   
354   if (leadingMC)
355   {
356     fCorrelationpT->Fill(leadingMC->Pt(), leadingReco->Pt());
357     if (leadingMC->Pt() > 0.5)
358     {
359       fCorrelationEta->Fill(leadingMC->Eta(), leadingReco->Eta());
360       fCorrelationPhi->Fill(leadingMC->Phi(), leadingReco->Phi());
361     }
362     
363     Float_t phiDiff = leadingMC->Phi() - leadingReco->Phi();
364     if (phiDiff > TMath::Pi())
365       phiDiff -= TMath::TwoPi();
366     if (phiDiff < -TMath::Pi())
367       phiDiff += TMath::TwoPi();
368       
369     Float_t etaDiff = leadingMC->Eta() - leadingReco->Eta();
370     
371     fCorrelationR->Fill(TMath::Sqrt(phiDiff * phiDiff + etaDiff * etaDiff), leadingMC->Pt());
372     fCorrelationLeading2Phi->Fill(phiDiff, leadingMC->Pt());
373   }
374   else
375   {
376     fCorrelationpT->Fill(1.0, leadingReco->Pt());
377     if (leadingReco->Pt() > 0.5)
378     {
379       fCorrelationEta->Fill(0.0, leadingReco->Eta());
380       fCorrelationPhi->Fill(0.0, leadingReco->Phi());
381     }
382   }
383 }
384
385 //____________________________________________________________________
386 void AliUEHistograms::FillCorrelations(Double_t centrality, Float_t zVtx, AliUEHist::CFStep step, TObjArray* particles, TObjArray* mixed, Float_t weight, Bool_t firstTime)
387 {
388   // fills the fNumberDensityPhi histogram
389   //
390   // this function need a list of AliVParticles which contain the particles/tracks to be filled
391   //
392   // if mixed is non-0, mixed events are filled, the trigger particle is from particles, the associated from mixed
393   
394   // Eta() is extremely time consuming, therefore cache it for the inner loop here:
395   TObjArray* input = (mixed) ? mixed : particles;
396   TArrayF eta(input->GetEntriesFast());
397   for (Int_t i=0; i<input->GetEntriesFast(); i++)
398     eta[i] = ((AliVParticle*) input->At(i))->Eta();
399   
400   // if particles is not set, just fill event statistics
401   if (particles)
402   {
403     Int_t jMax = particles->GetEntriesFast();
404     if (mixed)
405       jMax = mixed->GetEntriesFast();
406     
407     for (Int_t i=0; i<particles->GetEntriesFast(); i++)
408     {
409       AliVParticle* triggerParticle = (AliVParticle*) particles->At(i);
410       
411       // some optimization
412       Float_t triggerEta = triggerParticle->Eta();
413         
414       if (!mixed)
415       {
416         // QA
417         fCorrelationpT->Fill(centrality, triggerParticle->Pt());
418         fCorrelationEta->Fill(centrality, triggerEta);
419         fCorrelationPhi->Fill(centrality, triggerParticle->Phi());
420 /*        if (dynamic_cast<AliAODTrack*>(triggerParticle))
421           fITSClusterMap->Fill(((AliAODTrack*) triggerParticle)->GetITSClusterMap(), centrality, triggerParticle->Pt());*/
422       }
423         
424       for (Int_t j=0; j<jMax; j++)
425       {
426         if (!mixed && i == j)
427           continue;
428       
429         AliVParticle* particle = 0;
430         if (!mixed)
431           particle = (AliVParticle*) particles->At(j);
432         else
433           particle = (AliVParticle*) mixed->At(j);
434         
435         // 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)
436         if (mixed && triggerParticle == particle)
437           continue;
438         
439         if (particle->Pt() > triggerParticle->Pt())
440           continue;
441           
442         if (fSelectCharge > 0)
443         {
444           // skip like sign
445           if (fSelectCharge == 1 && particle->Charge() * triggerParticle->Charge() > 0)
446             continue;
447             
448           // skip unlike sign
449           if (fSelectCharge == 2 && particle->Charge() * triggerParticle->Charge() < 0)
450             continue;
451         }
452         
453         Double_t vars[6];
454         vars[0] = triggerEta - eta[j];
455         vars[1] = particle->Pt();
456         vars[2] = triggerParticle->Pt();
457         vars[3] = centrality;
458         vars[4] = triggerParticle->Phi() - particle->Phi();
459         if (vars[4] > 1.5 * TMath::Pi()) 
460           vars[4] -= TMath::TwoPi();
461         if (vars[4] < -0.5 * TMath::Pi())
462           vars[4] += TMath::TwoPi();
463         vars[5] = zVtx;
464     
465         // fill all in toward region and do not use the other regions
466         fNumberDensityPhi->GetTrackHist(AliUEHist::kToward)->Fill(vars, step, weight);
467       }
468  
469       if (firstTime)
470       {
471         // once per trigger particle
472         Double_t vars[3];
473         vars[0] = triggerParticle->Pt();
474         vars[1] = centrality;
475         vars[2] = zVtx;
476         fNumberDensityPhi->GetEventHist()->Fill(vars, step);
477       }
478     }
479   }
480   
481   fCentralityDistribution->Fill(centrality);
482   FillEvent(centrality, step);
483 }
484   
485 //____________________________________________________________________
486 void AliUEHistograms::FillTrackingEfficiency(TObjArray* mc, TObjArray* recoPrim, TObjArray* recoAll, Int_t particleType, Double_t centrality)
487 {
488   // fills the tracking efficiency objects
489   //
490   // mc: all primary MC particles
491   // recoPrim: reconstructed primaries (again MC particles)
492   // recoAll: reconstructed (again MC particles)
493   // particleType is: 0 for pion, 1 for kaon, 2 for proton, 3 for others
494   
495   for (Int_t step=0; step<3; step++)
496   {
497     TObjArray* list = mc;
498     if (step == 1)
499       list = recoPrim;
500     else if (step == 2)
501       list = recoAll;
502       
503     for (Int_t i=0; i<list->GetEntriesFast(); i++)
504     {
505       AliVParticle* particle = (AliVParticle*) list->At(i);
506       Double_t vars[4];
507       vars[0] = particle->Eta();
508       vars[1] = particle->Pt();
509       vars[2] = particleType;
510       vars[3] = centrality;
511       
512       for (Int_t j=0; j<fgkUEHists; j++)
513         if (GetUEHist(j))
514           GetUEHist(j)->GetTrackHistEfficiency()->Fill(vars, step);
515     }
516   }
517 }
518
519 //____________________________________________________________________
520 void AliUEHistograms::FillEvent(Int_t eventType, Int_t step)
521 {
522   // fills the number of events at the given step and the given enty type
523   //
524   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
525   
526   fEventCount->Fill(step, eventType);
527 }
528
529 //____________________________________________________________________
530 void AliUEHistograms::FillEvent(Double_t centrality, Int_t step)
531 {
532   // fills the number of events at the given step and the given centrality
533   //
534   // WARNING: This function is called from Fill, so only call it for steps where Fill is not called
535   
536   fEventCount->Fill(step, centrality);
537 }
538
539 //____________________________________________________________________
540 void AliUEHistograms::SetEtaRange(Float_t etaMin, Float_t etaMax)
541 {
542   // sets eta min and max for all contained AliUEHist classes
543   
544   for (Int_t i=0; i<fgkUEHists; i++)
545     if (GetUEHist(i))
546       GetUEHist(i)->SetEtaRange(etaMin, etaMax);
547 }
548
549 //____________________________________________________________________
550 void AliUEHistograms::SetPtRange(Float_t ptMin, Float_t ptMax)
551 {
552   // sets pT min and max for all contained AliUEHist classes
553   
554   for (Int_t i=0; i<fgkUEHists; i++)
555     if (GetUEHist(i))
556       GetUEHist(i)->SetPtRange(ptMin, ptMax);
557 }
558
559 //____________________________________________________________________
560 void AliUEHistograms::SetZVtxRange(Float_t min, Float_t max)
561 {
562   // sets pT min and max for all contained AliUEHist classes
563   
564   for (Int_t i=0; i<fgkUEHists; i++)
565     if (GetUEHist(i))
566       GetUEHist(i)->SetZVtxRange(min, max);
567 }
568
569 //____________________________________________________________________
570 void AliUEHistograms::SetContaminationEnhancement(TH1F* hist)
571 {
572   // sets the contamination enhancement histogram in all contained AliUEHist classes
573   
574   for (Int_t i=0; i<fgkUEHists; i++)
575     if (GetUEHist(i))
576       GetUEHist(i)->SetContaminationEnhancement(hist);
577 }  
578
579 //____________________________________________________________________
580 void AliUEHistograms::SetCombineMinMax(Bool_t flag)
581 {
582   // sets pT min and max for all contained AliUEHist classes
583   
584   for (Int_t i=0; i<fgkUEHists; i++)
585     if (GetUEHist(i))
586       GetUEHist(i)->SetCombineMinMax(flag);
587 }
588
589 //____________________________________________________________________
590 void AliUEHistograms::Correct(AliUEHistograms* corrections)
591 {
592   // corrects the contained histograms by calling AliUEHist::Correct
593   
594   for (Int_t i=0; i<fgkUEHists; i++)
595     if (GetUEHist(i))
596       GetUEHist(i)->Correct(corrections->GetUEHist(i));
597 }
598
599 //____________________________________________________________________
600 AliUEHistograms &AliUEHistograms::operator=(const AliUEHistograms &c)
601 {
602   // assigment operator
603
604   if (this != &c)
605     ((AliUEHistograms &) c).Copy(*this);
606
607   return *this;
608 }
609
610 //____________________________________________________________________
611 void AliUEHistograms::Copy(TObject& c) const
612 {
613   // copy function
614
615   AliUEHistograms& target = (AliUEHistograms &) c;
616
617   if (fNumberDensitypT)
618     target.fNumberDensitypT = dynamic_cast<AliUEHist*> (fNumberDensitypT->Clone());
619
620   if (fSumpT)
621     target.fSumpT = dynamic_cast<AliUEHist*> (fSumpT->Clone());
622
623   if (fNumberDensityPhi)
624     target.fNumberDensityPhi = dynamic_cast<AliUEHist*> (fNumberDensityPhi->Clone());
625
626   if (fCorrelationpT)
627     target.fCorrelationpT = dynamic_cast<TH2F*> (fCorrelationpT->Clone());
628
629   if (fCorrelationEta)
630     target.fCorrelationEta = dynamic_cast<TH2F*> (fCorrelationEta->Clone());
631
632   if (fCorrelationPhi)
633     target.fCorrelationPhi = dynamic_cast<TH2F*> (fCorrelationPhi->Clone());
634
635   if (fCorrelationR)
636     target.fCorrelationR = dynamic_cast<TH2F*> (fCorrelationR->Clone());
637
638   if (fCorrelationLeading2Phi)
639     target.fCorrelationLeading2Phi = dynamic_cast<TH2F*> (fCorrelationLeading2Phi->Clone());
640
641   if (fCorrelationMultiplicity)
642     target.fCorrelationMultiplicity = dynamic_cast<TH2F*> (fCorrelationMultiplicity->Clone());
643   
644   if (fEventCount)
645     target.fEventCount = dynamic_cast<TH2F*> (fEventCount->Clone());
646
647   if (fEventCountDifferential)
648     target.fEventCountDifferential = dynamic_cast<TH3F*> (fEventCountDifferential->Clone());
649     
650   if (fVertexContributors)
651     target.fVertexContributors = dynamic_cast<TH1F*> (fVertexContributors->Clone());
652
653   if (fCentralityDistribution)
654     target.fCentralityDistribution = dynamic_cast<TH1F*> (fCentralityDistribution->Clone());
655     
656   if (fITSClusterMap)
657     target.fITSClusterMap = dynamic_cast<TH3F*> (fITSClusterMap->Clone());
658     
659   target.fSelectCharge = fSelectCharge;
660   target.fRunNumber = fRunNumber;
661 }
662
663 //____________________________________________________________________
664 Long64_t AliUEHistograms::Merge(TCollection* list)
665 {
666   // Merge a list of AliUEHistograms objects with this (needed for
667   // PROOF). 
668   // Returns the number of merged objects (including this).
669
670   if (!list)
671     return 0;
672   
673   if (list->IsEmpty())
674     return 1;
675
676   TIterator* iter = list->MakeIterator();
677   TObject* obj;
678
679   // collections of objects
680   const Int_t kMaxLists = 14;
681   TList* lists[kMaxLists];
682   
683   for (Int_t i=0; i<kMaxLists; i++)
684     lists[i] = new TList;
685   
686   Int_t count = 0;
687   while ((obj = iter->Next())) {
688     
689     AliUEHistograms* entry = dynamic_cast<AliUEHistograms*> (obj);
690     if (entry == 0) 
691       continue;
692
693     if (entry->fNumberDensitypT)
694       lists[0]->Add(entry->fNumberDensitypT);
695     if (entry->fSumpT)
696       lists[1]->Add(entry->fSumpT);
697     if (entry->fNumberDensityPhi)
698       lists[2]->Add(entry->fNumberDensityPhi);
699     lists[3]->Add(entry->fCorrelationpT);
700     lists[4]->Add(entry->fCorrelationEta);
701     lists[5]->Add(entry->fCorrelationPhi);
702     lists[6]->Add(entry->fCorrelationR);
703     lists[7]->Add(entry->fCorrelationLeading2Phi);
704     lists[8]->Add(entry->fCorrelationMultiplicity);
705     lists[9]->Add(entry->fEventCount);
706     lists[10]->Add(entry->fEventCountDifferential);
707     lists[11]->Add(entry->fVertexContributors);
708     lists[12]->Add(entry->fCentralityDistribution);
709     lists[13]->Add(entry->fITSClusterMap);
710
711     count++;
712   }
713     
714   if (fNumberDensitypT)
715     fNumberDensitypT->Merge(lists[0]);
716   if (fSumpT)
717     fSumpT->Merge(lists[1]);
718   if (fNumberDensityPhi)
719     fNumberDensityPhi->Merge(lists[2]);
720   fCorrelationpT->Merge(lists[3]);
721   fCorrelationEta->Merge(lists[4]);
722   fCorrelationPhi->Merge(lists[5]);
723   fCorrelationR->Merge(lists[6]);
724   fCorrelationLeading2Phi->Merge(lists[7]);
725   fCorrelationMultiplicity->Merge(lists[8]);
726   fEventCount->Merge(lists[9]);
727   fEventCountDifferential->Merge(lists[10]);
728   fVertexContributors->Merge(lists[11]);
729   fCentralityDistribution->Merge(lists[12]);
730   fITSClusterMap->Merge(lists[13]);
731   
732   for (Int_t i=0; i<kMaxLists; i++)
733     delete lists[i];
734
735   return count+1;
736 }
737
738 void AliUEHistograms::CopyReconstructedData(AliUEHistograms* from)
739 {
740   // copies those histograms extracted from ESD to this object
741   
742   for (Int_t i=0; i<fgkUEHists; i++)
743     if (GetUEHist(i))
744       GetUEHist(i)->CopyReconstructedData(from->GetUEHist(i));
745 }
746
747 void AliUEHistograms::ExtendTrackingEfficiency(Bool_t verbose)
748 {
749   // delegates to AliUEHists
750
751   for (Int_t i=0; i<fgkUEHists; i++)
752     if (GetUEHist(i))
753       GetUEHist(i)->ExtendTrackingEfficiency(verbose);
754 }
755
756 void AliUEHistograms::Scale(Double_t factor)
757 {
758   // scales all contained histograms by the given factor
759   
760   for (Int_t i=0; i<fgkUEHists; i++)
761     if (GetUEHist(i))
762       GetUEHist(i)->Scale(factor);
763       
764   TList list;
765   list.Add(fCorrelationpT);
766   list.Add(fCorrelationEta);
767   list.Add(fCorrelationPhi);
768   list.Add(fCorrelationR);
769   list.Add(fCorrelationLeading2Phi);
770   list.Add(fCorrelationMultiplicity);
771   list.Add(fEventCount);
772   list.Add(fEventCountDifferential);
773   list.Add(fVertexContributors);
774   list.Add(fCentralityDistribution);
775   list.Add(fITSClusterMap);
776   
777   for (Int_t i=0; i<list.GetEntries(); i++)
778     ((TH1*) list.At(i))->Scale(factor);
779 }
780
781 void AliUEHistograms::Reset()
782 {
783   // delegates to AliUEHists
784
785   for (Int_t i=0; i<fgkUEHists; i++)
786     if (GetUEHist(i))
787       GetUEHist(i)->Reset();
788 }