LCOV - code coverage report
Current view: top level - HLT/ITS/tracking - AliITStrackerHLT.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 541 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 38 2.6 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : /* $Id: AliITStrackerHLT.cxx 32466 2009-05-20 07:51:56Z hristov $ */
      16             : 
      17             : //-------------------------------------------------------------------------
      18             : //               Implementation of the ITS tracker class
      19             : //    It reads AliITSRecPoint clusters and creates AliHLTITSTrack tracks
      20             : //                   and fills with them the ESD
      21             : //          Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch 
      22             : //          Current support and development: 
      23             : //                     Andrea Dainese, andrea.dainese@lnl.infn.it
      24             : //     dE/dx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
      25             : //     Params moved to AliITSRecoParam by: Andrea Dainese, INFN
      26             : //     Material budget from TGeo by: Ludovic Gaudichet & Andrea Dainese, INFN
      27             : //-------------------------------------------------------------------------
      28             : 
      29             : //#include <TMatrixD.h>
      30             : #include <TTree.h>
      31             : #include <TDatabasePDG.h>
      32             : #include <TString.h>
      33             : #include <TRandom.h>
      34             : #include <TTreeStream.h>
      35             : 
      36             : 
      37             : #include "AliLog.h"
      38             : #include "AliITSCalibrationSPD.h"
      39             : #include "AliITSCalibrationSDD.h"
      40             : #include "AliITSCalibrationSSD.h"
      41             : #include "AliCDBEntry.h"
      42             : #include "AliCDBManager.h"
      43             : #include "AliAlignObj.h"
      44             : #include "AliTrackPointArray.h"
      45             : #include "AliESDVertex.h"
      46             : #include "AliESDEvent.h"
      47             : #include "AliESDtrack.h"
      48             : #include "AliV0.h"
      49             : #include "AliHelix.h"
      50             : #include "AliITSChannelStatus.h"
      51             : #include "AliITSRecPoint.h"
      52             : #include "AliITSgeomTGeo.h"
      53             : #include "AliITSReconstructor.h"
      54             : #include "AliITSClusterParam.h"
      55             : #include "AliITSsegmentation.h"
      56             : #include "AliITSCalibration.h"
      57             : #include "AliITSV0Finder.h"
      58             : #include "AliITStrackerHLT.h"
      59             : #include "TStopwatch.h"
      60             : //#include "AliHLTTPCCATrackParam.h"
      61             : //#include "AliHLTVertexer.h"
      62             : #include <vector>
      63             : 
      64             : using std::vector;
      65           6 : ClassImp(AliITStrackerHLT)
      66             : 
      67             : Bool_t AliITStrackerHLT::CheckTrack( const AliExternalTrackParam *t )
      68             : {
      69             :   // Check that the track parameters are reasonable in order to avoid floating point exeptions in AliExternalTrackParam routines
      70             :   
      71             :   bool ok = 1;
      72           0 :   for( int i=0; i<5; i++ ) ok = ok && finite(t->GetParameter()[i]);
      73           0 :   for( int i=0; i<15; i++ ) ok = ok && finite(t->GetCovariance()[i]);
      74           0 :   ok = ok && ( TMath::Abs(t->GetX()) < 500. );
      75           0 :   ok = ok && ( TMath::Abs(t->GetY()) < 500. );
      76           0 :   ok = ok && ( TMath::Abs(t->GetZ()) < 500. );
      77           0 :   ok = ok && ( TMath::Abs(t->GetSnp()) < .99 );
      78           0 :   ok = ok && ( TMath::Abs(t->GetSigned1Pt()) < 1./0.01 );
      79           0 :   return ok;
      80             : }
      81             : 
      82             : Bool_t AliITStrackerHLT::TransportToX( AliExternalTrackParam *t, double x ) const
      83             : {
      84           0 :   return CheckTrack(t) && t->PropagateTo( x, t->GetBz() );
      85             : }
      86             : 
      87             : Bool_t AliITStrackerHLT::TransportToPhiX( AliExternalTrackParam *t, double phi, double x ) const
      88             : {
      89           0 :   return CheckTrack(t) && t->Propagate( phi, x, t->GetBz() );
      90             : }
      91             : 
      92             : 
      93             : 
      94             : AliITStrackerHLT::AliITStrackerHLT()
      95           0 :   :AliTracker(),
      96           0 :    fRecoParam(0),
      97           0 :    fLayers(new AliHLTITSLayer[AliITSgeomTGeo::kNLayers]),
      98           0 :    fUseTGeo(2),
      99           0 :    fxOverX0Pipe(-1.),
     100           0 :    fxTimesRhoPipe(-1.), 
     101           0 :    fTracks(0),
     102           0 :    fITSOutTracks(0),
     103           0 :    fNTracks(0),
     104           0 :    fNITSOutTracks(0),
     105           0 :    fLoadTime(0),
     106           0 :    fRecoTime(0),
     107           0 :    fNEvents(0),
     108           0 :    fClusters(0),
     109           0 :    fNClusters(0)
     110           0 : {
     111             :   //Default constructor
     112             :   Int_t i;
     113           0 :   for(i=0;i<4;i++) fSPDdetzcentre[i]=0.;
     114           0 :   for(i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;}
     115           0 :   for(i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;}
     116           0 : }
     117             : //------------------------------------------------------------------------
     118             : AliITStrackerHLT::AliITStrackerHLT(const Char_t *geom) 
     119           0 : : AliTracker(),
     120           0 :   fRecoParam(0),
     121           0 :   fLayers(new AliHLTITSLayer[AliITSgeomTGeo::kNLayers]),  
     122           0 :   fUseTGeo(2),
     123           0 :   fxOverX0Pipe(-1.),
     124           0 :   fxTimesRhoPipe(-1.),
     125           0 :   fTracks(0),
     126           0 :   fITSOutTracks(0),
     127           0 :   fNTracks(0),
     128           0 :   fNITSOutTracks(0),
     129           0 :   fLoadTime(0),
     130           0 :    fRecoTime(0),
     131           0 :   fNEvents(0),
     132           0 :   fClusters(0),
     133           0 :   fNClusters(0)
     134           0 : {
     135             :   //--------------------------------------------------------------------
     136             :   //This is the AliITStrackerHLT constructor
     137             :   //--------------------------------------------------------------------
     138           0 :   if (geom) {
     139           0 :     AliWarning("\"geom\" is actually a dummy argument !");
     140             :   }
     141             : 
     142           0 :   if(AliGeomManager::GetGeometry()==NULL){
     143           0 :     AliGeomManager::LoadGeometry();
     144             :   }
     145             : 
     146           0 :   fRecoParam = AliITSReconstructor::GetRecoParam();
     147           0 :   if( !fRecoParam ){
     148           0 :     AliITSReconstructor *tmp = new AliITSReconstructor();
     149           0 :     tmp->Init();
     150           0 :     fRecoParam = AliITSRecoParam::GetLowFluxParam();
     151           0 :     tmp->AliReconstructor::SetRecoParam(fRecoParam);
     152           0 :   }
     153           0 :   for (Int_t i=1; i<AliITSgeomTGeo::GetNLayers()+1; i++) {
     154           0 :     Int_t nlad=AliITSgeomTGeo::GetNLadders(i);
     155           0 :     Int_t ndet=AliITSgeomTGeo::GetNDetectors(i);
     156             : 
     157           0 :     Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2];
     158           0 :     AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz); 
     159           0 :     Double_t poff=TMath::ATan2(y,x);
     160           0 :     Double_t zoff=z;
     161           0 :     Double_t r=TMath::Sqrt(x*x + y*y);
     162             : 
     163           0 :     AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz);
     164           0 :     r += TMath::Sqrt(x*x + y*y);
     165           0 :     AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz);
     166           0 :     r += TMath::Sqrt(x*x + y*y);
     167           0 :     AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz);
     168           0 :     r += TMath::Sqrt(x*x + y*y);
     169           0 :     r*=0.25;
     170             : 
     171           0 :     new (fLayers+i-1) AliHLTITSLayer(r,poff,zoff,nlad,ndet);
     172             : 
     173           0 :     for (Int_t j=1; j<nlad+1; j++) {
     174           0 :       for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
     175           0 :         TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
     176           0 :         const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
     177           0 :         m.Multiply(tm);
     178           0 :         Double_t txyz[3]={0.};
     179           0 :         xyz[0]=0.;xyz[1]=0.;xyz[2]=0.;
     180           0 :         m.LocalToMaster(txyz,xyz);
     181           0 :         r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
     182           0 :         Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
     183             : 
     184           0 :         if (phi<0) phi+=TMath::TwoPi();
     185           0 :         else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
     186             : 
     187           0 :         AliHLTITSDetector &det=fLayers[i-1].GetDetector((j-1)*ndet + k-1); 
     188           0 :         new(&det) AliHLTITSDetector(r,phi); 
     189             :         // compute the real radius (with misalignment)
     190           0 :         TGeoHMatrix mmisal(*(AliITSgeomTGeo::GetMatrix(i,j,k)));
     191           0 :         mmisal.Multiply(tm);
     192           0 :         xyz[0]=0.;xyz[1]=0.;xyz[2]=0.;
     193           0 :         mmisal.LocalToMaster(txyz,xyz);
     194           0 :         Double_t rmisal=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
     195           0 :         det.SetRmisal(rmisal);
     196             :         
     197           0 :       } // end loop on detectors
     198             :     } // end loop on ladders
     199           0 :   } // end loop on layers
     200             : 
     201             :   
     202           0 :   Double_t xyzVtx[]={ fRecoParam->GetXVdef(),
     203           0 :                       fRecoParam->GetYVdef(),
     204           0 :                       fRecoParam->GetZVdef()}; 
     205           0 :   Double_t ersVtx[]={ fRecoParam->GetSigmaXVdef(),
     206           0 :                       fRecoParam->GetSigmaYVdef(),
     207           0 :                       fRecoParam->GetSigmaZVdef()}; 
     208             : 
     209           0 :   SetVertex(xyzVtx,ersVtx);
     210             : 
     211             :   // store positions of centre of SPD modules (in z)
     212           0 :   Double_t tr[3];
     213           0 :   AliITSgeomTGeo::GetTranslation(1,1,1,tr);
     214           0 :   fSPDdetzcentre[0] = tr[2];
     215           0 :   AliITSgeomTGeo::GetTranslation(1,1,2,tr);
     216           0 :   fSPDdetzcentre[1] = tr[2];
     217           0 :   AliITSgeomTGeo::GetTranslation(1,1,3,tr);
     218           0 :   fSPDdetzcentre[2] = tr[2];
     219           0 :   AliITSgeomTGeo::GetTranslation(1,1,4,tr);
     220           0 :   fSPDdetzcentre[3] = tr[2];
     221             : 
     222             :   //fUseTGeo = fRecoParam->GetUseTGeoInTracker();
     223             :   //if(fRecoParam->GetExtendedEtaAcceptance() && fUseTGeo!=1 && fUseTGeo!=3) {
     224             :   //AliWarning("fUseTGeo changed to 3 because fExtendedEtaAcceptance is kTRUE");
     225             :   //fUseTGeo = 3;
     226             :   //}
     227             : 
     228           0 :   for(Int_t i=0;i<2;i++) {fxOverX0Shield[i]=-1.;fxTimesRhoShield[i]=-1.;}
     229           0 :   for(Int_t i=0;i<6;i++) {fxOverX0Layer[i]=-1.;fxTimesRhoLayer[i]=-1.;}
     230             :   
     231           0 :   Init();
     232           0 : }
     233             : //------------------------------------------------------------------------
     234             : AliITStrackerHLT::AliITStrackerHLT(const AliITStrackerHLT &tracker)
     235           0 : :AliTracker(tracker),
     236           0 :  fRecoParam( tracker.fRecoParam),
     237           0 :  fLayers(new AliHLTITSLayer[AliITSgeomTGeo::kNLayers]), 
     238           0 :  fUseTGeo(tracker.fUseTGeo),
     239           0 :  fxOverX0Pipe(tracker.fxOverX0Pipe),
     240           0 :  fxTimesRhoPipe(tracker.fxTimesRhoPipe), 
     241           0 :  fTracks(0),
     242           0 :  fITSOutTracks(0),
     243           0 :  fNTracks(0),
     244           0 :  fNITSOutTracks(0),
     245           0 :   fLoadTime(0),
     246           0 :    fRecoTime(0),
     247           0 :  fNEvents(0),
     248           0 :  fClusters(0),
     249           0 :  fNClusters(0)
     250           0 : {
     251             :   //Copy constructor
     252             :   Int_t i;
     253           0 :   for(i=0;i<4;i++) {
     254           0 :     fSPDdetzcentre[i]=tracker.fSPDdetzcentre[i];
     255             :   }
     256           0 :   for(i=0;i<6;i++) {
     257           0 :     fxOverX0Layer[i]=tracker.fxOverX0Layer[i];
     258           0 :     fxTimesRhoLayer[i]=tracker.fxTimesRhoLayer[i];
     259             :   }
     260           0 :   for(i=0;i<2;i++) {
     261           0 :     fxOverX0Shield[i]=tracker.fxOverX0Shield[i];
     262           0 :     fxTimesRhoShield[i]=tracker.fxTimesRhoShield[i];
     263             :   }
     264           0 :   Init();
     265           0 : }
     266             : //------------------------------------------------------------------------
     267             : AliITStrackerHLT & AliITStrackerHLT::operator=(const AliITStrackerHLT &tracker){
     268             :   //Assignment operator
     269           0 :   this->~AliITStrackerHLT();
     270           0 :   new(this) AliITStrackerHLT(tracker);
     271           0 :   return *this;
     272           0 : }
     273             : //------------------------------------------------------------------------
     274             : AliITStrackerHLT::~AliITStrackerHLT()
     275           0 : {
     276             :   //
     277             :   //destructor
     278             :   //
     279           0 :   delete[] fLayers;
     280           0 :   delete[] fTracks;
     281           0 :   delete[] fITSOutTracks;
     282           0 :   delete[] fClusters;
     283           0 : }
     284             : 
     285             : void AliITStrackerHLT::Init()
     286             : {
     287           0 :   BuildMaterialLUT("Layers");  
     288           0 :   BuildMaterialLUT("Pipe");  
     289           0 :   BuildMaterialLUT("Shields");  
     290           0 : }
     291             : 
     292             : 
     293             : void AliITStrackerHLT::StartLoadClusters( Int_t NOfClusters )
     294             : {
     295             :   // !
     296           0 :   delete[] fClusters;
     297           0 :   fClusters = new AliITSRecPoint[NOfClusters];
     298           0 :   fNClusters = 0;
     299           0 : }
     300             : 
     301             : void AliITStrackerHLT::LoadCluster( const AliITSRecPoint &cluster) 
     302             : {
     303           0 :   fClusters[fNClusters++] = cluster ;
     304           0 : }
     305             : 
     306             : 
     307             : 
     308             : //------------------------------------------------------------------------
     309             : Int_t AliITStrackerHLT::LoadClusters(TTree *cTree) {
     310             :   //--------------------------------------------------------------------
     311             :   //This function loads ITS clusters
     312             :   //--------------------------------------------------------------------
     313             : 
     314             : 
     315           0 :   TBranch *branch=cTree->GetBranch("ITSRecPoints");
     316           0 :   if (!branch) { 
     317           0 :     Error("LoadClusters"," can't get the branch !\n");
     318           0 :     return 1;
     319             :   }
     320             : 
     321           0 :   static TClonesArray dummy("AliITSRecPoint",10000), *clusters=&dummy;
     322           0 :   branch->SetAddress(&clusters);
     323             : 
     324             :   int nClustersTotal = 0;
     325             :   {
     326             :     Int_t j=0;
     327           0 :     for (int i=0; i<AliITSgeomTGeo::GetNLayers(); i++) {
     328           0 :       int ndet=fLayers[i].GetNdetectors();
     329           0 :       Int_t jmax = j + fLayers[i].GetNladders()*ndet;
     330           0 :       for (; j<jmax; j++) {           
     331           0 :         if (!cTree->GetEvent(j)) continue;
     332           0 :         nClustersTotal+=clusters->GetEntriesFast();      
     333           0 :         clusters->Delete();
     334           0 :       }
     335             :     }
     336             :   }
     337           0 :   StartLoadClusters(nClustersTotal);
     338             :   {
     339             :     Int_t j=0;
     340           0 :     for (int i=0; i<AliITSgeomTGeo::GetNLayers(); i++) {
     341           0 :       int ndet=fLayers[i].GetNdetectors();
     342           0 :       Int_t jmax = j + fLayers[i].GetNladders()*ndet;
     343           0 :       for (; j<jmax; j++) {           
     344           0 :         if (!cTree->GetEvent(j)) continue;
     345           0 :         Int_t ncl=clusters->GetEntriesFast(); 
     346           0 :         while (ncl--) {
     347           0 :           LoadCluster( *( (AliITSRecPoint*)clusters->UncheckedAt(ncl)));
     348             :         }
     349           0 :         clusters->Delete();
     350           0 :       }
     351             :     }
     352             :   }
     353             : 
     354           0 :   dummy.Clear();
     355             : 
     356             :   return 0;
     357           0 : }
     358             : 
     359             : //------------------------------------------------------------------------
     360             : void AliITStrackerHLT::UnloadClusters() {
     361             :   //--------------------------------------------------------------------
     362             :   //This function unloads ITS clusters
     363             :   //--------------------------------------------------------------------
     364           0 :   for (Int_t i=0; i<AliITSgeomTGeo::GetNLayers(); i++) fLayers[i].ResetClusters();
     365           0 :   delete[] fClusters;
     366           0 :   fClusters = 0;
     367           0 :   fNClusters=0;
     368           0 : }
     369             : 
     370             : 
     371             : 
     372             : 
     373             : void AliITStrackerHLT::Reconstruct( AliExternalTrackParam *tracksTPC, int *tracksTPCLab, int nTPCTracks )
     374             : {
     375             : 
     376             :   //--------------------------------------------------------------------
     377             :   // This functions reconstructs ITS tracks
     378             :   //--------------------------------------------------------------------
     379             : 
     380           0 :   fNEvents++;
     381             : 
     382             :   // Init clusters
     383             :  
     384           0 :   TStopwatch timerInit;
     385             : 
     386           0 :   for( int i=0; i<AliITSgeomTGeo::GetNLayers(); i++ ){ 
     387           0 :     fLayers[i].ResetClusters();
     388             :   }
     389             : 
     390           0 :   for( int icl=0; icl<fNClusters; icl++ ){   
     391           0 :     AliITSRecPoint &cl = fClusters[icl];
     392           0 :     if (!cl.Misalign()) AliWarning("Can't misalign this cluster !"); 
     393           0 :     fLayers[cl.GetLayer()].InsertCluster(&cl); 
     394             :   }
     395             : 
     396           0 :   for( int i=0; i<AliITSgeomTGeo::GetNLayers(); i++ ){ 
     397           0 :     fLayers[i].ResetRoad(); //road defined by the cluster density
     398           0 :     fLayers[i].SortClusters();
     399             :   }  
     400           0 :   timerInit.Stop();
     401           0 :   fLoadTime+=timerInit.RealTime();
     402             : 
     403             : 
     404           0 :   TStopwatch timer;
     405             : 
     406           0 :   Double_t pimass = TDatabasePDG::Instance()->GetParticle(211)->Mass();
     407           0 :   delete[] fTracks;
     408           0 :   delete[] fITSOutTracks;
     409           0 :   fTracks = new AliHLTITSTrack[nTPCTracks];
     410           0 :   fITSOutTracks = new AliHLTITSTrack[nTPCTracks];
     411           0 :   fNTracks = 0;
     412           0 :   fNITSOutTracks = 0;
     413           0 :   for( int itr=0; itr<nTPCTracks; itr++ ){    
     414             : 
     415           0 :     AliHLTITSTrack tMI( tracksTPC[itr] );
     416             :     AliHLTITSTrack *t = &tMI;
     417           0 :     t->SetTPCtrackId( itr );
     418           0 :     t->SetMass(pimass); 
     419           0 :     t->SetExpQ(0);
     420           0 :     t->SetLabel(tracksTPCLab[itr]);
     421             : 
     422             :     //if (!CorrectForTPCtoITSDeadZoneMaterial(t))  continue;
     423             :       
     424           0 :     Int_t tpcLabel=t->GetLabel(); //save the TPC track label       
     425             :     
     426           0 :     FollowProlongationTree(t); 
     427             :     int nclu=0;
     428           0 :     for(Int_t i=0; i<6; i++) {
     429           0 :       if( t->GetClusterIndex(i)>=0 ) nclu++; 
     430             :     }
     431             :     //cout<<"N assigned ITS clusters = "<<nclu<<std::endl;
     432           0 :     t->SetLabel(-1);
     433           0 :     if( nclu>0 ){
     434           0 :       t->SetLabel(tpcLabel);
     435           0 :       t->SetFakeRatio(1.);
     436           0 :       CookLabel(t,.99); //For comparison only
     437             :       //cout<<"SG: label = "<<t->GetLabel()<<" / "<<tpcLabel<<endl;
     438             :     }
     439             : 
     440           0 :     CorrectForPipeMaterial(t);
     441             :    
     442           0 :     TransportToX(t, 0 );
     443           0 :     fTracks[fNTracks++] = *t;  
     444             :     //cout<<"SG: ITS: Bz = "<<t->GetBz()<<endl;
     445             : 
     446           0 :     if(  nclu>0 ){ // construct ITSOut track
     447           0 :       AliHLTITSTrack tOut(*t);
     448           0 :       if( FitOutward( &tOut ) ){
     449           0 :         fITSOutTracks[fNITSOutTracks++] = *t;  
     450             :       }
     451           0 :     }
     452           0 :   }
     453             : 
     454           0 :   timer.Stop();
     455           0 :   fRecoTime+=timer.RealTime();
     456           0 : }
     457             : 
     458             : 
     459             : 
     460             : //------------------------------------------------------------------------
     461             : Int_t AliITStrackerHLT::Clusters2Tracks(AliESDEvent *event) {
     462             :   //--------------------------------------------------------------------
     463             :   // This functions reconstructs ITS tracks
     464             :   // The clusters must be already loaded !
     465             :   //--------------------------------------------------------------------
     466             :   
     467             :   
     468           0 :   std::vector<AliExternalTrackParam> tracksTPC;
     469           0 :   std::vector<int> tracksTPCLab;
     470           0 :   tracksTPC.reserve(event->GetNumberOfTracks());
     471             : 
     472           0 :   for( int itr=0; itr<event->GetNumberOfTracks(); itr++ ){
     473             : 
     474           0 :     AliESDtrack *esdTrack = event->GetTrack(itr);
     475             :     //esdTrack->myITS = esdTrack->myTPC;
     476           0 :     if ((esdTrack->GetStatus()&AliESDtrack::kTPCin)==0) continue;
     477             :     //if (esdTrack->GetStatus()&AliESDtrack::kTPCout) continue;
     478           0 :     if (esdTrack->GetStatus()&AliESDtrack::kITSin) continue;
     479           0 :     if (esdTrack->GetKinkIndex(0)>0) continue;   //kink daughter
     480             :     
     481           0 :     AliHLTITSTrack t(*esdTrack);
     482           0 :     t.SetTPCtrackId( itr );
     483           0 :     tracksTPC.push_back( t );
     484           0 :     tracksTPCLab.push_back(esdTrack->GetLabel());
     485           0 :   }
     486             :   //for( int iter=0; iter<100; iter++){
     487           0 :   Reconstruct( &(tracksTPC[0]), &(tracksTPCLab[0]), tracksTPC.size() );
     488             :   //}
     489             : 
     490           0 :   for( int itr=0; itr<fNTracks; itr++ ){
     491           0 :     AliHLTITSTrack &t = fTracks[itr];    
     492           0 :     UpdateESDtrack(event->GetTrack(t.TPCtrackId()), &t, AliESDtrack::kITSin);          
     493             :     //event->GetTrack(t.TPCtrackId())->myITS = t;
     494             :   }
     495             :  
     496             : 
     497             :   //int hz = ( int ) ( (fRecoTime+fLoadTime) > 1.e-4 ? fNEvents / (fRecoTime+fLoadTime) : 0 );
     498             :   //int hz1 = ( int ) ( fRecoTime > 1.e-4 ? fNEvents / fRecoTime : 0 );
     499             :   //int hz2 = ( int ) ( fLoadTime > 1.e-4 ? fNEvents / fLoadTime : 0 );
     500             : 
     501             :   //std::cout<<"\n\nSG: ITS tracker time = "<<hz2<<" Hz load / "<<hz1<<" Hz reco ="
     502             :   //<<hz<<
     503             :   //" Hz ("
     504             :   //<<fLoadTime/fNEvents*1000<<"+"<<fRecoTime/fNEvents*1000.
     505             :   //<<" = "<<(fLoadTime + fRecoTime)/fNEvents*1000. 
     506             :   //<<" ms/ev), "<<fNEvents<<" events processed\n\n "<<std::endl;
     507             :   return 0;
     508           0 : }
     509             : 
     510             : 
     511             : AliCluster *AliITStrackerHLT::GetCluster(Int_t index) const 
     512             : {
     513             :   //       Return pointer to a given cluster
     514           0 :   Int_t l=(index & 0xf0000000) >> 28;
     515           0 :   Int_t c=(index & 0x0fffffff) >> 00;
     516           0 :   return fLayers[l].GetCluster(c);
     517             : }
     518             : 
     519             : 
     520             : 
     521             : 
     522             : //------------------------------------------------------------------------
     523             : void AliITStrackerHLT::FollowProlongationTree(AliHLTITSTrack * track ) 
     524             : {
     525             :   // FollowProlongationTree
     526           0 :   for (Int_t ilayer=5; ilayer>=0; ilayer--) {
     527             :    
     528           0 :     AliHLTITSLayer &layer=fLayers[ilayer];
     529             :   
     530             :     // material between SSD and SDD, SDD and SPD
     531             :     //if (ilayer==3 && !CorrectForShieldMaterial(track,1)) continue;
     532             :     //if (ilayer==1 && !CorrectForShieldMaterial(track,0)) continue;
     533             :     
     534             :     int idet;
     535             : 
     536             :     {            
     537           0 :       Double_t xloc, phi,z;
     538           0 :       if( !track->GetLocalXPhiZat( layer.GetR(), xloc, phi, z ) ) return;
     539           0 :       idet = layer.FindDetectorIndex(phi,z);
     540           0 :     }
     541             : 
     542             :     // track outside layer acceptance in z
     543             :    
     544           0 :     if( idet<0 ) continue;
     545             :     
     546             :     // propagate to the intersection with the detector plane     
     547             :     {
     548           0 :       const AliHLTITSDetector &det=layer.GetDetector( idet );
     549           0 :       if (!TransportToPhiX( track, det.GetPhi(), det.GetR() ) ) return;
     550           0 :       CorrectForLayerMaterial(track,ilayer);
     551           0 :     }
     552             : 
     553             :     // DEFINITION OF SEARCH ROAD AND CLUSTERS SELECTION
     554             :     
     555             :     // road in global (rphi,z) [i.e. in tracking ref. system]
     556             :     
     557           0 :     Double_t zmin,zmax,ymin,ymax;
     558             : 
     559           0 :     if (!ComputeRoad(track,ilayer,idet,zmin,zmax,ymin,ymax)) continue;
     560             :   
     561           0 :     layer.SelectClusters(zmin,zmax,ymin,ymax);     
     562             :     
     563             :     // Define criteria for track-cluster association
     564             :     
     565           0 :     Double_t msz = track->GetSigmaZ2() + 
     566           0 :       fRecoParam->GetNSigmaZLayerForRoadZ()*
     567           0 :       fRecoParam->GetNSigmaZLayerForRoadZ()*
     568           0 :       fRecoParam->GetSigmaZ2(ilayer);
     569             :     
     570           0 :     Double_t msy = track->GetSigmaY2() + 
     571           0 :       fRecoParam->GetNSigmaYLayerForRoadY()*
     572           0 :       fRecoParam->GetNSigmaYLayerForRoadY()*
     573           0 :       fRecoParam->GetSigmaY2(ilayer);
     574             :     
     575           0 :     msz *= fRecoParam->GetNSigma2RoadZNonC();
     576           0 :     msy *= fRecoParam->GetNSigma2RoadYNonC(); 
     577             :     
     578           0 :     msz = 1./msz; // 1/RoadZ^2
     579           0 :     msy = 1./msy; // 1/RoadY^2    
     580             :     
     581             :     const AliITSRecPoint *cl=0; 
     582           0 :     Int_t clidx=-1;     
     583             :     
     584             :     // loop over clusters in the road     
     585             :     
     586             :     const AliITSRecPoint *bestCluster=0; 
     587             :     double bestChi2 = 1.e10;
     588           0 :     AliHLTITSTrack bestTrack( *track );
     589             :     int bestIdx = -1;
     590             :      
     591           0 :     while( (cl=layer.GetNextCluster(clidx)) ){
     592           0 :       Int_t idetc=cl->GetDetectorIndex();
     593           0 :       if ( idet !=idetc ) { // new cluster's detector
     594           0 :         const AliHLTITSDetector &detc=layer.GetDetector(idetc);
     595           0 :         if (!TransportToPhiX( track, detc.GetPhi(),detc.GetR()) ) continue;
     596             :         idet = idetc;
     597           0 :       }  
     598             :       //double y,z;
     599             :       //if (! track->GetLocalYZat( layer.GetDetector(idetc).GetR() + cl->GetX(),y,z ) ) continue;
     600           0 :       double dz = track->GetZ() - cl->GetZ();
     601           0 :       double dy = track->GetY() - cl->GetY();
     602           0 :       double chi2 = dz*dz*msz + dy*dy*msy ;       
     603           0 :       if ( chi2 < bestChi2 ){
     604             :         bestChi2 = chi2;
     605             :         bestCluster = cl;
     606           0 :         bestTrack = *track;
     607           0 :         bestIdx = clidx;
     608           0 :         continue;
     609             :       }
     610           0 :     }
     611             :     
     612           0 :     if( !bestCluster || bestChi2 >2*10. ) continue;
     613             :     
     614           0 :     if (!TransportToX( &bestTrack, layer.GetDetector(bestCluster->GetDetectorIndex()).GetR() + bestCluster->GetX() ) ) continue;
     615             :     
     616           0 :     Double_t par[2]={ bestCluster->GetY(), bestCluster->GetZ()};
     617           0 :     Double_t cov[3]={ bestCluster->GetSigmaY2(), 0., bestCluster->GetSigmaZ2()};
     618           0 :     if( !bestTrack.AliExternalTrackParam::Update(par,cov) ) continue;
     619             :     
     620           0 :     *track = bestTrack;
     621           0 :     track->SetClusterIndex(track->GetNumberOfClusters(), (ilayer<<28)+bestIdx);
     622           0 :     track->SetNumberOfClusters(track->GetNumberOfClusters()+1);  
     623           0 :   }
     624           0 : }
     625             : 
     626             : 
     627             : 
     628             : Int_t AliITStrackerHLT::FitOutward(AliHLTITSTrack * track ) 
     629             : {
     630             :   // FitOutward
     631           0 :   track->ResetCovariance(100);
     632             : 
     633           0 :   for (Int_t iTrCl=track->GetNumberOfClusters()-1; iTrCl>=0; iTrCl--) {
     634             :     
     635           0 :     Int_t index = track->GetClusterIndex(iTrCl);
     636           0 :     Int_t ilayer=(index & 0xf0000000) >> 28;
     637           0 :     Int_t ic=(index & 0x0fffffff) >> 00;
     638           0 :     const AliHLTITSLayer &layer=fLayers[ilayer];
     639           0 :     AliITSRecPoint *cl = layer.GetCluster(ic); 
     640           0 :     int idet = cl->GetDetectorIndex();
     641           0 :     const AliHLTITSDetector &det=layer.GetDetector( idet );
     642             :  
     643             :     // material between SSD and SDD, SDD and SPD
     644             :     //if (ilayer==4 && !CorrectForShieldMaterial(track,1)) continue;
     645             :     //if (ilayer==2 && !CorrectForShieldMaterial(track,0)) continue;
     646             :     
     647             : 
     648             :     // propagate to the intersection with the detector plane     
     649             :     {
     650           0 :       if (!TransportToPhiX( track, det.GetPhi(), det.GetR()+ cl->GetX() ) ) return 0;
     651           0 :       CorrectForLayerMaterial(track,ilayer);
     652             :     }
     653             : 
     654           0 :     Double_t par[2]={ cl->GetY(), cl->GetZ()};
     655           0 :     Double_t cov[3]={ cl->GetSigmaY2(), 0., cl->GetSigmaZ2()};
     656           0 :     if( !track->AliExternalTrackParam::Update(par,cov) ) return 0;    
     657           0 :   }
     658           0 :   return 1;
     659           0 : }
     660             : 
     661             : 
     662             : //------------------------------------------------------------------------
     663             : AliHLTITSLayer & AliITStrackerHLT::GetLayer(Int_t layer) const
     664             : {
     665             :   //--------------------------------------------------------------------
     666             :   //
     667             :   //
     668           0 :   return fLayers[layer];
     669             : }
     670             : 
     671             : 
     672             : 
     673             : //------------------------------------------------------------------------
     674             : void AliITStrackerHLT::CookLabel(AliHLTITSTrack *track,Float_t wrong) const 
     675             : {
     676             :   // get MC label for the track
     677             : 
     678             :   Int_t mcLabel = -1;
     679             :   
     680           0 :   vector<int> labels;
     681           0 :   Int_t nClusters = track->GetNumberOfClusters();
     682             :   Int_t nClustersEff = 0;
     683           0 :   for (Int_t i=0; i<nClusters; i++){
     684           0 :     Int_t cindex = track->GetClusterIndex(i);
     685             :     //Int_t l=(cindex & 0xf0000000) >> 28;
     686           0 :     AliITSRecPoint *cl = (AliITSRecPoint*)GetCluster(cindex);    
     687           0 :     if ( cl->GetLabel(0) >= 0 ){ labels.push_back(cl->GetLabel(0)) ; nClustersEff++; }
     688           0 :     if ( cl->GetLabel(1) >= 0 ) labels.push_back(cl->GetLabel(1)) ;
     689           0 :     if ( cl->GetLabel(2) >= 0 ) labels.push_back(cl->GetLabel(2)) ;
     690             :   }
     691           0 :   std::sort( labels.begin(), labels.end() );
     692             : 
     693           0 :   labels.push_back( -1 ); // put -1 to the end    
     694             :   int labelMax = -1, labelCur = -1, nLabelsMax = 0, nLabelsCurr = 0;
     695             : 
     696           0 :   for ( unsigned int iLab = 0; iLab < labels.size(); iLab++ ) {
     697           0 :     if ( labels[iLab] != labelCur ) {         
     698           0 :       if ( labelCur >= 0 && nLabelsMax< nLabelsCurr ) {
     699             :         nLabelsMax = nLabelsCurr;
     700             :         labelMax = labelCur;
     701           0 :       }
     702           0 :       labelCur = labels[iLab];
     703             :       nLabelsCurr = 0;
     704           0 :     }
     705           0 :     nLabelsCurr++;
     706             :   }
     707             : 
     708           0 :   if( labelMax>=0 && nLabelsMax < wrong * nClustersEff ) labelMax = -labelMax;
     709             :   
     710             :   mcLabel = labelMax;
     711             :                 
     712           0 :   track->SetLabel( mcLabel );
     713           0 : }
     714             : 
     715             : 
     716             : 
     717             : 
     718             : 
     719             : 
     720             : 
     721             : 
     722             : 
     723             : //------------------------------------------------------------------------
     724             : void AliITStrackerHLT::UpdateESDtrack(AliESDtrack *tESD, AliHLTITSTrack* track, ULong_t flags) const
     725             : {
     726             :   //
     727             :   // Update ESD track
     728             :   //
     729           0 :   tESD->UpdateTrackParams(track,flags);
     730           0 :   AliHLTITSTrack * oldtrack = (AliHLTITSTrack*)(tESD->GetITStrack());
     731           0 :   if (oldtrack) delete oldtrack; 
     732           0 :   tESD->SetITStrack(new AliHLTITSTrack(*track));
     733           0 : }
     734             : 
     735             : 
     736             : 
     737             : 
     738             : //------------------------------------------------------------------------
     739             : void AliITStrackerHLT::BuildMaterialLUT(TString material) {
     740             :   //--------------------------------------------------------------------
     741             :   // Fill a look-up table with mean material
     742             :   //--------------------------------------------------------------------
     743             : 
     744             :   Int_t n=1000;
     745           0 :   Double_t mparam[7];
     746           0 :   Double_t point1[3],point2[3];
     747             :   Double_t phi,cosphi,sinphi,z;
     748             :   // 0-5 layers, 6 pipe, 7-8 shields 
     749           0 :   Double_t rmin[9]={ 3.5, 5.5,13.0,22.0,35.0,41.0, 2.0, 8.0,25.0};
     750           0 :   Double_t rmax[9]={ 5.5, 8.0,17.0,26.0,41.0,47.0, 3.0,10.5,30.0};
     751             : 
     752             :   Int_t ifirst=0,ilast=0;  
     753           0 :   if(material.Contains("Pipe")) {
     754             :     ifirst=6; ilast=6;
     755           0 :   } else if(material.Contains("Shields")) {
     756             :     ifirst=7; ilast=8;
     757           0 :   } else if(material.Contains("Layers")) {
     758             :     ifirst=0; ilast=5;
     759           0 :   } else {
     760           0 :     Error("BuildMaterialLUT","Wrong layer name\n");
     761             :   }
     762             : 
     763           0 :   for(Int_t imat=ifirst; imat<=ilast; imat++) {
     764           0 :     Double_t param[5]={0.,0.,0.,0.,0.};
     765           0 :     for (Int_t i=0; i<n; i++) {
     766           0 :       phi = 2.*TMath::Pi()*gRandom->Rndm();
     767           0 :       cosphi = TMath::Cos(phi); sinphi = TMath::Sin(phi); 
     768           0 :       z = 14.*(-1.+2.*gRandom->Rndm()); // SPD barrel
     769           0 :       point1[0] = rmin[imat]*cosphi;
     770           0 :       point1[1] = rmin[imat]*sinphi;
     771           0 :       point1[2] = z;
     772           0 :       point2[0] = rmax[imat]*cosphi;
     773           0 :       point2[1] = rmax[imat]*sinphi;
     774           0 :       point2[2] = z;
     775           0 :       AliTracker::MeanMaterialBudget(point1,point2,mparam);
     776           0 :       for(Int_t j=0;j<5;j++) param[j]+=mparam[j];
     777             :     }
     778           0 :     for(Int_t j=0;j<5;j++) param[j]/=(Float_t)n;
     779           0 :     if(imat<=5) {
     780           0 :       fxOverX0Layer[imat] = param[1];
     781           0 :       fxTimesRhoLayer[imat] = param[0]*param[4];
     782           0 :     } else if(imat==6) {
     783           0 :       fxOverX0Pipe = param[1];
     784           0 :       fxTimesRhoPipe = param[0]*param[4];
     785           0 :     } else if(imat==7) {
     786           0 :       fxOverX0Shield[0] = param[1];
     787           0 :       fxTimesRhoShield[0] = param[0]*param[4];
     788           0 :     } else if(imat==8) {
     789           0 :       fxOverX0Shield[1] = param[1];
     790           0 :       fxTimesRhoShield[1] = param[0]*param[4];
     791           0 :     }
     792           0 :   }
     793             :   /*
     794             :   printf("%s\n",material.Data());
     795             :   printf("%f  %f\n",fxOverX0Pipe,fxTimesRhoPipe);
     796             :   printf("%f  %f\n",fxOverX0Shield[0],fxTimesRhoShield[0]);
     797             :   printf("%f  %f\n",fxOverX0Shield[1],fxTimesRhoShield[1]);
     798             :   printf("%f  %f\n",fxOverX0Layer[0],fxTimesRhoLayer[0]);
     799             :   printf("%f  %f\n",fxOverX0Layer[1],fxTimesRhoLayer[1]);
     800             :   printf("%f  %f\n",fxOverX0Layer[2],fxTimesRhoLayer[2]);
     801             :   printf("%f  %f\n",fxOverX0Layer[3],fxTimesRhoLayer[3]);
     802             :   printf("%f  %f\n",fxOverX0Layer[4],fxTimesRhoLayer[4]);
     803             :   printf("%f  %f\n",fxOverX0Layer[5],fxTimesRhoLayer[5]);
     804             :   */
     805             :   return;
     806           0 : }
     807             : 
     808             : 
     809             : 
     810             : 
     811             : //------------------------------------------------------------------------
     812             : Int_t AliITStrackerHLT::CorrectForTPCtoITSDeadZoneMaterial(AliHLTITSTrack *t) {
     813             :   //--------------------------------------------------------------------
     814             :   // Correction for the material between the TPC and the ITS
     815             :   //--------------------------------------------------------------------
     816           0 :   if (t->GetX() > AliITSRecoParam::Getriw()) {   // inward direction 
     817           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getriw(),1)) return 0;// TPC inner wall
     818           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1)) return 0;// TPC central drum
     819           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1))  return 0;// ITS screen
     820           0 :   } else if (t->GetX() < AliITSRecoParam::Getrs()) {  // outward direction
     821           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getrs(),1))        return 0;// ITS screen
     822           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getrcd(),1))       return 0;// TPC central drum
     823           0 :       if (!t->PropagateToTGeo(AliITSRecoParam::Getriw()+0.001,1)) return 0;// TPC inner wall
     824             :   } else {
     825           0 :     printf("CorrectForTPCtoITSDeadZoneMaterial: Track is already in the dead zone !\n");
     826           0 :     return 0;
     827             :   }
     828             :   
     829           0 :   return 1;
     830           0 : }
     831             : 
     832             : 
     833             : //------------------------------------------------------------------------
     834             : Int_t AliITStrackerHLT::CorrectForPipeMaterial(AliHLTITSTrack *t,
     835             :                                                bool InwardDirection) {
     836             :   //-------------------------------------------------------------------
     837             :   // Propagate beyond beam pipe and correct for material
     838             :   // (material budget in different ways according to fUseTGeo value)
     839             :   // Add time if going outward (PropagateTo or PropagateToTGeo)
     840             :   //-------------------------------------------------------------------
     841             : 
     842             :   // Define budget mode:
     843             :   // 0: material from AliITSRecoParam (hard coded)
     844             :   // 1: material from TGeo in one step (on the fly)
     845             :   // 2: material from lut
     846             :   // 3: material from TGeo in one step (same for all hypotheses)
     847             :   Int_t mode;
     848           0 :   switch(fUseTGeo) {
     849             :   case 0:
     850             :     mode=0; 
     851           0 :     break;    
     852             :   case 1:
     853             :     mode=1;
     854           0 :     break;    
     855             :   case 2:
     856             :     mode=2;
     857           0 :     break;
     858             :   case 3:
     859             :     mode=3; 
     860           0 :     break;
     861             :   case 4:
     862             :     mode=3;
     863           0 :     break;
     864             :   default:
     865             :     mode=0;
     866           0 :     break;
     867             :   }
     868             :   
     869           0 :   Float_t  dir = (InwardDirection ? 1. : -1.);
     870           0 :   Double_t rToGo= ( InwardDirection ? AliITSRecoParam::GetrInsidePipe() : AliITSRecoParam::GetrOutsidePipe());
     871           0 :   Double_t xToGo, phi,z;
     872             : 
     873           0 :   if (!t->GetLocalXPhiZat(rToGo,xToGo,phi,z)) return 0;
     874             : 
     875           0 :   Double_t xOverX0,x0,lengthTimesMeanDensity;
     876             : 
     877           0 :   switch(mode) {
     878             :   case 0:
     879           0 :     xOverX0 = AliITSRecoParam::GetdPipe();
     880           0 :     x0 = AliITSRecoParam::GetX0Be();
     881           0 :     lengthTimesMeanDensity = xOverX0*x0;
     882           0 :     lengthTimesMeanDensity *= dir;
     883           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     884             :     break;
     885             :   case 1:
     886           0 :     if (!t->PropagateToTGeo(xToGo,1)) return 0;
     887             :     break;
     888             :   case 2:
     889           0 :     if(fxOverX0Pipe<0) BuildMaterialLUT("Pipe");  
     890           0 :     xOverX0 = fxOverX0Pipe;
     891           0 :     lengthTimesMeanDensity = fxTimesRhoPipe;
     892           0 :     lengthTimesMeanDensity *= dir;
     893           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     894             :     break;
     895             :   case 3:
     896             :     double xOverX0PipeTrks, xTimesRhoPipeTrks;
     897           0 :     if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0;
     898           0 :     Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/
     899           0 :                                ((1.-t->GetSnp())*(1.+t->GetSnp())));
     900           0 :     xOverX0PipeTrks = TMath::Abs(xOverX0)/angle;
     901           0 :     xTimesRhoPipeTrks = TMath::Abs(lengthTimesMeanDensity)/angle;
     902           0 :     xOverX0 = xOverX0PipeTrks;
     903             :     lengthTimesMeanDensity = xTimesRhoPipeTrks;
     904           0 :     lengthTimesMeanDensity *= dir;
     905           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     906           0 :     break;
     907             :   }
     908             :   
     909           0 :   return 1;
     910           0 : }
     911             : //------------------------------------------------------------------------
     912             : Int_t AliITStrackerHLT::CorrectForShieldMaterial(AliHLTITSTrack *t,
     913             :                                                  Int_t    shieldindex,
     914             :                                                 bool InwardDirection) {
     915             :   //-------------------------------------------------------------------
     916             :   // Propagate beyond SPD or SDD shield and correct for material
     917             :   // (material budget in different ways according to fUseTGeo value)
     918             :   // Add time if going outward (PropagateTo or PropagateToTGeo)
     919             :   //-------------------------------------------------------------------
     920             : 
     921             :   // Define budget mode:
     922             :   // 0: material from AliITSRecoParam (hard coded)
     923             :   // 1: material from TGeo in steps of X cm (on the fly)
     924             :   //    X = AliITSRecoParam::GetStepSizeTGeo()
     925             :   // 2: material from lut
     926             :   // 3: material from TGeo in one step (same for all hypotheses)
     927             :   Int_t mode;
     928           0 :   switch(fUseTGeo) {
     929             :   case 0:
     930             :     mode=0; 
     931           0 :     break;    
     932             :   case 1:
     933             :     mode=1;
     934           0 :     break;    
     935             :   case 2:
     936             :     mode=2;
     937           0 :     break;
     938             :   case 3:
     939             :     mode=3;
     940           0 :     break;
     941             :   case 4:
     942             :     mode=3;
     943           0 :     break;
     944             :   default:
     945             :     mode=0;
     946           0 :     break;
     947             :   }
     948             : 
     949             : 
     950           0 :   Float_t  dir = (InwardDirection ? 1. : -1.);
     951             :   Double_t rToGo;
     952             : 
     953           0 :   if (shieldindex==1 ) { // SDDouter
     954           0 :     rToGo=(InwardDirection ? AliITSRecoParam::GetrInsideShield(1) : AliITSRecoParam::GetrOutsideShield(1));
     955           0 :   } else if (shieldindex==0 ) {        // SPDouter
     956           0 :     rToGo=(InwardDirection ? AliITSRecoParam::GetrInsideShield(0) : AliITSRecoParam::GetrOutsideShield(0)); 
     957             :   } else {
     958           0 :     Error("CorrectForShieldMaterial"," Wrong shield name\n");
     959           0 :     return 0;
     960             :   }
     961           0 :   Double_t xToGo, phi,z;
     962             : 
     963           0 :   if (!t->GetLocalXPhiZat(rToGo,xToGo,phi,z)) return 0;
     964             : 
     965           0 :   Double_t xOverX0,x0,lengthTimesMeanDensity;
     966             :   Int_t nsteps=1;
     967             : 
     968           0 :   switch(mode) {
     969             :   case 0:
     970           0 :     xOverX0 = AliITSRecoParam::Getdshield(shieldindex);
     971           0 :     x0 = AliITSRecoParam::GetX0shield(shieldindex);
     972           0 :     lengthTimesMeanDensity = xOverX0*x0;
     973           0 :     lengthTimesMeanDensity *= dir;
     974           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     975             :     break;
     976             :   case 1:
     977           0 :     nsteps= (Int_t)(TMath::Abs(t->GetX()-xToGo)/fRecoParam->GetStepSizeTGeo())+1;
     978           0 :     if (!t->PropagateToTGeo(xToGo,nsteps)) return 0; // cross the material and apply correction
     979             :     break;
     980             :   case 2:
     981           0 :     if(fxOverX0Shield[shieldindex]<0) BuildMaterialLUT("Shields");  
     982           0 :     xOverX0 = fxOverX0Shield[shieldindex];
     983           0 :     lengthTimesMeanDensity = fxTimesRhoShield[shieldindex];
     984           0 :     lengthTimesMeanDensity *= dir;
     985           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     986             :     break;
     987             :   case 3:    
     988           0 :     if (!t->PropagateToTGeo(xToGo,1,xOverX0,lengthTimesMeanDensity)) return 0;
     989           0 :     Double_t angle=TMath::Sqrt((1.+t->GetTgl()*t->GetTgl())/
     990           0 :                                ((1.-t->GetSnp())*(1.+t->GetSnp())));
     991           0 :     double xOverX0ShieldTrks = TMath::Abs(xOverX0)/angle;
     992           0 :     double xTimesRhoShieldTrks = TMath::Abs(lengthTimesMeanDensity)/angle;
     993           0 :     xOverX0 = xOverX0ShieldTrks;
     994             :     lengthTimesMeanDensity = xTimesRhoShieldTrks;
     995           0 :     lengthTimesMeanDensity *= dir;
     996           0 :     if (!t->PropagateTo(xToGo,xOverX0,lengthTimesMeanDensity/xOverX0)) return 0;
     997           0 :     break;
     998             :   }
     999             : 
    1000           0 :   return 1;
    1001           0 : }
    1002             : //------------------------------------------------------------------------
    1003             : Int_t AliITStrackerHLT::CorrectForLayerMaterial(AliHLTITSTrack *t,
    1004             :                                                Int_t layerindex,
    1005             :                                                bool InwardDirection ){
    1006             :   //-------------------------------------------------------------------
    1007             :   // Propagate beyond layer and correct for material
    1008             :   // (material budget in different ways according to fUseTGeo value)
    1009             :   // Add time if going outward (PropagateTo or PropagateToTGeo)
    1010             :   //-------------------------------------------------------------------
    1011             : 
    1012             :   /*
    1013             :     Double_t r=fLayers[layerindex].GetR();
    1014             :     Double_t deltar=(layerindex<2 ? 0.10*r : 0.05*r);
    1015             :     Double_t rToGo=TMath::Sqrt(t->GetX()*t->GetX()+t->GetY()*t->GetY());
    1016             :     rToGo+= InwardDirection ?-deltar :deltar;
    1017             :     Double_t xToGo;
    1018             :     if (!t->GetLocalXat(rToGo,xToGo)) return 0;  
    1019             :   */
    1020             :   
    1021           0 :   if(fxOverX0Layer[layerindex]<0) BuildMaterialLUT("Layers");
    1022             : 
    1023           0 :   Double_t lengthTimesMeanDensity = fxTimesRhoLayer[layerindex];
    1024           0 :   if( !InwardDirection ) lengthTimesMeanDensity = -lengthTimesMeanDensity;
    1025             : 
    1026           0 :   return t->CorrectForMeanMaterial(fxOverX0Layer[layerindex],lengthTimesMeanDensity,kTRUE);
    1027           0 : }
    1028             : 
    1029             : 
    1030             : //------------------------------------------------------------------------
    1031             : Bool_t AliITStrackerHLT::LocalModuleCoord(Int_t ilayer,Int_t idet,
    1032             :                                        const AliHLTITSTrack *track,
    1033             :                                        Float_t &xloc,Float_t &zloc) const {
    1034             :   //-----------------------------------------------------------------
    1035             :   // Gives position of track in local module ref. frame
    1036             :   //-----------------------------------------------------------------
    1037             : 
    1038           0 :   xloc=0.; 
    1039           0 :   zloc=0.;
    1040             : 
    1041           0 :   if(idet<0) return kFALSE;
    1042             : 
    1043           0 :   Int_t ndet=AliITSgeomTGeo::GetNDetectors(ilayer+1); // layers from 1 to 6 
    1044             : 
    1045           0 :   Int_t lad = Int_t(idet/ndet) + 1;
    1046             : 
    1047           0 :   Int_t det = idet - (lad-1)*ndet + 1;
    1048             : 
    1049           0 :   Double_t xyzGlob[3],xyzLoc[3];
    1050             : 
    1051           0 :   AliHLTITSDetector &detector = fLayers[ilayer].GetDetector(idet);
    1052             :   // take into account the misalignment: xyz at real detector plane
    1053           0 :   if(!track->GetXYZAt(detector.GetRmisal(),GetBz(),xyzGlob)) return kFALSE;
    1054             : 
    1055           0 :   if(!AliITSgeomTGeo::GlobalToLocal(ilayer+1,lad,det,xyzGlob,xyzLoc)) return kFALSE;
    1056             : 
    1057           0 :   xloc = (Float_t)xyzLoc[0];
    1058           0 :   zloc = (Float_t)xyzLoc[2];
    1059             : 
    1060           0 :   return kTRUE;
    1061           0 : }
    1062             : 
    1063             : //------------------------------------------------------------------------
    1064             : 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 {
    1065             :   //--------------------------------------------------------------------
    1066             :   // This function computes the rectangular road for this track
    1067             :   //--------------------------------------------------------------------
    1068             : 
    1069             : 
    1070           0 :   AliHLTITSDetector &det = fLayers[ilayer].GetDetector(idet);
    1071             :   // take into account the misalignment: propagate track to misaligned detector plane
    1072             : 
    1073           0 :   double y,z,snp,cov[3];
    1074           0 :   if( !track->GetYZAtPhiX( det.GetPhi(),det.GetRmisal(), y, z, snp, cov))return 0;
    1075             : 
    1076             : 
    1077           0 :   Double_t dz=fRecoParam->GetNSigmaRoadZ()*
    1078           0 :                     TMath::Sqrt(cov[2] + 
    1079           0 :                                 fRecoParam->GetNSigmaZLayerForRoadZ()*
    1080           0 :                                 fRecoParam->GetNSigmaZLayerForRoadZ()*
    1081           0 :                                 fRecoParam->GetSigmaZ2(ilayer));
    1082           0 :   Double_t dy=fRecoParam->GetNSigmaRoadY()*
    1083           0 :                     TMath::Sqrt(cov[0] + 
    1084           0 :                                 fRecoParam->GetNSigmaYLayerForRoadY()*
    1085           0 :                                 fRecoParam->GetNSigmaYLayerForRoadY()*
    1086           0 :                                 fRecoParam->GetSigmaY2(ilayer));
    1087             :       
    1088             :   // track at boundary between detectors, enlarge road
    1089           0 :   Double_t boundaryWidth=AliITSRecoParam::GetBoundaryWidth();
    1090           0 :   if ( (y-dy < det.GetYmin()+boundaryWidth) || 
    1091           0 :        (y+dy > det.GetYmax()-boundaryWidth) || 
    1092           0 :        (z-dz < det.GetZmin()+boundaryWidth) ||
    1093           0 :        (z+dz > det.GetZmax()-boundaryWidth) ) {
    1094           0 :     Float_t tgl = TMath::Abs(track->GetTgl());
    1095           0 :     if (tgl > 1.) tgl=1.;
    1096           0 :     Double_t deltaXNeighbDets=AliITSRecoParam::GetDeltaXNeighbDets();
    1097           0 :     dz = TMath::Sqrt(dz*dz+deltaXNeighbDets*deltaXNeighbDets*tgl*tgl);
    1098           0 :     if (snp > fRecoParam->GetMaxSnp()) return kFALSE;
    1099           0 :     dy = TMath::Sqrt(dy*dy+deltaXNeighbDets*deltaXNeighbDets*snp*snp);
    1100           0 :   } // boundary
    1101             :   
    1102             :   // add to the road a term (up to 2-3 mm) to deal with misalignments
    1103           0 :   dy = TMath::Sqrt(dy*dy + fRecoParam->GetRoadMisal()*fRecoParam->GetRoadMisal());
    1104           0 :   dz = TMath::Sqrt(dz*dz + fRecoParam->GetRoadMisal()*fRecoParam->GetRoadMisal());
    1105             : 
    1106           0 :   Double_t r = fLayers[ilayer].GetR();
    1107           0 :   zmin = z - dz; 
    1108           0 :   zmax = z + dz;
    1109           0 :   ymin = y + r*det.GetPhi() - dy;
    1110           0 :   ymax = y + r*det.GetPhi() + dy;
    1111             : 
    1112             :   return kTRUE;
    1113           0 : }
    1114             : 
    1115             : 
    1116             : 
    1117             : Int_t AliITStrackerHLT::PropagateBack(AliESDEvent * /*event*/) 
    1118             : {
    1119             :   // dummy
    1120           0 :   return 0;
    1121             : }
    1122             : 
    1123             : Int_t AliITStrackerHLT::RefitInward(AliESDEvent * /*event*/ ) 
    1124             : {
    1125             :   // dummy
    1126           0 :   return 0;
    1127             : }
    1128             : 
    1129             : 
    1130             : Bool_t AliITStrackerHLT::GetTrackPoint(Int_t /*index*/, AliTrackPoint& /*p*/) const 
    1131             : {
    1132             :   // dummy
    1133           0 :   return 0;
    1134             : }
    1135             : 
    1136             : Bool_t AliITStrackerHLT::GetTrackPointTrackingError(Int_t /*index*/, 
    1137             :                                                     AliTrackPoint& /*p*/, const AliESDtrack */*t*/) 
    1138             : {
    1139             :   // dummy
    1140           0 :   return 0;
    1141             : }

Generated by: LCOV version 1.11