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