]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/STRANGENESS/Correlations/AliAnalysisTaskV0ChCorrelations.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / Correlations / AliAnalysisTaskV0ChCorrelations.cxx
CommitLineData
59bd5476 1/**************************************************************************
85c11f5a 2 * Copyright(c) 1998-2013, ALICE Experiment at CERN, All rights reserved. *
59bd5476 3 * *
4 * Author: Marek Bombara *
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/* The task selects candidates for K0s, Lambdas and AntiLambdas (trigger particles)
17 * and calculates correlations with charged unidentified particles (associated particles) in phi and eta.
74754736 18 * The task works with AOD (with or without MC info) events only and containes also mixing for acceptance corrections.
bccd1153 19 * Last update edited by Marek Bombara, August 2013, Marek.Bombara@cern.ch
59bd5476 20 */
21
22#include <TCanvas.h>
23#include <TList.h>
24#include <TH1.h>
25#include <TH2.h>
26#include <TH3.h>
27#include <THnSparse.h>
bccd1153 28#include <TObjArray.h>
29#include <TObject.h>
59bd5476 30
31#include "AliLog.h"
32#include "AliAnalysisManager.h"
33#include "AliAODTrack.h"
34#include "AliAODEvent.h"
35#include "AliAODv0.h"
36#include "AliAODcascade.h"
37#include "AliAODVertex.h"
38
74754736 39#include "AliMCEvent.h"
40#include "AliMCVertex.h"
bccd1153 41#include "AliGenEventHeader.h"
74754736 42#include "AliAODMCHeader.h"
43#include "AliAODMCParticle.h"
bccd1153 44#include "AliAnalyseLeadingTrackUE.h"
74754736 45
59bd5476 46#include "AliAODPid.h"
47#include "AliPIDResponse.h"
48#include "AliEventPoolManager.h"
49#include "AliCentrality.h"
50
51#include "AliAnalysisTaskV0ChCorrelations.h"
52#include "AliPhysicsSelectionTask.h"
53
54#include <AliMultiInputEventHandler.h>
55#include <AliMixInputEventHandler.h>
56
57ClassImp(AliAnalysisTaskV0ChCorrelations)
58ClassImp(AliV0ChBasicParticle)
59
59bd5476 60//________________________________________________________________________
61AliAnalysisTaskV0ChCorrelations::AliAnalysisTaskV0ChCorrelations(const char *name) // All data members should be initialised here
62 : AliAnalysisTaskSE(name),
74754736 63 fAnalysisMC(kFALSE),
59bd5476 64 fFillMixed(kTRUE),
bccd1153 65 fMixingTracks(50000),
59bd5476 66 fPoolMgr(0x0),
67
74754736 68 fDcaDToPV(0.5),
69 fDcaV0D(0.1),
70 fWithChCh(kFALSE),
71 fOStatus(1),
85c11f5a 72
59bd5476 73 fOutput(0),
74 fPIDResponse(0),
75 fHistCentVtx(0),
76 fHistMultiMain(0),
77 fHistMassK0(0),
78 fHistMassLambda(0),
79 fHistMassAntiLambda(0),
80
81 fHistdPhidEtaSib(0),
82 fHistdPhidEtaMix(0),
82bd566c 83 fHistNTrigSib(0),
74754736 84
85 fHistMCPtCentTrig(0),
86 fHistRCPtCentTrig(0),
87 fHistMCPtCentAs(0),
88 fHistRCPtCentAs(0),
bccd1153 89 fHistRCPtCentAll(0),
59bd5476 90
74754736 91 fHistTemp(0),
92 fHistTemp2(0)// The last in the above list should not have a comma after it
59bd5476 93{
94 // Constructor
95 // Define input and output slots here (never in the dummy constructor)
96 // Input slot #0 works with a TChain - it is connected to the default input container
97 // Output slot #1 writes into a TH1 container
98 DefineOutput(1, TList::Class()); // for output list
99}
100
101//________________________________________________________________________
102AliAnalysisTaskV0ChCorrelations::~AliAnalysisTaskV0ChCorrelations()
103{
104 // Destructor. Clean-up the output list, but not the histograms that are put inside
105 // (the list is owner and will clean-up these histograms). Protect in PROOF case.
106 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
107 delete fOutput;
108 }
109}
110
111//________________________________________________________________________
112void AliAnalysisTaskV0ChCorrelations::UserCreateOutputObjects()
113{
114 // Create histograms
115
116 fOutput = new TList();
117 fOutput->SetOwner(); // IMPORTANT!
118 // defining bins for centrality
119 Int_t nCentralityBins = 9;
120 Double_t centBins[] = {0.,10.,20.,30.,40.,50.,60.,70.,80.,90.};
121 const Double_t* centralityBins = centBins;
122 // defining bins for Z vertex
bccd1153 123 Int_t nZvtxBins = 7;
124 //Double_t vertexBins[] = {-10.,-8.,-6.,-4.,-2.,0.,2.,4.,6.,8.,10.};
125 Double_t vertexBins[] = {-7.,-5.,-3.,-1.,1.,3.,5.,7.};
59bd5476 126 const Double_t* zvtxBins = vertexBins;
127 // pt bins of associated particles for the analysis
bccd1153 128 Int_t nPtBins = 7;
129 const Double_t PtBins[8] = {2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0};
85c11f5a 130 //Int_t nPtBins = 1;
131 //const Double_t PtBins[2] = {3.0,15.0};
59bd5476 132 // pt bins of trigger particles for the analysis
bccd1153 133 Int_t nPtBinsV0 = 11;
70840314 134 //const Double_t PtBinsV0[2] = {6.0,15.0};
bccd1153 135 const Double_t PtBinsV0[12] = {4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0};
59bd5476 136 // V0 candidate: 1 - K0sig, 2 - Lamsig, 3 - Alamsig, 4 - K0bg, 5 - Lambg, 6 - Alambg
82bd566c 137 Int_t nTrigC = 7;
138 const Double_t TrigC[8] = {0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5};
59bd5476 139
140 // Create general histograms
141 fHistCentVtx = new TH2F("fHistCentVtx", "Centrality vs. Z vertex", nCentralityBins, centralityBins, nZvtxBins, zvtxBins);
142 fHistMultiMain = new TH1F("fHistMultiMain", "Multiplicity of main events", 2000, 0, 2000);
143
74754736 144 const Int_t mrBins[3] = {nPtBinsV0, nCentralityBins, nTrigC};
145 const Double_t mrMin[3] = {PtBinsV0[0], centralityBins[0], TrigC[0]};
bccd1153 146 const Double_t mrMax[3] = {PtBinsV0[11], centralityBins[9], TrigC[6]};
74754736 147
148 // Create histograms for reconstruction track and V0 efficiency
149 fHistMCPtCentTrig = new THnSparseF("fHistMCPtCentTrig", "MC Pt vs. Cent. Trig", 3, mrBins, mrMin, mrMax);
150 fHistRCPtCentTrig = new THnSparseF("fHistRCPtCentTrig", "Rec Pt vs. Cent. Trig", 3, mrBins, mrMin, mrMax);
151
152 // pt bins of associated particles for the efficiency
bccd1153 153 Int_t nPtBinsAs = 13;
154 const Double_t PtBinsAs[14] = {2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0};
74754736 155
bccd1153 156 fHistMCPtCentAs = new TH2D("fHistMCPtCentAs", "MC Pt vs. Cent. Assoc", nPtBinsAs, PtBinsAs[0], PtBinsAs[13], nCentralityBins, centBins[0], centBins[9]);
157 fHistRCPtCentAs = new TH2D("fHistRCPtCentAs", "Rec Pt vs. Cent. Assoc", nPtBinsAs, PtBinsAs[0], PtBinsAs[13], nCentralityBins, centBins[0], centBins[9]);
158 fHistRCPtCentAll = new TH2D("fHistRCPtCentAll", "Rec Pt vs. Cent. All Prim+Sec", nPtBinsAs, PtBinsAs[0], PtBinsAs[13], nCentralityBins, centBins[0], centBins[9]);
74754736 159
59bd5476 160 // defining bins for mass distributions
161 Int_t nBins = 200;
162 Double_t mk0Min = 0.40;
163 Double_t mk0Max = 0.60;
164 Double_t mlaMin = 1.07;
165 Double_t mlaMax = 1.17;
166 Double_t malMin = 1.07;
167 Double_t malMax = 1.17;
168
85c11f5a 169 const Int_t spBins[3] = {nBins, nPtBinsV0, nCentralityBins};
170 const Double_t spMinK0[3] = {mk0Min, PtBinsV0[0], centralityBins[0]};
bccd1153 171 const Double_t spMaxK0[3] = {mk0Max, PtBinsV0[11], centralityBins[9]};
85c11f5a 172 const Double_t spMinLa[3] = {mlaMin, PtBinsV0[0], centralityBins[0]};
bccd1153 173 const Double_t spMaxLa[3] = {mlaMax, PtBinsV0[11], centralityBins[9]};
85c11f5a 174 const Double_t spMinAl[3] = {malMin, PtBinsV0[0], centralityBins[0]};
bccd1153 175 const Double_t spMaxAl[3] = {malMax, PtBinsV0[11], centralityBins[9]};
59bd5476 176 // Create mass histograms
85c11f5a 177 fHistMassK0 = new THnSparseF("fHistMassK0","V0 mass for K0 hypothesis", 3, spBins, spMinK0, spMaxK0);
178 fHistMassLambda = new THnSparseF("fHistMassLambda","V0 mass for Lambda hypothesis", 3, spBins, spMinLa, spMaxLa);
179 fHistMassAntiLambda = new THnSparseF("fHistMassAntiLambda","V0 mass for AntiLambda hypothesis", 3, spBins, spMinAl, spMaxAl);
59bd5476 180
181 // defining bins for dPhi distributions
bccd1153 182 const Int_t nbPhiBins = 72;
183 //const Double_t kPi = TMath::Pi();
184 //Double_t PhiMin = -kPi/2.;
185 //Double_t PhiMax = -kPi/2. + 2*kPi;
186 Double_t PhiMin = -1.57;
187 Double_t PhiMax = 4.71;
59bd5476 188 Double_t PhiBins[nbPhiBins+1] = {0.};
189 PhiBins[0] = PhiMin;
190 for (Int_t i=0; i<nbPhiBins; i++) { PhiBins[i+1] = PhiBins[i] + (PhiMax - PhiMin)/nbPhiBins; }
191
192 // defining bins for dEta distributions
bccd1153 193 const Int_t nbEtaBins = 40;
194 Double_t EtaMin = -2.0;
195 Double_t EtaMax = 2.0;
59bd5476 196 Double_t EtaBins[nbEtaBins+1] = {0.};
197 EtaBins[0] = EtaMin;
198 for (Int_t i=0; i<nbEtaBins; i++) { EtaBins[i+1] = EtaBins[i] + (EtaMax - EtaMin)/nbEtaBins; }
199
200 const Int_t corBins[7] = {nbPhiBins, nbEtaBins, nPtBinsV0, nPtBins, nCentralityBins, nZvtxBins, nTrigC};
201 const Double_t corMin[7] = {PhiBins[0], EtaBins[0], PtBinsV0[0], PtBins[0], centralityBins[0], zvtxBins[0], TrigC[0]};
bccd1153 202 const Double_t corMax[7] = {PhiBins[72], EtaBins[40], PtBinsV0[11], PtBins[7], centralityBins[9], zvtxBins[7], TrigC[7]};
59bd5476 203 // Create correlation histograms
204 fHistdPhidEtaSib = new THnSparseF("fHistdPhidEtaSib","dPhi vs. dEta siblings", 7, corBins, corMin, corMax);
205 fHistdPhidEtaMix = new THnSparseF("fHistdPhidEtaMix","dPhi vs. dEta mixed", 7, corBins, corMin, corMax);
206
82bd566c 207 // Create histograms for counting the numbers of trigger particles
208 const Int_t corNTrigBins[5] = {nPtBinsV0, nCentralityBins, nZvtxBins, nTrigC};
209 const Double_t corNTrigMin[5] = {PtBinsV0[0], centBins[0], vertexBins[0], TrigC[0]};
bccd1153 210 const Double_t corNTrigMax[5] = {PtBinsV0[11], centBins[9], vertexBins[7], TrigC[7]};
74754736 211 fHistNTrigSib = new THnSparseF("fHistNTrigSib","Number trigger sib", 4, corNTrigBins, corNTrigMin, corNTrigMax);
212
70840314 213 // Histograms for debugging
74754736 214 fHistTemp = new TH1D("fHistTemp", "Temporary", 100, -10., 10.);
215 fHistTemp2 = new TH1D("fHistTemp2", "Temporary2", 100, -10., 10.);
59bd5476 216
217 fOutput->Add(fHistCentVtx);
218
219 fOutput->Add(fHistMultiMain);
220 fOutput->Add(fHistMassK0);
221 fOutput->Add(fHistMassLambda);
222 fOutput->Add(fHistMassAntiLambda);
223
bccd1153 224 fOutput->Add(fHistdPhidEtaSib);
225 fOutput->Add(fHistdPhidEtaMix);
82bd566c 226 fOutput->Add(fHistNTrigSib);
74754736 227
228 fOutput->Add(fHistMCPtCentTrig);
229 fOutput->Add(fHistRCPtCentTrig);
230 fOutput->Add(fHistMCPtCentAs);
231 fOutput->Add(fHistRCPtCentAs);
bccd1153 232 fOutput->Add(fHistRCPtCentAll);
59bd5476 233
234 fOutput->Add(fHistTemp);
74754736 235 fOutput->Add(fHistTemp2);
59bd5476 236
237 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
238
239 // Settings for event mixing -------------------------------------
240 Int_t trackDepth = fMixingTracks;
241 Int_t poolSize = 200; // Maximum number of events, ignored in the present implemented of AliEventPoolManager
242
243 fPoolMgr = new AliEventPoolManager(poolSize, trackDepth, nCentralityBins, centBins, nZvtxBins, vertexBins);
244 //----------------------------------------------
245}
246
247//________________________________________________________________________
248void AliAnalysisTaskV0ChCorrelations::Terminate(Option_t *)
249{
250 // Draw result to screen, or perform fitting, normalizations
251 // Called once at the end of the query
252
253 fOutput = dynamic_cast<TList*>(GetOutputData(1));
254 if (!fOutput) { AliError("Could not retrieve TList fOutput"); return; }
255
256 // NEW HISTO should be retrieved from the TList container in the above way,
257 // so it is available to draw on a canvas such as below
258}
259
260//_________________________________________________________________________
261void AliAnalysisTaskV0ChCorrelations::UserExec(Option_t *)
262{
263 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
74754736 264 AliInputEventHandler *inEvMain = (AliInputEventHandler*)mgr->GetInputEventHandler();
59bd5476 265
266 // physics selection
267 UInt_t maskIsSelected = inEvMain->IsEventSelected();
268 // 2010 data trigger selection
269 //Bool_t isSelected = (maskIsSelected & AliVEvent::kMB);
270 // 2011 data trigger selection
271 Bool_t isSelected = ((maskIsSelected & AliVEvent::kMB) || (maskIsSelected & AliVEvent::kCentral) || (maskIsSelected & AliVEvent::kSemiCentral));
272 if (!isSelected) return;
74754736 273 // calculating the event types
82bd566c 274 if (maskIsSelected & AliVEvent::kMB) fHistTemp->Fill(2);
275 if (maskIsSelected & AliVEvent::kCentral) fHistTemp->Fill(4);
276 if (maskIsSelected & AliVEvent::kSemiCentral) fHistTemp->Fill(6);
59bd5476 277
74754736 278 AliAODEvent* aod = (AliAODEvent*)inEvMain->GetEvent();
59bd5476 279 fPIDResponse = inEvMain->GetPIDResponse();
280
74754736 281 // pt intervals for trigger particles
282 const Double_t kPi = TMath::Pi();
bccd1153 283 Double_t PtTrigMin = 4.0;
74754736 284 Double_t PtTrigMax = 15.0;
285 // pt interval for associated particles
bccd1153 286 Double_t PtAssocMin = 2.0;
74754736 287 fHistMultiMain->Fill(aod->GetNumberOfTracks());
288
289 // Vertex cut
bccd1153 290 Double_t cutPrimVertex = 7.0;
74754736 291 AliAODVertex *myPrimVertex = aod->GetPrimaryVertex();
292 if (!myPrimVertex) return;
293 if ( ( TMath::Abs(myPrimVertex->GetZ()) ) >= cutPrimVertex) return ;
294 Double_t lPVx = myPrimVertex->GetX();
295 Double_t lPVy = myPrimVertex->GetY();
296 Double_t lPVz = myPrimVertex->GetZ();
297
298 if (TMath::Abs(lPVx)<10e-5 && TMath::Abs(lPVy)<10e-5 && TMath::Abs(lPVz)<10e-5) return;
299
300 // Centrality definition
301 Double_t lCent = 0.0;
302 AliCentrality *centralityObj = 0;
0a918d8d 303 centralityObj = ((AliVAODHeader*)aod->GetHeader())->GetCentralityP();
bccd1153 304 lCent = centralityObj->GetCentralityPercentile("V0M");
74754736 305 if ((lCent < 0.)||(lCent > 90.)) return;
306 fHistCentVtx->Fill(lCent,lPVz);
307
308//=========== MC loop ===============================
309 if (fAnalysisMC)
310 {
311 AliAODMCHeader *aodMCheader = (AliAODMCHeader*)aod->FindListObject(AliAODMCHeader::StdBranchName());
312 Float_t vzMC = aodMCheader->GetVtxZ();
bccd1153 313 if (TMath::Abs(vzMC) >= 7.) return;
314 //retrieve MC particles from event
74754736 315 TClonesArray *mcArray = (TClonesArray*)aod->FindListObject(AliAODMCParticle::StdBranchName());
316 if(!mcArray){
317 Printf("No MC particle branch found");
318 return;
319 }
bccd1153 320
321 Int_t nMCAllTracks = mcArray->GetEntriesFast();
322 // new tracks array - without injected signal
323 TObjArray * mcTracks = new TObjArray;
324 //selectedMCTracks->SetOwner(kTRUE);
325
326 for (Int_t i = 0; i < nMCAllTracks; i++)
327 {
328 AliAODMCParticle *mcTrack = (AliAODMCParticle*)mcArray->At(i);
329 if (!mcTrack) {
330 Error("ReadEventAODMC", "Could not receive particle %d", i);
331 continue;
332 }
333 mcTracks->Add(mcTrack);
334 }
335
336 // get labels for injected particles -------
337 TObject* mc = mcArray;
338 //TObjArray * mcTracks = mcArray;
339 Int_t skipParticlesAbove = 0;
340 //AliGenEventHeader* eventHeader = 0;
341 //Int_t headers = 0;
342 //headers = aodMCheader->GetNCocktailHeaders();
343 //eventHeader = aodMCheader->GetCocktailHeader(0);
344 AliGenEventHeader* eventHeader = aodMCheader->GetCocktailHeader(0);
345 Int_t headers = aodMCheader->GetNCocktailHeaders();
346 if (!eventHeader)
347 {
348 // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing
349 // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
350 AliError("First event header not found. Skipping this event.");
351 return;
352 }
353 skipParticlesAbove = eventHeader->NProduced();
354 //cout << "ski label = " << skipParticlesAbove << endl;
355 AliInfo(Form("Injected signals in this event (%d headers). Keeping events of %s.Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove));
356 //cout << "before MC compressing = " << mcTracks->GetEntriesFast() << endl;
357 RemovingInjectedSignal(mcTracks,mc,skipParticlesAbove);
358 //cout << "after MC compressing = " << mcTracks->GetEntriesFast() << endl;
359 // -------------
360
361 Int_t nMCTracks = mcTracks->GetEntriesFast();
74754736 362 //cout << "number of MC tracks = " << nMCTracks << endl;
363 for (Int_t iMC = 0; iMC<nMCTracks; iMC++)
364 {
bccd1153 365 AliAODMCParticle *mcTrack = (AliAODMCParticle*)mcTracks->At(iMC);
74754736 366 if (!mcTrack) {
367 Error("ReadEventAODMC", "Could not receive particle %d", iMC);
368 continue;
369 }
370 // track part
371 Double_t mcTrackEta = mcTrack->Eta();
372 Double_t mcTrackPt = mcTrack->Pt();
373 Bool_t TrIsPrim = mcTrack->IsPhysicalPrimary();
bccd1153 374 Bool_t TrEtaMax = TMath::Abs(mcTrackEta)<0.9;
74754736 375 Bool_t TrPtMin = mcTrackPt>PtAssocMin;
376 Bool_t TrCharge = (mcTrack->Charge())!=0;
377 if (TrIsPrim && TrEtaMax && TrPtMin && TrCharge) fHistMCPtCentAs->Fill(mcTrackPt,lCent);
378 // V0 part
379 Int_t mcMotherPdg = 0;
380 Int_t mcPartPdg = mcTrack->GetPdgCode();
381
382 // Keep only K0s, Lambda and AntiLambda
383 if ((mcPartPdg != 310) && (mcPartPdg != 3122) && (mcPartPdg != (-3122))) continue;
384
385 //cout << " mc pdg is " << mcPartPdg << endl;
386
387 Bool_t IsK0 = mcPartPdg==310;
388 Bool_t IsLambda = mcPartPdg==3122;
389 Bool_t IsAntiLambda = mcPartPdg==-3122;
390 Bool_t IsSigma = kFALSE;
bccd1153 391 Int_t mcMotherLabel = mcTrack->GetMother();
74754736 392 AliAODMCParticle *mcMother = (AliAODMCParticle*)mcArray->At(mcMotherLabel);
393 if (mcMotherLabel < 0) {mcMotherPdg = 0;} else {mcMotherPdg = mcMother->GetPdgCode();}
394 //if ((mcMotherLabel >= 0) && mcMother)
395 //if ((mcMotherLabel >= 0) && mcMother)
396 //{
397 // Bool_t IsFromCascade = ((mcMotherPdg==3312)||(mcMotherPdg==-3312)||(mcMotherPdg==3334)||(mcMotherPdg==-3334));
398 Bool_t IsFromSigma = ((mcMotherPdg==3212)||(mcMotherPdg==-3212));
399 IsFromSigma = IsFromSigma || ((mcMotherPdg==3224)||(mcMotherPdg==-3224));
400 IsFromSigma = IsFromSigma || ((mcMotherPdg==3214)||(mcMotherPdg==-3214));
401 IsFromSigma = IsFromSigma || ((mcMotherPdg==3114)||(mcMotherPdg==-3114));
402 if ((IsFromSigma) && (mcMother->IsPhysicalPrimary()) && (IsLambda || IsAntiLambda)) IsSigma = kTRUE;
403 Double_t mcRapidity = mcTrack->Y();
404 Bool_t V0RapMax = TMath::Abs(mcRapidity)<0.75;
405 Bool_t PtInterval = ((mcTrackPt>PtTrigMin)&&(mcTrackPt<PtTrigMax));
406 //Bool_t PtInterval = kTRUE;
407 IsK0 = IsK0 && (mcTrack->IsPhysicalPrimary());
408 IsLambda = IsLambda && (mcTrack->IsPhysicalPrimary() || IsSigma);
409 IsAntiLambda = IsAntiLambda && (mcTrack->IsPhysicalPrimary() || IsSigma);
410 Double_t mcK0[3] = {mcTrackPt, lCent, 1};
411 Double_t mcLa[3] = {mcTrackPt, lCent, 2};
412 Double_t mcAl[3] = {mcTrackPt, lCent, 3};
413 if (IsK0 && V0RapMax && PtInterval) fHistMCPtCentTrig->Fill(mcK0);
414 if (IsLambda && V0RapMax && PtInterval) fHistMCPtCentTrig->Fill(mcLa);
415 if (IsAntiLambda && V0RapMax && PtInterval) fHistMCPtCentTrig->Fill(mcAl);
416 //}
417 }
418 // ------- access the real data -----------
bccd1153 419 Int_t nTracks = aod->GetNumberOfTracks();
420 // new tracks array - without injected signal
421 TObjArray * selectedMCTracks = new TObjArray;
422 //selectedMCTracks->SetOwner(kTRUE);
423
424 for (Int_t i = 0; i < nTracks; i++)
425 {
f15c1f69 426 AliAODTrack* tr = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
427 if(!tr) AliFatal("Not a standard AOD");
bccd1153 428 selectedMCTracks->Add(tr);
429 }
430 // cout << "before compressing = " << selectedMCTracks->GetEntriesFast() << endl;
431 RemovingInjectedSignal(selectedMCTracks,mc,skipParticlesAbove);
432 //AliAnalyseLeadingTrackUE::RemoveInjectedSignals(selectedMCTracks,mc,skipParticlesAbove);
433 //RemoveInjectedSignals(selectedMCTracks,mc,skipParticlesAbove);
434 // cout << "after compressing = " << selectedMCTracks->GetEntriesFast() << endl;
435 //-----------------------
436 //cout << "before getting label -4" << endl;
437 Int_t nRecTracks = selectedMCTracks->GetEntriesFast();
438 //cout << "before getting label -3" << endl;
74754736 439 for (Int_t i = 0; i < nRecTracks; i++)
440 {
f15c1f69 441 //AliAODTrack* tras = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
bccd1153 442 AliAODTrack* tras = (AliAODTrack*)selectedMCTracks->At(i);
443 //cout << "before getting label -2" << endl;
444 //cout << " and i = " << i << endl;
445 //cout << "pt = " << tras->Pt() << " and i = " << i << endl;
74754736 446 if ((tras->Pt())<PtAssocMin) continue;
bccd1153 447 //cout << "before getting label -1" << endl;
74754736 448 if (!(IsMyGoodPrimaryTrack(tras))) continue;
bccd1153 449 //cout << "before getting label 0" << endl;
74754736 450 Int_t AssocLabel = tras->GetLabel();
451 if (AssocLabel<=0) continue;
bccd1153 452 //cout << "before getting label 1" << endl;
453 Bool_t isPhyPrim = static_cast<AliAODMCParticle*>(mcArray->At(tras->GetLabel()))->IsPhysicalPrimary();
454 //Bool_t isPhyPrim = static_cast<AliAODMCParticle*>(mcArray->At(tras->GetLabel()))->IsPhysicalPrimary();
455 //if(!(static_cast<AliAODMCParticle*>(mcArray->At(tras->GetLabel()))->IsPhysicalPrimary())) continue;
456 //cout << "before getting label 2" << endl;
457 Double_t mcPt = static_cast<AliAODMCParticle*>(mcArray->At(tras->GetLabel()))->Pt();
458 //cout << "before getting label 3" << endl;
459 //Double_t mcEta = static_cast<AliAODMCParticle*>(mcArray->At(tras->GetLabel()))->Eta();
460 //if (mcPt<PtAssocMin) continue;
461 //if (TMath::Abs(mcEta)>0.8) continue;
462 //Double_t trPt = tras->Pt();
463 fHistRCPtCentAll->Fill(mcPt,lCent);
464 if (isPhyPrim) fHistRCPtCentAs->Fill(mcPt,lCent);
74754736 465 }
466 // ------- end of real data access, for V0s see the main V0 loop --------
467 }
468//============= End of MC loop ======================
59bd5476 469
470 // Track selection loop
471 //--------------------------------
472 Int_t nTracks = aod->GetNumberOfTracks();
473 // new tracks array
474 TObjArray * selectedTracks = new TObjArray;
475 selectedTracks->SetOwner(kTRUE);
74754736 476
477 Bool_t ChChWith = GetWithChCh();
478 TObjArray * selectedChargedTriggers = new TObjArray;
479 selectedChargedTriggers->SetOwner(kTRUE);
480 for (Int_t i = 0; i < nTracks; i++)
481 {
f15c1f69 482 AliAODTrack* tr = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
483 if(!tr) AliFatal("Not a standard AOD");
74754736 484 if ((tr->Pt())<PtAssocMin) continue;
485 if (!(IsMyGoodPrimaryTrack(tr))) continue;
486 selectedTracks->Add(tr);
487 // saving the Charged trigger particles
bccd1153 488 if ((tr->Pt()>4.)&&(tr->Pt()<15.))
74754736 489 {
490 selectedChargedTriggers->Add(new AliV0ChBasicParticle(tr->Eta(), tr->Phi(), tr->Pt(), 7));
491 }
492 }
493
59bd5476 494 //---------------------------------
495
496 // V0 loop for reconstructed event
497 TObjArray * selectedV0s = new TObjArray;
498 selectedV0s->SetOwner(kTRUE);
499
500 Int_t nV0s = aod->GetNumberOfV0s();
501
502 for (Int_t i = 0; i < nV0s; i++)
503 { // start of V0 slection loop
504 AliAODv0* aodV0 = dynamic_cast<AliAODv0 *>(aod->GetV0(i));
505 if (!aodV0) {
506 AliError(Form("ERROR: Could not retrieve aodv0 %d", i));
507 continue;
508 }
399ef8f2 509 if (aodV0->GetOnFlyStatus()) fHistTemp->Fill(6.);
510 if (!aodV0->GetOnFlyStatus()) fHistTemp->Fill(8.);
74754736 511 //cout << "pt of v0: " << aodV0->Pt() << endl;
59bd5476 512 if (((aodV0->Pt())<PtTrigMin)||((aodV0->Pt())>PtTrigMax)) continue;
513 // get daughters
74754736 514 const AliAODTrack *myTrackPos;
515 const AliAODTrack *myTrackNeg;
59bd5476 516 AliAODTrack *myTrackNegTest=dynamic_cast<AliAODTrack *>(aodV0->GetDaughter(1));
517 AliAODTrack *myTrackPosTest=dynamic_cast<AliAODTrack *>(aodV0->GetDaughter(0));
518
519 if (!myTrackPosTest || !myTrackNegTest) {
520 Printf("strange analysis::UserExec:: Error:Could not retreive one of the daughter track\n");
521 continue;
522 }
523
524 if( myTrackPosTest->Charge() ==1){
525 myTrackPos = myTrackPosTest;
526 myTrackNeg = myTrackNegTest;
527 }
528
529 if( myTrackPosTest->Charge() ==-1){
530 myTrackPos = myTrackNegTest;
531 myTrackNeg = myTrackPosTest;
532 }
533
59bd5476 534 // effective mass calculations for each hypothesis
535 Double_t lInvMassK0 = aodV0->MassK0Short();
536 Double_t lInvMassAntiLambda = aodV0->MassAntiLambda();
537 Double_t lInvMassLambda = aodV0->MassLambda();
538
539 // calculations for c*tau cut--------------------------------------
74754736 540 // Double_t lDVx = aodV0->GetSecVtxX();
541 // Double_t lDVy = aodV0->GetSecVtxY();
542 // Double_t lDVz = aodV0->GetSecVtxZ();
543 // const Double_t kLambdaMass = 1.115683;
544 // const Double_t kK0Mass = 0.497648;
545 // Double_t cutcTauLam = 3*7.89;
546 // Double_t cutcTauK0 = 3*2.68;
547 // Double_t lV0DecayLength = TMath::Sqrt(TMath::Power(lDVx - lPVx,2) + TMath::Power(lDVy- lPVy,2) + TMath::Power(lDVz - lPVz,2 ));
548 // Double_t lPV0 = TMath::Sqrt((aodV0->Pt())*(aodV0->Pt())+(aodV0->Pz())*(aodV0->Pz()));
549 // Double_t lcTauLam = (lV0DecayLength*kLambdaMass)/lPV0;
550 // Double_t lcTauK0 = (lV0DecayLength*kK0Mass)/lPV0;
59bd5476 551 // sc - standard cuts
74754736 552 //Bool_t cutK0sc = (lcTauK0<cutcTauK0);
553 //Bool_t cutLambdasc = (lcTauLam<cutcTauLam);
554 //Bool_t cutAntiLambdasc = (lcTauLam<cutcTauLam);
555 Bool_t cutK0sc = kTRUE;
556 Bool_t cutLambdasc = kTRUE;
557 Bool_t cutAntiLambdasc = kTRUE;
59bd5476 558
559 //------------------------------------------------
560
561 // preparations for daughter's PID cut------------------------------
562 Float_t nSigmaPosPion = 0.;
563 Float_t nSigmaNegPion = 0.;
564 Float_t nSigmaPosProton = 0.;
565 Float_t nSigmaNegProton = 0.;
566
567 const AliAODPid *pPid = myTrackPos->GetDetPid();
568 const AliAODPid *nPid = myTrackNeg->GetDetPid();
569
570 if (pPid)
571 {
572 Double_t pdMom = pPid->GetTPCmomentum();
573 if (pdMom<1.)
574 {
575 nSigmaPosPion = fPIDResponse->NumberOfSigmasTPC(myTrackPos, AliPID::kPion);
576 nSigmaPosProton = fPIDResponse->NumberOfSigmasTPC(myTrackPos, AliPID::kProton);
577 }
578 }
579
580 if (nPid)
581 {
582 Double_t ndMom = nPid->GetTPCmomentum();
583 if (ndMom<1.)
584 {
585 nSigmaNegPion = fPIDResponse->NumberOfSigmasTPC(myTrackPos, AliPID::kPion);
586 nSigmaNegProton = fPIDResponse->NumberOfSigmasTPC(myTrackPos, AliPID::kProton);
587 }
588 }
589 Bool_t bpPion = TMath::Abs(nSigmaPosPion) <= 3.;
590 Bool_t bpProton = TMath::Abs(nSigmaPosProton) <= 3.;
591 Bool_t bnPion = TMath::Abs(nSigmaNegPion) <= 3.;
592 Bool_t bnProton = TMath::Abs(nSigmaNegProton) <= 3.;
593
594 Bool_t cutK0Pid = (bpPion && bnPion);
595 Bool_t cutLambdaPid = (bpProton && bnPion);
596 Bool_t cutAntiLambdaPid = (bpPion && bnProton);
597 //--------------------------------------------------
598 // mass cuts
599 Bool_t cutMassLambda = ((lInvMassLambda>1.10) && (lInvMassLambda<1.13));
600 Bool_t cutMassAntiLambda = ((lInvMassAntiLambda>1.10) && (lInvMassAntiLambda<1.13));
601 Bool_t cutMassK0 = (lInvMassK0>0.47) && (lInvMassK0<0.53);
602
603 cutK0sc = cutK0Pid && (!cutMassLambda) && (!cutMassAntiLambda);
604 cutLambdasc = cutLambdaPid && (!cutMassK0);
605 cutAntiLambdasc = cutAntiLambdaPid && (!cutMassK0);
606 // special cut related to AP diagram for K0s
74754736 607 Bool_t k0APcut = (aodV0->PtArmV0()>(TMath::Abs(0.2*aodV0->AlphaV0())));
59bd5476 608 cutK0sc = cutK0sc && k0APcut;
70840314 609 // fill the mass histograms
74754736 610
611 Int_t oStatus = GetOStatus();
612
613 if (!IsMyGoodV0(aod,aodV0,myTrackPos,myTrackNeg,oStatus)) continue;
85c11f5a 614 Double_t spK0[3] = {lInvMassK0, aodV0->Pt(), lCent};
615 Double_t spLa[3] = {lInvMassLambda, aodV0->Pt(), lCent};
616 Double_t spAl[3] = {lInvMassAntiLambda, aodV0->Pt(), lCent};
617 if (cutK0sc) fHistMassK0->Fill(spK0);
618 if (cutLambdasc) fHistMassLambda->Fill(spLa);
619 if (cutAntiLambdasc) fHistMassAntiLambda->Fill(spAl);
59bd5476 620 // select final V0s for correlation, selected background to study its contribution to correlation function
621 // the values for signal might change in the future ...
70840314 622 Bool_t K0Signal = (lInvMassK0>0.48)&&(lInvMassK0<0.52);
623 Bool_t K0Bckg = ((lInvMassK0>0.40)&&(lInvMassK0<0.44)) || ((lInvMassK0>0.56)&&(lInvMassK0<0.60));
59bd5476 624
70840314 625 Bool_t LamSignal = (lInvMassLambda>1.108)&&(lInvMassLambda<1.125);
626 Bool_t LamBckg = ((lInvMassLambda>1.090)&&(lInvMassLambda<1.100)) || ((lInvMassLambda>1.135)&&(lInvMassLambda<1.145));
59bd5476 627
70840314 628 Bool_t ALamSignal = (lInvMassAntiLambda>1.108)&&(lInvMassAntiLambda<1.125);
629 Bool_t ALamBckg = ((lInvMassAntiLambda>1.090)&&(lInvMassAntiLambda<1.100)) || ((lInvMassAntiLambda>1.135)&&(lInvMassAntiLambda<1.145));
59bd5476 630
631 // Fill selected V0 particle array
74754736 632 if ((cutK0sc)&&(K0Signal))
633 {
634 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 1.));
635 Double_t nTrigK0Sig[4] = {aodV0->Pt(), lCent, lPVz, 1.};
636 fHistNTrigSib->Fill(nTrigK0Sig);
637 }
638 if ((cutK0sc)&&(K0Bckg))
639 {
640 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 4.));
641 Double_t nTrigK0Bkg[4] = {aodV0->Pt(), lCent, lPVz, 4.};
642 fHistNTrigSib->Fill(nTrigK0Bkg);
643 }
644 if ((cutLambdasc)&&(LamSignal))
645 {
646 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 2.));
647 Double_t nTrigLaSig[4] = {aodV0->Pt(), lCent, lPVz, 2.};
648 fHistNTrigSib->Fill(nTrigLaSig);
649 }
650 if ((cutLambdasc)&&(LamBckg))
651 {
652 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 5.));
653 Double_t nTrigLaBkg[4] = {aodV0->Pt(), lCent, lPVz, 5.};
654 fHistNTrigSib->Fill(nTrigLaBkg);
655 }
656 if ((cutAntiLambdasc)&&(ALamSignal))
657 {
658 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 3.));
659 Double_t nTrigAlSig[4] = {aodV0->Pt(), lCent, lPVz, 3.};
660 fHistNTrigSib->Fill(nTrigAlSig);
661 }
662 if ((cutAntiLambdasc)&&(ALamBckg))
663 {
664 selectedV0s->Add(new AliV0ChBasicParticle(aodV0->Eta(), aodV0->Phi(), aodV0->Pt(), 6.));
665 Double_t nTrigAlBkg[4] = {aodV0->Pt(), lCent, lPVz, 6.};
666 fHistNTrigSib->Fill(nTrigAlBkg);
667 }
668
669
670 //===== MC part for V0 reconstruction efficiency ==============
671 if (fAnalysisMC)
672 {
673 TClonesArray *mcArray = (TClonesArray*)aod->FindListObject(AliAODMCParticle::StdBranchName());
674 if(!mcArray){
675 Printf("No MC particle branch found");
676 return;
677 }
678
679 Int_t MotherOfMotherPdg = 0;
680
681 Int_t myTrackPosLabel = TMath::Abs(myTrackPos->GetLabel());
682 Int_t myTrackNegLabel = TMath::Abs(myTrackNeg->GetLabel());
683 AliAODMCParticle *mcPosTrack = (AliAODMCParticle*)mcArray->At(myTrackPosLabel);
684 if (!mcPosTrack) continue;
685 AliAODMCParticle *mcNegTrack = (AliAODMCParticle*)mcArray->At(myTrackNegLabel);
686 if (!mcNegTrack) continue;
687
688 Int_t PosTrackPdg = mcPosTrack->GetPdgCode();
689 Int_t NegTrackPdg = mcNegTrack->GetPdgCode();
690 //if (!mcPosTrack->IsPrimary()) continue;
691 //if (!mcNegTrack->IsPrimary()) continue;
692
693 Int_t myTrackPosMotherLabel = mcPosTrack->GetMother();
694 Int_t myTrackNegMotherLabel = mcNegTrack->GetMother();
695
696 if ((myTrackPosMotherLabel==-1)||(myTrackNegMotherLabel==-1)) continue;
697
698 AliAODMCParticle *mcPosMother = (AliAODMCParticle*)mcArray->At(myTrackPosMotherLabel);
699 if (!mcPosMother) continue;
700 Int_t MotherPdg = mcPosMother->GetPdgCode();
701 Int_t MotherOfMother = mcPosMother->GetMother();
702 //if (MotherOfMother == -1) MotherOfMotherPdg = 0;
703
704 if (myTrackPosMotherLabel!=myTrackNegMotherLabel) continue;
705 //if (!mcPosMother->IsPrimary()) continue;
706 Bool_t IsK0FromMC = (mcPosMother->IsPhysicalPrimary())&&(MotherPdg==310)&&(PosTrackPdg==211)&&(NegTrackPdg==-211);
707 Bool_t IsLambdaFromMC = (mcPosMother->IsPhysicalPrimary())&&(MotherPdg==3122)&&(PosTrackPdg==2212)&&(NegTrackPdg==-211);
708 Bool_t IsAntiLambdaFromMC = (mcPosMother->IsPhysicalPrimary())&&(MotherPdg==-3122)&&(PosTrackPdg==211)&&(NegTrackPdg==-2212);
709
710 Bool_t ComeFromSigma = kFALSE;
711 Bool_t ComeFromSigmaLa = kFALSE;
712 Bool_t ComeFromSigmaAl = kFALSE;
713
714 if (MotherOfMother != -1)
715 {
716 AliAODMCParticle *mcPosMotherOfMother = (AliAODMCParticle*)mcArray->At(MotherOfMother);
717 MotherOfMotherPdg = mcPosMotherOfMother->GetPdgCode();
718 Int_t MoMPdg = TMath::Abs(MotherOfMotherPdg);
719 ComeFromSigma = (mcPosMotherOfMother->IsPhysicalPrimary())&&((MoMPdg==3212)||(MoMPdg==3224)||(MoMPdg==3214)||(MoMPdg==3114));
720 ComeFromSigmaLa = ComeFromSigma && (MotherPdg==3122)&&(PosTrackPdg==2212)&&(NegTrackPdg==-211);
721 ComeFromSigmaAl = ComeFromSigma && (MotherPdg==-3122)&&(PosTrackPdg==211)&&(NegTrackPdg==-2212);
722 }
723
724 IsLambdaFromMC = IsLambdaFromMC || ComeFromSigmaLa;
725 IsAntiLambdaFromMC = IsAntiLambdaFromMC || ComeFromSigmaAl;
726
727 Double_t RecMotherPt = aodV0->Pt();
728 //cout << "Pt of rec v0 = " << RecMotherPt << " nMC = " << mcArray->GetEntries() << endl;
729 //cout << "Pos Label = " << myTrackPosLabel << " Neg Label = " << myTrackNegLabel << endl;
730 Double_t rcK0[3] = {RecMotherPt, lCent, 1};
731 Double_t rcLa[3] = {RecMotherPt, lCent, 2};
732 Double_t rcAl[3] = {RecMotherPt, lCent, 3};
733 if ((cutK0sc)&&(K0Signal)&&(IsK0FromMC)) fHistRCPtCentTrig->Fill(rcK0);
734 if ((cutLambdasc)&&(LamSignal)&&(IsLambdaFromMC)) fHistRCPtCentTrig->Fill(rcLa);
735 if ((cutAntiLambdasc)&&(ALamSignal)&&(IsAntiLambdaFromMC)) fHistRCPtCentTrig->Fill(rcAl);
736
737 }
738
739 //===== End of the MC part for V0 reconstruction efficiency ===
85c11f5a 740
59bd5476 741 Int_t nSelectedTracks = selectedTracks->GetEntries();
742 // Correlation part
743 //===================================
744 for (Int_t j = 0; j < nSelectedTracks; j++)
745 {
59bd5476 746 AliAODTrack* atr = (AliAODTrack*) selectedTracks->At(j);
59bd5476 747 if ((atr->Pt())>=(aodV0->Pt())) continue;
748 Double_t dEta = atr->Eta() - aodV0->Eta();
749 Double_t dPhi = atr->Phi() - aodV0->Phi();
750 if (dPhi > (1.5*kPi)) dPhi -= 2.0*kPi;
751 if (dPhi < (-0.5*kPi)) dPhi += 2.0*kPi;
752 // removing autocorrelations
753 //----------------------------------
754 Int_t negID = myTrackNeg->GetID();
755 Int_t posID = myTrackPos->GetID();
756 Int_t atrID = atr->GetID();
757
758 if ((TMath::Abs(negID)+1)==(TMath::Abs(atrID))) continue;
759 if ((TMath::Abs(posID)+1)==(TMath::Abs(atrID))) continue;
760 //----------------------------------
761
74754736 762 fHistNTrigSib->Sumw2();
59bd5476 763 fHistdPhidEtaSib->Sumw2();
85c11f5a 764 // Filling correlation histograms and histograms for triggers counting
765 //----------------- K0 ---------------------
59bd5476 766 if ((cutK0sc)&&(K0Signal))
767 {
59bd5476 768 Double_t spK0Sig[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 1.};
769 fHistdPhidEtaSib->Fill(spK0Sig);
770 }
85c11f5a 771
59bd5476 772 if ((cutK0sc)&&(K0Bckg))
773 {
59bd5476 774 Double_t spK0Bkg[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 4.};
775 fHistdPhidEtaSib->Fill(spK0Bkg);
776 }
85c11f5a 777 //---------------- Lambda -------------------
59bd5476 778 if ((cutLambdasc)&&(LamSignal))
779 {
59bd5476 780 Double_t spLaSig[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 2.};
781 fHistdPhidEtaSib->Fill(spLaSig);
782 }
85c11f5a 783
59bd5476 784 if ((cutLambdasc)&&(LamBckg))
785 {
59bd5476 786 Double_t spLaBkg[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 5.};
787 fHistdPhidEtaSib->Fill(spLaBkg);
788 }
85c11f5a 789 //------------- AntiLambda -------------------
59bd5476 790 if ((cutAntiLambdasc)&&(ALamSignal))
791 {
59bd5476 792 Double_t spAlSig[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 3.};
793 fHistdPhidEtaSib->Fill(spAlSig);
794 }
85c11f5a 795
59bd5476 796 if ((cutAntiLambdasc)&&(ALamBckg))
797 {
59bd5476 798 Double_t spAlBkg[7] = {dPhi, dEta, aodV0->Pt(), atr->Pt(), lCent, lPVz, 6.};
799 fHistdPhidEtaSib->Fill(spAlBkg);
800 }
801
802 } // end of correlation loop
803 //===================================
74754736 804
59bd5476 805
806 } // end of V0 selection loop
807
82bd566c 808 // ===========================================
74754736 809 // Ch-Ch correlation part
82bd566c 810
74754736 811 if (ChChWith)
812 {
813 Int_t nSelectedChargedTriggers = selectedChargedTriggers->GetEntries();
814 for (Int_t i = 0; i < nSelectedChargedTriggers; i++)
815 {
816 AliV0ChBasicParticle* chTrig = (AliV0ChBasicParticle*) selectedChargedTriggers->At(i);
817 Double_t chTrigPhi = chTrig->Phi();
818 Double_t chTrigEta = chTrig->Eta();
819 Double_t chTrigPt = chTrig->Pt();
820
821 Double_t nTrigChSig[4] = {chTrigPt, lCent, lPVz, 7.};
822 fHistNTrigSib->Fill(nTrigChSig);
823
824 Int_t nSelectedTracks = selectedTracks->GetEntries();
825 for (Int_t j = 0; j < nSelectedTracks; j++)
826 {
827 AliAODTrack* atr = (AliAODTrack*) selectedTracks->At(j);
828 if ((atr->Pt())>=chTrigPt) continue;
829 Double_t dEta = atr->Eta() - chTrigEta;
830 Double_t dPhi = atr->Phi() - chTrigPhi;
831 if (dPhi > (1.5*kPi)) dPhi -= 2.0*kPi;
832 if (dPhi < (-0.5*kPi)) dPhi += 2.0*kPi;
833
834 Double_t spCh[7] = {dPhi, dEta, chTrigPt, atr->Pt(), lCent, lPVz, 7.};
835 fHistdPhidEtaSib->Fill(spCh);
836 }
837 }
838 }
839 // end of Ch-Ch correlation part
82bd566c 840
59bd5476 841 // Mixing ==============================================
842
59bd5476 843 fHistdPhidEtaMix->Sumw2();
844 AliEventPool* pool = fPoolMgr->GetEventPool(lCent, lPVz);
845 if (!pool) AliFatal(Form("No pool found for centrality = %f, zVtx = %f", lCent, lPVz));
846 //pool->SetDebug(1);
847 if (pool->IsReady() || pool->NTracksInPool() > fMixingTracks / 10 || pool->GetCurrentNEvents() >= 5)
848 {
849 Int_t nMix = pool->GetCurrentNEvents();
850 for (Int_t jMix=0; jMix<nMix; jMix++)
851 {// loop through mixing events
852 TObjArray* bgTracks = pool->GetEvent(jMix);
853 for (Int_t i=0; i<selectedV0s->GetEntriesFast(); i++)
854 {// loop through selected V0 particles
855 AliV0ChBasicParticle* trig = (AliV0ChBasicParticle*) selectedV0s->At(i);
856 Double_t trigPhi = trig->Phi();
857 Double_t trigEta = trig->Eta();
858 Double_t trigPt = trig->Pt();
859 Short_t trigC = trig->WhichCandidate();
860 for (Int_t j=0; j<bgTracks->GetEntriesFast(); j++)
861 { // mixing tracks loop
862 AliVParticle* assoc = (AliVParticle*) bgTracks->At(j);
863 // be careful tracks may have bigger pt than v0s.
864 if ( ( (assoc->Pt())>=trigPt )||( (assoc->Pt())<PtAssocMin ) ) continue;
865 Double_t dEtaMix = assoc->Eta() - trigEta;
866 Double_t dPhiMix = assoc->Phi() - trigPhi;
867 if (dPhiMix > (1.5*kPi)) dPhiMix -= 2.0*kPi;
868 if (dPhiMix < (-0.5*kPi)) dPhiMix += 2.0*kPi;
869
2942f542 870 Double_t spMix[7] = {dPhiMix, dEtaMix, trigPt, assoc->Pt(), lCent, lPVz, static_cast<Double_t>(trigC)};
59bd5476 871 fHistdPhidEtaMix->Fill(spMix);
872
873 } // end of mixing track loop
874 }// end of loop through selected V0 particles
82bd566c 875 if (ChChWith)
74754736 876 {
877 for (Int_t i=0; i<selectedChargedTriggers->GetEntriesFast(); i++)
878 {// loop through selected charged trigger particles
879 AliV0ChBasicParticle* trig = (AliV0ChBasicParticle*) selectedChargedTriggers->At(i);
880 Double_t trigPhi = trig->Phi();
881 Double_t trigEta = trig->Eta();
882 Double_t trigPt = trig->Pt();
883 Short_t trigC = trig->WhichCandidate();
884 for (Int_t j=0; j<bgTracks->GetEntriesFast(); j++)
885 { // mixing tracks loop
886 AliVParticle* assoc = (AliVParticle*) bgTracks->At(j);
887 // be careful tracks may have bigger pt than v0s.
888 if ( ( (assoc->Pt())>=trigPt )||( (assoc->Pt())<PtAssocMin ) ) continue;
889
890 Double_t dEtaMix = assoc->Eta() - trigEta;
891 Double_t dPhiMix = assoc->Phi() - trigPhi;
892 if (dPhiMix > (1.5*kPi)) dPhiMix -= 2.0*kPi;
893 if (dPhiMix < (-0.5*kPi)) dPhiMix += 2.0*kPi;
894
2942f542 895 Double_t spMix[7] = {dPhiMix, dEtaMix, trigPt, assoc->Pt(), lCent, lPVz, static_cast<Double_t>(trigC)};
74754736 896 fHistdPhidEtaMix->Fill(spMix);
897
898 } // end of mixing track loop
899 }// end of loop through selected Ch particles
900 } // end of ChCh mixing
901
59bd5476 902 }// end of loop of mixing events
903 }
904
905 TObjArray* tracksClone = (TObjArray*) selectedTracks->Clone();
906 tracksClone->SetOwner(kTRUE);
907 pool->UpdatePool(tracksClone);
908 //delete selectedtracks;
909
74754736 910 PostData(1, fOutput);
59bd5476 911
912}
913//___________________________________________
914Bool_t AliAnalysisTaskV0ChCorrelations::IsMyGoodPrimaryTrack(const AliAODTrack *t)
915{
916 // Pseudorapidity cut
bccd1153 917 if (TMath::Abs(t->Eta())>0.9) return kFALSE;
918 // Should correspond to set of cuts suitable for correlation analysis, 768 - hybrid tracks for 2011 data
919 if (!t->TestFilterBit(768)) return kFALSE;
59bd5476 920
921 return kTRUE;
922}
923//_____________________________________________
924Bool_t AliAnalysisTaskV0ChCorrelations::IsMyGoodDaughterTrack(const AliAODTrack *t)
925{
926 // TPC refit
927 if (!t->IsOn(AliAODTrack::kTPCrefit)) return kFALSE;
928 // Minimum number of clusters
929 Float_t nCrossedRowsTPC = t->GetTPCClusterInfo(2,1);
930 if (nCrossedRowsTPC < 70) return kFALSE;
931 Int_t findable=t->GetTPCNclsF();
932 if (findable <= 0) return kFALSE;
933 if (nCrossedRowsTPC/findable < 0.8) return kFALSE;
934
935 return kTRUE;
936}
937//______________________________________________
74754736 938Bool_t AliAnalysisTaskV0ChCorrelations::IsMyGoodV0(const AliAODEvent* aod, const AliAODv0* aodV0, const AliAODTrack* myTrackPos, const AliAODTrack* myTrackNeg, Int_t oSta)
59bd5476 939{
940 if (!aodV0) {
941 AliError(Form("ERROR: Could not retrieve aodV0"));
942 return kFALSE;
943 }
944
59bd5476 945 // Offline reconstructed V0 only
74754736 946 if (oSta==1) {if (aodV0->GetOnFlyStatus()) return kFALSE;}
947 if (oSta==3) {if (!aodV0->GetOnFlyStatus()) return kFALSE;}
948
399ef8f2 949 if (oSta==2)
950 {
951 if (aodV0->GetOnFlyStatus())
952 {
953 return kTRUE;
954 } else {
955 return kFALSE;
956 }
957 }
958 if (oSta==4)
959 {
960 if (!aodV0->GetOnFlyStatus())
961 {
962 return kTRUE;
963 } else {
964 return kFALSE;
965 }
966 }
74754736 967
968 // Get daughters and check them
969 AliAODTrack *myTrackNegTest=dynamic_cast<AliAODTrack *>(aodV0->GetDaughter(1));
970 AliAODTrack *myTrackPosTest=dynamic_cast<AliAODTrack *>(aodV0->GetDaughter(0));
971
972 if (!myTrackPosTest || !myTrackNegTest) {
973 Printf("strange analysis::UserExec:: Error:Could not retreive one of the daughter track\n");
974 return kFALSE;
975 }
976
977 if( myTrackPosTest->Charge() ==1){
978 myTrackPos = myTrackPosTest;
979 myTrackNeg = myTrackNegTest;
980 }
981
982 if( myTrackPosTest->Charge() ==-1){
983 myTrackPos = myTrackNegTest;
984 myTrackNeg = myTrackPosTest;
985 }
986
987 // Track cuts for daughter tracks
988 if ( !(IsMyGoodDaughterTrack(myTrackPos)) || !(IsMyGoodDaughterTrack(myTrackNeg)) ) return kFALSE;
989
990 // Unlike signs of daughters
991 if (myTrackNegTest->Charge() == myTrackPosTest->Charge()) return kFALSE;
59bd5476 992
74754736 993 // Rapidity cut
994 //Double_t lCutRap = 0.75;
995 //Double_t lRapK0s = aodV0->Y(310);
996 //Double_t lRapLambda = aodV0->Y(3122);
997 //Double_t lRapAntiLambda = aodV0->Y(-3122);
998
999 // Pseudorapidity cut - there are high pt V0
1000 Double_t lCutEta = 0.75;
1001 Double_t lEtaV0 = aodV0->Eta();
1002 if (TMath::Abs(lEtaV0)>=lCutEta) return kFALSE;
1003 //if (TMath::Abs(lRapK0s)>=lCutRap) return kFALSE;
1004 //if (TMath::Abs(lRapLambda)>=lCutRap) return kFALSE;
1005 //if (TMath::Abs(lRapAntiLambda)>=lCutRap) return kFALSE;
1006
85c11f5a 1007 // getting global variables
1008 Float_t dcaDaughtersToPrimVtx = GetDcaDToPV();
1009 Float_t dcaBetweenDaughters = GetDcaV0D();
70840314 1010
1011 // DCA of daughter track to Primary Vertex
1012 Float_t xyn=aodV0->DcaNegToPrimVertex();
85c11f5a 1013 if (TMath::Abs(xyn)<dcaDaughtersToPrimVtx) return kFALSE;
70840314 1014 Float_t xyp=aodV0->DcaPosToPrimVertex();
85c11f5a 1015 if (TMath::Abs(xyp)<dcaDaughtersToPrimVtx) return kFALSE;
70840314 1016
1017 // DCA of daughter tracks
1018 Double_t dca=aodV0->DcaV0Daughters();
85c11f5a 1019 if (dca>dcaBetweenDaughters) return kFALSE;
70840314 1020
1021 // Cosinus of pointing angle
1022 Double_t cpa=aodV0->CosPointingAngle(aod->GetPrimaryVertex());
1023 if (cpa<0.998) return kFALSE;
1024
1025 // Fiducial volume cut
1026 Double_t xyz[3]; aodV0->GetSecondaryVtx(xyz);
1027 Double_t r2=xyz[0]*xyz[0] + xyz[1]*xyz[1];
1028 if (r2<0.9*0.9) return kFALSE;
1029 if (r2>100*100) return kFALSE;
1030
1031 // c*tau cut - in main V0 loop - depends on particle hypothesis
1032
59bd5476 1033 // Minimum pt of daughters
1034 Double_t lMomPos[3] = {999,999,999};
1035 Double_t lMomNeg[3] = {999,999,999};
1036
1037 lMomPos[0] = aodV0->MomPosX();
1038 lMomPos[1] = aodV0->MomPosY();
1039 lMomPos[2] = aodV0->MomPosZ();
1040
1041 lMomNeg[0] = aodV0->MomNegX();
1042 lMomNeg[1] = aodV0->MomNegY();
1043 lMomNeg[2] = aodV0->MomNegZ();
1044
1045 Double_t lPtPos = TMath::Sqrt(lMomPos[0]*lMomPos[0] + lMomPos[1]*lMomPos[1]);
1046 Double_t lPtNeg = TMath::Sqrt(lMomNeg[0]*lMomNeg[0] + lMomNeg[1]*lMomNeg[1]);
1047
1048 Double_t cutMinPtDaughter = 0.160;
1049 if (lPtPos<cutMinPtDaughter || lPtNeg<cutMinPtDaughter) return kFALSE;
1050
1051 // Daughter PID cut - in main V0 loop - depends on particle hypothesis
1052
1053 return kTRUE;
1054}
1055
bccd1153 1056void AliAnalysisTaskV0ChCorrelations::RemovingInjectedSignal(TObjArray* tracks, TObject* mcObj, Int_t maxLabel)
1057{
1058 // remove injected signals (primaries above <maxLabel>)
1059 // <tracks> can be the following cases:
1060 // a. tracks: in this case the label is taken and then case b.
1061 // b. particles: the first stable mother is searched and checked if it is <= <maxLabel>
1062 // <mcObj> can be AOD (TClonesArray) or ESD (AliMCEvent)
1063
1064 TClonesArray* arrayMC = 0;
1065 AliMCEvent* mcEvent = 0;
1066 if (mcObj->InheritsFrom("AliMCEvent"))
1067 mcEvent = static_cast<AliMCEvent*>(mcObj);
1068 else if (mcObj->InheritsFrom("TClonesArray"))
1069 arrayMC = static_cast<TClonesArray*>(mcObj);
1070 else
1071 {
1072 mcObj->Dump();
1073 AliFatal("Invalid object passed");
1074 }
1075
1076 Int_t before = tracks->GetEntriesFast();
1077
1078 for (Int_t i=0; i<before; ++i)
1079 {
1080 AliVParticle* part = (AliVParticle*) tracks->At(i);
1081
1082 if (part->InheritsFrom("AliESDtrack")) part = mcEvent->GetTrack(TMath::Abs(part->GetLabel()));
1083 if (part->InheritsFrom("AliAODTrack"))
1084 {
1085 part =(AliVParticle*)arrayMC->At(TMath::Abs(part->GetLabel()));
1086 //cout << "toto musi byt len pri reco trackoch" << endl;
1087 }
1088
1089 AliVParticle* mother = part;
1090 if (mcEvent)
1091 {
1092 while (!mcEvent->IsPhysicalPrimary(mother->GetLabel()))
1093 {
1094 if (((AliMCParticle*)mother)->GetMother() < 0)
1095 {
1096 mother = 0;
1097 break;
1098 }
1099
1100 mother = (AliMCParticle*) mcEvent->GetTrack(((AliMCParticle*)mother)->GetMother());
1101 if (!mother)
1102 break;
1103 }
1104 }
1105 else
1106 {
1107 // find the primary mother
1108 while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
1109 {
1110 if (((AliAODMCParticle*)mother)->GetMother() < 0)
1111 {
1112 mother = 0;
1113 break;
1114 }
1115
1116 mother = (AliVParticle*) arrayMC->At(((AliAODMCParticle*)mother)->GetMother());
1117 if (!mother)
1118 break;
1119 }
1120 }
1121
1122 if (!mother)
1123 {
1124 //Printf("WARNING: No mother found for particle %d:", part->GetLabel());
1125 continue;
1126 }
1127
1128 if (mother->GetLabel() > maxLabel)
1129 {
1130// Printf("Removing %d with label %d", i, part->GetLabel()); part->Dump();
1131 TObject* object = tracks->RemoveAt(i);
1132 if (tracks->IsOwner())
1133 delete object;
1134 }
1135 }
1136
1137 tracks->Compress();
1138
1139 AliInfo(Form("Reduced from %d to %d", before, tracks->GetEntriesFast()));
1140
1141}
1142