]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FEMTOSCOPYAOD/AliAnalysisTaskPWG2ESDfilter.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPYAOD / AliAnalysisTaskPWG2ESDfilter.cxx
CommitLineData
f9228736 1//-------------------------------------------------------------------------
2// Task for the Analysis Framework
3// Creates a PWG2 specific AOD, from the ESD adding information required
4// for PWG2 analysis.
5// - Puts the per-track information into the AliPWG2AODTrack container,
6// together with the link to the original AliAODTrack
7//
8// Author: Adam Kisiel, OSU, Adam.Kisiel@cern.ch
9//-------------------------------------------------------------------------
10#include <TChain.h>
11#include <TFile.h>
12#include <TList.h>
13
14#include "AliAnalysisTaskPWG2ESDfilter.h"
15#include "AliAnalysisManager.h"
16#include "AliESDEvent.h"
17#include "AliAODEvent.h"
18#include "AliESDInputHandler.h"
19#include "AliAODHandler.h"
20#include "AliAnalysisFilter.h"
21#include "AliESDtrack.h"
22#include "AliESDMuonTrack.h"
23#include "AliESDVertex.h"
24#include "AliESDv0.h"
25#include "AliESDkink.h"
26#include "AliESDcascade.h"
27#include "AliLog.h"
28#include "AliPWG2AODTrack.h"
29
30ClassImp(AliAnalysisTaskPWG2ESDfilter)
31
32////////////////////////////////////////////////////////////////////////
33
34AliAnalysisTaskPWG2ESDfilter::AliAnalysisTaskPWG2ESDfilter():
35 fDebug(0),
36 fTree(0x0),
37 fESD(0x0),
38 fAOD(0x0),
39 fTreeA(0x0),
40 fTrackFilter(0x0),
41 fKinkFilter(0x0),
42 fV0Filter(0x0),
43 fPWG2AODTracks(0x0)
44{
45 // Default constructor
46}
47
48AliAnalysisTaskPWG2ESDfilter::AliAnalysisTaskPWG2ESDfilter(const char* name):
49 AliAnalysisTask(name, "AnalysisTaskESDfilter"),
50 fDebug(0),
51 fTree(0x0),
52 fESD(0x0),
53 fAOD(0x0),
54 fTreeA(0x0),
55 fTrackFilter(0x0),
56 fKinkFilter(0x0),
57 fV0Filter(0x0),
58 fPWG2AODTracks(0x0)
59{
60 // Default constructor
61 DefineInput (0, TChain::Class());
62 DefineOutput(0, TTree::Class());
63}
64
65AliAnalysisTaskPWG2ESDfilter::AliAnalysisTaskPWG2ESDfilter(const AliAnalysisTaskPWG2ESDfilter &task):
66 AliAnalysisTask(),
67 fDebug(0),
68 fTree(0x0),
69 fESD(0x0),
70 fAOD(0x0),
71 fTreeA(0x0),
72 fTrackFilter(0x0),
73 fKinkFilter(0x0),
74 fV0Filter(0x0),
75 fPWG2AODTracks(0x0)
76{
77 // Copy
78 fDebug = task.fDebug;
79 fTree = task.fTree;
80 fESD = task.fESD;
81 fAOD = task.fAOD;
82 fTreeA = task.fTreeA;
83 fTrackFilter = task.fTrackFilter;
84 fKinkFilter = task.fKinkFilter;
85 fV0Filter = task.fV0Filter;
86 fPWG2AODTracks = task.fPWG2AODTracks;
87}
88
89AliAnalysisTaskPWG2ESDfilter& AliAnalysisTaskPWG2ESDfilter::operator=(const AliAnalysisTaskPWG2ESDfilter &task)
90{
91 // Assignment
92 if (&task == this) return *this;
93 TTask::operator=(task);
94
95 fDebug = task.fDebug;
96 fTree = task.fTree;
97 fESD = task.fESD;
98 fAOD = task.fAOD;
99 fTreeA = task.fTreeA;
100 fTrackFilter = task.fTrackFilter;
101 fKinkFilter = task.fKinkFilter;
102 fV0Filter = task.fV0Filter;
103 fPWG2AODTracks = task.fPWG2AODTracks;
104
105 return *this;
106}
107
108void AliAnalysisTaskPWG2ESDfilter::CreateOutputObjects()
109{
110// Create the output container
111 if (fDebug > 1) AliInfo("CreateOutPutData() \n");
112 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
113
114 fAOD = handler->GetAOD();
115 fTreeA = handler->GetTree();
116 fTreeA->GetUserInfo()->Add(fTrackFilter);
117
118 // *** PWG2 specific ***
119
120 fPWG2AODTracks = new TClonesArray("AliPWG2AODTrack", 0);
121 const char *name = "pwg2aodtracks";
122 fPWG2AODTracks->SetName(name);
123
124 fAOD->AddObject(fPWG2AODTracks);
125
126 // TBranch *newBranch = fTreeA->Branch(name, &fPWG2AODTracks);
127 fTreeA->Branch(name, &fPWG2AODTracks);
128 fTreeA->GetUserInfo()->Add(fPWG2AODTracks);
129
130 // --- END PWG2 specific ---
131}
132
133void AliAnalysisTaskPWG2ESDfilter::Init()
134{
135 // Initialization
136 if (fDebug > 1) AliInfo("Init() \n");
137 // Call configuration file
138}
139
140void AliAnalysisTaskPWG2ESDfilter::ConnectInputData(Option_t */*option*/)
141{
142// Connect the input data
143//
144 if (fDebug > 1) AliInfo("ConnectInputData() \n");
145 // Input
146 AliESDInputHandler* esdH = (AliESDInputHandler*)
147 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
148 fESD = (AliESDEvent*) esdH->GetEvent();
149 fTree = esdH->GetTree();
150}
151
152void AliAnalysisTaskPWG2ESDfilter::Exec(Option_t */*option*/)
153{
154// Execute analysis for current event
155//
156 // ESD Filter analysis task executed for each event
157 AliESD* old = fESD->GetAliESDOld();
158
159 Long64_t ientry = fTree->GetReadEntry();
160 printf("Filter: Analysing event # %5d\n", (Int_t) ientry);
161
162 // set arrays and pointers
163 Double_t pos[3];
164 Double_t p[3];
165 Double_t covVtx[6];
166 Double_t covTr[21];
76b98553 167 // Double_t pid[10];
f9228736 168
169 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
170 for (Int_t i = 0; i < 21; i++) covTr [i] = 0.;
171
172 // *** PWG2 specific ***
173
174 Double_t tpcentrancepoint[3];
175 Double_t tpcexitpoint[3];
176 TBits sharemap;
177 TBits clustermap;
178
179 for (Int_t i = 0; i < 3; i++) { tpcentrancepoint[i] = 0.; tpcexitpoint[i] = 0; }
180
181 // --- END PWG2 specific ---
182
183
184 // loop over events and fill them
185
186 // Multiplicity information needed by the header (to be revised!)
187 Int_t nTracks = fESD->GetNumberOfTracks();
188 Int_t nPosTracks = 0;
189 for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack)
190 if (fESD->GetTrack(iTrack)->GetSign()> 0) nPosTracks++;
191
192 // Update the header
193
0a918d8d 194 AliAODHeader* header = dynamic_cast<AliAODHeader*>(fAOD->GetHeader());
195 if(!header) AliFatal("Not a standard AOD");
f9228736 196 header->SetRunNumber(fESD->GetRunNumber());
197 if (old) {
198 header->SetBunchCrossNumber(0);
199 header->SetOrbitNumber(0);
200 header->SetPeriodNumber(0);
201 header->SetEventType(0);
202 header->SetMuonMagFieldScale(-999.);
203 header->SetCentrality(0);
204 } else {
205 header->SetBunchCrossNumber(fESD->GetBunchCrossNumber());
206 header->SetOrbitNumber(fESD->GetOrbitNumber());
207 header->SetPeriodNumber(fESD->GetPeriodNumber());
208 header->SetEventType(fESD->GetEventType());
209 header->SetMuonMagFieldScale(-999.);
210 header->SetCentrality(0);
211 }
212
213 header->SetTriggerMask(fESD->GetTriggerMask());
214 header->SetTriggerCluster(fESD->GetTriggerCluster());
215 header->SetMagneticField(fESD->GetMagneticField());
216 header->SetZDCN1Energy(fESD->GetZDCN1Energy());
217 header->SetZDCP1Energy(fESD->GetZDCP1Energy());
218 header->SetZDCN2Energy(fESD->GetZDCN2Energy());
219 header->SetZDCP2Energy(fESD->GetZDCP2Energy());
220 header->SetZDCEMEnergy(fESD->GetZDCEMEnergy(0),fESD->GetZDCEMEnergy(1));
221 header->SetRefMultiplicity(nTracks);
222 header->SetRefMultiplicityPos(nPosTracks);
223 header->SetRefMultiplicityNeg(nTracks - nPosTracks);
224
225
226 Int_t nV0s = fESD->GetNumberOfV0s();
227 Int_t nCascades = fESD->GetNumberOfCascades();
228 Int_t nKinks = fESD->GetNumberOfKinks();
229 // Int_t nVertices = nV0s + nCascades + nKinks + 1 /* = prim. vtx*/;
230 // Int_t nJets = 0;
231 // Int_t nCaloClus = fESD->GetNumberOfCaloClusters();
232 // Int_t nFmdClus = 0;
233 // Int_t nPmdClus = fESD->GetNumberOfPmdTracks();
234
235 printf(" NV0=%d NCASCADES=%d NKINKS=%d\n", nV0s, nCascades, nKinks);
236
237// fAOD->ResetStd(nTracks, nVertices, nV0s+nCascades, nJets, nCaloClus, nFmdClus, nPmdClus);
238
239 AliAODTrack *aodTrack;
240
241
242 // Array to take into account the tracks already added to the AOD
243 Bool_t * usedTrack = NULL;
244 if (nTracks>0) {
245 usedTrack = new Bool_t[nTracks];
246 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) usedTrack[iTrack]=kFALSE;
247 }
248 // Array to take into account the V0s already added to the AOD
249 Bool_t * usedV0 = NULL;
250 if (nV0s>0) {
251 usedV0 = new Bool_t[nV0s];
252 for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE;
253 }
254 // Array to take into account the kinks already added to the AOD
255 Bool_t * usedKink = NULL;
256 if (nKinks>0) {
257 usedKink = new Bool_t[nKinks];
258 for (Int_t iKink=0; iKink<nKinks; ++iKink) usedKink[iKink]=kFALSE;
259 }
260
261 // Access to the AOD container of vertices
262 TClonesArray &vertices = *(fAOD->GetVertices());
263 Int_t jVertices=0;
264
265 // Access to the AOD container of tracks
266 TClonesArray &tracks = *(fAOD->GetTracks());
267 Int_t jTracks=0;
268 Int_t pTracks=0;
269
270 // Add primary vertex. The primary tracks will be defined
271 // after the loops on the composite objects (V0, cascades, kinks)
272 const AliESDVertex *vtx = fESD->GetPrimaryVertex();
273
274 vtx->GetXYZ(pos); // position
275 vtx->GetCovMatrix(covVtx); //covariance matrix
276
277 AliAODVertex * primary = new(vertices[jVertices++])
278 AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, AliAODVertex::kPrimary);
279 primary->Print();
280
281
282 // Create vertices starting from the most complex objects
283 Double_t chi2 = 0.;
284
285 // Cascades
286 for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) {
287 AliESDcascade *cascade = fESD->GetCascade(nCascade);
288
289 cascade->GetXYZ(pos[0], pos[1], pos[2]);
290
291 if (!old) {
292 chi2 = vtx->GetChi2toNDF();
293 cascade->GetPosCovXi(covVtx);
294 } else {
295 chi2 = -999.;
296 }
297 // Add the cascade vertex
298 AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos,
299 covVtx,
300 chi2, // = chi2/NDF since NDF = 2*2-3 (AM)
301 primary,
302 AliAODVertex::kCascade);
303
304 primary->AddDaughter(vcascade);
305
306 // Add the V0 from the cascade. The ESD class have to be optimized...
307 // Now we have to search for the corresponding Vo in the list of V0s
308 // using the indeces of the positive and negative tracks
309
310 Int_t posFromV0 = cascade->GetPindex();
311 Int_t negFromV0 = cascade->GetNindex();
312
313
314 AliESDv0 * v0 = 0x0;
315 Int_t indV0 = -1;
316
317 for (Int_t iV0=0; iV0<nV0s; ++iV0) {
318
319 v0 = fESD->GetV0(iV0);
320 Int_t posV0 = v0->GetPindex();
321 Int_t negV0 = v0->GetNindex();
322
323 if (posV0==posFromV0 && negV0==negFromV0) {
324 indV0 = iV0;
325 break;
326 }
327 }
328
329 AliAODVertex * vV0FromCascade = 0x0;
330
331 if (indV0>-1 && !usedV0[indV0] ) {
332
333 // the V0 exists in the array of V0s and is not used
334
335 usedV0[indV0] = kTRUE;
336
337 v0->GetXYZ(pos[0], pos[1], pos[2]);
338 if (!old) {
339 chi2 = v0->GetChi2V0();
340 v0->GetPosCov(covVtx);
341 } else {
342 chi2 = -999.;
343 }
344
345 vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos,
346 covVtx,
347 chi2, // = chi2/NDF since NDF = 2*2-3 (AM)
348 vcascade,
349 AliAODVertex::kV0);
350 } else {
351
352 // the V0 doesn't exist in the array of V0s or was used
353// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade
354// << " The V0 " << indV0
355// << " doesn't exist in the array of V0s or was used!" << endl;
356
357 cascade->GetXYZ(pos[0], pos[1], pos[2]);
358
359 if (!old) {
360 chi2 = v0->GetChi2V0();
361 cascade->GetPosCov(covVtx);
362 } else {
363 chi2 = -999.;
364 }
365
366 vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos,
367 covVtx,
368 chi2, // = chi2/NDF since NDF = 2*2-3 (AM)
369 vcascade,
370 AliAODVertex::kV0);
371 vcascade->AddDaughter(vV0FromCascade);
372 }
373
374 // Add the positive tracks from the V0
375
376 if (posFromV0>-1 && !usedTrack[posFromV0]) {
377
378 usedTrack[posFromV0] = kTRUE;
379
380 AliESDtrack *esdTrack = fESD->GetTrack(posFromV0);
381 esdTrack->GetPxPyPz(p);
382 esdTrack->GetXYZ(pos);
383 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 384 // esdTrack->GetESDpid(pid);
f9228736 385
386 vV0FromCascade->AddDaughter(aodTrack =
387 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
388 esdTrack->GetLabel(),
389 p,
390 kTRUE,
391 pos,
392 kFALSE,
393 covTr,
394 (Short_t)esdTrack->GetSign(),
395 esdTrack->GetITSClusterMap(),
76b98553 396 // pid,
f9228736 397 vV0FromCascade,
398 kTRUE, // check if this is right
399 kFALSE, // check if this is right
a01415e2 400 AliAODTrack::kFromDecayVtx)
f9228736 401 );
402 aodTrack->ConvertAliPIDtoAODPID();
403 }
404 else {
405// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade
406// << " track " << posFromV0 << " has already been used!" << endl;
407 }
408
409 // Add the negative tracks from the V0
410
411 if (negFromV0>-1 && !usedTrack[negFromV0]) {
412
413 usedTrack[negFromV0] = kTRUE;
414
415 AliESDtrack *esdTrack = fESD->GetTrack(negFromV0);
416 esdTrack->GetPxPyPz(p);
417 esdTrack->GetXYZ(pos);
418 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 419 // esdTrack->GetESDpid(pid);
f9228736 420
421 vV0FromCascade->AddDaughter(aodTrack =
422 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
423 esdTrack->GetLabel(),
424 p,
425 kTRUE,
426 pos,
427 kFALSE,
428 covTr,
429 (Short_t)esdTrack->GetSign(),
430 esdTrack->GetITSClusterMap(),
76b98553 431 //pid,
f9228736 432 vV0FromCascade,
433 kTRUE, // check if this is right
434 kFALSE, // check if this is right
a01415e2 435 AliAODTrack::kFromDecayVtx)
f9228736 436 );
437 aodTrack->ConvertAliPIDtoAODPID();
438 }
439 else {
440// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade
441// << " track " << negFromV0 << " has already been used!" << endl;
442 }
443
444 // Add the bachelor track from the cascade
445
446 Int_t bachelor = cascade->GetBindex();
447
448 if(bachelor>-1 && !usedTrack[bachelor]) {
449
450 usedTrack[bachelor] = kTRUE;
451
452 AliESDtrack *esdTrack = fESD->GetTrack(bachelor);
453 esdTrack->GetPxPyPz(p);
454 esdTrack->GetXYZ(pos);
455 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 456 // esdTrack->GetESDpid(pid);
f9228736 457
458 vcascade->AddDaughter(aodTrack =
459 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
460 esdTrack->GetLabel(),
461 p,
462 kTRUE,
463 pos,
464 kFALSE,
465 covTr,
466 (Short_t)esdTrack->GetSign(),
467 esdTrack->GetITSClusterMap(),
76b98553 468 //pid,
f9228736 469 vcascade,
470 kTRUE, // check if this is right
471 kFALSE, // check if this is right
a01415e2 472 AliAODTrack::kFromDecayVtx)
f9228736 473 );
474 aodTrack->ConvertAliPIDtoAODPID();
475 }
476 else {
477// cerr << "Error: event " << fESD->GetEventNumberInFile() << " cascade " << nCascade
478// << " track " << bachelor << " has already been used!" << endl;
479 }
480
481 // Add the primary track of the cascade (if any)
482
483 } // end of the loop on cascades
484
485 // V0s
486
487 for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) {
488
489 if (usedV0[nV0]) continue; // skip if aready added to the AOD
490
491 AliESDv0 *v0 = fESD->GetV0(nV0);
492
493 v0->GetXYZ(pos[0], pos[1], pos[2]);
494
495 if (!old) {
496 chi2 = v0->GetChi2V0();
497 v0->GetPosCov(covVtx);
498 } else {
499 chi2 = -999.;
500 }
501
502
503 AliAODVertex * vV0 =
504 new(vertices[jVertices++]) AliAODVertex(pos,
505 covVtx,
506 chi2, // = chi2/NDF since NDF = 2*2-3
507 primary,
508 AliAODVertex::kV0);
509 primary->AddDaughter(vV0);
510
511 Int_t posFromV0 = v0->GetPindex();
512 Int_t negFromV0 = v0->GetNindex();
513
514 // Add the positive tracks from the V0
515
516 if (posFromV0>-1 && !usedTrack[posFromV0]) {
517
518 usedTrack[posFromV0] = kTRUE;
519
520 AliESDtrack *esdTrack = fESD->GetTrack(posFromV0);
521 esdTrack->GetPxPyPz(p);
522 esdTrack->GetXYZ(pos);
523 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 524 //esdTrack->GetESDpid(pid);
f9228736 525
526 vV0->AddDaughter(aodTrack =
527 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
528 esdTrack->GetLabel(),
529 p,
530 kTRUE,
531 pos,
532 kFALSE,
533 covTr,
534 (Short_t)esdTrack->GetSign(),
535 esdTrack->GetITSClusterMap(),
76b98553 536 //pid,
f9228736 537 vV0,
538 kTRUE, // check if this is right
539 kFALSE, // check if this is right
a01415e2 540 AliAODTrack::kFromDecayVtx)
f9228736 541 );
542 aodTrack->ConvertAliPIDtoAODPID();
543 }
544 else {
545// cerr << "Error: event " << fESD->GetEventNumberInFile() << " V0 " << nV0
546// << " track " << posFromV0 << " has already been used!" << endl;
547 }
548
549 // Add the negative tracks from the V0
550
551 if (negFromV0>-1 && !usedTrack[negFromV0]) {
552
553 usedTrack[negFromV0] = kTRUE;
554
555 AliESDtrack *esdTrack = fESD->GetTrack(negFromV0);
556 esdTrack->GetPxPyPz(p);
557 esdTrack->GetXYZ(pos);
558 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 559 //esdTrack->GetESDpid(pid);
f9228736 560
561 vV0->AddDaughter(aodTrack =
562 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
563 esdTrack->GetLabel(),
564 p,
565 kTRUE,
566 pos,
567 kFALSE,
568 covTr,
569 (Short_t)esdTrack->GetSign(),
570 esdTrack->GetITSClusterMap(),
76b98553 571 //pid,
f9228736 572 vV0,
573 kTRUE, // check if this is right
574 kFALSE, // check if this is right
a01415e2 575 AliAODTrack::kFromDecayVtx)
f9228736 576 );
577 aodTrack->ConvertAliPIDtoAODPID();
578 }
579 else {
580// cerr << "Error: event " << fESD->GetEventNumberInFile() << " V0 " << nV0
581// << " track " << negFromV0 << " has already been used!" << endl;
582 }
583
584 } // end of the loop on V0s
585
586 // Kinks: it is a big mess the access to the information in the kinks
587 // The loop is on the tracks in order to find the mother and daugther of each kink
588
589
590 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) {
591
592
593 AliESDtrack * esdTrack = fESD->GetTrack(iTrack);
594
595 Int_t ikink = esdTrack->GetKinkIndex(0);
596
597 if (ikink && nKinks) {
598 // Negative kink index: mother, positive: daughter
599
600 // Search for the second track of the kink
601
602 for (Int_t jTrack = iTrack+1; jTrack<nTracks; ++jTrack) {
603
604 AliESDtrack * esdTrack1 = fESD->GetTrack(jTrack);
605
606 Int_t jkink = esdTrack1->GetKinkIndex(0);
607
608 if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) {
609
610 // The two tracks are from the same kink
611
612 if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks
613
614 Int_t imother = -1;
615 Int_t idaughter = -1;
616
617 if (ikink<0 && jkink>0) {
618
619 imother = iTrack;
620 idaughter = jTrack;
621 }
622 else if (ikink>0 && jkink<0) {
623
624 imother = jTrack;
625 idaughter = iTrack;
626 }
627 else {
628// cerr << "Error: Wrong combination of kink indexes: "
629// << ikink << " " << jkink << endl;
630 continue;
631 }
632
633 // Add the mother track
634
635 AliAODTrack * mother = NULL;
636
637 if (!usedTrack[imother]) {
638
639 usedTrack[imother] = kTRUE;
640
641 AliESDtrack *esdTrackC = fESD->GetTrack(imother);
642 esdTrackC->GetPxPyPz(p);
643 esdTrackC->GetXYZ(pos);
644 esdTrackC->GetCovarianceXYZPxPyPz(covTr);
76b98553 645 //esdTrackC->GetESDpid(pid);
f9228736 646
647 mother =
648 new(tracks[jTracks++]) AliAODTrack(esdTrackC->GetID(),
649 esdTrackC->GetLabel(),
650 p,
651 kTRUE,
652 pos,
653 kFALSE,
654 covTr,
655 (Short_t)esdTrackC->GetSign(),
656 esdTrackC->GetITSClusterMap(),
76b98553 657 //pid,
f9228736 658 primary,
659 kTRUE, // check if this is right
660 kTRUE, // check if this is right
661 AliAODTrack::kPrimary);
662 primary->AddDaughter(mother);
663 mother->ConvertAliPIDtoAODPID();
664 }
665 else {
666// cerr << "Error: event " << fESD->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1
667// << " track " << imother << " has already been used!" << endl;
668 }
669
670 // Add the kink vertex
671 AliESDkink * kink = fESD->GetKink(TMath::Abs(ikink)-1);
672
673 AliAODVertex * vkink =
674 new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(),
675 NULL,
676 0.,
677 mother,
678 AliAODVertex::kKink);
679 // Add the daughter track
680
681 AliAODTrack * daughter = NULL;
682
683 if (!usedTrack[idaughter]) {
684
685 usedTrack[idaughter] = kTRUE;
686
687 AliESDtrack *esdTrackC = fESD->GetTrack(idaughter);
688 esdTrackC->GetPxPyPz(p);
689 esdTrackC->GetXYZ(pos);
690 esdTrackC->GetCovarianceXYZPxPyPz(covTr);
76b98553 691 //esdTrackC->GetESDpid(pid);
f9228736 692
693 daughter =
694 new(tracks[jTracks++]) AliAODTrack(esdTrackC->GetID(),
695 esdTrackC->GetLabel(),
696 p,
697 kTRUE,
698 pos,
699 kFALSE,
700 covTr,
701 (Short_t)esdTrackC->GetSign(),
702 esdTrackC->GetITSClusterMap(),
76b98553 703 //pid,
f9228736 704 vkink,
705 kTRUE, // check if this is right
706 kTRUE, // check if this is right
707 AliAODTrack::kPrimary);
708 vkink->AddDaughter(daughter);
709 daughter->ConvertAliPIDtoAODPID();
710 }
711 else {
712// cerr << "Error: event " << fESD->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1
713// << " track " << idaughter << " has already been used!" << endl;
714 }
715 }
716 }
717 }
718 }
719
720
721 // Tracks (primary and orphan)
722
723 printf("NUMBER OF TRACKS %5d\n", nTracks);
724
725 // *** PWG2 specific ***
726
727 fPWG2AODTracks->Delete();
728 fPWG2AODTracks->Expand(nTracks);
729 TClonesArray &tPWG2AODTracks = *fPWG2AODTracks;
730
731 // --- END PWG2 specific ---
732
733 for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) {
734
735 if (usedTrack[nTrack]) continue;
736 AliESDtrack *esdTrack = fESD->GetTrack(nTrack);
737 UInt_t selectInfo = 0;
738 //
739 // Track selection
740 if (fTrackFilter) {
741 selectInfo = fTrackFilter->IsSelected(esdTrack);
742 if (!selectInfo) continue;
743 }
744
745 //
746 esdTrack->GetPxPyPz(p);
747 esdTrack->GetXYZ(pos);
748 esdTrack->GetCovarianceXYZPxPyPz(covTr);
76b98553 749 //esdTrack->GetESDpid(pid);
f9228736 750
751 Float_t impactXY, impactZ;
752
753 esdTrack->GetImpactParameters(impactXY,impactZ);
754
755 // *** PWG2 specific ***
756
757 sharemap = esdTrack->GetTPCSharedMap();
758 clustermap = esdTrack->GetTPCClusterMap();
759
760 esdTrack->GetInnerXYZ(tpcentrancepoint);
761 tpcentrancepoint[2] -= pos[2];
762
763 esdTrack->GetOuterXYZ(tpcexitpoint);
764 tpcexitpoint[2] -= pos[2];
765
766 // --- END PWG2 specific ---
767
768
769 if (impactXY<3) {
770 // track inside the beam pipe
771
772 primary->AddDaughter(aodTrack =
773 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
774 esdTrack->GetLabel(),
775 p,
776 kTRUE,
777 pos,
778 kFALSE,
779 covTr,
780 (Short_t)esdTrack->GetSign(),
781 esdTrack->GetITSClusterMap(),
76b98553 782 //pid,
f9228736 783 primary,
784 kTRUE, // check if this is right
785 kTRUE, // check if this is right
786 AliAODTrack::kPrimary,
787 selectInfo)
788 );
789 aodTrack->ConvertAliPIDtoAODPID();
790
791 // *** PWG2 specific ****
792 // Add the PWG2 info into the AOD
793 new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint,
794 tpcexitpoint,
795 sharemap,
796 clustermap,
797 aodTrack);
798 // --- END PWG2 specific ---
799 }
800 else {
801 // outside the beam pipe: orphan track
802 aodTrack =
803 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
804 esdTrack->GetLabel(),
805 p,
806 kTRUE,
807 pos,
808 kFALSE,
809 covTr,
810 (Short_t)esdTrack->GetSign(),
811 esdTrack->GetITSClusterMap(),
76b98553 812 //pid,
f9228736 813 NULL,
814 kFALSE, // check if this is right
815 kFALSE, // check if this is right
816 AliAODTrack::kOrphan,
817 selectInfo);
818 aodTrack->ConvertAliPIDtoAODPID();
819
820 // *** PWG2 specific ****
821 // Add the PWG2 info into the AOD
822 new (tPWG2AODTracks[pTracks++]) AliPWG2AODTrack(tpcentrancepoint,
823 tpcexitpoint,
824 sharemap,
825 clustermap,
826 aodTrack);
827 // --- END PWG2 specific ---
828 }
829 } // end of loop on tracks
830
831 // muon tracks
832 Int_t nMuTracks = fESD->GetNumberOfMuonTracks();
833 for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {
834
835 AliESDMuonTrack *esdMuTrack = fESD->GetMuonTrack(nMuTrack);
836 p[0] = esdMuTrack->Px();
837 p[1] = esdMuTrack->Py();
838 p[2] = esdMuTrack->Pz();
839 pos[0] = primary->GetX();
840 pos[1] = primary->GetY();
841 pos[2] = primary->GetZ();
842
843 // has to be changed once the muon pid is provided by the ESD
76b98553 844 //for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
845 //pid[AliAODTrack::kMuon]=1.;
f9228736 846
847 primary->AddDaughter(
848 new(tracks[jTracks++]) AliAODTrack(0, // no ID provided
849 0, // no label provided
850 p,
851 kTRUE,
852 pos,
853 kFALSE,
854 NULL, // no covariance matrix provided
855 (Short_t)-99, // no charge provided
856 0, // no ITSClusterMap
76b98553 857 //pid,
f9228736 858 primary,
859 kTRUE, // check if this is right
860 kTRUE, // not used for vertex fit
861 AliAODTrack::kPrimary)
862 );
863 }
864
865 printf(" jTracks=%d pTracks=%d PWG2=%d\n", jTracks, pTracks, fPWG2AODTracks->GetEntries());
866
867 delete [] usedTrack;
868 delete [] usedV0;
869 delete [] usedKink;
870
871
872 //
873 PostData(0, fTreeA);
874 return;
875}
876
877void AliAnalysisTaskPWG2ESDfilter::Terminate(Option_t */*option*/)
878{
879// Terminate analysis
880//
881 if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");
882}
883