AliESDCaloCluster.cxx,.h: Removed fM11 and related getter and setter,
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskESDfilter.cxx
CommitLineData
96b85d73 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id: AliAnalysisTaskESDfilter.cxx 24535 2008-03-16 22:43:30Z fca $ */
17
18#include <TChain.h>
19#include <TFile.h>
e6500713 20#include <TArrayI.h>
96b85d73 21
22#include "AliAnalysisTaskESDfilter.h"
23#include "AliAnalysisManager.h"
24#include "AliESDEvent.h"
25#include "AliAODEvent.h"
26#include "AliESDInputHandler.h"
27#include "AliAODHandler.h"
28#include "AliAnalysisFilter.h"
29#include "AliESDtrack.h"
30#include "AliESDMuonTrack.h"
31#include "AliESDVertex.h"
32#include "AliESDv0.h"
33#include "AliESDkink.h"
34#include "AliESDcascade.h"
35#include "AliESDPmdTrack.h"
36#include "AliESDCaloCluster.h"
37#include "AliESDCaloCells.h"
38#include "AliMultiplicity.h"
39#include "AliLog.h"
40
41ClassImp(AliAnalysisTaskESDfilter)
42
43////////////////////////////////////////////////////////////////////////
44
45AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter():
46 AliAnalysisTaskSE(),
47 fTrackFilter(0x0),
48 fKinkFilter(0x0),
49 fV0Filter(0x0)
50{
51 // Default constructor
52}
53
54AliAnalysisTaskESDfilter::AliAnalysisTaskESDfilter(const char* name):
55 AliAnalysisTaskSE(name),
56 fTrackFilter(0x0),
57 fKinkFilter(0x0),
58 fV0Filter(0x0)
59{
60 // Constructor
61}
62
63void AliAnalysisTaskESDfilter::UserCreateOutputObjects()
64{
65// Create the output container
66 OutputTree()->GetUserInfo()->Add(fTrackFilter);
67}
68
69void AliAnalysisTaskESDfilter::Init()
70{
71 // Initialization
72 if (fDebug > 1) AliInfo("Init() \n");
73 // Call configuration file
74}
75
76
77void AliAnalysisTaskESDfilter::UserExec(Option_t */*option*/)
78{
79// Execute analysis for current event
80//
81
82 Long64_t ientry = Entry();
83 printf("Filter: Analysing event # %5d\n", (Int_t) ientry);
84
85 ConvertESDtoAOD();
86}
87
88void AliAnalysisTaskESDfilter::ConvertESDtoAOD() {
89 // ESD Filter analysis task executed for each event
90 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
91 AliESD* old = esd->GetAliESDOld();
92
93 // set arrays and pointers
94 Float_t posF[3];
95 Double_t pos[3];
96 Double_t p[3];
97 Double_t p_pos[3];
98 Double_t p_neg[3];
99 Double_t covVtx[6];
100 Double_t covTr[21];
101 Double_t pid[10];
102
103 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
104 for (Int_t i = 0; i < 21; i++) covTr [i] = 0.;
105
106
107 // loop over events and fill them
108
109 // Multiplicity information needed by the header (to be revised!)
110 Int_t nTracks = esd->GetNumberOfTracks();
111 Int_t nPosTracks = 0;
112 for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack)
113 if (esd->GetTrack(iTrack)->GetSign()> 0) nPosTracks++;
114
115 // Update the header
116
117 AliAODHeader* header = AODEvent()->GetHeader();
118 header->SetRunNumber(esd->GetRunNumber());
119 if (old) {
120 header->SetBunchCrossNumber(0);
121 header->SetOrbitNumber(0);
122 header->SetPeriodNumber(0);
123 header->SetEventType(0);
124 header->SetMuonMagFieldScale(-999.); // FIXME
125 header->SetCentrality(-999.); // FIXME
126 } else {
127 header->SetBunchCrossNumber(esd->GetBunchCrossNumber());
128 header->SetOrbitNumber(esd->GetOrbitNumber());
129 header->SetPeriodNumber(esd->GetPeriodNumber());
130 header->SetEventType(esd->GetEventType());
131 header->SetMuonMagFieldScale(-999.); // FIXME
132 header->SetCentrality(-999.); // FIXME
133 }
134
135 header->SetTriggerMask(esd->GetTriggerMask());
136 header->SetTriggerCluster(esd->GetTriggerCluster());
137 header->SetMagneticField(esd->GetMagneticField());
138 header->SetZDCN1Energy(esd->GetZDCN1Energy());
139 header->SetZDCP1Energy(esd->GetZDCP1Energy());
140 header->SetZDCN2Energy(esd->GetZDCN2Energy());
141 header->SetZDCP2Energy(esd->GetZDCP2Energy());
142 header->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
143 header->SetRefMultiplicity(nTracks);
144 header->SetRefMultiplicityPos(nPosTracks);
145 header->SetRefMultiplicityNeg(nTracks - nPosTracks);
146//
147//
148 Int_t nV0s = esd->GetNumberOfV0s();
149 Int_t nCascades = esd->GetNumberOfCascades();
150 Int_t nKinks = esd->GetNumberOfKinks();
151 Int_t nVertices = nV0s + 2*nCascades /*could lead to two vertices, one V0 and the Xi */+ nKinks + 1 /* = prim. vtx*/;
152 Int_t nJets = 0;
153 Int_t nCaloClus = esd->GetNumberOfCaloClusters();
154 Int_t nFmdClus = 0;
155 Int_t nPmdClus = esd->GetNumberOfPmdTracks();
156
157 printf(" NV0=%d NCASCADES=%d NKINKS=%d\n", nV0s, nCascades, nKinks);
158
159 AODEvent()->ResetStd(nTracks, nVertices, nV0s+nCascades, nJets, nCaloClus, nFmdClus, nPmdClus);
160
161 AliAODTrack *aodTrack = 0x0;
162
163 // Array to take into account the tracks already added to the AOD
164 Bool_t * usedTrack = NULL;
165 if (nTracks>0) {
166 usedTrack = new Bool_t[nTracks];
167 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) usedTrack[iTrack]=kFALSE;
168 }
169 // Array to take into account the V0s already added to the AOD
170 Bool_t * usedV0 = NULL;
171 if (nV0s>0) {
172 usedV0 = new Bool_t[nV0s];
173 for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE;
174 }
175 // Array to take into account the kinks already added to the AOD
176 Bool_t * usedKink = NULL;
177 if (nKinks>0) {
178 usedKink = new Bool_t[nKinks];
179 for (Int_t iKink=0; iKink<nKinks; ++iKink) usedKink[iKink]=kFALSE;
180 }
181
182 // Access to the AOD container of vertices
183 TClonesArray &vertices = *(AODEvent()->GetVertices());
184 Int_t jVertices=0;
185
186 // Access to the AOD container of tracks
187 TClonesArray &tracks = *(AODEvent()->GetTracks());
188 Int_t jTracks=0;
189
190 // Access to the AOD container of V0s
191 TClonesArray &V0s = *(AODEvent()->GetV0s());
192 Int_t jV0s=0;
193
194 // Add primary vertex. The primary tracks will be defined
195 // after the loops on the composite objects (V0, cascades, kinks)
196 const AliESDVertex *vtx = esd->GetPrimaryVertex();
197
198 vtx->GetXYZ(pos); // position
199 vtx->GetCovMatrix(covVtx); //covariance matrix
200
201 AliAODVertex * primary = new(vertices[jVertices++])
202 AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, AliAODVertex::kPrimary);
203 primary->Print();
204
205 // Create vertices starting from the most complex objects
206 Double_t chi2 = 0.;
207
208 // Cascades
209 for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) {
210 AliESDcascade *cascade = esd->GetCascade(nCascade);
211
212 cascade->GetXYZ(pos[0], pos[1], pos[2]);
213
214 if (!old) {
215 chi2 = cascade->GetChi2Xi(); // = chi2/NDF since NDF = 2*2-3
216 cascade->GetPosCovXi(covVtx);
217 } else {
218 chi2 = -999.;
219 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
220 }
221 // Add the cascade vertex
222 AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos,
223 covVtx,
224 chi2,
225 primary,
226 nCascade,
227 AliAODVertex::kCascade);
228
229 primary->AddDaughter(vcascade);
230
231 // Add the V0 from the cascade. The ESD class have to be optimized...
232 // Now we have to search for the corresponding Vo in the list of V0s
233 // using the indeces of the positive and negative tracks
234
235 Int_t posFromV0 = cascade->GetPindex();
236 Int_t negFromV0 = cascade->GetNindex();
237
238
239 AliESDv0 * v0 = 0x0;
240 Int_t indV0 = -1;
241
242 for (Int_t iV0=0; iV0<nV0s; ++iV0) {
243
244 v0 = esd->GetV0(iV0);
245 Int_t posV0 = v0->GetPindex();
246 Int_t negV0 = v0->GetNindex();
247
248 if (posV0==posFromV0 && negV0==negFromV0) {
249 indV0 = iV0;
250 break;
251 }
252 }
253
254 AliAODVertex * vV0FromCascade = 0x0;
255
256 if (indV0>-1 && !usedV0[indV0] ) {
257
258 // the V0 exists in the array of V0s and is not used
259
260 usedV0[indV0] = kTRUE;
261
262 v0->GetXYZ(pos[0], pos[1], pos[2]);
263 if (!old) {
264 chi2 = v0->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3
265 v0->GetPosCov(covVtx);
266 } else {
267 chi2 = -999.;
268 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
269 }
270
271 vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos,
272 covVtx,
273 chi2,
274 vcascade,
275 indV0,
276 AliAODVertex::kV0);
277 } else {
278
279 // the V0 doesn't exist in the array of V0s or was used
280// cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade
281// << " The V0 " << indV0
282// << " doesn't exist in the array of V0s or was used!" << endl;
283
284 cascade->GetXYZ(pos[0], pos[1], pos[2]);
285
286 if (!old) {
287 chi2 = v0->GetChi2V0();
288 cascade->GetPosCov(covVtx);
289 } else {
290 chi2 = -999.;
291 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
292 }
293
294 vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos,
295 covVtx,
296 chi2, // = chi2/NDF since NDF = 2*2-3 (AM)
297 vcascade,
298 indV0,
299 AliAODVertex::kV0);
300 vcascade->AddDaughter(vV0FromCascade);
301 }
302
303 // Add the positive tracks from the V0
304
305 if (posFromV0>-1 && !usedTrack[posFromV0]) {
306
307 usedTrack[posFromV0] = kTRUE;
308
309 AliESDtrack *esdTrack = esd->GetTrack(posFromV0);
310 esdTrack->GetPxPyPz(p_pos);
311 esdTrack->GetXYZ(pos);
312 esdTrack->GetCovarianceXYZPxPyPz(covTr);
313 esdTrack->GetESDpid(pid);
314
315 vV0FromCascade->AddDaughter(aodTrack =
316 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
317 esdTrack->GetLabel(),
318 p_pos,
319 kTRUE,
320 pos,
321 kFALSE,
322 covTr,
323 (Short_t)esdTrack->GetSign(),
324 esdTrack->GetITSClusterMap(),
325 pid,
326 vV0FromCascade,
327 kTRUE, // check if this is right
328 kFALSE, // check if this is right
329 AliAODTrack::kSecondary)
330 );
331 aodTrack->ConvertAliPIDtoAODPID();
4fcd837c 332 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 333 }
334 else {
335// cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade
336// << " track " << posFromV0 << " has already been used!" << endl;
337 }
338
339 // Add the negative tracks from the V0
340
341 if (negFromV0>-1 && !usedTrack[negFromV0]) {
342
343 usedTrack[negFromV0] = kTRUE;
344
345 AliESDtrack *esdTrack = esd->GetTrack(negFromV0);
346 esdTrack->GetPxPyPz(p_neg);
347 esdTrack->GetXYZ(pos);
348 esdTrack->GetCovarianceXYZPxPyPz(covTr);
349 esdTrack->GetESDpid(pid);
350
351 vV0FromCascade->AddDaughter(aodTrack =
352 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
353 esdTrack->GetLabel(),
354 p_neg,
355 kTRUE,
356 pos,
357 kFALSE,
358 covTr,
359 (Short_t)esdTrack->GetSign(),
360 esdTrack->GetITSClusterMap(),
361 pid,
362 vV0FromCascade,
363 kTRUE, // check if this is right
364 kFALSE, // check if this is right
365 AliAODTrack::kSecondary)
366 );
367 aodTrack->ConvertAliPIDtoAODPID();
4fcd837c 368 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 369 }
370 else {
371// cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade
372// << " track " << negFromV0 << " has already been used!" << endl;
373 }
374
375 // add it to the V0 array as well
376 Double_t d0[2] = { -999., -99.};
377 // counting is probably wrong
378 new(V0s[jV0s++]) AliAODv0(vV0FromCascade, -999., -99., p_pos, p_neg, d0); // to be refined
379
380 // Add the bachelor track from the cascade
381
382 Int_t bachelor = cascade->GetBindex();
383
384 if(bachelor>-1 && !usedTrack[bachelor]) {
385
386 usedTrack[bachelor] = kTRUE;
387
388 AliESDtrack *esdTrack = esd->GetTrack(bachelor);
389 esdTrack->GetPxPyPz(p);
390 esdTrack->GetXYZ(pos);
391 esdTrack->GetCovarianceXYZPxPyPz(covTr);
392 esdTrack->GetESDpid(pid);
393
394 vcascade->AddDaughter(aodTrack =
395 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
396 esdTrack->GetLabel(),
397 p,
398 kTRUE,
399 pos,
400 kFALSE,
401 covTr,
402 (Short_t)esdTrack->GetSign(),
403 esdTrack->GetITSClusterMap(),
404 pid,
405 vcascade,
406 kTRUE, // check if this is right
407 kFALSE, // check if this is right
408 AliAODTrack::kSecondary)
409 );
410 aodTrack->ConvertAliPIDtoAODPID();
4fcd837c 411 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 412 }
413 else {
414// cerr << "Error: event " << esd->GetEventNumberInFile() << " cascade " << nCascade
415// << " track " << bachelor << " has already been used!" << endl;
416 }
417
418 // Add the primary track of the cascade (if any)
419
420 } // end of the loop on cascades
421
422 // V0s
423
424 for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) {
425
426 if (usedV0[nV0]) continue; // skip if aready added to the AOD
427
428 AliESDv0 *v0 = esd->GetV0(nV0);
429
430 v0->GetXYZ(pos[0], pos[1], pos[2]);
431
432 if (!old) {
433 chi2 = v0->GetChi2V0(); // = chi2/NDF since NDF = 2*2-3
434 v0->GetPosCov(covVtx);
435 } else {
436 chi2 = -999.;
437 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
438 }
439
440
441 AliAODVertex * vV0 =
442 new(vertices[jVertices++]) AliAODVertex(pos,
443 covVtx,
444 chi2,
445 primary,
446 nV0,
447 AliAODVertex::kV0);
448 primary->AddDaughter(vV0);
449
450 Int_t posFromV0 = v0->GetPindex();
451 Int_t negFromV0 = v0->GetNindex();
452
453 // Add the positive tracks from the V0
454
455 if (posFromV0>-1 && !usedTrack[posFromV0]) {
456
457 usedTrack[posFromV0] = kTRUE;
458
459 AliESDtrack *esdTrack = esd->GetTrack(posFromV0);
460 esdTrack->GetPxPyPz(p_pos);
461 esdTrack->GetXYZ(pos);
462 esdTrack->GetCovarianceXYZPxPyPz(covTr);
463 esdTrack->GetESDpid(pid);
464
465 vV0->AddDaughter(aodTrack =
466 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
467 esdTrack->GetLabel(),
468 p_pos,
469 kTRUE,
470 pos,
471 kFALSE,
472 covTr,
473 (Short_t)esdTrack->GetSign(),
474 esdTrack->GetITSClusterMap(),
475 pid,
476 vV0,
477 kTRUE, // check if this is right
478 kFALSE, // check if this is right
479 AliAODTrack::kSecondary)
480 );
481 aodTrack->ConvertAliPIDtoAODPID();
4fcd837c 482 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 483 }
484 else {
485// cerr << "Error: event " << esd->GetEventNumberInFile() << " V0 " << nV0
486// << " track " << posFromV0 << " has already been used!" << endl;
487 }
488
489 // Add the negative tracks from the V0
490
491 if (negFromV0>-1 && !usedTrack[negFromV0]) {
492
493 usedTrack[negFromV0] = kTRUE;
494
495 AliESDtrack *esdTrack = esd->GetTrack(negFromV0);
496 esdTrack->GetPxPyPz(p_neg);
497 esdTrack->GetXYZ(pos);
498 esdTrack->GetCovarianceXYZPxPyPz(covTr);
499 esdTrack->GetESDpid(pid);
500
501 vV0->AddDaughter(aodTrack =
502 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
503 esdTrack->GetLabel(),
504 p_neg,
505 kTRUE,
506 pos,
507 kFALSE,
508 covTr,
509 (Short_t)esdTrack->GetSign(),
510 esdTrack->GetITSClusterMap(),
511 pid,
512 vV0,
513 kTRUE, // check if this is right
514 kFALSE, // check if this is right
515 AliAODTrack::kSecondary)
516 );
517 aodTrack->ConvertAliPIDtoAODPID();
4fcd837c 518 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 519 }
520 else {
521// cerr << "Error: event " << esd->GetEventNumberInFile() << " V0 " << nV0
522// << " track " << negFromV0 << " has already been used!" << endl;
523 }
524
525 // add it to the V0 array as well
526 Double_t d0[2] = { 999., 99.};
527 new(V0s[jV0s++]) AliAODv0(vV0, 999., 99., p_pos, p_neg, d0); // to be refined
528 }
529 V0s.Expand(jV0s);
530 // end of the loop on V0s
531
532 // Kinks: it is a big mess the access to the information in the kinks
533 // The loop is on the tracks in order to find the mother and daugther of each kink
534
535
536 for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) {
537
538 AliESDtrack * esdTrack = esd->GetTrack(iTrack);
539
540 Int_t ikink = esdTrack->GetKinkIndex(0);
541
542 if (ikink && nKinks) {
543 // Negative kink index: mother, positive: daughter
544
545 // Search for the second track of the kink
546
547 for (Int_t jTrack = iTrack+1; jTrack<nTracks; ++jTrack) {
548
549 AliESDtrack * esdTrack1 = esd->GetTrack(jTrack);
550
551 Int_t jkink = esdTrack1->GetKinkIndex(0);
552
553 if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) {
554
555 // The two tracks are from the same kink
556
557 if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks
558
559 Int_t imother = -1;
560 Int_t idaughter = -1;
561
562 if (ikink<0 && jkink>0) {
563
564 imother = iTrack;
565 idaughter = jTrack;
566 }
567 else if (ikink>0 && jkink<0) {
568
569 imother = jTrack;
570 idaughter = iTrack;
571 }
572 else {
573// cerr << "Error: Wrong combination of kink indexes: "
574// << ikink << " " << jkink << endl;
575 continue;
576 }
577
578 // Add the mother track
579
580 AliAODTrack * mother = NULL;
581
582 if (!usedTrack[imother]) {
583
584 usedTrack[imother] = kTRUE;
585
586 AliESDtrack *esdTrack = esd->GetTrack(imother);
587 esdTrack->GetPxPyPz(p);
588 esdTrack->GetXYZ(pos);
589 esdTrack->GetCovarianceXYZPxPyPz(covTr);
590 esdTrack->GetESDpid(pid);
591
592 mother =
593 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
594 esdTrack->GetLabel(),
595 p,
596 kTRUE,
597 pos,
598 kFALSE,
599 covTr,
600 (Short_t)esdTrack->GetSign(),
601 esdTrack->GetITSClusterMap(),
602 pid,
603 primary,
604 kTRUE, // check if this is right
605 kTRUE, // check if this is right
606 AliAODTrack::kPrimary);
635ef56c 607 mother->SetFlags(esdTrack->GetStatus());
608 mother->ConvertAliPIDtoAODPID();
96b85d73 609 primary->AddDaughter(mother);
610 mother->ConvertAliPIDtoAODPID();
611 }
612 else {
613// cerr << "Error: event " << esd->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1
614// << " track " << imother << " has already been used!" << endl;
615 }
616
617 // Add the kink vertex
618 AliESDkink * kink = esd->GetKink(TMath::Abs(ikink)-1);
619
620 AliAODVertex * vkink =
621 new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(),
622 NULL,
623 0.,
624 mother,
625 esdTrack->GetID(), // This is the track ID of the mother's track!
626 AliAODVertex::kKink);
627 // Add the daughter track
628
629 AliAODTrack * daughter = NULL;
630
631 if (!usedTrack[idaughter]) {
632
633 usedTrack[idaughter] = kTRUE;
634
635 AliESDtrack *esdTrack = esd->GetTrack(idaughter);
636 esdTrack->GetPxPyPz(p);
637 esdTrack->GetXYZ(pos);
638 esdTrack->GetCovarianceXYZPxPyPz(covTr);
639 esdTrack->GetESDpid(pid);
640
641 daughter =
642 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
643 esdTrack->GetLabel(),
644 p,
645 kTRUE,
646 pos,
647 kFALSE,
648 covTr,
649 (Short_t)esdTrack->GetSign(),
650 esdTrack->GetITSClusterMap(),
651 pid,
652 vkink,
653 kTRUE, // check if this is right
654 kTRUE, // check if this is right
655 AliAODTrack::kPrimary);
635ef56c 656 daughter->SetFlags(esdTrack->GetStatus());
657 daughter->ConvertAliPIDtoAODPID();
96b85d73 658 vkink->AddDaughter(daughter);
659 daughter->ConvertAliPIDtoAODPID();
660 }
661 else {
662// cerr << "Error: event " << esd->GetEventNumberInFile() << " kink " << TMath::Abs(ikink)-1
663// << " track " << idaughter << " has already been used!" << endl;
664 }
665 }
666 }
667 }
668 }
669
670
671 // Tracks (primary and orphan)
672
673 printf("NUMBER OF TRACKS %5d\n", nTracks);
674
675 for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) {
676
677
678 if (usedTrack[nTrack]) continue;
679
680 AliESDtrack *esdTrack = esd->GetTrack(nTrack);
681 UInt_t selectInfo = 0;
682 //
683 // Track selection
684 if (fTrackFilter) {
685 selectInfo = fTrackFilter->IsSelected(esdTrack);
686 if (!selectInfo) continue;
687 }
688
689 //
690 esdTrack->GetPxPyPz(p);
691 esdTrack->GetXYZ(pos);
692 esdTrack->GetCovarianceXYZPxPyPz(covTr);
693 esdTrack->GetESDpid(pid);
694
695 Float_t impactXY, impactZ;
696
697 esdTrack->GetImpactParameters(impactXY,impactZ);
698
699 if (impactXY<3) {
700 // track inside the beam pipe
701
702 primary->AddDaughter(aodTrack =
703 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
704 esdTrack->GetLabel(),
705 p,
706 kTRUE,
707 pos,
708 kFALSE,
709 covTr,
710 (Short_t)esdTrack->GetSign(),
711 esdTrack->GetITSClusterMap(),
712 pid,
713 primary,
714 kTRUE, // check if this is right
715 kTRUE, // check if this is right
716 AliAODTrack::kPrimary,
717 selectInfo)
718 );
4fcd837c 719 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 720 aodTrack->ConvertAliPIDtoAODPID();
721 }
722 else {
723 // outside the beam pipe: orphan track
724 // Don't write them anymore!
725 continue;
726 /*
727 aodTrack =
728 new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(),
729 esdTrack->GetLabel(),
730 p,
731 kTRUE,
732 pos,
733 kFALSE,
734 covTr,
735 (Short_t)esdTrack->GetSign(),
736 esdTrack->GetITSClusterMap(),
737 pid,
738 NULL,
739 kFALSE, // check if this is right
740 kFALSE, // check if this is right
741 AliAODTrack::kOrphan,
742 selectInfo);
4fcd837c 743 aodTrack->SetFlags(esdTrack->GetStatus());
96b85d73 744 aodTrack->ConvertAliPIDtoAODPID();
745 */
746 }
747 } // end of loop on tracks
748
749 // muon tracks
750 Int_t nMuTracks = esd->GetNumberOfMuonTracks();
751 for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {
752
753 AliESDMuonTrack *esdMuTrack = esd->GetMuonTrack(nMuTrack);
754 p[0] = esdMuTrack->Px();
755 p[1] = esdMuTrack->Py();
756 p[2] = esdMuTrack->Pz();
757 pos[0] = primary->GetX();
758 pos[1] = primary->GetY();
759 pos[2] = primary->GetZ();
760
761 // has to be changed once the muon pid is provided by the ESD
762 for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.;
763
675123cb 764 primary->AddDaughter(aodTrack =
96b85d73 765 new(tracks[jTracks++]) AliAODTrack(0, // no ID provided
766 0, // no label provided
767 p,
768 kTRUE,
769 pos,
770 kFALSE,
771 NULL, // no covariance matrix provided
772 (Short_t)-99, // no charge provided
773 0, // no ITSClusterMap
774 pid,
775 primary,
776 kTRUE, // check if this is right
777 kTRUE, // not used for vertex fit
778 AliAODTrack::kPrimary)
779 );
780
4fcd837c 781 aodTrack->ConvertAliPIDtoAODPID();
96b85d73 782 aodTrack->SetHitsPatternInTrigCh(esdMuTrack->GetHitsPatternInTrigCh());
783 Int_t track2Trigger = esdMuTrack->GetMatchTrigger();
784 aodTrack->SetMatchTrigger(track2Trigger);
785 if (track2Trigger)
786 aodTrack->SetChi2MatchTrigger(esdMuTrack->GetChi2MatchTrigger());
787 else
788 aodTrack->SetChi2MatchTrigger(0.);
789 }
790 tracks.Expand(jTracks); // remove 'empty slots' due to unwritten tracks
791
792 // Access to the AOD container of PMD clusters
793 TClonesArray &pmdClusters = *(AODEvent()->GetPmdClusters());
794 Int_t jPmdClusters=0;
795
796 for (Int_t iPmd = 0; iPmd < nPmdClus; ++iPmd) {
797 // file pmd clusters, to be revised!
798 AliESDPmdTrack *pmdTrack = esd->GetPmdTrack(iPmd);
799 Int_t nLabel = 0;
800 Int_t *label = 0x0;
801 Double_t pos[3] = { pmdTrack->GetClusterX(), pmdTrack->GetClusterY(), pmdTrack->GetClusterZ() };
802 Double_t pid[9] = { 0., 0., 0., 0., 0., 0., 0., 0., 0. }; // to be revised!
803 // type not set!
804 // assoc cluster not set
805 new(pmdClusters[jPmdClusters++]) AliAODPmdCluster(iPmd, nLabel, label, pmdTrack->GetClusterADC(), pos, pid);
806 }
807
808 // Access to the AOD container of clusters
809 TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());
810 Int_t jClusters=0;
811
812 for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
813
814 AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust);
815
e6500713 816 Int_t id = cluster->GetID();
817 Int_t nLabel = cluster->GetNLabels();
818 TArrayI* labels = cluster->GetLabels();
819 Int_t *label = 0;
820 if (labels) label = (cluster->GetLabels())->GetArray();
821
96b85d73 822 Float_t energy = cluster->E();
823 cluster->GetPosition(posF);
e6500713 824 Char_t ttype = AliAODCluster::kUndef;
96b85d73 825
826 if (cluster->GetClusterType() == AliESDCaloCluster::kPHOSCluster) {
827 ttype=AliAODCluster::kPHOSNeutral;
828 }
829 else if (cluster->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1) {
830 ttype = AliAODCluster::kEMCALClusterv1;
831 }
832
833
834 AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) AliAODCaloCluster(id,
835 nLabel,
836 label,
837 energy,
838 pos,
839 NULL,
840 ttype);
841
e6500713 842 caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),
843 cluster->GetClusterDisp(),
78902954 844 cluster->GetM20(), cluster->GetM02(),
845 cluster->GetEmcCpvDistance(),
846 cluster->GetNExMax(),cluster->GetTOF()) ;
e6500713 847
848 caloCluster->SetNCells(cluster->GetNCells());
849 caloCluster->SetCellsAbsId(cluster->GetCellsAbsId());
850 caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction());
78902954 851
852 TArrayI* matchedT = cluster->GetTracksMatched();
853 if (matchedT) {
854 for (Int_t im = 0; im < matchedT->GetSize(); im++) {
855 caloCluster->AddTrackMatched((esd->GetTrack(im)));
856 }
857 }
858
96b85d73 859 }
860 caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters
861 // end of loop on calo clusters
862
863 // fill EMCAL cell info
864 if (esd->GetEMCALCells()) { // protection against missing ESD information
865 AliESDCaloCells &esdEMcells = *(esd->GetEMCALCells());
866 Int_t nEMcell = esdEMcells.GetNumberOfCells() ;
867
868 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
869 aodEMcells.CreateContainer(nEMcell);
870 aodEMcells.SetType(AliAODCaloCells::kEMCAL);
871 for (Int_t iCell = 0; iCell < nEMcell; iCell++) {
872 aodEMcells.SetCell(iCell,esdEMcells.GetCellNumber(iCell),esdEMcells.GetAmplitude(iCell));
873 }
874 aodEMcells.Sort();
875 }
876
877 // fill PHOS cell info
878 if (esd->GetPHOSCells()) { // protection against missing ESD information
879 AliESDCaloCells &esdPHcells = *(esd->GetPHOSCells());
880 Int_t nPHcell = esdPHcells.GetNumberOfCells() ;
881
882 AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells());
883 aodPHcells.CreateContainer(nPHcell);
884 aodPHcells.SetType(AliAODCaloCells::kPHOS);
885 for (Int_t iCell = 0; iCell < nPHcell; iCell++) {
886 aodPHcells.SetCell(iCell,esdPHcells.GetCellNumber(iCell),esdPHcells.GetAmplitude(iCell));
887 }
888 aodPHcells.Sort();
889 }
890
891 // tracklets
892 AliAODTracklets &SPDTracklets = *(AODEvent()->GetTracklets());
893 const AliMultiplicity *mult = esd->GetMultiplicity();
894 if (mult) {
895 if (mult->GetNumberOfTracklets()>0) {
896 SPDTracklets.CreateContainer(mult->GetNumberOfTracklets());
897
898 for (Int_t n=0; n<mult->GetNumberOfTracklets(); n++) {
0939e22a 899 SPDTracklets.SetTracklet(n, mult->GetTheta(n), mult->GetPhi(n), mult->GetDeltaPhi(n), mult->GetLabel(n, 0), mult->GetLabel(n, 1));
96b85d73 900 }
901 }
902 } else {
903 //Printf("ERROR: AliMultiplicity could not be retrieved from ESD");
904 }
905
906 delete [] usedTrack;
907 delete [] usedV0;
908 delete [] usedKink;
909
910 return;
911}
912
913void AliAnalysisTaskESDfilter::Terminate(Option_t */*option*/)
914{
915// Terminate analysis
916//
917 if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");
918}
919