4 #include "TLorentzVector.h"
5 #include "TGraphErrors.h"
15 #include "AliAnalysisTaskSE.h"
16 #include "AliAnalysisManager.h"
18 #include "AliESDVertex.h"
19 #include "AliESDEvent.h"
20 #include "AliESDInputHandler.h"
21 #include "AliAODEvent.h"
22 #include "AliAODTrack.h"
23 #include "AliAODInputHandler.h"
24 #include "AliAODMCParticle.h"
25 #include "AliCollisionGeometry.h"
26 #include "AliGenEventHeader.h"
27 #include "AliMCEventHandler.h"
28 #include "AliMCEvent.h"
30 #include "AliESDtrackCuts.h"
31 #include "AliEventplane.h"
34 #include "AliAnalysisUtils.h"
36 #include "AliEventPoolManager.h"
39 #include "AliPIDResponse.h"
40 #include "AliPIDCombined.h"
42 #include "AliAnalysisTaskBFPsi.h"
43 #include "AliBalancePsi.h"
44 #include "AliAnalysisTaskTriggeredBF.h"
47 // Analysis task for the BF vs Psi code
48 // Authors: Panos.Christakoglou@nikhef.nl
53 ClassImp(AliAnalysisTaskBFPsi)
55 //________________________________________________________________________
56 AliAnalysisTaskBFPsi::AliAnalysisTaskBFPsi(const char *name)
57 : AliAnalysisTaskSE(name),
59 fArrayMC(0), //+++++++++++++
61 fRunShuffling(kFALSE),
64 fRunMixingEventPlane(kFALSE),
75 fHistCentStatsUsed(0),
81 fHistTPCvsVZEROMultiplicity(0),
99 fHistdEdxVsPTPCbeforePID(NULL),
100 fHistBetavsPTOFbeforePID(NULL),
101 fHistProbTPCvsPtbeforePID(NULL),
102 fHistProbTOFvsPtbeforePID(NULL),
103 fHistProbTPCTOFvsPtbeforePID(NULL),
104 fHistNSigmaTPCvsPtbeforePID(NULL),
105 fHistNSigmaTOFvsPtbeforePID(NULL),
106 fHistBetaVsdEdXbeforePID(NULL), //+++++++
107 fHistNSigmaTPCTOFvsPtbeforePID(NULL), //++++++
108 fHistdEdxVsPTPCafterPID(NULL),
109 fHistBetavsPTOFafterPID(NULL),
110 fHistProbTPCvsPtafterPID(NULL),
111 fHistProbTOFvsPtafterPID(NULL),
112 fHistProbTPCTOFvsPtafterPID(NULL),
113 fHistNSigmaTPCvsPtafterPID(NULL),
114 fHistNSigmaTOFvsPtafterPID(NULL),
115 fHistBetaVsdEdXafterPID(NULL), //+++++++
116 fHistNSigmaTPCTOFvsPtafterPID(NULL), //+++++++
117 fHistdEdxVsPTPCbeforePIDelectron(NULL), //+++++++
118 fHistNSigmaTPCvsPtbeforePIDelectron(NULL), //+++++++
119 fHistdEdxVsPTPCafterPIDelectron(NULL), //+++++++
120 fHistNSigmaTPCvsPtafterPIDelectron(NULL), //+++++++
121 fCentralityArrayBinsForCorrections(kCENTRALITY),
122 fCentralityWeights(0x0),
125 fParticleOfInterest(kPion),
126 fPidDetectorConfig(kTPCTOF),
128 fUsePIDnSigma(kTRUE),
129 fUsePIDPropabilities(kFALSE),
131 fMinAcceptedPIDProbability(0.8),
132 fElectronRejection(kFALSE),
133 fElectronOnlyRejection(kFALSE),
134 fElectronRejectionNSigma(-1.),
135 fElectronRejectionMinPt(0.),
136 fElectronRejectionMaxPt(1000.),
138 fCentralityEstimator("V0M"),
139 fUseCentrality(kFALSE),
140 fCentralityPercentileMin(0.),
141 fCentralityPercentileMax(5.),
142 fImpactParameterMin(0.),
143 fImpactParameterMax(20.),
144 fMultiplicityEstimator("V0A"),
145 fUseMultiplicity(kFALSE),
146 fNumberOfAcceptedTracksMin(0),
147 fNumberOfAcceptedTracksMax(10000),
148 fHistNumberOfAcceptedTracks(0),
149 fHistMultiplicity(0),
150 fUseOfflineTrigger(kFALSE),
151 fCheckFirstEventInChunk(kFALSE),
152 fCheckPileUp(kFALSE),
153 fCheckPrimaryFlagAOD(kFALSE),
154 fUseMCforKinematics(kFALSE),
158 fnAODtrackCutBit(128),
161 fPtMinForCorrections(0.3),//=================================correction
162 fPtMaxForCorrections(1.5),//=================================correction
163 fPtBinForCorrections(36), //=================================correction
166 fEtaMinForCorrections(-0.8),//=================================correction
167 fEtaMaxForCorrections(0.8),//=================================correction
168 fEtaBinForCorrections(16), //=================================correction
171 fPhiMinForCorrections(0.),//=================================correction
172 fPhiMaxForCorrections(360.),//=================================correction
173 fPhiBinForCorrections(100), //=================================correction
177 fNClustersTPCCut(-1),
178 fAcceptanceParameterization(0),
180 fUseFlowAfterBurner(kFALSE),
181 fExcludeResonancesInMC(kFALSE),
182 fExcludeElectronsInMC(kFALSE),
183 fUseMCPdgCode(kFALSE),
184 fPDGCodeToBeAnalyzed(-1),
185 fEventClass("EventPlane"),
187 fHistVZEROAGainEqualizationMap(0),
188 fHistVZEROCGainEqualizationMap(0),
189 fHistVZEROChannelGainEqualizationMap(0) {
191 // Define input and output slots here
192 // Input slot #0 works with a TChain
194 //======================================================correction
195 for (Int_t i=0; i<kCENTRALITY; i++){
196 fHistCorrectionPlus[i] = NULL;
197 fHistCorrectionMinus[i] = NULL;
198 fCentralityArrayForCorrections[i] = -1.;
200 //=====================================================correction
202 DefineInput(0, TChain::Class());
203 // Output slot #0 writes into a TH1 container
204 DefineOutput(1, TList::Class());
205 DefineOutput(2, TList::Class());
206 DefineOutput(3, TList::Class());
207 DefineOutput(4, TList::Class());
208 DefineOutput(5, TList::Class());
211 //________________________________________________________________________
212 AliAnalysisTaskBFPsi::~AliAnalysisTaskBFPsi() {
215 // delete fShuffledBalance;
220 // delete fHistEventStats;
221 // delete fHistTrackStats;
232 // delete fHistEtaPhiPos;
233 // delete fHistEtaPhiNeg;
237 //________________________________________________________________________
238 void AliAnalysisTaskBFPsi::UserCreateOutputObjects() {
242 // global switch disabling the reference
243 // (to avoid "Replacing existing TH1" if several wagons are created in train)
244 Bool_t oldStatus = TH1::AddDirectoryStatus();
245 TH1::AddDirectory(kFALSE);
248 fBalance = new AliBalancePsi();
249 fBalance->SetAnalysisLevel("ESD");
250 fBalance->SetEventClass(fEventClass);
251 //fBalance->SetNumberOfBins(-1,16);
252 //fBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.);
255 if(!fShuffledBalance) {
256 fShuffledBalance = new AliBalancePsi();
257 fShuffledBalance->SetAnalysisLevel("ESD");
258 fShuffledBalance->SetEventClass(fEventClass);
259 //fShuffledBalance->SetNumberOfBins(-1,16);
260 //fShuffledBalance->SetInterval(-1,-0.8,0.8,16,0.,1.6,15.);
265 fMixedBalance = new AliBalancePsi();
266 fMixedBalance->SetAnalysisLevel("ESD");
267 fMixedBalance->SetEventClass(fEventClass);
273 fList->SetName("listQA");
276 //Balance Function list
277 fListBF = new TList();
278 fListBF->SetName("listBF");
282 fListBFS = new TList();
283 fListBFS->SetName("listBFShuffled");
284 fListBFS->SetOwner();
288 fListBFM = new TList();
289 fListBFM->SetName("listTriggeredBFMixed");
290 fListBFM->SetOwner();
294 if(fUsePID || fElectronRejection) {
295 fHistListPIDQA = new TList();
296 fHistListPIDQA->SetName("listQAPID");
297 fHistListPIDQA->SetOwner();
301 TString gCutName[7] = {"Total","Offline trigger",
302 "Vertex","Analyzed","sel. Centrality","Not1stEvInChunk","No Pile-Up"};
303 fHistEventStats = new TH2F("fHistEventStats",
304 "Event statistics;;Centrality percentile;N_{events}",
305 7,0.5,7.5,220,-5,105);
306 for(Int_t i = 1; i <= 7; i++)
307 fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data());
308 fList->Add(fHistEventStats);
310 TString gCentName[13] = {"V0M","V0A","V0C","FMD","TRK","TKL","CL0","CL1","ZNA","ZPA","V0MvsFMD","TKLvsV0M","ZEMvsZDC"};
311 fHistCentStats = new TH2F("fHistCentStats",
312 "Centrality statistics;;Cent percentile",
313 13,-0.5,12.5,220,-5,105);
314 for(Int_t i = 1; i <= 13; i++){
315 fHistCentStats->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data());
316 //fHistCentStatsUsed->GetXaxis()->SetBinLabel(i,gCentName[i-1].Data());
318 fList->Add(fHistCentStats);
320 fHistCentStatsUsed = new TH2F("fHistCentStatsUsed","Centrality statistics;;Cent percentile", 1,-0.5,0.5,220,-5,105);
321 fHistCentStatsUsed->GetXaxis()->SetBinLabel(1,fCentralityEstimator.Data());
322 fList->Add(fHistCentStatsUsed);
324 fHistTriggerStats = new TH1F("fHistTriggerStats","Trigger statistics;TriggerBit;N_{events}",1025,0,1025);
325 fList->Add(fHistTriggerStats);
327 fHistTrackStats = new TH1F("fHistTrackStats","Event statistics;TrackFilterBit;N_{events}",16,0,16);
328 fList->Add(fHistTrackStats);
330 fHistNumberOfAcceptedTracks = new TH2F("fHistNumberOfAcceptedTracks",";N_{acc.};Centrality percentile;Entries",4001,-0.5,4000.5,220,-5,105);
331 fList->Add(fHistNumberOfAcceptedTracks);
333 fHistMultiplicity = new TH1F("fHistMultiplicity",";N_{ch.};Entries",30001,-0.5,30000.5);
334 fList->Add(fHistMultiplicity);
336 // Vertex distributions
337 fHistVx = new TH1F("fHistVx","Primary vertex distribution - x coordinate;V_{x} (cm);Entries",100,-0.5,0.5);
339 fHistVy = new TH1F("fHistVy","Primary vertex distribution - y coordinate;V_{y} (cm);Entries",100,-0.5,0.5);
341 fHistVz = new TH2F("fHistVz","Primary vertex distribution - z coordinate;V_{z} (cm);Centrality percentile;Entries",100,-20.,20.,220,-5,105);
344 //TPC vs VZERO multiplicity
345 fHistTPCvsVZEROMultiplicity = new TH2F("fHistTPCvsVZEROMultiplicity","VZERO vs TPC multiplicity",10001,-0.5,10000.5,4001,-0.5,4000.5);
346 if(fMultiplicityEstimator == "V0A")
347 fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-A multiplicity (a.u.)");
348 else if(fMultiplicityEstimator == "V0C")
349 fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO-C multiplicity (a.u.)");
351 fHistTPCvsVZEROMultiplicity->GetXaxis()->SetTitle("VZERO multiplicity (a.u.)");
352 fList->Add(fHistTPCvsVZEROMultiplicity);
354 fHistVZEROSignal = new TH2F("fHistVZEROSignal","VZERO signal vs VZERO channel;VZERO channel; Signal (a.u.)",64,0.5,64.5,3001,-0.5,30000.5);
355 fList->Add(fHistVZEROSignal);
358 fHistEventPlane = new TH2F("fHistEventPlane",";#Psi_{2} [deg.];Centrality percentile;Counts",100,0,360.,220,-5,105);
359 fList->Add(fHistEventPlane);
362 fHistClus = new TH2F("fHistClus","# Cluster (TPC vs. ITS)",10,0,10,200,0,200);
363 fList->Add(fHistClus);
364 fHistChi2 = new TH2F("fHistChi2","Chi2/NDF distribution;#chi^{2}/ndf;Centrality percentile",200,0,10,220,-5,105);
365 fList->Add(fHistChi2);
366 fHistDCA = new TH2F("fHistDCA","DCA (xy vs. z)",400,-5,5,400,-5,5);
367 fList->Add(fHistDCA);
368 fHistPt = new TH2F("fHistPt","p_{T} distribution;p_{T} (GeV/c);Centrality percentile",200,0,10,220,-5,105);
370 fHistEta = new TH2F("fHistEta","#eta distribution;#eta;Centrality percentile",200,-2,2,220,-5,105);
371 fList->Add(fHistEta);
372 fHistRapidity = new TH2F("fHistRapidity","y distribution;y;Centrality percentile",200,-2,2,220,-5,105);
373 fList->Add(fHistRapidity);
374 fHistPhi = new TH2F("fHistPhi","#phi distribution;#phi (rad);Centrality percentile",200,0.0,2.*TMath::Pi(),220,-5,105);
375 fList->Add(fHistPhi);
376 fHistEtaPhiPos = new TH3F("fHistEtaPhiPos","#eta-#phi distribution (+);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105);
377 fList->Add(fHistEtaPhiPos);
378 fHistEtaPhiNeg = new TH3F("fHistEtaPhiNeg","#eta-#phi distribution (-);#eta;#phi (rad);Centrality percentile",80,-2,2,72,0.0,2.*TMath::Pi(),220,-5,105);
379 fList->Add(fHistEtaPhiNeg);
380 fHistPhiBefore = new TH2F("fHistPhiBefore","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105);
381 fList->Add(fHistPhiBefore);
382 fHistPhiAfter = new TH2F("fHistPhiAfter","#phi distribution;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105);
383 fList->Add(fHistPhiAfter);
384 fHistPhiPos = new TH2F("fHistPhiPos","#phi distribution for positive particles;#phi;Centrality percentile",200,0.,2*TMath::Pi(),220,-5,105);
385 fList->Add(fHistPhiPos);
386 fHistPhiNeg = new TH2F("fHistPhiNeg","#phi distribution for negative particles;#phi;Centrality percentile",200,0.,2.*TMath::Pi(),220,-5,105);
387 fList->Add(fHistPhiNeg);
388 fHistV0M = new TH2F("fHistV0M","V0 Multiplicity C vs. A",500, 0, 20000, 500, 0, 20000);
389 fList->Add(fHistV0M);
390 TString gRefTrackName[6] = {"tracks","tracksPos","tracksNeg","tracksTPConly","clusITS0","clusITS1"};
391 fHistRefTracks = new TH2F("fHistRefTracks","Nr of Ref tracks/event vs. ref track estimator;;Nr of tracks",6, 0, 6, 400, 0, 20000);
392 for(Int_t i = 1; i <= 6; i++)
393 fHistRefTracks->GetXaxis()->SetBinLabel(i,gRefTrackName[i-1].Data());
394 fList->Add(fHistRefTracks);
396 // Balance function histograms
397 // Initialize histograms if not done yet (including the custom binning)
398 if(!fBalance->GetHistNp()){
399 AliInfo("Histograms not yet initialized! --> Will be done now");
400 fBalance->SetCustomBinning(fCustomBinning);
401 fBalance->InitHistograms();
405 if(!fShuffledBalance->GetHistNp()) {
406 AliInfo("Histograms (shuffling) not yet initialized! --> Will be done now");
407 fShuffledBalance->SetCustomBinning(fCustomBinning);
408 fShuffledBalance->InitHistograms();
413 if(!fMixedBalance->GetHistNp()) {
414 AliInfo("Histograms (mixing) not yet initialized! --> Will be done now");
415 fMixedBalance->SetCustomBinning(fCustomBinning);
416 fMixedBalance->InitHistograms();
420 // QA histograms for different cuts
421 fList->Add(fBalance->GetQAHistHBTbefore());
422 fList->Add(fBalance->GetQAHistHBTafter());
423 fList->Add(fBalance->GetQAHistConversionbefore());
424 fList->Add(fBalance->GetQAHistConversionafter());
425 fList->Add(fBalance->GetQAHistPsiMinusPhi());
426 fList->Add(fBalance->GetQAHistResonancesBefore());
427 fList->Add(fBalance->GetQAHistResonancesRho());
428 fList->Add(fBalance->GetQAHistResonancesK0());
429 fList->Add(fBalance->GetQAHistResonancesLambda());
430 fList->Add(fBalance->GetQAHistQbefore());
431 fList->Add(fBalance->GetQAHistQafter());
433 //for(Int_t a = 0; a < ANALYSIS_TYPES; a++){
434 fListBF->Add(fBalance->GetHistNp());
435 fListBF->Add(fBalance->GetHistNn());
436 fListBF->Add(fBalance->GetHistNpn());
437 fListBF->Add(fBalance->GetHistNnn());
438 fListBF->Add(fBalance->GetHistNpp());
439 fListBF->Add(fBalance->GetHistNnp());
442 fListBFS->Add(fShuffledBalance->GetHistNp());
443 fListBFS->Add(fShuffledBalance->GetHistNn());
444 fListBFS->Add(fShuffledBalance->GetHistNpn());
445 fListBFS->Add(fShuffledBalance->GetHistNnn());
446 fListBFS->Add(fShuffledBalance->GetHistNpp());
447 fListBFS->Add(fShuffledBalance->GetHistNnp());
451 fListBFM->Add(fMixedBalance->GetHistNp());
452 fListBFM->Add(fMixedBalance->GetHistNn());
453 fListBFM->Add(fMixedBalance->GetHistNpn());
454 fListBFM->Add(fMixedBalance->GetHistNnn());
455 fListBFM->Add(fMixedBalance->GetHistNpp());
456 fListBFM->Add(fMixedBalance->GetHistNnp());
463 Int_t trackDepth = fMixingTracks;
464 Int_t poolsize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager
467 Double_t* centbins = NULL;
468 Int_t nCentralityBins;
469 if(fBalance->IsUseVertexBinning()){
470 centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centralityVertex", nCentralityBins);
473 centbins = fBalance->GetBinning(fBalance->GetBinningString(), "centrality", nCentralityBins);
477 Double_t* multbins = NULL;
478 Int_t nMultiplicityBins;
479 multbins = fBalance->GetBinning(fBalance->GetBinningString(), "multiplicity", nMultiplicityBins);
482 Double_t* vtxbins = NULL;
484 if(fBalance->IsUseVertexBinning()){
485 vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertexVertex", nVertexBins);
488 vtxbins = fBalance->GetBinning(fBalance->GetBinningString(), "vertex", nVertexBins);
491 // Event plane angle (Psi) bins
492 Double_t* psibins = NULL;
494 psibins = fBalance->GetBinning(fBalance->GetBinningString(), "eventPlane", nPsiBins);
497 // run the event mixing also in bins of event plane (statistics!)
498 if(fRunMixingEventPlane){
499 if(fEventClass=="Multiplicity"){
500 if(multbins && vtxbins && psibins){
501 fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins, nPsiBins, psibins);
505 if(centbins && vtxbins && psibins){
506 fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins, nPsiBins, psibins);
511 if(fEventClass=="Multiplicity"){
512 if(multbins && vtxbins){
513 fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nMultiplicityBins, multbins, nVertexBins, vtxbins);
517 if(centbins && vtxbins){
518 fPoolMgr = new AliEventPoolManager(poolsize, trackDepth, nCentralityBins, centbins, nVertexBins, vtxbins);
523 // check pool manager
525 AliError("Event Mixing required, but Pool Manager not initialized...");
530 if(fESDtrackCuts) fList->Add(fESDtrackCuts);
532 //====================PID========================//
534 fPIDCombined = new AliPIDCombined();
535 fPIDCombined->SetDefaultTPCPriors();
537 fHistdEdxVsPTPCbeforePID = new TH2D ("dEdxVsPTPCbefore","dEdxVsPTPCbefore", 1000, -10.0, 10.0, 1000, 0, 1000);
538 fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePID);
540 fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2);
541 fHistListPIDQA->Add(fHistBetavsPTOFbeforePID);
543 fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0);
544 fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID);
546 fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0);
547 fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID);
549 fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0);
550 fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID);
552 fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500);
553 fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID);
555 fHistNSigmaTOFvsPtbeforePID = new TH2D ("NSigmaTOFvsPtbefore","NSigmaTOFvsPtbefore", 1000, -10, 10, 1000, 0, 500);
556 fHistListPIDQA->Add(fHistNSigmaTOFvsPtbeforePID);
558 fHistBetaVsdEdXbeforePID = new TH2D ("BetaVsdEdXbefore","BetaVsdEdXbefore", 1000, 0., 1000, 1000, 0, 1.2);
559 fHistListPIDQA->Add(fHistBetaVsdEdXbeforePID); //++++++++
561 fHistNSigmaTPCTOFvsPtbeforePID = new TH2D ("NSigmaTPCTOFvsPtbefore","NSigmaTPCTOFvsPtbefore", 1000, -10., 10., 1000, 0, 500);
562 fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtbeforePID); //++++++++
564 fHistdEdxVsPTPCafterPID = new TH2D ("dEdxVsPTPCafter","dEdxVsPTPCafter", 1000, -10, 10, 1000, 0, 1000);
565 fHistListPIDQA->Add(fHistdEdxVsPTPCafterPID);
567 fHistBetavsPTOFafterPID = new TH2D ("BetavsPTOFafter","BetavsPTOFafter", 1000, -10, 10, 1000, 0, 1.2);
568 fHistListPIDQA->Add(fHistBetavsPTOFafterPID);
570 fHistProbTPCvsPtafterPID = new TH2D ("ProbTPCvsPtafter","ProbTPCvsPtafter", 1000, -10, 10, 1000, 0, 2);
571 fHistListPIDQA->Add(fHistProbTPCvsPtafterPID);
573 fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000, -10, 10, 1000, 0, 2);
574 fHistListPIDQA->Add(fHistProbTOFvsPtafterPID);
576 fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0);
577 fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID);
579 fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500);
580 fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID);
582 fHistNSigmaTOFvsPtafterPID = new TH2D ("NSigmaTOFvsPtafter","NSigmaTOFvsPtafter", 1000, -10, 10, 1000, 0, 500);
583 fHistListPIDQA->Add(fHistNSigmaTOFvsPtafterPID);
585 fHistBetaVsdEdXafterPID = new TH2D ("BetaVsdEdXafter","BetaVsdEdXafter", 1000, 0., 1000, 1000, 0, 1.2);
586 fHistListPIDQA->Add(fHistBetaVsdEdXafterPID); //++++++++
588 fHistNSigmaTPCTOFvsPtafterPID = new TH2D ("NSigmaTPCTOFvsPtafter","NSigmaTPCTOFvsPtafter", 1000, -10., 10., 1000, 0, 500);
589 fHistListPIDQA->Add(fHistNSigmaTPCTOFvsPtafterPID); //++++++++
592 // for electron rejection only TPC nsigma histograms
593 if(fElectronRejection) {
595 fHistdEdxVsPTPCbeforePIDelectron = new TH2D ("dEdxVsPTPCbeforeelectron","dEdxVsPTPCbeforeelectron", 1000, -10.0, 10.0, 1000, 0, 1000);
596 fHistListPIDQA->Add(fHistdEdxVsPTPCbeforePIDelectron);
598 fHistNSigmaTPCvsPtbeforePIDelectron = new TH2D ("NSigmaTPCvsPtbeforeelectron","NSigmaTPCvsPtbeforeelectron", 1000, -10, 10, 1000, 0, 500);
599 fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePIDelectron);
601 fHistdEdxVsPTPCafterPIDelectron = new TH2D ("dEdxVsPTPCafterelectron","dEdxVsPTPCafterelectron", 1000, -10, 10, 1000, 0, 1000);
602 fHistListPIDQA->Add(fHistdEdxVsPTPCafterPIDelectron);
604 fHistNSigmaTPCvsPtafterPIDelectron = new TH2D ("NSigmaTPCvsPtafterelectron","NSigmaTPCvsPtafterelectron", 1000, -10, 10, 1000, 0, 500);
605 fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPIDelectron);
607 //====================PID========================//
611 PostData(2, fListBF);
612 if(fRunShuffling) PostData(3, fListBFS);
613 if(fRunMixing) PostData(4, fListBFM);
614 if(fUsePID || fElectronRejection) PostData(5, fHistListPIDQA); //PID
616 AliInfo("Finished setting up the Output");
618 TH1::AddDirectory(oldStatus);
622 //________________________________________________________________________
623 void AliAnalysisTaskBFPsi::SetInputCorrection(TString filename,
624 Int_t nCentralityBins,
625 Double_t *centralityArrayForCorrections) {
626 //Open files that will be used for correction
627 fCentralityArrayBinsForCorrections = nCentralityBins;
628 for (Int_t i=0; i<nCentralityBins; i++)
629 fCentralityArrayForCorrections[i] = centralityArrayForCorrections[i];
631 // No file specified -> run without corrections
632 if(!filename.Contains(".root")) {
633 AliInfo(Form("No correction file specified (= %s) --> run without corrections",filename.Data()));
637 //Open the input file
638 TFile *f = TFile::Open(filename);
640 AliInfo(Form("File %s not found --> run without corrections",filename.Data()));
644 //TString listEffName = "";
645 for (Int_t iCent = 0; iCent < fCentralityArrayBinsForCorrections-1; iCent++) {
646 //Printf("iCent %d:",iCent);
647 TString histoName = "fHistCorrectionPlus";
648 histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1]));
649 fHistCorrectionPlus[iCent]= dynamic_cast<TH3F *>(f->Get(histoName.Data()));
650 if(!fHistCorrectionPlus[iCent]) {
651 AliError(Form("fHist %s not found!!!",histoName.Data()));
655 histoName = "fHistCorrectionMinus";
656 histoName += Form("%d-%d",(Int_t)(fCentralityArrayForCorrections[iCent]),(Int_t)(fCentralityArrayForCorrections[iCent+1]));
657 fHistCorrectionMinus[iCent] = dynamic_cast<TH3F *>(f->Get(histoName.Data()));
658 if(!fHistCorrectionMinus[iCent]) {
659 AliError(Form("fHist %s not found!!!",histoName.Data()));
662 }//loop over centralities: ONLY the PbPb case is covered
664 if(fHistCorrectionPlus[0]){
665 fEtaMinForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmin();
666 fEtaMaxForCorrections = fHistCorrectionPlus[0]->GetXaxis()->GetXmax();
667 fEtaBinForCorrections = fHistCorrectionPlus[0]->GetNbinsX();
669 fPtMinForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmin();
670 fPtMaxForCorrections = fHistCorrectionPlus[0]->GetYaxis()->GetXmax();
671 fPtBinForCorrections = fHistCorrectionPlus[0]->GetNbinsY();
673 fPhiMinForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmin();
674 fPhiMaxForCorrections = fHistCorrectionPlus[0]->GetZaxis()->GetXmax();
675 fPhiBinForCorrections = fHistCorrectionPlus[0]->GetNbinsZ();
679 //________________________________________________________________________
680 void AliAnalysisTaskBFPsi::UserExec(Option_t *) {
682 // Called for each event
684 TString gAnalysisLevel = fBalance->GetAnalysisLevel();
685 Int_t gNumberOfAcceptedTracks = 0;
686 Double_t lMultiplicityVar = -999.; //-1
687 Double_t gReactionPlane = -1.;
690 // get the event (for generator level: MCEvent())
691 AliVEvent* eventMain = NULL;
692 if(gAnalysisLevel == "MC") {
693 eventMain = dynamic_cast<AliVEvent*>(MCEvent());
696 eventMain = dynamic_cast<AliVEvent*>(InputEvent());
697 // for HBT like cuts need magnetic field sign
698 bSign = (eventMain->GetMagneticField() > 0) ? 1 : -1;
701 AliError("eventMain not available");
705 // PID Response task active?
706 if(fUsePID || fElectronRejection) {
707 fPIDResponse = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetPIDResponse();
708 if (!fPIDResponse) AliFatal("This Task needs the PID response attached to the inputHandler");
711 // check event cuts and fill event histograms
712 if((lMultiplicityVar = IsEventAccepted(eventMain)) < 0){
715 // get the reaction plane
716 if(fEventClass != "Multiplicity") {
717 gReactionPlane = GetEventPlane(eventMain);
718 fHistEventPlane->Fill(gReactionPlane,lMultiplicityVar);
719 if(gReactionPlane < 0){
724 // get the accepted tracks in main event
725 TObjArray *tracksMain = GetAcceptedTracks(eventMain,lMultiplicityVar,gReactionPlane);
726 gNumberOfAcceptedTracks = tracksMain->GetEntriesFast();
728 //multiplicity cut (used in pp)
729 fHistNumberOfAcceptedTracks->Fill(gNumberOfAcceptedTracks,lMultiplicityVar);
731 // store charges of all accepted tracks,shuffle and reassign(two extra loops)
732 TObjArray* tracksShuffled = NULL;
734 tracksShuffled = GetShuffledTracks(tracksMain,lMultiplicityVar);
740 // 1. First get an event pool corresponding in mult (cent) and
741 // zvertex to the current event. Once initialized, the pool
742 // should contain nMix (reduced) events. This routine does not
743 // pre-scan the chain. The first several events of every chain
744 // will be skipped until the needed pools are filled to the
745 // specified depth. If the pool categories are not too rare, this
746 // should not be a problem. If they are rare, you could lose`
749 // 2. Collect the whole pool's content of tracks into one TObjArray
750 // (bgTracks), which is effectively a single background super-event.
752 // 3. The reduced and bgTracks arrays must both be passed into
753 // FillCorrelations(). Also nMix should be passed in, so a weight
754 // of 1./nMix can be applied.
756 AliEventPool* pool = fPoolMgr->GetEventPool(lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane);
759 AliFatal(Form("No pool found for centrality = %f, zVtx = %f, psi = %f", lMultiplicityVar, eventMain->GetPrimaryVertex()->GetZ(),gReactionPlane));
765 if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5){
768 Int_t nMix = pool->GetCurrentNEvents();
769 //cout << "nMix = " << nMix << " tracks in pool = " << pool->NTracksInPool() << endl;
771 //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(2);
772 //((TH2F*) fListOfHistos->FindObject("mixedDist"))->Fill(centrality, pool->NTracksInPool());
773 //if (pool->IsReady())
774 //((TH1F*) fListOfHistos->FindObject("eventStat"))->Fill(3);
776 // Fill mixed-event histos here
777 for (Int_t jMix=0; jMix<nMix; jMix++)
779 TObjArray* tracksMixed = pool->GetEvent(jMix);
780 fMixedBalance->CalculateBalance(gReactionPlane,tracksMain,tracksMixed,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ());
784 // Update the Event pool
785 pool->UpdatePool(tracksMain);
791 // calculate balance function
792 fBalance->CalculateBalance(gReactionPlane,tracksMain,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ());
794 // calculate shuffled balance function
795 if(fRunShuffling && tracksShuffled != NULL) {
796 fShuffledBalance->CalculateBalance(gReactionPlane,tracksShuffled,NULL,bSign,lMultiplicityVar,eventMain->GetPrimaryVertex()->GetZ());
800 //________________________________________________________________________
801 Double_t AliAnalysisTaskBFPsi::IsEventAccepted(AliVEvent *event){
802 // Checks the Event cuts
803 // Fills Event statistics histograms
805 Bool_t isSelectedMain = kTRUE;
806 Float_t gRefMultiplicity = -1.;
807 TString gAnalysisLevel = fBalance->GetAnalysisLevel();
809 AliMCEvent *mcevent = dynamic_cast<AliMCEvent*>(event);
811 fHistEventStats->Fill(1,gRefMultiplicity); //all events
813 // check first event in chunk (is not needed for new reconstructions)
814 if(fCheckFirstEventInChunk){
816 if(ut.IsFirstEventInChunk(event))
818 fHistEventStats->Fill(6,gRefMultiplicity);
820 // check for pile-up event
823 ut.SetUseMVPlpSelection(kTRUE);
824 ut.SetUseOutOfBunchPileUp(kTRUE);
825 if(ut.IsPileUpEvent(event))
827 fHistEventStats->Fill(7,gRefMultiplicity);
830 // Event trigger bits
831 fHistTriggerStats->Fill(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected());
832 if(fUseOfflineTrigger)
833 isSelectedMain = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
836 fHistEventStats->Fill(2,gRefMultiplicity); //triggered events
839 if(gAnalysisLevel == "MC") {
841 AliError("mcEvent not available");
846 AliGenEventHeader *header = dynamic_cast<AliGenEventHeader*>(mcevent->GenEventHeader());
848 TArrayF gVertexArray;
849 header->PrimaryVertex(gVertexArray);
850 //Printf("Vertex: %lf (x) - %lf (y) - %lf (z)",
851 //gVertexArray.At(0),
852 //gVertexArray.At(1),
853 //gVertexArray.At(2));
854 fHistEventStats->Fill(3,gRefMultiplicity); //events with a proper vertex
855 if(TMath::Abs(gVertexArray.At(0)) < fVxMax) {
856 if(TMath::Abs(gVertexArray.At(1)) < fVyMax) {
857 if(TMath::Abs(gVertexArray.At(2)) < fVzMax) {
858 fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events
860 // get the reference multiplicty or centrality
861 gRefMultiplicity = GetRefMultiOrCentrality(event);
863 fHistVx->Fill(gVertexArray.At(0));
864 fHistVy->Fill(gVertexArray.At(1));
865 fHistVz->Fill(gVertexArray.At(2),gRefMultiplicity);
867 // take only events inside centrality class
869 if((fImpactParameterMin < gRefMultiplicity) && (fImpactParameterMax > gRefMultiplicity)){
870 fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality
871 return gRefMultiplicity;
874 // take events only within the same multiplicity class
875 else if(fUseMultiplicity) {
876 if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) {
877 fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity
878 return gRefMultiplicity;
880 }//multiplicity range
888 // Event Vertex AOD, ESD, ESDMC
890 const AliVVertex *vertex = event->GetPrimaryVertex();
894 vertex->GetCovarianceMatrix(fCov);
895 if(vertex->GetNContributors() > 0) {
897 fHistEventStats->Fill(3,gRefMultiplicity); //proper vertex
898 if(TMath::Abs(vertex->GetX()) < fVxMax) {
899 if(TMath::Abs(vertex->GetY()) < fVyMax) {
900 if(TMath::Abs(vertex->GetZ()) < fVzMax) {
901 fHistEventStats->Fill(4,gRefMultiplicity);//analyzed events
903 // get the reference multiplicty or centrality
904 gRefMultiplicity = GetRefMultiOrCentrality(event);
906 fHistVx->Fill(vertex->GetX());
907 fHistVy->Fill(vertex->GetY());
908 fHistVz->Fill(vertex->GetZ(),gRefMultiplicity);
910 // take only events inside centrality class
912 if((gRefMultiplicity > fCentralityPercentileMin) && (gRefMultiplicity < fCentralityPercentileMax)){
914 // centrality weighting (optional for 2011 if central and semicentral triggers are used)
915 if (fCentralityWeights && !AcceptEventCentralityWeight(gRefMultiplicity)){
916 AliInfo(Form("Rejecting event because of centrality weighting: %f", gRefMultiplicity));
920 fHistEventStats->Fill(5,gRefMultiplicity); //events with correct centrality
921 return gRefMultiplicity;
924 // take events only within the same multiplicity class
925 else if(fUseMultiplicity) {
927 //Printf("N(min): %.0f, N(max): %.0f - N(ref): %.0f",fNumberOfAcceptedTracksMin,
928 //fNumberOfAcceptedTracksMax,gRefMultiplicity);
930 if((gRefMultiplicity > fNumberOfAcceptedTracksMin) && (gRefMultiplicity < fNumberOfAcceptedTracksMax)) {
931 fHistEventStats->Fill(5,gRefMultiplicity); //events with correct multiplicity
932 return gRefMultiplicity;
934 }//multiplicity range
938 }//proper vertex resolution
939 }//proper number of contributors
940 }//vertex object valid
944 // in all other cases return -1 (event not accepted)
949 //________________________________________________________________________
950 Double_t AliAnalysisTaskBFPsi::GetRefMultiOrCentrality(AliVEvent *event){
951 // Checks the Event cuts
952 // Fills Event statistics histograms
954 Float_t gCentrality = -1.;
955 Double_t gMultiplicity = -1.;
956 TString gAnalysisLevel = fBalance->GetAnalysisLevel();
959 // calculate centrality always (not only in centrality mode)
960 if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ) { //centrality in AOD header //++++++++++++++
961 AliAODHeader *header = (AliAODHeader*) event->GetHeader();
963 gCentrality = header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data());
965 // QA for centrality estimators
966 fHistCentStats->Fill(0.,header->GetCentralityP()->GetCentralityPercentile("V0M"));
967 fHistCentStats->Fill(1.,header->GetCentralityP()->GetCentralityPercentile("V0A"));
968 fHistCentStats->Fill(2.,header->GetCentralityP()->GetCentralityPercentile("V0C"));
969 fHistCentStats->Fill(3.,header->GetCentralityP()->GetCentralityPercentile("FMD"));
970 fHistCentStats->Fill(4.,header->GetCentralityP()->GetCentralityPercentile("TRK"));
971 fHistCentStats->Fill(5.,header->GetCentralityP()->GetCentralityPercentile("TKL"));
972 fHistCentStats->Fill(6.,header->GetCentralityP()->GetCentralityPercentile("CL0"));
973 fHistCentStats->Fill(7.,header->GetCentralityP()->GetCentralityPercentile("CL1"));
974 fHistCentStats->Fill(8.,header->GetCentralityP()->GetCentralityPercentile("ZNA"));
975 fHistCentStats->Fill(9.,header->GetCentralityP()->GetCentralityPercentile("ZPA"));
976 fHistCentStats->Fill(10.,header->GetCentralityP()->GetCentralityPercentile("V0MvsFMD"));
977 fHistCentStats->Fill(11.,header->GetCentralityP()->GetCentralityPercentile("TKLvsV0M"));
978 fHistCentStats->Fill(12.,header->GetCentralityP()->GetCentralityPercentile("ZEMvsZDC"));
980 // Centrality estimator USED ++++++++++++++++++++++++++++++
981 fHistCentStatsUsed->Fill(0.,header->GetCentralityP()->GetCentralityPercentile(fCentralityEstimator.Data()));
983 // centrality QA (V0M)
984 fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C());
986 // centrality QA (reference tracks)
987 fHistRefTracks->Fill(0.,header->GetRefMultiplicity());
988 fHistRefTracks->Fill(1.,header->GetRefMultiplicityPos());
989 fHistRefTracks->Fill(2.,header->GetRefMultiplicityNeg());
990 fHistRefTracks->Fill(3.,header->GetTPConlyRefMultiplicity());
991 fHistRefTracks->Fill(4.,header->GetNumberOfITSClusters(0));
992 fHistRefTracks->Fill(5.,header->GetNumberOfITSClusters(1));
993 fHistRefTracks->Fill(6.,header->GetNumberOfITSClusters(2));
994 fHistRefTracks->Fill(7.,header->GetNumberOfITSClusters(3));
995 fHistRefTracks->Fill(8.,header->GetNumberOfITSClusters(4));
1000 else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){ // centrality class for ESDs or MC-ESDs
1001 AliCentrality *centrality = event->GetCentrality();
1002 gCentrality = centrality->GetCentralityPercentile(fCentralityEstimator.Data());
1004 // QA for centrality estimators
1005 fHistCentStats->Fill(0.,centrality->GetCentralityPercentile("V0M"));
1006 fHistCentStats->Fill(1.,centrality->GetCentralityPercentile("V0A"));
1007 fHistCentStats->Fill(2.,centrality->GetCentralityPercentile("V0C"));
1008 fHistCentStats->Fill(3.,centrality->GetCentralityPercentile("FMD"));
1009 fHistCentStats->Fill(4.,centrality->GetCentralityPercentile("TRK"));
1010 fHistCentStats->Fill(5.,centrality->GetCentralityPercentile("TKL"));
1011 fHistCentStats->Fill(6.,centrality->GetCentralityPercentile("CL0"));
1012 fHistCentStats->Fill(7.,centrality->GetCentralityPercentile("CL1"));
1013 fHistCentStats->Fill(8.,centrality->GetCentralityPercentile("ZNA"));
1014 fHistCentStats->Fill(9.,centrality->GetCentralityPercentile("ZPA"));
1015 fHistCentStats->Fill(10.,centrality->GetCentralityPercentile("V0MvsFMD"));
1016 fHistCentStats->Fill(11.,centrality->GetCentralityPercentile("TKLvsV0M"));
1017 fHistCentStats->Fill(12.,centrality->GetCentralityPercentile("ZEMvsZDC"));
1019 // Centrality estimator USED ++++++++++++++++++++++++++++++
1020 fHistCentStatsUsed->Fill(0.,centrality->GetCentralityPercentile(fCentralityEstimator.Data()));
1022 // centrality QA (V0M)
1023 fHistV0M->Fill(event->GetVZEROData()->GetMTotV0A(), event->GetVZEROData()->GetMTotV0C());
1026 else if(gAnalysisLevel == "MC"){
1027 Double_t gImpactParameter = 0.;
1028 AliMCEvent *gMCEvent = dynamic_cast<AliMCEvent*>(event);
1030 AliCollisionGeometry* headerH = dynamic_cast<AliCollisionGeometry*>(gMCEvent->GenEventHeader());
1032 gImpactParameter = headerH->ImpactParameter();
1033 gCentrality = gImpactParameter;
1042 // calculate reference multiplicity always (not only in multiplicity mode)
1043 if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD"){
1044 AliESDEvent* gESDEvent = dynamic_cast<AliESDEvent*>(event);
1046 gMultiplicity = fESDtrackCuts->GetReferenceMultiplicity(gESDEvent, AliESDtrackCuts::kTrackletsITSTPC,0.5);
1047 fHistMultiplicity->Fill(gMultiplicity);
1051 else if(gAnalysisLevel == "AOD"|| gAnalysisLevel == "MCAOD" || gAnalysisLevel == "MCAODrec" ){
1052 AliAODHeader *header = (AliAODHeader*) event->GetHeader();
1053 if ((fMultiplicityEstimator == "V0M")||
1054 (fMultiplicityEstimator == "V0A")||
1055 (fMultiplicityEstimator == "V0C") ||
1056 (fMultiplicityEstimator == "TPC")) {
1057 gMultiplicity = GetReferenceMultiplicityFromAOD(event);
1058 if(fDebugLevel) Printf("Reference multiplicity (calculated): %.0f",gMultiplicity);
1062 gMultiplicity = header->GetRefMultiplicity();
1063 if(fDebugLevel) Printf("Reference multiplicity (AOD header): %.0f",gMultiplicity);
1065 fHistMultiplicity->Fill(gMultiplicity);
1067 else if(gAnalysisLevel == "MC") {
1068 AliMCEvent* gMCEvent = dynamic_cast<AliMCEvent*>(event);
1069 //Calculating the multiplicity as the number of charged primaries
1070 //within \pm 0.8 in eta and pT > 0.1 GeV/c
1071 for(Int_t iParticle = 0; iParticle < gMCEvent->GetNumberOfPrimaries(); iParticle++) {
1072 AliMCParticle* track = dynamic_cast<AliMCParticle *>(gMCEvent->GetTrack(iParticle));
1074 AliError(Form("Could not receive particle %d", iParticle));
1078 //exclude non stable particles
1079 if(!(gMCEvent->IsPhysicalPrimary(iParticle))) continue;
1082 if (fMultiplicityEstimator == "V0M") {
1083 if((track->Eta() > 5.1 || track->Eta() < 2.8)&&(track->Eta() < -3.7 || track->Eta() > -1.7))
1085 else if (fMultiplicityEstimator == "V0A") {
1086 if(track->Eta() > 5.1 || track->Eta() < 2.8) continue;}
1087 else if (fMultiplicityEstimator == "V0C") {
1088 if(track->Eta() > -1.7 || track->Eta() < -3.7) continue;}
1089 else if (fMultiplicityEstimator == "TPC") {
1090 if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue;
1091 if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue;
1094 if(track->Pt() < fPtMin || track->Pt() > fPtMax) continue;
1095 if(track->Eta() < fEtaMin || track->Eta() > fEtaMax) continue;
1099 if(track->Charge() == 0) continue;
1102 }//loop over primaries
1103 fHistMultiplicity->Fill(gMultiplicity);
1110 // decide what should be returned only here
1111 Double_t lReturnVal = -100;
1112 if(fEventClass=="Multiplicity"){
1113 lReturnVal = gMultiplicity;
1114 }else if(fEventClass=="Centrality"){
1115 lReturnVal = gCentrality;
1120 //________________________________________________________________________
1121 Double_t AliAnalysisTaskBFPsi::GetReferenceMultiplicityFromAOD(AliVEvent *event){
1122 //Function that returns the reference multiplicity from AODs (data or reco MC)
1123 //Different ref. mult. implemented: V0M, V0A, V0C, TPC
1124 Double_t gRefMultiplicity = 0., gRefMultiplicityTPC = 0.;
1125 Double_t gRefMultiplicityVZERO = 0., gRefMultiplicityVZEROA = 0., gRefMultiplicityVZEROC = 0.;
1127 AliAODHeader *header = dynamic_cast<AliAODHeader *>(event->GetHeader());
1129 Printf("ERROR: AOD header not available");
1132 Int_t gRunNumber = header->GetRunNumber();
1134 // Loop over tracks in event
1135 for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {
1136 AliAODTrack* aodTrack = dynamic_cast<AliAODTrack *>(event->GetTrack(iTracks));
1138 AliError(Form("Could not receive track %d", iTracks));
1143 if(!aodTrack->TestFilterBit(fnAODtrackCutBit)) continue;
1145 if(aodTrack->Charge() == 0) continue;
1146 // Kinematics cuts from ESD track cuts
1147 if( aodTrack->Pt() < fPtMin || aodTrack->Pt() > fPtMax) continue;
1148 if( aodTrack->Eta() < fEtaMin || aodTrack->Eta() > fEtaMax) continue;
1150 //=================PID (so far only for electron rejection)==========================//
1151 if(fElectronRejection) {
1152 // get the electron nsigma
1153 Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron));
1155 // check only for given momentum range
1156 if( aodTrack->Pt() > fElectronRejectionMinPt && aodTrack->Pt() < fElectronRejectionMaxPt ){
1157 //look only at electron nsigma
1158 if(!fElectronOnlyRejection) {
1159 //Make the decision based on the n-sigma of electrons
1160 if(nSigma < fElectronRejectionNSigma) continue;
1163 Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion));
1164 Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon));
1165 Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton));
1167 //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species)
1168 if(nSigma < fElectronRejectionNSigma
1169 && nSigmaPions > fElectronRejectionNSigma
1170 && nSigmaKaons > fElectronRejectionNSigma
1171 && nSigmaProtons > fElectronRejectionNSigma ) continue;
1174 }//electron rejection
1176 gRefMultiplicityTPC += 1.0;
1179 //VZERO segmentation in two detectors (0-31: VZERO-C, 32-63: VZERO-A)
1180 for(Int_t iChannel = 0; iChannel < 64; iChannel++) {
1181 fHistVZEROSignal->Fill(iChannel,event->GetVZEROEqMultiplicity(iChannel));
1184 gRefMultiplicityVZEROC += event->GetVZEROEqMultiplicity(iChannel);
1185 else if(iChannel >= 32)
1186 gRefMultiplicityVZEROA += event->GetVZEROEqMultiplicity(iChannel);
1189 //Equalization of gain
1190 Double_t gFactorA = GetEqualizationFactor(gRunNumber,"A");
1192 gRefMultiplicityVZEROA /= gFactorA;
1193 Double_t gFactorC = GetEqualizationFactor(gRunNumber,"C");
1195 gRefMultiplicityVZEROC /= gFactorC;
1196 if((gFactorA != 0)&&(gFactorC != 0))
1197 gRefMultiplicityVZERO = (gRefMultiplicityVZEROA/gFactorA)+(gRefMultiplicityVZEROC/gFactorC);
1200 Printf("VZERO multiplicity: %.0f - TPC multiplicity: %.0f",gRefMultiplicityVZERO,gRefMultiplicityTPC);
1202 fHistTPCvsVZEROMultiplicity->Fill(gRefMultiplicityVZERO,gRefMultiplicityTPC);
1204 if(fMultiplicityEstimator == "TPC")
1205 gRefMultiplicity = gRefMultiplicityTPC;
1206 else if(fMultiplicityEstimator == "V0M")
1207 gRefMultiplicity = gRefMultiplicityVZERO;
1208 else if(fMultiplicityEstimator == "V0A")
1209 gRefMultiplicity = gRefMultiplicityVZEROA;
1210 else if(fMultiplicityEstimator == "V0C")
1211 gRefMultiplicity = gRefMultiplicityVZEROC;
1213 return gRefMultiplicity;
1216 //________________________________________________________________________
1217 Double_t AliAnalysisTaskBFPsi::GetEventPlane(AliVEvent *event){
1218 // Get the event plane
1220 TString gAnalysisLevel = fBalance->GetAnalysisLevel();
1222 Float_t gVZEROEventPlane = -10.;
1223 Float_t gReactionPlane = -10.;
1224 Double_t qxTot = 0.0, qyTot = 0.0;
1226 //MC: from reaction plane
1227 if(gAnalysisLevel == "MC"){
1229 AliError("mcEvent not available");
1233 AliMCEvent *gMCEvent = dynamic_cast<AliMCEvent*>(event);
1235 AliCollisionGeometry* headerH = dynamic_cast<AliCollisionGeometry*>(gMCEvent->GenEventHeader());
1237 gReactionPlane = headerH->ReactionPlaneAngle();
1238 //gReactionPlane *= TMath::RadToDeg();
1243 // AOD,ESD,ESDMC: from VZERO Event Plane
1246 AliEventplane *ep = event->GetEventplane();
1248 gVZEROEventPlane = ep->CalculateVZEROEventPlane(event,10,2,qxTot,qyTot);
1249 if(gVZEROEventPlane < 0.) gVZEROEventPlane += TMath::Pi();
1250 //gReactionPlane = gVZEROEventPlane*TMath::RadToDeg();
1251 gReactionPlane = gVZEROEventPlane;
1255 return gReactionPlane;
1258 //________________________________________________________________________
1259 Double_t AliAnalysisTaskBFPsi::GetTrackbyTrackCorrectionMatrix( Double_t vEta,
1263 Double_t gCentrality) {
1264 // -- Get efficiency correction of particle dependent on (eta, phi, pt, charge, centrality)
1266 Double_t correction = 1.;
1267 Int_t binEta = 0, binPt = 0, binPhi = 0;
1269 //Printf("EtaMAx: %lf - EtaMin: %lf - EtaBin: %lf", fEtaMaxForCorrections,fEtaMinForCorrections,fEtaBinForCorrections);
1270 if(fEtaBinForCorrections != 0) {
1271 Double_t widthEta = (fEtaMaxForCorrections - fEtaMinForCorrections)/fEtaBinForCorrections;
1272 if(fEtaMaxForCorrections != fEtaMinForCorrections)
1273 binEta = (Int_t)((vEta-fEtaMinForCorrections)/widthEta)+1;
1276 if(fPtBinForCorrections != 0) {
1277 Double_t widthPt = (fPtMaxForCorrections - fPtMinForCorrections)/fPtBinForCorrections;
1278 if(fPtMaxForCorrections != fPtMinForCorrections)
1279 binPt = (Int_t)((vPt-fPtMinForCorrections)/widthPt) + 1;
1282 if(fPhiBinForCorrections != 0) {
1283 Double_t widthPhi = (fPhiMaxForCorrections - fPhiMinForCorrections)/fPhiBinForCorrections;
1284 if(fPhiMaxForCorrections != fPhiMinForCorrections)
1285 binPhi = (Int_t)((vPhi-fPhiMinForCorrections)/widthPhi)+ 1;
1288 Int_t gCentralityInt = -1;
1289 for (Int_t i=0; i<fCentralityArrayBinsForCorrections-1; i++){
1290 if((fCentralityArrayForCorrections[i] <= gCentrality)&&(gCentrality <= fCentralityArrayForCorrections[i+1])){
1296 // centrality not in array --> no correction
1297 if(gCentralityInt < 0){
1302 //Printf("//=============CENTRALITY=============// %d:",gCentralityInt);
1304 if(fHistCorrectionPlus[gCentralityInt]){
1306 correction = fHistCorrectionPlus[gCentralityInt]->GetBinContent(fHistCorrectionPlus[gCentralityInt]->GetBin(binEta, binPt, binPhi));
1307 //Printf("CORRECTIONplus: %.2f | Centrality %d",correction,gCentralityInt);
1310 correction = fHistCorrectionMinus[gCentralityInt]->GetBinContent(fHistCorrectionMinus[gCentralityInt]->GetBin(binEta, binPt, binPhi));
1311 //Printf("CORRECTIONminus: %.2f | Centrality %d",correction,gCentralityInt);
1317 }//centrality in array
1319 if (correction == 0.) {
1320 AliError(Form("Should not happen : bin content = 0. >> eta: %.2f | phi : %.2f | pt : %.2f | cent %d",vEta, vPhi, vPt, gCentralityInt));
1327 //________________________________________________________________________
1328 TObjArray* AliAnalysisTaskBFPsi::GetAcceptedTracks(AliVEvent *event, Double_t gCentrality, Double_t gReactionPlane){
1329 // Returns TObjArray with tracks after all track cuts (only for AOD!)
1330 // Fills QA histograms
1332 TString gAnalysisLevel = fBalance->GetAnalysisLevel();
1334 //output TObjArray holding all good tracks
1335 TObjArray* tracksAccepted = new TObjArray;
1336 tracksAccepted->SetOwner(kTRUE);
1345 if(gAnalysisLevel == "AOD") { // handling of TPC only tracks different in AOD and ESD
1346 // Loop over tracks in event
1348 for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {
1349 AliAODTrack* aodTrack = dynamic_cast<AliAODTrack *>(event->GetTrack(iTracks));
1351 AliError(Form("Could not receive track %d", iTracks));
1357 // For ESD Filter Information: ANALYSIS/macros/AddTaskESDfilter.C
1358 // take only TPC only tracks
1359 //fHistTrackStats->Fill(aodTrack->GetFilterMap());
1360 for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){
1361 fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<<iTrackBit));
1364 if(!aodTrack->TestFilterBit(fnAODtrackCutBit)) continue;
1367 // additional check on kPrimary flag
1368 if(fCheckPrimaryFlagAOD){
1369 if(aodTrack->GetType() != AliAODTrack::kPrimary)
1374 vCharge = aodTrack->Charge();
1375 vEta = aodTrack->Eta();
1377 vPhi = aodTrack->Phi();// * TMath::RadToDeg();
1378 vPt = aodTrack->Pt();
1380 //===========================PID (so far only for electron rejection)===============================//
1381 if(fElectronRejection) {
1383 // get the electron nsigma
1384 Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron));
1386 //Fill QA before the PID
1387 fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1388 fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma);
1389 //end of QA-before pid
1391 // check only for given momentum range
1392 if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){
1394 //look only at electron nsigma
1395 if(!fElectronOnlyRejection){
1397 //Make the decision based on the n-sigma of electrons
1398 if(nSigma < fElectronRejectionNSigma) continue;
1402 Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion));
1403 Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon));
1404 Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton));
1406 //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species)
1407 if(nSigma < fElectronRejectionNSigma
1408 && nSigmaPions > fElectronRejectionNSigma
1409 && nSigmaKaons > fElectronRejectionNSigma
1410 && nSigmaProtons > fElectronRejectionNSigma ) continue;
1414 //Fill QA after the PID
1415 fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1416 fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma);
1419 //===========================end of PID (so far only for electron rejection)===============================//
1421 //+++++++++++++++++++++++++++++//
1422 //===========================PID===============================//
1424 Double_t prob[AliPID::kSPECIES]={0.};
1425 Double_t probTPC[AliPID::kSPECIES]={0.};
1426 Double_t probTOF[AliPID::kSPECIES]={0.};
1427 Double_t probTPCTOF[AliPID::kSPECIES]={0.};
1429 Double_t nSigma = 0.;
1430 Double_t nSigmaTPC = 0.; //++++
1431 Double_t nSigmaTOF = 0.; //++++
1432 Double_t nSigmaTPCTOF = 0.; //++++
1433 UInt_t detUsedTPC = 0;
1434 UInt_t detUsedTOF = 0;
1435 UInt_t detUsedTPCTOF = 0;
1437 nSigmaTPC = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)fParticleOfInterest));
1438 nSigmaTOF = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(aodTrack,(AliPID::EParticleType)fParticleOfInterest));
1439 nSigmaTPCTOF = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF);
1441 //Decide what detector configuration we want to use
1442 switch(fPidDetectorConfig) {
1444 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
1446 detUsedTPC = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPC);
1447 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1448 prob[iSpecies] = probTPC[iSpecies];
1451 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF);
1453 detUsedTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTOF);
1454 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1455 prob[iSpecies] = probTOF[iSpecies];
1458 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC);
1459 nSigma = nSigmaTPCTOF;
1460 detUsedTPCTOF = fPIDCombined->ComputeProbabilities(aodTrack, fPIDResponse, probTPCTOF);
1461 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1462 prob[iSpecies] = probTPCTOF[iSpecies];
1466 }//end switch: define detector mask
1468 //Filling the PID QA
1469 Double_t tofTime = -999., length = 999., tof = -999.;
1470 Double_t c = TMath::C()*1.E-9;// m/ns
1471 Double_t beta = -999.;
1472 if ( (aodTrack->IsOn(AliAODTrack::kTOFin)) &&
1473 (aodTrack->IsOn(AliAODTrack::kTIME)) ) {
1474 tofTime = aodTrack->GetTOFsignal();//in ps
1475 length = aodTrack->GetIntegratedLength();
1476 tof = tofTime*1E-3; // ns
1479 //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n");
1483 //printf("WARNING: track with negative length found!Skipping this track for PID checks\n");
1487 length = length*0.01; // in meters
1491 fHistBetavsPTOFbeforePID ->Fill(aodTrack->P()*aodTrack->Charge(),beta);
1492 fHistProbTOFvsPtbeforePID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]);
1493 fHistNSigmaTOFvsPtbeforePID ->Fill(aodTrack->Pt(),nSigmaTOF);
1496 fHistdEdxVsPTPCbeforePID -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1497 fHistProbTPCvsPtbeforePID -> Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]);
1498 fHistNSigmaTPCvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPC);
1500 fHistProbTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]);
1503 fHistBetaVsdEdXbeforePID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++
1504 fHistNSigmaTPCTOFvsPtbeforePID -> Fill(aodTrack->Pt(),nSigmaTPCTOF);
1505 Printf("NSIGMA: %lf - nSigmaTOF: %lf - nSigmaTPC: %lf - nSigmaTPCTOF: %lf",nSigma,nSigmaTOF,nSigmaTPC,nSigmaTPCTOF);
1507 //end of QA-before pid
1509 if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) {
1510 //Make the decision based on the n-sigma
1512 if(nSigma > fPIDNSigma) continue;
1514 fHistNSigmaTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTOF);
1515 fHistNSigmaTPCvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPC);
1516 fHistNSigmaTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),nSigmaTPCTOF);
1518 //Make the decision based on the bayesian
1519 else if(fUsePIDPropabilities) {
1520 if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue;
1521 if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue;
1523 fHistProbTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTOF[fParticleOfInterest]);
1524 fHistProbTPCvsPtafterPID ->Fill(aodTrack->Pt(),probTPC[fParticleOfInterest]);
1525 fHistProbTPCTOFvsPtafterPID ->Fill(aodTrack->Pt(),probTPCTOF[fParticleOfInterest]);
1529 //Fill QA after the PID
1530 fHistBetavsPTOFafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),beta);
1531 fHistdEdxVsPTPCafterPID ->Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1532 fHistBetaVsdEdXafterPID->Fill(aodTrack->GetTPCsignal(),beta); //+++++++++
1535 //===========================PID===============================//
1536 //+++++++++++++++++++++++++++++//
1539 Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on)
1540 Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on)
1543 // Kinematics cuts from ESD track cuts
1544 if( vPt < fPtMin || vPt > fPtMax) continue;
1545 if( vEta < fEtaMin || vEta > fEtaMax) continue;
1547 // Extra DCA cuts (for systematic studies [!= -1])
1548 if( fDCAxyCut != -1 && fDCAzCut != -1){
1549 if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){
1554 // Extra TPC cuts (for systematic studies [!= -1])
1555 if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){
1558 if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){
1562 // fill QA histograms
1563 fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls());
1564 fHistDCA->Fill(dcaZ,dcaXY);
1565 fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality);
1566 fHistPt->Fill(vPt,gCentrality);
1567 fHistEta->Fill(vEta,gCentrality);
1568 fHistRapidity->Fill(vY,gCentrality);
1569 if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality);
1570 else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality);
1571 fHistPhi->Fill(vPhi,gCentrality);
1572 if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality);
1573 else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality);
1575 //=======================================correction
1576 Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);
1577 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
1579 // add the track to the TObjArray
1580 tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction));
1584 //==============================================================================================================
1585 else if(gAnalysisLevel == "MCAOD") {
1587 AliMCEvent* mcEvent = MCEvent();
1589 AliError("ERROR: Could not retrieve MC event");
1593 for (Int_t iTracks = 0; iTracks < mcEvent->GetNumberOfTracks(); iTracks++) {
1594 AliAODMCParticle *aodTrack = (AliAODMCParticle*) mcEvent->GetTrack(iTracks);
1596 AliError(Form("ERROR: Could not receive track %d (mc loop)", iTracks));
1600 if(!aodTrack->IsPhysicalPrimary()) continue;
1602 vCharge = aodTrack->Charge();
1603 vEta = aodTrack->Eta();
1605 vPhi = aodTrack->Phi();// * TMath::RadToDeg();
1606 vPt = aodTrack->Pt();
1608 // Kinematics cuts from ESD track cuts
1609 if( vPt < fPtMin || vPt > fPtMax) continue;
1610 if( vEta < fEtaMin || vEta > fEtaMax) continue;
1612 // Remove neutral tracks
1613 if( vCharge == 0 ) continue;
1615 //Exclude resonances
1616 if(fExcludeResonancesInMC) {
1618 Bool_t kExcludeParticle = kFALSE;
1619 Int_t gMotherIndex = aodTrack->GetMother();
1620 if(gMotherIndex != -1) {
1621 AliAODMCParticle* motherTrack = dynamic_cast<AliAODMCParticle *>(mcEvent->GetTrack(gMotherIndex));
1623 Int_t pdgCodeOfMother = motherTrack->GetPdgCode();
1624 //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) {
1625 //if(pdgCodeOfMother == 113) {
1626 if(pdgCodeOfMother == 113 // rho0
1627 || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+
1628 // || pdgCodeOfMother == 221 // eta
1629 // || pdgCodeOfMother == 331 // eta'
1630 // || pdgCodeOfMother == 223 // omega
1631 // || pdgCodeOfMother == 333 // phi
1632 || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0
1633 // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0*
1634 // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+*
1635 || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda
1636 || pdgCodeOfMother == 111 // pi0 Dalitz
1637 || pdgCodeOfMother == 22 // photon
1639 kExcludeParticle = kTRUE;
1644 //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi
1645 if(kExcludeParticle) continue;
1648 //Exclude electrons with PDG
1649 if(fExcludeElectronsInMC) {
1651 if(TMath::Abs(aodTrack->GetPdgCode()) == 11) continue;
1655 // fill QA histograms
1656 fHistPt->Fill(vPt,gCentrality);
1657 fHistEta->Fill(vEta,gCentrality);
1658 fHistRapidity->Fill(vY,gCentrality);
1659 if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality);
1660 else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality);
1661 fHistPhi->Fill(vPhi,gCentrality);
1662 if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality);
1663 else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality);
1665 //=======================================correction
1666 Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);
1667 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
1669 // add the track to the TObjArray
1670 tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction));
1674 //==============================================================================================================
1676 //==============================================================================================================
1677 else if(gAnalysisLevel == "MCAODrec") {
1679 /* fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
1681 printf("ERROR: fAOD not available\n");
1685 fArrayMC = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
1687 AliError("No array of MC particles found !!!");
1690 AliMCEvent* mcEvent = MCEvent();
1692 AliError("ERROR: Could not retrieve MC event");
1693 return tracksAccepted;
1696 for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {
1697 AliAODTrack* aodTrack = dynamic_cast<AliAODTrack *>(event->GetTrack(iTracks));
1699 AliError(Form("Could not receive track %d", iTracks));
1703 for(Int_t iTrackBit = 0; iTrackBit < 16; iTrackBit++){
1704 fHistTrackStats->Fill(iTrackBit,aodTrack->TestFilterBit(1<<iTrackBit));
1706 if(!aodTrack->TestFilterBit(fnAODtrackCutBit)) continue;
1708 vCharge = aodTrack->Charge();
1709 vEta = aodTrack->Eta();
1711 vPhi = aodTrack->Phi();// * TMath::RadToDeg();
1712 vPt = aodTrack->Pt();
1714 //===========================use MC information for Kinematics===============================//
1715 if(fUseMCforKinematics){
1717 Int_t label = TMath::Abs(aodTrack->GetLabel());
1718 AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label);
1721 vCharge = AODmcTrack->Charge();
1722 vEta = AODmcTrack->Eta();
1723 vY = AODmcTrack->Y();
1724 vPhi = AODmcTrack->Phi();// * TMath::RadToDeg();
1725 vPt = AODmcTrack->Pt();
1728 AliDebug(1, "no MC particle for this track");
1732 //===========================end of use MC information for Kinematics========================//
1735 //===========================PID (so far only for electron rejection)===============================//
1736 if(fElectronRejection) {
1738 // get the electron nsigma
1739 Double_t nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kElectron));
1741 //Fill QA before the PID
1742 fHistdEdxVsPTPCbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1743 fHistNSigmaTPCvsPtbeforePIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma);
1744 //end of QA-before pid
1746 // check only for given momentum range
1747 if( vPt > fElectronRejectionMinPt && vPt < fElectronRejectionMaxPt ){
1749 //look only at electron nsigma
1750 if(!fElectronOnlyRejection){
1752 //Make the decision based on the n-sigma of electrons
1753 if(nSigma < fElectronRejectionNSigma) continue;
1757 Double_t nSigmaPions = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kPion));
1758 Double_t nSigmaKaons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kKaon));
1759 Double_t nSigmaProtons = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodTrack,(AliPID::EParticleType)AliPID::kProton));
1761 //Make the decision based on the n-sigma of electrons exclusively ( = track not in nsigma region for other species)
1762 if(nSigma < fElectronRejectionNSigma
1763 && nSigmaPions > fElectronRejectionNSigma
1764 && nSigmaKaons > fElectronRejectionNSigma
1765 && nSigmaProtons > fElectronRejectionNSigma ) continue;
1769 //Fill QA after the PID
1770 fHistdEdxVsPTPCafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),aodTrack->GetTPCsignal());
1771 fHistNSigmaTPCvsPtafterPIDelectron -> Fill(aodTrack->P()*aodTrack->Charge(),nSigma);
1774 //===========================end of PID (so far only for electron rejection)===============================//
1776 Float_t dcaXY = aodTrack->DCA(); // this is the DCA from global track (not exactly what is cut on)
1777 Float_t dcaZ = aodTrack->ZAtDCA(); // this is the DCA from global track (not exactly what is cut on)
1779 // Kinematics cuts from ESD track cuts
1780 if( vPt < fPtMin || vPt > fPtMax) continue;
1781 if( vEta < fEtaMin || vEta > fEtaMax) continue;
1783 // Extra DCA cuts (for systematic studies [!= -1])
1784 if( fDCAxyCut != -1 && fDCAzCut != -1){
1785 if(TMath::Sqrt((dcaXY*dcaXY)/(fDCAxyCut*fDCAxyCut)+(dcaZ*dcaZ)/(fDCAzCut*fDCAzCut)) > 1 ){
1790 // Extra TPC cuts (for systematic studies [!= -1])
1791 if( fTPCchi2Cut != -1 && aodTrack->Chi2perNDF() > fTPCchi2Cut){
1794 if( fNClustersTPCCut != -1 && aodTrack->GetTPCNcls() < fNClustersTPCCut){
1798 //Exclude resonances
1799 if(fExcludeResonancesInMC) {
1801 Bool_t kExcludeParticle = kFALSE;
1803 Int_t label = TMath::Abs(aodTrack->GetLabel());
1804 AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label);
1807 //if (AODmcTrack->IsPhysicalPrimary()){
1809 Int_t gMotherIndex = AODmcTrack->GetMother();
1810 if(gMotherIndex != -1) {
1811 AliAODMCParticle* motherTrack = dynamic_cast<AliAODMCParticle *>(mcEvent->GetTrack(gMotherIndex));
1813 Int_t pdgCodeOfMother = motherTrack->GetPdgCode();
1814 if(pdgCodeOfMother == 113 // rho0
1815 || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+
1816 // || pdgCodeOfMother == 221 // eta
1817 // || pdgCodeOfMother == 331 // eta'
1818 // || pdgCodeOfMother == 223 // omega
1819 // || pdgCodeOfMother == 333 // phi
1820 || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0
1821 // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0*
1822 // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+*
1823 || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda
1824 || pdgCodeOfMother == 111 // pi0 Dalitz
1825 || pdgCodeOfMother == 22 // photon
1827 kExcludeParticle = kTRUE;
1832 //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi
1833 if(kExcludeParticle) continue;
1836 //Exclude electrons with PDG
1837 if(fExcludeElectronsInMC) {
1839 Int_t label = TMath::Abs(aodTrack->GetLabel());
1840 AliAODMCParticle *AODmcTrack = (AliAODMCParticle*) fArrayMC->At(label);
1843 if(TMath::Abs(AODmcTrack->GetPdgCode()) == 11) continue;
1847 // fill QA histograms
1848 fHistClus->Fill(aodTrack->GetITSNcls(),aodTrack->GetTPCNcls());
1849 fHistDCA->Fill(dcaZ,dcaXY);
1850 fHistChi2->Fill(aodTrack->Chi2perNDF(),gCentrality);
1851 fHistPt->Fill(vPt,gCentrality);
1852 fHistEta->Fill(vEta,gCentrality);
1853 fHistRapidity->Fill(vY,gCentrality);
1854 if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality);
1855 else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality);
1856 fHistPhi->Fill(vPhi,gCentrality);
1857 if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality);
1858 else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality);
1860 //=======================================correction
1861 Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);
1862 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
1864 // add the track to the TObjArray
1865 tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction));
1868 //==============================================================================================================
1870 else if(gAnalysisLevel == "ESD" || gAnalysisLevel == "MCESD") { // handling of TPC only tracks different in AOD and ESD
1872 AliESDtrack *trackTPC = NULL;
1873 AliMCParticle *mcTrack = NULL;
1875 AliMCEvent* mcEvent = NULL;
1877 // for MC ESDs use also MC information
1878 if(gAnalysisLevel == "MCESD"){
1879 mcEvent = MCEvent();
1881 AliError("mcEvent not available");
1882 return tracksAccepted;
1886 // Loop over tracks in event
1887 for (Int_t iTracks = 0; iTracks < event->GetNumberOfTracks(); iTracks++) {
1888 AliESDtrack* track = dynamic_cast<AliESDtrack *>(event->GetTrack(iTracks));
1890 AliError(Form("Could not receive track %d", iTracks));
1894 // for MC ESDs use also MC information --> MC track not used further???
1895 if(gAnalysisLevel == "MCESD"){
1896 Int_t label = TMath::Abs(track->GetLabel());
1897 if(label > mcEvent->GetNumberOfTracks()) continue;
1898 if(label > mcEvent->GetNumberOfPrimaries()) continue;
1900 mcTrack = dynamic_cast<AliMCParticle *>(mcEvent->GetTrack(label));
1901 if(!mcTrack) continue;
1904 // take only TPC only tracks
1905 trackTPC = new AliESDtrack();
1906 if(!track->FillTPCOnlyTrack(*trackTPC)) continue;
1910 if(!fESDtrackCuts->AcceptTrack(trackTPC)) continue;
1912 // fill QA histograms
1915 trackTPC->GetImpactParameters(b,bCov);
1916 if (bCov[0]<=0 || bCov[2]<=0) {
1917 AliDebug(1, "Estimated b resolution lower or equal zero!");
1918 bCov[0]=0; bCov[2]=0;
1921 Int_t nClustersTPC = -1;
1922 nClustersTPC = trackTPC->GetTPCNclsIter1(); // TPC standalone
1923 //nClustersTPC = track->GetTPCclusters(0); // global track
1924 Float_t chi2PerClusterTPC = -1;
1925 if (nClustersTPC!=0) {
1926 chi2PerClusterTPC = trackTPC->GetTPCchi2Iter1()/Float_t(nClustersTPC); // TPC standalone
1927 //chi2PerClusterTPC = track->GetTPCchi2()/Float_t(nClustersTPC); // global track
1930 //===========================PID===============================//
1932 Double_t prob[AliPID::kSPECIES]={0.};
1933 Double_t probTPC[AliPID::kSPECIES]={0.};
1934 Double_t probTOF[AliPID::kSPECIES]={0.};
1935 Double_t probTPCTOF[AliPID::kSPECIES]={0.};
1937 Double_t nSigma = 0.;
1938 UInt_t detUsedTPC = 0;
1939 UInt_t detUsedTOF = 0;
1940 UInt_t detUsedTPCTOF = 0;
1942 //Decide what detector configuration we want to use
1943 switch(fPidDetectorConfig) {
1945 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);
1946 nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest));
1947 detUsedTPC = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPC);
1948 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1949 prob[iSpecies] = probTPC[iSpecies];
1952 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF);
1953 nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest));
1954 detUsedTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTOF);
1955 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1956 prob[iSpecies] = probTOF[iSpecies];
1959 fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC);
1960 detUsedTPCTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPCTOF);
1961 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
1962 prob[iSpecies] = probTPCTOF[iSpecies];
1966 }//end switch: define detector mask
1968 //Filling the PID QA
1969 Double_t tofTime = -999., length = 999., tof = -999.;
1970 Double_t c = TMath::C()*1.E-9;// m/ns
1971 Double_t beta = -999.;
1972 Double_t nSigmaTOFForParticleOfInterest = -999.;
1973 if ( (track->IsOn(AliESDtrack::kTOFin)) &&
1974 (track->IsOn(AliESDtrack::kTIME)) ) {
1975 tofTime = track->GetTOFsignal();//in ps
1976 length = track->GetIntegratedLength();
1977 tof = tofTime*1E-3; // ns
1980 //Printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n");
1984 //printf("WARNING: track with negative length found!Skipping this track for PID checks\n");
1988 length = length*0.01; // in meters
1992 nSigmaTOFForParticleOfInterest = fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest);
1993 fHistBetavsPTOFbeforePID ->Fill(track->P()*track->Charge(),beta);
1994 fHistProbTOFvsPtbeforePID ->Fill(track->Pt(),probTOF[fParticleOfInterest]);
1995 fHistNSigmaTOFvsPtbeforePID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest);
1999 Double_t nSigmaTPCForParticleOfInterest = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest);
2000 fHistdEdxVsPTPCbeforePID -> Fill(track->P()*track->Charge(),track->GetTPCsignal());
2001 fHistProbTPCvsPtbeforePID -> Fill(track->Pt(),probTPC[fParticleOfInterest]);
2002 fHistNSigmaTPCvsPtbeforePID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest);
2003 fHistProbTPCTOFvsPtbeforePID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]);
2004 //end of QA-before pid
2006 if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) {
2007 //Make the decision based on the n-sigma
2009 if(nSigma > fPIDNSigma) continue;}
2011 //Make the decision based on the bayesian
2012 else if(fUsePIDPropabilities) {
2013 if(fParticleOfInterest != TMath::LocMax(AliPID::kSPECIES,prob)) continue;
2014 if (prob[fParticleOfInterest] < fMinAcceptedPIDProbability) continue;
2017 //Fill QA after the PID
2018 fHistBetavsPTOFafterPID ->Fill(track->P()*track->Charge(),beta);
2019 fHistProbTOFvsPtafterPID ->Fill(track->Pt(),probTOF[fParticleOfInterest]);
2020 fHistNSigmaTOFvsPtafterPID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest);
2022 fHistdEdxVsPTPCafterPID -> Fill(track->P()*track->Charge(),track->GetTPCsignal());
2023 fHistProbTPCvsPtafterPID -> Fill(track->Pt(),probTPC[fParticleOfInterest]);
2024 fHistProbTPCTOFvsPtafterPID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]);
2025 fHistNSigmaTPCvsPtafterPID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest);
2028 //===========================PID===============================//
2029 vCharge = trackTPC->Charge();
2031 vEta = trackTPC->Eta();
2032 vPhi = trackTPC->Phi();// * TMath::RadToDeg();
2033 vPt = trackTPC->Pt();
2034 fHistClus->Fill(trackTPC->GetITSclusters(0),nClustersTPC);
2035 fHistDCA->Fill(b[1],b[0]);
2036 fHistChi2->Fill(chi2PerClusterTPC,gCentrality);
2037 fHistPt->Fill(vPt,gCentrality);
2038 fHistEta->Fill(vEta,gCentrality);
2039 fHistPhi->Fill(vPhi,gCentrality);
2040 if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality);
2041 else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality);
2042 fHistRapidity->Fill(vY,gCentrality);
2043 if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality);
2044 else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality);
2046 //=======================================correction
2047 Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);
2048 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
2050 // add the track to the TObjArray
2051 tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction));
2057 else if(gAnalysisLevel == "MC"){
2059 AliError("mcEvent not available");
2063 AliMCEvent *gMCEvent = dynamic_cast<AliMCEvent*>(event);
2065 // Loop over tracks in event
2066 for (Int_t iTracks = 0; iTracks < gMCEvent->GetNumberOfPrimaries(); iTracks++) {
2067 AliMCParticle* track = dynamic_cast<AliMCParticle *>(gMCEvent->GetTrack(iTracks));
2069 AliError(Form("Could not receive particle %d", iTracks));
2073 //exclude non stable particles
2074 if(!(gMCEvent->IsPhysicalPrimary(iTracks))) continue;
2076 vCharge = track->Charge();
2077 vEta = track->Eta();
2081 if( vPt < fPtMin || vPt > fPtMax)
2084 if( vEta < fEtaMin || vEta > fEtaMax) continue;
2087 if( vY < fEtaMin || vY > fEtaMax) continue;
2090 // Remove neutral tracks
2091 if( vCharge == 0 ) continue;
2093 //analyze one set of particles
2095 TParticle *particle = track->Particle();
2096 if(!particle) continue;
2098 Int_t gPdgCode = particle->GetPdgCode();
2099 if(TMath::Abs(fPDGCodeToBeAnalyzed) != TMath::Abs(gPdgCode))
2103 //Use the acceptance parameterization
2104 if(fAcceptanceParameterization) {
2105 Double_t gRandomNumber = gRandom->Rndm();
2106 if(gRandomNumber > fAcceptanceParameterization->Eval(track->Pt()))
2110 //Exclude resonances
2111 if(fExcludeResonancesInMC) {
2112 TParticle *particle = track->Particle();
2113 if(!particle) continue;
2115 Bool_t kExcludeParticle = kFALSE;
2116 Int_t gMotherIndex = particle->GetFirstMother();
2117 if(gMotherIndex != -1) {
2118 AliMCParticle* motherTrack = dynamic_cast<AliMCParticle *>(event->GetTrack(gMotherIndex));
2120 TParticle *motherParticle = motherTrack->Particle();
2121 if(motherParticle) {
2122 Int_t pdgCodeOfMother = motherParticle->GetPdgCode();
2123 //if((pdgCodeOfMother == 113)||(pdgCodeOfMother == 213)||(pdgCodeOfMother == 221)||(pdgCodeOfMother == 223)||(pdgCodeOfMother == 331)||(pdgCodeOfMother == 333)) {
2124 if(pdgCodeOfMother == 113 // rho0
2125 || pdgCodeOfMother == 213 || pdgCodeOfMother == -213 // rho+
2126 // || pdgCodeOfMother == 221 // eta
2127 // || pdgCodeOfMother == 331 // eta'
2128 // || pdgCodeOfMother == 223 // omega
2129 // || pdgCodeOfMother == 333 // phi
2130 || pdgCodeOfMother == 311 || pdgCodeOfMother == -311 // K0
2131 // || pdgCodeOfMother == 313 || pdgCodeOfMother == -313 // K0*
2132 // || pdgCodeOfMother == 323 || pdgCodeOfMother == -323 // K+*
2133 || pdgCodeOfMother == 3122 || pdgCodeOfMother == -3122 // Lambda
2134 || pdgCodeOfMother == 111 // pi0 Dalitz
2136 kExcludeParticle = kTRUE;
2142 //Exclude from the analysis decay products of rho0, rho+, eta, eta' and phi
2143 if(kExcludeParticle) continue;
2146 //Exclude electrons with PDG
2147 if(fExcludeElectronsInMC) {
2149 TParticle *particle = track->Particle();
2152 if(TMath::Abs(particle->GetPdgCode()) == 11) continue;
2156 vPhi = track->Phi();
2157 //Printf("phi (before): %lf",vPhi);
2159 fHistPt->Fill(vPt,gCentrality);
2160 fHistEta->Fill(vEta,gCentrality);
2161 fHistPhi->Fill(vPhi,gCentrality);
2162 if(vCharge > 0) fHistEtaPhiPos->Fill(vEta,vPhi,gCentrality);
2163 else if(vCharge < 0) fHistEtaPhiNeg->Fill(vEta,vPhi,gCentrality);
2164 //fHistPhi->Fill(vPhi*TMath::RadToDeg(),gCentrality);
2165 fHistRapidity->Fill(vY,gCentrality);
2166 //if(vCharge > 0) fHistPhiPos->Fill(vPhi*TMath::RadToDeg(),gCentrality);
2167 //else if(vCharge < 0) fHistPhiNeg->Fill(vPhi*TMath::RadToDeg(),gCentrality);
2168 if(vCharge > 0) fHistPhiPos->Fill(vPhi,gCentrality);
2169 else if(vCharge < 0) fHistPhiNeg->Fill(vPhi,gCentrality);
2172 if(fUseFlowAfterBurner) {
2173 Double_t precisionPhi = 0.001;
2174 Int_t maxNumberOfIterations = 100;
2176 Double_t phi0 = vPhi;
2177 Double_t gV2 = fDifferentialV2->Eval(vPt);
2179 for (Int_t j = 0; j < maxNumberOfIterations; j++) {
2180 Double_t phiprev = vPhi;
2181 Double_t fl = vPhi - phi0 + gV2*TMath::Sin(2.*(vPhi - gReactionPlane*TMath::DegToRad()));
2182 Double_t fp = 1.0 + 2.0*gV2*TMath::Cos(2.*(vPhi - gReactionPlane*TMath::DegToRad()));
2184 if (TMath::AreEqualAbs(phiprev,vPhi,precisionPhi)) break;
2186 //Printf("phi (after): %lf\n",vPhi);
2187 Double_t vDeltaphiBefore = phi0 - gReactionPlane*TMath::DegToRad();
2188 if(vDeltaphiBefore < 0) vDeltaphiBefore += 2*TMath::Pi();
2189 fHistPhiBefore->Fill(vDeltaphiBefore,gCentrality);
2191 Double_t vDeltaphiAfter = vPhi - gReactionPlane*TMath::DegToRad();
2192 if(vDeltaphiAfter < 0) vDeltaphiAfter += 2*TMath::Pi();
2193 fHistPhiAfter->Fill(vDeltaphiAfter,gCentrality);
2197 //vPhi *= TMath::RadToDeg();
2199 //=======================================correction
2200 Double_t correction = GetTrackbyTrackCorrectionMatrix(vEta, vPhi, vPt, vCharge, gCentrality);
2201 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
2203 tracksAccepted->Add(new AliBFBasicParticle(vEta, vPhi, vPt, vCharge, correction));
2208 return tracksAccepted;
2211 //________________________________________________________________________
2212 TObjArray* AliAnalysisTaskBFPsi::GetShuffledTracks(TObjArray *tracks, Double_t gCentrality){
2213 // Clones TObjArray and returns it with tracks after shuffling the charges
2215 TObjArray* tracksShuffled = new TObjArray;
2216 tracksShuffled->SetOwner(kTRUE);
2218 vector<Short_t> *chargeVector = new vector<Short_t>; //original charge of accepted tracks
2220 for (Int_t i=0; i<tracks->GetEntriesFast(); i++)
2222 AliVParticle* track = (AliVParticle*) tracks->At(i);
2223 chargeVector->push_back(track->Charge());
2226 random_shuffle(chargeVector->begin(), chargeVector->end());
2228 for(Int_t i = 0; i < tracks->GetEntriesFast(); i++){
2229 AliVParticle* track = (AliVParticle*) tracks->At(i);
2230 //==============================correction
2231 Double_t correction = GetTrackbyTrackCorrectionMatrix(track->Eta(), track->Phi(),track->Pt(), chargeVector->at(i), gCentrality);
2232 //Printf("CORRECTIONminus: %.2f | Centrality %lf",correction,gCentrality);
2233 tracksShuffled->Add(new AliBFBasicParticle(track->Eta(), track->Phi(), track->Pt(),chargeVector->at(i), correction));
2236 delete chargeVector;
2238 return tracksShuffled;
2241 //________________________________________________________________________
2242 void AliAnalysisTaskBFPsi::SetVZEROCalibrationFile(const char* filename,
2243 const char* lhcPeriod) {
2244 //Function to setup the VZERO gain equalization
2245 //============Get the equilization map============//
2246 TFile *calibrationFile = TFile::Open(filename);
2247 if((!calibrationFile)||(!calibrationFile->IsOpen())) {
2248 Printf("No calibration file found!!!");
2252 TList *list = dynamic_cast<TList *>(calibrationFile->Get(lhcPeriod));
2254 Printf("Calibration TList not found!!!");
2258 fHistVZEROAGainEqualizationMap = dynamic_cast<TH1F *>(list->FindObject("gHistVZEROAGainEqualizationMap"));
2259 if(!fHistVZEROAGainEqualizationMap) {
2260 Printf("VZERO-A calibration object not found!!!");
2263 fHistVZEROCGainEqualizationMap = dynamic_cast<TH1F *>(list->FindObject("gHistVZEROCGainEqualizationMap"));
2264 if(!fHistVZEROCGainEqualizationMap) {
2265 Printf("VZERO-C calibration object not found!!!");
2269 fHistVZEROChannelGainEqualizationMap = dynamic_cast<TH2F *>(list->FindObject("gHistVZEROChannelGainEqualizationMap"));
2270 if(!fHistVZEROChannelGainEqualizationMap) {
2271 Printf("VZERO channel calibration object not found!!!");
2276 //________________________________________________________________________
2277 Double_t AliAnalysisTaskBFPsi::GetChannelEqualizationFactor(Int_t run,
2280 if(!fHistVZEROAGainEqualizationMap) return 1.0;
2282 for(Int_t iBinX = 1; iBinX <= fHistVZEROChannelGainEqualizationMap->GetNbinsX(); iBinX++) {
2283 Int_t gRunNumber = atoi(fHistVZEROChannelGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX));
2284 if(gRunNumber == run)
2285 return fHistVZEROChannelGainEqualizationMap->GetBinContent(iBinX,channel+1);
2291 //________________________________________________________________________
2292 Double_t AliAnalysisTaskBFPsi::GetEqualizationFactor(Int_t run,
2295 if(!fHistVZEROAGainEqualizationMap) return 1.0;
2297 TString gVZEROSide = side;
2298 for(Int_t iBinX = 1; iBinX < fHistVZEROAGainEqualizationMap->GetNbinsX(); iBinX++) {
2299 Int_t gRunNumber = atoi(fHistVZEROAGainEqualizationMap->GetXaxis()->GetBinLabel(iBinX));
2300 //cout<<"Looking for run "<<run<<" - current run: "<<gRunNumber<<endl;
2301 if(gRunNumber == run) {
2302 if(gVZEROSide == "A")
2303 return fHistVZEROAGainEqualizationMap->GetBinContent(iBinX);
2304 else if(gVZEROSide == "C")
2305 return fHistVZEROCGainEqualizationMap->GetBinContent(iBinX);
2312 //____________________________________________________________________
2313 Bool_t AliAnalysisTaskBFPsi::AcceptEventCentralityWeight(Double_t centrality)
2315 // copied from AliAnalysisTaskPhiCorrelations
2317 // rejects "randomly" events such that the centrality gets flat
2318 // uses fCentralityWeights histogram
2320 // TODO code taken and adapted from AliRDHFCuts; waiting for general class AliCentralityFlattening
2322 Double_t weight = fCentralityWeights->GetBinContent(fCentralityWeights->FindBin(centrality));
2323 Double_t centralityDigits = centrality*100. - (Int_t)(centrality*100.);
2325 Bool_t result = kFALSE;
2326 if (centralityDigits < weight)
2329 AliInfo(Form("Centrality: %f; Digits: %f; Weight: %f; Result: %d", centrality, centralityDigits, weight, result));
2334 //________________________________________________________________________
2335 void AliAnalysisTaskBFPsi::FinishTaskOutput(){
2339 AliError("fBalance not available");
2343 if (!fShuffledBalance) {
2344 AliError("fShuffledBalance not available");
2351 //________________________________________________________________________
2352 void AliAnalysisTaskBFPsi::Terminate(Option_t *) {
2353 // Draw result to the screen
2354 // Called once at the end of the query
2356 // not implemented ...