]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackV1.cxx
Fixing part of the Coding violation
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.cxx
index fca6528c32e7bc05b75aa6dec1727015d44b70e7..dacf6535ce449721c75558d82177400112214904 100644 (file)
 
 /* $Id$ */
 
+#include "AliESDtrack.h"
+#include "AliTracker.h"
+
 #include "AliTRDtrackV1.h"
 #include "AliTRDcluster.h"
 #include "AliTRDcalibDB.h"
 #include "AliTRDrecoParam.h"
 
-#include "AliESDtrack.h"
-
 ClassImp(AliTRDtrackV1)
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -38,7 +39,6 @@ ClassImp(AliTRDtrackV1)
 //_______________________________________________________________
 AliTRDtrackV1::AliTRDtrackV1() 
   :AliTRDtrack()
-  ,fRecoParam(0x0)
 {
   //
   // Default constructor
@@ -53,7 +53,6 @@ AliTRDtrackV1::AliTRDtrackV1()
 //_______________________________________________________________
 AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) 
   :AliTRDtrack(t)
-  ,fRecoParam(0x0)
 {
   //
   // Constructor from AliESDtrack
@@ -67,7 +66,6 @@ AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t)
 //_______________________________________________________________
 AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref) 
   :AliTRDtrack(ref)
-  ,fRecoParam(ref.fRecoParam)
 {
   //
   // Copy constructor
@@ -86,11 +84,9 @@ AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &ref)
 // }
        
 //_______________________________________________________________
-AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5]
-                           , const Double_t cov[15]
-                           , Double_t x, Double_t alpha)
+AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5], const Double_t cov[15]
+             , Double_t x, Double_t alpha)
   :AliTRDtrack()
-  ,fRecoParam(0x0)
 {
   //
   // The stand alone tracking constructor
@@ -145,7 +141,59 @@ AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5]
                //printf("%d N clusters plane %d [%d %d].\n", iplane, nclPlane, fTracklet[iplane].GetN2(), trklts[iplane].GetN());
        }
        //printf("N clusters in AliTRDtrackV1 %d.\n", ncl);
-       SetNumberOfClusters(ncl);
+       SetNumberOfClusters(/*ncl*/);
+}
+
+//_______________________________________________________________
+Bool_t AliTRDtrackV1::CookLabel(Float_t wrong)
+{
+       // set MC label for this tracklet
+
+  Int_t s[kMAXCLUSTERSPERTRACK][2];
+  for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
+    s[i][0] = -1;
+    s[i][1] =  0;
+  }
+
+  Bool_t labelAdded;
+       Int_t label;
+       AliTRDcluster *c    = 0x0;
+  for (Int_t ip = 0; ip < AliESDtrack::kTRDnPlanes; ip++) {
+               if(fTrackletIndex[ip] < 0) continue;
+               for (Int_t ic = 0; ic < AliTRDseed::knTimebins; ic++) {
+                       if(!(c = fTracklet[ip].GetClusters(ic))) continue;
+                       for (Int_t k = 0; k < 3; k++) { 
+                               label      = c->GetLabel(k);
+                               labelAdded = kFALSE; 
+                               Int_t j = 0;
+                               if (label >= 0) {
+                                       while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) {
+                                               if ((s[j][0] == label) || 
+                                                               (s[j][1] ==     0)) {
+                                                       s[j][0] = label; 
+                                                       s[j][1]++; 
+                                                       labelAdded = kTRUE;
+                                               }
+                                               j++;
+                                       }
+                               }
+                       }
+               }
+       }
+
+  Int_t max = 0;
+  label = -123456789;
+  for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) {
+    if (s[i][1] <= max) continue;
+               max   = s[i][1]; 
+               label = s[i][0];
+  }
+
+  if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label;
+
+  SetLabel(label); 
+       
+       return kTRUE;
 }
 
 //_______________________________________________________________
@@ -167,7 +215,7 @@ Bool_t AliTRDtrackV1::CookPID()
        // steer PID calculation @ tracklet level
        Double_t *prob = 0x0;
        fPIDquality = 0;
-       for(int itrklt=0; itrklt<AliESDtrack::kNPlane; itrklt++){
+       for(int itrklt=0; itrklt<AliESDtrack::kTRDnPlanes; itrklt++){
     //for (Int_t iSlice = 0; iSlice < AliESDtrack::kNSlice; iSlice++) fdEdxPlane[itrklt][iSlice] = -1.;
 
                if(fTrackletIndex[itrklt]<0) continue;
@@ -240,13 +288,41 @@ Bool_t AliTRDtrackV1::IsOwner() const
   // Check whether track owns the tracklets
   //
 
-       for (Int_t ip = 0; ip < AliESDtrack::kNPlane; ip++) {
+       for (Int_t ip = 0; ip < AliESDtrack::kTRDnPlanes; ip++) {
                if(fTrackletIndex[ip] < 0) continue;
                if(!fTracklet[ip].IsOwner()) return kFALSE;
        }
        return kTRUE;
 }
        
+//_____________________________________________________________________________
+void AliTRDtrackV1::MakeBackupTrack()
+{
+  //
+  // Creates a backup track
+  //
+
+  if (fBackupTrack) {
+    fBackupTrack->~AliTRDtrack();
+    new(fBackupTrack) AliTRDtrack((AliTRDtrack&)(*this));
+  }
+  fBackupTrack = new AliTRDtrack((AliTRDtrack&)(*this));
+}
+
+
+//___________________________________________________________
+void AliTRDtrackV1::SetNumberOfClusters() 
+{
+// Calculate the number of clusters attached to this track
+       
+       Int_t ncls = 0;
+       for(int ip=0; ip<6; ip++){
+               if(fTrackletIndex[ip] >= 0) ncls += fTracklet[ip].GetN();
+       }
+       AliKalmanTrack::SetNumberOfClusters(ncls);      
+}
+
+       
 //_______________________________________________________________
 void AliTRDtrackV1::SetOwner(Bool_t own)
 {
@@ -254,7 +330,7 @@ void AliTRDtrackV1::SetOwner(Bool_t own)
   // Toggle ownership of tracklets
   //
 
-       for (Int_t ip = 0; ip < AliESDtrack::kNPlane; ip++) {
+       for (Int_t ip = 0; ip < AliESDtrack::kTRDnPlanes; ip++) {
                if(fTrackletIndex[ip] < 0) continue;
                //AliInfo(Form("p[%d] index[%d]", ip, fTrackletIndex[ip]));
                fTracklet[ip].SetOwner(own);
@@ -268,7 +344,7 @@ void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t plane, Int_t index)
   // Set the tracklets
   //
 
-       if(plane < 0 || plane >=6) return;
+       if(plane < 0 || plane >= AliESDtrack::kTRDnPlanes) return;
        fTracklet[plane]      = (*trklt);
        fTrackletIndex[plane] = index;
 }
@@ -292,17 +368,22 @@ Bool_t  AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq)
   if(!AliExternalTrackParam::Update(p, cov)) return kFALSE;
        //Print();
 
+       AliTRDcluster *c = 0x0;
+       Int_t ic = 0; while(!(c = trklt->GetClusters(ic))) ic++;
+       AliTracker::FillResiduals(this, p, cov, c->GetVolumeId());
+
+
   // Register info to track
 //   Int_t n      = GetNumberOfClusters();
 //   fIndex[n]    = index;
 //   fClusters[n] = c;
-  SetNumberOfClusters(GetNumberOfClusters()+trklt->GetN());
+  SetNumberOfClusters(/*GetNumberOfClusters()+trklt->GetN()*/);
   SetChi2(GetChi2() + chisq);
        
        // update tracklet
        trklt->SetMomentum(GetP());
-  Double_t s = GetSnp(), t = GetTgl();
-       trklt->SetdQdl(TMath::Sqrt((1.0 - s*s) / (1.0 + t*t)));
+       trklt->SetSnp(GetSnp());
+       trklt->SetTgl(GetTgl());
        return kTRUE;
 }
 
@@ -310,20 +391,21 @@ Bool_t  AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq)
 void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track)
 {
   //
-  // Update the ESD track
+  // Update the TRD PID information in the ESD track
   //
+
+  track->SetNumberOfTRDslices(kNslice);
        
-       // copy dEdx to ESD
-       Float_t *dedx = 0x0;
-       for (Int_t ip = 0; ip < AliESDtrack::kNPlane; ip++) {
-               if(fTrackletIndex[ip] < 0) continue;
-               fTracklet[ip].CookdEdx(AliESDtrack::kNSlice);
-               dedx = fTracklet[ip].GetdEdx();
-               for (Int_t js = 0; js < AliESDtrack::kNSlice; js++) track->SetTRDsignals(dedx[js], ip, js);
-               //track->SetTRDTimBin(fTimBinPlane[i], i);
-       }
+  for (Int_t ip = 0; ip < kNplane; ip++) {
+      if(fTrackletIndex[ip] < 0) continue;
+      fTracklet[ip].CookdEdx(kNslice);
+      Float_t *dedx = fTracklet[ip].GetdEdx();
+      for (Int_t js = 0; js < kNslice; js++) { 
+          track->SetTRDslice(dedx[js], ip, js);
+      }
+  }
 
-       // copy PID to ESD
-       track->SetTRDpid(fPID);
-       track->SetTRDpidQuality(fPIDquality);
+  // copy PID to ESD
+  track->SetTRDpid(fPID);
+  track->SetTRDpidQuality(fPIDquality);
 }