]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliCascadeVertexer.cxx
Using default Root containers for Root tags bigger than v4-00-01. Removing fast wrapp...
[u/mrichter/AliRoot.git] / ITS / AliCascadeVertexer.cxx
index 2eede113605286e7b40267ac7e7185304fbe265c..59af374a5bece433241cacc8d72c9aa0626c752b 100644 (file)
@@ -15,7 +15,8 @@
 
 //-------------------------------------------------------------------------
 //               Implementation of the cascade vertexer class
-//
+//          Reads V0s and tracks, writes out cascade vertices
+//                     Fills the ESD with the cascades 
 //    Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
 //-------------------------------------------------------------------------
 #include <TObjArray.h>
@@ -23,7 +24,6 @@
 
 #include "AliESD.h"
 #include "AliESDv0.h"
-#include "AliESDcascade.h"
 #include "AliCascadeVertex.h"
 #include "AliCascadeVertexer.h"
 #include "AliITStrackV2.h"
@@ -50,10 +50,21 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
    TObjArray trks(ntr);
    for (i=0; i<ntr; i++) {
        AliESDtrack *esdtr=event->GetTrack(i);
+       UInt_t status=esdtr->GetStatus();
+       UInt_t flags=AliESDtrack::kITSin|AliESDtrack::kTPCin|
+                    AliESDtrack::kTPCpid|AliESDtrack::kESDpid;
+
+       if ((status&AliESDtrack::kITSrefit)==0)
+          if (flags!=status) continue;
+
        AliITStrackV2 *iotrack=new AliITStrackV2(*esdtr);
-       iotrack->PropagateTo(3.,0.0023,65.19); iotrack->PropagateTo(2.5,0.,0.);
+       iotrack->SetLabel(i);  // now it is the index in array of ESD tracks
+       if ((status&AliESDtrack::kITSrefit)==0)   //correction for the beam pipe
+          if (!iotrack->PropagateTo(3.,0.0023,65.19)) continue; 
+       if (!iotrack->PropagateTo(2.5,0.,0.)) continue;
        trks.AddLast(iotrack);
    }   
+   ntr=trks.GetEntriesFast();
 
    Double_t massLambda=1.11568;
    Int_t ncasc=0;
@@ -63,12 +74,12 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
       AliV0vertex *v=(AliV0vertex*)vtcs.UncheckedAt(i);
       v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda 
       if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
-      if (v->GetD(0,0,0)<fDV0min) continue;
+      if (v->GetD(fX,fY,fZ)<fDV0min) continue;
       for (Int_t j=0; j<ntr; j++) {
         AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
 
-         if (TMath::Abs(b->GetD())<fDBachMin) continue;
-         if (b->Get1Pt()<0.) continue;  // bachelor's charge 
+         if (b->Get1Pt()>0.) continue;  // bachelor's charge 
+         if (TMath::Abs(b->GetD(fX,fY))<fDBachMin) continue;
           
         AliV0vertex v0(*v), *pv0=&v0;
          AliITStrackV2 bt(*b), *pbt=&bt;
@@ -87,14 +98,14 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
          {
          Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
          if (r2 > (x1*x1+y1*y1)) continue;
-         if (z*z > z1*z1) continue;
+         //if ((z-fZ)*(z-fZ) > (z1-fZ)*(z1-fZ)) continue;
          }
 
         Double_t px,py,pz; cascade.GetPxPyPz(px,py,pz);
          Double_t p2=px*px+py*py+pz*pz;
-         Double_t cost=(x*px+y*py+z*pz)/TMath::Sqrt(p2*(r2+z*z));
-
-         if (cost<fCPAmax) continue; //condition on the cascade pointing angle 
+         Double_t cost=((x-fX)*px + (y-fY)*py + (z-fZ)*pz)/
+               TMath::Sqrt(p2*((x-fX)*(x-fX) + (y-fY)*(y-fY) + (z-fZ)*(z-fZ)));
+        if (cost<fCPAmax) continue; //condition on the cascade pointing angle 
          //cascade.ChangeMassHypothesis(); //default is Xi
 
          event->AddCascade(&cascade);
@@ -109,12 +120,12 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
       AliV0vertex *v=(AliV0vertex*)vtcs.UncheckedAt(i);
       v->ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda 
       if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
-      if (v->GetD(0,0,0)<fDV0min) continue;
+      if (v->GetD(fX,fY,fZ)<fDV0min) continue;
       for (Int_t j=0; j<ntr; j++) {
         AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
 
-         if (TMath::Abs(b->GetD())<fDBachMin) continue;
-         if (b->Get1Pt()>0.) continue;  // bachelor's charge 
+         if (TMath::Abs(b->GetD(fX,fY))<fDBachMin) continue;
+         if (b->Get1Pt()<0.) continue;  // bachelor's charge 
           
         AliV0vertex v0(*v), *pv0=&v0;
          AliITStrackV2 bt(*b), *pbt=&bt;
@@ -138,7 +149,8 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
 
         Double_t px,py,pz; cascade.GetPxPyPz(px,py,pz);
          Double_t p2=px*px+py*py+pz*pz;
-         Double_t cost=(x*px+y*py+z*pz)/TMath::Sqrt(p2*(r2+z*z));
+         Double_t cost=((x-fX)*px + (y-fY)*py + (z-fZ)*pz)/
+               TMath::Sqrt(p2*((x-fX)*(x-fX) + (y-fY)*(y-fY) + (z-fZ)*(z-fZ)));
 
          if (cost<fCPAmax) continue; //condition on the cascade pointing angle 
          //cascade.ChangeMassHypothesis(); //default is Xi
@@ -163,6 +175,9 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
   //--------------------------------------------------------------------
   // This function reconstructs cascade vertices
   //--------------------------------------------------------------------
+  Warning("V0sTracks2CascadeVertices(TTree*,TTree*,TTree*)",
+  "Will be removed soon !  Use V0sTracks2CascadeVertices(AliESD*) instead");
+
    TBranch *branch=vTree->GetBranch("vertices");
    if (!branch) {
       Error("V0sTracks2CascadeVertices","Can't get the V0 branch !");
@@ -204,7 +219,8 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
        branch->SetAddress(&iotrack);
        tTree->GetEvent(i);
 
-       iotrack->PropagateTo(3.,0.0023,65.19); iotrack->PropagateTo(2.5,0.,0.);
+       if (!iotrack->PropagateTo(3.,0.0023,65.19)) continue; 
+       if (!iotrack->PropagateTo(2.5,0.,0.)) continue;
 
        ntrack++; trks.AddLast(iotrack);
        
@@ -240,8 +256,8 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
 
           if (TMath::Abs(bachtrk->GetD())<fDBachMin) continue;        // eliminate to small impact parameters
 
-          if (lV0ver->GetPdgCode()==kLambda0 && bachtrk->Get1Pt()<0.) continue;     // condition on V0 label 
-          if (lV0ver->GetPdgCode()==kLambda0Bar && bachtrk->Get1Pt()>0.) continue;  // + good sign for bachelor
+          if (lV0ver->GetPdgCode()==kLambda0 && bachtrk->Get1Pt()>0.) continue;     // condition on V0 label 
+          if (lV0ver->GetPdgCode()==kLambda0Bar && bachtrk->Get1Pt()<0.) continue;  // + good sign for bachelor
           
          AliV0vertex lV0(*lV0ver), *pV0=&lV0;
           AliITStrackV2 bt(*bachtrk), *pbt=&bt;