]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCascadeVertexer.cxx
update some settings, add option depending on year, collision type, output file name
[u/mrichter/AliRoot.git] / STEER / AliCascadeVertexer.cxx
index 7451457500ea312108d4e5a16ba4c58e73f92085..e8ac235c8674bfc27b65a7c12ea2a2e79fd5bd1f 100644 (file)
 //                     Fills the ESD with the cascades 
 //    Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
 //-------------------------------------------------------------------------
-#include <TObjArray.h>
-#include <TTree.h>
 
-#include "AliESD.h"
-#include "AliESDv0.h"
+//modified by R. Vernet 30/6/2006 : daughter label
+//modified by R. Vernet  3/7/2006 : causality
+//modified by I. Belikov 24/11/2006 : static setter for the default cuts
+
+#include "AliESDEvent.h"
 #include "AliESDcascade.h"
 #include "AliCascadeVertexer.h"
 
 ClassImp(AliCascadeVertexer)
 
-Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
+//A set of loose cuts
+Double_t 
+  AliCascadeVertexer::fgChi2max=33.;   //maximal allowed chi2 
+Double_t 
+  AliCascadeVertexer::fgDV0min=0.01;   //min V0 impact parameter
+Double_t 
+  AliCascadeVertexer::fgMassWin=0.008; //"window" around the Lambda mass
+Double_t 
+  AliCascadeVertexer::fgDBachMin=0.01; //min bachelor impact parameter
+Double_t 
+  AliCascadeVertexer::fgDCAmax=2.0;    //max DCA between the V0 and the track 
+Double_t 
+  AliCascadeVertexer::fgCPAmin=0.98; //min cosine of the cascade pointing angle
+Double_t 
+  AliCascadeVertexer::fgRmin=0.2;      //min radius of the fiducial volume
+Double_t 
+  AliCascadeVertexer::fgRmax=100.;     //max radius of the fiducial volume
+  
+
+Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESDEvent *event) {
   //--------------------------------------------------------------------
   // This function reconstructs cascade vertices
   //      Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
   //--------------------------------------------------------------------
+   const AliESDVertex *vtxT3D=event->GetPrimaryVertex();
+
+   Double_t xPrimaryVertex=vtxT3D->GetXv();
+   Double_t yPrimaryVertex=vtxT3D->GetYv();
+   Double_t zPrimaryVertex=vtxT3D->GetZv();
+
    Double_t b=event->GetMagneticField();
    Int_t nV0=(Int_t)event->GetNumberOfV0s();
+
+   //stores relevant V0s in an array
    TObjArray vtcs(nV0);
    Int_t i;
    for (i=0; i<nV0; i++) {
        AliESDv0 *v=event->GetV0(i);
-       if (v->GetD(fX,fY,fZ)<fDV0min) continue;
+       if (v->GetOnFlyStatus()) continue;
+       if (v->GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex)<fDV0min) continue;
        vtcs.AddLast(v);
    }
    nV0=vtcs.GetEntriesFast();
 
+   // stores relevant tracks in another array
    Int_t nentr=(Int_t)event->GetNumberOfTracks();
    TArrayI trk(nentr); Int_t ntr=0;
    for (i=0; i<nentr; i++) {
        AliESDtrack *esdtr=event->GetTrack(i);
-       UInt_t status=esdtr->GetStatus();
-       UInt_t flags=AliESDtrack::kITSin|AliESDtrack::kTPCin|
-                    AliESDtrack::kTPCpid|AliESDtrack::kESDpid;
+       ULong_t status=esdtr->GetStatus();
 
        if ((status&AliESDtrack::kITSrefit)==0)
-          if (flags!=status) continue;
+         if ((status&AliESDtrack::kTPCrefit)==0) continue;
 
-       if (TMath::Abs(esdtr->GetD(fX,fY,b))<fDBachMin) continue;
+       if (TMath::Abs(esdtr->GetD(xPrimaryVertex,yPrimaryVertex,b))<fDBachMin) continue;
 
        trk[ntr++]=i;
    }   
@@ -65,95 +93,94 @@ Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
    Int_t ncasc=0;
 
    // Looking for the cascades...
-   for (i=0; i<nV0; i++) {
+
+   for (i=0; i<nV0; i++) { //loop on V0s
+
       AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
-      v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda 
-      if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
-      for (Int_t j=0; j<ntr; j++) {
+      AliESDv0 v0(*v);
+      v0.ChangeMassHypothesis(kLambda0); // the v0 must be Lambda 
+      if (TMath::Abs(v0.GetEffMass()-massLambda)>fMassWin) continue; 
+
+      for (Int_t j=0; j<ntr; j++) {//loop on tracks
         Int_t bidx=trk[j];
+        //Bo:   if (bidx==v->GetNindex()) continue; //bachelor and v0's negative tracks must be different
+         if (bidx==v0.GetIndex(0)) continue; //Bo:  consistency 0 for neg
         AliESDtrack *btrk=event->GetTrack(bidx);
-
          if (btrk->GetSign()>0) continue;  // bachelor's charge 
           
-        AliESDv0 v0(*v), *pv0=&v0;
+        AliESDv0 *pv0=&v0;
          AliExternalTrackParam bt(*btrk), *pbt=&bt;
 
          Double_t dca=PropagateToDCA(pv0,pbt,b);
          if (dca > fDCAmax) continue;
 
-         AliESDcascade cascade(*pv0,*pbt,bidx);
-         if (cascade.GetChi2() > fChi2max) continue;
+         AliESDcascade cascade(*pv0,*pbt,bidx);//constucts a cascade candidate
+        //PH        if (cascade.GetChi2Xi() > fChi2max) continue;
 
-        Double_t x,y,z; cascade.GetXYZ(x,y,z); 
+        Double_t x,y,z; cascade.GetXYZcascade(x,y,z); // Bo: bug correction
          Double_t r2=x*x + y*y; 
          if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
          if (r2 < fRmin*fRmin) continue;
 
-         {
+        Double_t pxV0,pyV0,pzV0;
+        pv0->GetPxPyPz(pxV0,pyV0,pzV0);
+        if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
+
          Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
          if (r2 > (x1*x1+y1*y1)) 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-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);
 
+        if (cascade.GetCascadeCosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex) <fCPAmin) continue; //condition on the cascade pointing angle 
+        
+         cascade.SetDcaXiDaughters(dca);
+        event->AddCascade(&cascade);
          ncasc++;
-
-      }
-   }
+      } // end loop tracks
+   } // end loop V0s
 
    // Looking for the anti-cascades...
-   for (i=0; i<nV0; i++) {
+
+   for (i=0; i<nV0; i++) { //loop on V0s
       AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
-      v->ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda 
-      if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
-      for (Int_t j=0; j<ntr; j++) {
+      AliESDv0 v0(*v);
+      v0.ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda 
+      if (TMath::Abs(v0.GetEffMass()-massLambda)>fMassWin) continue; 
+
+      for (Int_t j=0; j<ntr; j++) {//loop on tracks
         Int_t bidx=trk[j];
+        //Bo:   if (bidx==v->GetPindex()) continue; //bachelor and v0's positive tracks must be different
+         if (bidx==v0.GetIndex(1)) continue; //Bo:  consistency 1 for pos
         AliESDtrack *btrk=event->GetTrack(bidx);
-
          if (btrk->GetSign()<0) continue;  // bachelor's charge 
           
-        AliESDv0 v0(*v), *pv0=&v0;
+        AliESDv0 *pv0=&v0;
          AliESDtrack bt(*btrk), *pbt=&bt;
 
          Double_t dca=PropagateToDCA(pv0,pbt,b);
          if (dca > fDCAmax) continue;
 
-         AliESDcascade cascade(*pv0,*pbt,bidx);
-         if (cascade.GetChi2() > fChi2max) continue;
+         AliESDcascade cascade(*pv0,*pbt,bidx); //constucts a cascade candidate
+        //PH         if (cascade.GetChi2Xi() > fChi2max) continue;
 
-        Double_t x,y,z; cascade.GetXYZ(x,y,z); 
+        Double_t x,y,z; cascade.GetXYZcascade(x,y,z); // Bo: bug correction
          Double_t r2=x*x + y*y; 
          if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
          if (r2 < fRmin*fRmin) continue;
 
-         {
+        Double_t pxV0,pyV0,pzV0;
+        pv0->GetPxPyPz(pxV0,pyV0,pzV0);
+        if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
+
          Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
          if (r2 > (x1*x1+y1*y1)) continue;
-         if (z*z > z1*z1) continue;
-         }
 
-        Double_t px,py,pz; cascade.GetPxPyPz(px,py,pz);
-         Double_t p2=px*px+py*py+pz*pz;
-         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);
+        if (cascade.GetCascadeCosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex) < fCPAmin) continue; //condition on the cascade pointing angle 
 
+         cascade.SetDcaXiDaughters(dca);
+        event->AddCascade(&cascade);
          ncasc++;
 
-      }
-   }
+      } // end loop tracks
+   } // end loop V0s
 
 Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
 
@@ -161,24 +188,26 @@ Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
 }
 
 
-inline Double_t det(Double_t a00, Double_t a01, Double_t a10, Double_t a11){
-  // determinant 2x2
+Double_t AliCascadeVertexer::Det(Double_t a00, Double_t a01, Double_t a10, Double_t a11) const {
+  //--------------------------------------------------------------------
+  // This function calculates locally a 2x2 determinant
+  //--------------------------------------------------------------------
   return a00*a11 - a01*a10;
 }
 
-inline Double_t det (Double_t a00,Double_t a01,Double_t a02,
-                     Double_t a10,Double_t a11,Double_t a12,
-                     Double_t a20,Double_t a21,Double_t a22) {
-  // determinant 3x3
-  return 
-  a00*det(a11,a12,a21,a22)-a01*det(a10,a12,a20,a22)+a02*det(a10,a11,a20,a21);
+Double_t AliCascadeVertexer::Det(Double_t a00,Double_t a01,Double_t a02,
+                                Double_t a10,Double_t a11,Double_t a12,
+                                Double_t a20,Double_t a21,Double_t a22) const {
+  //--------------------------------------------------------------------
+  // This function calculates locally a 3x3 determinant
+  //--------------------------------------------------------------------
+  return  a00*Det(a11,a12,a21,a22)-a01*Det(a10,a12,a20,a22)+a02*Det(a10,a11,a20,a21);
 }
 
 
 
 
-Double_t AliCascadeVertexer::
-PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
+Double_t AliCascadeVertexer::PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
   //--------------------------------------------------------------------
   // This function returns the DCA between the V0 and the track
   //--------------------------------------------------------------------
@@ -196,16 +225,16 @@ PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
  
 // calculation dca
    
-  Double_t dd= det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
-  Double_t ax= det(py1,pz1,py2,pz2);
-  Double_t ay=-det(px1,pz1,px2,pz2);
-  Double_t az= det(px1,py1,px2,py2);
+  Double_t dd= Det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
+  Double_t ax= Det(py1,pz1,py2,pz2);
+  Double_t ay=-Det(px1,pz1,px2,pz2);
+  Double_t az= Det(px1,py1,px2,py2);
 
   Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
 
 //points of the DCA
-  Double_t t1 = det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
-                det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
+  Double_t t1 = Det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
+                Det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
   
   x1 += px1*t1; y1 += py1*t1; //z1 += pz1*t1;