adding TPCFitMap to the AODtrack
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskESDfilter.cxx
CommitLineData
f7ed7e88 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
9 * without fee, provided that the above copyright notice appears in all *\r
10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
c7ef1c47 16/* $Id$ */\r
f7ed7e88 17 \r
18#include <TChain.h>\r
19#include <TTree.h>\r
20#include <TList.h>\r
21#include <TArrayI.h>\r
22#include <TRandom.h>\r
23#include <TParticle.h>\r
a5f7aba4 24#include <TFile.h>\r
f7ed7e88 25\r
26#include "AliAnalysisTaskESDfilter.h"\r
27#include "AliAnalysisManager.h"\r
28#include "AliESDEvent.h"\r
f2f21b24 29#include "AliESDRun.h"\r
f7ed7e88 30#include "AliStack.h"\r
31#include "AliAODEvent.h"\r
32#include "AliMCEvent.h"\r
33#include "AliMCEventHandler.h"\r
34#include "AliESDInputHandler.h"\r
35#include "AliAODHandler.h"\r
36#include "AliAODMCParticle.h"\r
37#include "AliAnalysisFilter.h"\r
38#include "AliESDMuonTrack.h"\r
39#include "AliESDVertex.h"\r
fba4b2e2 40#include "AliCentrality.h"\r
ce7adfe9 41#include "AliEventplane.h"\r
f7ed7e88 42#include "AliESDv0.h"\r
43#include "AliESDkink.h"\r
44#include "AliESDcascade.h"\r
45#include "AliESDPmdTrack.h"\r
46#include "AliESDCaloCluster.h"\r
47#include "AliESDCaloCells.h"\r
48#include "AliMultiplicity.h"\r
49#include "AliLog.h"\r
c7ef1c47 50#include "AliCodeTimer.h"\r
a7b1466d 51#include "AliESDtrackCuts.h"\r
c7ef1c47 52#include "AliESDpid.h"\r
53#include "Riostream.h"\r
54\r
f7ed7e88 55ClassImp(AliAnalysisTaskESDfilter)\r
56\r
57////////////////////////////////////////////////////////////////////////\r
58\r
59AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter():\r
60 AliAnalysisTaskSE(),\r
61 fTrackFilter(0x0),\r
62 fKinkFilter(0x0),\r
63 fV0Filter(0x0),\r
64 fCascadeFilter(0x0),\r
65 fHighPthreshold(0),\r
12588061 66 fPtshape(0x0),\r
26917b0b 67 fEnableFillAOD(kTRUE),\r
8c87d22c 68 fUsedTrack(0x0),\r
69 fUsedKink(0x0),\r
70 fUsedV0(0x0),\r
71 fAODTrackRefs(0x0),\r
72 fAODV0VtxRefs(0x0),\r
73 fAODV0Refs(0x0),\r
74 fMChandler(0x0),\r
75 fNumberOfTracks(0),\r
76 fNumberOfPositiveTracks(0),\r
77 fNumberOfV0s(0),\r
78 fNumberOfVertices(0),\r
79 fNumberOfCascades(0),\r
80 fNumberOfKinks(0),\r
81 fOldESDformat(kFALSE),\r
82 fPrimaryVertex(0x0),\r
67abcce9 83 fTPCConstrainedFilterMask(0),\r
84 fHybridFilterMaskTPCCG(0),\r
85 fWriteHybridTPCCOnly(kFALSE),\r
86 fGlobalConstrainedFilterMask(0),\r
87 fHybridFilterMaskGCG(0),\r
88 fWriteHybridGCOnly(kFALSE),\r
8c87d22c 89 fIsVZEROEnabled(kTRUE),\r
a1f96974 90 fIsTZEROEnabled(kTRUE),\r
8c87d22c 91 fIsZDCEnabled(kTRUE),\r
92 fAreCascadesEnabled(kTRUE),\r
93 fAreV0sEnabled(kTRUE),\r
94 fAreKinksEnabled(kTRUE),\r
95 fAreTracksEnabled(kTRUE),\r
96 fArePmdClustersEnabled(kTRUE),\r
97 fAreCaloClustersEnabled(kTRUE),\r
98 fAreEMCALCellsEnabled(kTRUE),\r
99 fArePHOSCellsEnabled(kTRUE),\r
100 fAreTrackletsEnabled(kTRUE),\r
101 fESDpid(0x0),\r
102 fIsPidOwner(kFALSE),\r
103 fTimeZeroType(AliESDpid::kTOF_T0),\r
104 fTPCaloneTrackCuts(0)\r
f7ed7e88 105{\r
106 // Default constructor\r
107}\r
108\r
c7ef1c47 109//______________________________________________________________________________\r
f7ed7e88 110AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter(const char* name):\r
111 AliAnalysisTaskSE(name),\r
112 fTrackFilter(0x0),\r
113 fKinkFilter(0x0),\r
114 fV0Filter(0x0),\r
115 fCascadeFilter(0x0),\r
116 fHighPthreshold(0),\r
12588061 117 fPtshape(0x0),\r
26917b0b 118 fEnableFillAOD(kTRUE),\r
8c87d22c 119 fUsedTrack(0x0),\r
120 fUsedKink(0x0),\r
121 fUsedV0(0x0),\r
122 fAODTrackRefs(0x0),\r
123 fAODV0VtxRefs(0x0),\r
124 fAODV0Refs(0x0),\r
125 fMChandler(0x0),\r
126 fNumberOfTracks(0),\r
127 fNumberOfPositiveTracks(0),\r
128 fNumberOfV0s(0),\r
129 fNumberOfVertices(0),\r
130 fNumberOfCascades(0),\r
131 fNumberOfKinks(0),\r
132 fOldESDformat(kFALSE),\r
133 fPrimaryVertex(0x0),\r
67abcce9 134 fTPCConstrainedFilterMask(0),\r
135 fHybridFilterMaskTPCCG(0),\r
136 fWriteHybridTPCCOnly(kFALSE),\r
137 fGlobalConstrainedFilterMask(0),\r
138 fHybridFilterMaskGCG(0),\r
139 fWriteHybridGCOnly(kFALSE),\r
8c87d22c 140 fIsVZEROEnabled(kTRUE),\r
a1f96974 141 fIsTZEROEnabled(kTRUE),\r
8c87d22c 142 fIsZDCEnabled(kTRUE),\r
143 fAreCascadesEnabled(kTRUE),\r
144 fAreV0sEnabled(kTRUE),\r
145 fAreKinksEnabled(kTRUE),\r
146 fAreTracksEnabled(kTRUE),\r
147 fArePmdClustersEnabled(kTRUE),\r
148 fAreCaloClustersEnabled(kTRUE),\r
149 fAreEMCALCellsEnabled(kTRUE),\r
150 fArePHOSCellsEnabled(kTRUE),\r
151 fAreTrackletsEnabled(kTRUE),\r
152 fESDpid(0x0),\r
153 fIsPidOwner(kFALSE),\r
154 fTimeZeroType(AliESDpid::kTOF_T0),\r
155 fTPCaloneTrackCuts(0)\r
f7ed7e88 156{\r
157 // Constructor\r
158}\r
75a996ab 159AliAnalysisTaskESDfilter::~AliAnalysisTaskESDfilter(){\r
8c87d22c 160 if(fIsPidOwner) delete fESDpid;\r
75a996ab 161}\r
c7ef1c47 162//______________________________________________________________________________\r
f7ed7e88 163void AliAnalysisTaskESDfilter::UserCreateOutputObjects()\r
164{\r
cd5eefa7 165 //\r
166 // Create Output Objects conenct filter to outputtree\r
167 // \r
c7ef1c47 168 if(OutputTree())\r
169 {\r
f7ed7e88 170 OutputTree()->GetUserInfo()->Add(fTrackFilter);\r
d3815ca9 171 }\r
c7ef1c47 172 else\r
173 {\r
d3815ca9 174 AliError("No OutputTree() for adding the track filter");\r
175 }\r
2f5ee3b7 176 fTPCaloneTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();\r
f7ed7e88 177}\r
178\r
c7ef1c47 179//______________________________________________________________________________\r
f7ed7e88 180void AliAnalysisTaskESDfilter::Init()\r
181{\r
c7ef1c47 182 // Initialization\r
183 if (fDebug > 1) AliInfo("Init() \n");\r
184 // Call configuration file\r
f7ed7e88 185}\r
186\r
c7ef1c47 187//______________________________________________________________________________\r
188void AliAnalysisTaskESDfilter::PrintTask(Option_t *option, Int_t indent) const\r
189{\r
5204c278 190// Print selection task information\r
c7ef1c47 191 AliInfo("");\r
192 \r
193 AliAnalysisTaskSE::PrintTask(option,indent);\r
194 \r
195 TString spaces(' ',indent+3);\r
196 \r
197 cout << spaces.Data() << Form("Cascades are %s",fAreCascadesEnabled ? "ENABLED":"DISABLED") << endl;\r
198 cout << spaces.Data() << Form("V0s are %s",fAreV0sEnabled ? "ENABLED":"DISABLED") << endl;\r
199 cout << spaces.Data() << Form("Kinks are %s",fAreKinksEnabled ? "ENABLED":"DISABLED") << endl;\r
200 cout << spaces.Data() << Form("Tracks are %s",fAreTracksEnabled ? "ENABLED":"DISABLED") << endl;\r
201 cout << spaces.Data() << Form("PmdClusters are %s",fArePmdClustersEnabled ? "ENABLED":"DISABLED") << endl;\r
202 cout << spaces.Data() << Form("CaloClusters are %s",fAreCaloClustersEnabled ? "ENABLED":"DISABLED") << endl;\r
203 cout << spaces.Data() << Form("EMCAL cells are %s",fAreEMCALCellsEnabled ? "ENABLED":"DISABLED") << endl;\r
204 cout << spaces.Data() << Form("Tracklets are %s",fAreTrackletsEnabled ? "ENABLED":"DISABLED") << endl; \r
205}\r
f7ed7e88 206\r
c7ef1c47 207//______________________________________________________________________________\r
f7ed7e88 208void AliAnalysisTaskESDfilter::UserExec(Option_t */*option*/)\r
209{\r
210// Execute analysis for current event\r
211//\r
212 \r
213 Long64_t ientry = Entry();\r
f2f21b24 214 \r
e26c0b71 215 if (fDebug > 0) {\r
f2f21b24 216 printf("Filter: Analysing event # %5d\n", (Int_t) ientry);\r
217 if (fHighPthreshold == 0) AliInfo("detector PID signals are stored in each track");\r
218 if (!fPtshape) AliInfo("detector PID signals are not stored below the pt threshold");\r
e26c0b71 219 }\r
5b173801 220 // Filters must explicitely enable AOD filling in their UserExec (AG)\r
221 if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) AliFatal("Cannot run ESD filter without an output event handler");\r
307b6330 222 if(fEnableFillAOD) {\r
223 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);\r
224 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE);\r
225 } \r
f7ed7e88 226 ConvertESDtoAOD();\r
227}\r
228\r
c7ef1c47 229//______________________________________________________________________________\r
230TClonesArray& AliAnalysisTaskESDfilter::Cascades()\r
231{\r
232 return *(AODEvent()->GetCascades());\r
233}\r
f7ed7e88 234\r
c7ef1c47 235//______________________________________________________________________________\r
236TClonesArray& AliAnalysisTaskESDfilter::Tracks()\r
237{\r
238 return *(AODEvent()->GetTracks());\r
239}\r
f7ed7e88 240\r
c7ef1c47 241//______________________________________________________________________________\r
242TClonesArray& AliAnalysisTaskESDfilter::V0s()\r
243{\r
244 return *(AODEvent()->GetV0s());\r
245}\r
f7ed7e88 246\r
c7ef1c47 247//______________________________________________________________________________\r
248TClonesArray& AliAnalysisTaskESDfilter::Vertices()\r
249{\r
250 return *(AODEvent()->GetVertices());\r
251}\r
f7ed7e88 252\r
c7ef1c47 253//______________________________________________________________________________\r
254AliAODHeader* AliAnalysisTaskESDfilter::ConvertHeader(const AliESDEvent& esd)\r
255{\r
5204c278 256// Convert header information\r
257\r
c7ef1c47 258 AliCodeTimerAuto("",0);\r
259 \r
260 AliAODHeader* header = AODEvent()->GetHeader();\r
261 \r
262 header->SetRunNumber(esd.GetRunNumber());\r
263 header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection\r
f7ed7e88 264\r
c7ef1c47 265 TTree* tree = fInputHandler->GetTree();\r
266 if (tree) {\r
267 TFile* file = tree->GetCurrentFile();\r
268 if (file) header->SetESDFileName(file->GetName());\r
269 }\r
270 \r
271 if (fOldESDformat) {\r
272 header->SetBunchCrossNumber(0);\r
273 header->SetOrbitNumber(0);\r
274 header->SetPeriodNumber(0);\r
275 header->SetEventType(0);\r
276 header->SetMuonMagFieldScale(-999.);\r
277 header->SetCentrality(0); \r
ce7adfe9 278 header->SetEventplane(0);\r
c7ef1c47 279 } else {\r
280 header->SetBunchCrossNumber(esd.GetBunchCrossNumber());\r
281 header->SetOrbitNumber(esd.GetOrbitNumber());\r
282 header->SetPeriodNumber(esd.GetPeriodNumber());\r
283 header->SetEventType(esd.GetEventType());\r
f7ed7e88 284 \r
c7ef1c47 285 header->SetEventNumberESDFile(esd.GetHeader()->GetEventNumberInFile());\r
286 if(const_cast<AliESDEvent&>(esd).GetCentrality()){\r
75a996ab 287 header->SetCentrality(const_cast<AliESDEvent&>(esd).GetCentrality());\r
a98c78e5 288 }\r
c7ef1c47 289 else{\r
290 header->SetCentrality(0);\r
a98c78e5 291 }\r
ce7adfe9 292 if(const_cast<AliESDEvent&>(esd).GetEventplane()){\r
293 header->SetEventplane(const_cast<AliESDEvent&>(esd).GetEventplane());\r
294 }\r
295 else{\r
296 header->SetEventplane(0);\r
297 }\r
c7ef1c47 298 }\r
299 \r
300 // Trigger\r
301 header->SetFiredTriggerClasses(esd.GetFiredTriggerClasses());\r
302 header->SetTriggerMask(esd.GetTriggerMask()); \r
303 header->SetTriggerCluster(esd.GetTriggerCluster());\r
304 header->SetL0TriggerInputs(esd.GetHeader()->GetL0TriggerInputs()); \r
305 header->SetL1TriggerInputs(esd.GetHeader()->GetL1TriggerInputs()); \r
306 header->SetL2TriggerInputs(esd.GetHeader()->GetL2TriggerInputs()); \r
307 \r
308 header->SetMagneticField(esd.GetMagneticField());\r
309 header->SetMuonMagFieldScale(esd.GetCurrentDip()/6000.);\r
310 header->SetZDCN1Energy(esd.GetZDCN1Energy());\r
311 header->SetZDCP1Energy(esd.GetZDCP1Energy());\r
312 header->SetZDCN2Energy(esd.GetZDCN2Energy());\r
313 header->SetZDCP2Energy(esd.GetZDCP2Energy());\r
314 header->SetZDCEMEnergy(esd.GetZDCEMEnergy(0),esd.GetZDCEMEnergy(1));\r
315 \r
f7ce7a37 316 // ITS Cluster Multiplicty\r
317 const AliMultiplicity *mult = esd.GetMultiplicity();\r
318 for (Int_t ilay = 0; ilay < 6; ilay++) header->SetITSClusters(ilay, mult->GetNumberOfITSClusters(ilay));\r
c7ef1c47 319 \r
f7ce7a37 320 // TPC only Reference Multiplicty\r
2f5ee3b7 321 Int_t refMult = fTPCaloneTrackCuts ? (Short_t)fTPCaloneTrackCuts->GetReferenceMultiplicity(&esd, kTRUE) : -1;\r
f7ce7a37 322 header->SetTPConlyRefMultiplicity(refMult);\r
323 \r
324 //\r
c7ef1c47 325 Float_t diamxy[2]={esd.GetDiamondX(),esd.GetDiamondY()};\r
326 Float_t diamcov[3]; \r
327 esd.GetDiamondCovXY(diamcov);\r
328 header->SetDiamond(diamxy,diamcov);\r
329 header->SetDiamondZ(esd.GetDiamondZ(),esd.GetSigma2DiamondZ());\r
330 \r
331 return header;\r
332}\r
a98c78e5 333\r
c7ef1c47 334//______________________________________________________________________________\r
335void AliAnalysisTaskESDfilter::ConvertCascades(const AliESDEvent& esd) \r
336{\r
337 // Convert the cascades part of the ESD.\r
338 // Return the number of cascades\r
339 \r
340 AliCodeTimerAuto("",0);\r
341 \r
342 // Create vertices starting from the most complex objects\r
343 Double_t chi2 = 0.;\r
344 \r
345 const AliESDVertex* vtx = esd.GetPrimaryVertex();\r
346 Double_t pos[3] = { 0. };\r
347 Double_t covVtx[6] = { 0. };\r
348 Double_t momBach[3]={0.};\r
349 Double_t covTr[21]={0.};\r
350 Double_t pid[10]={0.};\r
351 AliAODPid* detpid(0x0);\r
352 AliAODVertex* vV0FromCascade(0x0);\r
353 AliAODv0* aodV0(0x0);\r
354 AliAODcascade* aodCascade(0x0);\r
355 AliAODTrack* aodTrack(0x0);\r
356 Double_t momPos[3]={0.};\r
357 Double_t momNeg[3] = { 0. };\r
358 Double_t momPosAtV0vtx[3]={0.};\r
359 Double_t momNegAtV0vtx[3]={0.};\r
360\r
361 TClonesArray& verticesArray = Vertices();\r
362 TClonesArray& tracksArray = Tracks();\r
363 TClonesArray& cascadesArray = Cascades();\r
364 \r
365 // Cascades (Modified by A.Maire - February 2009)\r
366 for (Int_t nCascade = 0; nCascade < esd.GetNumberOfCascades(); ++nCascade) {\r
6878d51e 367 \r
c7ef1c47 368 // 0- Preparation\r
369 //\r
370 AliESDcascade *esdCascade = esd.GetCascade(nCascade);\r
371 Int_t idxPosFromV0Dghter = esdCascade->GetPindex();\r
372 Int_t idxNegFromV0Dghter = esdCascade->GetNindex();\r
373 Int_t idxBachFromCascade = esdCascade->GetBindex();\r
b13bcc35 374 \r
c7ef1c47 375 AliESDtrack *esdCascadePos = esd.GetTrack( idxPosFromV0Dghter);\r
376 AliESDtrack *esdCascadeNeg = esd.GetTrack( idxNegFromV0Dghter);\r
377 AliESDtrack *esdCascadeBach = esd.GetTrack( idxBachFromCascade);\r
253cab77 378 \r
c7ef1c47 379 // Identification of the V0 within the esdCascade (via both daughter track indices)\r
380 AliESDv0 * currentV0 = 0x0;\r
381 Int_t idxV0FromCascade = -1;\r
382 \r
383 for (Int_t iV0=0; iV0<esd.GetNumberOfV0s(); ++iV0) {\r
384 \r
385 currentV0 = esd.GetV0(iV0);\r
386 Int_t posCurrentV0 = currentV0->GetPindex();\r
387 Int_t negCurrentV0 = currentV0->GetNindex();\r
388 \r
389 if (posCurrentV0==idxPosFromV0Dghter && negCurrentV0==idxNegFromV0Dghter) {\r
390 idxV0FromCascade = iV0;\r
391 break;\r
392 }\r
b13bcc35 393 }\r
f7ed7e88 394 \r
c7ef1c47 395 if(idxV0FromCascade < 0){\r
396 printf("Cascade - no matching for the V0 (index V0 = -1) ! Skip ... \n");\r
397 continue;\r
398 }// a priori, useless check, but safer ... in case of pb with tracks "out of bounds"\r
399 \r
400 AliESDv0 *esdV0FromCascade = esd.GetV0(idxV0FromCascade);\r
401 \r
402 // 1 - Cascade selection \r
403 \r
404 // AliESDVertex *esdPrimVtx = new AliESDVertex(*(esd.GetPrimaryVertex()));\r
405 // TList cascadeObjects;\r
406 // cascadeObjects.AddAt(esdV0FromCascade, 0);\r
407 // cascadeObjects.AddAt(esdCascadePos, 1);\r
408 // cascadeObjects.AddAt(esdCascadeNeg, 2);\r
409 // cascadeObjects.AddAt(esdCascade, 3);\r
410 // cascadeObjects.AddAt(esdCascadeBach, 4);\r
411 // cascadeObjects.AddAt(esdPrimVtx, 5);\r
412 // \r
413 // UInt_t selectCascade = 0;\r
414 // if (fCascadeFilter) {\r
415 // // selectCascade = fCascadeFilter->IsSelected(&cascadeObjects); \r
416 // // FIXME AliESDCascadeCuts to be implemented ...\r
417 // \r
418 // // Here we may encounter a moot point at the V0 level \r
419 // // between the cascade selections and the V0 ones :\r
420 // // the V0 selected along with the cascade (secondary V0) may \r
421 // // usually be removed from the dedicated V0 selections (prim V0) ...\r
422 // // -> To be discussed !\r
423 // \r
424 // // this is a little awkward but otherwise the \r
425 // // list wants to access the pointer (delete it) \r
426 // // again when going out of scope\r
427 // delete cascadeObjects.RemoveAt(5); // esdPrimVtx created via copy construct\r
428 // esdPrimVtx = 0;\r
429 // if (!selectCascade) \r
430 // continue;\r
431 // }\r
432 // else{\r
433 // delete cascadeObjects.RemoveAt(5); // esdPrimVtx created via copy construct\r
434 // esdPrimVtx = 0;\r
435 // }\r
436 \r
437 // 2 - Add the cascade vertex\r
438 \r
439 esdCascade->GetXYZcascade(pos[0], pos[1], pos[2]);\r
440 esdCascade->GetPosCovXi(covVtx);\r
441 chi2 = esdCascade->GetChi2Xi(); \r
442 \r
443 AliAODVertex *vCascade = new(verticesArray[fNumberOfVertices++]) AliAODVertex( pos,\r
444 covVtx,\r
445 chi2, // FIXME = Chi2/NDF will be needed\r
446 fPrimaryVertex,\r
447 nCascade, // id\r
448 AliAODVertex::kCascade);\r
449 fPrimaryVertex->AddDaughter(vCascade);\r
450 \r
451// if (fDebug > 2) {\r
452// printf("---- Cascade / Cascade Vertex (AOD) : \n");\r
453// vCascade->Print();\r
454// }\r
455 \r
7557fd4b 456 if(esd.GetTOFHeader() && fIsPidOwner) fESDpid->SetTOFResponse(const_cast<AliESDEvent*>(&esd), (AliESDpid::EStartTimeType_t)fTimeZeroType); //in case of AOD production strating form LHC10e without Tender. \r
f7ed7e88 457\r
f7ed7e88 458\r
c7ef1c47 459 // 3 - Add the bachelor track from the cascade\r
460 \r
461 if (!fUsedTrack[idxBachFromCascade]) {\r
462 \r
463 esdCascadeBach->GetPxPyPz(momBach);\r
464 esdCascadeBach->GetXYZ(pos);\r
465 esdCascadeBach->GetCovarianceXYZPxPyPz(covTr);\r
466 esdCascadeBach->GetESDpid(pid);\r
467 \r
468 fUsedTrack[idxBachFromCascade] = kTRUE;\r
f7ed7e88 469 UInt_t selectInfo = 0;\r
9eeae5d5 470 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdCascadeBach);\r
c7ef1c47 471 if (fMChandler) fMChandler->SelectParticle(esdCascadeBach->GetLabel());\r
472 aodTrack = new(tracksArray[fNumberOfTracks++]) AliAODTrack(esdCascadeBach->GetID(),\r
473 esdCascadeBach->GetLabel(), \r
474 momBach, \r
475 kTRUE,\r
476 pos,\r
477 kFALSE, // Why kFALSE for "isDCA" ? FIXME\r
478 covTr, \r
479 (Short_t)esdCascadeBach->GetSign(),\r
480 esdCascadeBach->GetITSClusterMap(), \r
481 pid,\r
482 vCascade,\r
483 kTRUE, // usedForVtxFit = kFALSE ? FIXME\r
484 vtx->UsesTrack(esdCascadeBach->GetID()),\r
485 AliAODTrack::kSecondary,\r
486 selectInfo);\r
bcabd0e4 487 aodTrack->SetTPCFitMap(esdCascadeBach->GetTPCFitMap());\r
f2f21b24 488 aodTrack->SetTPCClusterMap(esdCascadeBach->GetTPCClusterMap());\r
489 aodTrack->SetTPCSharedMap (esdCascadeBach->GetTPCSharedMap());\r
40a060e5 490 aodTrack->SetChi2perNDF(Chi2perNDF(esdCascadeBach));\r
3c01c166 491 aodTrack->SetTPCPointsF(esdCascadeBach->GetTPCNclsF());\r
c7ef1c47 492 fAODTrackRefs->AddAt(aodTrack,idxBachFromCascade);\r
f2f21b24 493 \r
c7ef1c47 494 if (esdCascadeBach->GetSign() > 0) ++fNumberOfPositiveTracks;\r
f7ed7e88 495 aodTrack->ConvertAliPIDtoAODPID();\r
496 aodTrack->SetFlags(esdCascadeBach->GetStatus());\r
1a3579a6 497 SetAODPID(esdCascadeBach,aodTrack,detpid);\r
c7ef1c47 498 }\r
499 else {\r
500 aodTrack = static_cast<AliAODTrack*>( fAODTrackRefs->At(idxBachFromCascade) );\r
501 }\r
502 \r
503 vCascade->AddDaughter(aodTrack);\r
504 \r
505// if (fDebug > 4) {\r
506// printf("---- Cascade / bach dghter : \n");\r
507// aodTrack->Print();\r
508// }\r
509 \r
510 \r
511 // 4 - Add the V0 from the cascade. \r
512 // = V0vtx + both pos and neg daughter tracks + the aodV0 itself\r
513 //\r
514 \r
515 if ( !fUsedV0[idxV0FromCascade] ) {\r
516 // 4.A - if VO structure hasn't been created yet\r
517 \r
518 // 4.A.1 - Create the V0 vertex of the cascade\r
519 \r
520 esdV0FromCascade->GetXYZ(pos[0], pos[1], pos[2]);\r
521 esdV0FromCascade->GetPosCov(covVtx);\r
522 chi2 = esdV0FromCascade->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3 ?\r
f7ed7e88 523 \r
c7ef1c47 524 vV0FromCascade = new(verticesArray[fNumberOfVertices++]) AliAODVertex(pos,\r
525 covVtx,\r
526 chi2,\r
527 vCascade,\r
528 idxV0FromCascade, //id of ESDv0\r
529 AliAODVertex::kV0);\r
530 // Note:\r
531 // one V0 can be used by several cascades.\r
532 // So, one AOD V0 vtx can have several parent vtx.\r
533 // This is not directly allowed by AliAODvertex.\r
534 // Setting the parent vtx (here = param "vCascade") doesn't lead to a crash\r
535 // but to a problem of consistency within AODEvent.\r
536 // -> See below paragraph 4.B, for the proposed treatment of such a case.\r
537 \r
538 // Add the vV0FromCascade to the aodVOVtxRefs\r
539 fAODV0VtxRefs->AddAt(vV0FromCascade,idxV0FromCascade);\r
540 \r
541 \r
542 // 4.A.2 - Add the positive tracks from the V0\r
543 \r
544 esdCascadePos->GetPxPyPz(momPos);\r
545 esdCascadePos->GetXYZ(pos);\r
546 esdCascadePos->GetCovarianceXYZPxPyPz(covTr);\r
547 esdCascadePos->GetESDpid(pid);\r
548 \r
549 \r
550 if (!fUsedTrack[idxPosFromV0Dghter]) {\r
551 fUsedTrack[idxPosFromV0Dghter] = kTRUE;\r
552 \r
553 UInt_t selectInfo = 0;\r
554 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdCascadePos);\r
555 if(fMChandler) fMChandler->SelectParticle(esdCascadePos->GetLabel());\r
556 aodTrack = new(tracksArray[fNumberOfTracks++]) \r
557 AliAODTrack( esdCascadePos->GetID(),\r
558 esdCascadePos->GetLabel(), \r
559 momPos, \r
560 kTRUE,\r
561 pos,\r
562 kFALSE, // Why kFALSE for "isDCA" ? FIXME\r
563 covTr, \r
564 (Short_t)esdCascadePos->GetSign(),\r
565 esdCascadePos->GetITSClusterMap(), \r
566 pid,\r
567 vV0FromCascade,\r
568 kTRUE, // usedForVtxFit = kFALSE ? FIXME\r
569 vtx->UsesTrack(esdCascadePos->GetID()),\r
570 AliAODTrack::kSecondary,\r
571 selectInfo);\r
bcabd0e4 572 aodTrack->SetTPCFitMap(esdCascadePos->GetTPCFitMap());\r
c7ef1c47 573 aodTrack->SetTPCClusterMap(esdCascadePos->GetTPCClusterMap());\r
574 aodTrack->SetTPCSharedMap (esdCascadePos->GetTPCSharedMap());\r
575 aodTrack->SetChi2perNDF(Chi2perNDF(esdCascadePos));\r
3c01c166 576 aodTrack->SetTPCPointsF(esdCascadePos->GetTPCNclsF());\r
c7ef1c47 577 fAODTrackRefs->AddAt(aodTrack,idxPosFromV0Dghter);\r
578 \r
579 if (esdCascadePos->GetSign() > 0) ++fNumberOfPositiveTracks;\r
580 aodTrack->ConvertAliPIDtoAODPID();\r
581 aodTrack->SetFlags(esdCascadePos->GetStatus());\r
1a3579a6 582 SetAODPID(esdCascadePos,aodTrack,detpid);\r
c7ef1c47 583 }\r
584 else {\r
585 aodTrack = static_cast<AliAODTrack*>(fAODTrackRefs->At(idxPosFromV0Dghter));\r
586 }\r
587 vV0FromCascade->AddDaughter(aodTrack);\r
588 \r
589 \r
590 // 4.A.3 - Add the negative tracks from the V0\r
591 \r
592 esdCascadeNeg->GetPxPyPz(momNeg);\r
593 esdCascadeNeg->GetXYZ(pos);\r
594 esdCascadeNeg->GetCovarianceXYZPxPyPz(covTr);\r
595 esdCascadeNeg->GetESDpid(pid);\r
596 \r
597 \r
598 if (!fUsedTrack[idxNegFromV0Dghter]) {\r
599 fUsedTrack[idxNegFromV0Dghter] = kTRUE;\r
600 \r
601 UInt_t selectInfo = 0;\r
602 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdCascadeNeg);\r
603 if(fMChandler)fMChandler->SelectParticle(esdCascadeNeg->GetLabel());\r
604 aodTrack = new(tracksArray[fNumberOfTracks++]) AliAODTrack( esdCascadeNeg->GetID(),\r
605 esdCascadeNeg->GetLabel(),\r
606 momNeg,\r
607 kTRUE,\r
608 pos,\r
609 kFALSE, // Why kFALSE for "isDCA" ? FIXME\r
610 covTr, \r
611 (Short_t)esdCascadeNeg->GetSign(),\r
612 esdCascadeNeg->GetITSClusterMap(), \r
613 pid,\r
614 vV0FromCascade,\r
615 kTRUE, // usedForVtxFit = kFALSE ? FIXME\r
616 vtx->UsesTrack(esdCascadeNeg->GetID()),\r
617 AliAODTrack::kSecondary,\r
618 selectInfo);\r
bcabd0e4 619 aodTrack->SetTPCFitMap(esdCascadeNeg->GetTPCFitMap());\r
c7ef1c47 620 aodTrack->SetTPCClusterMap(esdCascadeNeg->GetTPCClusterMap());\r
621 aodTrack->SetTPCSharedMap (esdCascadeNeg->GetTPCSharedMap());\r
622 aodTrack->SetChi2perNDF(Chi2perNDF(esdCascadeNeg));\r
3c01c166 623 aodTrack->SetTPCPointsF(esdCascadeNeg->GetTPCNclsF());\r
c7ef1c47 624 fAODTrackRefs->AddAt(aodTrack,idxNegFromV0Dghter);\r
625 \r
626 if (esdCascadeNeg->GetSign() > 0) ++fNumberOfPositiveTracks;\r
627 aodTrack->ConvertAliPIDtoAODPID();\r
628 aodTrack->SetFlags(esdCascadeNeg->GetStatus());\r
1a3579a6 629 SetAODPID(esdCascadeNeg,aodTrack,detpid);\r
c7ef1c47 630 }\r
631 else {\r
632 aodTrack = static_cast<AliAODTrack*>(fAODTrackRefs->At(idxNegFromV0Dghter));\r
633 }\r
634 \r
635 vV0FromCascade->AddDaughter(aodTrack);\r
636 \r
f7ed7e88 637 \r
c7ef1c47 638 // 4.A.4 - Add the V0 from cascade to the V0 array\r
639 \r
640 Double_t dcaV0Daughters = esdV0FromCascade->GetDcaV0Daughters();\r
641 Double_t dcaV0ToPrimVertex = esdV0FromCascade->GetD( esd.GetPrimaryVertex()->GetX(),\r
642 esd.GetPrimaryVertex()->GetY(),\r
643 esd.GetPrimaryVertex()->GetZ() );\r
644 esdV0FromCascade->GetPPxPyPz( momPosAtV0vtx[0],momPosAtV0vtx[1],momPosAtV0vtx[2] ); \r
645 esdV0FromCascade->GetNPxPyPz( momNegAtV0vtx[0],momNegAtV0vtx[1],momNegAtV0vtx[2] ); \r
646 \r
647 Double_t dcaDaughterToPrimVertex[2] = { 999., 999.}; // ..[0] = DCA in (x,y) for Pos and ..[1] = Neg\r
648 dcaDaughterToPrimVertex[0] = TMath::Abs(esdCascadePos->GetD( esd.GetPrimaryVertex()->GetX(),\r
649 esd.GetPrimaryVertex()->GetY(),\r
650 esd.GetMagneticField()) );\r
651 dcaDaughterToPrimVertex[1] = TMath::Abs(esdCascadeNeg->GetD( esd.GetPrimaryVertex()->GetX(),\r
652 esd.GetPrimaryVertex()->GetY(),\r
653 esd.GetMagneticField()) );\r
654 \r
655 aodV0 = new(V0s()[fNumberOfV0s++]) AliAODv0( vV0FromCascade, \r
656 dcaV0Daughters,\r
657 dcaV0ToPrimVertex, \r
658 momPosAtV0vtx, \r
659 momNegAtV0vtx, \r
660 dcaDaughterToPrimVertex); \r
661 // set the aod v0 on-the-fly status\r
662 aodV0->SetOnFlyStatus(esdV0FromCascade->GetOnFlyStatus());\r
663 \r
664 // Add the aodV0 to the aodVORefs\r
665 fAODV0Refs->AddAt(aodV0,idxV0FromCascade);\r
666 \r
667 fUsedV0[idxV0FromCascade] = kTRUE;\r
668 \r
669 } else { \r
670 // 4.B - if V0 structure already used\r
671 \r
672 // Note :\r
673 // one V0 can be used by several cascades (frequent in PbPb evts) : \r
674 // same V0 which used but attached to different bachelor tracks\r
675 // -> aodVORefs and fAODV0VtxRefs are needed.\r
676 // Goal : avoid a redundancy of the info in "Vertices" and "v0s" clones array.\r
677 \r
678 vV0FromCascade = static_cast<AliAODVertex*>( fAODV0VtxRefs->At(idxV0FromCascade) );\r
679 aodV0 = static_cast<AliAODv0*> ( fAODV0Refs ->At(idxV0FromCascade) );\r
680 \r
681 // - Treatment of the parent for such a "re-used" V0 :\r
682 // Insert the cascade that reuses the V0 vertex in the lineage chain\r
683 // Before : vV0 -> vCascade1 -> vPrimary\r
684 // - Hyp : cascade2 uses the same V0 as cascade1\r
685 // After : vV0 -> vCascade2 -> vCascade1 -> vPrimary\r
686 \r
687 AliAODVertex *vCascadePreviousParent = static_cast<AliAODVertex*> (vV0FromCascade->GetParent());\r
f7ed7e88 688 vV0FromCascade->SetParent(vCascade);\r
689 vCascade ->SetParent(vCascadePreviousParent);\r
c7ef1c47 690 \r
691// if(fDebug > 2) \r
692// printf("---- Cascade / Lineage insertion\n"\r
693// "Parent of V0 vtx = Cascade vtx %p\n"\r
694// "Parent of the cascade vtx = Cascade vtx %p\n"\r
695// "Parent of the parent cascade vtx = Cascade vtx %p\n", \r
696// static_cast<void*> (vV0FromCascade->GetParent()),\r
697// static_cast<void*> (vCascade->GetParent()),\r
698// static_cast<void*> (vCascadePreviousParent->GetParent()) );\r
699 \r
700 }// end if V0 structure already used\r
701 \r
702// if (fDebug > 2) {\r
703// printf("---- Cascade / V0 vertex: \n");\r
704// vV0FromCascade->Print();\r
705// }\r
706// \r
707// if (fDebug > 4) {\r
708// printf("---- Cascade / pos dghter : \n");\r
709// aodTrack->Print();\r
710// printf("---- Cascade / neg dghter : \n");\r
711// aodTrack->Print();\r
712// printf("---- Cascade / aodV0 : \n");\r
713// aodV0->Print();\r
714// }\r
715 \r
716 // In any case (used V0 or not), add the V0 vertex to the cascade one.\r
717 vCascade->AddDaughter(vV0FromCascade); \r
718 \r
f7ed7e88 719 \r
c7ef1c47 720 // 5 - Add the primary track of the cascade (if any)\r
721 \r
722 \r
723 // 6 - Add the cascade to the AOD array of cascades\r
724 \r
725 Double_t dcaBachToPrimVertexXY = TMath::Abs(esdCascadeBach->GetD(esd.GetPrimaryVertex()->GetX(),\r
726 esd.GetPrimaryVertex()->GetY(),\r
727 esd.GetMagneticField()) );\r
728 \r
729 Double_t momBachAtCascadeVtx[3]={0.};\r
f7ed7e88 730\r
c7ef1c47 731 esdCascade->GetBPxPyPz(momBachAtCascadeVtx[0], momBachAtCascadeVtx[1], momBachAtCascadeVtx[2]);\r
732 \r
733 aodCascade = new(cascadesArray[fNumberOfCascades++]) AliAODcascade( vCascade,\r
734 esdCascade->Charge(),\r
735 esdCascade->GetDcaXiDaughters(),\r
736 -999.,\r
737 // DCAXiToPrimVtx -> needs to be calculated ----|\r
738 // doesn't exist at ESD level;\r
739 // See AODcascade::DcaXiToPrimVertex(Double, Double, Double)\r
740 dcaBachToPrimVertexXY,\r
741 momBachAtCascadeVtx,\r
742 *aodV0);\r
743 \r
40771071 744 if (fDebug > 10) {\r
745 printf("---- Cascade / AOD cascade : \n\n");\r
746 aodCascade->PrintXi(fPrimaryVertex->GetX(), fPrimaryVertex->GetY(), fPrimaryVertex->GetZ());\r
747 }\r
c7ef1c47 748 \r
749 } // end of the loop on cascades\r
750 \r
751 Cascades().Expand(fNumberOfCascades);\r
752}\r
f7ed7e88 753\r
c7ef1c47 754//______________________________________________________________________________\r
755void AliAnalysisTaskESDfilter::ConvertV0s(const AliESDEvent& esd)\r
756{\r
757 // Access to the AOD container of V0s\r
758 \r
759 AliCodeTimerAuto("",0);\r
f7ed7e88 760\r
c7ef1c47 761 //\r
762 // V0s\r
763 //\r
764 \r
765 Double_t pos[3] = { 0. }; \r
766 Double_t chi2(0.0);\r
767 Double_t covVtx[6] = { 0. };\r
768 Double_t momPos[3]={0.};\r
769 Double_t covTr[21]={0.};\r
770 Double_t pid[10]={0.};\r
771 AliAODTrack* aodTrack(0x0);\r
772 AliAODPid* detpid(0x0);\r
773 Double_t momNeg[3]={0.};\r
774 Double_t momPosAtV0vtx[3]={0.};\r
775 Double_t momNegAtV0vtx[3]={0.};\r
776 \r
777 for (Int_t nV0 = 0; nV0 < esd.GetNumberOfV0s(); ++nV0) \r
778 {\r
779 if (fUsedV0[nV0]) continue; // skip if already added to the AOD\r
780 \r
781 AliESDv0 *v0 = esd.GetV0(nV0);\r
782 Int_t posFromV0 = v0->GetPindex();\r
783 Int_t negFromV0 = v0->GetNindex();\r
784 \r
785 // V0 selection \r
f7ed7e88 786 //\r
c7ef1c47 787 AliESDVertex *esdVtx = new AliESDVertex(*(esd.GetPrimaryVertex()));\r
788 AliESDtrack *esdV0Pos = esd.GetTrack(posFromV0);\r
789 AliESDtrack *esdV0Neg = esd.GetTrack(negFromV0);\r
790 TList v0objects;\r
791 v0objects.AddAt(v0, 0);\r
792 v0objects.AddAt(esdV0Pos, 1);\r
793 v0objects.AddAt(esdV0Neg, 2);\r
794 v0objects.AddAt(esdVtx, 3);\r
795 UInt_t selectV0 = 0;\r
796 if (fV0Filter) {\r
797 selectV0 = fV0Filter->IsSelected(&v0objects);\r
798 // this is a little awkward but otherwise the \r
799 // list wants to access the pointer (delete it) \r
800 // again when going out of scope\r
801 delete v0objects.RemoveAt(3); // esdVtx created via copy construct\r
802 esdVtx = 0;\r
803 if (!selectV0) \r
804 continue;\r
805 }\r
806 else{\r
807 delete v0objects.RemoveAt(3); // esdVtx created via copy construct\r
808 esdVtx = 0;\r
809 }\r
810 \r
811 v0->GetXYZ(pos[0], pos[1], pos[2]);\r
f7ed7e88 812 \r
c7ef1c47 813 if (!fOldESDformat) {\r
f7ed7e88 814 chi2 = v0->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3\r
815 v0->GetPosCov(covVtx);\r
c7ef1c47 816 } else {\r
f7ed7e88 817 chi2 = -999.;\r
818 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;\r
c7ef1c47 819 }\r
820 \r
821 \r
822 AliAODVertex * vV0 = \r
823 new(Vertices()[fNumberOfVertices++]) AliAODVertex(pos,\r
824 covVtx,\r
825 chi2,\r
826 fPrimaryVertex,\r
827 nV0,\r
828 AliAODVertex::kV0);\r
829 fPrimaryVertex->AddDaughter(vV0);\r
830 \r
831 \r
832 // Add the positive tracks from the V0\r
833 \r
834\r
835 esdV0Pos->GetPxPyPz(momPos);\r
836 esdV0Pos->GetXYZ(pos);\r
837 esdV0Pos->GetCovarianceXYZPxPyPz(covTr);\r
838 esdV0Pos->GetESDpid(pid);\r
839 \r
840 const AliESDVertex *vtx = esd.GetPrimaryVertex();\r
841\r
842 if (!fUsedTrack[posFromV0]) {\r
843 fUsedTrack[posFromV0] = kTRUE;\r
f7ed7e88 844 UInt_t selectInfo = 0;\r
9eeae5d5 845 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdV0Pos);\r
c7ef1c47 846 if(fMChandler)fMChandler->SelectParticle(esdV0Pos->GetLabel());\r
847 aodTrack = new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdV0Pos->GetID(),\r
848 esdV0Pos->GetLabel(), \r
849 momPos, \r
850 kTRUE,\r
851 pos,\r
852 kFALSE,\r
853 covTr, \r
854 (Short_t)esdV0Pos->GetSign(),\r
855 esdV0Pos->GetITSClusterMap(), \r
856 pid,\r
857 vV0,\r
858 kTRUE, // check if this is right\r
859 vtx->UsesTrack(esdV0Pos->GetID()),\r
860 AliAODTrack::kSecondary,\r
861 selectInfo);\r
bcabd0e4 862 aodTrack->SetTPCFitMap(esdV0Pos->GetTPCFitMap());\r
f2f21b24 863 aodTrack->SetTPCClusterMap(esdV0Pos->GetTPCClusterMap());\r
864 aodTrack->SetTPCSharedMap (esdV0Pos->GetTPCSharedMap());\r
40a060e5 865 aodTrack->SetChi2perNDF(Chi2perNDF(esdV0Pos));\r
3c01c166 866 aodTrack->SetTPCPointsF(esdV0Pos->GetTPCNclsF());\r
c7ef1c47 867 fAODTrackRefs->AddAt(aodTrack,posFromV0);\r
f7ed7e88 868 // if (fDebug > 0) printf("-------------------Bo: pos track from original pt %.3f \n",aodTrack->Pt());\r
c7ef1c47 869 if (esdV0Pos->GetSign() > 0) ++fNumberOfPositiveTracks;\r
f7ed7e88 870 aodTrack->ConvertAliPIDtoAODPID();\r
871 aodTrack->SetFlags(esdV0Pos->GetStatus());\r
1a3579a6 872 SetAODPID(esdV0Pos,aodTrack,detpid);\r
c7ef1c47 873 }\r
874 else {\r
875 aodTrack = static_cast<AliAODTrack*>(fAODTrackRefs->At(posFromV0));\r
f7ed7e88 876 // if (fDebug > 0) printf("-------------------Bo pos track from refArray pt %.3f \n",aodTrack->Pt());\r
c7ef1c47 877 }\r
878 vV0->AddDaughter(aodTrack);\r
879 \r
880 // Add the negative tracks from the V0\r
881 \r
882 esdV0Neg->GetPxPyPz(momNeg);\r
883 esdV0Neg->GetXYZ(pos);\r
884 esdV0Neg->GetCovarianceXYZPxPyPz(covTr);\r
885 esdV0Neg->GetESDpid(pid);\r
886 \r
887 if (!fUsedTrack[negFromV0]) {\r
888 fUsedTrack[negFromV0] = kTRUE;\r
f7ed7e88 889 UInt_t selectInfo = 0;\r
9eeae5d5 890 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdV0Neg);\r
c7ef1c47 891 if(fMChandler)fMChandler->SelectParticle(esdV0Neg->GetLabel());\r
892 aodTrack = new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdV0Neg->GetID(),\r
893 esdV0Neg->GetLabel(),\r
894 momNeg,\r
895 kTRUE,\r
896 pos,\r
897 kFALSE,\r
898 covTr, \r
899 (Short_t)esdV0Neg->GetSign(),\r
900 esdV0Neg->GetITSClusterMap(), \r
901 pid,\r
902 vV0,\r
903 kTRUE, // check if this is right\r
904 vtx->UsesTrack(esdV0Neg->GetID()),\r
905 AliAODTrack::kSecondary,\r
906 selectInfo);\r
bcabd0e4 907 aodTrack->SetTPCFitMap(esdV0Neg->GetTPCFitMap());\r
f2f21b24 908 aodTrack->SetTPCClusterMap(esdV0Neg->GetTPCClusterMap());\r
909 aodTrack->SetTPCSharedMap (esdV0Neg->GetTPCSharedMap());\r
40a060e5 910 aodTrack->SetChi2perNDF(Chi2perNDF(esdV0Neg));\r
3c01c166 911 aodTrack->SetTPCPointsF(esdV0Neg->GetTPCNclsF());\r
f7ed7e88 912 \r
c7ef1c47 913 fAODTrackRefs->AddAt(aodTrack,negFromV0);\r
f7ed7e88 914 // if (fDebug > 0) printf("-------------------Bo: neg track from original pt %.3f \n",aodTrack->Pt());\r
c7ef1c47 915 if (esdV0Neg->GetSign() > 0) ++fNumberOfPositiveTracks;\r
f7ed7e88 916 aodTrack->ConvertAliPIDtoAODPID();\r
917 aodTrack->SetFlags(esdV0Neg->GetStatus());\r
1a3579a6 918 SetAODPID(esdV0Neg,aodTrack,detpid);\r
c7ef1c47 919 }\r
920 else {\r
921 aodTrack = static_cast<AliAODTrack*>(fAODTrackRefs->At(negFromV0));\r
f7ed7e88 922 // if (fDebug > 0) printf("-------------------Bo neg track from refArray pt %.3f \n",aodTrack->Pt());\r
f7ed7e88 923 }\r
c7ef1c47 924 vV0->AddDaughter(aodTrack);\r
925 \r
926 \r
927 // Add the V0 the V0 array as well\r
928 \r
929 Double_t dcaV0Daughters = v0->GetDcaV0Daughters();\r
930 Double_t dcaV0ToPrimVertex = v0->GetD(esd.GetPrimaryVertex()->GetX(),\r
931 esd.GetPrimaryVertex()->GetY(),\r
932 esd.GetPrimaryVertex()->GetZ());\r
933 \r
934 v0->GetPPxPyPz(momPosAtV0vtx[0],momPosAtV0vtx[1],momPosAtV0vtx[2]); \r
935 v0->GetNPxPyPz(momNegAtV0vtx[0],momNegAtV0vtx[1],momNegAtV0vtx[2]); \r
936 \r
937 Double_t dcaDaughterToPrimVertex[2] = { 999., 999.}; // ..[0] = DCA in (x,y) for Pos and ..[1] = Neg\r
938 dcaDaughterToPrimVertex[0] = TMath::Abs(esdV0Pos->GetD( esd.GetPrimaryVertex()->GetX(),\r
939 esd.GetPrimaryVertex()->GetY(),\r
940 esd.GetMagneticField()) );\r
941 dcaDaughterToPrimVertex[1] = TMath::Abs(esdV0Neg->GetD( esd.GetPrimaryVertex()->GetX(),\r
942 esd.GetPrimaryVertex()->GetY(),\r
943 esd.GetMagneticField()) );\r
f7ed7e88 944 \r
c7ef1c47 945 AliAODv0* aodV0 = new(V0s()[fNumberOfV0s++]) AliAODv0(vV0, \r
946 dcaV0Daughters,\r
947 dcaV0ToPrimVertex,\r
948 momPosAtV0vtx,\r
949 momNegAtV0vtx,\r
950 dcaDaughterToPrimVertex);\r
951 \r
952 // set the aod v0 on-the-fly status\r
953 aodV0->SetOnFlyStatus(v0->GetOnFlyStatus());\r
954 }//End of loop on V0s \r
f7ed7e88 955 \r
c7ef1c47 956 V0s().Expand(fNumberOfV0s); \r
957}\r
f7ed7e88 958\r
c7ef1c47 959//______________________________________________________________________________\r
960void AliAnalysisTaskESDfilter::ConvertTPCOnlyTracks(const AliESDEvent& esd)\r
961{\r
962 // Convert TPC only tracks\r
25a60d41 963 // Here we have wo hybrid appraoch to remove fakes\r
964 // ******* ITSTPC ********\r
965 // Uses a cut on the ITS properties to select global tracks\r
67abcce9 966 // which are than marked as HybdridITSTPC for the remainder \r
967 // the TPC only tracks are flagged as HybridITSTPConly. \r
968 // Note, in order not to get fakes back in the TPC cuts, one needs \r
25a60d41 969 // two "ITS" cuts one tight (1) (to throw out fakes) and one lose (2) (to NOT flag the trakcs in the TPC only)\r
970 // using cut number (3)\r
971 // so fHybridFilterMask == (1)|(2) fTPCFilterMask = (3), Usercode needs to slect with mask = (1)|(3) and track->IsHybridITSTPC()\r
972 // ******* TPC ********\r
973 // Here, only TPC tracks are flagged that pass the tight ITS cuts and tracks that pass the TPC cuts and NOT the loose ITS cuts\r
974 // the ITS cuts neeed to be added to the filter as extra cuts, since here the selections info is reset in the global and put to the TPC only track\r
975\r
c7ef1c47 976 AliCodeTimerAuto("",0);\r
977 \r
978 // Loop over the tracks and extract and mask out all aod tracks that pass the selections for AODt racks\r
979 for(int it = 0;it < fNumberOfTracks;++it)\r
980 {\r
981 AliAODTrack *tr = (AliAODTrack*)(Tracks().At(it));\r
982 if(!tr)continue;\r
983 UInt_t map = tr->GetFilterMap();\r
67abcce9 984 if(map&fTPCConstrainedFilterMask){\r
c7ef1c47 985 // we only reset the track select ionfo, no deletion...\r
67abcce9 986 tr->SetFilterMap(map&~fTPCConstrainedFilterMask);\r
c7ef1c47 987 }\r
67abcce9 988 if(map&fHybridFilterMaskTPCCG){\r
25a60d41 989 // this is one part of the hybrid tracks\r
990 // the others not passing the selection will be TPC only selected below\r
041743e4 991 tr->SetIsHybridTPCConstrainedGlobal(kTRUE);\r
25a60d41 992 }\r
c7ef1c47 993 }\r
994 // Loop over the ESD trcks and pick out the tracks passing TPC only cuts\r
995 \r
996 \r
997 const AliESDVertex *vtxSPD = esd.GetPrimaryVertexSPD();\r
998 const AliESDVertex *vtx = esd.GetPrimaryVertex();\r
999\r
1000 Double_t pos[3] = { 0. }; \r
1001 Double_t covTr[21]={0.};\r
1002 Double_t pid[10]={0.}; \r
bcab9a54 1003\r
1004\r
c7ef1c47 1005 Double_t p[3] = { 0. };\r
4b6f9f24 1006\r
1007 Double_t pDCA[3] = { 0. }; // momentum at DCA\r
1008 Double_t rDCA[3] = { 0. }; // position at DCA\r
1009 Float_t dDCA[2] = {0.}; // DCA to the vertex d and z\r
1010 Float_t cDCA[3] = {0.}; // covariance of impact parameters\r
1011\r
1012\r
c7ef1c47 1013 AliAODTrack* aodTrack(0x0);\r
ceb821c3 1014 // AliAODPid* detpid(0x0);\r
bcab9a54 1015\r
041743e4 1016 // account for change in pT after the constraint\r
1017 Float_t ptMax = 1E10;\r
1018 Float_t ptMin = 0;\r
1019 for(int i = 0;i<32;i++){\r
1020 if(fTPCConstrainedFilterMask&(1<<i)){\r
1021 AliESDtrackCuts*cuts = (AliESDtrackCuts*)fTrackFilter->GetCuts()->At(i);\r
1022 Float_t tmp1= 0,tmp2 = 0;\r
1023 cuts->GetPtRange(tmp1,tmp2);\r
1024 if(tmp1>ptMin)ptMin=tmp1;\r
1025 if(tmp2<ptMax)ptMax=tmp2;\r
1026 }\r
1027 } \r
1028\r
c7ef1c47 1029 for (Int_t nTrack = 0; nTrack < esd.GetNumberOfTracks(); ++nTrack) \r
1030 {\r
1031 AliESDtrack* esdTrack = esd.GetTrack(nTrack); //carefull do not modify it othwise need to work with a copy \r
1032 \r
1033 UInt_t selectInfo = 0;\r
25a60d41 1034 Bool_t isHybridITSTPC = false;\r
c7ef1c47 1035 //\r
1036 // Track selection\r
1037 if (fTrackFilter) {\r
1038 selectInfo = fTrackFilter->IsSelected(esdTrack);\r
1039 }\r
25a60d41 1040\r
67abcce9 1041 if(!(selectInfo&fHybridFilterMaskTPCCG)){\r
25a60d41 1042 // not already selected tracks, use second part of hybrid tracks\r
1043 isHybridITSTPC = true;\r
1044 // too save space one could only store these...\r
1045 }\r
1046\r
67abcce9 1047 selectInfo &= fTPCConstrainedFilterMask;\r
c7ef1c47 1048 if (!selectInfo)continue;\r
67abcce9 1049 if (fWriteHybridTPCCOnly&&!isHybridITSTPC)continue; // write only complementary tracks\r
c7ef1c47 1050 // create a tpc only tracl\r
1051 AliESDtrack *track = AliESDtrackCuts::GetTPCOnlyTrack(const_cast<AliESDEvent*>(&esd),esdTrack->GetID());\r
1052 if(!track) continue;\r
1053 \r
1054 if(track->Pt()>0.)\r
1055 {\r
1056 // only constrain tracks above threshold\r
1057 AliExternalTrackParam exParam;\r
1058 // take the B-field from the ESD, no 3D fieldMap available at this point\r
1059 Bool_t relate = false;\r
2fb345ad 1060 relate = track->RelateToVertexTPC(vtxSPD,esd.GetMagneticField(),kVeryBig,&exParam);\r
c7ef1c47 1061 if(!relate){\r
1062 delete track;\r
1063 continue;\r
a7b1466d 1064 }\r
4b6f9f24 1065 // fetch the track parameters at the DCA (unconstraint)\r
1066 if(track->GetTPCInnerParam()){\r
1067 track->GetTPCInnerParam()->GetPxPyPz(pDCA);\r
1068 track->GetTPCInnerParam()->GetXYZ(rDCA);\r
1069 }\r
1070 // get the DCA to the vertex:\r
1071 track->GetImpactParametersTPC(dDCA,cDCA);\r
67abcce9 1072 // set the constrained parameters to the track\r
c7ef1c47 1073 track->Set(exParam.GetX(),exParam.GetAlpha(),exParam.GetParameter(),exParam.GetCovariance());\r
1074 }\r
1075 \r
1076 track->GetPxPyPz(p);\r
041743e4 1077\r
1078 Float_t pT = track->Pt();\r
1079 if(pT<ptMin||pT>ptMax){\r
1080 delete track;\r
1081 continue;\r
1082 }\r
1083\r
1084 // \r
1085\r
1086\r
c7ef1c47 1087 track->GetXYZ(pos);\r
1088 track->GetCovarianceXYZPxPyPz(covTr);\r
bcab9a54 1089 esdTrack->GetESDpid(pid);// original PID\r
041743e4 1090\r
c7ef1c47 1091 if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());\r
1092 aodTrack = new(Tracks()[fNumberOfTracks++]) AliAODTrack((track->GetID()+1)*-1,\r
1093 track->GetLabel(),\r
1094 p,\r
1095 kTRUE,\r
1096 pos,\r
1097 kFALSE,\r
1098 covTr, \r
1099 (Short_t)track->GetSign(),\r
1100 track->GetITSClusterMap(), \r
1101 pid,\r
1102 fPrimaryVertex,\r
1103 kTRUE, // check if this is right\r
1104 vtx->UsesTrack(track->GetID()),\r
1105 AliAODTrack::kPrimary, \r
1106 selectInfo);\r
041743e4 1107 aodTrack->SetIsHybridTPCConstrainedGlobal(isHybridITSTPC); \r
bcabd0e4 1108 aodTrack->SetTPCFitMap(track->GetTPCFitMap());\r
c7ef1c47 1109 aodTrack->SetTPCClusterMap(track->GetTPCClusterMap());\r
1110 aodTrack->SetTPCSharedMap (track->GetTPCSharedMap());\r
041743e4 1111 aodTrack->SetIsTPCConstrained(kTRUE); \r
bcab9a54 1112 aodTrack->SetChi2perNDF(Chi2perNDF(esdTrack)); // original track\r
4b6f9f24 1113 // set the DCA values to the AOD track\r
1114 aodTrack->SetPxPyPzAtDCA(pDCA[0],pDCA[1],pDCA[2]);\r
1115 aodTrack->SetXYAtDCA(rDCA[0],rDCA[1]);\r
1116 aodTrack->SetDCA(dDCA[0],dDCA[1]);\r
1117\r
c7ef1c47 1118 aodTrack->SetFlags(track->GetStatus());\r
3c01c166 1119 aodTrack->SetTPCPointsF(track->GetTPCNclsF());\r
1120\r
bcab9a54 1121 // do not duplicate PID information \r
1122 // aodTrack->ConvertAliPIDtoAODPID();\r
1123 // SetAODPID(esdTrack,aodTrack,detpid);\r
1124\r
c7ef1c47 1125 delete track;\r
1126 } // end of loop on tracks\r
1127 \r
1128}\r
1129\r
67abcce9 1130\r
1131void AliAnalysisTaskESDfilter::ConvertGlobalConstrainedTracks(const AliESDEvent& esd)\r
1132{\r
1133\r
1134 // Here we have the option to store the complement from global constraint information\r
1135 // to tracks passing tight cuts (1) in order not to get fakes back in, one needs \r
1136 // two sets of cuts one tight (1) (to throw out fakes) and one lose (2) (fakes/bad tracks would pass (2) but not (1))\r
1137 // using cut number (3) selects the tracks that complement (1) e.g. tracks witout ITS refit or cluster requirement\r
1138\r
1139\r
1140 AliCodeTimerAuto("",0);\r
1141 \r
1142 // Loop over the tracks and extract and mask out all aod tracks that pass the selections for AODt racks\r
1143 for(int it = 0;it < fNumberOfTracks;++it)\r
1144 {\r
1145 AliAODTrack *tr = (AliAODTrack*)(Tracks().At(it));\r
1146 if(!tr)continue;\r
1147 UInt_t map = tr->GetFilterMap();\r
1148 if(map&fGlobalConstrainedFilterMask){\r
1149 // we only reset the track select info, no deletion...\r
1150 // mask reset mask in case track is already taken\r
1151 tr->SetFilterMap(map&~fGlobalConstrainedFilterMask);\r
1152 }\r
1153 if(map&fHybridFilterMaskGCG){\r
1154 // this is one part of the hybrid tracks\r
1155 // the others not passing the selection will be the ones selected below\r
041743e4 1156 tr->SetIsHybridGlobalConstrainedGlobal(kTRUE);\r
67abcce9 1157 }\r
1158 }\r
1159 // Loop over the ESD trcks and pick out the tracks passing the GlobalConstraint cuts\r
1160 \r
1161\r
1162 Double_t pos[3] = { 0. }; \r
1163 Double_t covTr[21]={0.};\r
1164 Double_t pid[10]={0.}; \r
1165 Double_t p[3] = { 0. };\r
1166\r
1167 Double_t pDCA[3] = { 0. }; // momentum at DCA\r
1168 Double_t rDCA[3] = { 0. }; // position at DCA\r
1169 Float_t dDCA[2] = {0.}; // DCA to the vertex d and z\r
1170 Float_t cDCA[3] = {0.}; // covariance of impact parameters\r
1171\r
1172\r
1173 AliAODTrack* aodTrack(0x0);\r
bcab9a54 1174 AliAODPid* detpid(0x0);\r
67abcce9 1175 const AliESDVertex *vtx = esd.GetPrimaryVertex();\r
041743e4 1176\r
1177 // account for change in pT after the constraint\r
1178 Float_t ptMax = 1E10;\r
1179 Float_t ptMin = 0;\r
1180 for(int i = 0;i<32;i++){\r
1181 if(fGlobalConstrainedFilterMask&(1<<i)){\r
1182 AliESDtrackCuts*cuts = (AliESDtrackCuts*)fTrackFilter->GetCuts()->At(i);\r
1183 Float_t tmp1= 0,tmp2 = 0;\r
1184 cuts->GetPtRange(tmp1,tmp2);\r
1185 if(tmp1>ptMin)ptMin=tmp1;\r
1186 if(tmp2<ptMax)ptMax=tmp2;\r
1187 }\r
1188 } \r
1189\r
1190\r
1191\r
1192 for (Int_t nTrack = 0; nTrack < esd.GetNumberOfTracks(); ++nTrack) \r
67abcce9 1193 {\r
1194 AliESDtrack* esdTrack = esd.GetTrack(nTrack); //carefull do not modify it othwise need to work with a copy \r
1195 const AliExternalTrackParam * exParamGC = esdTrack->GetConstrainedParam();\r
1196 if(!exParamGC)continue;\r
1197\r
1198 UInt_t selectInfo = 0;\r
1199 Bool_t isHybridGC = false;\r
1200\r
1201 //\r
1202 // Track selection\r
1203 if (fTrackFilter) {\r
1204 selectInfo = fTrackFilter->IsSelected(esdTrack);\r
1205 }\r
1206\r
1207\r
1208 if(!(selectInfo&fHybridFilterMaskGCG))isHybridGC = true;\r
1209 if (fWriteHybridGCOnly&&!isHybridGC)continue; // write only complementary tracks\r
1210\r
1211 selectInfo &= fGlobalConstrainedFilterMask;\r
1212 if (!selectInfo)continue;\r
1213 // fetch the track parameters at the DCA (unconstrained)\r
1214 esdTrack->GetPxPyPz(pDCA);\r
1215 esdTrack->GetXYZ(rDCA);\r
1216 // get the DCA to the vertex:\r
1217 esdTrack->GetImpactParameters(dDCA,cDCA);\r
1218\r
1219 esdTrack->GetConstrainedPxPyPz(p);\r
041743e4 1220\r
1221\r
1222 Float_t pT = exParamGC->Pt();\r
1223 if(pT<ptMin||pT>ptMax){\r
1224 continue;\r
1225 }\r
1226\r
1227\r
67abcce9 1228 esdTrack->GetConstrainedXYZ(pos);\r
1229 exParamGC->GetCovarianceXYZPxPyPz(covTr);\r
1230 esdTrack->GetESDpid(pid);\r
1231 if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());\r
1232 aodTrack = new(Tracks()[fNumberOfTracks++]) AliAODTrack((esdTrack->GetID()+1)*-1,\r
1233 esdTrack->GetLabel(),\r
1234 p,\r
1235 kTRUE,\r
1236 pos,\r
1237 kFALSE,\r
1238 covTr, \r
1239 (Short_t)esdTrack->GetSign(),\r
1240 esdTrack->GetITSClusterMap(), \r
1241 pid,\r
1242 fPrimaryVertex,\r
1243 kTRUE, // check if this is right\r
1244 vtx->UsesTrack(esdTrack->GetID()),\r
1245 AliAODTrack::kPrimary, \r
1246 selectInfo);\r
041743e4 1247 aodTrack->SetIsHybridGlobalConstrainedGlobal(isHybridGC); \r
1248 aodTrack->SetIsGlobalConstrained(kTRUE); \r
bcabd0e4 1249 aodTrack->SetTPCFitMap(esdTrack->GetTPCFitMap());\r
67abcce9 1250 aodTrack->SetTPCClusterMap(esdTrack->GetTPCClusterMap());\r
1251 aodTrack->SetTPCSharedMap (esdTrack->GetTPCSharedMap());\r
bcab9a54 1252 aodTrack->SetChi2perNDF(Chi2perNDF(esdTrack));\r
1253\r
67abcce9 1254\r
1255 // set the DCA values to the AOD track\r
1256 aodTrack->SetPxPyPzAtDCA(pDCA[0],pDCA[1],pDCA[2]);\r
1257 aodTrack->SetXYAtDCA(rDCA[0],rDCA[1]);\r
1258 aodTrack->SetDCA(dDCA[0],dDCA[1]);\r
1259\r
1260 aodTrack->SetFlags(esdTrack->GetStatus());\r
1261 aodTrack->SetTPCPointsF(esdTrack->GetTPCNclsF());\r
bcab9a54 1262\r
1263 if(isHybridGC){\r
1264 // only copy AOD information for hybrid, no duplicate information\r
1265 aodTrack->ConvertAliPIDtoAODPID();\r
1266 SetAODPID(esdTrack,aodTrack,detpid);\r
1267 }\r
67abcce9 1268 } // end of loop on tracks\r
1269 \r
1270}\r
1271\r
1272\r
c7ef1c47 1273//______________________________________________________________________________\r
1274void AliAnalysisTaskESDfilter::ConvertTracks(const AliESDEvent& esd)\r
1275{\r
1276 // Tracks (primary and orphan)\r
1277\r
1278 AliCodeTimerAuto("",0);\r
1279 \r
1280 AliDebug(1,Form("NUMBER OF ESD TRACKS %5d\n", esd.GetNumberOfTracks()));\r
1281 \r
1282 const AliESDVertex *vtx = esd.GetPrimaryVertex();\r
1283 Double_t p[3] = { 0. };\r
1284 Double_t pos[3] = { 0. };\r
1285 Double_t covTr[21] = { 0. };\r
1286 Double_t pid[10] = { 0. };\r
1287 AliAODTrack* aodTrack(0x0);\r
1288 AliAODPid* detpid(0x0);\r
1289 \r
1290 for (Int_t nTrack = 0; nTrack < esd.GetNumberOfTracks(); ++nTrack) \r
1291 {\r
1292 if (fUsedTrack[nTrack]) continue;\r
1293 \r
1294 AliESDtrack *esdTrack = esd.GetTrack(nTrack);\r
1295 UInt_t selectInfo = 0;\r
1296 //\r
1297 // Track selection\r
1298 if (fTrackFilter) {\r
9eeae5d5 1299 selectInfo = fTrackFilter->IsSelected(esdTrack);\r
f7ed7e88 1300 if (!selectInfo && !vtx->UsesTrack(esdTrack->GetID())) continue;\r
f7ed7e88 1301 }\r
c7ef1c47 1302 \r
1303 \r
1304 esdTrack->GetPxPyPz(p);\r
1305 esdTrack->GetXYZ(pos);\r
1306 esdTrack->GetCovarianceXYZPxPyPz(covTr);\r
1307 esdTrack->GetESDpid(pid);\r
1308 if(fMChandler)fMChandler->SelectParticle(esdTrack->GetLabel());\r
1309 fPrimaryVertex->AddDaughter(aodTrack =\r
1310 new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdTrack->GetID(),\r
1311 esdTrack->GetLabel(),\r
1312 p,\r
1313 kTRUE,\r
1314 pos,\r
1315 kFALSE,\r
1316 covTr, \r
1317 (Short_t)esdTrack->GetSign(),\r
1318 esdTrack->GetITSClusterMap(), \r
1319 pid,\r
1320 fPrimaryVertex,\r
1321 kTRUE, // check if this is right\r
1322 vtx->UsesTrack(esdTrack->GetID()),\r
1323 AliAODTrack::kPrimary, \r
1324 selectInfo)\r
1325 );\r
bcabd0e4 1326 aodTrack->SetTPCFitMap(esdTrack->GetTPCFitMap());\r
c7ef1c47 1327 aodTrack->SetTPCClusterMap(esdTrack->GetTPCClusterMap());\r
1328 aodTrack->SetTPCSharedMap (esdTrack->GetTPCSharedMap());\r
1329 aodTrack->SetChi2perNDF(Chi2perNDF(esdTrack));\r
3c01c166 1330 aodTrack->SetTPCPointsF(esdTrack->GetTPCNclsF());\r
a7d9ab9e 1331 if(esdTrack->IsEMCAL()) aodTrack->SetEMCALcluster(esdTrack->GetEMCALcluster());\r
1332 if(esdTrack->IsPHOS()) aodTrack->SetPHOScluster(esdTrack->GetPHOScluster());\r
3c01c166 1333\r
c7ef1c47 1334 fAODTrackRefs->AddAt(aodTrack, nTrack);\r
1335 \r
1336 \r
1337 if (esdTrack->GetSign() > 0) ++fNumberOfPositiveTracks;\r
1338 aodTrack->SetFlags(esdTrack->GetStatus());\r
1339 aodTrack->ConvertAliPIDtoAODPID();\r
1a3579a6 1340 SetAODPID(esdTrack,aodTrack,detpid);\r
c7ef1c47 1341 } // end of loop on tracks\r
1342}\r
f7ed7e88 1343\r
c7ef1c47 1344//______________________________________________________________________________\r
1345void AliAnalysisTaskESDfilter::ConvertPmdClusters(const AliESDEvent& esd)\r
1346{\r
5204c278 1347// Convert PMD Clusters \r
c7ef1c47 1348 AliCodeTimerAuto("",0);\r
1349 Int_t jPmdClusters=0;\r
1350 // Access to the AOD container of PMD clusters\r
1351 TClonesArray &pmdClusters = *(AODEvent()->GetPmdClusters());\r
1352 for (Int_t iPmd = 0; iPmd < esd.GetNumberOfPmdTracks(); ++iPmd) {\r
1353 // file pmd clusters, to be revised!\r
1354 AliESDPmdTrack *pmdTrack = esd.GetPmdTrack(iPmd);\r
1355 Int_t nLabel = 0;\r
1356 Int_t *label = 0x0;\r
1357 Double_t posPmd[3] = { pmdTrack->GetClusterX(), pmdTrack->GetClusterY(), pmdTrack->GetClusterZ()};\r
1358 Double_t pidPmd[13] = { 0.}; // to be revised!\r
1359 // type not set!\r
1360 // assoc cluster not set\r
1361 new(pmdClusters[jPmdClusters++]) AliAODPmdCluster(iPmd, nLabel, label, pmdTrack->GetClusterADC(), posPmd, pidPmd);\r
1362 }\r
1363}\r
f7ed7e88 1364\r
c7ef1c47 1365//______________________________________________________________________________\r
1366void AliAnalysisTaskESDfilter::ConvertCaloClusters(const AliESDEvent& esd)\r
1367{\r
5204c278 1368// Convert Calorimeter Clusters\r
c7ef1c47 1369 AliCodeTimerAuto("",0);\r
1370 \r
1371 // Access to the AOD container of clusters\r
1372 TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());\r
1373 Int_t jClusters(0);\r
1374 \r
1375 for (Int_t iClust=0; iClust<esd.GetNumberOfCaloClusters(); ++iClust) {\r
1376 \r
1377 AliESDCaloCluster * cluster = esd.GetCaloCluster(iClust);\r
1378 \r
1379 Int_t id = cluster->GetID();\r
1380 Int_t nLabel = cluster->GetNLabels();\r
1381 Int_t *labels = cluster->GetLabels();\r
1382 if(labels){ \r
c8fe2783 1383 for(int i = 0;i < nLabel;++i){\r
c7ef1c47 1384 if(fMChandler)fMChandler->SelectParticle(labels[i]);\r
c8fe2783 1385 }\r
1386 } \r
c7ef1c47 1387 \r
1388 Float_t energy = cluster->E();\r
1389 Float_t posF[3] = { 0.};\r
1390 cluster->GetPosition(posF);\r
1391 \r
1392 AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) AliAODCaloCluster(id,\r
1393 nLabel,\r
1394 labels,\r
1395 energy,\r
1396 posF,\r
1397 NULL,\r
1398 cluster->GetType(),0);\r
1399 \r
1400 caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),\r
1401 cluster->GetDispersion(),\r
1402 cluster->GetM20(), cluster->GetM02(),\r
1403 cluster->GetEmcCpvDistance(), \r
1404 cluster->GetNExMax(),cluster->GetTOF()) ;\r
1405 \r
1406 caloCluster->SetPIDFromESD(cluster->GetPID());\r
1407 caloCluster->SetNCells(cluster->GetNCells());\r
1408 caloCluster->SetCellsAbsId(cluster->GetCellsAbsId());\r
1409 caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction());\r
1410 \r
1411 TArrayI* matchedT = cluster->GetTracksMatched();\r
1412 if (fNumberOfTracks>0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) { \r
1413 for (Int_t im = 0; im < matchedT->GetSize(); im++) {\r
1414 Int_t iESDtrack = matchedT->At(im);;\r
1415 if (fAODTrackRefs->At(iESDtrack) != 0) {\r
1416 caloCluster->AddTrackMatched((AliAODTrack*)fAODTrackRefs->At(iESDtrack));\r
1417 }\r
1418 }\r
1419 }\r
1420 \r
1421 } \r
1422 caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters \r
1423}\r
f7ed7e88 1424\r
c7ef1c47 1425//______________________________________________________________________________\r
1426void AliAnalysisTaskESDfilter::ConvertEMCALCells(const AliESDEvent& esd)\r
1427{\r
5204c278 1428// Convert EMCAL Cells\r
c7ef1c47 1429 AliCodeTimerAuto("",0);\r
1430 // fill EMCAL cell info\r
1431 if (esd.GetEMCALCells()) { // protection against missing ESD information\r
1432 AliESDCaloCells &esdEMcells = *(esd.GetEMCALCells());\r
1433 Int_t nEMcell = esdEMcells.GetNumberOfCells() ;\r
1434 \r
1435 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());\r
1436 aodEMcells.CreateContainer(nEMcell);\r
1437 aodEMcells.SetType(AliAODCaloCells::kEMCALCell);\r
1438 for (Int_t iCell = 0; iCell < nEMcell; iCell++) { \r
1439 aodEMcells.SetCell(iCell,esdEMcells.GetCellNumber(iCell),esdEMcells.GetAmplitude(iCell));\r
1440 }\r
1441 aodEMcells.Sort();\r
1442 }\r
1443}\r
f7ed7e88 1444\r
c7ef1c47 1445//______________________________________________________________________________\r
1446void AliAnalysisTaskESDfilter::ConvertPHOSCells(const AliESDEvent& esd)\r
1447{\r
5204c278 1448// Convert PHOS Cells\r
c7ef1c47 1449 AliCodeTimerAuto("",0);\r
1450 // fill PHOS cell info\r
1451 if (esd.GetPHOSCells()) { // protection against missing ESD information\r
1452 AliESDCaloCells &esdPHcells = *(esd.GetPHOSCells());\r
1453 Int_t nPHcell = esdPHcells.GetNumberOfCells() ;\r
1454 \r
1455 AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells());\r
1456 aodPHcells.CreateContainer(nPHcell);\r
1457 aodPHcells.SetType(AliAODCaloCells::kPHOSCell);\r
1458 for (Int_t iCell = 0; iCell < nPHcell; iCell++) { \r
1459 aodPHcells.SetCell(iCell,esdPHcells.GetCellNumber(iCell),esdPHcells.GetAmplitude(iCell));\r
f7ed7e88 1460 }\r
c7ef1c47 1461 aodPHcells.Sort();\r
1462 }\r
1463}\r
f7ed7e88 1464\r
c7ef1c47 1465//______________________________________________________________________________\r
1466void AliAnalysisTaskESDfilter::ConvertTracklets(const AliESDEvent& esd)\r
1467{\r
1468 // tracklets \r
1469 AliCodeTimerAuto("",0);\r
1470\r
1471 AliAODTracklets &SPDTracklets = *(AODEvent()->GetTracklets());\r
1472 const AliMultiplicity *mult = esd.GetMultiplicity();\r
1473 if (mult) {\r
1474 if (mult->GetNumberOfTracklets()>0) {\r
1475 SPDTracklets.CreateContainer(mult->GetNumberOfTracklets());\r
f7ed7e88 1476 \r
c7ef1c47 1477 for (Int_t n=0; n<mult->GetNumberOfTracklets(); n++) {\r
1478 if(fMChandler){\r
1479 fMChandler->SelectParticle(mult->GetLabel(n, 0));\r
1480 fMChandler->SelectParticle(mult->GetLabel(n, 1));\r
1481 }\r
1482 SPDTracklets.SetTracklet(n, mult->GetTheta(n), mult->GetPhi(n), mult->GetDeltaPhi(n), mult->GetLabel(n, 0),mult->GetLabel(n, 1));\r
f7ed7e88 1483 }\r
f7ed7e88 1484 }\r
c7ef1c47 1485 } else {\r
1486 //Printf("ERROR: AliMultiplicity could not be retrieved from ESD");\r
1487 }\r
1488}\r
f7ed7e88 1489\r
c7ef1c47 1490//______________________________________________________________________________\r
1491void AliAnalysisTaskESDfilter::ConvertKinks(const AliESDEvent& esd)\r
1492{\r
1493 AliCodeTimerAuto("",0);\r
1494 \r
1495 // Kinks: it is a big mess the access to the information in the kinks\r
1496 // The loop is on the tracks in order to find the mother and daugther of each kink\r
1497 \r
1498 Double_t covTr[21]={0.};\r
1499 Double_t pid[10]={0.};\r
1500 AliAODPid* detpid(0x0);\r
1501 \r
1502 fNumberOfKinks = esd.GetNumberOfKinks();\r
1503\r
1504 const AliESDVertex* vtx = esd.GetPrimaryVertex();\r
1505 \r
1506 for (Int_t iTrack=0; iTrack<esd.GetNumberOfTracks(); ++iTrack) \r
1507 {\r
1508 AliESDtrack * esdTrack = esd.GetTrack(iTrack);\r
1509 \r
1510 Int_t ikink = esdTrack->GetKinkIndex(0);\r
1511 \r
1512 if (ikink && fNumberOfKinks) {\r
1513 // Negative kink index: mother, positive: daughter\r
1514 \r
1515 // Search for the second track of the kink\r
1516 \r
1517 for (Int_t jTrack = iTrack+1; jTrack<esd.GetNumberOfTracks(); ++jTrack) {\r
1518 \r
1519 AliESDtrack * esdTrack1 = esd.GetTrack(jTrack);\r
1520 \r
1521 Int_t jkink = esdTrack1->GetKinkIndex(0);\r
1522 \r
1523 if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) {\r
1524 \r
1525 // The two tracks are from the same kink\r
1526 \r
1527 if (fUsedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks\r
1528 \r
1529 Int_t imother = -1;\r
1530 Int_t idaughter = -1;\r
1531 \r
1532 if (ikink<0 && jkink>0) {\r
1533 \r
1534 imother = iTrack;\r
1535 idaughter = jTrack;\r
1536 }\r
1537 else if (ikink>0 && jkink<0) {\r
1538 \r
1539 imother = jTrack;\r
1540 idaughter = iTrack;\r
1541 }\r
1542 else {\r
1543 // cerr << "Error: Wrong combination of kink indexes: "\r
1544 // << ikink << " " << jkink << endl;\r
1545 continue;\r
1546 }\r
1547 \r
1548 // Add the mother track if it passed primary track selection cuts\r
1549 \r
1550 AliAODTrack * mother = NULL;\r
1551 \r
1552 UInt_t selectInfo = 0;\r
1553 if (fTrackFilter) {\r
1554 selectInfo = fTrackFilter->IsSelected(esd.GetTrack(imother));\r
1555 if (!selectInfo) continue;\r
1556 }\r
1557 \r
1558 if (!fUsedTrack[imother]) {\r
1559 \r
1560 fUsedTrack[imother] = kTRUE;\r
1561 \r
1562 AliESDtrack *esdTrackM = esd.GetTrack(imother);\r
1563 Double_t p[3] = { 0. };\r
1564 Double_t pos[3] = { 0. };\r
1565 esdTrackM->GetPxPyPz(p);\r
1566 esdTrackM->GetXYZ(pos);\r
1567 esdTrackM->GetCovarianceXYZPxPyPz(covTr);\r
1568 esdTrackM->GetESDpid(pid);\r
1569 if(fMChandler)fMChandler->SelectParticle(esdTrackM->GetLabel());\r
1570 mother = \r
1571 new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdTrackM->GetID(),\r
1572 esdTrackM->GetLabel(),\r
1573 p,\r
1574 kTRUE,\r
1575 pos,\r
1576 kFALSE,\r
1577 covTr, \r
1578 (Short_t)esdTrackM->GetSign(),\r
1579 esdTrackM->GetITSClusterMap(), \r
1580 pid,\r
1581 fPrimaryVertex,\r
1582 kTRUE, // check if this is right\r
1583 vtx->UsesTrack(esdTrack->GetID()),\r
1584 AliAODTrack::kPrimary,\r
1585 selectInfo);\r
bcabd0e4 1586 mother->SetTPCFitMap(esdTrackM->GetTPCFitMap());\r
c7ef1c47 1587 mother->SetTPCClusterMap(esdTrackM->GetTPCClusterMap());\r
1588 mother->SetTPCSharedMap (esdTrackM->GetTPCSharedMap());\r
1589 mother->SetChi2perNDF(Chi2perNDF(esdTrackM));\r
3c01c166 1590 mother->SetTPCPointsF(esdTrackM->GetTPCNclsF());\r
1591\r
c7ef1c47 1592 fAODTrackRefs->AddAt(mother, imother);\r
1593 \r
1594 if (esdTrackM->GetSign() > 0) ++fNumberOfPositiveTracks;\r
1595 mother->SetFlags(esdTrackM->GetStatus());\r
1596 mother->ConvertAliPIDtoAODPID();\r
1597 fPrimaryVertex->AddDaughter(mother);\r
1598 mother->ConvertAliPIDtoAODPID();\r
1a3579a6 1599 SetAODPID(esdTrackM,mother,detpid);\r
c7ef1c47 1600 }\r
1601 else {\r
1602 // cerr << "Error: event " << esd.GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1\r
1603 // << " track " << imother << " has already been used!" << endl;\r
1604 }\r
1605 \r
1606 // Add the kink vertex\r
1607 AliESDkink * kink = esd.GetKink(TMath::Abs(ikink)-1);\r
1608 \r
1609 AliAODVertex * vkink = \r
1610 new(Vertices()[fNumberOfVertices++]) AliAODVertex(kink->GetPosition(),\r
1611 NULL,\r
1612 0.,\r
1613 mother,\r
1614 esdTrack->GetID(), // This is the track ID of the mother's track!\r
1615 AliAODVertex::kKink);\r
1616 // Add the daughter track\r
1617 \r
1618 AliAODTrack * daughter = NULL;\r
1619 \r
1620 if (!fUsedTrack[idaughter]) {\r
1621 \r
1622 fUsedTrack[idaughter] = kTRUE;\r
1623 \r
1624 AliESDtrack *esdTrackD = esd.GetTrack(idaughter);\r
1625 Double_t p[3] = { 0. };\r
1626 Double_t pos[3] = { 0. };\r
1627\r
1628 esdTrackD->GetPxPyPz(p);\r
1629 esdTrackD->GetXYZ(pos);\r
1630 esdTrackD->GetCovarianceXYZPxPyPz(covTr);\r
1631 esdTrackD->GetESDpid(pid);\r
1632 selectInfo = 0;\r
1633 if (fTrackFilter) selectInfo = fTrackFilter->IsSelected(esdTrackD);\r
1634 if(fMChandler)fMChandler->SelectParticle(esdTrackD->GetLabel());\r
1635 daughter = \r
1636 new(Tracks()[fNumberOfTracks++]) AliAODTrack(esdTrackD->GetID(),\r
1637 esdTrackD->GetLabel(),\r
1638 p,\r
1639 kTRUE,\r
1640 pos,\r
1641 kFALSE,\r
1642 covTr, \r
1643 (Short_t)esdTrackD->GetSign(),\r
1644 esdTrackD->GetITSClusterMap(), \r
1645 pid,\r
1646 vkink,\r
1647 kTRUE, // check if this is right\r
1648 vtx->UsesTrack(esdTrack->GetID()),\r
1649 AliAODTrack::kSecondary,\r
1650 selectInfo);\r
bcabd0e4 1651 daughter->SetTPCFitMap(esdTrackD->GetTPCFitMap());\r
c7ef1c47 1652 daughter->SetTPCClusterMap(esdTrackD->GetTPCClusterMap());\r
1653 daughter->SetTPCSharedMap (esdTrackD->GetTPCSharedMap());\r
3c01c166 1654 daughter->SetTPCPointsF(esdTrackD->GetTPCNclsF());\r
c7ef1c47 1655 fAODTrackRefs->AddAt(daughter, idaughter);\r
1656 \r
1657 if (esdTrackD->GetSign() > 0) ++fNumberOfPositiveTracks;\r
1658 daughter->SetFlags(esdTrackD->GetStatus());\r
1659 daughter->ConvertAliPIDtoAODPID();\r
1660 vkink->AddDaughter(daughter);\r
1661 daughter->ConvertAliPIDtoAODPID();\r
1a3579a6 1662 SetAODPID(esdTrackD,daughter,detpid);\r
c7ef1c47 1663 }\r
1664 else {\r
1665 // cerr << "Error: event " << esd.GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1\r
1666 // << " track " << idaughter << " has already been used!" << endl;\r
1667 }\r
1668 }\r
1669 }\r
1670 } \r
1671 }\r
1672}\r
1673\r
1674//______________________________________________________________________________\r
1675void AliAnalysisTaskESDfilter::ConvertPrimaryVertices(const AliESDEvent& esd)\r
1676{\r
1677 AliCodeTimerAuto("",0);\r
1678 \r
1679 // Access to the AOD container of vertices\r
1680 fNumberOfVertices = 0;\r
1681 \r
1682 Double_t pos[3] = { 0. };\r
1683 Double_t covVtx[6] = { 0. };\r
f7ed7e88 1684\r
c7ef1c47 1685 // Add primary vertex. The primary tracks will be defined\r
1686 // after the loops on the composite objects (V0, cascades, kinks)\r
1687 const AliESDVertex *vtx = esd.GetPrimaryVertex();\r
1688 \r
1689 vtx->GetXYZ(pos); // position\r
1690 vtx->GetCovMatrix(covVtx); //covariance matrix\r
1691 \r
1692 fPrimaryVertex = new(Vertices()[fNumberOfVertices++])\r
1693 AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, -1, AliAODVertex::kPrimary);\r
1694 fPrimaryVertex->SetName(vtx->GetName());\r
1695 fPrimaryVertex->SetTitle(vtx->GetTitle());\r
1696 \r
1697 TString vtitle = vtx->GetTitle();\r
1698 if (!vtitle.Contains("VertexerTracks")) \r
1699 fPrimaryVertex->SetNContributors(vtx->GetNContributors());\r
1700 \r
1701 if (fDebug > 0) fPrimaryVertex->Print(); \r
1702 \r
1703 // Add SPD "main" vertex \r
1704 const AliESDVertex *vtxS = esd.GetPrimaryVertexSPD();\r
1705 vtxS->GetXYZ(pos); // position\r
1706 vtxS->GetCovMatrix(covVtx); //covariance matrix\r
1707 AliAODVertex * mVSPD = new(Vertices()[fNumberOfVertices++])\r
1708 AliAODVertex(pos, covVtx, vtxS->GetChi2toNDF(), NULL, -1, AliAODVertex::kMainSPD);\r
1709 mVSPD->SetName(vtxS->GetName());\r
1710 mVSPD->SetTitle(vtxS->GetTitle());\r
1711 mVSPD->SetNContributors(vtxS->GetNContributors()); \r
1712 \r
1713 // Add SPD pileup vertices\r
1714 for(Int_t iV=0; iV<esd.GetNumberOfPileupVerticesSPD(); ++iV)\r
1715 {\r
1716 const AliESDVertex *vtxP = esd.GetPileupVertexSPD(iV);\r
1717 vtxP->GetXYZ(pos); // position\r
1718 vtxP->GetCovMatrix(covVtx); //covariance matrix\r
1719 AliAODVertex * pVSPD = new(Vertices()[fNumberOfVertices++])\r
1720 AliAODVertex(pos, covVtx, vtxP->GetChi2toNDF(), NULL, -1, AliAODVertex::kPileupSPD);\r
1721 pVSPD->SetName(vtxP->GetName());\r
1722 pVSPD->SetTitle(vtxP->GetTitle());\r
1723 pVSPD->SetNContributors(vtxP->GetNContributors()); \r
0249e9b8 1724 pVSPD->SetBC(vtxP->GetBC());\r
c7ef1c47 1725 }\r
1726 \r
1727 // Add TRK pileup vertices\r
1728 for(Int_t iV=0; iV<esd.GetNumberOfPileupVerticesTracks(); ++iV)\r
1729 {\r
1730 const AliESDVertex *vtxP = esd.GetPileupVertexTracks(iV);\r
1731 vtxP->GetXYZ(pos); // position\r
1732 vtxP->GetCovMatrix(covVtx); //covariance matrix\r
1733 AliAODVertex * pVTRK = new(Vertices()[fNumberOfVertices++])\r
1734 AliAODVertex(pos, covVtx, vtxP->GetChi2toNDF(), NULL, -1, AliAODVertex::kPileupTracks);\r
1735 pVTRK->SetName(vtxP->GetName());\r
1736 pVTRK->SetTitle(vtxP->GetTitle());\r
1737 pVTRK->SetNContributors(vtxP->GetNContributors());\r
0249e9b8 1738 pVTRK->SetBC(vtxP->GetBC());\r
c7ef1c47 1739 }\r
f7ed7e88 1740}\r
1741\r
c7ef1c47 1742//______________________________________________________________________________\r
1743void AliAnalysisTaskESDfilter::ConvertVZERO(const AliESDEvent& esd)\r
1744{\r
1745 // Convert VZERO data\r
1746 AliAODVZERO* vzeroData = AODEvent()->GetVZEROData();\r
1747 *vzeroData = *(esd.GetVZEROData());\r
1748}\r
f7ed7e88 1749\r
a1f96974 1750//______________________________________________________________________________\r
1751void AliAnalysisTaskESDfilter::ConvertTZERO(const AliESDEvent& esd)\r
1752{\r
1753 // Convert TZERO data\r
1754 const AliESDTZERO* esdTzero = esd.GetESDTZERO(); \r
1755 AliAODTZERO* aodTzero = AODEvent()->GetTZEROData();\r
1756\r
1757 for (Int_t icase=0; icase<3; icase++){ \r
1758 aodTzero->SetT0TOF( icase, esdTzero->GetT0TOF(icase));\r
1759 aodTzero->SetT0TOFbest(icase, esdTzero->GetT0TOFbest(icase)); \r
1760 }\r
1761 aodTzero->SetBackgroundFlag(esdTzero->GetBackgroundFlag());\r
1762 aodTzero->SetPileupFlag(esdTzero->GetPileupFlag());\r
1763 aodTzero->SetSatelliteFlag(esdTzero->GetSatellite()); \r
1764\r
1765}\r
1766\r
1767\r
8c87d22c 1768//______________________________________________________________________________\r
1769void AliAnalysisTaskESDfilter::ConvertZDC(const AliESDEvent& esd)\r
1770{\r
1771 // Convert ZDC data\r
1772 AliESDZDC* esdZDC = esd.GetZDCData();\r
1773 \r
1774 const Double_t zem1Energy = esdZDC->GetZEM1Energy();\r
1775 const Double_t zem2Energy = esdZDC->GetZEM2Energy();\r
1776 \r
1777 const Double_t *towZNC = esdZDC->GetZNCTowerEnergy();\r
1778 const Double_t *towZPC = esdZDC->GetZPCTowerEnergy();\r
1779 const Double_t *towZNA = esdZDC->GetZNATowerEnergy();\r
1780 const Double_t *towZPA = esdZDC->GetZPATowerEnergy();\r
1781 const Double_t *towZNCLG = esdZDC->GetZNCTowerEnergyLR();\r
1782 const Double_t *towZNALG = esdZDC->GetZNATowerEnergyLR();\r
1783 \r
1784 AliAODZDC* zdcAOD = AODEvent()->GetZDCData();\r
1785\r
1786 zdcAOD->SetZEM1Energy(zem1Energy);\r
1787 zdcAOD->SetZEM2Energy(zem2Energy);\r
1788 zdcAOD->SetZNCTowers(towZNC, towZNCLG);\r
1789 zdcAOD->SetZNATowers(towZNA, towZNALG);\r
1790 zdcAOD->SetZPCTowers(towZPC);\r
1791 zdcAOD->SetZPATowers(towZPA);\r
1792 \r
1793 zdcAOD->SetZDCParticipants(esdZDC->GetZDCParticipants(), esdZDC->GetZDCPartSideA(), esdZDC->GetZDCPartSideC());\r
1794 zdcAOD->SetZDCImpactParameter(esdZDC->GetImpactParameter(), esdZDC->GetImpactParamSideA(), \r
1795 esdZDC->GetImpactParamSideC());\r
1796 zdcAOD->SetZDCTDCSum(esdZDC->GetZNTDCSum(0)); \r
1797 zdcAOD->SetZDCTDCDiff(esdZDC->GetZNTDCDiff(0)); \r
1798\r
1799}\r
1800\r
c7ef1c47 1801//______________________________________________________________________________\r
1802void AliAnalysisTaskESDfilter::ConvertESDtoAOD() \r
1803{\r
1804 // ESD Filter analysis task executed for each event\r
1805 \r
1806 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());\r
1807 \r
1808 if(!esd)return;\r
1809\r
1810 AliCodeTimerAuto("",0);\r
1811 \r
1812 fOldESDformat = ( esd->GetAliESDOld() != 0x0 );\r
1813 \r
1814 fNumberOfTracks = 0;\r
1815 fNumberOfPositiveTracks = 0;\r
1816 fNumberOfV0s = 0;\r
1817 fNumberOfVertices = 0;\r
1818 fNumberOfCascades = 0;\r
1819 fNumberOfKinks = 0;\r
1820 \r
1821 AliAODHeader* header = ConvertHeader(*esd);\r
1822\r
1823 if ( fIsVZEROEnabled ) ConvertVZERO(*esd);\r
a1f96974 1824 if ( fIsTZEROEnabled ) ConvertTZERO(*esd);\r
c7ef1c47 1825 \r
1826 // Fetch Stack for debuggging if available \r
1827 fMChandler=0x0;\r
1828 if(MCEvent())\r
1829 {\r
1830 fMChandler = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); \r
1831 }\r
1832 \r
1833 // loop over events and fill them\r
1834 // Multiplicity information needed by the header (to be revised!)\r
1835 Int_t nTracks = esd->GetNumberOfTracks();\r
1836 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) esd->GetTrack(iTrack)->SetESDEvent(esd);\r
1837\r
1838 // Update the header\r
1839\r
1840 Int_t nV0s = esd->GetNumberOfV0s();\r
1841 Int_t nCascades = esd->GetNumberOfCascades();\r
1842 Int_t nKinks = esd->GetNumberOfKinks();\r
1843 Int_t nVertices = nV0s + nCascades /*V0 wihtin cascade already counted*/+ nKinks + 1 /* = prim. vtx*/;\r
1844 Int_t nPileSPDVertices=1+esd->GetNumberOfPileupVerticesSPD(); // also SPD main vertex\r
1845 Int_t nPileTrkVertices=esd->GetNumberOfPileupVerticesTracks();\r
1846 nVertices+=nPileSPDVertices;\r
1847 nVertices+=nPileTrkVertices;\r
1848 Int_t nJets = 0;\r
1849 Int_t nCaloClus = esd->GetNumberOfCaloClusters();\r
1850 Int_t nFmdClus = 0;\r
1851 Int_t nPmdClus = esd->GetNumberOfPmdTracks();\r
1852 \r
1853 AliDebug(1,Form(" NV0=%d NCASCADES=%d NKINKS=%d", nV0s, nCascades, nKinks));\r
1854 \r
1855 AODEvent()->ResetStd(nTracks, nVertices, nV0s, nCascades, nJets, nCaloClus, nFmdClus, nPmdClus);\r
1856\r
1857 if (nV0s > 0) \r
1858 {\r
1859 // RefArray to store a mapping between esd V0 number and newly created AOD-Vertex V0\r
1860 fAODV0VtxRefs = new TRefArray(nV0s);\r
1861 // RefArray to store the mapping between esd V0 number and newly created AOD-V0\r
1862 fAODV0Refs = new TRefArray(nV0s); \r
1863 // Array to take into account the V0s already added to the AOD (V0 within cascades)\r
1864 fUsedV0 = new Bool_t[nV0s];\r
1865 for (Int_t iV0=0; iV0<nV0s; ++iV0) fUsedV0[iV0]=kFALSE;\r
1866 }\r
1867 \r
1868 if (nTracks>0) \r
1869 {\r
1870 // RefArray to store the mapping between esd track number and newly created AOD-Track\r
1871 \r
1872 fAODTrackRefs = new TRefArray(nTracks);\r
1873\r
1874 // Array to take into account the tracks already added to the AOD \r
1875 fUsedTrack = new Bool_t[nTracks];\r
1876 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) fUsedTrack[iTrack]=kFALSE;\r
1877 }\r
1878 \r
1879 // Array to take into account the kinks already added to the AOD\r
1880 if (nKinks>0) \r
1881 {\r
1882 fUsedKink = new Bool_t[nKinks];\r
1883 for (Int_t iKink=0; iKink<nKinks; ++iKink) fUsedKink[iKink]=kFALSE;\r
1884 }\r
1885 \r
1886 ConvertPrimaryVertices(*esd);\r
1887\r
1888 //setting best TOF PID\r
39d6c296 1889 AliESDInputHandler* esdH = dynamic_cast<AliESDInputHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
1890 if (esdH)\r
1891 fESDpid = esdH->GetESDpid();\r
c7ef1c47 1892\r
39d6c296 1893 if (fIsPidOwner && fESDpid){\r
75a996ab 1894 delete fESDpid;\r
1895 fESDpid = 0;\r
1896 }\r
c7ef1c47 1897 if(!fESDpid)\r
1898 { //in case of no Tender attached \r
1899 fESDpid = new AliESDpid;\r
1900 fIsPidOwner = kTRUE;\r
1901 }\r
1902 \r
1903 if(!esd->GetTOFHeader())\r
1904 { //protection in case the pass2 LHC10b,c,d have been processed without tender. \r
1905 Float_t t0spread[10];\r
1906 Float_t intrinsicTOFres=100; //ps ok for LHC10b,c,d pass2!! \r
1907 for (Int_t i=0; i<10; i++) t0spread[i] = (TMath::Sqrt(esd->GetSigma2DiamondZ()))/0.03; //0.03 to convert from cm to ps\r
1908 fESDpid->GetTOFResponse().SetT0resolution(t0spread);\r
1909 fESDpid->GetTOFResponse().SetTimeResolution(intrinsicTOFres);\r
1910 \r
1911 fESDpid->SetTOFResponse(esd, (AliESDpid::EStartTimeType_t)fTimeZeroType); \r
1912 }\r
1913 \r
1914 if(esd->GetTOFHeader() && fIsPidOwner) fESDpid->SetTOFResponse(esd, (AliESDpid::EStartTimeType_t)fTimeZeroType); //in case of AOD production strating form LHC10e without Tender. \r
1915 \r
1916 if ( fAreCascadesEnabled ) ConvertCascades(*esd);\r
1917\r
1918 if ( fAreV0sEnabled ) ConvertV0s(*esd);\r
1919 \r
1920 if ( fAreKinksEnabled ) ConvertKinks(*esd);\r
1921 \r
1922 if ( fAreTracksEnabled ) ConvertTracks(*esd);\r
1923 \r
1924 // Update number of AOD tracks in header at the end of track loop (M.G.)\r
1925 header->SetRefMultiplicity(fNumberOfTracks);\r
1926 header->SetRefMultiplicityPos(fNumberOfPositiveTracks);\r
1927 header->SetRefMultiplicityNeg(fNumberOfTracks - fNumberOfPositiveTracks);\r
1928\r
67abcce9 1929 if ( fTPCConstrainedFilterMask ) ConvertTPCOnlyTracks(*esd);\r
1930 if( fGlobalConstrainedFilterMask) ConvertGlobalConstrainedTracks(*esd); \r
1931\r
c7ef1c47 1932 if ( fArePmdClustersEnabled ) ConvertPmdClusters(*esd);\r
1933 \r
1934 if ( fAreCaloClustersEnabled ) ConvertCaloClusters(*esd);\r
1935 \r
1936 if ( fAreEMCALCellsEnabled )ConvertEMCALCells(*esd);\r
1937 \r
1938 if ( fArePHOSCellsEnabled )ConvertPHOSCells(*esd);\r
1939 \r
1940 if ( fAreTrackletsEnabled ) ConvertTracklets(*esd);\r
1941 \r
1942 delete fAODTrackRefs; fAODTrackRefs=0x0;\r
1943 delete fAODV0VtxRefs; fAODV0VtxRefs=0x0;\r
1944 delete fAODV0Refs; fAODV0Refs=0x0;\r
1945 \r
1946 delete[] fUsedTrack; fUsedTrack=0x0;\r
1947 delete[] fUsedV0; fUsedV0=0x0;\r
1948 delete[] fUsedKink; fUsedKink=0x0;\r
67456c92 1949\r
1950 if ( fIsPidOwner){\r
1951 delete fESDpid;\r
1952 fESDpid = 0x0;\r
1953 }\r
1954\r
1955\r
c7ef1c47 1956}\r
1957\r
1958\r
1959//______________________________________________________________________________\r
1a3579a6 1960void AliAnalysisTaskESDfilter::SetAODPID(AliESDtrack *esdtrack, AliAODTrack *aodtrack, AliAODPid *detpid)\r
f7ed7e88 1961{\r
1962 //\r
1963 // Setter for the raw PID detector signals\r
1964 //\r
1965\r
1966 // Save PID object for candidate electrons\r
1967 Bool_t pidSave = kFALSE;\r
1968 if (fTrackFilter) {\r
0c6c629b 1969 Bool_t selectInfo = fTrackFilter->IsSelected((char*) "Electrons");\r
f7ed7e88 1970 if (selectInfo) pidSave = kTRUE;\r
1971 }\r
1972\r
1973\r
1974 // Tracks passing pt cut \r
1975 if(esdtrack->Pt()>fHighPthreshold) {\r
1976 pidSave = kTRUE;\r
1977 } else {\r
1978 if(fPtshape){\r
1979 if(esdtrack->Pt()> fPtshape->GetXmin()){\r
1980 Double_t y = fPtshape->Eval(esdtrack->Pt())/fPtshape->Eval(fHighPthreshold);\r
1981 if(gRandom->Rndm(0)<1./y){\r
1982 pidSave = kTRUE;\r
1983 }//end rndm\r
1984 }//end if p < pmin\r
1985 }//end if p function\r
1986 }// end else\r
1987\r
1988 if (pidSave) {\r
6ece2430 1989 if(!aodtrack->GetDetPid()){// prevent memory leak when calling SetAODPID twice for the same track\r
f7ed7e88 1990 detpid = new AliAODPid();\r
1a3579a6 1991 SetDetectorRawSignals(detpid,esdtrack);\r
f7ed7e88 1992 aodtrack->SetDetPID(detpid);\r
6ece2430 1993 }\r
f7ed7e88 1994 }\r
1995}\r
1996\r
c7ef1c47 1997//______________________________________________________________________________\r
1a3579a6 1998void AliAnalysisTaskESDfilter::SetDetectorRawSignals(AliAODPid *aodpid, AliESDtrack *track)\r
f7ed7e88 1999{\r
2000//\r
2001//assignment of the detector signals (AliXXXesdPID inspired)\r
2002//\r
2003 if(!track){\r
2004 AliInfo("no ESD track found. .....exiting");\r
2005 return;\r
2006 }\r
febefa51 2007 // TPC momentum\r
2008 const AliExternalTrackParam *in=track->GetInnerParam();\r
2009 if (in) {\r
2010 aodpid->SetTPCmomentum(in->GetP());\r
2011 }else{\r
2012 aodpid->SetTPCmomentum(-1.);\r
2013 }\r
2014\r
f7ed7e88 2015\r
2016 aodpid->SetITSsignal(track->GetITSsignal());\r
6d354ed1 2017 Double_t itsdedx[4]; // dE/dx samples for individual ITS layers\r
2018 track->GetITSdEdxSamples(itsdedx);\r
2019 aodpid->SetITSdEdxSamples(itsdedx);\r
2020\r
f7ed7e88 2021 aodpid->SetTPCsignal(track->GetTPCsignal());\r
597b16d8 2022 aodpid->SetTPCsignalN(track->GetTPCsignalN());\r
f7ed7e88 2023\r
febefa51 2024 //n TRD planes = 6\r
f7ed7e88 2025 Int_t nslices = track->GetNumberOfTRDslices()*6;\r
59a8e853 2026 TArrayD trdslices(nslices);\r
f7ed7e88 2027 for(Int_t iSl =0; iSl < track->GetNumberOfTRDslices(); iSl++) {\r
febefa51 2028 for(Int_t iPl =0; iPl<6; iPl++) trdslices[iPl*track->GetNumberOfTRDslices()+iSl] = track->GetTRDslice(iPl,iSl);\r
2029 }\r
2030 \r
2031//TRD momentum\r
2032 for(Int_t iPl=0;iPl<6;iPl++){\r
2033 Double_t trdmom=track->GetTRDmomentum(iPl);\r
2034 aodpid->SetTRDmomentum(iPl,trdmom);\r
2035 }\r
f7ed7e88 2036\r
59a8e853 2037 aodpid->SetTRDsignal(track->GetNumberOfTRDslices()*6,trdslices.GetArray());\r
b13bcc35 2038\r
59a8e853 2039 //TRD clusters and tracklets\r
2040 aodpid->SetTRDncls(track->GetTRDncls());\r
2041 aodpid->SetTRDntrackletsPID(track->GetTRDntrackletsPID());\r
2042 \r
b13bcc35 2043 //TOF PID \r
f7ed7e88 2044 Double_t times[AliAODPid::kSPECIES]; track->GetIntegratedTimes(times);\r
2045 aodpid->SetIntegratedTimes(times);\r
2046\r
c7ef1c47 2047 Float_t tzeroTrack = fESDpid->GetTOFResponse().GetStartTime(track->P());\r
2048 aodpid->SetTOFsignal(track->GetTOFsignal()-tzeroTrack);\r
2049 \r
2050 Double_t tofRes[5];\r
2051 for (Int_t iMass=0; iMass<5; iMass++){\r
2052 tofRes[iMass]=(Double_t)fESDpid->GetTOFResponse().GetExpectedSigma(track->P(), times[iMass], AliPID::ParticleMass(iMass));\r
2053 }\r
2054 aodpid->SetTOFpidResolution(tofRes);\r
2055\r
2056 aodpid->SetHMPIDsignal(track->GetHMPIDsignal());\r
f7ed7e88 2057\r
2058 //Extrapolate track to EMCAL surface for AOD-level track-cluster matching\r
2059 Double_t emcpos[3] = {0.,0.,0.};\r
2060 Double_t emcmom[3] = {0.,0.,0.};\r
2061 aodpid->SetEMCALPosition(emcpos);\r
2062 aodpid->SetEMCALMomentum(emcmom);\r
2063\r
028c7a2c 2064 Double_t hmpPid[5] = {0};\r
2065 track->GetHMPIDpid(hmpPid);\r
2066 aodpid->SetHMPIDprobs(hmpPid);\r
2067\r
f7ed7e88 2068 AliExternalTrackParam *outerparam = (AliExternalTrackParam*)track->GetOuterParam();\r
2069 if(!outerparam) return;\r
2070\r
2071 //To be replaced by call to AliEMCALGeoUtils when the class becomes available\r
1a3579a6 2072 Bool_t okpos = outerparam->GetXYZ(emcpos);\r
2073 Bool_t okmom = outerparam->GetPxPyPz(emcmom);\r
f7ed7e88 2074 if(!(okpos && okmom)) return;\r
2075\r
2076 aodpid->SetEMCALPosition(emcpos);\r
2077 aodpid->SetEMCALMomentum(emcmom);\r
2078\r
2079}\r
2080\r
40a060e5 2081Double_t AliAnalysisTaskESDfilter::Chi2perNDF(AliESDtrack* track)\r
2082{\r
2083 // Calculate chi2 per ndf for track\r
2084 Int_t nClustersTPC = track->GetTPCNcls();\r
2085\r
2086 if ( nClustersTPC > 5) {\r
762fdfb5 2087 return (track->GetTPCchi2()/Float_t(nClustersTPC - 5));\r
40a060e5 2088 } else {\r
2089 return (-1.);\r
2090 }\r
2091 }\r
2092\r
2093\r
c7ef1c47 2094//______________________________________________________________________________\r
f7ed7e88 2095void AliAnalysisTaskESDfilter::Terminate(Option_t */*option*/)\r
2096{\r
2097// Terminate analysis\r
2098//\r
2099 if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");\r
2100}\r
2101\r
c7ef1c47 2102//______________________________________________________________________________\r
f7ed7e88 2103void AliAnalysisTaskESDfilter::PrintMCInfo(AliStack *pStack,Int_t label){\r
f690bf48 2104// Print MC info\r
f7ed7e88 2105 if(!pStack)return;\r
2106 label = TMath::Abs(label);\r
2107 TParticle *part = pStack->Particle(label);\r
2108 Printf("########################");\r
2109 Printf("%s:%d %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,label,part->GetUniqueID(),part->GetPdgCode(),part->P());\r
2110 part->Print();\r
2111 TParticle* mother = part;\r
2112 Int_t imo = part->GetFirstMother();\r
2113 Int_t nprim = pStack->GetNprimary();\r
2114 // while((imo >= nprim) && (mother->GetUniqueID() == 4)) {\r
2115 while((imo >= nprim)) {\r
2116 mother = pStack->Particle(imo);\r
2117 Printf("Mother %s:%d Label %d UniqueID %d PDG %d P %3.3f",(char*)__FILE__,__LINE__,imo,mother->GetUniqueID(),mother->GetPdgCode(),mother->P());\r
2118 mother->Print();\r
2119 imo = mother->GetFirstMother();\r
2120 }\r
2121 Printf("########################");\r
2122}\r