]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
First round of ESD clean-up at the physics level: removing the tracks that do not...
authorbelikov <belikov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Oct 2007 08:43:35 +0000 (08:43 +0000)
committerbelikov <belikov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Oct 2007 08:43:35 +0000 (08:43 +0000)
STEER/AliESD.cxx
STEER/AliESD.h
STEER/AliESDEvent.cxx
STEER/AliESDEvent.h
STEER/AliESDcascade.h
STEER/AliReconstruction.cxx
STEER/AliReconstruction.h

index 6b12b4876a9ca96ea51bb6fb0c680428159a921d..127e962e26276310aaae4e59f7fcdfb59fd8bd0b 100644 (file)
@@ -213,25 +213,138 @@ void AliESD::Reset()
   fErrorLogs.Clear();
 }
 
-Bool_t  AliESD::RemoveTrack(Int_t /*i*/) {
+Bool_t  AliESD::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++;
+  }
 
-  // Remap the indices of the daughters of recosntructed decays
+  Int_t ncs=GetNumberOfCascades();
+  for (Int_t n=0; n<ncs; n++) {
+    AliESDcascade *cs=GetCascade(n);
 
-  // Remove the track
-  // delete fTracks->RemoveAt(i);
+    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);
 
-  // Compress the array with tracks
-  // fTracks->Compress();
+    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++;
+  }
+
+
+  //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 AliESD::Clean(Float_t *cleanPars) {
+  //
+  // Remove the data which are not needed for the physics analysis.
+  //
+  // If track's transverse parameter is larger than dmax
+  //                       OR
+  //    track's longitudinal parameter is larger than zmax
+  // an attempt to remove this track from ESD is made.
+  //
+  // The track gets removed if it does not come 
+  // from a reconstructed decay
+  //
+
+  Float_t dmax=cleanPars[0], zmax=cleanPars[1];
+
+  const AliESDVertex *vertex=GetVertex();
+  Bool_t vtxOK=vertex->GetStatus(), rc=kFALSE;
+  
+  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 AliESD::AddV0(const AliESDv0 *v) {
   //
   // Add V0
index 1daea4764abb04f8b96b5facd8920ffea6c709e3..e80095f12b91ce8e49630e891df5d5414606f927 100644 (file)
@@ -75,7 +75,8 @@ public:
     return (AliESDTrdTrack *)fTrdTracks.UncheckedAt(i);
   }
 
-  Bool_t  RemoveTrack(Int_t i);
+  Bool_t Clean(Float_t *cleanPars);
+  Bool_t RemoveTrack(Int_t i);
 
   Int_t  AddTrack(const AliESDtrack *t) {
     AliESDtrack * track = new(fTracks[fTracks.GetEntriesFast()]) AliESDtrack(*t);
index 70d8cb23d0ea3d2d909ca74695c924b2c37f341e..ac57bd4734b2040737235a962187971eefa99103 100644 (file)
@@ -380,26 +380,139 @@ void AliESDEvent::SetESDfriend(const AliESDfriend *ev) {
   }
 }
 
-Bool_t  AliESDEvent::RemoveTrack(Int_t /*i*/) {
+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);
 
-  // Remap the indices of the daughters of recosntructed decays
+    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);
+
+    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.
+  //
+  // If track's transverse parameter is larger than fDmax
+  //                       OR
+  //    track's longitudinal parameter is larger than fZmax
+  // an attempt to remove this track from ESD is made.
+  //
+  // The track gets removed if it does not come 
+  // from a reconstructed decay
+  //
+
+  Float_t dmax=cleanPars[0], zmax=cleanPars[1];
+
+  const AliESDVertex *vertex=GetVertex();
+  Bool_t vtxOK=vertex->GetStatus(), rc=kFALSE;
+  
+  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;
index 5ef58162abf9d95873a1c1c75ab23493943efaf5..ca19f8d8fb3f111b056d614e1adc8e656eb602a5 100644 (file)
@@ -176,7 +176,8 @@ public:
   const AliMultiplicity *GetMultiplicity() const {return fSPDMult;}
 
 
-  Bool_t  RemoveTrack(Int_t i);
+  Bool_t Clean(Float_t *cleanPars);
+  Bool_t RemoveTrack(Int_t i);
 
   AliESDtrack *GetTrack(Int_t i) const {
     return (AliESDtrack *)fTracks->UncheckedAt(i);
index acf66f2ccbcd0a4be1fcc48acc924fb2bb0d6fa2..dc4c2762e2afa621bdd3708c056a7f6d3ada1115 100644 (file)
@@ -46,6 +46,8 @@ public:
   }
 
   Int_t    GetBindex() const {return fBachIdx;}
+  void     SetIndex(Int_t i) {fBachIdx=i;}        //for the consistensy with V0
+  Int_t    GetIndex() const {return GetBindex();} //for the consistensy with V0
   void     SetDcaXiDaughters(Double_t rDcaXiDaughters=0.);
   Double_t GetDcaXiDaughters() const {return fDcaXiDaughters;}
   Double_t GetCascadeCosineOfPointingAngle(Double_t&, Double_t&, Double_t&) const;
index a91eff1d99fc72447b89f68d7c128fb211647653..c3883d3ab1a3d52b473d8b381bc55c4e7d59f60c 100644 (file)
@@ -191,11 +191,14 @@ AliReconstruction::AliReconstruction(const char* gAliceFilename, const char* cdb
   fRunCascadeFinder(kTRUE),
   fStopOnError(kFALSE),
   fWriteAlignmentData(kFALSE),
-  fCleanESD(kTRUE),
   fWriteESDfriend(kFALSE),
   fWriteAOD(kFALSE),
   fFillTriggerESD(kTRUE),
 
+  fCleanESD(kTRUE),
+  fDmax(50.),
+  fZmax(50.),
+
   fRunLocalReconstruction("ALL"),
   fRunTracking("ALL"),
   fFillESD("ALL"),
@@ -247,11 +250,14 @@ AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
   fRunCascadeFinder(rec.fRunCascadeFinder),
   fStopOnError(rec.fStopOnError),
   fWriteAlignmentData(rec.fWriteAlignmentData),
-  fCleanESD(rec.fCleanESD),
   fWriteESDfriend(rec.fWriteESDfriend),
   fWriteAOD(rec.fWriteAOD),
   fFillTriggerESD(rec.fFillTriggerESD),
 
+  fCleanESD(rec.fCleanESD),
+  fDmax(rec.fDmax),
+  fZmax(rec.fZmax),
+
   fRunLocalReconstruction(rec.fRunLocalReconstruction),
   fRunTracking(rec.fRunTracking),
   fFillESD(rec.fFillESD),
@@ -1350,23 +1356,16 @@ Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
   //
 
   AliInfo("Cleaning the ESD...");
-
-  const AliESDVertex *vertex=esd->GetVertex();
-  Double_t vz=vertex->GetZv();
-  
   Int_t nTracks=esd->GetNumberOfTracks();
-  for (Int_t i=0; i<nTracks; i++) {
-    AliESDtrack *track=esd->GetTrack(i);
+  AliInfo(Form("Number of ESD tracks before cleaning %d",nTracks));
 
-    Float_t xy,z; track->GetImpactParameters(xy,z);
-    if (TMath::Abs(xy) < 50.)    continue;  
-    if (vertex->GetStatus())
-      if (TMath::Abs(vz-z) < 5.) continue;  
+  Float_t cleanPars[]={fDmax,fZmax};
+  Bool_t rc=esd->Clean(cleanPars);
 
-    esd->RemoveTrack(i);
-  }
+  nTracks=esd->GetNumberOfTracks();
+  AliInfo(Form("Number of ESD tracks after cleaning %d",nTracks));
 
-  return kTRUE;
+  return rc;
 }
 
 //_____________________________________________________________________________
index 9fe9d508ffc4c9236eac8b3f5f34567e599eee77..2ae673012bee30761aa1f4723550b86474713f57 100644 (file)
@@ -78,12 +78,17 @@ public:
   void SetRunCascadeFinder(Bool_t flag=kTRUE) {fRunCascadeFinder=flag;};
   void SetStopOnError(Bool_t flag=kTRUE) {fStopOnError=flag;}
   void SetWriteAlignmentData(Bool_t flag=kTRUE){fWriteAlignmentData=flag;}
-  void SetCleanESD(Bool_t flag=kTRUE){fCleanESD=flag;}
   void SetWriteESDfriend(Bool_t flag=kTRUE){fWriteESDfriend=flag;}
   void SetWriteAOD(Bool_t flag=kTRUE){fWriteAOD=flag;}
   void SetFillTriggerESD(Bool_t flag=kTRUE){fFillTriggerESD=flag;}
   void SetDiamondProfile(AliESDVertex *dp) {fDiamondProfile=dp;}
                   
+  void SetCleanESD(Bool_t flag=kTRUE){fCleanESD=flag;}
+  void SetDmax(Float_t d) {fDmax=d;}
+  void SetZmax(Float_t z) {fZmax=z;}
+  Float_t GetDmax() const {return fDmax;}
+  Float_t GetZmax() const {return fZmax;}
+
   void           SetCheckPointLevel(Int_t checkPointLevel)
     {fCheckPointLevel = checkPointLevel;}
   // CDB storage activation
@@ -149,11 +154,15 @@ private:
   Bool_t         fRunCascadeFinder;   // run the ESD cascade finder
   Bool_t         fStopOnError;        // stop or continue on errors
   Bool_t         fWriteAlignmentData; // write track space-points flag
-  Bool_t         fCleanESD;           // clean ESD flag
   Bool_t         fWriteESDfriend;     // write ESD friend flag
   Bool_t         fWriteAOD;           // write AOD flag
   Bool_t         fFillTriggerESD;     // fill trigger info into ESD
 
+  //*** Clean ESD flag and parameters *******************
+  Bool_t         fCleanESD;      // clean ESD flag
+  Float_t        fDmax;          // max. allowed transverse impact parameter 
+  Float_t        fZmax;          // max. allowed longitudinal impact parameter 
+
   TString        fRunLocalReconstruction; // run the local reconstruction for these detectors
   TString        fRunTracking;        // run the tracking for these detectors
   TString        fFillESD;            // fill ESD for these detectors
@@ -192,7 +201,7 @@ private:
   AliQualAssDataMaker * fQualAssDataMaker[fgkNDetectors];  //! array of QA data maker objects
   Int_t                 fQACycles[fgkNDetectors] ;         // cycle length (# events) over which QA data are accumulated
 
-  ClassDef(AliReconstruction, 14)      // class for running the reconstruction
+  ClassDef(AliReconstruction, 15)      // class for running the reconstruction
 };
 
 #endif