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