]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDtrack.cxx
Using AliPHOSLoader instead of AliPHOSGetter
[u/mrichter/AliRoot.git] / STEER / AliESDtrack.cxx
index 31ea94cb9f2b30e8fc620e0198e0b5993514a1f0..6b7cfc65b3353ff260056fcd7ece6cab6f04a8fd 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliKalmanTrack.h"
 #include "AliLog.h"
 #include "AliTrackPointArray.h"
+#include "TPolyMarker3D.h"
 
 ClassImp(AliESDtrack)
 
@@ -139,6 +140,7 @@ AliESDtrack::AliESDtrack() :
   for (i=0;i<4;i++) {fTPCPoints[i]=0;}
   for (i=0;i<3;i++) {fTOFLabel[i]=0;}
   for (i=0;i<10;i++) {fTOFInfo[i]=0;}
+  for (i=0;i<12;i++) {fITSModule[i]=-1;}
 }
 
 //_______________________________________________________________________
@@ -220,6 +222,7 @@ AliESDtrack::AliESDtrack(const AliESDtrack& track):
   for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
   for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
   for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
+  for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
   for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
 
   if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
@@ -313,6 +316,7 @@ AliESDtrack::AliESDtrack(TParticle * part) :
   for (i=0;i<4;i++) {fTPCPoints[i]=0;}
   for (i=0;i<3;i++) {fTOFLabel[i]=0;}
   for (i=0;i<10;i++) {fTOFInfo[i]=0;}
+  for (i=0;i<12;i++) {fITSModule[i]=-1;}
 
   // Calculate the AliExternalTrackParam content
 
@@ -685,11 +689,12 @@ Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
     break;
 
   case kTRDout: case kTRDin: case kTRDrefit:
-    index=fFriendTrack->GetTRDindices();
+    index     = fFriendTrack->GetTRDindices();
     fTRDLabel = t->GetLabel(); 
-    fTRDncls=t->GetNumberOfClusters();
-    fTRDchi2=t->GetChi2();
-    for (Int_t i=0;i<fTRDncls;i++) index[i]=t->GetClusterIndex(i);
+    fTRDchi2  = t->GetChi2();
+    fTRDncls  = t->GetNumberOfClusters();
+    for (Int_t i=0;i<6;i++) index[i]=t->GetTrackletIndex(i);
+    
     fTRDsignal=t->GetPIDsignal();
     break;
   case kTRDbackup:
@@ -892,6 +897,64 @@ Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
   return fITSncls;
 }
 
+//_______________________________________________________________________
+Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
+                                        Float_t &xloc,Float_t &zloc) const {
+  //----------------------------------------------------------------------
+  // This function encodes in the module number also the status of cluster association
+  // "status" can have the following values: 
+  // 1 "found" (cluster is associated), 
+  // 2 "dead" (module is dead from OCDB), 
+  // 3 "skipped" (module or layer forced to be skipped),
+  // 4 "outinz" (track out of z acceptance), 
+  // 5 "nocls" (no clusters in the road), 
+  // 6 "norefit" (cluster rejected during refit), 
+  // 7 "deadzspd" (holes in z in SPD)
+  // Also given are the coordinates of the crossing point of track and module
+  // (in the local module ref. system)
+  // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
+  //----------------------------------------------------------------------
+
+  if(fITSModule[ilayer]==-1) {
+    AliError("fModule was not set !");
+    idet = -1;
+    status=0;
+    xloc=-99.; zloc=-99.;
+    return kFALSE;
+  }
+
+  Int_t module = fITSModule[ilayer];
+
+  idet = Int_t(module/1000000);
+
+  module -= idet*1000000;
+
+  status = Int_t(module/100000);
+
+  module -= status*100000;
+
+  Int_t signs = Int_t(module/10000);
+
+  module-=signs*10000;
+
+  Int_t xInt = Int_t(module/100);
+  module -= xInt*100;
+
+  Int_t zInt = module;
+
+  if(signs==1) { xInt*=1; zInt*=1; }
+  if(signs==2) { xInt*=1; zInt*=-1; }
+  if(signs==3) { xInt*=-1; zInt*=1; }
+  if(signs==4) { xInt*=-1; zInt*=-1; }
+
+  xloc = 0.1*(Float_t)xInt;
+  zloc = 0.1*(Float_t)zInt;
+
+  if(status==4) idet = -1;
+
+  return kTRUE;
+}
+
 //_______________________________________________________________________
 UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
   //---------------------------------------------------------------------
@@ -948,6 +1011,18 @@ UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
   return fTRDncls;
 }
 
+//_______________________________________________________________________
+UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
+  //---------------------------------------------------------------------
+  // This function returns indices of the assigned TRD tracklets 
+  //---------------------------------------------------------------------
+  if (idx!=0) {
+     Int_t *index=fFriendTrack->GetTRDindices();
+     for (Int_t i=0; i<6/*AliESDfriendTrack::kMaxTRDcluster*/; i++) idx[i]=index[i];
+  }
+  return fTRDncls;
+}
+
 //_______________________________________________________________________
 void AliESDtrack::SetTRDpid(const Double_t *p) {  
   // Sets values for the probability of each particle type (in TRD)
@@ -1059,58 +1134,28 @@ Bool_t AliESDtrack::RelateToVertex
 
   if (!vtx) return kFALSE;
 
-  Double_t alpha=GetAlpha();
-  Double_t sn=TMath::Sin(alpha), cs=TMath::Cos(alpha);
-  Double_t x=GetX(), y=GetParameter()[0], snp=GetParameter()[2];
-  Double_t xv= vtx->GetXv()*cs + vtx->GetYv()*sn;
-  Double_t yv=-vtx->GetXv()*sn + vtx->GetYv()*cs, zv=vtx->GetZv();
-  x-=xv; y-=yv;
-
-  //Estimate the impact parameter neglecting the track curvature
-  Double_t d=TMath::Abs(x*snp - y*TMath::Sqrt(1.- snp*snp));
-  if (d > maxd) return kFALSE; 
-
-  //Propagate to the DCA
-  Double_t crv=kB2C*b*GetParameter()[4];
-  if (TMath::Abs(b) < kAlmost0Field) crv=0.;
-
-  Double_t tgfv=-(crv*x - snp)/(crv*y + TMath::Sqrt(1.-snp*snp));
-  sn=tgfv/TMath::Sqrt(1.+ tgfv*tgfv);
-  if (TMath::Abs(tgfv)>0.) cs = sn/tgfv;
-  else cs=1.;
+  Double_t dz[2],cov[3];
+  if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
 
-  x = xv*cs + yv*sn;
-  yv=-xv*sn + yv*cs; xv=x;
-
-  if (!Propagate(alpha+TMath::ASin(sn),xv,b)) return kFALSE;
-
-  fD = GetParameter()[0] - yv;
-  fZ = GetParameter()[1] - zv;
+  fD = dz[0];
+  fZ = dz[1];  
+  fCdd = cov[0];
+  fCdz = cov[1];
+  fCzz = cov[2];
   
-  Double_t cov[6]; vtx->GetCovMatrix(cov);
-
-  //***** Improvements by A.Dainese
-  alpha=GetAlpha(); sn=TMath::Sin(alpha); cs=TMath::Cos(alpha);
-  Double_t s2ylocvtx = cov[0]*sn*sn + cov[2]*cs*cs - 2.*cov[1]*cs*sn;
-  fCdd = GetCovariance()[0] + s2ylocvtx;   // neglecting correlations
-  fCdz = GetCovariance()[1];               // between (x,y) and z
-  fCzz = GetCovariance()[2] + cov[5];      // in vertex's covariance matrix
-  //*****
+  Double_t covar[6]; vtx->GetCovMatrix(covar);
+  Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
+  Double_t c[3]={covar[2],0.,covar[5]};
 
-  {//Try to constrain 
-    Double_t p[2]={yv,zv}, c[3]={cov[2],0.,cov[5]};
-    Double_t chi2=GetPredictedChi2(p,c);
+  Double_t chi2=GetPredictedChi2(p,c);
+  if (chi2>77.) return kFALSE;
 
-    if (chi2>77.) return kFALSE;
-
-    AliExternalTrackParam tmp(*this);
-    if (!tmp.Update(p,c)) return kFALSE;
-
-    fCchi2=chi2;
-    if (!fCp) fCp=new AliExternalTrackParam();
-    new (fCp) AliExternalTrackParam(tmp);
-  }
+  delete fCp;
+  fCp=new AliExternalTrackParam(*this);  
 
+  if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
+  
+  fCchi2=chi2;
   return kTRUE;
 }
 
@@ -1158,3 +1203,59 @@ void AliESDtrack::Print(Option_t *) const {
   }
 } 
 
+
+//
+// Draw functionality
+// Origin: Marian Ivanov, Marian.Ivanov@cern.ch
+//
+void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
+  //
+  // Fill points in the polymarker
+  //
+  TObjArray arrayRef;
+  arrayRef.AddLast(new AliExternalTrackParam(*this));
+  if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
+  if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
+  //
+  Double_t mpos[3]={0,0,0};
+  Int_t entries=arrayRef.GetEntries();
+  for (Int_t i=0;i<entries;i++){
+    Double_t pos[3];
+    ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
+    mpos[0]+=pos[0]/entries;
+    mpos[1]+=pos[1]/entries;
+    mpos[2]+=pos[2]/entries;    
+  }
+  // Rotate to the mean position
+  //
+  Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
+  for (Int_t i=0;i<entries;i++){
+    Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
+    if (!res) delete arrayRef.RemoveAt(i);
+  }
+  Int_t counter=0;
+  for (Double_t r=minR; r<maxR; r+=stepR){
+    Double_t sweight=0;
+    Double_t mlpos[3]={0,0,0};
+    for (Int_t i=0;i<entries;i++){
+      Double_t point[3]={0,0,0};
+      AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
+      if (!param) continue;
+      if (param->GetXYZAt(r,magF,point)){
+       Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
+       sweight+=weight;
+       mlpos[0]+=point[0]*weight;
+       mlpos[1]+=point[1]*weight;
+       mlpos[2]+=point[2]*weight;
+      }
+    }
+    if (sweight>0){
+      mlpos[0]/=sweight;
+      mlpos[1]/=sweight;
+      mlpos[2]/=sweight;      
+      pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
+      printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
+      counter++;
+    }
+  }
+}