First version of the HLT ITS tracker
authorsgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Jun 2009 13:08:35 +0000 (13:08 +0000)
committersgorbuno <sgorbuno@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Jun 2009 13:08:35 +0000 (13:08 +0000)
HLT/ITS/tracking/AliHLTITSDetector.cxx [new file with mode: 0644]
HLT/ITS/tracking/AliHLTITSDetector.h [new file with mode: 0644]
HLT/ITS/tracking/AliHLTITSLayer.cxx [new file with mode: 0644]
HLT/ITS/tracking/AliHLTITSLayer.h [new file with mode: 0644]
HLT/ITS/tracking/AliHLTITSTrack.cxx [new file with mode: 0644]
HLT/ITS/tracking/AliHLTITSTrack.h [new file with mode: 0644]
HLT/ITS/tracking/AliHLTVertexer.cxx [new file with mode: 0644]
HLT/ITS/tracking/AliHLTVertexer.h [new file with mode: 0644]
HLT/ITS/tracking/AliITStrackerHLT.cxx [new file with mode: 0644]
HLT/ITS/tracking/AliITStrackerHLT.h [new file with mode: 0644]
HLT/libAliHLTITS.pkg

diff --git a/HLT/ITS/tracking/AliHLTITSDetector.cxx b/HLT/ITS/tracking/AliHLTITSDetector.cxx
new file mode 100644 (file)
index 0000000..b8b98b8
--- /dev/null
@@ -0,0 +1,97 @@
+// **************************************************************************
+// This file is property of and copyright by the ALICE HLT Project          *
+// ALICE Experiment at CERN, All rights reserved.                           *
+//                                                                          *
+// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
+//                  for The ALICE HLT Project.                              *
+//                                                                          *
+// Permission to use, copy, modify and distribute this software and its     *
+// documentation strictly for non-commercial purposes is hereby granted     *
+// without fee, provided that the above copyright notice appears in all     *
+// copies and that both the copyright notice and this permission notice     *
+// appear in the supporting documentation. The authors make no claims       *
+// about the suitability of this software for any purpose. It is            *
+// provided "as is" without express or implied warranty.                    *
+//                                                                          *
+//***************************************************************************
+
+
+#include "AliHLTITSDetector.h"
+
+#include "AliITSgeomTGeo.h"
+#include "AliITSCalibration.h"
+#include "AliITSsegmentation.h"
+#include "AliITSDetTypeRec.h"
+
+//------------------------------------------------------------------------
+AliHLTITSDetector::AliHLTITSDetector(const AliHLTITSDetector& det):
+fR(det.fR),
+fRmisal(det.fRmisal),
+fPhi(det.fPhi),
+fSinPhi(det.fSinPhi),
+fCosPhi(det.fCosPhi),
+fYmin(det.fYmin),
+fYmax(det.fYmax),
+fZmin(det.fZmin),
+fZmax(det.fZmax),
+fIsBad(det.fIsBad),
+fNChips(det.fNChips),
+fChipIsBad(det.fChipIsBad)
+{
+  //Copy constructor
+}
+//------------------------------------------------------------------------
+void AliHLTITSDetector::ReadBadDetectorAndChips(Int_t ilayer,Int_t idet,
+                                               const AliITSDetTypeRec *detTypeRec)
+{
+  //--------------------------------------------------------------------
+  // Read bad detectors and chips from calibration objects in AliITSDetTypeRec
+  //--------------------------------------------------------------------
+
+  // In AliITSDetTypeRec, detector numbers go from 0 to 2197
+  // while in the tracker they start from 0 for each layer
+  for(Int_t il=0; il<ilayer; il++) 
+    idet += AliITSgeomTGeo::GetNLadders(il+1)*AliITSgeomTGeo::GetNDetectors(il+1);
+
+  Int_t detType;
+  if (ilayer==0 || ilayer==1) {        // ----------  SPD
+    detType = 0;
+  } else if (ilayer==2 || ilayer==3) { // ----------  SDD
+    detType = 1;
+  } else if (ilayer==4 || ilayer==5) { // ----------  SSD
+    detType = 2;
+  } else {
+    printf("AliITStrackerHLT::AliHLTITSDetector::InitBadFromOCDB: Wrong layer number %d\n",ilayer);
+    return;
+  }
+
+  // Get calibration from AliITSDetTypeRec
+  AliITSCalibration *calib = (AliITSCalibration*)detTypeRec->GetCalibrationModel(idet);
+  calib->SetModuleIndex(idet);
+  AliITSCalibration *calibSPDdead = 0;
+  if(detType==0) calibSPDdead = (AliITSCalibration*)detTypeRec->GetSPDDeadModel(idet); // TEMPORARY
+  if (calib->IsBad() ||
+      (detType==0 && calibSPDdead->IsBad())) // TEMPORARY
+    {
+      SetBad();
+      //      printf("lay %d bad %d\n",ilayer,idet);
+    }
+
+  // Get segmentation from AliITSDetTypeRec
+  AliITSsegmentation *segm = (AliITSsegmentation*)detTypeRec->GetSegmentationModel(detType);
+
+  // Read info about bad chips
+  fNChips = segm->GetMaximumChipIndex()+1;
+  //printf("ilayer %d  detType %d idet %d fNChips %d %d  GetNumberOfChips %d\n",ilayer,detType,idet,fNChips,segm->GetMaximumChipIndex(),segm->GetNumberOfChips());
+  if(fChipIsBad) { delete [] fChipIsBad; fChipIsBad=NULL; }
+  fChipIsBad = new Bool_t[fNChips];
+  for (Int_t iCh=0;iCh<fNChips;iCh++) {
+    fChipIsBad[iCh] = calib->IsChipBad(iCh);
+    if (detType==0 && calibSPDdead->IsChipBad(iCh)) fChipIsBad[iCh] = kTRUE; // TEMPORARY
+    //if(fChipIsBad[iCh]) {printf("lay %d det %d bad chip %d\n",ilayer,idet,iCh);}
+  }
+
+  return;
+}
+
+
diff --git a/HLT/ITS/tracking/AliHLTITSDetector.h b/HLT/ITS/tracking/AliHLTITSDetector.h
new file mode 100644 (file)
index 0000000..d2eb4d8
--- /dev/null
@@ -0,0 +1,78 @@
+// ************************************************************************
+// This file is property of and copyright by the ALICE HLT Project        *
+// ALICE Experiment at CERN, All rights reserved.                         *
+// See cxx source for full Copyright notice                               *
+//                                                                        *
+//*************************************************************************
+
+#ifndef ALIHLTITSDETECTOR_H
+#define ALIHLTITSDETECTOR_H
+
+#include "AliITSRecPoint.h"
+#include "TMath.h"
+
+class AliITSDetTypeRec;
+
+/**
+ * @class AliHLTITSDetector
+ *
+ * The AliHLTTPCCAHit class is the internal representation
+ * of the TPC clusters for the AliHLTTPCCATracker algorithm.
+ *
+ */
+class AliHLTITSDetector 
+{ 
+ public:
+  AliHLTITSDetector():fR(0),fRmisal(0),fPhi(0),fSinPhi(0),fCosPhi(0),fYmin(0),fYmax(0),fZmin(0),fZmax(0),fIsBad(kFALSE),fNChips(0),fChipIsBad(0) {}
+  AliHLTITSDetector(Double_t r,Double_t phi):fR(r),fRmisal(r),fPhi(phi),fSinPhi(TMath::Sin(phi)),fCosPhi(TMath::Cos(phi)),fYmin(10000),fYmax(-1000),fZmin(10000),fZmax(-1000),fIsBad(kFALSE),fNChips(0),fChipIsBad(0) {}
+  ~AliHLTITSDetector() {if(fChipIsBad) delete [] fChipIsBad;}
+  inline void GetGlobalXYZ( const AliITSRecPoint *cl, Double_t xyz[3]) const;
+  Double_t GetR()   const {return fR;}
+  Double_t GetRmisal()   const {return fRmisal;}
+  Double_t GetPhi() const {return fPhi;}
+  Double_t GetYmin() const {return fYmin;}
+  Double_t GetYmax() const {return fYmax;}
+  Double_t GetZmin() const {return fZmin;}
+  Double_t GetZmax() const {return fZmax;}
+  Bool_t   IsBad() const {return fIsBad;}
+  Int_t    GetNChips() const {return fNChips;}
+  Bool_t   IsChipBad(Int_t iChip) const {return (fChipIsBad ? fChipIsBad[iChip] : kFALSE);}
+  void SetRmisal(Double_t rmisal) {fRmisal = rmisal;}
+  void SetYmin(Double_t min) {fYmin = min;}
+  void SetYmax(Double_t max) {fYmax = max;}
+  void SetZmin(Double_t min) {fZmin = min;}
+  void SetZmax(Double_t max) {fZmax = max;}
+  void SetBad() {fIsBad = kTRUE;}
+  void ReadBadDetectorAndChips(Int_t ilayer,Int_t idet,const AliITSDetTypeRec *detTypeRec);
+
+ private:
+
+  AliHLTITSDetector(const AliHLTITSDetector& det);
+  AliHLTITSDetector & operator=(const AliHLTITSDetector& det){
+    this->~AliHLTITSDetector();new(this) AliHLTITSDetector(det);
+    return *this;}
+  Double_t fR;    // polar coordinates: r 
+  Double_t fRmisal;    // polar coordinates: r, with misalignment 
+  Double_t fPhi;  // polar coordinates: phi
+  Double_t fSinPhi; // sin of phi;
+  Double_t fCosPhi; // cos of phi 
+  Double_t fYmin;   //  local y minimal
+  Double_t fYmax;   //  local max y
+  Double_t fZmin;   //  local z min
+  Double_t fZmax;   //  local z max
+  Bool_t fIsBad;    // is detector dead or noisy?
+  Int_t fNChips;    // number of chips
+  Bool_t *fChipIsBad; //[fNChips] is chip dead or noisy? 
+};
+
+inline void  AliHLTITSDetector::GetGlobalXYZ(const AliITSRecPoint *cl, Double_t xyz[3]) const
+{
+  //
+  // get cluster coordinates in global cooordinate 
+  //
+  xyz[2] = cl->GetZ();
+  xyz[0] = fR*fCosPhi - cl->GetY()*fSinPhi;
+  xyz[1] = fR*fSinPhi + cl->GetY()*fCosPhi;
+}
+
+#endif
diff --git a/HLT/ITS/tracking/AliHLTITSLayer.cxx b/HLT/ITS/tracking/AliHLTITSLayer.cxx
new file mode 100644 (file)
index 0000000..d0b4e44
--- /dev/null
@@ -0,0 +1,603 @@
+// **************************************************************************
+// This file is property of and copyright by the ALICE HLT Project          *
+// ALICE Experiment at CERN, All rights reserved.                           *
+//                                                                          *
+// Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
+//                  for The ALICE HLT Project.                              *
+//                                                                          *
+// Permission to use, copy, modify and distribute this software and its     *
+// documentation strictly for non-commercial purposes is hereby granted     *
+// without fee, provided that the above copyright notice appears in all     *
+// copies and that both the copyright notice and this permission notice     *
+// appear in the supporting documentation. The authors make no claims       *
+// about the suitability of this software for any purpose. It is            *
+// provided "as is" without express or implied warranty.                    *
+//                                                                          *
+//***************************************************************************
+
+
+#include "AliHLTITSLayer.h"
+
+//------------------------------------------------------------------------
+AliHLTITSLayer::AliHLTITSLayer():
+fR(0),
+fPhiOffset(0),
+fNladders(0),
+fZOffset(0),
+fNdetectors(0),
+fDetectors(0),
+fN(0),
+fDy5(0),
+fDy10(0),
+fDy20(0),
+fClustersCs(0),
+fClusterIndexCs(0),
+fYcs(0),
+fZcs(0),
+fNcs(0),
+fCurrentSlice(-1),
+fZmax(0),
+fYmin(0),
+fYmax(0),
+fI(0),
+fImax(0),
+fSkip(0),
+fAccepted(0),
+fRoad(0){
+  //--------------------------------------------------------------------
+  //default AliHLTITSLayer constructor
+  //--------------------------------------------------------------------
+  for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
+    fClusterWeight[i]=0;
+    fClusterTracks[0][i]=-1;
+    fClusterTracks[1][i]=-1;
+    fClusterTracks[2][i]=-1;    
+    fClusterTracks[3][i]=-1;    
+  }
+}
+//------------------------------------------------------------------------
+AliHLTITSLayer::
+AliHLTITSLayer(Double_t r,Double_t p,Double_t z,Int_t nl,Int_t nd):
+fR(r),
+fPhiOffset(p),
+fNladders(nl),
+fZOffset(z),
+fNdetectors(nd),
+fDetectors(0),
+fN(0),
+fDy5(0),
+fDy10(0),
+fDy20(0),
+fClustersCs(0),
+fClusterIndexCs(0),
+fYcs(0),
+fZcs(0),
+fNcs(0),
+fCurrentSlice(-1),
+fZmax(0),
+fYmin(0),
+fYmax(0),
+fI(0),
+fImax(0),
+fSkip(0),
+fAccepted(0),
+fRoad(0) {
+  //--------------------------------------------------------------------
+  //main AliHLTITSLayer constructor
+  //--------------------------------------------------------------------
+  fDetectors=new AliHLTITSDetector[fNladders*fNdetectors];
+  fRoad=2*fR*TMath::Sqrt(TMath::Pi()/1.);//assuming that there's only one cluster
+}
+//------------------------------------------------------------------------
+AliHLTITSLayer::AliHLTITSLayer(const AliHLTITSLayer& layer):
+fR(layer.fR),
+fPhiOffset(layer.fPhiOffset),
+fNladders(layer.fNladders),
+fZOffset(layer.fZOffset),
+fNdetectors(layer.fNdetectors),
+fDetectors(layer.fDetectors),
+fN(layer.fN),
+fDy5(layer.fDy5),
+fDy10(layer.fDy10),
+fDy20(layer.fDy20),
+fClustersCs(layer.fClustersCs),
+fClusterIndexCs(layer.fClusterIndexCs),
+fYcs(layer.fYcs),
+fZcs(layer.fZcs),
+fNcs(layer.fNcs),
+fCurrentSlice(layer.fCurrentSlice),
+fZmax(layer.fZmax),
+fYmin(layer.fYmin),
+fYmax(layer.fYmax),
+fI(layer.fI),
+fImax(layer.fImax),
+fSkip(layer.fSkip),
+fAccepted(layer.fAccepted),
+fRoad(layer.fRoad){
+  //Copy constructor
+}
+//------------------------------------------------------------------------
+AliHLTITSLayer::~AliHLTITSLayer() {
+  //--------------------------------------------------------------------
+  // AliHLTITSLayer destructor
+  //--------------------------------------------------------------------
+  delete [] fDetectors;
+  for (Int_t i=0; i<fN; i++) delete fClusters[i];
+  for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
+    fClusterWeight[i]=0;
+    fClusterTracks[0][i]=-1;
+    fClusterTracks[1][i]=-1;
+    fClusterTracks[2][i]=-1;    
+    fClusterTracks[3][i]=-1;    
+  }
+}
+//------------------------------------------------------------------------
+void AliHLTITSLayer::ResetClusters() {
+  //--------------------------------------------------------------------
+  // This function removes loaded clusters
+  //--------------------------------------------------------------------
+  for (Int_t i=0; i<fN; i++) delete fClusters[i];
+  for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++){
+    fClusterWeight[i]=0;
+    fClusterTracks[0][i]=-1;
+    fClusterTracks[1][i]=-1;
+    fClusterTracks[2][i]=-1;    
+    fClusterTracks[3][i]=-1;  
+  }
+  
+  fN=0;
+  fI=0;
+}
+//------------------------------------------------------------------------
+void AliHLTITSLayer::ResetWeights() {
+  //--------------------------------------------------------------------
+  // This function reset weights of the clusters
+  //--------------------------------------------------------------------
+  for (Int_t i=0; i<AliITSRecoParam::GetMaxClusterPerLayer(); i++) {
+    fClusterWeight[i]=0;
+    fClusterTracks[0][i]=-1;
+    fClusterTracks[1][i]=-1;
+    fClusterTracks[2][i]=-1;    
+    fClusterTracks[3][i]=-1;  
+  }
+  for (Int_t i=0; i<fN;i++) {
+    AliITSRecPoint * cl = (AliITSRecPoint*)GetCluster(i);
+    if (cl&&cl->IsUsed()) cl->Use();
+  }
+
+}
+//------------------------------------------------------------------------
+void AliHLTITSLayer::ResetRoad() {
+  //--------------------------------------------------------------------
+  // This function calculates the road defined by the cluster density
+  //--------------------------------------------------------------------
+  Int_t n=0;
+  for (Int_t i=0; i<fN; i++) {
+     if (TMath::Abs(fClusters[i]->GetZ())<fR) n++;
+  }
+  if (n>1) fRoad=2*fR*TMath::Sqrt(TMath::Pi()/n);
+}
+//------------------------------------------------------------------------
+Int_t AliHLTITSLayer::InsertCluster(AliITSRecPoint *cl) {
+  //--------------------------------------------------------------------
+  //This function adds a cluster to this layer
+  //--------------------------------------------------------------------
+  if (fN==AliITSRecoParam::GetMaxClusterPerLayer()) {
+    ::Error("InsertCluster","Too many clusters !\n");
+    return 1;
+  }
+  fCurrentSlice=-1;
+  fClusters[fN]=cl;
+  fN++;
+  AliHLTITSDetector &det=GetDetector(cl->GetDetectorIndex());    
+  if (cl->GetY()<det.GetYmin()) det.SetYmin(cl->GetY());
+  if (cl->GetY()>det.GetYmax()) det.SetYmax(cl->GetY());
+  if (cl->GetZ()<det.GetZmin()) det.SetZmin(cl->GetZ());
+  if (cl->GetZ()>det.GetZmax()) det.SetZmax(cl->GetZ());
+                            
+  return 0;
+}
+//------------------------------------------------------------------------
+void  AliHLTITSLayer::SortClusters()
+{
+  //
+  //sort clusters
+  //
+  AliITSRecPoint **clusters = new AliITSRecPoint*[fN];
+  Float_t *z                = new Float_t[fN];
+  Int_t   * index           = new Int_t[fN];
+  //
+  for (Int_t i=0;i<fN;i++){
+    z[i] = fClusters[i]->GetZ();
+  }
+  TMath::Sort(fN,z,index,kFALSE);
+  for (Int_t i=0;i<fN;i++){
+    clusters[i] = fClusters[index[i]];
+  }
+  //
+  for (Int_t i=0;i<fN;i++){
+    fClusters[i] = clusters[i];
+    fZ[i]        = fClusters[i]->GetZ();
+    AliHLTITSDetector &det=GetDetector(fClusters[i]->GetDetectorIndex());    
+    Double_t y=fR*det.GetPhi() + fClusters[i]->GetY();
+    if (y>2.*fR*TMath::Pi()) y -= 2.*fR*TMath::Pi();
+    fY[i] = y;
+  }
+  delete[] index;
+  delete[] z;
+  delete[] clusters;
+  //
+
+  fYB[0]=10000000;
+  fYB[1]=-10000000;
+  for (Int_t i=0;i<fN;i++){
+    if (fY[i]<fYB[0]) fYB[0]=fY[i];
+    if (fY[i]>fYB[1]) fYB[1]=fY[i];
+    fClusterIndex[i] = i;
+  }
+  //
+  // fill slices
+  fDy5 = (fYB[1]-fYB[0])/5.;
+  fDy10 = (fYB[1]-fYB[0])/10.;
+  fDy20 = (fYB[1]-fYB[0])/20.;
+  for (Int_t i=0;i<6;i++)  fN5[i] =0;  
+  for (Int_t i=0;i<11;i++) fN10[i]=0;  
+  for (Int_t i=0;i<21;i++) fN20[i]=0;
+  //  
+  for (Int_t i=0;i<6;i++) {fBy5[i][0] =  fYB[0]+(i-0.75)*fDy5; fBy5[i][1] =  fYB[0]+(i+0.75)*fDy5;}
+  for (Int_t i=0;i<11;i++) {fBy10[i][0] =  fYB[0]+(i-0.75)*fDy10; fBy10[i][1] =  fYB[0]+(i+0.75)*fDy10;} 
+  for (Int_t i=0;i<21;i++) {fBy20[i][0] =  fYB[0]+(i-0.75)*fDy20; fBy20[i][1] =  fYB[0]+(i+0.75)*fDy20;}
+  //
+  //
+  for (Int_t i=0;i<fN;i++)
+    for (Int_t irot=-1;irot<=1;irot++){
+      Float_t curY = fY[i]+irot*TMath::TwoPi()*fR; 
+      // slice 5
+      for (Int_t slice=0; slice<6;slice++){
+       if (fBy5[slice][0]<curY && curY<fBy5[slice][1]&&fN5[slice]<AliITSRecoParam::GetMaxClusterPerLayer5()){
+         fClusters5[slice][fN5[slice]] = fClusters[i];
+         fY5[slice][fN5[slice]] = curY;
+         fZ5[slice][fN5[slice]] = fZ[i];
+         fClusterIndex5[slice][fN5[slice]]=i;
+         fN5[slice]++;
+       }
+      }
+      // slice 10
+      for (Int_t slice=0; slice<11;slice++){
+       if (fBy10[slice][0]<curY && curY<fBy10[slice][1]&&fN10[slice]<AliITSRecoParam::GetMaxClusterPerLayer10()){
+         fClusters10[slice][fN10[slice]] = fClusters[i];
+         fY10[slice][fN10[slice]] = curY;
+         fZ10[slice][fN10[slice]] = fZ[i];
+         fClusterIndex10[slice][fN10[slice]]=i;
+         fN10[slice]++;
+       }
+      }
+      // slice 20
+      for (Int_t slice=0; slice<21;slice++){
+       if (fBy20[slice][0]<curY && curY<fBy20[slice][1]&&fN20[slice]<AliITSRecoParam::GetMaxClusterPerLayer20()){
+         fClusters20[slice][fN20[slice]] = fClusters[i];
+         fY20[slice][fN20[slice]] = curY;
+         fZ20[slice][fN20[slice]] = fZ[i];
+         fClusterIndex20[slice][fN20[slice]]=i;
+         fN20[slice]++;
+       }
+      }      
+    }
+
+  //
+  // consistency check
+  //
+  for (Int_t i=0;i<fN-1;i++){
+    if (fZ[i]>fZ[i+1]){
+      printf("Bug\n");
+    }
+  }
+  //
+  for (Int_t slice=0;slice<21;slice++)
+  for (Int_t i=0;i<fN20[slice]-1;i++){
+    if (fZ20[slice][i]>fZ20[slice][i+1]){
+      printf("Bug\n");
+    }
+  }
+
+
+}
+//------------------------------------------------------------------------
+Int_t AliHLTITSLayer::FindClusterIndex(Float_t z) const {
+  //--------------------------------------------------------------------
+  // This function returns the index of the nearest cluster 
+  //--------------------------------------------------------------------
+  Int_t ncl=0;
+  const Float_t *zcl;  
+  if (fCurrentSlice<0) {
+    ncl = fN;
+    zcl   = fZ;
+  }
+  else{
+    ncl   = fNcs;
+    zcl   = fZcs;;
+  }
+  
+  if (ncl==0) return 0;
+  Int_t b=0, e=ncl-1, m=(b+e)/2;
+  for (; b<e; m=(b+e)/2) {
+    //    if (z > fClusters[m]->GetZ()) b=m+1;
+    if (z > zcl[m]) b=m+1;
+    else e=m; 
+  }
+  return m;
+}
+
+//------------------------------------------------------------------------
+void AliHLTITSLayer::
+SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) {
+  //--------------------------------------------------------------------
+  // This function sets the "window"
+  //--------------------------------------------------------------------
+  Double_t circle=2*TMath::Pi()*fR;
+  fYmin = ymin; fYmax =ymax;
+  Float_t ymiddle = (fYmin+fYmax)*0.5;
+  if (ymiddle<fYB[0]) {
+    fYmin+=circle; fYmax+=circle; ymiddle+=circle;
+  } else if (ymiddle>fYB[1]) {
+    fYmin-=circle; fYmax-=circle; ymiddle-=circle;
+  }
+  
+  //
+  fCurrentSlice =-1;
+  // defualt take all
+  fClustersCs = fClusters;
+  fClusterIndexCs = fClusterIndex;
+  fYcs  = fY;
+  fZcs  = fZ;
+  fNcs  = fN;
+  //
+  //is in 20 slice?
+  if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy20){
+    Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy20);
+    if (slice<0) slice=0;
+    if (slice>20) slice=20;
+    Bool_t isOK = (fYmin>fBy20[slice][0]&&fYmax<fBy20[slice][1]);
+    if (isOK) {
+      fCurrentSlice=slice;
+      fClustersCs = fClusters20[fCurrentSlice];
+      fClusterIndexCs = fClusterIndex20[fCurrentSlice];
+      fYcs  = fY20[fCurrentSlice];
+      fZcs  = fZ20[fCurrentSlice];
+      fNcs  = fN20[fCurrentSlice];
+    }
+  }  
+  //
+  //is in 10 slice?
+  if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy10){
+    Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy10);
+    if (slice<0) slice=0;
+    if (slice>10) slice=10;
+    Bool_t isOK = (fYmin>fBy10[slice][0]&&fYmax<fBy10[slice][1]);
+    if (isOK) {
+      fCurrentSlice=slice;
+      fClustersCs = fClusters10[fCurrentSlice];
+      fClusterIndexCs = fClusterIndex10[fCurrentSlice];
+      fYcs  = fY10[fCurrentSlice];
+      fZcs  = fZ10[fCurrentSlice];
+      fNcs  = fN10[fCurrentSlice];
+    }
+  }  
+  //
+  //is in 5 slice?
+  if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy5){
+    Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy5);
+    if (slice<0) slice=0;
+    if (slice>5) slice=5;
+    Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax<fBy5[slice][1]);
+    if (isOK) {
+      fCurrentSlice=slice;
+      fClustersCs = fClusters5[fCurrentSlice];
+      fClusterIndexCs = fClusterIndex5[fCurrentSlice];
+      fYcs  = fY5[fCurrentSlice];
+      fZcs  = fZ5[fCurrentSlice];
+      fNcs  = fN5[fCurrentSlice];
+    }
+  }  
+  //  
+  fI=FindClusterIndex(zmin); fZmax=zmax;
+  fImax = TMath::Min(FindClusterIndex(zmax)+1,fNcs);
+  fSkip = 0;
+  fAccepted =0;
+
+  return;
+}
+//------------------------------------------------------------------------
+Int_t AliHLTITSLayer::
+FindDetectorIndex(Double_t phi, Double_t z) const {
+  //--------------------------------------------------------------------
+  //This function finds the detector crossed by the track
+  //--------------------------------------------------------------------
+  Double_t dphi;
+  if (fZOffset<0)            // old geometry
+    dphi = -(phi-fPhiOffset);
+  else                       // new geometry
+    dphi = phi-fPhiOffset;
+
+
+  if      (dphi <  0) dphi += 2*TMath::Pi();
+  else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
+  Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
+  if (np>=fNladders) np-=fNladders;
+  if (np<0)          np+=fNladders;
+
+
+  Double_t dz=fZOffset-z;
+  Double_t nnz = dz*(fNdetectors-1)*0.5/fZOffset+0.5;
+  Int_t nz = (nnz<0 ? -1 : (Int_t)nnz);
+  if (nz>=fNdetectors) return -1;
+  if (nz<0)            return -1;
+
+  // ad hoc correction for 3rd ladder of SDD inner layer,
+  // which is reversed (rotated by pi around local y)
+  // this correction is OK only from AliITSv11Hybrid onwards
+  if (GetR()>12. && GetR()<20.) { // SDD inner
+    if(np==2) { // 3rd ladder
+      nz = (fNdetectors-1) - nz;
+    } 
+  }
+  //printf("ndet %d phi %f z %f  np %d nz %d\n",fNdetectors,phi,z,np,nz);
+
+
+  return np*fNdetectors + nz;
+}
+//------------------------------------------------------------------------
+const AliITSRecPoint *AliHLTITSLayer::GetNextCluster(Int_t &ci,Bool_t test)
+{
+  //--------------------------------------------------------------------
+  // This function returns clusters within the "window" 
+  //--------------------------------------------------------------------
+
+  if (fCurrentSlice<0) {
+    Double_t rpi2 = 2.*fR*TMath::Pi();
+    for (Int_t i=fI; i<fImax; i++) {
+      Double_t y = fY[i];
+      if (fYmax<y) y -= rpi2;
+      if (fYmin>y) y += rpi2;
+      if (y<fYmin) continue;
+      if (y>fYmax) continue;
+      if (fClusters[i]->GetQ()==0&&fSkip==2) continue;
+      ci=i;
+      if (!test) fI=i+1;
+      return fClusters[i];
+    }
+  } else {
+    for (Int_t i=fI; i<fImax; i++) {
+      if (fYcs[i]<fYmin) continue;
+      if (fYcs[i]>fYmax) continue;
+      if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue;
+      ci=fClusterIndexCs[i];
+      if (!test) fI=i+1;
+      return fClustersCs[i];
+    }
+  }
+  return 0;
+}
+//------------------------------------------------------------------------
+Double_t AliHLTITSLayer::GetThickness(Double_t y,Double_t z,Double_t &x0)
+const {
+  //--------------------------------------------------------------------
+  // This function returns the layer thickness at this point (units X0)
+  //--------------------------------------------------------------------
+  Double_t d=0.0085;
+  x0=AliITSRecoParam::GetX0Air();
+  if (43<fR&&fR<45) { //SSD2
+     Double_t dd=0.0034;
+     d=dd;
+     if (TMath::Abs(y-0.00)>3.40) d+=dd;
+     if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
+     if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
+     for (Int_t i=0; i<12; i++) {
+       if (TMath::Abs(z-3.9*(i+0.5))<0.15) {
+          if (TMath::Abs(y-0.00)>3.40) d+=dd;
+          d+=0.0034; 
+          break;
+       }
+       if (TMath::Abs(z+3.9*(i+0.5))<0.15) {
+          if (TMath::Abs(y-0.00)>3.40) d+=dd;
+          d+=0.0034; 
+          break;
+       }         
+       if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
+       if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;}
+     }
+  } else 
+  if (37<fR&&fR<41) { //SSD1
+     Double_t dd=0.0034;
+     d=dd;
+     if (TMath::Abs(y-0.00)>3.40) d+=dd;
+     if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);}
+     if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);}
+     for (Int_t i=0; i<11; i++) {
+       if (TMath::Abs(z-3.9*i)<0.15) {
+          if (TMath::Abs(y-0.00)>3.40) d+=dd;
+          d+=dd; 
+          break;
+       }
+       if (TMath::Abs(z+3.9*i)<0.15) {
+          if (TMath::Abs(y-0.00)>3.40) d+=dd;
+          d+=dd; 
+          break;
+       }         
+       if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;}
+       if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;}         
+     }
+  } else
+  if (13<fR&&fR<26) { //SDD
+     Double_t dd=0.0033;
+     d=dd;
+     if (TMath::Abs(y-0.00)>3.30) d+=dd;
+
+     if (TMath::Abs(y-1.80)<0.55) {
+        d+=0.016;
+        for (Int_t j=0; j<20; j++) {
+          if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
+          if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
+        } 
+     }
+     if (TMath::Abs(y+1.80)<0.55) {
+        d+=0.016;
+        for (Int_t j=0; j<20; j++) {
+          if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;}
+          if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;}
+        } 
+     }
+
+     for (Int_t i=0; i<4; i++) {
+       if (TMath::Abs(z-7.3*i)<0.60) {
+          d+=dd;
+          if (TMath::Abs(y-0.00)>3.30) d+=dd; 
+          break;
+       }
+       if (TMath::Abs(z+7.3*i)<0.60) {
+          d+=dd; 
+          if (TMath::Abs(y-0.00)>3.30) d+=dd; 
+          break;
+       }
+     }
+  } else
+  if (6<fR&&fR<8) {   //SPD2
+     Double_t dd=0.0063; x0=21.5;
+     d=dd;
+     if (TMath::Abs(y-3.08)>0.5) d+=dd;
+     if (TMath::Abs(y-3.03)<0.10) d+=0.014;
+  } else
+  if (3<fR&&fR<5) {   //SPD1
+     Double_t dd=0.0063; x0=21.5;
+     d=dd;
+     if (TMath::Abs(y+0.21)>0.6) d+=dd;
+     if (TMath::Abs(y+0.10)<0.10) d+=0.014;
+  }
+
+  return d;
+}
+
+//------------------------------------------------------------------------
+Int_t AliHLTITSLayer::InRoad() const {
+  //-------------------------------------------------------------------
+  // This function returns number of clusters within the "window" 
+  //--------------------------------------------------------------------
+  Int_t ncl=0;
+  for (Int_t i=fI; i<fN; i++) {
+    const AliITSRecPoint *c=fClusters[i];
+    if (c->GetZ() > fZmax) break;
+    if (c->IsUsed()) continue;
+    const AliHLTITSDetector &det=GetDetector(c->GetDetectorIndex());    
+    Double_t y=fR*det.GetPhi() + c->GetY();
+
+    if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi();
+    if (y>1.*fR*TMath::Pi() && fYmax<y) y -= 2*fR*TMath::Pi();
+
+    if (y<fYmin) continue;
+    if (y>fYmax) continue;
+    ncl++;
+  }
+  return ncl;
+}
+
diff --git a/HLT/ITS/tracking/AliHLTITSLayer.h b/HLT/ITS/tracking/AliHLTITSLayer.h
new file mode 100644 (file)
index 0000000..5901782
--- /dev/null
@@ -0,0 +1,116 @@
+// ************************************************************************
+// This file is property of and copyright by the ALICE HLT Project        *
+// ALICE Experiment at CERN, All rights reserved.                         *
+// See cxx source for full Copyright notice                               *
+//                                                                        *
+//*************************************************************************
+
+#ifndef ALIHLTITSLAYER_H
+#define ALIHLTITSLAYER_H
+
+#include "AliHLTITSDetector.h"
+#include "AliITSRecoParam.h"
+
+/**
+ * @class AliHLTITSLayer
+ *
+ * The AliHLTTPCCAHit class is the internal representation
+ * of the TPC clusters for the AliHLTTPCCATracker algorithm.
+ *
+ */
+class AliHLTITSLayer 
+{
+ public:
+  AliHLTITSLayer();
+  AliHLTITSLayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
+  ~AliHLTITSLayer();
+  Int_t InsertCluster(AliITSRecPoint *c);
+  void  SortClusters();
+  void ResetClusters();
+  void ResetWeights();
+  void SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin,Double_t ymax);
+  const AliITSRecPoint *GetNextCluster(Int_t &ci,Bool_t test=kFALSE);
+  void ResetRoad();
+  Double_t GetRoad() const {return fRoad;}
+  Double_t GetR() const {return fR;}
+  Int_t FindClusterIndex(Float_t z) const;
+  AliITSRecPoint *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;} 
+  Float_t  *GetWeight(Int_t i)  {return i<fN ?&fClusterWeight[i]:0;}
+  AliHLTITSDetector &GetDetector(Int_t n) const { return fDetectors[n]; }
+  Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
+  Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
+  Int_t InRoad() const ;
+  Int_t GetNumberOfClusters() const {return fN;}
+  Int_t GetNladders() const {return fNladders;}
+  Int_t GetNdetectors() const {return fNdetectors;}
+  Int_t GetSkip() const {return fSkip;}
+  void  SetSkip(Int_t skip){fSkip=skip;}
+  void IncAccepted(){fAccepted++;}
+  Int_t GetAccepted() const {return fAccepted;}    
+  Int_t GetClusterTracks(Int_t i, Int_t j) const {return fClusterTracks[i][j];}
+  void SetClusterTracks(Int_t i, Int_t j, Int_t c) {fClusterTracks[i][j]=c;}
+
+ protected:
+
+  AliHLTITSLayer(const AliHLTITSLayer& layer);
+  AliHLTITSLayer & operator=(const AliHLTITSLayer& layer){
+    this->~AliHLTITSLayer();new(this) AliHLTITSLayer(layer);
+    return *this;}
+  Double_t fR;                // mean radius of this layer
+  Double_t fPhiOffset;        // offset of the first detector in Phi
+  Int_t fNladders;            // number of ladders
+  Double_t fZOffset;          // offset of the first detector in Z
+  Int_t fNdetectors;          // detectors/ladder
+  AliHLTITSDetector *fDetectors; // array of detectors
+  Int_t fN;                   // number of clusters
+  AliITSRecPoint *fClusters[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
+  Int_t        fClusterIndex[AliITSRecoParam::fgkMaxClusterPerLayer]; // pointers to clusters
+  Float_t fY[AliITSRecoParam::fgkMaxClusterPerLayer];                // y position of the clusters      
+  Float_t fZ[AliITSRecoParam::fgkMaxClusterPerLayer];                // z position of the clusters      
+  Float_t fYB[2];                                       // ymin and ymax
+  //
+  AliITSRecPoint *fClusters5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters -     slice in y
+  Int_t        fClusterIndex5[6][AliITSRecoParam::fgkMaxClusterPerLayer5]; // pointers to clusters -     slice in y    
+  Float_t fY5[6][AliITSRecoParam::fgkMaxClusterPerLayer5];                // y position of the clusters  slice in y    
+  Float_t fZ5[6][AliITSRecoParam::fgkMaxClusterPerLayer5];                // z position of the clusters  slice in y 
+  Int_t fN5[6];                                       // number of cluster in slice
+  Float_t fDy5;                                       //delta y
+  Float_t fBy5[6][2];                                    //slice borders
+  //
+  AliITSRecPoint *fClusters10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters -     slice in y
+  Int_t        fClusterIndex10[11][AliITSRecoParam::fgkMaxClusterPerLayer10]; // pointers to clusters -     slice in y    
+  Float_t fY10[11][AliITSRecoParam::fgkMaxClusterPerLayer10];                // y position of the clusters  slice in y    
+  Float_t fZ10[11][AliITSRecoParam::fgkMaxClusterPerLayer10];                // z position of the clusters  slice in y 
+  Int_t fN10[11];                                       // number of cluster in slice
+  Float_t fDy10;                                        // delta y
+  Float_t fBy10[11][2];                                 // slice borders
+  //
+  AliITSRecPoint *fClusters20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters -     slice in y
+  Int_t        fClusterIndex20[21][AliITSRecoParam::fgkMaxClusterPerLayer20]; // pointers to clusters -     slice in y    
+  Float_t fY20[21][AliITSRecoParam::fgkMaxClusterPerLayer20];                // y position of the clusters  slice in y    
+  Float_t fZ20[21][AliITSRecoParam::fgkMaxClusterPerLayer20];                // z position of the clusters  slice in y 
+  Int_t fN20[21];                                       // number of cluster in slice
+  Float_t fDy20;                                        //delta y 
+  Float_t fBy20[21][2];                                 //slice borders
+  //
+  AliITSRecPoint** fClustersCs;                         //clusters table in current slice
+  Int_t   *fClusterIndexCs;                             //cluster index in current slice 
+  Float_t *fYcs;                                        //y position in current slice
+  Float_t *fZcs;                                        //z position in current slice
+  Int_t    fNcs;                                        //number of clusters in current slice    
+  Int_t fCurrentSlice;                                  //current slice
+  //
+  Float_t  fClusterWeight[AliITSRecoParam::fgkMaxClusterPerLayer]; // probabilistic weight of the cluster
+  Int_t    fClusterTracks[4][AliITSRecoParam::fgkMaxClusterPerLayer]; //tracks registered to given cluster
+  Float_t fZmax;      //    edges
+  Float_t fYmin;      //   of  the
+  Float_t fYmax;      //   "window"
+  Int_t fI;            // index of the current cluster within the "window"
+  Int_t fImax;            // index of the last cluster within the "window"    
+  Int_t fSkip;     // indicates possibility to skip cluster
+  Int_t fAccepted;     // accept indicator 
+  Double_t fRoad;      // road defined by the cluster density
+};
+
+
+#endif
diff --git a/HLT/ITS/tracking/AliHLTITSTrack.cxx b/HLT/ITS/tracking/AliHLTITSTrack.cxx
new file mode 100644 (file)
index 0000000..c0d76e0
--- /dev/null
@@ -0,0 +1,362 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//-------------------------------------------------------------------------
+//                Implementation of the ITS track class
+//
+//          Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
+//     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
+//-------------------------------------------------------------------------
+
+/* $Id: AliHLTITSTrack.cxx 30856 2009-02-02 11:12:50Z fca $ */
+
+#include <TMatrixD.h>
+
+#include <TMath.h>
+
+#include "AliCluster.h"
+#include "AliESDtrack.h"
+#include "AliITSgeomTGeo.h"
+#include "AliHLTITSTrack.h"
+#include "AliTracker.h"
+#include <TMath.h>
+
+#include "AliCluster.h"
+#include "AliESDtrack.h"
+#include "AliESDVertex.h"
+#include "AliITSReconstructor.h"
+#include "AliITStrackV2.h"
+#include "AliTracker.h"
+
+
+
+//____________________________________________________________________________
+AliHLTITSTrack::AliHLTITSTrack() : 
+  AliKalmanTrack(),
+  fESDtrack(0),
+  fExpQ(40)
+{
+  for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; }
+}
+
+//____________________________________________________________________________
+AliHLTITSTrack::AliHLTITSTrack(const AliHLTITSTrack& t) : 
+  AliKalmanTrack(t),
+  fESDtrack(t.fESDtrack),
+  fExpQ(t.fExpQ)
+{
+  //------------------------------------------------------------------
+  //Copy constructor
+  //------------------------------------------------------------------
+  Int_t i;
+  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
+    fIndex[i]=t.fIndex[i];
+  }
+  fLab = t.fLab;
+  fFakeRatio = t.fFakeRatio;
+}
+
+//____________________________________________________________________________
+AliHLTITSTrack &AliHLTITSTrack::operator=(const AliHLTITSTrack& t)
+{
+  //------------------------------------------------------------------
+  //Copy constructor
+  //------------------------------------------------------------------
+  *(AliKalmanTrack*)this = t;
+  fESDtrack = t.fESDtrack;
+  fExpQ = t.fExpQ;
+  Int_t i;
+  for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
+    fIndex[i]=t.fIndex[i];
+  }
+  fLab = t.fLab;
+  fFakeRatio = t.fFakeRatio;
+}
+
+
+//____________________________________________________________________________
+AliHLTITSTrack::AliHLTITSTrack(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
+  AliKalmanTrack(),
+  fESDtrack(&t),
+  fExpQ(40)
+{
+  //------------------------------------------------------------------
+  // Conversion ESD track -> ITS track.
+  // If c==kTRUE, create the ITS track out of the constrained params.
+  //------------------------------------------------------------------
+  const AliExternalTrackParam *par=&t;
+  if (c) {
+    par=t.GetConstrainedParam();
+    if (!par) throw "AliHLTITSTrack: conversion failed !\n";
+  }
+  Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
+
+  SetLabel(t.GetLabel());
+  SetMass(t.GetMass());
+  SetNumberOfClusters(t.GetITSclusters(fIndex));
+
+  if (t.GetStatus()&AliESDtrack::kTIME) {
+    StartTimeIntegral();
+    Double_t times[10]; t.GetIntegratedTimes(times); SetIntegratedTimes(times);
+    SetIntegratedLength(t.GetIntegratedLength());
+  }
+}
+
+Double_t AliHLTITSTrack::GetPredictedChi2(const AliCluster* c) const
+{
+  return GetPredictedChi2(c->GetY(), c->GetZ(), c->GetSigmaY2(), c->GetSigmaZ2() );
+}
+
+Double_t AliHLTITSTrack::GetPredictedChi2(Double_t cy, Double_t cz, Double_t cerr2Y, Double_t cerr2Z) const
+{
+  //-----------------------------------------------------------------
+  // This function calculates a predicted chi2 increment.
+  //-----------------------------------------------------------------
+  Double_t p[2]={cy, cz};
+  Double_t cov[3]={cerr2Y, 0., cerr2Z};
+  return AliExternalTrackParam::GetPredictedChi2(p,cov);
+}
+
+
+
+
+Int_t AliHLTITSTrack::GetProlongationFast(Double_t alp, Double_t xk,Double_t &y, Double_t &z)
+{
+  //-----------------------------------------------------------------------------
+  //get fast prolongation 
+  //-----------------------------------------------------------------------------
+  Double_t ca=TMath::Cos(alp-GetAlpha()), sa=TMath::Sin(alp-GetAlpha());
+  Double_t cf=TMath::Sqrt((1.-GetSnp())*(1.+GetSnp()));  
+  // **** rotation **********************  
+  y= -GetX()*sa + GetY()*ca;
+  // **** translation ******************  
+  Double_t dx = xk- GetX()*ca - GetY()*sa;
+  Double_t f1=GetSnp()*ca - cf*sa, f2=f1 + GetC()*dx;
+  if (TMath::Abs(f2) >= 0.9999) {
+    return 0;
+  }
+  Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2));  
+  y += dx*(f1+f2)/(r1+r2);
+  z  = GetZ()+dx*(f1+f2)/(f1*r2 + f2*r1)*GetTgl();  
+  return 1;
+}
+
+
+
+//____________________________________________________________________________
+void AliHLTITSTrack::ResetClusters() {
+  //------------------------------------------------------------------
+  // Reset the array of attached clusters.
+  //------------------------------------------------------------------
+  for (Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) fIndex[i]=-1;
+  SetChi2(0.); 
+  SetNumberOfClusters(0);
+} 
+
+void AliHLTITSTrack::UpdateESDtrack(ULong_t flags) const {
+  fESDtrack->UpdateTrackParams(this,flags);
+}
+
+
+
+
+//____________________________________________________________________________
+
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::
+GetGlobalXYZat(Double_t xloc, Double_t &x, Double_t &y, Double_t &z) const {
+  //------------------------------------------------------------------
+  //This function returns a track position in the global system
+  //------------------------------------------------------------------
+  Double_t r[3];
+  Bool_t rc=GetXYZAt(xloc, GetBz(), r);
+  x=r[0]; y=r[1]; z=r[2]; 
+  return rc;
+}
+
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
+  //------------------------------------------------------------------
+  //This function propagates a track
+  //------------------------------------------------------------------
+
+  Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
+  
+  Double_t bz=GetBz();
+  if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
+  Double_t xOverX0,xTimesRho; 
+  xOverX0 = d; xTimesRho = d*x0;
+  if (!CorrectForMeanMaterial(xOverX0,xTimesRho,kTRUE)) return kFALSE;
+
+  Double_t x=GetX(), y=GetY(), z=GetZ();
+  if (IsStartedTimeIntegral() && x>oldX) {
+    Double_t l2 = (x-oldX)*(x-oldX) + (y-oldY)*(y-oldY) + (z-oldZ)*(z-oldZ);
+    AddTimeStep(TMath::Sqrt(l2));
+  }
+
+  return kTRUE;
+}
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime) {
+  //-------------------------------------------------------------------
+  //  Propagates the track to a reference plane x=xToGo in n steps.
+  //  These n steps are only used to take into account the curvature.
+  //  The material is calculated with TGeo. (L.Gaudichet)
+  //-------------------------------------------------------------------
+  
+  Double_t startx = GetX(), starty = GetY(), startz = GetZ();
+  Double_t sign = (startx<xToGo) ? -1.:1.;
+  Double_t step = (xToGo-startx)/TMath::Abs(nstep);
+
+  Double_t start[3], end[3], mparam[7], bz = GetBz();
+  Double_t x = startx;
+  
+  for (Int_t i=0; i<nstep; i++) {
+    
+    GetXYZ(start);   //starting global position
+    x += step;
+    if (!GetXYZAt(x, bz, end)) return kFALSE;
+    if (!AliExternalTrackParam::PropagateTo(x, bz)) return kFALSE;
+    AliTracker::MeanMaterialBudget(start, end, mparam);
+    xTimesRho = sign*mparam[4]*mparam[0];
+    xOverX0   = mparam[1];
+    if (mparam[1]<900000) {
+      if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,
+                                                        xTimesRho,GetMass())) return kFALSE;
+    } else { // this happens when MeanMaterialBudget cannot cross a boundary
+      return kFALSE;
+    }
+  }
+
+  if (addTime && IsStartedTimeIntegral() && GetX()>startx) {
+    Double_t l2 = ( (GetX()-startx)*(GetX()-startx) +
+                   (GetY()-starty)*(GetY()-starty) +
+                   (GetZ()-startz)*(GetZ()-startz) );
+    AddTimeStep(TMath::Sqrt(l2));
+  }
+
+  return kTRUE;
+}
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::Update(const AliCluster* c, Double_t chi2, Int_t index) 
+{
+  //------------------------------------------------------------------
+  //This function updates track parameters
+  //------------------------------------------------------------------
+  Double_t p[2]={c->GetY(), c->GetZ()};
+  Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
+
+  if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
+
+  Int_t n=GetNumberOfClusters();
+
+  if (chi2<0) return kTRUE;
+
+  // fill residuals for ITS+TPC tracks 
+  if (fESDtrack) {
+    if (fESDtrack->GetStatus()&AliESDtrack::kTPCin) {
+      AliTracker::FillResiduals(this,p,cov,c->GetVolumeId());
+    }
+  }
+
+  fIndex[n]=index;
+  SetNumberOfClusters(n+1);
+  SetChi2(GetChi2()+chi2);
+
+  return kTRUE;
+}
+
+
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::Propagate(Double_t alp,Double_t xk) {
+  //------------------------------------------------------------------
+  //This function propagates a track
+  //------------------------------------------------------------------
+  Double_t bz=GetBz();
+  if (!AliExternalTrackParam::Propagate(alp,xk,bz)) return kFALSE;
+
+  return kTRUE;
+}
+
+
+
+
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::
+GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
+  //------------------------------------------------------------------
+  // This function returns the global cylindrical (phi,z) of the track 
+  // position estimated at the radius r. 
+  // The track curvature is neglected.
+  //------------------------------------------------------------------
+  Double_t d=GetD(0.,0.);
+  if (TMath::Abs(d) > r) {
+    if (r>1e-1) return kFALSE;
+    r = TMath::Abs(d);
+  }
+
+  Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
+  if (TMath::Abs(d) > rcurr) return kFALSE;
+  Double_t globXYZcurr[3]; GetXYZ(globXYZcurr); 
+  Double_t phicurr=TMath::ATan2(globXYZcurr[1],globXYZcurr[0]);
+
+  if (GetX()>=0.) {
+    phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
+  } else {
+    phi=phicurr+TMath::ASin(d/r)+TMath::ASin(d/rcurr)-TMath::Pi();
+  }
+
+  // return a phi in [0,2pi[ 
+  if (phi<0.) phi+=2.*TMath::Pi();
+  else if (phi>=2.*TMath::Pi()) phi-=2.*TMath::Pi();
+  z=GetZ()+GetTgl()*(TMath::Sqrt((r-d)*(r+d))-TMath::Sqrt((rcurr-d)*(rcurr+d)));
+  return kTRUE;
+}
+
+//____________________________________________________________________________
+Bool_t AliHLTITSTrack::
+GetLocalXat(Double_t r,Double_t &xloc) const {
+  //------------------------------------------------------------------
+  // This function returns the local x of the track 
+  // position estimated at the radius r. 
+  // The track curvature is neglected.
+  //------------------------------------------------------------------
+  Double_t d=GetD(0.,0.);
+  if (TMath::Abs(d) > r) { 
+    if (r>1e-1) return kFALSE; 
+    r = TMath::Abs(d); 
+  } 
+
+  Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
+  Double_t globXYZcurr[3]; GetXYZ(globXYZcurr); 
+  Double_t phicurr=TMath::ATan2(globXYZcurr[1],globXYZcurr[0]);
+  Double_t phi;
+  if (GetX()>=0.) {
+    phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
+  } else {
+    phi=phicurr+TMath::ASin(d/r)+TMath::ASin(d/rcurr)-TMath::Pi();
+  }
+
+  xloc=r*(TMath::Cos(phi)*TMath::Cos(GetAlpha())
+         +TMath::Sin(phi)*TMath::Sin(GetAlpha())); 
+
+  return kTRUE;
+}
diff --git a/HLT/ITS/tracking/AliHLTITSTrack.h b/HLT/ITS/tracking/AliHLTITSTrack.h
new file mode 100644 (file)
index 0000000..f95aaec
--- /dev/null
@@ -0,0 +1,87 @@
+#ifndef ALIHLTITSTRACK1_H
+#define ALIHLTITSTRACK1_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+#include "AliKalmanTrack.h"
+#include "AliITSRecoParam.h"
+#include "AliITSgeomTGeo.h"
+
+class AliESDtrack;
+class AliESDVertex;
+class AliTracker;
+class AliESDtrack;
+
+//_____________________________________________________________________________
+class AliHLTITSTrack : public AliKalmanTrack 
+{
+ public:
+  AliHLTITSTrack();
+  AliHLTITSTrack(AliESDtrack& t,Bool_t c=kFALSE) throw (const Char_t *);
+  AliHLTITSTrack(const AliHLTITSTrack& t);
+  AliHLTITSTrack &operator=(const AliHLTITSTrack& t);
+
+  Int_t GetProlongationFast(Double_t alpha, Double_t xr,Double_t &y, Double_t &z);
+
+
+  Float_t GetExpQ() const {return fExpQ;}
+  void SetExpQ(Float_t f) {fExpQ=f;}
+
+  Double_t GetPredictedChi2(const AliCluster* c) const;
+  Double_t GetPredictedChi2(Double_t cy, Double_t cz, Double_t cerr2Y, Double_t cerr2Z) const;
+
+
+  Bool_t CorrectForMeanMaterial(Double_t xOverX0, Double_t xTimesRho,
+                               Bool_t anglecorr=kFALSE) {
+    return AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,xTimesRho,GetMass(),anglecorr);
+  }
+
+  Bool_t PropagateTo(Double_t xr, Double_t d, Double_t x0=AliITSRecoParam::GetX0Air());
+
+  Bool_t PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime=kTRUE);
+  Bool_t PropagateToTGeo(Double_t xToGo, Int_t nstep=1, Bool_t addTime=kTRUE) {
+    Double_t dummy1,dummy2; return PropagateToTGeo(xToGo,nstep,dummy1,dummy2,addTime);
+  }
+
+  Bool_t Update(const AliCluster *cl, Double_t chi2, Int_t i);
+  
+  Bool_t Propagate(Double_t alpha, Double_t xr);
+  Bool_t Propagate(Double_t xr) { return Propagate(GetAlpha(),xr); }
+  
+  void ResetClusters();
+  void UpdateESDtrack(ULong_t flags) const;
+  
+  AliESDtrack *GetESDtrack() const {return fESDtrack;}
+
+  using AliExternalTrackParam::GetC;
+  Double_t GetC() const {return AliExternalTrackParam::GetC(GetBz());}
+  Double_t GetD(Double_t x, Double_t y) const {
+    return AliExternalTrackParam::GetD(x,y,GetBz());
+  }
+  Bool_t GetGlobalXYZat(Double_t xloc,Double_t &x,Double_t &y,Double_t &z) const;
+  Bool_t GetPhiZat(Double_t r,Double_t &phi,Double_t &z) const;
+  Bool_t GetLocalXat(Double_t r,Double_t &xloc) const;
+
+  Int_t GetClusterIndex(Int_t i) const {return fIndex[i];}
+  void SetClusterIndex(Int_t i, Int_t index ) { fIndex[i] = index;}
+
+ protected:
+
+
+  Int_t fIndex[2*AliITSgeomTGeo::kNLayers]; // indices of associated clusters 
+
+
+  AliESDtrack *fESDtrack;    //! pointer to the connected ESD track
+
+  Float_t fExpQ;            // expected Q
+};
+
+
+
+
+
+#endif
+
+
diff --git a/HLT/ITS/tracking/AliHLTVertexer.cxx b/HLT/ITS/tracking/AliHLTVertexer.cxx
new file mode 100644 (file)
index 0000000..4f5e706
--- /dev/null
@@ -0,0 +1,185 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+
+#include "AliHLTVertexer.h"
+#include "AliTracker.h"
+#include "TMath.h"
+#include "AliESDtrack.h"
+#include "AliESDv0.h"
+#include "AliESDVertex.h"
+#include "AliESDEvent.h"
+#include "AliKFParticle.h"
+#include "AliKFVertex.h"
+
+
+AliHLTVertexer::AliHLTVertexer():
+  fESD(0),
+  fTrackInfos(0)
+{
+}
+
+AliHLTVertexer::AliHLTVertexer(const AliHLTVertexer & ):
+  fESD(0),
+  fTrackInfos(0)
+{
+}
+
+void AliHLTVertexer::SetESD( AliESDEvent *event )
+{
+  //* Fill fTrackInfo array
+
+  delete[] fTrackInfos;
+  fESD = event;
+    
+  AliKFParticle::SetField( fESD->GetMagneticField() );
+
+  Int_t nESDTracks=event->GetNumberOfTracks(); 
+  fTrackInfos = new AliESDTrackInfo[ nESDTracks ];
+
+  for (Int_t iTr=0; iTr<nESDTracks; iTr++){ 
+  
+    AliESDTrackInfo &info = fTrackInfos[iTr];
+    info.fOK = 0;
+    info.fPrimUsedFlag = 0;
+    
+    //* track quality check
+
+    AliESDtrack *pTrack = event->GetTrack(iTr);    
+    if( !pTrack  ) continue;
+    if (pTrack->GetKinkIndex(0)>0) continue;
+    if ( !( pTrack->GetStatus()&AliESDtrack::kTPCin ) ) continue;
+    
+    //* Construct KFParticle for the track
+
+    info.fParticle = AliKFParticle( *pTrack, 211 );
+    info.fOK = 1;   
+  }
+}
+
+
+void AliHLTVertexer::FindPrimaryVertex(  )
+{
+  //* Find event primary vertex
+
+  int nTracks = fESD->GetNumberOfTracks();
+
+  const AliKFParticle **vSelected = new const AliKFParticle*[nTracks]; //* Selected particles for vertex fit
+  Int_t *vIndex = new int [nTracks];                    //* Indices of selected particles
+  Bool_t *vFlag = new bool [nTracks];                    //* Flags returned by the vertex finder
+  
+  Int_t nSelected = 0;
+  for( Int_t i = 0; i<nTracks; i++){ 
+    if(fTrackInfos[i].fOK ){
+      vSelected[nSelected] = &(fTrackInfos[i].fParticle);
+      vIndex[nSelected] = i;
+      nSelected++;
+    }
+  }
+
+  AliKFVertex primVtx;  
+  primVtx.SetBeamConstraint(fESD->GetDiamondX(),fESD->GetDiamondY(),0,
+                           TMath::Sqrt(fESD->GetSigma2DiamondX()),TMath::Sqrt(fESD->GetSigma2DiamondY()),5.3);
+
+  primVtx.ConstructPrimaryVertex( vSelected, nSelected, vFlag, 3. );
+  for( Int_t i = 0; i<nSelected; i++){ 
+    if( vFlag[i] ) fTrackInfos[vIndex[i]].fPrimUsedFlag = 1;
+  }
+  
+  
+  AliESDVertex vESD( primVtx.Parameters(), primVtx.CovarianceMatrix(), primVtx.GetChi2(), primVtx.GetNContributors() );
+  fESD->SetPrimaryVertexTracks( &vESD );
+
+  delete[] vSelected;
+  delete[] vIndex;
+  delete[] vFlag;
+}
+
+
+void AliHLTVertexer::FindV0s(  )
+{
+  //* V0 finder
+
+  int nTracks = fESD->GetNumberOfTracks();
+  AliKFVertex primVtx( *fESD->GetPrimaryVertexTracks() );
+
+  for( Int_t iTr = 0; iTr<nTracks; iTr++ ){ //* first daughter
+
+    AliESDTrackInfo &info = fTrackInfos[iTr];
+    if( !info.fOK ) continue;    
+
+    for( Int_t jTr = iTr+1; jTr<nTracks; jTr++ ){  //* second daughter
+      AliESDTrackInfo &jnfo = fTrackInfos[jTr];
+      if( !jnfo.fOK ) continue;
+      
+      //* check for different charge
+
+      if( info.fParticle.GetQ() == jnfo.fParticle.GetQ() ) continue;      
+
+      //* construct V0 mother
+
+      AliKFParticle V0( info.fParticle, jnfo.fParticle );     
+
+      //* check V0 Chi^2
+
+      if( V0.GetNDF()<1 ) continue;
+      if( TMath::Sqrt(TMath::Abs(V0.GetChi2()/V0.GetNDF())) >3. ) continue;
+
+      //* subtruct daughters from primary vertex 
+
+      AliKFVertex primVtxCopy = primVtx;
+       
+      if( info.fPrimUsedFlag ) primVtxCopy -= info.fParticle;
+      if( jnfo.fPrimUsedFlag ) primVtxCopy -= jnfo.fParticle;
+
+      //* Check V0 Chi^2 deviation from primary vertex 
+
+      if( V0.GetDeviationFromVertex( primVtxCopy ) >3. ) continue;
+
+      //* Add V0 to primary vertex to improve the primary vertex resolution
+
+      primVtxCopy += V0;      
+
+      //* Set production vertex for V0
+
+      V0.SetProductionVertex( primVtxCopy );
+
+      //* Check chi^2 for a case
+
+      if( TMath::Sqrt( TMath::Abs(V0.GetChi2()/V0.GetNDF()) >3. )) continue;
+
+      //* Get V0 decay length with estimated error
+
+      Double_t length, sigmaLength;
+      if( V0.GetDecayLength( length, sigmaLength ) ) continue;
+
+      //* Reject V0 if it decays too close to the primary vertex
+
+      if( length  <3.*sigmaLength ) continue;
+
+      //* Get V0 invariant mass 
+
+      // Double_t mass, sigmaMass;
+      //if( V0.GetMass( mass, sigmaMass ) ) continue;   
+      
+      //* add ESD v0 
+      
+      AliESDv0 v0ESD( *fESD->GetTrack( iTr ), iTr, *fESD->GetTrack( jTr ), jTr );
+      
+      fESD->AddV0( &v0ESD );
+    }
+  }
+}
+
diff --git a/HLT/ITS/tracking/AliHLTVertexer.h b/HLT/ITS/tracking/AliHLTVertexer.h
new file mode 100644 (file)
index 0000000..1cd9fcd
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALIHLTVERTEXER_H
+#define ALIHLTVERTEXER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+#include "AliKFParticle.h"
+
+class AliESDtrack;
+class AliESDVertex;
+class AliTracker;
+class AliESDtrack;
+class AliESDEvent;
+
+class AliHLTVertexer
+{
+public:
+
+  class AliESDTrackInfo{
+  public:
+    AliESDTrackInfo(){}
+
+    AliKFParticle fParticle; //* assigned KFParticle
+    Bool_t fPrimUsedFlag;    //* flag shows that the particle was used for primary vertex fit
+    Bool_t fOK;              //* is the track good enough
+  };
+
+  AliHLTVertexer();
+  ~AliHLTVertexer(){ delete[] fTrackInfos; }
+
+  void SetESD( AliESDEvent *event );
+
+  void FindPrimaryVertex();
+  void FindV0s();
+
+ private:
+  
+  AliHLTVertexer(const AliHLTVertexer &t);
+  AliHLTVertexer &operator = (const AliHLTVertexer & ){ return *this; }
+
+  AliESDEvent *fESD;
+  AliESDTrackInfo *fTrackInfos;
+
+};
+
+
+
+#endif
+
+
diff --git a/HLT/ITS/tracking/AliITStrackerHLT.cxx b/HLT/ITS/tracking/AliITStrackerHLT.cxx
new file mode 100644 (file)
index 0000000..8bc7a9a
--- /dev/null
@@ -0,0 +1,1538 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: AliITStrackerHLT.cxx 32466 2009-05-20 07:51:56Z hristov $ */
+
+//-------------------------------------------------------------------------
+//               Implementation of the ITS tracker class
+//    It reads AliITSRecPoint clusters and creates AliHLTITSTrack tracks
+//                   and fills with them the ESD
+//          Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch 
+//          Current support and development: 
+//                     Andrea Dainese, andrea.dainese@lnl.infn.it
+//     dE/dx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
+//     Params moved to AliITSRecoParam by: Andrea Dainese, INFN
+//     Material budget from TGeo by: Ludovic Gaudichet & Andrea Dainese, INFN
+//-------------------------------------------------------------------------
+
+//#include <TMatrixD.h>
+#include <TTree.h>
+#include <TDatabasePDG.h>
+#include <TString.h>
+#include <TRandom.h>
+#include <TTreeStream.h>
+
+
+#include "AliLog.h"
+#include "AliITSCalibrationSPD.h"
+#include "AliITSCalibrationSDD.h"
+#include "AliITSCalibrationSSD.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliAlignObj.h"
+#include "AliTrackPointArray.h"
+#include "AliESDVertex.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "AliV0.h"
+#include "AliHelix.h"
+#include "AliITSChannelStatus.h"
+#include "AliITSDetTypeRec.h"
+#include "AliITSRecPoint.h"
+#include "AliITSgeomTGeo.h"
+#include "AliITSReconstructor.h"
+#include "AliITSClusterParam.h"
+#include "AliITSsegmentation.h"
+#include "AliITSCalibration.h"
+#include "AliITSV0Finder.h"
+#include "AliITStrackerHLT.h"
+//#include "AliHLTTPCCATrackParam.h"
+#include "AliHLTVertexer.h"
+
+
+
+Bool_t AliITStrackerHLT::TransportToX( AliExternalTrackParam *t, double x ) const
+{
+  return t->PropagateTo( x, t->GetBz() );
+}
+
+Bool_t AliITStrackerHLT::TransportToPhiX( AliExternalTrackParam *t, double phi, double x ) const
+{
+  return t->Propagate( phi, x, t->GetBz() );
+}
+
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::UpdateMI(AliHLTITSTrack* track, const AliITSRecPoint* cl,Double_t /*chi2*/,Int_t index) const 
+{
+  //
+  // Update ITS track
+  //
+  
+  if (cl->GetQ()<=0) return 0;  // ingore the "virtual" clusters
+  Int_t layer = (index & 0xf0000000) >> 28;
+  // Take into account the mis-alignment (bring track to cluster plane)
+
+  Double_t xTrOrig=track->GetX();
+  if (!TransportToX( track, xTrOrig + cl->GetX() ) ) return 0;
+  
+  Double_t err2Y, err2Z;
+
+  GetClusterErrors2( layer, cl, track, err2Y, err2Z );
+
+  Double_t p[2]={ cl->GetY(), cl->GetZ()};
+  Double_t cov[3]={err2Y, 0., err2Z};
+
+  Int_t updated = 1;
+  //if( layer!=2 && layer!=3 ) 
+  updated = track->AliExternalTrackParam::Update(p,cov);
+
+  int n = track->GetNumberOfClusters();
+  track->SetClusterIndex(n,index);
+  track->SetNumberOfClusters(n+1);      
+  
+  return updated;
+}
+
+
+AliHLTITSLayer AliITStrackerHLT::fgLayers[AliITSgeomTGeo::kNLayers]; // ITS layers
+
+AliITStrackerHLT::AliITStrackerHLT():AliTracker(),
+fEsd(0),
+fUseTGeo(3),
+fxOverX0Pipe(-1.),
+fxTimesRhoPipe(-1.),
+fDebugStreamer(0),
+fITSChannelStatus(0),
+fkDetTypeRec(0)
+{
+  //Default constructor
+  Int_t i;
+  for(i=0;i<4;i++) fSPDdetzcentre[i]=0.;
+  for(i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;}
+  for(i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;}
+}
+//------------------------------------------------------------------------
+AliITStrackerHLT::AliITStrackerHLT(const Char_t *geom) : AliTracker(),
+fEsd(0),
+fUseTGeo(3),
+fxOverX0Pipe(-1.),
+fxTimesRhoPipe(-1.),
+fDebugStreamer(0),
+fITSChannelStatus(0),
+fkDetTypeRec(0)
+{
+  //--------------------------------------------------------------------
+  //This is the AliITStrackerHLT constructor
+  //--------------------------------------------------------------------
+  if (geom) {
+    AliWarning("\"geom\" is actually a dummy argument !");
+  }
+
+  for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) {
+    Int_t nlad=AliITSgeomTGeo::GetNLadders(i);
+    Int_t ndet=AliITSgeomTGeo::GetNDetectors(i);
+
+    Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2];
+    AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz); 
+    Double_t poff=TMath::ATan2(y,x);
+    Double_t zoff=z;
+    Double_t r=TMath::Sqrt(x*x + y*y);
+
+    AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz);
+    r += TMath::Sqrt(x*x + y*y);
+    AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz);
+    r += TMath::Sqrt(x*x + y*y);
+    AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz);
+    r += TMath::Sqrt(x*x + y*y);
+    r*=0.25;
+
+    new (fgLayers+i-1) AliHLTITSLayer(r,poff,zoff,nlad,ndet);
+
+    for (Int_t j=1; j<nlad+1; j++) {
+      for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
+        TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
+        const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
+        m.Multiply(tm);
+        Double_t txyz[3]={0.};
+       xyz[0]=0.;xyz[1]=0.;xyz[2]=0.;
+        m.LocalToMaster(txyz,xyz);
+        r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+        Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
+
+        if (phi<0) phi+=TMath::TwoPi();
+        else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
+
+        AliHLTITSDetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); 
+        new(&det) AliHLTITSDetector(r,phi); 
+       // compute the real radius (with misalignment)
+        TGeoHMatrix mmisal(*(AliITSgeomTGeo::GetMatrix(i,j,k)));
+        mmisal.Multiply(tm);
+       xyz[0]=0.;xyz[1]=0.;xyz[2]=0.;
+        mmisal.LocalToMaster(txyz,xyz);
+        Double_t rmisal=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+       det.SetRmisal(rmisal);
+       
+      } // end loop on detectors
+    } // end loop on ladders
+  } // end loop on layers
+
+  
+
+  Double_t xyzVtx[]={AliITSReconstructor::GetRecoParam()->GetXVdef(),
+                    AliITSReconstructor::GetRecoParam()->GetYVdef(),
+                    AliITSReconstructor::GetRecoParam()->GetZVdef()}; 
+  Double_t ersVtx[]={AliITSReconstructor::GetRecoParam()->GetSigmaXVdef(),
+                    AliITSReconstructor::GetRecoParam()->GetSigmaYVdef(),
+                    AliITSReconstructor::GetRecoParam()->GetSigmaZVdef()}; 
+  SetVertex(xyzVtx,ersVtx);
+
+  // store positions of centre of SPD modules (in z)
+  Double_t tr[3];
+  AliITSgeomTGeo::GetTranslation(1,1,1,tr);
+  fSPDdetzcentre[0] = tr[2];
+  AliITSgeomTGeo::GetTranslation(1,1,2,tr);
+  fSPDdetzcentre[1] = tr[2];
+  AliITSgeomTGeo::GetTranslation(1,1,3,tr);
+  fSPDdetzcentre[2] = tr[2];
+  AliITSgeomTGeo::GetTranslation(1,1,4,tr);
+  fSPDdetzcentre[3] = tr[2];
+
+  fUseTGeo = AliITSReconstructor::GetRecoParam()->GetUseTGeoInTracker();
+  if(AliITSReconstructor::GetRecoParam()->GetExtendedEtaAcceptance() && fUseTGeo!=1 && fUseTGeo!=3) {
+    AliWarning("fUseTGeo changed to 3 because fExtendedEtaAcceptance is kTRUE");
+    fUseTGeo = 3;
+  }
+
+  for(Int_t i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;}
+  for(Int_t i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;}
+  
+  fDebugStreamer = new TTreeSRedirector("ITSdebug.root");
+
+}
+//------------------------------------------------------------------------
+AliITStrackerHLT::AliITStrackerHLT(const AliITStrackerHLT &tracker):AliTracker(tracker),
+fEsd(tracker.fEsd),
+fUseTGeo(tracker.fUseTGeo),
+fxOverX0Pipe(tracker.fxOverX0Pipe),
+fxTimesRhoPipe(tracker.fxTimesRhoPipe),
+fDebugStreamer(tracker.fDebugStreamer),
+fITSChannelStatus(tracker.fITSChannelStatus),
+fkDetTypeRec(tracker.fkDetTypeRec)
+{
+  //Copy constructor
+  Int_t i;
+  for(i=0;i<4;i++) {
+    fSPDdetzcentre[i]=tracker.fSPDdetzcentre[i];
+  }
+  for(i=0;i<6;i++) {
+    fxOverX0Layer[i]=tracker.fxOverX0Layer[i];
+    fxTimesRhoLayer[i]=tracker.fxTimesRhoLayer[i];
+  }
+  for(i=0;i<2;i++) {
+    fxOverX0Shield[i]=tracker.fxOverX0Shield[i];
+    fxTimesRhoShield[i]=tracker.fxTimesRhoShield[i];
+  }
+}
+//------------------------------------------------------------------------
+AliITStrackerHLT & AliITStrackerHLT::operator=(const AliITStrackerHLT &tracker){
+  //Assignment operator
+  this->~AliITStrackerHLT();
+  new(this) AliITStrackerHLT(tracker);
+  return *this;
+}
+//------------------------------------------------------------------------
+AliITStrackerHLT::~AliITStrackerHLT()
+{
+  //
+  //destructor
+  //
+  if (fDebugStreamer) {
+    //fDebugStreamer->Close();
+    delete fDebugStreamer;
+  }
+  if(fITSChannelStatus) delete fITSChannelStatus;
+}
+
+
+//------------------------------------------------------------------------
+void AliITStrackerHLT::ReadBadFromDetTypeRec() {
+  //--------------------------------------------------------------------
+  //This function read ITS bad detectors, chips, channels from AliITSDetTypeRec
+  //i.e. from OCDB
+  //--------------------------------------------------------------------
+
+  if(!AliITSReconstructor::GetRecoParam()->GetUseBadZonesFromOCDB()) return;
+
+  Info("ReadBadFromDetTypeRec","Reading info about bad ITS detectors and channels");
+
+  if(!fkDetTypeRec) Error("ReadBadFromDetTypeRec","AliITSDetTypeRec nof found!\n");
+
+  // ITS channels map
+  if(fITSChannelStatus) delete fITSChannelStatus;
+  fITSChannelStatus = new AliITSChannelStatus(fkDetTypeRec);
+
+  // ITS detectors and chips
+  Int_t i=0,j=0,k=0,ndet=0;
+  for (i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) {
+    Int_t nBadDetsPerLayer=0;
+    ndet=AliITSgeomTGeo::GetNDetectors(i);    
+    for (j=1; j<AliITSgeomTGeo::GetNLadders(i)+1; j++) {
+      for (k=1; k<ndet+1; k++) {
+        AliHLTITSDetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1);  
+       det.ReadBadDetectorAndChips(i-1,(j-1)*ndet + k-1,fkDetTypeRec);
+       if(det.IsBad()) {nBadDetsPerLayer++;}
+      } // end loop on detectors
+    } // end loop on ladders
+    Info("ReadBadFromDetTypeRec",Form("Layer %d: %d bad out of %d",i-1,nBadDetsPerLayer,ndet*AliITSgeomTGeo::GetNLadders(i)));
+  } // end loop on layers
+  
+  return;
+}
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::LoadClusters(TTree *cTree) {
+  //--------------------------------------------------------------------
+  //This function loads ITS clusters
+  //--------------------------------------------------------------------
+  TBranch *branch=cTree->GetBranch("ITSRecPoints");
+  if (!branch) { 
+    Error("LoadClusters"," can't get the branch !\n");
+    return 1;
+  }
+
+  static TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
+  branch->SetAddress(&clusters);
+
+  Int_t i=0,j=0,ndet=0;
+  Int_t detector=0;
+  for (i=0; i<AliITSgeomTGeo::GetNLayers(); i++) {
+    ndet=fgLayers[i].GetNdetectors();
+    Int_t jmax = j + fgLayers[i].GetNladders()*ndet;
+    for (; j<jmax; j++) {           
+      if (!cTree->GetEvent(j)) continue;
+      Int_t ncl=clusters->GetEntriesFast();
+      SignDeltas(clusters,GetZ());
+      while (ncl--) {
+        AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
+        detector=c->GetDetectorIndex();
+
+       if (!c->Misalign()) AliWarning("Can't misalign this cluster !");
+
+        fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
+      }
+      clusters->Delete();
+      // add dead zone "virtual" cluster in SPD, if there is a cluster within 
+      // zwindow cm from the dead zone      
+      if (i<2 && AliITSReconstructor::GetRecoParam()->GetAddVirtualClustersInDeadZone()) {
+       for (Float_t xdead = 0; xdead < AliITSRecoParam::GetSPDdetxlength(); xdead += (i+1.)*AliITSReconstructor::GetRecoParam()->GetXPassDeadZoneHits()) {
+         Int_t lab[4]   = {0,0,0,detector};
+         Int_t info[3]  = {0,0,i};
+         Float_t q      = 0.; // this identifies virtual clusters
+         Float_t hit[5] = {xdead,
+                           0.,
+                           AliITSReconstructor::GetRecoParam()->GetSigmaXDeadZoneHit2(),
+                           AliITSReconstructor::GetRecoParam()->GetSigmaZDeadZoneHit2(),
+                           q};
+         Bool_t local   = kTRUE;
+         Double_t zwindow = AliITSReconstructor::GetRecoParam()->GetZWindowDeadZone();
+         hit[1] = fSPDdetzcentre[0]+0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+         hit[1] = fSPDdetzcentre[1]-0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+         hit[1] = fSPDdetzcentre[1]+0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+         hit[1] = fSPDdetzcentre[2]-0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+         hit[1] = fSPDdetzcentre[2]+0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+         hit[1] = fSPDdetzcentre[3]-0.5*AliITSRecoParam::GetSPDdetzlength();
+         if (TMath::Abs(fgLayers[i].GetDetector(detector).GetZmax()-hit[1])<zwindow) 
+           fgLayers[i].InsertCluster(new AliITSRecPoint(lab,hit,info,local));
+       }
+      } // "virtual" clusters in SPD
+      
+    }
+    //
+    fgLayers[i].ResetRoad(); //road defined by the cluster density
+    fgLayers[i].SortClusters();
+  }
+
+  dummy.Clear();
+
+  return 0;
+}
+//------------------------------------------------------------------------
+void AliITStrackerHLT::UnloadClusters() {
+  //--------------------------------------------------------------------
+  //This function unloads ITS clusters
+  //--------------------------------------------------------------------
+  for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fgLayers[i].ResetClusters();
+}
+
+
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::CorrectForTPCtoITSDeadZoneMaterial(AliHLTITSTrack *t) {
+  //--------------------------------------------------------------------
+  // Correction for the material between the TPC and the ITS
+  //--------------------------------------------------------------------
+  if (t->GetX() > AliITSRecoParam::Getriw()) {   // inward direction 
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getriw(),1)) return 0;// TPC inner wall
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1))  return 0;// ITS screen
+  } else if (t->GetX() < AliITSRecoParam::Getrs()) {  // outward direction
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1))        return 0;// ITS screen
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1))       return 0;// TPC central drum
+      if (!t->PropagateToTGeo(AliITSRecoParam::Getriw()+0.001,1)) return 0;// TPC inner wall
+  } else {
+    printf("CorrectForTPCtoITSDeadZoneMaterial: Track is already in the dead zone !\n");
+    return 0;
+  }
+  
+  return 1;
+}
+
+#include "TStopwatch.h"
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::Clusters2Tracks(AliESDEvent *event) {
+  //--------------------------------------------------------------------
+  // This functions reconstructs ITS tracks
+  // The clusters must be already loaded !
+  //--------------------------------------------------------------------
+  std::cout<<"\n\n ITS starts...\n"<<std::endl;
+  TStopwatch timer;
+  
+  fEsd = event;         // store pointer to the esd 
+  {/* Read ESD tracks */
+   
+    Double_t pimass = TDatabasePDG::Instance()->GetParticle(211)->Mass();
+
+    for( int itr=0; itr<event->GetNumberOfTracks(); itr++ ){
+
+      AliESDtrack *esdTrack = event->GetTrack(itr);
+
+      if ((esdTrack->GetStatus()&AliESDtrack::kTPCin)==0) continue;
+      if (esdTrack->GetStatus()&AliESDtrack::kTPCout) continue;
+      if (esdTrack->GetStatus()&AliESDtrack::kITSin) continue;
+      if (esdTrack->GetKinkIndex(0)>0) continue;   //kink daughter
+      AliHLTITSTrack tMI(*esdTrack);
+      AliHLTITSTrack *t = &tMI;
+      
+      if (tMI.GetMass()<0.9*pimass) t->SetMass(pimass); 
+      t->SetExpQ(TMath::Max(0.8*t->GetESDtrack()->GetTPCsignal(),30.));
+
+      if (!CorrectForTPCtoITSDeadZoneMaterial(t))  continue;
+
+      Int_t tpcLabel=t->GetLabel(); //save the TPC track label       
+      
+      FollowProlongationTree(t);
+      int nclu=0;
+      for(Int_t i=0; i<6; i++) {
+       if( t->GetClusterIndex(i)>=0 ) nclu++; 
+      }
+      cout<<"N assigned ITS clusters = "<<nclu<<std::endl;
+      if( nclu>0 ){
+       t->SetLabel(-1);//tpcLabel);
+       t->SetFakeRatio(1.);
+       CookLabel(t,0.); //For comparison only
+       cout<<"label = "<<t->GetLabel()<<" / "<<tpcLabel<<endl;
+       TransportToX(t, 0 );
+       cout<<"\n fill track : parameters at "<<t->GetX()<<": "<< TMath::Sqrt(TMath::Abs(t->GetSigmaY2()))<<" "<< TMath::Sqrt(TMath::Abs(t->GetSigmaY2()))<<endl;
+       //t->Print();
+       UpdateESDtrack(t,AliESDtrack::kITSin);          
+      }
+    }
+  } /* End Read ESD tracks */
+
+  AliHLTVertexer vertexer;
+  vertexer.SetESD( event );
+  vertexer.FindPrimaryVertex();
+  vertexer.FindV0s();
+
+
+  timer.Stop();
+  static double totalTime = 0;
+  static int nEvnts = 0;
+  totalTime+=timer.CpuTime();
+  nEvnts++;
+  std::cout<<"\n\n ITS tracker time = "<<totalTime/nEvnts<<" [s/ev]  for "<<nEvnts<<" events\n\n "<<std::endl;
+  return 0;
+}
+
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::PropagateBack(AliESDEvent * /*event*/) {
+  return 0;
+}
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::RefitInward(AliESDEvent * /*event*/ ) {
+  return 0;
+}
+//------------------------------------------------------------------------
+AliCluster *AliITStrackerHLT::GetCluster(Int_t index) const {
+  //--------------------------------------------------------------------
+  //       Return pointer to a given cluster
+  //--------------------------------------------------------------------
+  Int_t l=(index & 0xf0000000) >> 28;
+  Int_t c=(index & 0x0fffffff) >> 00;
+  return fgLayers[l].GetCluster(c);
+}
+//------------------------------------------------------------------------
+Bool_t AliITStrackerHLT::GetTrackPoint(Int_t index, AliTrackPoint& p) const {
+  //--------------------------------------------------------------------
+  // Get track space point with index i
+  //--------------------------------------------------------------------
+
+  Int_t l=(index & 0xf0000000) >> 28;
+  Int_t c=(index & 0x0fffffff) >> 00;
+  AliITSRecPoint *cl = fgLayers[l].GetCluster(c);
+  Int_t idet = cl->GetDetectorIndex();
+
+  Float_t xyz[3];
+  Float_t cov[6];
+  cl->GetGlobalXYZ(xyz);
+  cl->GetGlobalCov(cov);
+  p.SetXYZ(xyz, cov);
+  p.SetCharge(cl->GetQ());
+  p.SetDriftTime(cl->GetDriftTime());
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; 
+  switch (l) {
+  case 0:
+    iLayer = AliGeomManager::kSPD1;
+    break;
+  case 1:
+    iLayer = AliGeomManager::kSPD2;
+    break;
+  case 2:
+    iLayer = AliGeomManager::kSDD1;
+    break;
+  case 3:
+    iLayer = AliGeomManager::kSDD2;
+    break;
+  case 4:
+    iLayer = AliGeomManager::kSSD1;
+    break;
+  case 5:
+    iLayer = AliGeomManager::kSSD2;
+    break;
+  default:
+    AliWarning(Form("Wrong layer index in ITS (%d) !",l));
+    break;
+  };
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet);
+  p.SetVolumeID((UShort_t)volid);
+  return kTRUE;
+}
+//------------------------------------------------------------------------
+Bool_t AliITStrackerHLT::GetTrackPointTrackingError(Int_t index, 
+                       AliTrackPoint& p, const AliESDtrack *t) {
+  //--------------------------------------------------------------------
+  // Get track space point with index i
+  // (assign error estimated during the tracking)
+  //--------------------------------------------------------------------
+
+  Int_t l=(index & 0xf0000000) >> 28;
+  Int_t c=(index & 0x0fffffff) >> 00;
+  const AliITSRecPoint *cl = fgLayers[l].GetCluster(c);
+  Int_t idet = cl->GetDetectorIndex();
+
+  const AliHLTITSDetector &det=fgLayers[l].GetDetector(idet);
+
+  // tgphi and tglambda of the track in tracking frame with alpha=det.GetPhi
+  Float_t detxy[2];
+  detxy[0] = det.GetR()*TMath::Cos(det.GetPhi());
+  detxy[1] = det.GetR()*TMath::Sin(det.GetPhi());
+  Double_t alpha = t->GetAlpha();
+  Double_t xdetintrackframe = detxy[0]*TMath::Cos(alpha)+detxy[1]*TMath::Sin(alpha);
+  Float_t phi = TMath::ASin(t->GetSnpAt(xdetintrackframe,GetBz()));
+  phi += alpha-det.GetPhi();
+  Float_t tgphi = TMath::Tan(phi);
+
+  Float_t tgl = t->GetTgl(); // tgl about const along track
+  Float_t expQ = TMath::Max(0.8*t->GetTPCsignal(),30.);
+
+  Float_t errlocalx,errlocalz;
+  Bool_t addMisalErr=kFALSE;
+  AliITSClusterParam::GetError(l,cl,tgl,tgphi,expQ,errlocalx,errlocalz,addMisalErr);
+
+  Float_t xyz[3];
+  Float_t cov[6];
+  cl->GetGlobalXYZ(xyz);
+  //  cl->GetGlobalCov(cov);
+  Float_t pos[3] = {0.,0.,0.};
+  AliCluster tmpcl((UShort_t)cl->GetVolumeId(),pos[0],pos[1],pos[2],errlocalx*errlocalx,errlocalz*errlocalz,0);
+  tmpcl.GetGlobalCov(cov);
+
+  p.SetXYZ(xyz, cov);
+  p.SetCharge(cl->GetQ());
+  p.SetDriftTime(cl->GetDriftTime());
+
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; 
+  switch (l) {
+  case 0:
+    iLayer = AliGeomManager::kSPD1;
+    break;
+  case 1:
+    iLayer = AliGeomManager::kSPD2;
+    break;
+  case 2:
+    iLayer = AliGeomManager::kSDD1;
+    break;
+  case 3:
+    iLayer = AliGeomManager::kSDD2;
+    break;
+  case 4:
+    iLayer = AliGeomManager::kSSD1;
+    break;
+  case 5:
+    iLayer = AliGeomManager::kSSD2;
+    break;
+  default:
+    AliWarning(Form("Wrong layer index in ITS (%d) !",l));
+    break;
+  };
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,idet);
+
+  p.SetVolumeID((UShort_t)volid);
+  return kTRUE;
+}
+
+
+//------------------------------------------------------------------------
+void AliITStrackerHLT::FollowProlongationTree(AliHLTITSTrack * track ) 
+{
+    //cout<<endl;
+  for (Int_t ilayer=5; ilayer>=0; ilayer--) {
+    //cout<<"\nLayer "<<ilayer<<endl;
+    
+    AliHLTITSLayer &layer=fgLayers[ilayer];
+  
+    //cout<<" shield material.. "<<endl;
+
+    // material between SSD and SDD, SDD and SPD
+    if (ilayer==3 && !CorrectForShieldMaterial(track,"SDD","inward")) continue;
+    if (ilayer==1 && !CorrectForShieldMaterial(track,"SPD","inward")) continue;
+    
+    int idet;
+
+    {
+      // propagate to the layer radius
+      
+      Double_t r = layer.GetR(), phi,z;
+      Double_t xToGo;
+      //cout<<" propagate to layer R= "<<r<<" .."<<endl;
+      if( !track->GetLocalXat(r,xToGo) ) continue;
+      if( !TransportToX(track, xToGo) ) continue;
+
+      // detector number
+      
+      if (!track->GetPhiZat(r,phi,z)) continue;
+      idet=layer.FindDetectorIndex(phi,z);
+      //cout<<" detector number = "<<idet<<endl;
+   }
+
+
+    //cout<<" correct for the layer material .. "<<endl;
+
+    // correct for the layer material
+    {
+      Double_t trackGlobXYZ1[3];
+      if (!track->GetXYZ(trackGlobXYZ1)) continue;
+      CorrectForLayerMaterial(track,ilayer,trackGlobXYZ1,"inward");
+    }
+
+    // track outside layer acceptance in z
+    
+    if( idet<0 ) continue;
+    
+    // propagate to the intersection with the detector plane
+     
+    //cout<<" propagate to the intersection with the detector .. "<<endl;
+
+    const AliHLTITSDetector &det=layer.GetDetector( idet );
+    if (!TransportToPhiX( track, det.GetPhi(), det.GetR() ) ) continue;
+
+    // DEFINITION OF SEARCH ROAD AND CLUSTERS SELECTION
+    
+    // road in global (rphi,z) [i.e. in tracking ref. system]
+    
+    Double_t zmin,zmax,ymin,ymax;
+    
+    //cout<<" ComputeRoad .. "<<endl;
+    if (!ComputeRoad(track,ilayer,idet,zmin,zmax,ymin,ymax)) continue;
+  
+    //cout<<" Road: y["<<ymin<<","<<ymax<<"], z["<<zmin<<","<<zmax<<"] "<<endl;
+
+    // select clusters in road
+    
+    //cout<<" SelectClusters .. "<<endl;
+    layer.SelectClusters(zmin,zmax,ymin,ymax);     
+    
+    // Define criteria for track-cluster association
+    
+    Double_t msz = track->GetSigmaZ2() + 
+      AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+      AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+      AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer);
+
+    Double_t msy = track->GetSigmaY2() + 
+      AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+      AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+      AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer);
+
+     msz *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadZNonC();
+     msy *= AliITSReconstructor::GetRecoParam()->GetNSigma2RoadYNonC(); 
+  
+     msz = 1./msz; // 1/RoadZ^2
+     msy = 1./msy; // 1/RoadY^2
+     
+     //
+     // LOOP OVER ALL POSSIBLE TRACK PROLONGATIONS ON THIS LAYER
+     //
+
+     const AliITSRecPoint *cl=0; 
+     Int_t clidx=-1;
+     Double_t chi2trkcl=AliITSReconstructor::GetRecoParam()->GetMaxChi2(); // init with big value
+     Bool_t deadzoneSPD=kFALSE;
+
+     // check if the road contains a dead zone 
+     Bool_t noClusters = !layer.GetNextCluster(clidx,kTRUE);
+     
+     Double_t dz=0.5*(zmax-zmin);
+     Double_t dy=0.5*(ymax-ymin);
+     
+     Int_t dead = CheckDeadZone(track,ilayer,idet,dz,dy,noClusters); 
+
+     // create a prolongation without clusters (check also if there are no clusters in the road)
+
+     if (dead==1) { // dead zone at z=0,+-7cm in SPD
+       deadzoneSPD=kTRUE;
+     }
+     
+     clidx=-1;
+
+     //cout<<" loop over clusters in the road .. "<<endl;
+
+     // loop over clusters in the road     
+     const AliITSRecPoint *bestCluster=0; 
+     double bestChi2 = 1.e10;
+     AliHLTITSTrack bestTrack( *track );
+     int bestIdx = -1;
+     while ((cl=layer.GetNextCluster(clidx))!=0) {        
+       //cout<<" cluster: "<<cl->GetX()<<" "<<cl->GetY()<<" "<<cl->GetZ()<<endl;
+       AliHLTITSTrack t(*track);
+       if (cl->GetQ()==0 && deadzoneSPD==kTRUE) continue;
+       
+       Int_t idetc=cl->GetDetectorIndex();
+       
+       //cout<<" cluster detector: "<<idetc<<endl;
+
+       if ( idet !=idetc ) { // new cluster's detector
+        const AliHLTITSDetector &detc=layer.GetDetector(idetc);
+        if (!TransportToPhiX( track, detc.GetPhi(),detc.GetR()) ) continue;
+        t = *track;
+        idet = idetc;
+       }
+
+       // take into account misalignment (bring track to real detector plane)
+
+       if (!TransportToX( &t, t.GetX() + cl->GetX() ) ) continue;
+       double chi2 = ( (t.GetZ()-cl->GetZ())*(t.GetZ()-cl->GetZ())*msz + 
+                      (t.GetY()-cl->GetY())*(t.GetY()-cl->GetY())*msy   );
+       //cout<<" chi2="<<chi2<<endl;
+       if ( chi2 < bestChi2 ){
+        bestChi2 = chi2;
+        bestCluster = cl;
+        bestTrack = t;
+        bestIdx = clidx;
+        continue;
+       }
+     }
+
+     //cout<<" best chi2= "<<bestChi2<<endl;
+
+     if( bestCluster && bestChi2 <=1. ){
+
+       //cout<<" cluster found "<<endl;
+       *track = bestTrack;
+
+      // calculate track-clusters chi2
+       chi2trkcl = GetPredictedChi2MI(track,bestCluster,ilayer); 
+       //cout<<" track-clusters chi2 = "<<chi2trkcl<<endl;
+       //cout<<" max chi2 = "<<AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)<<endl;
+
+       // chi2 cut
+       if (chi2trkcl < AliITSReconstructor::GetRecoParam()->GetMaxChi2s(ilayer)) {
+        if (bestCluster->GetQ()==0) deadzoneSPD=kTRUE; // only 1 prolongation with virtual cluster
+        //cout<<"set index.."<<endl;    
+        //cout<<"set index ok"<<endl;
+        if (bestCluster->GetQ()!=0) { // real cluster     
+          //cout<<" UpdateMI ... "<<endl;
+          if (!UpdateMI(track,bestCluster,chi2trkcl,(ilayer<<28)+bestIdx)) {
+            continue;
+          } 
+        }
+       }          
+     }
+     //cout<<" goto next layer "<<endl;
+
+  }
+}
+
+
+//------------------------------------------------------------------------
+AliHLTITSLayer & AliITStrackerHLT::GetLayer(Int_t layer) const
+{
+  //--------------------------------------------------------------------
+  //
+  //
+  return fgLayers[layer];
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+//------------------------------------------------------------------------
+void AliITStrackerHLT::CookLabel(AliHLTITSTrack *track,Float_t wrong) const {
+  //--------------------------------------------------------------------
+  //This function "cooks" a track label. If label<0, this track is fake.
+  //--------------------------------------------------------------------
+  Int_t tpcLabel=-1; 
+     
+  if ( track->GetESDtrack())   tpcLabel =  TMath::Abs(track->GetESDtrack()->GetTPCLabel());
+
+   Int_t nwrong=0;
+   cout<<"cook label: nclu = "<<track->GetNumberOfClusters()<<endl;
+   for (Int_t i=0;i<track->GetNumberOfClusters();i++){
+     Int_t cindex = track->GetClusterIndex(i);
+     //Int_t l=(cindex & 0xf0000000) >> 28;
+     AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex);
+     Int_t isWrong=1;
+     for (Int_t ind=0;ind<3;ind++){
+       if (tpcLabel>0)
+        if (cl->GetLabel(ind)==tpcLabel) isWrong=0;
+       AliDebug(2,Form("icl %d  ilab %d lab %d",i,ind,cl->GetLabel(ind)));
+     }
+      nwrong+=isWrong;
+   }
+   Int_t nclusters = track->GetNumberOfClusters();
+   if (nclusters > 0) //PH Some tracks don't have any cluster
+     track->SetFakeRatio(double(nwrong)/double(nclusters));
+   cout<<"fake ratio = "<<track->GetFakeRatio()<<endl;
+   if (tpcLabel>0){
+     if (track->GetFakeRatio()>wrong) track->SetLabel(-tpcLabel);
+     else
+       track->SetLabel(tpcLabel);
+   }
+   AliDebug(2,Form(" nls %d wrong %d  label %d  tpcLabel %d\n",nclusters,nwrong,track->GetLabel(),tpcLabel));
+   
+}
+
+
+
+void AliITStrackerHLT::GetClusterErrors2( Int_t layer, const AliITSRecPoint *cluster, AliHLTITSTrack* track, double &err2Y, double &err2Z ) const
+{
+  Float_t erry,errz;
+  Float_t theta = track->GetTgl();
+  Float_t phi   = track->GetSnp();
+  phi = TMath::Abs(phi)*TMath::Sqrt(1./((1.-phi)*(1.+phi)));
+  AliITSClusterParam::GetError(layer,cluster,theta,phi,track->GetExpQ(),erry,errz);
+  err2Y = erry*erry;
+  err2Z = errz*errz;
+}
+
+
+//------------------------------------------------------------------------
+Double_t AliITStrackerHLT::GetPredictedChi2MI(AliHLTITSTrack* track, const AliITSRecPoint *cluster,Int_t layer) 
+{
+  //
+  // Compute predicted chi2
+  //
+
+  AliHLTITSTrack t(*track);
+  if (!t.Propagate( t.GetX()+cluster->GetX())) return 1000.;
+  Double_t  err2Y,err2Z;  
+  GetClusterErrors2( layer, cluster, &t, err2Y, err2Z );
+
+  Double_t chi2 = t.GetPredictedChi2(cluster->GetY(),cluster->GetZ(),err2Y,err2Z);
+
+  Float_t ny,nz; 
+  Float_t theta = track->GetTgl();
+  Float_t phi   = track->GetSnp();
+  phi = TMath::Abs(phi)*TMath::Sqrt(1./((1.-phi)*(1.+phi)));
+  AliITSClusterParam::GetNTeor(layer,cluster,theta,phi,ny,nz);  
+  Double_t delta = cluster->GetNy()+cluster->GetNz()-nz-ny;
+  if (delta>1){
+    chi2+=0.5*TMath::Min(delta/2,2.);
+    chi2+=2.*cluster->GetDeltaProbability();
+  }
+  return chi2;
+}
+
+
+//------------------------------------------------------------------------
+void AliITStrackerHLT::SignDeltas(const TObjArray *clusterArray, Float_t vz)
+{
+  //
+  // Clusters from delta electrons?
+  //  
+  Int_t entries = clusterArray->GetEntriesFast();
+  if (entries<4) return;
+  AliITSRecPoint* cluster = (AliITSRecPoint*)clusterArray->At(0);
+  Int_t layer = cluster->GetLayer();
+  if (layer>1) return;
+  Int_t index[10000];
+  Int_t ncandidates=0;
+  Float_t r = (layer>0)? 7:4;
+  // 
+  for (Int_t i=0;i<entries;i++){
+    AliITSRecPoint* cl0 = (AliITSRecPoint*)clusterArray->At(i);
+    Float_t nz = 1+TMath::Abs((cl0->GetZ()-vz)/r);
+    if (cl0->GetNy()+cl0->GetNz()<=5+2*layer+nz) continue;
+    index[ncandidates] = i;  //candidate to belong to delta electron track
+    ncandidates++;
+    if (cl0->GetNy()+cl0->GetNz()>9+2*layer+nz) {
+      cl0->SetDeltaProbability(1);
+    }
+  }
+  //
+  //  
+  //
+  for (Int_t i=0;i<ncandidates;i++){
+    AliITSRecPoint* cl0 = (AliITSRecPoint*)clusterArray->At(index[i]);
+    if (cl0->GetDeltaProbability()>0.8) continue;
+    // 
+    Int_t ncl = 0;
+    Float_t y[100],z[100],sumy,sumz,sumy2, sumyz, sumw;
+    sumy=sumz=sumy2=sumyz=sumw=0.0;
+    for (Int_t j=0;j<ncandidates;j++){
+      if (i==j) continue;
+      AliITSRecPoint* cl1 = (AliITSRecPoint*)clusterArray->At(index[j]);
+      //
+      Float_t dz = cl0->GetZ()-cl1->GetZ();
+      Float_t dy = cl0->GetY()-cl1->GetY();
+      if (TMath::Sqrt(dz*dz+dy*dy)<0.2){
+       Float_t weight = cl1->GetNy()+cl1->GetNz()-2;
+       y[ncl] = cl1->GetY();
+       z[ncl] = cl1->GetZ();
+       sumy+= y[ncl]*weight;
+       sumz+= z[ncl]*weight;
+       sumy2+=y[ncl]*y[ncl]*weight;
+       sumyz+=y[ncl]*z[ncl]*weight;
+       sumw+=weight;
+       ncl++;
+      }
+    }
+    if (ncl<4) continue;
+    Float_t det = sumw*sumy2  - sumy*sumy;
+    Float_t delta=1000;
+    if (TMath::Abs(det)>0.01){
+      Float_t z0  = (sumy2*sumz - sumy*sumyz)/det;
+      Float_t k   = (sumyz*sumw - sumy*sumz)/det;
+      delta = TMath::Abs(cl0->GetZ()-(z0+k*cl0->GetY()));
+    }
+    else{
+      Float_t z0  = sumyz/sumy;
+      delta = TMath::Abs(cl0->GetZ()-z0);
+    }
+    if ( delta<0.05) {
+      cl0->SetDeltaProbability(1-20.*delta);
+    }   
+  }
+}
+//------------------------------------------------------------------------
+void AliITStrackerHLT::UpdateESDtrack(AliHLTITSTrack* track, ULong_t flags) const
+{
+  //
+  // Update ESD track
+  //
+  track->UpdateESDtrack(flags);
+  AliHLTITSTrack * oldtrack = (AliHLTITSTrack*)(track->GetESDtrack()->GetITStrack());
+  if (oldtrack) delete oldtrack; 
+  track->GetESDtrack()->SetITStrack(new AliHLTITSTrack(*track));
+}
+
+
+
+
+//------------------------------------------------------------------------
+void AliITStrackerHLT::BuildMaterialLUT(TString material) {
+  //--------------------------------------------------------------------
+  // Fill a look-up table with mean material
+  //--------------------------------------------------------------------
+
+  Int_t n=1000;
+  Double_t mparam[7];
+  Double_t point1[3],point2[3];
+  Double_t phi,cosphi,sinphi,z;
+  // 0-5 layers, 6 pipe, 7-8 shields 
+  Double_t rmin[9]={ 3.5, 5.5,13.0,22.0,35.0,41.0, 2.0, 8.0,25.0};
+  Double_t rmax[9]={ 5.5, 8.0,17.0,26.0,41.0,47.0, 3.0,10.5,30.0};
+
+  Int_t ifirst=0,ilast=0;  
+  if(material.Contains("Pipe")) {
+    ifirst=6; ilast=6;
+  } else if(material.Contains("Shields")) {
+    ifirst=7; ilast=8;
+  } else if(material.Contains("Layers")) {
+    ifirst=0; ilast=5;
+  } else {
+    Error("BuildMaterialLUT","Wrong layer name\n");
+  }
+
+  for(Int_t imat=ifirst; imat<=ilast; imat++) {
+    Double_t param[5]={0.,0.,0.,0.,0.};
+    for (Int_t i=0; i<n; i++) {
+      phi = 2.*TMath::Pi()*gRandom->Rndm();
+      cosphi = TMath::Cos(phi); sinphi = TMath::Sin(phi); 
+      z = 14.*(-1.+2.*gRandom->Rndm()); // SPD barrel
+      point1[0] = rmin[imat]*cosphi;
+      point1[1] = rmin[imat]*sinphi;
+      point1[2] = z;
+      point2[0] = rmax[imat]*cosphi;
+      point2[1] = rmax[imat]*sinphi;
+      point2[2] = z;
+      AliTracker::MeanMaterialBudget(point1,point2,mparam);
+      for(Int_t j=0;j<5;j++) param[j]+=mparam[j];
+    }
+    for(Int_t j=0;j<5;j++) param[j]/=(Float_t)n;
+    if(imat<=5) {
+      fxOverX0Layer[imat] = param[1];
+      fxTimesRhoLayer[imat] = param[0]*param[4];
+    } else if(imat==6) {
+      fxOverX0Pipe = param[1];
+      fxTimesRhoPipe = param[0]*param[4];
+    } else if(imat==7) {
+      fxOverX0Shield[0] = param[1];
+      fxTimesRhoShield[0] = param[0]*param[4];
+    } else if(imat==8) {
+      fxOverX0Shield[1] = param[1];
+      fxTimesRhoShield[1] = param[0]*param[4];
+    }
+  }
+  /*
+  printf("%s\n",material.Data());
+  printf("%f  %f\n",fxOverX0Pipe,fxTimesRhoPipe);
+  printf("%f  %f\n",fxOverX0Shield[0],fxTimesRhoShield[0]);
+  printf("%f  %f\n",fxOverX0Shield[1],fxTimesRhoShield[1]);
+  printf("%f  %f\n",fxOverX0Layer[0],fxTimesRhoLayer[0]);
+  printf("%f  %f\n",fxOverX0Layer[1],fxTimesRhoLayer[1]);
+  printf("%f  %f\n",fxOverX0Layer[2],fxTimesRhoLayer[2]);
+  printf("%f  %f\n",fxOverX0Layer[3],fxTimesRhoLayer[3]);
+  printf("%f  %f\n",fxOverX0Layer[4],fxTimesRhoLayer[4]);
+  printf("%f  %f\n",fxOverX0Layer[5],fxTimesRhoLayer[5]);
+  */
+  return;
+}
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::CorrectForPipeMaterial(AliHLTITSTrack *t,
+                                             TString direction) {
+  //-------------------------------------------------------------------
+  // Propagate beyond beam pipe and correct for material
+  // (material budget in different ways according to fUseTGeo value)
+  // Add time if going outward (PropagateTo or PropagateToTGeo)
+  //-------------------------------------------------------------------
+
+  // Define budget mode:
+  // 0: material from AliITSRecoParam (hard coded)
+  // 1: material from TGeo in one step (on the fly)
+  // 2: material from lut
+  // 3: material from TGeo in one step (same for all hypotheses)
+  Int_t mode;
+  switch(fUseTGeo) {
+  case 0:
+    mode=0; 
+    break;    
+  case 1:
+    mode=1;
+    break;    
+  case 2:
+    mode=2;
+    break;
+  case 3:
+    mode=3; 
+    break;
+  case 4:
+    mode=3;
+    break;
+  default:
+    mode=0;
+    break;
+  }
+  
+  Float_t  dir = (direction.Contains("inward") ? 1. : -1.);
+  Double_t rToGo=(dir>0 ? AliITSRecoParam::GetrInsidePipe() : AliITSRecoParam::GetrOutsidePipe());
+  Double_t xToGo;
+  if (!t->GetLocalXat(rToGo,xToGo)) return 0;
+
+  Double_t xOverX0,x0,lengthTimesMeanDensity;
+
+  switch(mode) {
+  case 0:
+    xOverX0 = AliITSRecoParam::GetdPipe();
+    x0 = AliITSRecoParam::GetX0Be();
+    lengthTimesMeanDensity = xOverX0*x0;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 1:
+    if (!t->PropagateToTGeo(xToGo,1)) return 0;
+    break;
+  case 2:
+    if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe");  
+    xOverX0 = fxOverX0Pipe;
+    lengthTimesMeanDensity = fxTimesRhoPipe;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 3:
+    double xOverX0PipeTrks, xTimesRhoPipeTrks;
+    if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0;
+    Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/
+                              ((1.-t->GetSnp())*(1.+t->GetSnp())));
+    xOverX0PipeTrks = TMath::Abs(xOverX0)/angle;
+    xTimesRhoPipeTrks = TMath::Abs(lengthTimesMeanDensity)/angle;
+    xOverX0 = xOverX0PipeTrks;
+    lengthTimesMeanDensity = xTimesRhoPipeTrks;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  }
+  
+  return 1;
+}
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::CorrectForShieldMaterial(AliHLTITSTrack *t,
+                                               TString shield,
+                                               TString direction) {
+  //-------------------------------------------------------------------
+  // Propagate beyond SPD or SDD shield and correct for material
+  // (material budget in different ways according to fUseTGeo value)
+  // Add time if going outward (PropagateTo or PropagateToTGeo)
+  //-------------------------------------------------------------------
+
+  // Define budget mode:
+  // 0: material from AliITSRecoParam (hard coded)
+  // 1: material from TGeo in steps of X cm (on the fly)
+  //    X = AliITSRecoParam::GetStepSizeTGeo()
+  // 2: material from lut
+  // 3: material from TGeo in one step (same for all hypotheses)
+  Int_t mode;
+  switch(fUseTGeo) {
+  case 0:
+    mode=0; 
+    break;    
+  case 1:
+    mode=1;
+    break;    
+  case 2:
+    mode=2;
+    break;
+  case 3:
+    mode=3;
+    break;
+  case 4:
+    mode=3;
+    break;
+  default:
+    mode=0;
+    break;
+  }
+
+
+  Float_t  dir = (direction.Contains("inward") ? 1. : -1.);
+  Double_t rToGo;
+  Int_t    shieldindex=0;
+  if (shield.Contains("SDD")) { // SDDouter
+    rToGo=(dir>0 ? AliITSRecoParam::GetrInsideShield(1) : AliITSRecoParam::GetrOutsideShield(1));
+    shieldindex=1;
+  } else if (shield.Contains("SPD")) {        // SPDouter
+    rToGo=(dir>0 ? AliITSRecoParam::GetrInsideShield(0) : AliITSRecoParam::GetrOutsideShield(0)); 
+    shieldindex=0;
+  } else {
+    Error("CorrectForShieldMaterial"," Wrong shield name\n");
+    return 0;
+  }
+  Double_t xToGo;
+  if (!t->GetLocalXat(rToGo,xToGo)) return 0;
+
+  Double_t xOverX0,x0,lengthTimesMeanDensity;
+  Int_t nsteps=1;
+
+  switch(mode) {
+  case 0:
+    xOverX0 = AliITSRecoParam::Getdshield(shieldindex);
+    x0 = AliITSRecoParam::GetX0shield(shieldindex);
+    lengthTimesMeanDensity = xOverX0*x0;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 1:
+    nsteps= (Int_t)(TMath::Abs(t->GetX()-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1;
+    if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction
+    break;
+  case 2:
+    if(fxOverX0Shield[shieldindex]<0) BuildMaterialLUT("Shields");  
+    xOverX0 = fxOverX0Shield[shieldindex];
+    lengthTimesMeanDensity = fxTimesRhoShield[shieldindex];
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 3:    
+    if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0;
+    Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/
+                              ((1.-t->GetSnp())*(1.+t->GetSnp())));
+    double xOverX0ShieldTrks = TMath::Abs(xOverX0)/angle;
+    double xTimesRhoShieldTrks = TMath::Abs(lengthTimesMeanDensity)/angle;
+    xOverX0 = xOverX0ShieldTrks;
+    lengthTimesMeanDensity = xTimesRhoShieldTrks;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  }
+
+  return 1;
+}
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::CorrectForLayerMaterial(AliHLTITSTrack *t,
+                                              Int_t layerindex,
+                                              Double_t oldGlobXYZ[3],
+                                              TString direction) {
+  //-------------------------------------------------------------------
+  // Propagate beyond layer and correct for material
+  // (material budget in different ways according to fUseTGeo value)
+  // Add time if going outward (PropagateTo or PropagateToTGeo)
+  //-------------------------------------------------------------------
+
+  // Define budget mode:
+  // 0: material from AliITSRecoParam (hard coded)
+  // 1: material from TGeo in stepsof X cm (on the fly)
+  //    X = AliITSRecoParam::GetStepSizeTGeo()
+  // 2: material from lut
+  // 3: material from TGeo in one step (same for all hypotheses)
+  Int_t mode;
+  switch(fUseTGeo) {
+  case 0:
+    mode=0; 
+    break;    
+  case 1:
+    mode=1;
+    break;    
+  case 2:
+    mode=2;
+    break;
+  case 3:
+    mode=3;
+    break;
+  case 4:
+    mode=3;
+    break;
+  default:
+    mode=0;
+    break;
+  }
+
+
+  Float_t  dir = (direction.Contains("inward") ? 1. : -1.);
+
+  Double_t r=fgLayers[layerindex].GetR();
+  Double_t deltar=(layerindex<2 ? 0.10*r : 0.05*r);
+
+  Double_t rToGo=TMath::Sqrt(t->GetX()*t->GetX()+t->GetY()*t->GetY())-deltar*dir;
+  Double_t xToGo;
+  if (!t->GetLocalXat(rToGo,xToGo)) return 0;  
+
+
+  Double_t xOverX0=0.0,x0=0.0,lengthTimesMeanDensity=0.0;
+  Int_t nsteps=1;
+
+  // back before material (no correction)
+  Double_t rOld,xOld;
+  rOld=TMath::Sqrt(oldGlobXYZ[0]*oldGlobXYZ[0]+oldGlobXYZ[1]*oldGlobXYZ[1]);
+  if (!t->GetLocalXat(rOld,xOld)) return 0;
+  if (!TransportToX( t, xOld)) return 0;
+
+  switch(mode) {
+  case 0:
+    xOverX0 = fgLayers[layerindex].GetThickness(t->GetY(),t->GetZ(),x0);
+    lengthTimesMeanDensity = xOverX0*x0;
+    lengthTimesMeanDensity *= dir;
+    // Bring the track beyond the material
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 1:
+    nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1;
+    if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction
+    break;
+  case 2:
+    if(fxOverX0Layer[layerindex]<0) BuildMaterialLUT("Layers");  
+    xOverX0 = fxOverX0Layer[layerindex];
+    lengthTimesMeanDensity = fxTimesRhoLayer[layerindex];
+    lengthTimesMeanDensity *= dir;
+    // Bring the track beyond the material
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  case 3:
+    nsteps = (Int_t)(TMath::Abs(xOld-xToGo)/AliITSReconstructor::GetRecoParam()->GetStepSizeTGeo())+1;
+    if (!t->PropagateToTGeo(xToGo,nsteps,xOverX0,lengthTimesMeanDensity)) return 0;
+    Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/
+                              ((1.-t->GetSnp())*(1.+t->GetSnp())));
+    double xOverX0LayerTrks = TMath::Abs(xOverX0)/angle;
+    double xTimesRhoLayerTrks = TMath::Abs(lengthTimesMeanDensity)/angle;
+    xOverX0 = xOverX0LayerTrks;
+    lengthTimesMeanDensity = xTimesRhoLayerTrks;
+    lengthTimesMeanDensity *= dir;
+    if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
+    break;
+  }
+
+
+  return 1;
+}
+
+
+//------------------------------------------------------------------------
+Int_t AliITStrackerHLT::CheckDeadZone(AliHLTITSTrack *track,
+                                    Int_t ilayer,Int_t idet,
+                                    Double_t dz,Double_t dy,
+                                    Bool_t noClusters) const {
+  //-----------------------------------------------------------------
+  // This method is used to decide whether to allow a prolongation 
+  // without clusters, because there is a dead zone in the road.
+  // In this case the return value is > 0:
+  // return 1: dead zone at z=0,+-7cm in SPD
+  // return 2: all road is "bad" (dead or noisy) from the OCDB
+  // return 3: something "bad" (dead or noisy) from the OCDB
+  //-----------------------------------------------------------------
+
+  // check dead zones at z=0,+-7cm in the SPD
+  if (ilayer<2 && !AliITSReconstructor::GetRecoParam()->GetAddVirtualClustersInDeadZone()) {
+    Double_t zmindead[3]={fSPDdetzcentre[0] + 0.5*AliITSRecoParam::GetSPDdetzlength(),
+                         fSPDdetzcentre[1] + 0.5*AliITSRecoParam::GetSPDdetzlength(),
+                         fSPDdetzcentre[2] + 0.5*AliITSRecoParam::GetSPDdetzlength()};
+    Double_t zmaxdead[3]={fSPDdetzcentre[1] - 0.5*AliITSRecoParam::GetSPDdetzlength(),
+                         fSPDdetzcentre[2] - 0.5*AliITSRecoParam::GetSPDdetzlength(),
+                         fSPDdetzcentre[3] - 0.5*AliITSRecoParam::GetSPDdetzlength()};
+    for (Int_t i=0; i<3; i++)
+      if (track->GetZ()-dz<zmaxdead[i] && track->GetZ()+dz>zmindead[i]) {
+       AliDebug(2,Form("crack SPD %d",ilayer));
+       return 1; 
+      } 
+  }
+
+  // check bad zones from OCDB
+  if (!AliITSReconstructor::GetRecoParam()->GetUseBadZonesFromOCDB()) return 0;
+
+  if (idet<0) return 0;
+
+  AliHLTITSDetector &det=fgLayers[ilayer].GetDetector(idet);  
+
+  Int_t detType=-1;
+  Float_t detSizeFactorX=0.0001,detSizeFactorZ=0.0001;
+  if (ilayer==0 || ilayer==1) {        // ----------  SPD
+    detType = 0;
+  } else if (ilayer==2 || ilayer==3) { // ----------  SDD
+    detType = 1;
+    detSizeFactorX *= 2.;
+  } else if (ilayer==4 || ilayer==5) { // ----------  SSD
+    detType = 2;
+  }
+  AliITSsegmentation *segm = (AliITSsegmentation*)fkDetTypeRec->GetSegmentationModel(detType);
+  if (detType==2) segm->SetLayer(ilayer+1);
+  Float_t detSizeX = detSizeFactorX*segm->Dx(); 
+  Float_t detSizeZ = detSizeFactorZ*segm->Dz(); 
+
+  // check if the road overlaps with bad chips
+  Float_t xloc,zloc;
+  LocalModuleCoord(ilayer,idet,track,xloc,zloc);
+  Float_t zlocmin = zloc-dz;
+  Float_t zlocmax = zloc+dz;
+  Float_t xlocmin = xloc-dy;
+  Float_t xlocmax = xloc+dy;
+  Int_t chipsInRoad[100];
+
+  // check if road goes out of detector
+  Bool_t touchNeighbourDet=kFALSE; 
+  if (TMath::Abs(xlocmin)>0.5*detSizeX) {xlocmin=-0.5*detSizeX; touchNeighbourDet=kTRUE;} 
+  if (TMath::Abs(xlocmax)>0.5*detSizeX) {xlocmax=+0.5*detSizeX; touchNeighbourDet=kTRUE;} 
+  if (TMath::Abs(zlocmin)>0.5*detSizeZ) {zlocmin=-0.5*detSizeZ; touchNeighbourDet=kTRUE;} 
+  if (TMath::Abs(zlocmax)>0.5*detSizeZ) {zlocmax=+0.5*detSizeZ; touchNeighbourDet=kTRUE;} 
+  AliDebug(2,Form("layer %d det %d zmim zmax %f %f xmin xmax %f %f   %f %f",ilayer,idet,zlocmin,zlocmax,xlocmin,xlocmax,detSizeZ,detSizeX));
+
+  // check if this detector is bad
+  if (det.IsBad()) {
+    AliDebug(2,Form("lay %d  bad detector %d",ilayer,idet));
+    if(!touchNeighbourDet) {
+      return 2; // all detectors in road are bad
+    } else { 
+      return 3; // at least one is bad
+    }
+  }
+
+  Int_t nChipsInRoad = segm->GetChipsInLocalWindow(chipsInRoad,zlocmin,zlocmax,xlocmin,xlocmax);
+  AliDebug(2,Form("lay %d nChipsInRoad %d",ilayer,nChipsInRoad));
+  if (!nChipsInRoad) return 0;
+
+  Bool_t anyBad=kFALSE,anyGood=kFALSE;
+  for (Int_t iCh=0; iCh<nChipsInRoad; iCh++) {
+    if (chipsInRoad[iCh]<0 || chipsInRoad[iCh]>det.GetNChips()-1) continue;
+    AliDebug(2,Form("  chip %d bad %d",chipsInRoad[iCh],(Int_t)det.IsChipBad(chipsInRoad[iCh])));
+    if (det.IsChipBad(chipsInRoad[iCh])) {
+      anyBad=kTRUE;
+    } else {
+      anyGood=kTRUE;
+    } 
+  }
+
+  if (!anyGood) {
+    if(!touchNeighbourDet) {
+      AliDebug(2,"all bad in road");
+      return 2;  // all chips in road are bad
+    } else {
+      return 3; // at least a bad chip in road
+    }
+  }
+
+  if (anyBad) {
+    AliDebug(2,"at least a bad in road");
+    return 3; // at least a bad chip in road
+  } 
+
+
+  if (!AliITSReconstructor::GetRecoParam()->GetUseSingleBadChannelsFromOCDB()
+      || ilayer==4 || ilayer==5     // SSD
+      || !noClusters) return 0;
+
+  // There are no clusters in road: check if there is at least 
+  // a bad SPD pixel or SDD anode 
+
+  Int_t idetInITS=idet;
+  for(Int_t l=0;l<ilayer;l++) idetInITS+=AliITSgeomTGeo::GetNLadders(l+1)*AliITSgeomTGeo::GetNDetectors(l+1);
+
+  if (fITSChannelStatus->AnyBadInRoad(idetInITS,zlocmin,zlocmax,xlocmin,xlocmax)) {
+    AliDebug(2,Form("Bad channel in det %d of layer %d\n",idet,ilayer));
+    return 3;
+  }
+  //if (fITSChannelStatus->FractionOfBadInRoad(idet,zlocmin,zlocmax,xlocmin,xlocmax) > AliITSReconstructor::GetRecoParam()->GetMinFractionOfBadInRoad()) return 3;
+
+  return 0;
+}
+//------------------------------------------------------------------------
+Bool_t AliITStrackerHLT::LocalModuleCoord(Int_t ilayer,Int_t idet,
+                                      const AliHLTITSTrack *track,
+                                      Float_t &xloc,Float_t &zloc) const {
+  //-----------------------------------------------------------------
+  // Gives position of track in local module ref. frame
+  //-----------------------------------------------------------------
+
+  xloc=0.; 
+  zloc=0.;
+
+  if(idet<0) return kFALSE;
+
+  Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6 
+
+  Int_t lad = Int_t(idet/ndet) + 1;
+
+  Int_t det = idet - (lad-1)*ndet + 1;
+
+  Double_t xyzGlob[3],xyzLoc[3];
+
+  AliHLTITSDetector &detector = fgLayers[ilayer].GetDetector(idet);
+  // take into account the misalignment: xyz at real detector plane
+  if(!track->GetXYZAt(detector.GetRmisal(),GetBz(),xyzGlob)) return kFALSE;
+
+  if(!AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,det,xyzGlob,xyzLoc)) return kFALSE;
+
+  xloc = (Float_t)xyzLoc[0];
+  zloc = (Float_t)xyzLoc[2];
+
+  return kTRUE;
+}
+
+//------------------------------------------------------------------------
+Bool_t AliITStrackerHLT::ComputeRoad(AliHLTITSTrack* track,Int_t ilayer,Int_t idet,Double_t &zmin,Double_t &zmax,Double_t &ymin,Double_t &ymax) const {
+  //--------------------------------------------------------------------
+  // This function computes the rectangular road for this track
+  //--------------------------------------------------------------------
+
+
+  AliHLTITSDetector &det = fgLayers[ilayer].GetDetector(idet);
+  // take into account the misalignment: propagate track to misaligned detector plane
+  if (!TransportToPhiX( track, det.GetPhi(),det.GetRmisal() ) ) return kFALSE;
+
+  Double_t dz=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadZ()*
+                    TMath::Sqrt(track->GetSigmaZ2() + 
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaZLayerForRoadZ()*
+                   AliITSReconstructor::GetRecoParam()->GetSigmaZ2(ilayer));
+  Double_t dy=AliITSReconstructor::GetRecoParam()->GetNSigmaRoadY()*
+                    TMath::Sqrt(track->GetSigmaY2() + 
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+                   AliITSReconstructor::GetRecoParam()->GetNSigmaYLayerForRoadY()*
+                   AliITSReconstructor::GetRecoParam()->GetSigmaY2(ilayer));
+      
+  // track at boundary between detectors, enlarge road
+  Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidth();
+  if ( (track->GetY()-dy < det.GetYmin()+boundaryWidth) || 
+       (track->GetY()+dy > det.GetYmax()-boundaryWidth) || 
+       (track->GetZ()-dz < det.GetZmin()+boundaryWidth) ||
+       (track->GetZ()+dz > det.GetZmax()-boundaryWidth) ) {
+    Float_t tgl = TMath::Abs(track->GetTgl());
+    if (tgl > 1.) tgl=1.;
+    Double_t deltaXNeighbDets=AliITSRecoParam::GetDeltaXNeighbDets();
+    dz = TMath::Sqrt(dz*dz+deltaXNeighbDets*deltaXNeighbDets*tgl*tgl);
+    Float_t snp = TMath::Abs(track->GetSnp());
+    if (snp > AliITSReconstructor::GetRecoParam()->GetMaxSnp()) return kFALSE;
+    dy = TMath::Sqrt(dy*dy+deltaXNeighbDets*deltaXNeighbDets*snp*snp);
+  } // boundary
+  
+  // add to the road a term (up to 2-3 mm) to deal with misalignments
+  dy = TMath::Sqrt(dy*dy + AliITSReconstructor::GetRecoParam()->GetRoadMisal()*AliITSReconstructor::GetRecoParam()->GetRoadMisal());
+  dz = TMath::Sqrt(dz*dz + AliITSReconstructor::GetRecoParam()->GetRoadMisal()*AliITSReconstructor::GetRecoParam()->GetRoadMisal());
+
+  Double_t r = fgLayers[ilayer].GetR();
+  zmin = track->GetZ() - dz; 
+  zmax = track->GetZ() + dz;
+  ymin = track->GetY() + r*det.GetPhi() - dy;
+  ymax = track->GetY() + r*det.GetPhi() + dy;
+
+  // bring track back to idead detector plane
+  if (!TransportToPhiX( track, det.GetPhi(),det.GetR())) return kFALSE;
+
+  return kTRUE;
+}
diff --git a/HLT/ITS/tracking/AliITStrackerHLT.h b/HLT/ITS/tracking/AliITStrackerHLT.h
new file mode 100644 (file)
index 0000000..c3fdba5
--- /dev/null
@@ -0,0 +1,139 @@
+#ifndef ALIITSTRACKERHLT_H
+#define ALIITSTRACKERHLT_H
+/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+class TTree;
+class TTreeSRedirector;
+class AliESDEvent;
+
+
+class AliITSChannelStatus;
+class AliITSDetTypeRec;
+#include "AliHLTITSTrack.h" 
+#include "AliHLTITSDetector.h"
+#include "AliHLTITSLayer.h"
+
+#include <TObjArray.h>
+
+#include "AliITSRecPoint.h"
+#include "AliTracker.h"
+
+
+//-------------------------------------------------------------------------
+class AliITStrackerHLT : public AliTracker {
+public:
+  Bool_t TransportToX( AliExternalTrackParam *t, double x ) const;
+  Bool_t TransportToPhiX( AliExternalTrackParam *t, double phi, double x ) const;
+  Bool_t UpdateMy( AliExternalTrackParam *t, double y, double z, double err2y, double err2z ) const;
+  void GetClusterErrors2( Int_t layer, const AliITSRecPoint *cluster, AliHLTITSTrack* track, double &err2Y, double &err2Z ) const ;
+
+  AliITStrackerHLT();
+  AliITStrackerHLT(const Char_t *geom);
+  virtual ~AliITStrackerHLT();
+  AliCluster *GetCluster(Int_t index) const;
+  virtual Bool_t GetTrackPoint(Int_t index, AliTrackPoint& p) const;
+  virtual Bool_t GetTrackPointTrackingError(Int_t index, 
+                       AliTrackPoint& p, const AliESDtrack *t);
+  AliITSRecPoint *GetClusterLayer(Int_t layn, Int_t ncl) const
+                  {return fgLayers[layn].GetCluster(ncl);}
+  Int_t GetNumberOfClustersLayer(Int_t layn) const 
+                        {return fgLayers[layn].GetNumberOfClusters();}
+  Int_t LoadClusters(TTree *cf);
+  void UnloadClusters();
+  
+  Int_t Clusters2Tracks(AliESDEvent *event);
+  Int_t PropagateBack(AliESDEvent *event);
+  Int_t RefitInward(AliESDEvent *event);
+
+  void SetLayersNotToSkip(const Int_t *l);
+
+  Double_t GetPredictedChi2MI(AliHLTITSTrack* track, const AliITSRecPoint *cluster,Int_t layer);
+  Int_t UpdateMI(AliHLTITSTrack* track, const AliITSRecPoint* cl,Double_t chi2,Int_t layer) const;  
+  void SetDetTypeRec(const AliITSDetTypeRec *detTypeRec) {fkDetTypeRec = detTypeRec; ReadBadFromDetTypeRec(); }
+
+  TTreeSRedirector *GetDebugStreamer() {return fDebugStreamer;}
+  static Int_t CorrectForTPCtoITSDeadZoneMaterial(AliHLTITSTrack *t);
+
+
+  AliHLTITSLayer    & GetLayer(Int_t layer) const;
+  AliHLTITSDetector & GetDetector(Int_t layer, Int_t n) const {return GetLayer(layer).GetDetector(n); }
+  void FollowProlongationTree(AliHLTITSTrack * otrack);
+
+protected:
+  Bool_t ComputeRoad(AliHLTITSTrack* track,Int_t ilayer,Int_t idet,Double_t &zmin,Double_t &zmax,Double_t &ymin,Double_t &ymax) const;
+  
+  
+  void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
+  void CookLabel(AliHLTITSTrack *t,Float_t wrong) const;
+
+  void       SignDeltas(const TObjArray *clusterArray, Float_t zv);
+  void BuildMaterialLUT(TString material);
+  
+  Int_t CorrectForPipeMaterial(AliHLTITSTrack *t, TString direction="inward");
+  Int_t CorrectForShieldMaterial(AliHLTITSTrack *t, TString shield, TString direction="inward");
+  Int_t CorrectForLayerMaterial(AliHLTITSTrack *t, Int_t layerindex, Double_t oldGlobXYZ[3], TString direction="inward");
+  void UpdateESDtrack(AliHLTITSTrack* track, ULong_t flags) const;
+  void ReadBadFromDetTypeRec();
+  
+  Int_t CheckDeadZone(AliHLTITSTrack *track,Int_t ilayer,Int_t idet,Double_t dz,Double_t dy,Bool_t noClusters=kFALSE) const;
+  Bool_t LocalModuleCoord(Int_t ilayer,Int_t idet,const AliHLTITSTrack *track,
+                         Float_t &xloc,Float_t &zloc) const;
+// method to be used for Plane Efficiency evaluation
+
+  // 
+
+  static AliHLTITSLayer fgLayers[AliITSgeomTGeo::kNLayers];// ITS layers
+  
+  AliESDEvent  * fEsd;                   //! pointer to the ESD event
+  Double_t fSPDdetzcentre[4];            // centres of SPD modules in z
+  
+  Int_t fUseTGeo;                        // use TGeo to get material budget
+
+  Float_t fxOverX0Pipe;                  // material budget
+  Float_t fxTimesRhoPipe;                // material budget
+  Float_t fxOverX0Shield[2];             // material budget
+  Float_t fxTimesRhoShield[2];           // material budget
+  Float_t fxOverX0Layer[6];              // material budget
+  Float_t fxTimesRhoLayer[6];            // material budget
+
+  TTreeSRedirector *fDebugStreamer;      //!debug streamer
+  AliITSChannelStatus *fITSChannelStatus;//! bitmaps with channel status for SPD and SDD
+  const AliITSDetTypeRec *fkDetTypeRec;         //! ITS det type rec, from AliITSReconstructor
+
+private:
+  AliITStrackerHLT(const AliITStrackerHLT &tracker);
+  AliITStrackerHLT & operator=(const AliITStrackerHLT &tracker);  
+};
+
+
+
+
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+
+
+
+
+
+inline void AliITStrackerHLT::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
+  //--------------------------------------------------------------------
+  //This function "cooks" a track label. If label<0, this track is fake.
+  //--------------------------------------------------------------------
+   Int_t tpcLabel=t->GetLabel();
+   if (tpcLabel<0) return;
+   AliTracker::CookLabel(t,wrong);
+   if (tpcLabel!=TMath::Abs(t->GetLabel())){
+     t->SetFakeRatio(1.);
+   }
+   if (tpcLabel !=t->GetLabel()) {
+     t->SetLabel(-tpcLabel);      
+   }
+}
+
+
+
+#endif
index 526f705..6141354 100644 (file)
@@ -8,7 +8,12 @@ CLASS_HDRS:=   AliHLTITStrack.h \
                AliHLTITSAgent.h\
                AliHLTITSClusterFinderSPDComponent.h\
                AliHLTITSClusterFinderSSDComponent.h\
-               AliHLTITSCompressRawDataSDDComponent.h  
+               AliHLTITSCompressRawDataSDDComponent.h \
+               tracking/AliITStrackerHLT.h \
+               tracking/AliHLTITSDetector.h \
+               tracking/AliHLTITSLayer.h \
+               tracking/AliHLTITSTrack.h \
+               tracking/AliHLTVertexer.h
 
 MODULE_SRCS=   $(CLASS_HDRS:.h=.cxx)
 
@@ -16,7 +21,7 @@ MODULE_HDRS:=         $(CLASS_HDRS)
 
 MODULE_DHDR:=          
 
-EINCLUDE := HLT/BASE HLT/ITS HLT/MUON/src TPC ITS MUON STEER RAW
+EINCLUDE := HLT/BASE HLT/ITS HLT/ITS/tracking HLT/MUON/src TPC ITS MUON STEER RAW
 
 LIBRARY_DEP := -lHLTbase -lAliHLTUtil -lRAWDatarec -lRAWDatabase -lITSrec -lITSbase -lESD -lSTEER -lSTEERBase -L$(shell root-config --libdir) -lEG