//-----------------------------------------------------------------
#include "TList.h"
+#include "TRefArray.h"
#include <TNamed.h>
+#include "AliLog.h"
#include "AliESDEvent.h"
#include "AliESDfriend.h"
#include "AliESDVZERO.h"
if(fESDTZERO) fESDTZERO->Reset();
// CKB no clear/reset implemented
if(fSPDVertex){
+ fSPDVertex->~AliESDVertex();
new (fSPDVertex) AliESDVertex();
fSPDVertex->SetName(fESDListName[kSPDVertex]);
}
if(fPrimaryVertex){
+ fPrimaryVertex->~AliESDVertex();
new (fPrimaryVertex) AliESDVertex();
fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
}
- if(fSPDMult)new (fSPDMult) AliMultiplicity();
+ if(fSPDMult){
+ fSPDMult->~AliMultiplicity();
+ new (fSPDMult) AliMultiplicity();
+ }
if(fPHOSTrigger)fPHOSTrigger->Reset();
if(fEMCALTrigger)fEMCALTrigger->Reset();
- if(fTracks)fTracks->Clear();
+ if(fTracks)fTracks->Delete();
if(fMuonTracks)fMuonTracks->Clear();
if(fPmdTracks)fPmdTracks->Clear();
if(fTrdTracks)fTrdTracks->Clear();
if(fV0s)fV0s->Clear();
if(fCascades)fCascades->Clear();
if(fKinks)fKinks->Clear();
- if(fCaloClusters)fCaloClusters->Clear();
- if(fErrorLogs) fErrorLogs->Clear();
+ if(fCaloClusters)fCaloClusters->Delete();
+ if(fErrorLogs) fErrorLogs->Delete();
// don't reset fconnected fConnected ;
}
}
-Bool_t AliESDEvent::RemoveTrack(Int_t /*i*/) {
+Bool_t AliESDEvent::RemoveKink(Int_t rm) {
+ // ---------------------------------------------------------
+ // Remove a kink candidate and references to it from ESD,
+ // if this candidate does not come from a reconstructed decay
+ // Not yet implemented...
+ // ---------------------------------------------------------
+ Int_t last=GetNumberOfKinks()-1;
+ if ((rm<0)||(rm>last)) return kFALSE;
+
+ return kTRUE;
+}
+
+Bool_t AliESDEvent::RemoveV0(Int_t rm) {
+ // ---------------------------------------------------------
+ // Remove a V0 candidate and references to it from ESD,
+ // if this candidate does not come from a reconstructed decay
+ // ---------------------------------------------------------
+ Int_t last=GetNumberOfV0s()-1;
+ if ((rm<0)||(rm>last)) return kFALSE;
+
+ AliESDv0 *v0=GetV0(rm);
+ Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex();
+
+ v0=GetV0(last);
+ Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex();
+
+ Int_t used=0;
+
+ // Check if this V0 comes from a reconstructed decay
+ Int_t ncs=GetNumberOfCascades();
+ for (Int_t n=0; n<ncs; n++) {
+ AliESDcascade *cs=GetCascade(n);
+
+ Int_t csIdxP=cs->GetPindex();
+ Int_t csIdxN=cs->GetNindex();
+
+ if (idxP==csIdxP)
+ if (idxN==csIdxN) return kFALSE;
+
+ if (csIdxP==lastIdxP)
+ if (csIdxN==lastIdxN) used++;
+ }
+
+ //Replace the removed V0 with the last V0
+ TClonesArray &a=*fV0s;
+ delete a.RemoveAt(rm);
+
+ if (rm==last) return kTRUE;
+
+ //v0 is pointing to the last V0 candidate...
+ new (a[rm]) AliESDv0(*v0);
+ delete a.RemoveAt(last);
+
+ if (!used) return kTRUE;
+
+
+ // Remap the indices of the daughters of reconstructed decays
+ for (Int_t n=0; n<ncs; n++) {
+ AliESDcascade *cs=GetCascade(n);
+
+
+ Int_t csIdxP=cs->GetPindex();
+ Int_t csIdxN=cs->GetNindex();
+
+ if (csIdxP==lastIdxP)
+ if (csIdxN==lastIdxN) {
+ cs->AliESDv0::SetIndex(1,idxP);
+ cs->AliESDv0::SetIndex(0,idxN);
+ used--;
+ if (!used) return kTRUE;
+ }
+ }
+
+ return kTRUE;
+}
+
+Bool_t AliESDEvent::RemoveTrack(Int_t rm) {
// ---------------------------------------------------------
- // Remove track
+ // Remove a track and references to it from ESD,
+ // if this track does not come from a reconstructed decay
// ---------------------------------------------------------
+ Int_t last=GetNumberOfTracks()-1;
+ if ((rm<0)||(rm>last)) return kFALSE;
+
+ Int_t used=0;
// Check if this track comes from a reconstructed decay
- // if (yes) return kFALSE
+ Int_t nv0=GetNumberOfV0s();
+ for (Int_t n=0; n<nv0; n++) {
+ AliESDv0 *v0=GetV0(n);
+
+ Int_t idx=v0->GetNindex();
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+
+ idx=v0->GetPindex();
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+ }
+
+ Int_t ncs=GetNumberOfCascades();
+ for (Int_t n=0; n<ncs; n++) {
+ AliESDcascade *cs=GetCascade(n);
+
+ Int_t idx=cs->GetIndex();
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+ }
+
+ Int_t nkn=GetNumberOfKinks();
+ for (Int_t n=0; n<nkn; n++) {
+ AliESDkink *kn=GetKink(n);
- // Remap the indices of the daughters of recosntructed decays
+ Int_t idx=kn->GetIndex(0);
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+
+ idx=kn->GetIndex(1);
+ if (rm==idx) return kFALSE;
+ if (idx==last) used++;
+ }
- // Remove the track
- // delete fTracks->RemoveAt(i);
- // Compress the array with tracks
- // fTracks->Compress();
+ //Replace the removed track with the last track
+ TClonesArray &a=*fTracks;
+ delete a.RemoveAt(rm);
+
+ if (rm==last) return kTRUE;
+
+ AliESDtrack *t=GetTrack(last);
+ t->SetID(rm);
+ new (a[rm]) AliESDtrack(*t);
+ delete a.RemoveAt(last);
+
+ if (!used) return kTRUE;
+
+
+ // Remap the indices of the daughters of reconstructed decays
+ for (Int_t n=0; n<nv0; n++) {
+ AliESDv0 *v0=GetV0(n);
+ if (v0->GetIndex(0)==last) {
+ v0->SetIndex(0,rm);
+ used--;
+ if (!used) return kTRUE;
+ }
+ if (v0->GetIndex(1)==last) {
+ v0->SetIndex(1,rm);
+ used--;
+ if (!used) return kTRUE;
+ }
+ }
+
+ for (Int_t n=0; n<ncs; n++) {
+ AliESDcascade *cs=GetCascade(n);
+ if (cs->GetIndex()==last) {
+ cs->SetIndex(rm);
+ used--;
+ if (!used) return kTRUE;
+ }
+ }
+
+ for (Int_t n=0; n<nkn; n++) {
+ AliESDkink *kn=GetKink(n);
+ if (kn->GetIndex(0)==last) {
+ kn->SetIndex(rm,0);
+ used--;
+ if (!used) return kTRUE;
+ }
+ if (kn->GetIndex(1)==last) {
+ kn->SetIndex(rm,1);
+ used--;
+ if (!used) return kTRUE;
+ }
+ }
return kTRUE;
}
+Bool_t AliESDEvent::Clean(Float_t *cleanPars) {
+ //
+ // Remove the data which are not needed for the physics analysis.
+ //
+ // 1) Cleaning the V0 candidates
+ // ---------------------------
+ // If the cosine of the V0 pointing angle "csp" and
+ // the DCA between the daughter tracks "dca" does not satisfy
+ // the conditions
+ //
+ // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1])
+ //
+ // an attempt to remove this V0 candidate from ESD is made.
+ //
+ // The V0 candidate gets removed if it does not belong to any
+ // recosntructed cascade decay
+ //
+ // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999
+ //
+ // 2) Cleaning the tracks
+ // ----------------------
+ // If track's transverse parameter is larger than cleanPars[2]
+ // OR
+ // track's longitudinal parameter is larger than cleanPars[3]
+ // an attempt to remove this track from ESD is made.
+ //
+ // The track gets removed if it does not come
+ // from a reconstructed decay
+ //
+ Bool_t rc=kFALSE;
+
+ Float_t dcaMax=cleanPars[0];
+ Float_t cspMin=cleanPars[1];
+
+ Int_t nV0s=GetNumberOfV0s();
+ for (Int_t i=nV0s-1; i>=0; i--) {
+ AliESDv0 *v0=GetV0(i);
+
+ Float_t dca=v0->GetDcaV0Daughters();
+ Float_t csp=v0->GetV0CosineOfPointingAngle();
+ Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin);
+ if (csp > cspcut) continue;
+
+ if (RemoveV0(i)) rc=kTRUE;
+ }
+
+
+ Float_t dmax=cleanPars[2], zmax=cleanPars[3];
+
+ const AliESDVertex *vertex=GetVertex();
+ Bool_t vtxOK=vertex->GetStatus();
+
+ Int_t nTracks=GetNumberOfTracks();
+ for (Int_t i=nTracks-1; i>=0; i--) {
+ AliESDtrack *track=GetTrack(i);
+ Float_t xy,z; track->GetImpactParameters(xy,z);
+ if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) {
+ if (RemoveTrack(i)) rc=kTRUE;
+ }
+ }
+
+ return rc;
+}
+
Int_t AliESDEvent::AddTrack(const AliESDtrack *t) {
// Add track
TClonesArray &ftr = *fTracks;
void AliESDEvent::SetVertex(const AliESDVertex *vertex) {
// use already allocated space
if(fSPDVertex){
- new(fSPDVertex) AliESDVertex(*vertex);
+ *fSPDVertex = *vertex;
fSPDVertex->SetName(fESDListName[kSPDVertex]);
}
}
void AliESDEvent::SetPrimaryVertex(const AliESDVertex *vertex) {
- // use already allocated space
if(fPrimaryVertex){
- new(fPrimaryVertex) AliESDVertex(*vertex);
+ *fPrimaryVertex = *vertex;
fPrimaryVertex->SetName(fESDListName[kPrimaryVertex]);
}
}
void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) {
if(fSPDMult){
- new (fSPDMult) AliMultiplicity(*mul);
+ *fSPDMult = *mul;
}
}
void AliESDEvent::SetFMDData(AliESDFMD * obj) {
// use already allocated space
if(fESDFMD){
- new(fESDFMD) AliESDFMD(*obj);
+ *fESDFMD = *obj;
}
}
Int_t ntrk=GetNumberOfTracks();
for (Int_t i=0; i<ntrk; i++) {
- const AliESDtrack *t=GetTrack(i);
+ AliESDtrack *t=GetTrack(i);
const AliESDfriendTrack *f=t->GetFriendTrack();
ev->AddTrack(f);
+
+ t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack"
+
}
}
return 0;
}
+Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const
+{
+ // fills the provided TRefArray with all found phos clusters
+
+ clusters->Clear();
+
+ AliESDCaloCluster *cl = 0;
+ for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
+
+ if ( cl = GetCaloCluster(i)) {
+ if (cl->IsPHOS()){
+ clusters->Add(cl);
+ printf("IsPHOS %d Size: %d \n",i,clusters->GetEntriesFast());
+ }
+ }
+ }
+ return clusters->GetEntriesFast();
+}
+
+Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const
+{
+ // fills the provided TRefArray with all found phos clusters
+
+ clusters->Clear();
+
+ AliESDCaloCluster *cl = 0;
+ for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
+
+ if ( cl = GetCaloCluster(i)) {
+ if (cl->IsEMCAL()){
+ clusters->Add(cl);
+ printf("IsEMCAL %d Size: %d \n",i,clusters->GetEntriesFast());
+ }
+ }
+ }
+ return clusters->GetEntriesFast();
+}
+
+
void AliESDEvent::ReadFromTree(TTree *tree){
// load the TTree
// FMD
- SetFMDData(fESDOld->GetFMDData());
+ if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData());
// T0
// leave amps out
// VZERO
- SetVZEROData(fESDOld->GetVZEROData());
+ if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData());
- SetVertex(fESDOld->GetVertex());
+ if(fESDOld->GetVertex())SetVertex(fESDOld->GetVertex());
- SetPrimaryVertex(fESDOld->GetPrimaryVertex());
+ if(fESDOld->GetPrimaryVertex())SetPrimaryVertex(fESDOld->GetPrimaryVertex());
- SetMultiplicity(fESDOld->GetMultiplicity());
+ if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity());
for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){
AddTrack(fESDOld->GetTrack(i));