]>
Commit | Line | Data |
---|---|---|
e985a35a | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | ||
cf22b3fc | 3 | #include <Riostream.h> |
4 | #include <TFile.h> | |
5 | #include <TTree.h> | |
6 | #include <TMath.h> | |
df9db588 | 7 | |
8 | #include "AliAODEvent.h" | |
31fd97b2 | 9 | #include "AliAODHeader.h" |
cf22b3fc | 10 | #include "AliAODVertex.h" |
11 | #include "AliAODTrack.h" | |
a9255000 | 12 | #include "AliAODCluster.h" |
cf22b3fc | 13 | |
df9db588 | 14 | #include "AliESD.h" |
15 | #include "AliESDtrack.h" | |
200161ad | 16 | #include "AliESDMuonTrack.h" |
df9db588 | 17 | #include "AliESDVertex.h" |
18 | #include "AliESDv0.h" | |
31fd97b2 | 19 | #include "AliESDcascade.h" |
cf22b3fc | 20 | #include "AliESDCaloCluster.h" |
df9db588 | 21 | |
e985a35a | 22 | #endif |
23 | ||
cf22b3fc | 24 | void CreateAODfromESD(const char *inFileName = "AliESDs.root", |
25 | const char *outFileName = "AliAOD.root") { | |
df9db588 | 26 | |
27 | // create an AliAOD object | |
28 | AliAODEvent *aod = new AliAODEvent(); | |
29 | aod->CreateStdContent(); | |
30 | ||
31 | // open the file | |
32 | TFile *outFile = TFile::Open(outFileName, "RECREATE"); | |
33 | ||
34 | // create the tree | |
35 | TTree *aodTree = new TTree("AOD", "AliAOD tree"); | |
36 | aodTree->Branch(aod->GetList()); | |
37 | ||
38 | // connect to ESD | |
39 | TFile *inFile = TFile::Open(inFileName, "READ"); | |
40 | TTree *t = (TTree*) inFile->Get("esdTree"); | |
41 | TBranch *b = t->GetBranch("ESD"); | |
42 | AliESD *esd = 0; | |
43 | b->SetAddress(&esd); | |
44 | ||
45 | Int_t nEvents = b->GetEntries(); | |
46 | ||
9e2a7f16 | 47 | // set arrays and pointers |
48 | Float_t posF[3]; | |
49 | Double_t pos[3]; | |
50 | Double_t p[3]; | |
51 | Double_t covVtx[6]; | |
52 | Double_t covTr[21]; | |
53 | Double_t pid[10]; | |
54 | ||
df9db588 | 55 | // loop over events and fill them |
56 | for (Int_t iEvent = 0; iEvent < nEvents; ++iEvent) { | |
57 | b->GetEntry(iEvent); | |
58 | ||
59 | // Multiplicity information needed by the header (to be revised!) | |
60 | Int_t nTracks = esd->GetNumberOfTracks(); | |
61 | Int_t nPosTracks = 0; | |
62 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) | |
63 | if (esd->GetTrack(iTrack)->GetSign()> 0) nPosTracks++; | |
64 | ||
65 | // create the header | |
31fd97b2 | 66 | aod->AddHeader(new AliAODHeader(esd->GetRunNumber(), |
67 | esd->GetBunchCrossNumber(), | |
68 | esd->GetOrbitNumber(), | |
00946a1a | 69 | esd->GetPeriodNumber(), |
df9db588 | 70 | nTracks, |
71 | nPosTracks, | |
72 | nTracks-nPosTracks, | |
73 | esd->GetMagneticField(), | |
4773afc9 | 74 | -999., // fill muon magnetic field |
df9db588 | 75 | -999., // centrality; to be filled, still |
4773afc9 | 76 | esd->GetZDCN1Energy(), |
77 | esd->GetZDCP1Energy(), | |
78 | esd->GetZDCN2Energy(), | |
79 | esd->GetZDCP2Energy(), | |
80 | esd->GetZDCEMEnergy(), | |
df9db588 | 81 | esd->GetTriggerMask(), |
82 | esd->GetTriggerCluster(), | |
83 | esd->GetEventType())); | |
84 | ||
85 | Int_t nV0s = esd->GetNumberOfV0s(); | |
86 | Int_t nCascades = esd->GetNumberOfCascades(); | |
87 | Int_t nKinks = esd->GetNumberOfKinks(); | |
88 | Int_t nVertices = nV0s + nCascades + nKinks; | |
89 | ||
90 | aod->ResetStd(nTracks, nVertices); | |
9e2a7f16 | 91 | AliAODTrack *aodTrack; |
df9db588 | 92 | |
93 | ||
94 | // Array to take into account the tracks already added to the AOD | |
95 | Bool_t * usedTrack = NULL; | |
96 | if (nTracks>0) { | |
97 | usedTrack = new Bool_t[nTracks]; | |
98 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) usedTrack[iTrack]=kFALSE; | |
99 | } | |
100 | // Array to take into account the V0s already added to the AOD | |
101 | Bool_t * usedV0 = NULL; | |
102 | if (nV0s>0) { | |
103 | usedV0 = new Bool_t[nV0s]; | |
104 | for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE; | |
105 | } | |
cf22b3fc | 106 | // Array to take into account the kinks already added to the AOD |
107 | Bool_t * usedKink = NULL; | |
108 | if (nKinks>0) { | |
109 | usedKink = new Bool_t[nKinks]; | |
110 | for (Int_t iKink=0; iKink<nKinks; ++iKink) usedKink[iKink]=kFALSE; | |
111 | } | |
df9db588 | 112 | |
113 | // Access to the AOD container of vertices | |
114 | TClonesArray &vertices = *(aod->GetVertices()); | |
115 | Int_t jVertices=0; | |
116 | ||
117 | // Access to the AOD container of tracks | |
118 | TClonesArray &tracks = *(aod->GetTracks()); | |
119 | Int_t jTracks=0; | |
120 | ||
121 | // Add primary vertex. The primary tracks will be defined | |
122 | // after the loops on the composite objects (V0, cascades, kinks) | |
123 | const AliESDVertex *vtx = esd->GetPrimaryVertex(); | |
124 | ||
df9db588 | 125 | vtx->GetXYZ(pos); // position |
31fd97b2 | 126 | vtx->GetCovMatrix(covVtx); //covariance matrix |
df9db588 | 127 | |
128 | AliAODVertex * primary = new(vertices[jVertices++]) | |
00946a1a | 129 | AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, AliAODVertex::kPrimary); |
df9db588 | 130 | |
131 | // Create vertices starting from the most complex objects | |
132 | ||
133 | // Cascades | |
134 | for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) { | |
135 | AliESDcascade *cascade = esd->GetCascade(nCascade); | |
136 | ||
9e2a7f16 | 137 | cascade->GetXYZ(pos[0], pos[1], pos[2]); |
138 | cascade->GetPosCovXi(covVtx); | |
df9db588 | 139 | |
140 | // Add the cascade vertex | |
9e2a7f16 | 141 | AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(pos, |
142 | covVtx, | |
00946a1a | 143 | cascade->GetChi2Xi(), // = chi2/NDF since NDF = 2*2-3 |
df9db588 | 144 | primary, |
145 | AliAODVertex::kCascade); | |
146 | ||
147 | primary->AddDaughter(vcascade); | |
148 | ||
149 | // Add the V0 from the cascade. The ESD class have to be optimized... | |
150 | // Now we have to search for the corresponding Vo in the list of V0s | |
151 | // using the indeces of the positive and negative tracks | |
152 | ||
153 | Int_t posFromV0 = cascade->GetPindex(); | |
154 | Int_t negFromV0 = cascade->GetNindex(); | |
155 | ||
156 | ||
157 | AliESDv0 * v0 = 0x0; | |
158 | Int_t indV0 = -1; | |
159 | ||
160 | for (Int_t iV0=0; iV0<nV0s; ++iV0) { | |
161 | ||
162 | v0 = esd->GetV0(iV0); | |
31fd97b2 | 163 | Int_t posV0 = v0->GetPindex(); |
164 | Int_t negV0 = v0->GetNindex(); | |
df9db588 | 165 | |
31fd97b2 | 166 | if (posV0==posFromV0 && negV0==negFromV0) { |
df9db588 | 167 | indV0 = iV0; |
168 | break; | |
169 | } | |
170 | } | |
171 | ||
172 | AliAODVertex * vV0FromCascade = 0x0; | |
173 | ||
cf22b3fc | 174 | if (indV0>-1 && !usedV0[indV0] ) { |
df9db588 | 175 | |
cf22b3fc | 176 | // the V0 exists in the array of V0s and is not used |
177 | ||
df9db588 | 178 | usedV0[indV0] = kTRUE; |
179 | ||
9e2a7f16 | 180 | v0->GetXYZ(pos[0], pos[1], pos[2]); |
181 | v0->GetPosCov(covVtx); | |
cf22b3fc | 182 | |
9e2a7f16 | 183 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, |
184 | covVtx, | |
00946a1a | 185 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 |
df9db588 | 186 | vcascade, |
187 | AliAODVertex::kV0); | |
188 | } else { | |
189 | ||
cf22b3fc | 190 | // the V0 doesn't exist in the array of V0s or was used |
191 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
192 | << " The V0 " << indV0 | |
193 | << " doesn't exist in the array of V0s or was used!" << endl; | |
194 | ||
9e2a7f16 | 195 | cascade->GetXYZ(pos[0], pos[1], pos[2]); |
196 | cascade->GetPosCov(covVtx); | |
df9db588 | 197 | |
9e2a7f16 | 198 | vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(pos, |
199 | covVtx, | |
00946a1a | 200 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 |
df9db588 | 201 | vcascade, |
202 | AliAODVertex::kV0); | |
203 | vcascade->AddDaughter(vV0FromCascade); | |
204 | } | |
205 | ||
206 | // Add the positive tracks from the V0 | |
207 | ||
cf22b3fc | 208 | if (! usedTrack[posFromV0]) { |
209 | ||
210 | usedTrack[posFromV0] = kTRUE; | |
df9db588 | 211 | |
212 | AliESDtrack *esdTrack = esd->GetTrack(posFromV0); | |
9e2a7f16 | 213 | esdTrack->GetPxPyPz(p); |
214 | esdTrack->GetXYZ(pos); | |
215 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
216 | esdTrack->GetESDpid(pid); | |
cf22b3fc | 217 | |
9e2a7f16 | 218 | vV0FromCascade->AddDaughter(aodTrack = |
cf22b3fc | 219 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
df9db588 | 220 | esdTrack->GetLabel(), |
9e2a7f16 | 221 | p, |
31fd97b2 | 222 | kTRUE, |
9e2a7f16 | 223 | pos, |
df9db588 | 224 | kFALSE, |
9e2a7f16 | 225 | covTr, |
df9db588 | 226 | (Short_t)esdTrack->GetSign(), |
227 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 228 | pid, |
df9db588 | 229 | vV0FromCascade, |
00946a1a | 230 | kTRUE, // check if this is right |
4773afc9 | 231 | kFALSE, // check if this is right |
df9db588 | 232 | AliAODTrack::kSecondary) |
233 | ); | |
9e2a7f16 | 234 | aodTrack->ConvertAliPIDtoAODPID(); |
df9db588 | 235 | } |
cf22b3fc | 236 | else { |
237 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
238 | << " track " << posFromV0 << " has already been used!" << endl; | |
239 | } | |
df9db588 | 240 | |
241 | // Add the negative tracks from the V0 | |
242 | ||
cf22b3fc | 243 | if (!usedTrack[negFromV0]) { |
244 | ||
245 | usedTrack[negFromV0] = kTRUE; | |
246 | ||
df9db588 | 247 | AliESDtrack *esdTrack = esd->GetTrack(negFromV0); |
9e2a7f16 | 248 | esdTrack->GetPxPyPz(p); |
249 | esdTrack->GetXYZ(pos); | |
250 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
251 | esdTrack->GetESDpid(pid); | |
cf22b3fc | 252 | |
9e2a7f16 | 253 | vV0FromCascade->AddDaughter(aodTrack = |
df9db588 | 254 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
255 | esdTrack->GetLabel(), | |
9e2a7f16 | 256 | p, |
df9db588 | 257 | kTRUE, |
9e2a7f16 | 258 | pos, |
df9db588 | 259 | kFALSE, |
9e2a7f16 | 260 | covTr, |
df9db588 | 261 | (Short_t)esdTrack->GetSign(), |
262 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 263 | pid, |
df9db588 | 264 | vV0FromCascade, |
00946a1a | 265 | kTRUE, // check if this is right |
4773afc9 | 266 | kFALSE, // check if this is right |
df9db588 | 267 | AliAODTrack::kSecondary) |
268 | ); | |
9e2a7f16 | 269 | aodTrack->ConvertAliPIDtoAODPID(); |
df9db588 | 270 | } |
cf22b3fc | 271 | else { |
272 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
273 | << " track " << negFromV0 << " has already been used!" << endl; | |
274 | } | |
df9db588 | 275 | |
276 | // Add the bachelor track from the cascade | |
277 | ||
278 | Int_t bachelor = cascade->GetBindex(); | |
df9db588 | 279 | |
cf22b3fc | 280 | if(!usedTrack[bachelor]) { |
281 | ||
282 | usedTrack[bachelor] = kTRUE; | |
283 | ||
284 | AliESDtrack *esdTrack = esd->GetTrack(bachelor); | |
9e2a7f16 | 285 | esdTrack->GetPxPyPz(p); |
286 | esdTrack->GetXYZ(pos); | |
287 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
288 | esdTrack->GetESDpid(pid); | |
df9db588 | 289 | |
9e2a7f16 | 290 | vcascade->AddDaughter(aodTrack = |
df9db588 | 291 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
292 | esdTrack->GetLabel(), | |
9e2a7f16 | 293 | p, |
df9db588 | 294 | kTRUE, |
9e2a7f16 | 295 | pos, |
df9db588 | 296 | kFALSE, |
9e2a7f16 | 297 | covTr, |
df9db588 | 298 | (Short_t)esdTrack->GetSign(), |
299 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 300 | pid, |
df9db588 | 301 | vcascade, |
00946a1a | 302 | kTRUE, // check if this is right |
4773afc9 | 303 | kFALSE, // check if this is right |
df9db588 | 304 | AliAODTrack::kSecondary) |
305 | ); | |
9e2a7f16 | 306 | aodTrack->ConvertAliPIDtoAODPID(); |
200161ad | 307 | } |
cf22b3fc | 308 | else { |
309 | cerr << "Error: event " << iEvent << " cascade " << nCascade | |
310 | << " track " << bachelor << " has already been used!" << endl; | |
311 | } | |
df9db588 | 312 | |
313 | // Add the primary track of the cascade (if any) | |
314 | ||
cf22b3fc | 315 | } // end of the loop on cascades |
df9db588 | 316 | |
317 | // V0s | |
318 | ||
319 | for (Int_t nV0 = 0; nV0 < nV0s; ++nV0) { | |
320 | ||
321 | if (usedV0[nV0]) continue; // skip if aready added to the AOD | |
322 | ||
323 | AliESDv0 *v0 = esd->GetV0(nV0); | |
324 | ||
9e2a7f16 | 325 | v0->GetXYZ(pos[0], pos[1], pos[2]); |
326 | v0->GetPosCov(covVtx); | |
df9db588 | 327 | |
328 | AliAODVertex * vV0 = | |
9e2a7f16 | 329 | new(vertices[jVertices++]) AliAODVertex(pos, |
330 | covVtx, | |
00946a1a | 331 | v0->GetChi2V0(), // = chi2/NDF since NDF = 2*2-3 |
df9db588 | 332 | primary, |
333 | AliAODVertex::kV0); | |
334 | primary->AddDaughter(vV0); | |
335 | ||
336 | Int_t posFromV0 = v0->GetPindex(); | |
337 | Int_t negFromV0 = v0->GetNindex(); | |
31fd97b2 | 338 | |
df9db588 | 339 | // Add the positive tracks from the V0 |
340 | ||
cf22b3fc | 341 | if (!usedTrack[posFromV0]) { |
342 | ||
343 | usedTrack[posFromV0] = kTRUE; | |
df9db588 | 344 | |
345 | AliESDtrack *esdTrack = esd->GetTrack(posFromV0); | |
9e2a7f16 | 346 | esdTrack->GetPxPyPz(p); |
347 | esdTrack->GetXYZ(pos); | |
348 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
349 | esdTrack->GetESDpid(pid); | |
df9db588 | 350 | |
9e2a7f16 | 351 | vV0->AddDaughter(aodTrack = |
df9db588 | 352 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
353 | esdTrack->GetLabel(), | |
9e2a7f16 | 354 | p, |
31fd97b2 | 355 | kTRUE, |
9e2a7f16 | 356 | pos, |
df9db588 | 357 | kFALSE, |
9e2a7f16 | 358 | covTr, |
df9db588 | 359 | (Short_t)esdTrack->GetSign(), |
360 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 361 | pid, |
df9db588 | 362 | vV0, |
00946a1a | 363 | kTRUE, // check if this is right |
4773afc9 | 364 | kFALSE, // check if this is right |
df9db588 | 365 | AliAODTrack::kSecondary) |
366 | ); | |
9e2a7f16 | 367 | aodTrack->ConvertAliPIDtoAODPID(); |
df9db588 | 368 | } |
cf22b3fc | 369 | else { |
370 | cerr << "Error: event " << iEvent << " V0 " << nV0 | |
371 | << " track " << posFromV0 << " has already been used!" << endl; | |
372 | } | |
df9db588 | 373 | |
374 | // Add the negative tracks from the V0 | |
375 | ||
cf22b3fc | 376 | if (!usedTrack[negFromV0]) { |
377 | ||
378 | usedTrack[negFromV0] = kTRUE; | |
df9db588 | 379 | |
380 | AliESDtrack *esdTrack = esd->GetTrack(negFromV0); | |
9e2a7f16 | 381 | esdTrack->GetPxPyPz(p); |
382 | esdTrack->GetXYZ(pos); | |
383 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
384 | esdTrack->GetESDpid(pid); | |
df9db588 | 385 | |
9e2a7f16 | 386 | vV0->AddDaughter(aodTrack = |
df9db588 | 387 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
388 | esdTrack->GetLabel(), | |
9e2a7f16 | 389 | p, |
df9db588 | 390 | kTRUE, |
9e2a7f16 | 391 | pos, |
df9db588 | 392 | kFALSE, |
9e2a7f16 | 393 | covTr, |
df9db588 | 394 | (Short_t)esdTrack->GetSign(), |
395 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 396 | pid, |
df9db588 | 397 | vV0, |
00946a1a | 398 | kTRUE, // check if this is right |
4773afc9 | 399 | kFALSE, // check if this is right |
df9db588 | 400 | AliAODTrack::kSecondary) |
401 | ); | |
9e2a7f16 | 402 | aodTrack->ConvertAliPIDtoAODPID(); |
df9db588 | 403 | } |
cf22b3fc | 404 | else { |
405 | cerr << "Error: event " << iEvent << " V0 " << nV0 | |
406 | << " track " << negFromV0 << " has already been used!" << endl; | |
407 | } | |
df9db588 | 408 | |
cf22b3fc | 409 | } // end of the loop on V0s |
df9db588 | 410 | |
cf22b3fc | 411 | // Kinks: it is a big mess the access to the information in the kinks |
412 | // The loop is on the tracks in order to find the mother and daugther of each kink | |
413 | ||
414 | ||
415 | for (Int_t iTrack=0; iTrack<nTracks; ++iTrack) { | |
416 | ||
417 | ||
9e2a7f16 | 418 | AliESDtrack * esdTrack = esd->GetTrack(iTrack); |
cf22b3fc | 419 | |
9e2a7f16 | 420 | Int_t ikink = esdTrack->GetKinkIndex(0); |
cf22b3fc | 421 | |
422 | if (ikink) { | |
423 | // Negative kink index: mother, positive: daughter | |
424 | ||
425 | // Search for the second track of the kink | |
426 | ||
427 | for (Int_t jTrack = iTrack+1; jTrack<nTracks; ++jTrack) { | |
428 | ||
9e2a7f16 | 429 | AliESDtrack * esdTrack1 = esd->GetTrack(jTrack); |
cf22b3fc | 430 | |
9e2a7f16 | 431 | Int_t jkink = esdTrack1->GetKinkIndex(0); |
cf22b3fc | 432 | |
433 | if ( TMath::Abs(ikink)==TMath::Abs(jkink) ) { | |
434 | ||
435 | // The two tracks are from the same kink | |
436 | ||
437 | if (usedKink[TMath::Abs(ikink)-1]) continue; // skip used kinks | |
438 | ||
439 | Int_t imother = -1; | |
440 | Int_t idaughter = -1; | |
441 | ||
442 | if (ikink<0 && jkink>0) { | |
443 | ||
444 | imother = iTrack; | |
445 | idaughter = jTrack; | |
446 | } | |
447 | else if (ikink>0 && jkink<0) { | |
448 | ||
449 | imother = jTrack; | |
450 | idaughter = iTrack; | |
451 | } | |
452 | else { | |
453 | cerr << "Error: Wrong combination of kink indexes: " | |
454 | << ikink << " " << jkink << endl; | |
455 | continue; | |
456 | } | |
457 | ||
458 | // Add the mother track | |
459 | ||
460 | AliAODTrack * mother = NULL; | |
461 | ||
462 | if (!usedTrack[imother]) { | |
463 | ||
464 | usedTrack[imother] = kTRUE; | |
465 | ||
466 | AliESDtrack *esdTrack = esd->GetTrack(imother); | |
9e2a7f16 | 467 | esdTrack->GetPxPyPz(p); |
468 | esdTrack->GetXYZ(pos); | |
469 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
470 | esdTrack->GetESDpid(pid); | |
31fd97b2 | 471 | |
cf22b3fc | 472 | mother = |
473 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
474 | esdTrack->GetLabel(), | |
9e2a7f16 | 475 | p, |
cf22b3fc | 476 | kTRUE, |
9e2a7f16 | 477 | pos, |
cf22b3fc | 478 | kFALSE, |
9e2a7f16 | 479 | covTr, |
cf22b3fc | 480 | (Short_t)esdTrack->GetSign(), |
481 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 482 | pid, |
cf22b3fc | 483 | primary, |
4773afc9 | 484 | kTRUE, // check if this is right |
00946a1a | 485 | kTRUE, // check if this is right |
cf22b3fc | 486 | AliAODTrack::kPrimary); |
487 | primary->AddDaughter(mother); | |
200161ad | 488 | mother->ConvertAliPIDtoAODPID(); |
cf22b3fc | 489 | } |
490 | else { | |
491 | cerr << "Error: event " << iEvent << " kink " << TMath::Abs(ikink)-1 | |
492 | << " track " << imother << " has already been used!" << endl; | |
493 | } | |
494 | ||
495 | // Add the kink vertex | |
496 | AliESDkink * kink = esd->GetKink(TMath::Abs(ikink)-1); | |
497 | ||
498 | AliAODVertex * vkink = | |
499 | new(vertices[jVertices++]) AliAODVertex(kink->GetPosition(), | |
500 | NULL, | |
501 | 0., | |
502 | mother, | |
503 | AliAODVertex::kKink); | |
504 | // Add the daughter track | |
505 | ||
506 | AliAODTrack * daughter = NULL; | |
507 | ||
508 | if (!usedTrack[idaughter]) { | |
509 | ||
510 | usedTrack[idaughter] = kTRUE; | |
511 | ||
512 | AliESDtrack *esdTrack = esd->GetTrack(idaughter); | |
9e2a7f16 | 513 | esdTrack->GetPxPyPz(p); |
514 | esdTrack->GetXYZ(pos); | |
515 | esdTrack->GetCovarianceXYZPxPyPz(covTr); | |
516 | esdTrack->GetESDpid(pid); | |
31fd97b2 | 517 | |
cf22b3fc | 518 | daughter = |
519 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), | |
520 | esdTrack->GetLabel(), | |
9e2a7f16 | 521 | p, |
cf22b3fc | 522 | kTRUE, |
9e2a7f16 | 523 | pos, |
cf22b3fc | 524 | kFALSE, |
9e2a7f16 | 525 | covTr, |
cf22b3fc | 526 | (Short_t)esdTrack->GetSign(), |
527 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 528 | pid, |
cf22b3fc | 529 | vkink, |
4773afc9 | 530 | kTRUE, // check if this is right |
00946a1a | 531 | kTRUE, // check if this is right |
cf22b3fc | 532 | AliAODTrack::kPrimary); |
533 | vkink->AddDaughter(daughter); | |
200161ad | 534 | daughter->ConvertAliPIDtoAODPID(); |
cf22b3fc | 535 | } |
536 | else { | |
537 | cerr << "Error: event " << iEvent << " kink " << TMath::Abs(ikink)-1 | |
538 | << " track " << idaughter << " has already been used!" << endl; | |
539 | } | |
540 | ||
541 | ||
542 | } | |
543 | } | |
544 | ||
545 | } | |
df9db588 | 546 | |
df9db588 | 547 | } |
cf22b3fc | 548 | |
df9db588 | 549 | |
cf22b3fc | 550 | // Tracks (primary and orphan) |
df9db588 | 551 | |
552 | for (Int_t nTrack = 0; nTrack < nTracks; ++nTrack) { | |
553 | ||
554 | ||
555 | if (usedTrack[nTrack]) continue; | |
556 | ||
557 | AliESDtrack *esdTrack = esd->GetTrack(nTrack); | |
9e2a7f16 | 558 | esdTrack->GetPxPyPz(p); |
559 | esdTrack->GetXYZ(pos); | |
31fd97b2 | 560 | esdTrack->GetCovarianceXYZPxPyPz(covTr); |
9e2a7f16 | 561 | esdTrack->GetESDpid(pid); |
cf22b3fc | 562 | |
563 | Float_t impactXY, impactZ; | |
564 | ||
565 | esdTrack->GetImpactParameters(impactXY,impactZ); | |
566 | ||
567 | if (impactXY<3) { | |
568 | // track inside the beam pipe | |
df9db588 | 569 | |
9e2a7f16 | 570 | primary->AddDaughter(aodTrack = |
cf22b3fc | 571 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
df9db588 | 572 | esdTrack->GetLabel(), |
9e2a7f16 | 573 | p, |
df9db588 | 574 | kTRUE, |
9e2a7f16 | 575 | pos, |
df9db588 | 576 | kFALSE, |
31fd97b2 | 577 | covTr, |
df9db588 | 578 | (Short_t)esdTrack->GetSign(), |
579 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 580 | pid, |
df9db588 | 581 | primary, |
4773afc9 | 582 | kTRUE, // check if this is right |
00946a1a | 583 | kTRUE, // check if this is right |
df9db588 | 584 | AliAODTrack::kPrimary) |
cf22b3fc | 585 | ); |
9e2a7f16 | 586 | aodTrack->ConvertAliPIDtoAODPID(); |
cf22b3fc | 587 | } |
588 | else { | |
589 | // outside the beam pipe: orphan track | |
9e2a7f16 | 590 | aodTrack = |
cf22b3fc | 591 | new(tracks[jTracks++]) AliAODTrack(esdTrack->GetID(), |
592 | esdTrack->GetLabel(), | |
9e2a7f16 | 593 | p, |
cf22b3fc | 594 | kTRUE, |
9e2a7f16 | 595 | pos, |
cf22b3fc | 596 | kFALSE, |
31fd97b2 | 597 | covTr, |
cf22b3fc | 598 | (Short_t)esdTrack->GetSign(), |
599 | esdTrack->GetITSClusterMap(), | |
9e2a7f16 | 600 | pid, |
cf22b3fc | 601 | NULL, |
4773afc9 | 602 | kFALSE, // check if this is right |
00946a1a | 603 | kFALSE, // check if this is right |
cf22b3fc | 604 | AliAODTrack::kOrphan); |
9e2a7f16 | 605 | aodTrack->ConvertAliPIDtoAODPID(); |
cf22b3fc | 606 | } |
607 | } // end of loop on tracks | |
608 | ||
200161ad | 609 | // muon tracks |
610 | Int_t nMuTracks = esd->GetNumberOfMuonTracks(); | |
611 | for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) { | |
612 | ||
9e2a7f16 | 613 | AliESDMuonTrack *esdMuTrack = esd->GetMuonTrack(nMuTrack); |
614 | p[0] = esdMuTrack->Px(); | |
615 | p[1] = esdMuTrack->Py(); | |
616 | p[2] = esdMuTrack->Pz(); | |
617 | pos[0] = primary->GetX(); | |
618 | pos[1] = primary->GetY(); | |
619 | pos[2] = primary->GetZ(); | |
200161ad | 620 | |
9e2a7f16 | 621 | // has to be changed once the muon pid is provided by the ESD |
622 | for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.; | |
200161ad | 623 | |
624 | primary->AddDaughter( | |
625 | new(tracks[jTracks++]) AliAODTrack(0, // no ID provided | |
626 | 0, // no label provided | |
9e2a7f16 | 627 | p, |
200161ad | 628 | kTRUE, |
9e2a7f16 | 629 | pos, |
200161ad | 630 | kFALSE, |
9e2a7f16 | 631 | NULL, // no covariance matrix provided |
200161ad | 632 | (Short_t)-99, // no charge provided |
633 | 0, // no ITSClusterMap | |
9e2a7f16 | 634 | pid, |
200161ad | 635 | primary, |
00946a1a | 636 | kTRUE, // check if this is right |
637 | kTRUE, // not used for vertex fit | |
200161ad | 638 | AliAODTrack::kPrimary) |
639 | ); | |
640 | } | |
641 | ||
4773afc9 | 642 | // Access to the AOD container of clusters |
a9255000 | 643 | TClonesArray &clusters = *(aod->GetClusters()); |
cf22b3fc | 644 | Int_t jClusters=0; |
645 | ||
4773afc9 | 646 | // Calo Clusters |
cf22b3fc | 647 | Int_t nClusters = esd->GetNumberOfCaloClusters(); |
648 | ||
649 | for (Int_t iClust=0; iClust<nClusters; ++iClust) { | |
650 | ||
651 | AliESDCaloCluster * cluster = esd->GetCaloCluster(iClust); | |
652 | ||
653 | Int_t id = cluster->GetID(); | |
654 | Int_t label = -1; | |
655 | Float_t energy = cluster->GetClusterEnergy(); | |
9e2a7f16 | 656 | cluster->GetGlobalPosition(posF); |
cf22b3fc | 657 | AliAODVertex *prodVertex = primary; |
658 | AliAODTrack *primTrack = NULL; | |
a9255000 | 659 | Char_t ttype=AliAODCluster::kUndef; |
cf22b3fc | 660 | |
a9255000 | 661 | if (cluster->IsPHOS()) ttype=AliAODCluster::kPHOSNeutral; |
cf22b3fc | 662 | else if (cluster->IsEMCAL()) { |
663 | ||
664 | if (cluster->GetClusterType() == AliESDCaloCluster::kPseudoCluster) | |
a9255000 | 665 | ttype = AliAODCluster::kEMCALPseudoCluster; |
cf22b3fc | 666 | else |
a9255000 | 667 | ttype = AliAODCluster::kEMCALClusterv1; |
cf22b3fc | 668 | |
669 | } | |
df9db588 | 670 | |
a9255000 | 671 | new(clusters[jClusters++]) AliAODCluster(id, |
cf22b3fc | 672 | label, |
673 | energy, | |
9e2a7f16 | 674 | pos, |
675 | NULL, // no covariance matrix provided | |
676 | NULL, // no pid for clusters provided | |
cf22b3fc | 677 | prodVertex, |
678 | primTrack, | |
679 | ttype); | |
680 | ||
4773afc9 | 681 | } // end of loop on calo clusters |
cf22b3fc | 682 | |
cf22b3fc | 683 | delete [] usedTrack; |
684 | delete [] usedV0; | |
685 | delete [] usedKink; | |
686 | ||
df9db588 | 687 | // fill the tree for this event |
688 | aodTree->Fill(); | |
cf22b3fc | 689 | } // end of event loop |
df9db588 | 690 | |
691 | aodTree->GetUserInfo()->Add(aod); | |
692 | ||
693 | // close ESD file | |
694 | inFile->Close(); | |
695 | ||
696 | // write the tree to the specified file | |
697 | outFile = aodTree->GetCurrentFile(); | |
698 | outFile->cd(); | |
699 | aodTree->Write(); | |
700 | outFile->Close(); | |
701 | ||
702 | } |