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