- // Array to take into account the V0s already added to the AOD
- Bool_t * usedV0 = NULL;
- if (nV0s>0) {
- usedV0 = new Bool_t[nV0s];
- for (Int_t iV0=0; iV0<nV0s; ++iV0) usedV0[iV0]=kFALSE;
- }
-
- // Access to the AOD container of vertices
- TClonesArray &vertices = *(aod->GetVertices());
- Int_t jVertices=0;
-
- // Access to the AOD container of tracks
- TClonesArray &tracks = *(aod->GetTracks());
- Int_t jTracks=0;
-
- // Add primary vertex. The primary tracks will be defined
- // after the loops on the composite objects (V0, cascades, kinks)
- const AliESDVertex *vtx = esd->GetPrimaryVertex();
-
- Double_t pos[3];
- vtx->GetXYZ(pos); // position
- Double_t cov[6];
- vtx->GetCovMatrix(cov); //covariance matrix
-
- AliAODVertex * primary = new(vertices[jVertices++])
- AliAODVertex(pos, cov, vtx->GetChi2(), NULL, AliAODVertex::kPrimary);
-
- // Create vertices starting from the most complex objects
-
- // Cascades
- for (Int_t nCascade = 0; nCascade < nCascades; ++nCascade) {
- AliESDcascade *cascade = esd->GetCascade(nCascade);
-
- Double_t posXi[3];
- cascade->GetXYZ(posXi[0], posXi[1], posXi[2]);
- Double_t covXi[6];
- cascade->GetPosCovXi(covXi);
-
- // Add the cascade vertex
- AliAODVertex * vcascade = new(vertices[jVertices++]) AliAODVertex(posXi,
- covXi,
- cascade->GetChi2Xi(),
- primary,
- AliAODVertex::kCascade);
-
- primary->AddDaughter(vcascade);
-
- // Add the V0 from the cascade. The ESD class have to be optimized...
- // Now we have to search for the corresponding Vo in the list of V0s
- // using the indeces of the positive and negative tracks
-
- Int_t posFromV0 = cascade->GetPindex();
- Int_t negFromV0 = cascade->GetNindex();
-
-
- AliESDv0 * v0 = 0x0;
- Int_t indV0 = -1;
-
- for (Int_t iV0=0; iV0<nV0s; ++iV0) {
-
- v0 = esd->GetV0(iV0);
- Int_t pos = v0->GetPindex();
- Int_t neg = v0->GetNindex();
-
- if (pos==posFromV0 && neg==negFromV0) {
- indV0 = iV0;
- break;
- }
- }
-
- AliAODVertex * vV0FromCascade = 0x0;
-
- if (indV0>-1) {
-
- usedV0[indV0] = kTRUE;
-
- Double_t posV0[3];
- v0->GetXYZ(posV0[0], posV0[1], posV0[2]);
- Double_t covV0[6];
- v0->GetPosCov(covV0);
-
- vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(posV0,
- covV0,
- v0->GetChi2V0(),
- vcascade,
- AliAODVertex::kV0);
- } else {
-
- Double_t posV0[3];
- cascade->GetXYZ(posV0[0], posV0[1], posV0[2]);
- Double_t covV0[6];
- cascade->GetPosCov(covV0);
-
- vV0FromCascade = new(vertices[jVertices++]) AliAODVertex(posV0,
- covV0,
- v0->GetChi2V0(),
- vcascade,
- AliAODVertex::kV0);
- vcascade->AddDaughter(vV0FromCascade);
- }
-
- // Add the positive tracks from the V0
-
- usedTrack[posFromV0] = kTRUE;
- {
-
- AliESDtrack *esdTrack = esd->GetTrack(posFromV0);
-
- Double_t p[3];
- esdTrack->GetPxPyPz(p);
-
- Double_t x[3];
- esdTrack->GetXYZ(x);
-
- Double_t cov[21];
- esdTrack->GetCovarianceXYZPxPyPz(cov);