]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/Base/AliTwoPlusOneContainer.cxx
2+1 analysis update from Markus
[u/mrichter/AliRoot.git] / PWGCF / Correlations / Base / AliTwoPlusOneContainer.cxx
CommitLineData
c9ae910e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//
17//
18// encapsulates several AliUEHist objects for a full UE analysis plus additional control histograms
19// the method FillCorrelations is the only method which fills the container
20// associated particles are filled once for each near side and once for each away side
21// the pT 2 for the near side particles is set to the highest pT of all accepted away side pT 2
22// as consequence the pT 2 axis can only be cut for the minimum
23// if the maximum of the axis should be changed the full analysis needs to rerun
24//
25//
26// Author: Markus Zimmermann
27//
28
29
30#include "AliTwoPlusOneContainer.h"
31
fbee6f27 32#include "TList.h"
33
c9ae910e 34#include "AliCFContainer.h"
35#include "AliVParticle.h"
36
37#include "TH1F.h"
7db96852 38#include "TH2F.h"
c9ae910e 39#include "TMath.h"
40
41ClassImp(AliTwoPlusOneContainer)
42
5a516e0a 43AliTwoPlusOneContainer::AliTwoPlusOneContainer(const char* name, const char* binning, Double_t alpha) :
c9ae910e 44 TNamed(name, name),
45 fTwoPlusOne(0),
7db96852 46 fAsymmetry(0),
47 fAsymmetryMixed(0),
48 fTriggerPt(0),
c9ae910e 49 fTriggerPt1Min(0),
50 fTriggerPt1Max(0),
51 fTriggerPt2Min(0),
52 fTriggerPt2Max(0),
53 fPtAssocMin(0),
54 fPtAssocMax(0),
fbee6f27 55 fAlpha(alpha),
5a9d8759 56 fUseLeadingPt(1),
fbee6f27 57 fMergeCount(0)
c9ae910e 58{
59 // Constructor
60 //
61 TString defaultBinningStr;
62 defaultBinningStr = "eta: -1.0, 1.0\n"//needs to be defined for AliUEHist
63 "p_t_assoc: 0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0\n"
64 "p_t_leading: 6.0, 8.0, 10.0, 12.0, 14.0\n"
65 "p_t_leading_course: 4.0, 6.0, 8.0, 10.0\n"
66 "p_t_eff: 0.5, 8.0\n"//needs to be defined for AliUEHist
67 "vertex_eff: -10, 10\n"//needs to be defined for AliUEHist
68 "multiplicity: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1\n"
69 "vertex: -7, -5, -3, -1, 1, 3, 5, 7\n"
70 "delta_phi: -1.570796, -1.396263, -1.221730, -1.047197, -0.872664, -0.698131, -0.523598, -0.349065, -0.174532, 0.0, 0.174532, 0.349065, 0.523598, 0.698131, 0.872664, 1.047197, 1.221730, 1.396263, 1.570796, 1.745329, 1.919862, 2.094395, 2.268928, 2.443460, 2.617993, 2.792526, 2.967059, 3.141592, 3.316125, 3.490658, 3.665191, 3.839724, 4.014257, 4.188790, 4.363323, 4.537856, 4.712388\n" // this binning starts at -pi/2 and it ends at +3pi/2, it has 36 bins
48c9fd73 71 "delta_eta: -1.8, -1.6, -1.4, -1.2, -1.0, -0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8\n";
c9ae910e 72
73 // combine customBinning with defaultBinningStr -> use customBinning where available and otherwise defaultBinningStr
74 TString binningStr = AliUEHist::CombineBinning(defaultBinningStr, TString(binning));
75
76 fTwoPlusOne = new AliUEHist("TwoPlusOne", binningStr);
77
78 //set minimum and maximum trigger pt values
79 fTriggerPt1Min = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(2)->GetXmin();
80 fTriggerPt1Max = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(2)->GetXmax();
81 fTriggerPt2Min = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(6)->GetXmin();
82 fTriggerPt2Max = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(6)->GetXmax();
83 fPtAssocMin = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(1)->GetXmin();
84 fPtAssocMax = fTwoPlusOne->GetTrackHist(AliUEHist::kToward)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS)->GetAxis(1)->GetXmax();
7db96852 85
86 fAsymmetry = new TH1F("fAsymmetry", ";A;dN", 50, 0, 1);
87 fAsymmetryMixed = new TH1F("fAsymmetryMixed", ";A;dN", 50, 0, 1);
88 Int_t pt1_bins = (fTriggerPt1Max - fTriggerPt1Min)/0.1;
89 Int_t pt2_bins = (fTriggerPt2Max - fTriggerPt2Min)/0.1;
90 fTriggerPt = new TH2F("fTriggerPt", ";p_{T,1};p_{T,2}", pt1_bins, fTriggerPt1Min, fTriggerPt1Max, pt2_bins, fTriggerPt2Min, fTriggerPt2Max);
91
c9ae910e 92 TH1::AddDirectory();
93}
94
95//_____________________________________________________________________________
96AliTwoPlusOneContainer::AliTwoPlusOneContainer(const AliTwoPlusOneContainer &c) :
97 TNamed(fName, fTitle),
98 fTwoPlusOne(0),
7db96852 99 fAsymmetry(0),
100 fAsymmetryMixed(0),
101 fTriggerPt(0),
c9ae910e 102 fTriggerPt1Min(0),
103 fTriggerPt1Max(0),
104 fTriggerPt2Min(0),
105 fTriggerPt2Max(0),
106 fPtAssocMin(0),
107 fPtAssocMax(0),
fbee6f27 108 fAlpha(0.2),
109 fMergeCount(0)
c9ae910e 110{
111 //
112 // AliTwoPlusOneContainer copy constructor
113 //
114
115 ((AliTwoPlusOneContainer &) c).Copy(*this);
116 fTriggerPt1Min = ((AliTwoPlusOneContainer &) c).getTriggerPt1Min();
117 fTriggerPt1Max = ((AliTwoPlusOneContainer &) c).getTriggerPt1Max();
118 fTriggerPt2Min = ((AliTwoPlusOneContainer &) c).getTriggerPt2Min();
119 fTriggerPt2Max = ((AliTwoPlusOneContainer &) c).getTriggerPt2Max();
120 fPtAssocMin = ((AliTwoPlusOneContainer &) c).getPtAssocMin();
121 fPtAssocMax = ((AliTwoPlusOneContainer &) c).getPtAssocMax();
fbee6f27 122 fAlpha = ((AliTwoPlusOneContainer &) c).fAlpha;
123 fMergeCount = ((AliTwoPlusOneContainer &) c).fMergeCount;
c9ae910e 124}
125
126//____________________________________________________________________
127AliTwoPlusOneContainer::~AliTwoPlusOneContainer()
128{
129 // Destructor
130
131 DeleteContainers();
132}
133
134//____________________________________________________________________
135void AliTwoPlusOneContainer::DeleteContainers()
136{
137 if (fTwoPlusOne)
138 {
139 delete fTwoPlusOne;
140 fTwoPlusOne = 0;
141 }
7db96852 142
143 if(fAsymmetry)
144 {
145 delete fAsymmetry;
146 fAsymmetry = 0;
147 }
148
149 if(fAsymmetryMixed)
150 {
151 delete fAsymmetryMixed;
152 fAsymmetryMixed = 0;
153 }
154
155 if(fTriggerPt)
156 {
157 delete fTriggerPt;
158 fTriggerPt = 0;
159 }
c9ae910e 160}
161
162
163//____________________________________________________________________
9e4f78aa 164void AliTwoPlusOneContainer::FillCorrelations(Double_t centrality, Float_t zVtx, AliTwoPlusOneContainer::PlotKind step, TObjArray* triggerNear, TObjArray* triggerAway, TObjArray* assocNear, TObjArray* assocAway, Double_t weight, Bool_t is1plus1, Bool_t isBackgroundSame)
c9ae910e 165{
166 //Fill Correlations fills the UEHist fTwoPlusOne with the 2+1 correlation
167 //the input variables centrality and zVtx are the centrality and the z vertex of the event
168 //the 4 lists triggerNear, triggerAway, assocNear and assocAway are four lists of particles. For the same event analysis all for lists are identical. For the mixed event analysis assocNear and assocAway are from different events as the trigger lists and for the mixed combinatorics triggerNear and assocNear are from one event and triggerAway and assocAway are from another event.
169
170 AliCFContainer* track_hist = fTwoPlusOne->GetTrackHist(AliUEHist::kToward);
171 AliCFContainer* event_hist = fTwoPlusOne->GetEventHist();
172 AliUEHist::CFStep stepUEHist = static_cast<AliUEHist::CFStep>(step);
173
9e4f78aa 174 //in case of the computation of the background in the same event there are two possible positions: delta phi = +/- pi/2
175 //both positions are used so the results could only be weighted with 0.5*weight
176 if(isBackgroundSame)
177 weight *= 0.5;
178
c9ae910e 179 for (Int_t i=0; i<triggerNear->GetEntriesFast(); i++){
180 AliVParticle* part = (AliVParticle*) triggerNear->UncheckedAt(i);
181
182 Double_t part_pt = part->Pt();
183 if(part_pt<fTriggerPt1Min || part_pt>fTriggerPt1Max)
184 continue;
185
186 Double_t part_eta = part->Eta();
187 Double_t part_phi = part->Phi();
188
189 //search for second trigger particle
190 //entries is the number of particles in the event, so there can only be less particles within the trigger 2 conditions
191 Int_t ind_found = 0;
192 Int_t ind_max_found_pt = -1;
193 Int_t triggerAway_entries = triggerAway->GetEntriesFast();
194 AliVParticle* found_particle[triggerAway_entries];
195
5a9d8759 196 Bool_t do_not_use_T1 = false;
197
481980c3 198 //in case only the leading pt of a jet should be used, check every particle on the trigger near side if it's closer than alpha and if it has a higher pt than trigger 1
199 if(fUseLeadingPt){
200 for (Int_t i2=0; i2<triggerNear->GetEntriesFast(); i2++){
201 if(i==i2)
202 continue;
203
204 AliVParticle* part_i2 = (AliVParticle*) triggerNear->UncheckedAt(i2);
205
206 if(part_i2->Pt()<=part_pt)
207 continue;
208
209 Double_t dphi_check = part_phi-part_i2->Phi();
210 if(dphi_check>1.5*TMath::Pi()) dphi_check -= TMath::TwoPi();
211 else if(dphi_check<-0.5*TMath::Pi()) dphi_check += TMath::TwoPi();
212
213 if(TMath::Abs(dphi_check)<fAlpha){
214 do_not_use_T1 = true;
215 break;
216 }
217 }
218 }
219
220 //if there is a particle with higher energy than T1 closer than alpha to T1, do not use this T1
221 if(do_not_use_T1)
222 continue;
223
1baafa70 224 //have to fake the away side triggers for the 1+1 analysis
225 if(is1plus1){
226 found_particle[ind_found] = part;//in 1plus1 use first trigger particle also as pseudo second trigger particle
227 ind_max_found_pt = ind_found;
228 ind_found = 1;
229 }else{
230 //normal 2+1 analysis
231 for (Int_t j=0; j<triggerAway_entries; j++){
232 AliVParticle* part2 = (AliVParticle*) triggerAway->UncheckedAt(j);
233
234 Double_t part2_pt = part2->Pt();
5a9d8759 235 //check if pT of trigger 2 has enough energy to be a trigger
236 //maximum energy is checked later after checking this particle may have to much energy for trigger 1 or 2
237 if(part2_pt<fTriggerPt2Min)
1baafa70 238 continue;
5a9d8759 239
1baafa70 240 // don't use the same particle (is in any case impossible because the Delta phi angle will be 0)
241 if(part==part2){
242 continue;
243 }
c9ae910e 244
1baafa70 245 Double_t dphi_triggers = part_phi-part2->Phi();
1baafa70 246 if(dphi_triggers>1.5*TMath::Pi()) dphi_triggers -= TMath::TwoPi();
247 else if(dphi_triggers<-0.5*TMath::Pi()) dphi_triggers += TMath::TwoPi();
9e4f78aa 248
1baafa70 249 //if 2+1 analysis check if trigger particles have a delta phi = pi +/- alpha
250 if(!isBackgroundSame)
251 dphi_triggers -= TMath::Pi();
252 else if(isBackgroundSame){
253 //shift defined area of delta phi
254 if(dphi_triggers>TMath::Pi()) dphi_triggers -= TMath::TwoPi();
9e4f78aa 255
1baafa70 256 //look at delta phi = +/- pi/2
257 if(dphi_triggers<0)
258 dphi_triggers += 0.5*TMath::Pi();
259 else if(dphi_triggers>0)
260 dphi_triggers -= 0.5*TMath::Pi();
261 }
262 if(TMath::Abs(dphi_triggers)>fAlpha)
263 continue;
264
5a9d8759 265 //check if pT of trigger 2 is too high
266 if(part2_pt>fTriggerPt2Max || part2_pt>part_pt){
481980c3 267 //pt of trigger 2 needs to be smaller than the pt of trigger 1 (to have an ordering if both pt are close to each other)
5a9d8759 268 if(fUseLeadingPt){
269 do_not_use_T1 = true;
270 break;
271 }else
272 continue;
273 }
274
1baafa70 275 found_particle[ind_found] = part2;
276 if(ind_max_found_pt==-1 || part2_pt>found_particle[ind_max_found_pt]->Pt()) ind_max_found_pt = ind_found;
277 ind_found++;
278 }//end loop to search for the second trigger particle
279 }
c9ae910e 280
5a9d8759 281 //if there is a particle with higher energy than T1 or max(T2) within Delta phi = pi +/- alpha to T1, do not use this T1
282 if(do_not_use_T1)
283 continue;
284
c9ae910e 285 //if no second trigger particle was found continue to search for the next first trigger particle
286 if(ind_found==0)
287 continue;
288
481980c3 289 //use only the highest energetic particle on the away side, if there is only 1 away side trigger this is already the case
290 if(fUseLeadingPt && ind_found>1){
291 found_particle[0] = found_particle[ind_max_found_pt];
292 ind_found=1;
293 ind_max_found_pt = 0;
294 }
295
c9ae910e 296 //the energy of the second trigger particle is set for the near side to the maximum energy of all trigger 2 particles on the away side
297 // this leads to the fact that the number of accepted trigger combinations can be artificial smaller than the real number if there is a cut on the pT 2 energy from the top; cutting away the smallest energy of pT 2 is still save; this is the reason why it is not allowed to use a cut on the top pt of trigger particle 2
298 //fill trigger particles
299 if(ind_found>0){
481980c3 300 Double_t vars[4];
301 vars[0] = part_pt;
302 vars[1] = centrality;
303 vars[2] = zVtx;
304 vars[3] = found_particle[ind_max_found_pt]->Pt();
305 if(is1plus1)
306 vars[3] = (fTriggerPt2Max+fTriggerPt2Min)/2;
307
308 event_hist->Fill(vars, stepUEHist, weight);//near side
309
310 if(!is1plus1)
311 for(Int_t k=0; k< ind_found; k++){
312 vars[3] = found_particle[k]->Pt();
313 event_hist->Fill(vars, stepUEHist+1, weight);//away side
314 }
7db96852 315
481980c3 316 //fill fTriggerPt only once, choosed kSameNS
317 if(step==AliTwoPlusOneContainer::kSameNS)
318 for(Int_t k=0; k< ind_found; k++)
319 fTriggerPt->Fill(part_pt, found_particle[k]->Pt());
320
321 //fill asymmetry only for kSameNS and kMixedNS
322 if(step==AliTwoPlusOneContainer::kSameNS||step==AliTwoPlusOneContainer::kMixedNS){
323 for(Int_t k=0; k< ind_found; k++){
324 Float_t asymmetry = (part_pt-found_particle[k]->Pt())/(part_pt+found_particle[k]->Pt());
325 if(step==AliTwoPlusOneContainer::kSameNS){
326 fAsymmetry->Fill(asymmetry);
327 }else{
328 fAsymmetryMixed->Fill(asymmetry);
7db96852 329 }
330 }
481980c3 331 }
c9ae910e 332 }
481980c3 333
c9ae910e 334 //add correlated particles on the near side
335 for (Int_t k=0; k<assocNear->GetEntriesFast(); k++){
336 AliVParticle* part3 = (AliVParticle*) assocNear->UncheckedAt(k);
337
338 Double_t part3_pt = part3->Pt();
339 if(part3_pt<fPtAssocMin || part3_pt>fPtAssocMax)
340 continue;
341
342 //do not add the trigger 1 particle
343 if(part==part3)
344 continue;
345
346 //do not add the trigger 2 particle
347 if(found_particle[ind_max_found_pt]==part3)
348 continue;
349
350 Double_t dphi_near = part_phi-part3->Phi();
351 if(dphi_near>1.5*TMath::Pi()) dphi_near -= TMath::TwoPi();
352 else if(dphi_near<-0.5*TMath::Pi()) dphi_near += TMath::TwoPi();
353
354 Double_t deta_near = part_eta-part3->Eta();
355
356 Double_t vars[7];
357 vars[0] = deta_near;
358 vars[1] = part3_pt;
359 vars[2] = part_pt;
360 vars[3] = centrality;
361 vars[4] = dphi_near;
362 vars[5] = zVtx;
363 vars[6] = found_particle[ind_max_found_pt]->Pt();
2cfcbf43 364 if(is1plus1)
365 vars[6] = (fTriggerPt2Max+fTriggerPt2Min)/2;
c9ae910e 366
367 track_hist->Fill(vars, stepUEHist, weight);
368 }
369
1baafa70 370 //search only for the distribution of the 2nd trigger particle
371 if(is1plus1)
372 continue;
373
c9ae910e 374 //add correlated particles on the away side
375 for (Int_t k=0; k<assocAway->GetEntriesFast(); k++){
376 AliVParticle* part3 = (AliVParticle*) assocAway->UncheckedAt(k);
377
378 Double_t part3_pt = part3->Pt();
379 if(part3_pt<fPtAssocMin || part3_pt>fPtAssocMax)
380 continue;
381
382 //do not add the trigger 1 particle
383 if(part==part3)
384 continue;
385
386 for(int l=0; l<ind_found; l++){
387 //do not add the trigger 2 particle
388 if(found_particle[l]==part3)
389 continue;
390
391 Double_t dphi_away = found_particle[l]->Phi()-part3->Phi();
392 if(dphi_away>1.5*TMath::Pi()) dphi_away -= TMath::TwoPi();
393 else if(dphi_away<-0.5*TMath::Pi()) dphi_away += TMath::TwoPi();
394
395 Double_t deta_away = found_particle[l]->Eta()-part3->Eta();
396
397 Double_t vars[7];
398 vars[0] = deta_away;
399 vars[1] = part3_pt;
400 vars[2] = part_pt;
401 vars[3] = centrality;
402 vars[4] = dphi_away;
403 vars[5] = zVtx;
404 vars[6] = found_particle[l]->Pt();
405
406 track_hist->Fill(vars, stepUEHist+1, weight);//step +1 is the AS to the NS plot of step
407 }
408 }
409 }//end loop to search for the first trigger particle
410}
411
c9ae910e 412//____________________________________________________________________
413AliTwoPlusOneContainer &AliTwoPlusOneContainer::operator=(const AliTwoPlusOneContainer &c)
414{
415 // assigment operator
416
417 DeleteContainers();
418
419 if (this != &c)
420 ((AliTwoPlusOneContainer &) c).Copy(*this);
421
422 return *this;
423}
424
425//____________________________________________________________________
426void AliTwoPlusOneContainer::Copy(TObject& c) const
427{
428 // copy function
429
430 AliTwoPlusOneContainer& target = (AliTwoPlusOneContainer &) c;
431
432 if (fTwoPlusOne)
433 target.fTwoPlusOne = dynamic_cast<AliUEHist*> (fTwoPlusOne->Clone());
7db96852 434
435 if (fAsymmetry)
436 target.fAsymmetry = dynamic_cast<TH1F*> (fAsymmetry->Clone());
c9ae910e 437
7db96852 438 if (fAsymmetryMixed)
439 target.fAsymmetryMixed = dynamic_cast<TH1F*> (fAsymmetryMixed->Clone());
440
441 if (fTriggerPt)
442 target.fTriggerPt = dynamic_cast<TH2F*> (fTriggerPt->Clone());
443
c9ae910e 444}
445
fbee6f27 446//____________________________________________________________________
447Long64_t AliTwoPlusOneContainer::Merge(TCollection* list)
448{
449 // Merge a list of AliTwoPlusOneContainer objects with this.
450 // Returns the number of merged objects (including this).
451
452 if (!list)
453 return 0;
454
455 if (list->IsEmpty())
456 return 1;
457
458 TIterator* iter = list->MakeIterator();
459 TObject* obj;
7db96852 460
fbee6f27 461 // collections of objects
7db96852 462 const Int_t kMaxLists = 4;
463 TList* lists[kMaxLists];
464
465 for (Int_t i=0; i<kMaxLists; i++)
466 lists[i] = new TList;
fbee6f27 467
468 Int_t count = 0;
469 while ((obj = iter->Next())) {
470
471 AliTwoPlusOneContainer* entry = dynamic_cast<AliTwoPlusOneContainer*> (obj);
472 if (entry == 0)
473 continue;
474
7db96852 475 lists[0]->Add(entry->fTwoPlusOne);
476 lists[1]->Add(entry->fAsymmetry);
477 lists[2]->Add(entry->fAsymmetryMixed);
478 lists[3]->Add(entry->fTriggerPt);
fbee6f27 479
480 fMergeCount += entry->fMergeCount;
481 count++;
482 }
483
7db96852 484 fTwoPlusOne->Merge(lists[0]);
485 fAsymmetry->Merge(lists[1]);
486 fAsymmetryMixed->Merge(lists[2]);
487 fTriggerPt->Merge(lists[3]);
488
489 for (Int_t i=0; i<kMaxLists; i++)
490 delete lists[i];
fbee6f27 491
7db96852 492 // delete lists;
fbee6f27 493 return count+1;
494
495}