]> 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 11591933fad3401dffec6497f0b5e04ea2e98f9a..59af374a5bece433241cacc8d72c9aa0626c752b 100644 (file)
 
 //-------------------------------------------------------------------------
 //               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 <Riostream.h>
 #include <TObjArray.h>
-#include <TPDGCode.h>
 #include <TTree.h>
 
+#include "AliESD.h"
+#include "AliESDv0.h"
 #include "AliCascadeVertex.h"
 #include "AliCascadeVertexer.h"
 #include "AliITStrackV2.h"
 
 ClassImp(AliCascadeVertexer)
 
+Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
+  //--------------------------------------------------------------------
+  // This function reconstructs cascade vertices
+  //      Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
+  //--------------------------------------------------------------------
+
+   Int_t nV0=(Int_t)event->GetNumberOfV0s();
+   TObjArray vtcs(nV0);
+   Int_t i;
+   for (i=0; i<nV0; i++) {
+       const AliESDv0 *esdV0=event->GetV0(i);
+       vtcs.AddLast(new AliV0vertex(*esdV0));
+   }
+
+
+   Int_t ntr=(Int_t)event->GetNumberOfTracks();
+   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->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;
+
+   // Looking for the cascades...
+   for (i=0; i<nV0; i++) {
+      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(fX,fY,fZ)<fDV0min) continue;
+      for (Int_t j=0; j<ntr; j++) {
+        AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
+
+         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;
+
+         Double_t dca=PropagateToDCA(pv0,pbt);
+         if (dca > fDCAmax) continue;
+
+         AliCascadeVertex cascade(*pv0,*pbt);
+         if (cascade.GetChi2() > fChi2max) continue;
+
+        Double_t x,y,z; cascade.GetXYZ(x,y,z); 
+         Double_t r2=x*x + y*y; 
+         if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
+         if (r2 < fRmin*fRmin) continue;
+
+         {
+         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);
+
+         ncasc++;
+
+      }
+   }
+
+   // Looking for the anti-cascades...
+   for (i=0; i<nV0; i++) {
+      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(fX,fY,fZ)<fDV0min) continue;
+      for (Int_t j=0; j<ntr; j++) {
+        AliITStrackV2 *b=(AliITStrackV2*)trks.UncheckedAt(j);
+
+         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;
+
+         Double_t dca=PropagateToDCA(pv0,pbt);
+         if (dca > fDCAmax) continue;
+
+         AliCascadeVertex cascade(*pv0,*pbt);
+         if (cascade.GetChi2() > fChi2max) continue;
+
+        Double_t x,y,z; cascade.GetXYZ(x,y,z); 
+         Double_t r2=x*x + y*y; 
+         if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
+         if (r2 < fRmin*fRmin) continue;
+
+         {
+         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);
+
+         ncasc++;
+
+      }
+   }
+
+Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
+
+   trks.Delete();
+   vtcs.Delete();
+
+   return 0;
+}
+
 Int_t AliCascadeVertexer::
 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 !");
@@ -76,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);
        
@@ -94,14 +238,14 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
 
    for (i=0; i<nV0; i++) {
 
-       AliV0vertex *V0ver=(AliV0vertex *)vtxV0.UncheckedAt(i);
+       AliV0vertex *lV0ver=(AliV0vertex *)vtxV0.UncheckedAt(i);
 
-       V0ver->ChangeMassHypothesis(kLambda0); //I.B.
+       lV0ver->ChangeMassHypothesis(kLambda0); //I.B.
 
-       if (V0ver->GetEffMass()<massLambda-fMassWin ||       // condition of the V0 mass window (cut fMassWin)
-           V0ver->GetEffMass()>massLambda+fMassWin) continue; 
+       if (lV0ver->GetEffMass()<massLambda-fMassWin ||       // condition of the V0 mass window (cut fMassWin)
+           lV0ver->GetEffMass()>massLambda+fMassWin) continue; 
 
-       if (V0ver->GetD(0,0,0)<fDV0min) continue;          // condition of minimum impact parameter of the V0 (cut fDV0min) 
+       if (lV0ver->GetD(0,0,0)<fDV0min) continue;          // condition of minimum impact parameter of the V0 (cut fDV0min) 
                                                           // here why not cuting on pointing angle ???
 
    // for each vertex in the good mass range, loop on all tracks (= bachelor candidates)
@@ -112,10 +256,10 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
 
           if (TMath::Abs(bachtrk->GetD())<fDBachMin) continue;        // eliminate to small impact parameters
 
-          if (V0ver->GetPdgCode()==kLambda0 && bachtrk->Get1Pt()<0.) continue;     // condition on V0 label 
-          if (V0ver->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 V0(*V0ver), *pV0=&V0;
+         AliV0vertex lV0(*lV0ver), *pV0=&lV0;
           AliITStrackV2 bt(*bachtrk), *pbt=&bt;
 
    // calculation of the distance of closest approach between the V0 and the bachelor
@@ -137,7 +281,7 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
 
          {
    //I.B.
-         Double_t x1,y1,z1; V0ver->GetXYZ(x1,y1,z1);
+         Double_t x1,y1,z1; lV0ver->GetXYZ(x1,y1,z1);
          if (r2 > (x1*x1+y1*y1)) continue;
          if (z*z > z1*z1) continue;
          }
@@ -160,7 +304,7 @@ V0sTracks2CascadeVertices(TTree *vTree,TTree *tTree, TTree *xTree) {
       }
    }
 
-   cerr<<"Number of reconstructed cascades: "<<ncasc<<endl;
+Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
 
    trks.Delete();
    vtxV0.Delete();
@@ -230,7 +374,7 @@ AliCascadeVertexer::PropagateToDCA(AliV0vertex *v, AliITStrackV2 *t) {
 
   x1=x1*cs1 + y1*sn1;
   if (!t->PropagateTo(x1,0.,0.)) {
-    cerr<<"AliV0vertexer::PropagateToDCA: propagation failed !\n";
+    Error("PropagateToDCA","Propagation failed !");
     return 1.e+33;
   }