]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerSA.cxx
set reco param on an event by event basis
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
index 2d122dae68bdae5fa0621a19114ba383806c85ac..8c307a43bc76b6e0d6ad370c28e3573c992a957c 100644 (file)
 
 /* $Id$ */
 
-////////////////////////////////////////////////////
-//  Stand alone tracker class                     //
-//  Origin:  Elisabetta Crescio                   //
-//  e-mail:  crescio@to.infn.it                   //
-//  tracks are saved as AliITStrackV2 objects     //
-////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+//  Stand alone ITS tracker class                        //
+//  Origin:  Elisabetta Crescio - crescio@to.infn.it     //
+//  Updated: Francesco Prino    - prino@to.infn.it       //
+///////////////////////////////////////////////////////////
 
 #include <stdlib.h>
 
@@ -173,7 +172,7 @@ fCluCoord(0)
   fVertexer = vertexer;
  
 }
-
+/*
 //____________________________________________________________________________
 AliITStrackerSA::AliITStrackerSA(const AliITStrackerSA& tracker):AliITStrackerMI(),
 fPhiEstimate(tracker.fPhiEstimate),
@@ -224,7 +223,7 @@ AliITStrackerSA& AliITStrackerSA::operator=(const AliITStrackerSA& source){
   return *this;
  
 }
-
+*/
 //____________________________________________________________________________
 AliITStrackerSA::~AliITStrackerSA(){
   // destructor
@@ -271,6 +270,7 @@ Int_t AliITStrackerSA::Clusters2Tracks(AliESDEvent *event){
 // is done in the ITS only. In the standard reconstruction chain this option
 // can be set via AliReconstruction::SetOption("ITS","onlyITS")
   Int_t rc=0;
+
   if(!fITSStandAlone){
     rc=AliITStrackerMI::Clusters2Tracks(event);
   }
@@ -279,11 +279,14 @@ Int_t AliITStrackerSA::Clusters2Tracks(AliESDEvent *event){
   }
   if(!rc){ 
     rc=FindTracks(event,kFALSE);
-    if(AliITSReconstructor::GetRecoParam()->GetSAUseAllClusters()==kTRUE) {
+    Int_t nSPDcontr=0;
+    const AliESDVertex *spdv = event->GetPrimaryVertexSPD();
+    if(spdv) nSPDcontr = spdv->GetNContributors();
+    if(AliITSReconstructor::GetRecoParam()->GetSAUseAllClusters()==kTRUE && 
+       nSPDcontr<=AliITSReconstructor::GetRecoParam()->GetMaxSPDcontrForSAToUseAllClusters()) {
       rc=FindTracks(event,kTRUE);
     }
   }
-
   return rc;
 }
 
@@ -488,6 +491,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
                                        &trs,primaryVertex[2],pflag);
          Int_t nextLay=theLay+seedStep;
          Bool_t goon=kTRUE;
+         if(nextLay<0 || nextLay == 6) goon = kFALSE;
          while(goon){
            kk++;
            nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop],
@@ -613,11 +617,12 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   
   const Int_t kMaxClu=AliITStrackSA::kMaxNumberOfClusters;
 
-  static Int_t firstmod[AliITSgeomTGeo::kNLayers];
-  
+  static Int_t firstmod[AliITSgeomTGeo::kNLayers];  
   static Int_t clind[AliITSgeomTGeo::kNLayers][kMaxClu];
   static Int_t clmark[AliITSgeomTGeo::kNLayers][kMaxClu];
   static Int_t end[AliITSgeomTGeo::kNLayers];
+  static Int_t indices[AliITSgeomTGeo::kNLayers];
+
   static AliITSRecPoint *listlayer[AliITSgeomTGeo::kNLayers][kMaxClu];
 
   for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) {
@@ -635,7 +640,6 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   for(Int_t ncl=0;ncl<nclusters;ncl++){
     Int_t index = tr->GetClusterIndexSA(ncl); 
     AliITSRecPoint* cl = (AliITSRecPoint*)GetCluster(index);
-    if(cl->TestBit(kSAflag)==kTRUE) cl->ResetBit(kSAflag);
     Int_t lay = (index & 0xf0000000) >> 28;
     Int_t nInLay=end[lay];
     listlayer[lay][nInLay]=cl;
@@ -669,102 +673,47 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   TClonesArray &arrSA= *fListOfSATracks;
   Int_t nFoundTracks=0;
 
+
   for(Int_t l0=0;l0<end[0];l0++){ //loop on layer 1
-    AliITSRecPoint* cl0 = (AliITSRecPoint*)listlayer[0][l0];
+    indices[0]=l0;
     for(Int_t l1=0;l1<end[1];l1++){ //loop on layer 2
-      AliITSRecPoint* cl1 = (AliITSRecPoint*)listlayer[1][l1];
+      indices[1]=l1;
       for(Int_t l2=0;l2<end[2];l2++){  //loop on layer 3
-        AliITSRecPoint* cl2 = (AliITSRecPoint*)listlayer[2][l2];
+       indices[2]=l2;
         for(Int_t l3=0;l3<end[3];l3++){ //loop on layer 4   
-          AliITSRecPoint* cl3 = (AliITSRecPoint*)listlayer[3][l3];
+         indices[3]=l3;
           for(Int_t l4=0;l4<end[4];l4++){ //loop on layer 5
-            AliITSRecPoint* cl4 = (AliITSRecPoint*)listlayer[4][l4];
+           indices[4]=l4;
             for(Int_t l5=0;l5<end[5];l5++){ //loop on layer 6  
-              AliITSRecPoint* cl5 = (AliITSRecPoint*)listlayer[5][l5];
-
-
-             Double_t x1,y1,z1,sx1,sy1,sz1;
-             Double_t x2,y2,z2,sx2,sy2,sz2;
-             AliITSRecPoint* p1=0;
-             AliITSRecPoint* p2=0;
-             Int_t index1=0,index2=0;
-             Int_t mrk1=0,mrk2=0;
-
-             switch(firstLay) {
-             case 0:
-               p1=cl0;
-               index1=clind[0][l0];mrk1=clmark[0][l0];
-               break;
-             case 1:
-               p1=cl1;
-               index1=clind[1][l1];mrk1=clmark[1][l1];
-               break;
-             case 2:
-               p1=cl2;
-               index1=clind[2][l2];mrk1=clmark[2][l2];
-               break;
-             case 3:
-               p1=cl3;
-               index1=clind[3][l3];mrk1=clmark[3][l3];
-               break;
-             case 4:
-               p1=cl4;
-               index1=clind[4][l4];mrk1=clmark[4][l4];
-               break;
-             }
+             indices[5]=l5;
 
-             switch(secondLay) {
-             case 1:
-               p2=cl1;
-               index2=clind[1][l1];mrk2=clmark[1][l1];
-               break;
-             case 2:
-               p2=cl2;
-               index2=clind[2][l2];mrk2=clmark[2][l2];
-               break;
-             case 3:
-               p2=cl3;
-               index2=clind[3][l3];mrk2=clmark[3][l3];
-               break;
-             case 4:
-               p2=cl4;
-               index2=clind[4][l4];mrk2=clmark[4][l4];
-               break;
-             case 5:
-               p2=cl5;
-               index2=clind[5][l5];mrk2=clmark[5][l5];
-               break;
-             default:
-               p2=0;
-               index2=-1;mrk2=-1;
-               break;
-             }
+             // estimate curvature from 2 innermost points (or innermost point + vertex)
 
+             Int_t iFirstLay=indices[firstLay];
+             Int_t mrk1=clmark[firstLay][iFirstLay];
+
+             AliITSRecPoint* p1=(AliITSRecPoint*)listlayer[firstLay][iFirstLay];
              Int_t module1 = p1->GetDetectorIndex()+firstmod[firstLay]; 
              Int_t layer,ladder,detector;
              AliITSgeomTGeo::GetModuleId(module1,layer,ladder,detector);
              Float_t yclu1 = p1->GetY();
              Float_t zclu1 = p1->GetZ();
+
+             Double_t x1,y1,z1;
+             Double_t x2,y2,z2;
              Double_t cv=0,tgl2=0,phi2=0;
-             
-             Int_t cln1=mrk1;
-             AliITSclusterTable* arr1 = (AliITSclusterTable*)GetClusterCoord(firstLay,cln1);
+             AliITSclusterTable* arr1 = (AliITSclusterTable*)GetClusterCoord(firstLay,mrk1);
              x1 = arr1->GetX();
              y1 = arr1->GetY();
              z1 = arr1->GetZ();
-             sx1 = arr1->GetSx();
-             sy1 = arr1->GetSy();
-             sz1 = arr1->GetSz();
 
              if(secondLay>0) {
-               Int_t cln2=mrk2;
-               AliITSclusterTable* arr2 = (AliITSclusterTable*)GetClusterCoord(secondLay,cln2);
+               Int_t iSecondLay=indices[secondLay];          
+               Int_t mrk2=clmark[secondLay][iSecondLay];
+               AliITSclusterTable* arr2 = (AliITSclusterTable*)GetClusterCoord(secondLay,mrk2);
                x2 = arr2->GetX();
                y2 = arr2->GetY();
                z2 = arr2->GetZ();
-               sx2 = arr2->GetSx();
-               sy2 = arr2->GetSy();
-               sz2 = arr2->GetSz();
                cv = Curvature(primaryVertex[0],primaryVertex[1],x1,y1,x2,y2);
                tgl2 = (z2-z1)/TMath::Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
                phi2 = TMath::ATan2((y2-y1),(x2-x1));
@@ -777,33 +726,15 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
                phi2 = TMath::ATan2((y1-y2),(x1-x2));
              }
 
-
+             // create track and attach it the RecPoints
               AliITStrackSA trac(layer,ladder,detector,yclu1,zclu1,phi2,tgl2,cv,1);
-
-
-              if(cl5!=0) {
-               trac.AddClusterV2(5,(clind[5][l5] & 0x0fffffff)>>0);
-               trac.AddClusterMark(5,clmark[5][l5]);
-             }
-              if(cl4!=0){
-               trac.AddClusterV2(4,(clind[4][l4] & 0x0fffffff)>>0);
-               trac.AddClusterMark(4,clmark[4][l4]);
-             }
-              if(cl3!=0){
-               trac.AddClusterV2(3,(clind[3][l3] & 0x0fffffff)>>0);
-               trac.AddClusterMark(3,clmark[3][l3]);
-             }
-              if(cl2!=0){
-               trac.AddClusterV2(2,(clind[2][l2] & 0x0fffffff)>>0);
-               trac.AddClusterMark(2,clmark[2][l2]);
-             }
-              if(cl1!=0){
-               trac.AddClusterV2(1,(clind[1][l1] & 0x0fffffff)>>0);
-               trac.AddClusterMark(1,clmark[1][l1]);
-             }
-              if(cl0!=0){
-               trac.AddClusterV2(0,(clind[0][l0] & 0x0fffffff)>>0);
-               trac.AddClusterMark(0,clmark[0][l0]);
+             for(Int_t iLay=5; iLay>=0; iLay--){
+               Int_t iInLay=indices[iLay];
+               AliITSRecPoint* cl=(AliITSRecPoint*)listlayer[iLay][iInLay];
+               if(cl!=0){
+                 trac.AddClusterV2(iLay,(clind[iLay][iInLay] & 0x0fffffff)>>0);
+                 trac.AddClusterMark(iLay,clmark[iLay][iInLay]);
+               }
              }
 
               //fit with Kalman filter using AliITStrackerMI::RefitAt()
@@ -849,6 +780,9 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   CookLabel(otrack,0.); //MI change - to see fake ratio
   Int_t label=FindLabel(otrack);
   otrack->SetLabel(label);  
+  Double_t low=0.;
+  Double_t up=0.51;    
+  otrack->CookdEdx(low,up);
 
   //remove clusters of found track
   for(Int_t nlay=0;nlay<AliITSgeomTGeo::GetNLayers();nlay++){
@@ -879,6 +813,28 @@ void AliITStrackerSA::StoreTrack(AliITStrackV2 *t,AliESDEvent *event, Bool_t pur
   Double_t sdedx[4]={0.,0.,0.,0.};
   for(Int_t i=0; i<4; i++) sdedx[i]=t->GetSampledEdx(i);
   outtrack.SetITSdEdxSamples(sdedx);
+
+
+  if(AliITSReconstructor::GetRecoParam()->GetSAUsedEdxInfo()){
+    Double_t mom=t->P();
+    Double_t ppid[AliPID::kSPECIES];
+    for(Int_t isp=0;isp<AliPID::kSPECIES;isp++) ppid[isp]=0.;
+    ppid[AliPID::kPion]=1.;
+    if(mom<0.7){
+      Double_t truncmean=t->GetdEdx();
+      Int_t ide=fITSPid->GetParticleIdFromdEdxVsP(mom,truncmean,kTRUE);
+      if(ide==AliPID::kProton){
+       ppid[AliPID::kProton]=1.;
+       ppid[AliPID::kPion]=0.;
+      }
+      else if(ide==AliPID::kKaon){ 
+       ppid[AliPID::kKaon]=1.; 
+       ppid[AliPID::kPion]=0.;
+      }
+    }
+    outtrack.SetITSpid(ppid);
+    outtrack.SetESDpid(ppid);    
+  }
   event->AddTrack(&outtrack);
 
   return;
@@ -905,33 +861,37 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
   }
 
  
-  Int_t ncl = fCluLayer[layer]->GetEntries();
+  Double_t phiExpect=fPhiEstimate;
+  Double_t lamExpect=fLambdac;
+
+  Int_t ncl = fCluLayer[layer]->GetEntriesFast();
   for (Int_t index=0; index<ncl; index++) {
-    AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->At(index);
+    AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->UncheckedAt(index);
     if (!c) continue;
-    if (c->GetQ()<=0) continue;
-    if(layer>1 && c->GetQ()<=fMinQ) continue;
     
-     AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
-     Double_t phi = arr->GetPhi();
-     if (TMath::Abs(phi-fPhiEstimate)>phiwindow) continue;
-
-     Double_t lambda = arr->GetLambda();
-     if (TMath::Abs(lambda-fLambdac)>lambdawindow) continue;
-
-     if(trs->GetNumberOfClustersSA()==trs->GetMaxNumberOfClusters()) return 0;
-     if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0;
-     Int_t orind = arr->GetOrInd();
-     trs->AddClusterSA(layer,orind);
-     trs->AddClusterMark(layer,index);
-       
-     nc++;
-     fLambdac=lambda;
-     fPhiEstimate=phi;
-
-     fPointc[0]=arr->GetX();
-     fPointc[1]=arr->GetY();
+    AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
 
+    Double_t lambda = arr->GetLambda();
+    if (TMath::Abs(lambda-lamExpect)>lambdawindow) continue;
+
+    Double_t phi = arr->GetPhi();
+    Double_t deltaPhi = phi-phiExpect;
+    if(deltaPhi>TMath::Pi()) deltaPhi-=2*TMath::Pi();
+    else if(deltaPhi<-TMath::Pi()) deltaPhi+=2*TMath::Pi();
+    if (TMath::Abs(deltaPhi)>phiwindow) continue;
+    
+    if(trs->GetNumberOfClustersSA()==trs->GetMaxNumberOfClusters()) return 0;
+    if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0;
+    Int_t orind = arr->GetOrInd();
+    trs->AddClusterSA(layer,orind);
+    trs->AddClusterMark(layer,index);
+    nc++;
+    fLambdac=lambda;
+    fPhiEstimate=phi;
+    
+    fPointc[0]=arr->GetX();
+    fPointc[1]=arr->GetY();
+    
   }
   return nc;
 }
@@ -940,7 +900,7 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
 Bool_t AliITStrackerSA::SetFirstPoint(Int_t lay, Int_t clu, Double_t* primaryVertex){
   // Sets the first point (seed) for tracking
 
-  AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[lay]->At(clu);
+  AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[lay]->UncheckedAt(clu);
   if(!cl) return kFALSE;
   if (cl->GetQ()<=0) return kFALSE;
   if(lay>1 && cl->GetQ()<=fMinQ) return kFALSE;