]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/AliAnalysisTaskPhiCorrelations.cxx
changed to nanoAOD production; fix in AliAODVertex::CloneWithoutRefts
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / AliAnalysisTaskPhiCorrelations.cxx
CommitLineData
e0331fd9 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:$ */
17
18#include <TROOT.h>
19#include <TChain.h>
20#include <TFile.h>
21#include <TList.h>
22#include <TMath.h>
23#include <TTree.h>
24#include <TH2F.h>
ebda4319 25#include <TH3F.h>
e0331fd9 26#include <TRandom.h>
dc44bc1f 27#include <TParameter.h>
e0331fd9 28
29#include "AliAnalysisTaskPhiCorrelations.h"
30#include "AliAnalyseLeadingTrackUE.h"
31#include "AliUEHistograms.h"
32#include "AliUEHist.h"
33
e0331fd9 34#include "AliAnalysisManager.h"
35#include "AliAODHandler.h"
36#include "AliAODInputHandler.h"
37#include "AliAODMCParticle.h"
e0331fd9 38#include "AliInputEventHandler.h"
39#include "AliLog.h"
40#include "AliMCEventHandler.h"
41#include "AliVParticle.h"
2a910c25 42#include "AliCFContainer.h"
e0331fd9 43
44#include "AliESDEvent.h"
45#include "AliESDInputHandler.h"
46#include "AliMultiplicity.h"
2a910c25 47#include "AliCentrality.h"
48#include "AliStack.h"
7dd4dec4 49#include "AliAODMCHeader.h"
1ccd8a0a 50#include "AliGenCocktailEventHeader.h"
51#include "AliGenEventHeader.h"
3e09dd3e 52#include "AliCollisionGeometry.h"
e0331fd9 53
2a910c25 54#include "AliEventPoolManager.h"
e0331fd9 55
d728f490 56#include "AliESDZDC.h"
3bbad7c1 57#include "AliESDtrackCuts.h"
d728f490 58
32e49607 59#include "AliHelperPID.h"
6e84bd0a 60#include "AliAnalysisUtils.h"
dc44bc1f 61#include "TMap.h"
e0331fd9 62
63////////////////////////////////////////////////////////////////////////
64//
65// Analysis class for azimuthal correlation studies
66// Based on the UE task from Sara Vallero and Jan Fiete
67//
68// This class needs input AODs.
69// The output is a list of analysis-specific containers.
70//
71// The AOD can be either connected to the InputEventHandler
72// for a chain of AOD files
73// or
74// to the OutputEventHandler
75// for a chain of ESD files,
76// in this case the class should be in the train after the jet-finder
77//
78// Authors:
79// Jan Fiete Grosse-Oetringhaus
80//
81////////////////////////////////////////////////////////////////////////
82
83
84ClassImp( AliAnalysisTaskPhiCorrelations )
a1c31636 85ClassImp( AliDPhiBasicParticle )
e0331fd9 86
87//____________________________________________________________________
88AliAnalysisTaskPhiCorrelations:: AliAnalysisTaskPhiCorrelations(const char* name):
89AliAnalysisTask(name,""),
90// general configuration
91fDebug(0),
92fMode(0),
93fReduceMemoryFootprint(kFALSE),
eed401dc 94fFillMixed(kTRUE),
ac647b0f 95fMixingTracks(50000),
1bba939a 96fTwoTrackEfficiencyStudy(kFALSE),
d4b3dbfc 97fTwoTrackEfficiencyCut(0),
7e9608f2 98fTwoTrackCutMinRadius(0.8),
44af28f9 99fUseVtxAxis(kFALSE),
9894bedd 100fCourseCentralityBinning(kFALSE),
04af8d15 101fSkipTrigger(kFALSE),
1ccd8a0a 102fInjectedSignals(kFALSE),
f89c31a7 103fRandomizeReactionPlane(kFALSE),
32e49607 104fHelperPID(0x0),
6e84bd0a 105fAnalysisUtils(0x0),
dc44bc1f 106fMap(0x0),
107// pointers to UE classes
e0331fd9 108fAnalyseUE(0x0),
109fHistos(0x0),
110fHistosMixed(0),
418b56c5 111fEfficiencyCorrectionTriggers(0),
112fEfficiencyCorrectionAssociated(0),
24d8278b 113fCentralityWeights(0),
e0331fd9 114// handlers and events
85bfac17 115fAOD(0x0),
116fESD(0x0),
e0331fd9 117fArrayMC(0x0),
118fInputHandler(0x0),
119fMcEvent(0x0),
120fMcHandler(0x0),
2a910c25 121fPoolMgr(0x0),
e0331fd9 122// histogram settings
123fListOfHistos(0x0),
124// event QA
125fnTracksVertex(1), // QA tracks pointing to principal vertex (= 3 default)
85bfac17 126fZVertex(7.),
2a910c25 127fCentralityMethod("V0M"),
e0331fd9 128// track cuts
129fTrackEtaCut(0.8),
97dc2b4e 130fTrackEtaCutMin(-1.),
9da2f080 131fOnlyOneEtaSide(0),
e0331fd9 132fPtMin(0.5),
97270ee2 133fDCAXYCut(0),
7d756130 134fSharedClusterCut(-1),
132b6963 135fCrossedRowsCut(-1),
136fFoundFractionCut(-1),
e0331fd9 137fFilterBit(0xFF),
418b56c5 138fTrackStatus(0),
5cabd2cd 139fSelectBit(AliVEvent::kMB|AliVEvent::kUserDefined),
2a910c25 140fUseChargeHadrons(kFALSE),
5c9b9fa6 141fParticleSpeciesTrigger(-1),
142fParticleSpeciesAssociated(-1),
9e35c487 143fCheckMotherPDG(kTRUE),
c05ff6be 144fSelectCharge(0),
7a77d480 145fTriggerSelectCharge(0),
15b0fdd0 146fAssociatedSelectCharge(0),
d38fa455 147fTriggerRestrictEta(-1),
00b6f3c6 148fEtaOrdering(kFALSE),
b0d56b29 149fCutConversions(kFALSE),
150fCutResonances(kFALSE),
97270ee2 151fRejectResonanceDaughters(-1),
a26093ba 152fFillOnlyStep0(kFALSE),
153fSkipStep6(kFALSE),
5e053cad 154fRejectCentralityOutliers(kFALSE),
ff9f18e4 155fRejectZeroTrackEvents(kFALSE),
f613255f 156fRemoveWeakDecays(kFALSE),
d6a8903f 157fRemoveDuplicates(kFALSE),
51d0a028 158fSkipFastCluster(kFALSE),
8a368fc2 159fWeightPerEvent(kFALSE),
3f3f12d9 160fCustomBinning(),
640b9425 161fPtOrder(kTRUE),
2b27d6f4 162fTriggersFromDetector(0),
2313a5d0 163fMCUseUncheckedCentrality(kFALSE),
c05ff6be 164fFillpT(kFALSE)
e0331fd9 165{
166 // Default constructor
167 // Define input and output slots here
168 // Input slot #0 works with a TChain
169 DefineInput(0, TChain::Class());
170 // Output slot #0 writes into a TList container
171 DefineOutput(0, TList::Class());
e0331fd9 172}
173
174AliAnalysisTaskPhiCorrelations::~AliAnalysisTaskPhiCorrelations()
175{
176 // destructor
177
178 if (fListOfHistos && !AliAnalysisManager::GetAnalysisManager()->IsProofMode())
179 delete fListOfHistos;
180}
181
182//____________________________________________________________________
183void AliAnalysisTaskPhiCorrelations::ConnectInputData(Option_t* /*option*/)
184{
185
186 // Connect the input data
187 if (fDebug > 1) AliInfo("ConnectInputData() ");
188
189 // Since AODs can either be connected to the InputEventHandler
190 // or to the OutputEventHandler ( the AOD is created by a previus task in the train )
191 // we need to get the pointer to the AODEvent correctly.
192
193 // Delta AODs are also accepted.
194
195 TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
196
85bfac17 197 if( handler && handler->InheritsFrom("AliAODInputHandler") )
198 { // input AOD
199 fAOD = ((AliAODInputHandler*)handler)->GetEvent();
200 if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODInputHandler");
201 }
202 else
203 { //output AOD
204 handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
205 if (handler && handler->InheritsFrom("AliAODHandler") )
206 {
207 fAOD = ((AliAODHandler*)handler)->GetAOD();
208 if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODHandler");
209 }
210 else
211 { // no AOD
212 AliWarning("I can't get any AOD Event Handler");
213 }
214 }
215
216 if (handler && handler->InheritsFrom("AliESDInputHandler") )
217 { // input ESD
218 // pointer received per event in ::Exec
219 if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliESDInputHandler");
220 }
e0331fd9 221
222 // Initialize common pointers
223 Initialize();
e0331fd9 224}
225
226//____________________________________________________________________
227void AliAnalysisTaskPhiCorrelations::CreateOutputObjects()
228{
229 // Create the output container
230
231 if (fDebug > 1) AliInfo("CreateOutputObjects()");
232
233 // Initialize class with main algorithms, event and track selection.
234 fAnalyseUE = new AliAnalyseLeadingTrackUE();
97dc2b4e 235 fAnalyseUE->SetParticleSelectionCriteria(fFilterBit, fUseChargeHadrons, fTrackEtaCut, fTrackEtaCutMin, fPtMin);
97270ee2 236 fAnalyseUE->SetDCAXYCut(fDCAXYCut);
7d756130 237 fAnalyseUE->SetSharedClusterCut(fSharedClusterCut);
132b6963 238 fAnalyseUE->SetCrossedRowsCut(fCrossedRowsCut);
239 fAnalyseUE->SetFoundFractionCut(fFoundFractionCut);
418b56c5 240 fAnalyseUE->SetTrackStatus(fTrackStatus);
9e35c487 241 fAnalyseUE->SetCheckMotherPDG(fCheckMotherPDG);
e0331fd9 242 fAnalyseUE->SetDebug(fDebug);
85bfac17 243 fAnalyseUE->DefineESDCuts(fFilterBit);
5cabd2cd 244 fAnalyseUE->SetEventSelection(fSelectBit);
32e49607 245 fAnalyseUE->SetHelperPID(fHelperPID);
246 if ((fParticleSpeciesTrigger != -1 || fParticleSpeciesAssociated != -1) && !fHelperPID)
247 AliFatal("HelperPID object should be set in the steering macro");
e0331fd9 248
249 // Initialize output list of containers
250 if (fListOfHistos != NULL){
251 delete fListOfHistos;
252 fListOfHistos = NULL;
253 }
254 if (!fListOfHistos){
255 fListOfHistos = new TList();
256 fListOfHistos->SetOwner(kTRUE);
257 }
258
259 // Initialize class to handle histograms
9894bedd 260 TString histType = "4R";
3bbad7c1 261 if (fUseVtxAxis == 1)
b752706a 262 histType = "5R";
3bbad7c1 263 else if (fUseVtxAxis == 2)
264 histType = "6R";
9894bedd 265 if (fCourseCentralityBinning)
266 histType += "C";
3f3f12d9 267 fHistos = new AliUEHistograms("AliUEHistogramsSame", histType, fCustomBinning);
268 fHistosMixed = new AliUEHistograms("AliUEHistogramsMixed", histType, fCustomBinning);
e0331fd9 269
2a910c25 270 fHistos->SetSelectCharge(fSelectCharge);
271 fHistosMixed->SetSelectCharge(fSelectCharge);
272
afe13b94 273 fHistos->SetSelectTriggerCharge(fTriggerSelectCharge);
274 fHistosMixed->SetSelectTriggerCharge(fTriggerSelectCharge);
15b0fdd0 275
276 fHistos->SetSelectAssociatedCharge(fAssociatedSelectCharge);
277 fHistosMixed->SetSelectAssociatedCharge(fAssociatedSelectCharge);
7a77d480 278
d38fa455 279 fHistos->SetTriggerRestrictEta(fTriggerRestrictEta);
280 fHistosMixed->SetTriggerRestrictEta(fTriggerRestrictEta);
281
9da2f080 282 fHistos->SetOnlyOneEtaSide(fOnlyOneEtaSide);
283 fHistosMixed->SetOnlyOneEtaSide(fOnlyOneEtaSide);
284
00b6f3c6 285 fHistos->SetEtaOrdering(fEtaOrdering);
286 fHistosMixed->SetEtaOrdering(fEtaOrdering);
287
b0d56b29 288 fHistos->SetPairCuts(fCutConversions, fCutResonances);
289 fHistosMixed->SetPairCuts(fCutConversions, fCutResonances);
290
97270ee2 291 fHistos->SetRejectResonanceDaughters(fRejectResonanceDaughters);
292 fHistosMixed->SetRejectResonanceDaughters(fRejectResonanceDaughters);
293
defad170 294 fHistos->SetTrackEtaCut(fTrackEtaCut);
295 fHistosMixed->SetTrackEtaCut(fTrackEtaCut);
296
8a368fc2 297 fHistos->SetWeightPerEvent(fWeightPerEvent);
298 fHistosMixed->SetWeightPerEvent(fWeightPerEvent);
418b56c5 299
640b9425 300 fHistos->SetPtOrder(fPtOrder);
301 fHistosMixed->SetPtOrder(fPtOrder);
302
7e9608f2 303 fHistos->SetTwoTrackCutMinRadius(fTwoTrackCutMinRadius);
304 fHistosMixed->SetTwoTrackCutMinRadius(fTwoTrackCutMinRadius);
305
418b56c5 306 if (fEfficiencyCorrectionTriggers)
307 {
308 fHistos->SetEfficiencyCorrectionTriggers(fEfficiencyCorrectionTriggers);
309 fHistosMixed->SetEfficiencyCorrectionTriggers((THnF*) fEfficiencyCorrectionTriggers->Clone());
310 }
311 if (fEfficiencyCorrectionAssociated)
408d1ac9 312 {
418b56c5 313 fHistos->SetEfficiencyCorrectionAssociated(fEfficiencyCorrectionAssociated);
314 fHistosMixed->SetEfficiencyCorrectionAssociated((THnF*) fEfficiencyCorrectionAssociated->Clone());
408d1ac9 315 }
13a404ed 316
e0331fd9 317 // add histograms to list
318 fListOfHistos->Add(fHistos);
319 fListOfHistos->Add(fHistosMixed);
32e49607 320 // add HelperPID to list
321 if (fHelperPID)
322 fListOfHistos->Add(fHelperPID);
dc44bc1f 323 // add TMap to list
324 if (fMap)
325 fListOfHistos->Add(fMap);
e0331fd9 326
2a910c25 327 fListOfHistos->Add(new TH2F("processIDs", ";#Delta#phi;process id", 100, -0.5 * TMath::Pi(), 1.5 * TMath::Pi(), kPNoProcess + 1, -0.5, kPNoProcess + 0.5));
c066889a 328 fListOfHistos->Add(new TH1F("eventStat", ";;events", 4, -0.5, 3.5));
5614e02f 329 fListOfHistos->Add(new TH2F("mixedDist", ";centrality;tracks;events", 101, 0, 101, 200, 0, fMixingTracks * 1.5));
f0a25b1d 330 fListOfHistos->Add(new TH2F("referenceMultiplicity", ";centrality;tracks;events", 101, 0, 101, 200, 0, 200));
2b27d6f4 331 if (fCentralityMethod == "V0A_MANUAL")
332 {
333 fListOfHistos->Add(new TH2F("V0AMult", "V0A multiplicity;V0A multiplicity;V0A multiplicity (scaled)", 1000, -.5, 999.5, 1000, -.5, 999.5));
334 fListOfHistos->Add(new TH2F("V0AMultCorrelation", "V0A multiplicity;V0A multiplicity;SPD tracklets", 1000, -.5, 999.5, 1000, -.5, 999.5));
335 }
336 if (fTriggersFromDetector == 1 || fTriggersFromDetector == 2)
337 fListOfHistos->Add(new TH1F("V0SingleCells", "V0 single cell multiplicity;multiplicity;events", 100, -0.5, 99.5));
e0331fd9 338
1a32ecc0 339 PostData(0,fListOfHistos);
340
e0331fd9 341 // Add task configuration to output list
342 AddSettingsTree();
343
2a910c25 344 // event mixing
3f3f12d9 345 Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemention of AliEventPoolManager
c066889a 346
2a910c25 347 Int_t nCentralityBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(1);
348 Double_t* centralityBins = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(1, 0)->GetXbins()->GetArray();
349
5f54dac4 350 const Int_t kNZvtxBins = 10+(1+10)*4;
408d1ac9 351 // bins for further buffers are shifted by 100 cm
5f54dac4 352 Double_t vertexBins[kNZvtxBins+1] = { -10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10,
353 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110,
354 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210,
355 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310,
356 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410 };
357
358 Int_t nZvtxBins = kNZvtxBins;
eb88bdfe 359 Double_t* zvtxbin = vertexBins;
c066889a 360
408d1ac9 361 if (fMode == 0 && fHistos->GetUEHist(2)->GetEventHist()->GetNVar() > 2)
eb88bdfe 362 {
363 nZvtxBins = fHistos->GetUEHist(2)->GetEventHist()->GetNBins(2);
364 zvtxbin = (Double_t*) fHistos->GetUEHist(2)->GetEventHist()->GetAxis(2, 0)->GetXbins()->GetArray();
365 }
85bfac17 366
3f3f12d9 367 fPoolMgr = new AliEventPoolManager(poolsize, fMixingTracks, nCentralityBins, centralityBins, nZvtxBins, zvtxbin);
f0df9076 368 fPoolMgr->SetTargetValues(fMixingTracks, 0.1, 5);
e0331fd9 369}
370
371//____________________________________________________________________
372void AliAnalysisTaskPhiCorrelations::Exec(Option_t */*option*/)
373{
416af868 374 // exec (per event)
375 fAnalyseUE->NextEvent();
376
85bfac17 377 // receive ESD pointer if we are not running AOD analysis
378 if (!fAOD)
379 {
380 AliVEventHandler* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
381 if (handler && handler->InheritsFrom("AliESDInputHandler"))
382 fESD = ((AliESDInputHandler*)handler)->GetEvent();
383 }
384
7dd4dec4 385 if (fMode)
386 {
387 // correction mode
388
389 if (fMcHandler)
390 fMcEvent = fMcHandler->MCEvent();
391
392 if (fAOD)
393 {
394 // array of MC particles
395 fArrayMC = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
396 if (!fArrayMC)
397 AliFatal("No array of MC particles found !!!");
398 }
399
400 AnalyseCorrectionMode();
401 }
e0331fd9 402 else AnalyseDataMode();
e0331fd9 403}
404
405/******************** ANALYSIS METHODS *****************************/
406
407//____________________________________________________________________
408void AliAnalysisTaskPhiCorrelations::AddSettingsTree()
409{
410 //Write settings to output list
411 TTree *settingsTree = new TTree("UEAnalysisSettings","Analysis Settings in UE estimation");
c05ff6be 412 settingsTree->Branch("fnTracksVertex", &fnTracksVertex,"nTracksVertex/I");
413 settingsTree->Branch("fZVertex", &fZVertex,"ZVertex/D");
414 //settingsTree->Branch("fCentralityMethod", fCentralityMethod.Data(),"CentralityMethod/C");
e0331fd9 415 settingsTree->Branch("fTrackEtaCut", &fTrackEtaCut, "TrackEtaCut/D");
97dc2b4e 416 settingsTree->Branch("fTrackEtaCutMin", &fTrackEtaCutMin, "TrackEtaCutMin/D");
9da2f080 417 settingsTree->Branch("fOnlyOneEtaSide", &fOnlyOneEtaSide,"OnlyOneEtaSide/I");
e0331fd9 418 settingsTree->Branch("fPtMin", &fPtMin, "PtMin/D");
c05ff6be 419 settingsTree->Branch("fFilterBit", &fFilterBit,"FilterBit/I");
7d756130 420 settingsTree->Branch("fSharedClusterCut", &fSharedClusterCut,"SharedClusterCut/D");
132b6963 421 settingsTree->Branch("fCrossedRowsCut", &fCrossedRowsCut,"CrossedRowsCut/I");
422 settingsTree->Branch("fFoundFractionCut", &fFoundFractionCut,"FoundFractionCut/D");
418b56c5 423 settingsTree->Branch("fTrackStatus", &fTrackStatus,"TrackStatus/I");
c05ff6be 424 settingsTree->Branch("fSelectBit", &fSelectBit,"EventSelectionBit/I");
e0331fd9 425 settingsTree->Branch("fUseChargeHadrons", &fUseChargeHadrons,"UseChHadrons/O");
5c9b9fa6 426 settingsTree->Branch("fParticleSpeciesTrigger", &fParticleSpeciesTrigger,"ParticleSpeciesTrigger/I");
427 settingsTree->Branch("fParticleSpeciesAssociated", &fParticleSpeciesAssociated,"ParticleSpeciesAssociated/I");
9e35c487 428 settingsTree->Branch("fCheckMotherPDG", &fCheckMotherPDG,"CheckMotherPDG/I");
c05ff6be 429 settingsTree->Branch("fSelectCharge", &fSelectCharge,"SelectCharge/I");
7a77d480 430 settingsTree->Branch("fTriggerSelectCharge", &fTriggerSelectCharge,"TriggerSelectCharge/I");
15b0fdd0 431 settingsTree->Branch("fAssociatedSelectCharge", &fAssociatedSelectCharge,"fAssociatedSelectCharge/I");
b0d56b29 432 settingsTree->Branch("fTriggerRestrictEta", &fTriggerRestrictEta,"TriggerRestrictEta/D");
00b6f3c6 433 settingsTree->Branch("fEtaOrdering", &fEtaOrdering,"EtaOrdering/O");
b0d56b29 434 settingsTree->Branch("fCutConversions", &fCutConversions,"CutConversions/O");
435 settingsTree->Branch("fCutResonances", &fCutResonances,"CutResonances/O");
97270ee2 436 settingsTree->Branch("fRejectResonanceDaughters", &fRejectResonanceDaughters,"RejectResonanceDaughters/I");
c05ff6be 437 settingsTree->Branch("fFillpT", &fFillpT,"FillpT/O");
ac647b0f 438 settingsTree->Branch("fMixingTracks", &fMixingTracks,"MixingTracks/I");
04af8d15 439 settingsTree->Branch("fSkipTrigger", &fSkipTrigger,"SkipTrigger/O");
f89c31a7
JFGO
440 settingsTree->Branch("fInjectedSignals", &fInjectedSignals,"InjectedSignals/O");
441 settingsTree->Branch("fRandomizeReactionPlane", &fRandomizeReactionPlane,"RandomizeReactionPlane/O");
5e053cad 442 settingsTree->Branch("fRejectCentralityOutliers", &fRejectCentralityOutliers,"RejectCentralityOutliers/O");
ff9f18e4 443 settingsTree->Branch("fRejectZeroTrackEvents", &fRejectZeroTrackEvents,"RejectZeroTrackEvents/O");
f613255f 444 settingsTree->Branch("fRemoveWeakDecays", &fRemoveWeakDecays,"RemoveWeakDecays/O");
d6a8903f 445 settingsTree->Branch("fRemoveDuplicates", &fRemoveDuplicates,"RemoveDuplicates/O");
51d0a028 446 settingsTree->Branch("fSkipFastCluster", &fSkipFastCluster,"SkipFastCluster/O");
8a368fc2 447 settingsTree->Branch("fWeightPerEvent", &fWeightPerEvent,"WeightPerEvent/O");
640b9425 448 settingsTree->Branch("fPtOrder", &fPtOrder,"PtOrder/O");
2b27d6f4 449 settingsTree->Branch("fTriggersFromDetector", &fTriggersFromDetector,"TriggersFromDetector/I");
2313a5d0 450 settingsTree->Branch("fMCUseUncheckedCentrality", &fMCUseUncheckedCentrality,"MCUseUncheckedCentrality/O");
7e9608f2 451 settingsTree->Branch("fTwoTrackEfficiencyCut", &fTwoTrackEfficiencyCut,"TwoTrackEfficiencyCut/D");
452 settingsTree->Branch("fTwoTrackCutMinRadius", &fTwoTrackCutMinRadius,"TwoTrackCutMinRadius/D");
2b27d6f4 453
3f3f12d9 454 //fCustomBinning
04af8d15 455
e0331fd9 456 settingsTree->Fill();
457 fListOfHistos->Add(settingsTree);
458}
459
460//____________________________________________________________________
461void AliAnalysisTaskPhiCorrelations::AnalyseCorrectionMode()
462{
463 // Run the analysis on MC to get the correction maps
464 //
465
2a910c25 466 if ( fDebug > 3 ) AliInfo( " Processing event in Corrections mode ..." );
467
468 Double_t centrality = 0;
469
470 if (fCentralityMethod.Length() > 0)
471 {
3e09dd3e 472 if (fCentralityMethod == "MC_b")
2a910c25 473 {
3e09dd3e 474 AliGenEventHeader* eventHeader = GetFirstHeader();
475 if (!eventHeader)
476 {
477 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
478 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
479 AliError("Event header not found. Skipping this event.");
480 fHistos->FillEvent(0, AliUEHist::kCFStepAnaTopology);
481 return;
482 }
483
484 AliCollisionGeometry* collGeometry = dynamic_cast<AliCollisionGeometry*> (eventHeader);
485 if (!collGeometry)
486 {
487 eventHeader->Dump();
488 AliFatal("Asking for MC_b centrality, but event header has no collision geometry information");
489 }
2313a5d0 490
3e09dd3e 491 centrality = collGeometry->ImpactParameter();
2a910c25 492 }
493 else
494 {
3e09dd3e 495 AliCentrality *centralityObj = 0;
496 if (fAOD)
497 centralityObj = fAOD->GetHeader()->GetCentralityP();
498 else if (fESD)
499 centralityObj = fESD->GetCentrality();
500
501 if (centralityObj)
502 {
503 if (fMCUseUncheckedCentrality)
504 centrality = centralityObj->GetCentralityPercentileUnchecked(fCentralityMethod);
505 else
506 centrality = centralityObj->GetCentralityPercentile(fCentralityMethod);
507 }
508 else
509 {
510 Printf("WARNING: Centrality object is 0");
511 centrality = -1;
512 }
0df1f11b 513
514 if (centrality == -1 && fAOD && fAOD->GetHeader()->InheritsFrom("AliNanoAODHeader"))
515 centrality = (Float_t) gROOT->ProcessLine(Form("100.0 + 100.0 * ((AliNanoAODHeader*) %p)->GetCentrality(\"%s\")", fAOD->GetHeader(), fCentralityMethod.Data())) / 100 - 1.0;
3e09dd3e 516 }
517
518 AliInfo(Form("Centrality is %f", centrality));
2a910c25 519 }
520
85bfac17 521 // Support for ESD and AOD based analysis
522 AliVEvent* inputEvent = fAOD;
523 if (!inputEvent)
524 inputEvent = fESD;
d4b3dbfc 525
932155c7 526 Float_t bSign = 0;
527
d4b3dbfc 528 if (inputEvent)
932155c7 529 {
d4b3dbfc 530 fHistos->SetRunNumber(inputEvent->GetRunNumber());
932155c7 531 bSign = (inputEvent->GetMagneticField() > 0) ? 1 : -1;
532 }
533
85bfac17 534 TObject* mc = fArrayMC;
535 if (!mc)
536 mc = fMcEvent;
537
2a910c25 538 // count all events
539 fHistos->FillEvent(centrality, -1);
540
72b62cb8 541 if (centrality < 0)
542 return;
543
2a910c25 544 // Only consider MC events within the vtx-z region used also as cut on the reconstructed vertex
7dd4dec4 545 TObject* vertexSupplier = fMcEvent;
546 if (fAOD) // AOD
547 vertexSupplier = fAOD->FindListObject(AliAODMCHeader::StdBranchName());
548
549 if (!fAnalyseUE->VertexSelection(vertexSupplier, 0, fZVertex))
2a910c25 550 return;
85bfac17 551
7dd4dec4 552 Float_t zVtx = 0;
553 if (fAOD)
554 zVtx = ((AliAODMCHeader*) vertexSupplier)->GetVtxZ();
555 else
556 zVtx = fMcEvent->GetPrimaryVertex()->GetZ();
c05ff6be 557 Float_t weight = 1;
558 if (fFillpT)
559 weight = -1;
1ccd8a0a 560
561 // For productions with injected signals, figure out above which label to skip particles/tracks
562 Int_t skipParticlesAbove = 0;
563 if (fInjectedSignals)
564 {
565 AliGenEventHeader* eventHeader = 0;
566 Int_t headers = 0;
567
568 if (fMcEvent)
569 {
570 // ESD
571 AliHeader* header = (AliHeader*) fMcEvent->Header();
572 if (!header)
573 AliFatal("fInjectedSignals set but no MC header found");
574
575 AliGenCocktailEventHeader* cocktailHeader = dynamic_cast<AliGenCocktailEventHeader*> (header->GenEventHeader());
576 if (!cocktailHeader)
577 {
578 header->Dump();
579 AliFatal("fInjectedSignals set but no MC cocktail header found");
580 }
581
582 headers = cocktailHeader->GetHeaders()->GetEntries();
583 eventHeader = dynamic_cast<AliGenEventHeader*> (cocktailHeader->GetHeaders()->First());
888a53cf 584
585 if (fDebug > 4)
586 {
587 for (Int_t i=0; i<cocktailHeader->GetHeaders()->GetEntries(); i++)
588 {
24d8278b 589 AliGenEventHeader* headerTmp = dynamic_cast<AliGenEventHeader*> (cocktailHeader->GetHeaders()->At(i));
590 if (headerTmp)
591 Printf("%d particles in header:", headerTmp->NProduced());
888a53cf 592 cocktailHeader->GetHeaders()->At(i)->Dump();
593 }
594 }
1ccd8a0a 595 }
596 else
597 {
598 // AOD
599 AliAODMCHeader* header = (AliAODMCHeader*) fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName());
600 if (!header)
601 AliFatal("fInjectedSignals set but no MC header found");
602
603 headers = header->GetNCocktailHeaders();
604 eventHeader = header->GetCocktailHeader(0);
605 }
2a910c25 606
1ccd8a0a 607 if (!eventHeader)
46848f0b 608 {
609 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
610 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
611 AliError("First event header not found. Skipping this event.");
612 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
613 return;
614 }
1ccd8a0a 615
616 skipParticlesAbove = eventHeader->NProduced();
888a53cf 617 AliInfo(Form("Injected signals in this event (%d headers). Keeping particles/tracks of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
1ccd8a0a 618 }
619
f89c31a7
JFGO
620 if (fCentralityWeights && !AcceptEventCentralityWeight(centrality))
621 {
622 AliInfo(Form("Rejecting event because of centrality weighting: %f", centrality));
623 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
624 return;
625 }
626
2a910c25 627 // Get MC primaries
3f3f12d9 628 // triggers
5c9b9fa6 629 TObjArray* tmpList = fAnalyseUE->GetAcceptedParticles(mc, 0, kTRUE, fParticleSpeciesTrigger, kTRUE);
3f3f12d9 630 CleanUp(tmpList, mc, skipParticlesAbove);
762206c7 631 TObjArray* tracksMC = CloneAndReduceTrackList(tmpList);
632 delete tmpList;
2a910c25 633
3f3f12d9 634 // associated
635 TObjArray* tracksCorrelateMC = tracksMC;
5c9b9fa6 636 if (fParticleSpeciesAssociated != fParticleSpeciesTrigger)
3f3f12d9 637 {
b54ab0b1 638 tmpList = fAnalyseUE->GetAcceptedParticles(mc, 0, kTRUE, fParticleSpeciesAssociated, kTRUE);
639 CleanUp(tmpList, mc, skipParticlesAbove);
640 tracksCorrelateMC = CloneAndReduceTrackList(tmpList);
641 delete tmpList;
3f3f12d9 642 }
643
f89c31a7
JFGO
644 if (fRandomizeReactionPlane)
645 {
646 Double_t centralityDigits = centrality*1000. - (Int_t)(centrality*1000.);
647 Double_t angle = TMath::TwoPi() * centralityDigits;
648 AliInfo(Form("Shifting phi of all tracks by %f (digits %f)", angle, centralityDigits));
649 ShiftTracks(tracksMC, angle);
650 if (tracksCorrelateMC != tracksMC)
651 ShiftTracks(tracksCorrelateMC, angle);
652 }
653
9375b5e2 654 if (fFillOnlyStep0)
655 zVtx = 0;
656
2a910c25 657 // (MC-true all particles)
658 // STEP 0
3f3f12d9 659 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepAll, tracksMC, tracksCorrelateMC, weight);
2a910c25 660
7a028750 661 // mixed event
8781a433 662 if (fFillMixed)
663 {
664 AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx);
888a53cf 665 if (fFillOnlyStep0)
666 ((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());
f0df9076 667 if (pool->IsReady())
8781a433 668 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
669 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepAll, tracksMC, pool->GetEvent(jMix), 1.0 / pool->GetCurrentNEvents(), (jMix == 0));
3f3f12d9 670 pool->UpdatePool(CloneAndReduceTrackList(tracksCorrelateMC));
8781a433 671 }
7a028750 672
04af8d15 673// Printf("trigger: %d", ((AliInputEventHandler*)fInputHandler)->IsEventSelected());
674
2a910c25 675 // Trigger selection ************************************************
a26093ba 676 if (!fFillOnlyStep0 && (fSkipTrigger || fAnalyseUE->TriggerSelection(fInputHandler)))
2a910c25 677 {
c32a0ca9 678 // (MC-true all particles)
679 // STEP 1
680 if (!fReduceMemoryFootprint)
3f3f12d9 681 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTriggered, tracksMC, tracksCorrelateMC, weight);
c32a0ca9 682 else
683 fHistos->FillEvent(centrality, AliUEHist::kCFStepTriggered);
684
872dc651 685 if (!inputEvent) {
c32a0ca9 686 AliFatal("UNEXPECTED: inputEvent is 0. Trigger selection should have failed");
872dc651 687 return;
688 }
2a910c25 689
690 // Vertex selection *************************************************
85bfac17 691 if (fAnalyseUE->VertexSelection(inputEvent, fnTracksVertex, fZVertex))
2a910c25 692 {
693 // fill here for tracking efficiency
694 // loop over particle species
695
696 for (Int_t particleSpecies = 0; particleSpecies < 4; particleSpecies++)
697 {
85bfac17 698 TObjArray* primMCParticles = fAnalyseUE->GetAcceptedParticles(mc, 0x0, kTRUE, particleSpecies, kTRUE);
59375a30 699 TObjArray* primRecoTracksMatched = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, particleSpecies, kTRUE, kFALSE);
700 TObjArray* allRecoTracksMatched = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, particleSpecies, kTRUE, kFALSE);
701 TObjArray* primRecoTracksMatchedPID = 0;
702 TObjArray* allRecoTracksMatchedPID = 0;
703
704 if (fHelperPID)
705 {
706 primRecoTracksMatchedPID = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, particleSpecies, kTRUE, kTRUE);
707 allRecoTracksMatchedPID = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, particleSpecies, kTRUE, kTRUE);
708 }
1ccd8a0a 709
3f3f12d9 710 CleanUp(primMCParticles, mc, skipParticlesAbove);
711 CleanUp(primRecoTracksMatched, mc, skipParticlesAbove);
712 CleanUp(allRecoTracksMatched, mc, skipParticlesAbove);
59375a30 713 CleanUp(primRecoTracksMatchedPID, mc, skipParticlesAbove);
714 CleanUp(allRecoTracksMatchedPID, mc, skipParticlesAbove);
29cfdb5f 715
716 // select charges
717 if (fTriggerSelectCharge != 0)
718 {
719 SelectCharge(primMCParticles);
720 SelectCharge(primRecoTracksMatched);
721 SelectCharge(allRecoTracksMatched);
59375a30 722 SelectCharge(primRecoTracksMatchedPID);
723 SelectCharge(allRecoTracksMatchedPID);
29cfdb5f 724 }
2a910c25 725
59375a30 726 fHistos->FillTrackingEfficiency(primMCParticles, primRecoTracksMatched, allRecoTracksMatched, primRecoTracksMatchedPID, allRecoTracksMatchedPID, 0, particleSpecies, centrality, zVtx);
2a910c25 727
eed401dc 728// Printf("%d --> %d %d %d", particleSpecies, primMCParticles->GetEntries(), primRecoTracksMatched->GetEntries(), allRecoTracksMatched->GetEntries());
729
730 delete primMCParticles;
2a910c25 731 delete primRecoTracksMatched;
732 delete allRecoTracksMatched;
733 }
3f3f12d9 734
b591fb9c 735 TObjArray* fakeParticles = fAnalyseUE->GetFakeParticles(inputEvent, mc, kFALSE, -1, kTRUE);
3f3f12d9 736 CleanUp((TObjArray*) fakeParticles->At(0), mc, skipParticlesAbove);
737 CleanUp((TObjArray*) fakeParticles->At(1), mc, skipParticlesAbove);
738
59375a30 739 fHistos->FillTrackingEfficiency(0, 0, 0, 0, 0, (TObjArray*) fakeParticles->At(2), 0, centrality, zVtx);
b591fb9c 740 fHistos->FillFakePt(fakeParticles, centrality);
d728f490 741// Printf(">>>>> %d %d %d fakes", ((TObjArray*) fakeParticles->At(0))->GetEntriesFast(), ((TObjArray*) fakeParticles->At(1))->GetEntriesFast(), ((TObjArray*) fakeParticles->At(2))->GetEntriesFast());
b591fb9c 742 delete fakeParticles;
2a910c25 743
744 // (MC-true all particles)
745 // STEP 2
85bfac17 746 if (!fReduceMemoryFootprint)
3f3f12d9 747 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepVertex, tracksMC, tracksCorrelateMC, weight);
c32a0ca9 748 else
749 fHistos->FillEvent(centrality, AliUEHist::kCFStepVertex);
2a910c25 750
751 // Get MC primaries that match reconstructed track
3f3f12d9 752 // triggers
b54ab0b1 753 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, fParticleSpeciesTrigger, kTRUE);
754 CleanUp(tmpList, mc, skipParticlesAbove);
755 TObjArray* tracksRecoMatchedPrim = CloneAndReduceTrackList(tmpList);
756 delete tmpList;
757
3f3f12d9 758 // associated
759 TObjArray* tracksCorrelateRecoMatchedPrim = tracksRecoMatchedPrim;
5c9b9fa6 760 if (fParticleSpeciesAssociated != fParticleSpeciesTrigger)
3f3f12d9 761 {
b54ab0b1 762 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kTRUE, fParticleSpeciesAssociated, kTRUE);
763 CleanUp(tmpList, mc, skipParticlesAbove);
764 tracksCorrelateRecoMatchedPrim = CloneAndReduceTrackList(tmpList);
765 delete tmpList;
3f3f12d9 766 }
767
2a910c25 768 // (RECO-matched (quantities from MC particle) primary particles)
769 // STEP 4
3f3f12d9 770 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTrackedOnlyPrim, tracksRecoMatchedPrim, tracksCorrelateRecoMatchedPrim, weight);
408d1ac9 771
772 // mixed event
773 if (fFillMixed)
774 {
775 AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx + 200);
f0df9076 776 if (pool->IsReady())
408d1ac9 777 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
778 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTrackedOnlyPrim, tracksRecoMatchedPrim, pool->GetEvent(jMix), 1.0 / pool->GetCurrentNEvents(), (jMix == 0));
3f3f12d9 779 pool->UpdatePool(CloneAndReduceTrackList(tracksCorrelateRecoMatchedPrim));
408d1ac9 780 }
2a910c25 781
782 // Get MC primaries + secondaries that match reconstructed track
3f3f12d9 783 // triggers
b54ab0b1 784 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, fParticleSpeciesTrigger, kTRUE);
785 CleanUp(tmpList, mc, skipParticlesAbove);
786 TObjArray* tracksRecoMatchedAll = CloneAndReduceTrackList(tmpList);
787 delete tmpList;
788
3f3f12d9 789 // associated
790 TObjArray* tracksCorrelateRecoMatchedAll = tracksRecoMatchedAll;
5c9b9fa6 791 if (fParticleSpeciesAssociated != fParticleSpeciesTrigger)
3f3f12d9 792 {
b54ab0b1 793 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, mc, kFALSE, fParticleSpeciesAssociated, kTRUE);
794 CleanUp(tmpList, mc, skipParticlesAbove);
795 tracksCorrelateRecoMatchedAll = CloneAndReduceTrackList(tmpList);
796 delete tmpList;
3f3f12d9 797 }
798
2a910c25 799 // (RECO-matched (quantities from MC particle) all particles)
800 // STEP 5
3f3f12d9 801 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTracked, tracksRecoMatchedAll, tracksCorrelateRecoMatchedAll, weight);
2a910c25 802
408d1ac9 803 // mixed event
804 if (fFillMixed)
805 {
806 AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx + 300);
f0df9076 807 if (pool->IsReady())
408d1ac9 808 for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++)
809 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepTracked, tracksRecoMatchedAll, pool->GetEvent(jMix), 1.0 / pool->GetCurrentNEvents(), (jMix == 0));
3f3f12d9 810 pool->UpdatePool(CloneAndReduceTrackList(tracksCorrelateRecoMatchedAll));
408d1ac9 811 }
812
2a910c25 813 // Get RECO tracks
3f3f12d9 814 // triggers
b54ab0b1 815 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, fParticleSpeciesTrigger, kTRUE);
816 CleanUp(tmpList, mc, skipParticlesAbove);
817 TObjArray* tracks = CloneAndReduceTrackList(tmpList);
818 delete tmpList;
819
3f3f12d9 820 // associated
821 TObjArray* tracksCorrelate = tracks;
5c9b9fa6 822 if (fParticleSpeciesAssociated != fParticleSpeciesTrigger)
3f3f12d9 823 {
b54ab0b1 824 tmpList = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, fParticleSpeciesAssociated, kTRUE);
825 CleanUp(tmpList, mc, skipParticlesAbove);
826 tracksCorrelate = CloneAndReduceTrackList(tmpList);
827 delete tmpList;
3f3f12d9 828 }
1ccd8a0a 829
2a910c25 830 // (RECO all tracks)
831 // STEP 6
a26093ba 832 if (!fSkipStep6)
3f3f12d9 833 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, tracksCorrelate, weight);
2a910c25 834
932155c7 835 // two track cut, STEP 8
836 if (fTwoTrackEfficiencyCut > 0)
3f3f12d9 837 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracks, tracksCorrelate, weight, kTRUE, kTRUE, bSign, fTwoTrackEfficiencyCut);
932155c7 838
408d1ac9 839 // apply correction efficiency, STEP 10
418b56c5 840 if (fEfficiencyCorrectionTriggers || fEfficiencyCorrectionAssociated)
408d1ac9 841 {
418b56c5 842 // with or without two track efficiency depending on if fTwoTrackEfficiencyCut is set
408d1ac9 843 Bool_t twoTrackCut = (fTwoTrackEfficiencyCut > 0);
844
3f3f12d9 845 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepCorrected, tracks, tracksCorrelate, weight, kTRUE, twoTrackCut, bSign, fTwoTrackEfficiencyCut, kTRUE);
408d1ac9 846 }
418b56c5 847
7a028750 848 // mixed event
408d1ac9 849 if (fFillMixed)
8781a433 850 {
851 AliEventPool* pool2 = fPoolMgr->GetEventPool(centrality, zVtx + 100);
888a53cf 852 ((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool2->NTracksInPool());
f0df9076 853 if (pool2->IsReady())
408d1ac9 854 {
932155c7 855 for (Int_t jMix=0; jMix<pool2->GetCurrentNEvents(); jMix++)
856 {
857 // STEP 6
408d1ac9 858 if (!fSkipStep6)
859 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, pool2->GetEvent(jMix), 1.0 / pool2->GetCurrentNEvents(), (jMix == 0));
932155c7 860
861 // two track cut, STEP 8
862 if (fTwoTrackEfficiencyCut > 0)
863 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracks, pool2->GetEvent(jMix), 1.0 / pool2->GetCurrentNEvents(), (jMix == 0), kTRUE, bSign, fTwoTrackEfficiencyCut);
408d1ac9 864
865 // apply correction efficiency, STEP 10
418b56c5 866 if (fEfficiencyCorrectionTriggers || fEfficiencyCorrectionAssociated)
408d1ac9 867 {
868 // with or without two track efficiency depending on if fTwoTrackEfficiencyCut is set
869 Bool_t twoTrackCut = (fTwoTrackEfficiencyCut > 0);
870
871 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepCorrected, tracks, pool2->GetEvent(jMix), 1.0 / pool2->GetCurrentNEvents(), (jMix == 0), twoTrackCut, bSign, fTwoTrackEfficiencyCut, kTRUE);
872 }
932155c7 873 }
408d1ac9 874 }
3f3f12d9 875 pool2->UpdatePool(CloneAndReduceTrackList(tracksCorrelate));
8781a433 876 }
408d1ac9 877
85bfac17 878 if (0 && !fReduceMemoryFootprint)
2a910c25 879 {
880 // make list of secondaries (matched with MC)
881 TObjArray* tracksRecoMatchedSecondaries = new TObjArray;
b0d56b29 882 for (Int_t i=0; i<tracksRecoMatchedAll->GetEntriesFast(); i++)
2a910c25 883 if (((AliAODMCParticle*)tracksRecoMatchedAll->At(i))->IsPhysicalPrimary() == kFALSE)
884 tracksRecoMatchedSecondaries->Add(tracksRecoMatchedAll->At(i));
885
886 // Study: Use only secondaries as trigger particles and plot the correlation vs. all particles; store in step 9
c05ff6be 887 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy2, tracksRecoMatchedSecondaries, tracksRecoMatchedAll, weight);
2a910c25 888
889 // Study: Use only primaries as trigger particles and plot the correlation vs. secondaries; store in step 8
c05ff6be 890 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracksRecoMatchedPrim, tracksRecoMatchedSecondaries, weight);
2a910c25 891
892 // plot delta phi vs process id of secondaries
893 // trigger particles: primaries in 4 < pT < 10
894 // associated particles: secondaries in 1 < pT < 10
895
b0d56b29 896 for (Int_t i=0; i<tracksRecoMatchedPrim->GetEntriesFast(); i++)
2a910c25 897 {
898 AliVParticle* triggerParticle = (AliVParticle*) tracksRecoMatchedPrim->At(i);
899
900 if (triggerParticle->Pt() < 4 || triggerParticle->Pt() > 10)
901 continue;
902
b0d56b29 903 for (Int_t j=0; j<tracksRecoMatchedSecondaries->GetEntriesFast(); j++)
2a910c25 904 {
905 AliAODMCParticle* particle = (AliAODMCParticle*) tracksRecoMatchedSecondaries->At(j);
906
907 if (particle->Pt() < 1 || particle->Pt() > 10)
908 continue;
909
910 if (particle->Pt() > triggerParticle->Pt())
911 continue;
912
913 Double_t deltaPhi = triggerParticle->Phi() - particle->Phi();
914 if (deltaPhi > 1.5 * TMath::Pi())
915 deltaPhi -= TMath::TwoPi();
916 if (deltaPhi < -0.5 * TMath::Pi())
917 deltaPhi += TMath::TwoPi();
918
919 Int_t processID = fMcEvent->Stack()->Particle(particle->GetLabel())->GetUniqueID();
920
921 ((TH2F*) fListOfHistos->FindObject("processIDs"))->Fill(deltaPhi, processID);
922 }
923 }
924
925 delete tracksRecoMatchedSecondaries;
926 }
927
3f3f12d9 928 if (tracksCorrelateRecoMatchedPrim != tracksRecoMatchedPrim)
929 delete tracksCorrelateRecoMatchedPrim;
2a910c25 930 delete tracksRecoMatchedPrim;
3f3f12d9 931
932 if (tracksCorrelateRecoMatchedAll != tracksRecoMatchedAll)
933 delete tracksCorrelateRecoMatchedAll;
2a910c25 934 delete tracksRecoMatchedAll;
3f3f12d9 935
936 if (tracksCorrelate != tracks)
937 delete tracksCorrelate;
2a910c25 938 delete tracks;
939 }
940 }
941
3f3f12d9 942 if (tracksMC != tracksCorrelateMC)
943 delete tracksCorrelateMC;
2a910c25 944 delete tracksMC;
e0331fd9 945}
946
3e09dd3e 947//____________________________________________________________________
948AliGenEventHeader* AliAnalysisTaskPhiCorrelations::GetFirstHeader()
949{
950 // get first MC header from either ESD/AOD (including cocktail header if available)
951
952 if (fMcEvent)
953 {
954 // ESD
955 AliHeader* header = (AliHeader*) fMcEvent->Header();
956 if (!header)
957 return 0;
958
959 AliGenCocktailEventHeader* cocktailHeader = dynamic_cast<AliGenCocktailEventHeader*> (header->GenEventHeader());
960 if (cocktailHeader)
961 return dynamic_cast<AliGenEventHeader*> (cocktailHeader->GetHeaders()->First());
962
16e7d490 963 return dynamic_cast<AliGenEventHeader*> (header->GenEventHeader());
3e09dd3e 964 }
965 else
966 {
967 // AOD
968 AliAODMCHeader* header = (AliAODMCHeader*) fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName());
969 if (!header)
970 return 0;
971
972 return header->GetCocktailHeader(0);
973 }
974}
975
e0331fd9 976//____________________________________________________________________
977void AliAnalysisTaskPhiCorrelations::AnalyseDataMode()
978{
979
980 // Run the analysis on DATA or MC to get raw distributions
981
e0331fd9 982 if ( fDebug > 3 ) AliInfo( " Processing event in Data mode ..." );
e0331fd9 983
c066889a 984 ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(0);
985
2a910c25 986 if (!fInputHandler)
987 return;
988
5e053cad 989 // skip not selected events here (the AOD is not updated for those)
d728f490 990 if (!fSkipTrigger && !(fInputHandler->IsEventSelected() & fSelectBit))
2a910c25 991 return;
51d0a028 992
993 // skip fast cluster events here if requested
8a368fc2 994 if (fSkipFastCluster && (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly))
51d0a028 995 return;
6e84bd0a 996
72b62cb8 997 // Support for ESD and AOD based analysis
998 AliVEvent* inputEvent = fAOD;
999 if (!inputEvent)
1000 inputEvent = fESD;
1001
2a910c25 1002 Double_t centrality = 0;
1003
c3294f09 1004 AliCentrality *centralityObj = 0;
2a910c25 1005 if (fCentralityMethod.Length() > 0)
1006 {
d728f490 1007 if (fCentralityMethod == "ZNA_MANUAL")
1008 {
9894bedd 1009 Bool_t zna = kFALSE;
1010 for(Int_t j = 0; j < 4; ++j) {
1011 if (fESD->GetZDCData()->GetZDCTDCData(12,j) != 0) {
1012 zna = kTRUE;
1013 }
1014 }
1015
1016// Printf("%d %f", zna, fZNAtower[0]);
1017 if (zna)
1018 {
1019 // code from Chiara O (23.10.12)
1020 const Double_t *fZNAtower = fESD->GetZDCData()->GetZN2TowerEnergy();
72b62cb8 1021 Float_t znacut[4] = {681., 563., 413., 191.};
1022
9894bedd 1023 if(fZNAtower[0]>znacut[0]) centrality = 1;
72b62cb8 1024 else if(fZNAtower[0]>znacut[1]) centrality = 21;
1025 else if(fZNAtower[0]>znacut[2]) centrality = 41;
1026 else if(fZNAtower[0]>znacut[3]) centrality = 61;
1027 else centrality = 81;
9894bedd 1028 }
1029 else
1030 centrality = -1;
d728f490 1031 }
72b62cb8 1032 else if (fCentralityMethod == "TRACKS_MANUAL")
1033 {
1034 // for pp
1035 TObjArray* tracks = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, -1, kTRUE);
1036 centrality = tracks->GetEntriesFast();
1037 if (centrality > 40)
1038 centrality = 41;
1039// Printf("%d %f", tracks->GetEntriesFast(), centrality);
1040 delete tracks;
1041 }
17f8b959 1042 else if (fCentralityMethod == "V0A_MANUAL")
1043 {
ba874719 1044 // for pp
1045
dc44bc1f 1046 //Total multiplicity in the VZERO A detector
1047 Float_t MV0A=inputEvent->GetVZEROData()->GetMTotV0A();
1048 Float_t MV0AScaled=0.;
1049 if (fMap){
1050 TParameter<float>* sf=(TParameter<float>*)fMap->GetValue(Form("%d",inputEvent->GetRunNumber()));
1051 if(sf)MV0AScaled=MV0A*sf->GetVal();
1052 }
dc44bc1f 1053
ba874719 1054 if (MV0AScaled > 0)
1055 centrality = MV0AScaled;
1056 else
1057 centrality = -1;
17f8b959 1058 }
2a910c25 1059 else
a6d82f4e 1060 {
d728f490 1061 if (fAOD)
1062 centralityObj = fAOD->GetHeader()->GetCentralityP();
1063 else if (fESD)
1064 centralityObj = fESD->GetCentrality();
1065
1066 if (centralityObj)
1067 centrality = centralityObj->GetCentralityPercentile(fCentralityMethod);
1068 //centrality = centralityObj->GetCentralityPercentileUnchecked(fCentralityMethod);
1069 else
1070 centrality = -1;
0df1f11b 1071
1072// fAOD->GetHeader()->Dump();
1073// Printf("%p %d", dynamic_cast<AliNanoAODHeader*> (fAOD->GetHeader()), fAOD->GetHeader()->InheritsFrom("AliNanoAODHeader"));
1074
1075 if (centrality == -1 && fAOD && fAOD->GetHeader()->InheritsFrom("AliNanoAODHeader"))
1076 centrality = (Float_t) gROOT->ProcessLine(Form("100.0 + 100.0 * ((AliNanoAODHeader*) %p)->GetCentrality(\"%s\")", fAOD->GetHeader(), fCentralityMethod.Data())) / 100 - 1.0;
d728f490 1077
1078 if (fAOD)
a6d82f4e 1079 {
d728f490 1080 // remove outliers
1081 if (centrality == 0)
a6d82f4e 1082 {
d728f490 1083 if (fAOD->GetVZEROData())
a6d82f4e 1084 {
d728f490 1085 Float_t multV0 = 0;
1086 for (Int_t i=0; i<64; i++)
1087 multV0 += fAOD->GetVZEROData()->GetMultiplicity(i);
1088 if (multV0 < 19500)
1089 {
1090 centrality = -1;
1091 AliInfo("Rejecting event due to too small V0 multiplicity");
1092 }
a6d82f4e 1093 }
1094 }
1095 }
1096 }
1097
a8583211 1098 AliInfo(Form("Centrality is %f", centrality));
2a910c25 1099 }
1100
04af8d15 1101 Float_t bSign = (inputEvent->GetMagneticField() > 0) ? 1 : -1;
1102
85bfac17 1103 fHistos->SetRunNumber(inputEvent->GetRunNumber());
1104
2a910c25 1105 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
1106 fHistos->FillEvent(centrality, AliUEHist::kCFStepAll);
1107
e0331fd9 1108 // Trigger selection ************************************************
d728f490 1109 if (!fSkipTrigger && !fAnalyseUE->TriggerSelection(fInputHandler)) return;
6e84bd0a 1110
e0331fd9 1111 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
2a910c25 1112 fHistos->FillEvent(centrality, AliUEHist::kCFStepTriggered);
e0331fd9 1113
6e84bd0a 1114 // Pileup selection ************************************************
1115 if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(inputEvent))
1116 {
1117 // count the removed events
1118 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
1119
1120 return;
1121 }
1122
e0331fd9 1123 // Vertex selection *************************************************
85bfac17 1124 if(!fAnalyseUE->VertexSelection(inputEvent, fnTracksVertex, fZVertex)) return;
e0331fd9 1125
1126 // Fill the "event-counting-container", it is needed to get the number of events remaining after each event-selection cut
2a910c25 1127 fHistos->FillEvent(centrality, AliUEHist::kCFStepVertex);
e0331fd9 1128
b101208f 1129 // fill V0 control histograms
1130 if (fCentralityMethod == "V0A_MANUAL")
1131 {
1132 ((TH2F*) fListOfHistos->FindObject("V0AMult"))->Fill(inputEvent->GetVZEROData()->GetMTotV0A(), centrality);
1133 if (fAOD)
1134 ((TH2F*) fListOfHistos->FindObject("V0AMultCorrelation"))->Fill(inputEvent->GetVZEROData()->GetMTotV0A(), fAOD->GetTracklets()->GetNumberOfTracklets());
1135 }
1136
c3294f09 1137 // optimization
1d53fb34 1138 if (centrality < 0)
2a910c25 1139 return;
e0331fd9 1140
2b27d6f4 1141 TObjArray* tracks = 0;
1142
1143 if (fTriggersFromDetector == 0)
1144 tracks = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, fParticleSpeciesTrigger, kTRUE);
1145 else if (fTriggersFromDetector == 1 || fTriggersFromDetector == 2)
1146 {
1147 tracks = new TObjArray;
1148 tracks->SetOwner(kTRUE);
1149
1150 AliVVZERO* vZero = inputEvent->GetVZEROData();
1151
1152 const Int_t vZeroStart = (fTriggersFromDetector == 1) ? 32 : 0;
1153
1154 TH1F* singleCells = (TH1F*) fListOfHistos->FindObject("V0SingleCells");
1155 for (Int_t i=vZeroStart; i<vZeroStart+32; i++)
1156 {
1157 Float_t weight = vZero->GetMultiplicity(i);
1158 singleCells->Fill(weight);
1159
1160 // rough estimate of multiplicity
1161 for (Int_t j=0; j<TMath::Nint(weight); j++)
1162 {
1163 AliDPhiBasicParticle* particle = new AliDPhiBasicParticle((AliVVZERO::GetVZEROEtaMax(i) + AliVVZERO::GetVZEROEtaMin(i)) / 2, AliVVZERO::GetVZEROAvgPhi(i), 1.1, 0); // fit pT = 1.1 and charge = 0
1164 particle->SetUniqueID(-1); // not needed here
1165
1166 tracks->Add(particle);
1167 }
1168 }
1169 }
1170 else
1171 AliFatal(Form("Invalid setting for fTriggersFromDetector: %d", fTriggersFromDetector));
1172
636a6c1d 1173 //Printf("Accepted %d tracks", tracks->GetEntries());
5e053cad 1174
1175 // check for outlier in centrality vs number of tracks (rough constants extracted from correlation histgram)
1176 Bool_t reject = kFALSE;
1177 if (fRejectCentralityOutliers)
1178 {
1179 if (centrality > 40 && centrality <= 50 && tracks->GetEntriesFast() > 1160)
1180 reject = kTRUE;
1181 if (centrality > 50 && centrality <= 60 && tracks->GetEntriesFast() > 650)
1182 reject = kTRUE;
1183 if (centrality > 60 && centrality <= 70 && tracks->GetEntriesFast() > 370)
1184 reject = kTRUE;
1185 if (centrality > 70 && centrality <= 80 && tracks->GetEntriesFast() > 220)
1186 reject = kTRUE;
1187 if (centrality > 80 && centrality <= 90 && tracks->GetEntriesFast() > 130)
1188 reject = kTRUE;
1189 if (centrality > 90 && tracks->GetEntriesFast() > 75)
1190 reject = kTRUE;
1191 }
1192
1193 if (reject)
1194 {
1195 AliInfo(Form("Rejecting event due to centrality vs tracks correlation: %f %d", centrality, tracks->GetEntriesFast()));
1196 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
ff9f18e4 1197 delete tracks;
1198 return;
1199 }
1200
1201 if (fRejectZeroTrackEvents && tracks->GetEntriesFast() == 0)
1202 {
1203 AliInfo(Form("Rejecting event because it has no tracks: %f %d", centrality, tracks->GetEntriesFast()));
1204 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
5e053cad 1205 delete tracks;
1206 return;
1207 }
24d8278b 1208
1209 if (fCentralityWeights && !AcceptEventCentralityWeight(centrality))
1210 {
1211 AliInfo(Form("Rejecting event because of centrality weighting: %f", centrality));
1212 fHistos->FillEvent(centrality, AliUEHist::kCFStepAnaTopology);
1213 delete tracks;
1214 return;
1215 }
1216
636a6c1d 1217 // correlate particles with...
1218 TObjArray* tracksCorrelate = 0;
2b27d6f4 1219 if (fParticleSpeciesAssociated != fParticleSpeciesTrigger || fTriggersFromDetector > 0)
5c9b9fa6 1220 tracksCorrelate = fAnalyseUE->GetAcceptedParticles(inputEvent, 0, kTRUE, fParticleSpeciesAssociated, kTRUE);
636a6c1d 1221
3bbad7c1 1222 // reference multiplicity
1223 Int_t referenceMultiplicity = -1;
1224 if (fESD)
1225 referenceMultiplicity = AliESDtrackCuts::GetReferenceMultiplicity(fESD);
3f3f12d9 1226 else if (fAOD)
1227 referenceMultiplicity = tracks->GetEntriesFast(); // TODO to be replaced by the estimator once available in the AOD
418b56c5 1228// referenceMultiplicity = fAOD->GetHeader()->GetRefMultiplicityComb05();
5e053cad 1229
3bbad7c1 1230 ((TH2F*) fListOfHistos->FindObject("referenceMultiplicity"))->Fill(centrality, referenceMultiplicity);
5e053cad 1231
85bfac17 1232 const AliVVertex* vertex = inputEvent->GetPrimaryVertex();
2a910c25 1233 Double_t zVtx = vertex->GetZ();
1234
c05ff6be 1235 Float_t weight = 1;
1236 if (fFillpT)
1237 weight = -1;
1238
c3294f09 1239 // Fill containers at STEP 6 (reconstructed)
1240 if (centrality >= 0)
c066889a 1241 {
a26093ba 1242 if (!fSkipStep6)
636a6c1d 1243 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracks, tracksCorrelate, weight, kTRUE, kFALSE, 0, 0.02, kTRUE);
a26093ba 1244
c066889a 1245 ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(1);
04af8d15 1246
d4b3dbfc 1247 if (fTwoTrackEfficiencyCut > 0)
636a6c1d 1248 fHistos->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracks, tracksCorrelate, weight, kTRUE, kTRUE, bSign, fTwoTrackEfficiencyCut, kTRUE);
c066889a 1249 }
c3294f09 1250
636a6c1d 1251 // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
1252 TObjArray* tracksClone = CloneAndReduceTrackList(tracks);
1253 delete tracks;
1254
eed401dc 1255 if (fFillMixed)
e0331fd9 1256 {
eed401dc 1257 // event mixing
2a910c25 1258
eed401dc 1259 // 1. First get an event pool corresponding in mult (cent) and
1260 // zvertex to the current event. Once initialized, the pool
1261 // should contain nMix (reduced) events. This routine does not
1262 // pre-scan the chain. The first several events of every chain
1263 // will be skipped until the needed pools are filled to the
1264 // specified depth. If the pool categories are not too rare, this
1265 // should not be a problem. If they are rare, you could lose
1266 // statistics.
1267
1268 // 2. Collect the whole pool's content of tracks into one TObjArray
1269 // (bgTracks), which is effectively a single background super-event.
1270
1271 // 3. The reduced and bgTracks arrays must both be passed into
1272 // FillCorrelations(). Also nMix should be passed in, so a weight
1273 // of 1./nMix can be applied.
1274
1275 AliEventPool* pool = fPoolMgr->GetEventPool(centrality, zVtx);
1276
1277 if (!pool)
1278 AliFatal(Form("No pool found for centrality = %f, zVtx = %f", centrality, zVtx));
1279
f0df9076 1280// pool->SetDebug(1);
2d7827bf 1281
f0df9076 1282 if (pool->IsReady())
eed401dc 1283 {
1284
1285 Int_t nMix = pool->GetCurrentNEvents();
a1c31636 1286// cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;
c066889a 1287
1288 ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2);
5614e02f 1289 ((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());
c066889a 1290 if (pool->IsReady())
1291 ((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3);
eed401dc 1292
1293 // Fill mixed-event histos here
c05ff6be 1294 for (Int_t jMix=0; jMix<nMix; jMix++)
1295 {
eed401dc 1296 TObjArray* bgTracks = pool->GetEvent(jMix);
c5c840c5 1297
a26093ba 1298 if (!fSkipStep6)
408d1ac9 1299 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepReconstructed, tracksClone, bgTracks, 1.0 / nMix, (jMix == 0), kFALSE, 0, 0.02, kTRUE);
c5c840c5 1300
d4b3dbfc 1301 if (fTwoTrackEfficiencyCut > 0)
408d1ac9 1302 fHistosMixed->FillCorrelations(centrality, zVtx, AliUEHist::kCFStepBiasStudy, tracksClone, bgTracks, 1.0 / nMix, (jMix == 0), kTRUE, bSign, fTwoTrackEfficiencyCut, kTRUE);
eed401dc 1303 }
e0331fd9 1304 }
eed401dc 1305
04af8d15 1306 // ownership is with the pool now
636a6c1d 1307 if (tracksCorrelate)
1308 {
1309 pool->UpdatePool(CloneAndReduceTrackList(tracksCorrelate));
1310 delete tracksClone;
1311 }
1312 else
1313 pool->UpdatePool(tracksClone);
eed401dc 1314 //pool->PrintInfo();
e0331fd9 1315 }
04af8d15 1316 else
636a6c1d 1317 {
04af8d15 1318 delete tracksClone;
636a6c1d 1319 if (tracksCorrelate)
1320 delete tracksCorrelate;
1321 }
e0331fd9 1322}
1323
7a028750 1324TObjArray* AliAnalysisTaskPhiCorrelations::CloneAndReduceTrackList(TObjArray* tracks)
1325{
1326 // clones a track list by using AliDPhiBasicParticle which uses much less memory (used for event mixing)
1327
1328 TObjArray* tracksClone = new TObjArray;
1329 tracksClone->SetOwner(kTRUE);
1330
b0d56b29 1331 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)
7a028750 1332 {
1d53fb34 1333 AliVParticle* particle = (AliVParticle*) tracks->UncheckedAt(i);
1334 AliDPhiBasicParticle* copy = new AliDPhiBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge());
1335 copy->SetUniqueID(particle->GetUniqueID());
1336 tracksClone->Add(copy);
7a028750 1337 }
1338
1339 return tracksClone;
1340}
1341
e0331fd9 1342//____________________________________________________________________
1343void AliAnalysisTaskPhiCorrelations::Initialize()
1344{
1345 // input handler
1346 fInputHandler = (AliInputEventHandler*)
1347 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
1348 // MC handler
d8ee8cd0 1349 fMcHandler = dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
e0331fd9 1350}
d6a8903f 1351
1352//____________________________________________________________________
1353void AliAnalysisTaskPhiCorrelations::RemoveDuplicates(TObjArray* tracks)
1354{
1355 // remove particles with the same label
1356
1357 Int_t before = tracks->GetEntriesFast();
1358
1359 for (Int_t i=0; i<before; ++i)
1360 {
1361 AliVParticle* part = (AliVParticle*) tracks->At(i);
1362
1363 for (Int_t j=i+1; j<before; ++j)
1364 {
1365 AliVParticle* part2 = (AliVParticle*) tracks->At(j);
1366
1367 if (part->GetLabel() == part2->GetLabel())
1368 {
1369 Printf("Removing %d with label %d (duplicated in %d)", i, part->GetLabel(), j); part->Dump(); part2->Dump();
1370 TObject* object = tracks->RemoveAt(i);
1371 if (tracks->IsOwner())
1372 delete object;
1373 break;
1374 }
1375 }
1376 }
1377
1378 tracks->Compress();
1379
1380 if (before > tracks->GetEntriesFast())
1381 AliInfo(Form("Reduced from %d to %d", before, tracks->GetEntriesFast()));
1382}
3f3f12d9 1383
1384void AliAnalysisTaskPhiCorrelations::CleanUp(TObjArray* tracks, TObject* mcObj, Int_t maxLabel)
1385{
1386 // calls RemoveInjectedSignals, RemoveWeakDecays and RemoveDuplicates
1387
59375a30 1388 if (!tracks)
1389 return;
1390
3f3f12d9 1391 if (fInjectedSignals)
1392 fAnalyseUE->RemoveInjectedSignals(tracks, mcObj, maxLabel);
1393 if (fRemoveWeakDecays)
1394 fAnalyseUE->RemoveWeakDecays(tracks, mcObj);
1395 if (fRemoveDuplicates)
1396 RemoveDuplicates(tracks);
1397}
29cfdb5f 1398
1399//____________________________________________________________________
1400void AliAnalysisTaskPhiCorrelations::SelectCharge(TObjArray* tracks)
1401{
1402 // remove particles with charge not selected (depending on fTriggerSelectCharge)
1403
59375a30 1404 if (!tracks)
1405 return;
1406
29cfdb5f 1407 Int_t before = tracks->GetEntriesFast();
1408
1409 for (Int_t i=0; i<before; ++i)
1410 {
1411 AliVParticle* part = (AliVParticle*) tracks->At(i);
1412
1413 if (part->Charge() * fTriggerSelectCharge < -1)
1414 {
1415// Printf("Removing %d with charge %d", i, part->Charge());
1416 TObject* object = tracks->RemoveAt(i);
1417 if (tracks->IsOwner())
1418 delete object;
1419 }
1420 }
1421
1422 tracks->Compress();
1423
1424 if (before > tracks->GetEntriesFast())
1425 AliInfo(Form("Reduced from %d to %d", before, tracks->GetEntriesFast()));
1426}
24d8278b 1427
1428//____________________________________________________________________
1429Bool_t AliAnalysisTaskPhiCorrelations::AcceptEventCentralityWeight(Double_t centrality)
1430{
1431 // rejects "randomly" events such that the centrality gets flat
1432 // uses fCentralityWeights histogram
1433
1434 // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening
1435
1436 Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality));
e245fe0a 1437 Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.);
24d8278b 1438
1439 Bool_t result = kFALSE;
1440 if (centralityDigits < weight)
1441 result = kTRUE;
1442
1443 AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result));
1444
1445 return result;
1446}
f89c31a7
JFGO
1447
1448//____________________________________________________________________
1449void AliAnalysisTaskPhiCorrelations::ShiftTracks(TObjArray* tracks, Double_t angle)
1450{
1451 // shifts the phi angle of all tracks by angle
1452 // 0 <= angle <= 2pi
1453
1454 for (Int_t i=0; i<tracks->GetEntriesFast(); ++i)
1455 {
1456 AliDPhiBasicParticle* part = (AliDPhiBasicParticle*) tracks->At(i);
1457 Double_t newAngle = part->Phi() + angle;
1458 if (newAngle >= TMath::TwoPi())
1459 newAngle -= TMath::TwoPi();
1460
1461 part->SetPhi(newAngle);
1462 }
1463}
1464