// @(#) $Id$ //*************************************************************************** // This file is property of and copyright by the ALICE HLT Project * // ALICE Experiment at CERN, All rights reserved. * // * // Primary Authors: Sergey Gorbunov * // Ivan Kisel * // 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 "AliHLTTPCCATracker.h" #include "AliHLTTPCCAHit.h" #include "AliHLTTPCCACell.h" #include "AliHLTTPCCAEndPoint.h" #include "AliHLTTPCCAOutTrack.h" #include "AliHLTTPCCAGrid.h" #include "AliHLTTPCCARow.h" #include "AliHLTTPCCATrack.h" #include "TMath.h" #include "Riostream.h" //#include #include "TStopwatch.h" //#define DRAW #ifdef DRAW #include "AliHLTTPCCADisplay.h" #include "TApplication.h" #endif //DRAW ClassImp(AliHLTTPCCATracker) AliHLTTPCCATracker::AliHLTTPCCATracker() :fParam(),fRows(0),fOutTrackHits(0),fNOutTrackHits(0),fOutTracks(0),fNOutTracks(0),fNHitsTotal(0),fTracks(0),fNTracks(0),fCellHitPointers(0),fCells(0),fEndPoints(0) { // constructor fRows = new AliHLTTPCCARow[fParam.NRows()]; Initialize( fParam ); } AliHLTTPCCATracker::AliHLTTPCCATracker( const AliHLTTPCCATracker& ) :fParam(),fRows(0),fOutTrackHits(0),fNOutTrackHits(0),fOutTracks(0),fNOutTracks(0),fNHitsTotal(0),fTracks(0),fNTracks(0),fCellHitPointers(0),fCells(0),fEndPoints(0) { // dummy } AliHLTTPCCATracker &AliHLTTPCCATracker::operator=( const AliHLTTPCCATracker& ) { // dummy fRows=0; fOutTrackHits=0; fOutTracks=0; fNOutTracks=0; return *this; } AliHLTTPCCATracker::~AliHLTTPCCATracker() { // destructor StartEvent(); delete[] fRows; } // ---------------------------------------------------------------------------------- void AliHLTTPCCATracker::Initialize( AliHLTTPCCAParam ¶m ) { // initialosation StartEvent(); delete[] fRows; fRows = 0; fParam = param; fParam.Update(); fRows = new AliHLTTPCCARow[fParam.NRows()]; Float_t xStep = 1; Float_t deltaY = TMath::Tan(fParam.CellConnectionAngleXY()); Float_t deltaZ = TMath::Tan(fParam.CellConnectionAngleXZ()); for( Int_t irow=0; irow ymax ) continue; if( cont1.Zmax < zmin ) break;// in the grid cell hit Y is decreasing if( cont1.Zmin > zmax ) continue; if( cont1.Ymin < ymin ){ ymin = cont1.Ymin; repeat = 1; } if( cont1.Ymax > ymax ){ ymax = cont1.Ymax; repeat = 1; } if( cont1.Zmin < zmin ){ zmin = cont1.Zmin; repeat = 1; } if( cont1.Zmax > zmax ){ zmax = cont1.Zmax; repeat = 1; } if( cont1.binYmin < binYmin ){ binYmin = cont1.binYmin; repeat = 1; } if( cont1.binYmax > binYmax ){ binYmax = cont1.binYmax; repeat = 1; } if( cont1.binZmin < binZmin ){ binZmin = cont1.binZmin; repeat = 1; } if( cont1.binZmax > binZmax ){ binZmax = cont1.binZmax; repeat = 1; } row.CellHitPointers()[nPointers++] = jh; cell.NHits()++; cont1.used = 1; #ifdef DRAW //AliHLTTPCCADisplay::Instance().DrawHit( irow, jh, kRed ); //AliHLTTPCCADisplay::Instance().Ask(); #endif } } } } cell.Y() = .5*(ymin+ymax); cell.Z() = .5*(zmin+zmax); cell.ErrY() = .5*( ymax - ymin - 2*deltaY)/3.5; cell.ErrZ() = .5*( zmax - zmin -2*deltaZ)/3.5; cell.ZMin() = zmin; cell.ZMax() = zmax; #ifdef DRAW //AliHLTTPCCADisplay::Instance().DrawCell( irow, nCells-1 ); //AliHLTTPCCADisplay::Instance().Ask(); #endif } //cout<=fParam.NRows() ) lastRow2 = fParam.NRows()-1; for (Int_t i1 = 0; i1 yMax ) continue; if( y2Max < yMin ) continue; if( z2Min > zMax ) break; if( z2Max < zMin ) continue; // c1 & c2 are neighbours found = 1; if( c1.Link() ==-1 && c2.Status()==0 ){ // one-to-one connection - OK c1.Link() = IRowICell2ID(iRow2,i2); c2.Status() = 1; }else{ // multi-connection - break all links if( c1.Link()>=0 ) ID2Cell(c1.Link()).Status() = -1; c1.Link() = -2; c2.Status() = -1; } } }//row2 } }//row1 timer.Stop(); fTimers[1] = timer.CpuTime(); // Second step: create tracks // for each sequence of neighbouring Cells create Track object // // Final state: // cell.Track = TrackNumber for first and last track cell // = -1 for other cells // cell.Link = Neighbour ID, if there is a neighbour // = -1, if no neighbour (last cell on the track ) // cell.Link1 = backward neighbour ID, if there is a neighbour // = -1 for first and last track cells TStopwatch timer2; fTracks = new AliHLTTPCCATrack[nStartCells]; fNTracks = 0; for( Int_t iRow=0; iRow0 ) continue; // not a starting cell Int_t firstID = IRowICell2ID( iRow, iCell ); Int_t midID = firstID; Int_t lastID = firstID; AliHLTTPCCATrack &track = fTracks[fNTracks]; track.Alive() = 1; track.NCells() = 1; AliHLTTPCCACell *last = &c; while( last->Link() >=0 ){ Int_t nextID = last->Link(); AliHLTTPCCACell *next = & ID2Cell(nextID); if(next->Status()!=1 ){ last->Link() = -1; break; } track.NCells()++; last = next; lastID = nextID; } Int_t nCells05 = (track.NCells()-1)/2; for( Int_t i=0; iTrackID() = fNTracks; track.FirstCellID() = firstID; track.CellID()[0] = firstID; track.CellID()[1] = midID; track.CellID()[2] = lastID; track.PointID()[0] = -1; track.PointID()[1] = -1; //cout<<"Track N "<0 ){ AliHLTTPCCADisplay::Instance().Ask(); } AliHLTTPCCADisplay::Instance().ClearView(); AliHLTTPCCADisplay::Instance().DrawSlice( this ); for( Int_t iRow=0; iRow0 ) AliHLTTPCCADisplay::Instance().Ask(); #endif TStopwatch timer4; Bool_t doMerging=1;//SG!!! Float_t factor2 = fParam.TrackConnectionFactor()*fParam.TrackConnectionFactor(); Int_t *refEndPoints = new Int_t[fNHitsTotal]; Int_t nRefEndPoints = 0; for( Int_t iRow=0; iRow("<("<=0 && jc.Link()>=0 ){ Int_t currID = jTrack.CellID()[0]; jTrack.CellID()[0] = jTrack.CellID()[2]; jTrack.CellID()[2] = currID; Int_t pID = jTrack.PointID()[0]; jTrack.PointID()[0] = jTrack.PointID()[1]; jTrack.PointID()[1] = pID; currID = jTrack.FirstCellID(); Int_t lastID = -1; while( currID>=0 ){ AliHLTTPCCACell &c = ID2Cell( currID ); Int_t nextID = c.Link(); c.Link() = lastID; lastID = currID; currID = nextID; } jTrack.FirstCellID() = lastID; } //cout<<"track i "<jTrack ic.Link() = jcID; iTrack.PointID()[1] = jTrack.PointID()[1]; ID2Point(iTrack.PointID()[1]).TrackID() = itr; if( jTrack.NCells()<3 ){ refEndPoints[nRefEndPointsNew++] = iTrack.PointID()[1]; doMerging = 1; ID2Point(iTrack.PointID()[1]).Param() = ip.Param();// just to set phi direction } if( iTrack.NCells()<3 ){ refEndPoints[nRefEndPointsNew++] = iTrack.PointID()[0]; doMerging = 1; ID2Point(iTrack.PointID()[0]).Param() = jp.Param();// just to set phi direction } if( TMath::Abs(ID2Cell(jTrack.CellID()[2]).Z()-ID2Cell(iTrack.CellID()[0]).Z())> TMath::Abs(ID2Cell(iTrack.CellID()[2]).Z()-ID2Cell(iTrack.CellID()[0]).Z()) ){ iTrack.CellID()[2] = jTrack.CellID()[2]; } }else{ //match jTrack->iTrack jc.Link() = icID; iTrack.FirstCellID()=jTrack.FirstCellID(); iTrack.PointID()[0] = jTrack.PointID()[0]; ID2Point(iTrack.PointID()[0]).TrackID() = itr; if( jTrack.NCells()<3 ){ refEndPoints[nRefEndPointsNew++] = iTrack.PointID()[0]; doMerging = 1; ID2Point(iTrack.PointID()[0]).Param() = ip.Param(); // just to set phi direction } if( iTrack.NCells()<3 ){ refEndPoints[nRefEndPointsNew++] = iTrack.PointID()[1]; doMerging = 1; ID2Point(iTrack.PointID()[1]).Param() = jp.Param();// just to set phi direction } if( TMath::Abs(ID2Cell(jTrack.CellID()[0]).Z()-ID2Cell(iTrack.CellID()[2]).Z())> TMath::Abs(ID2Cell(iTrack.CellID()[0]).Z()-ID2Cell(iTrack.CellID()[2]).Z()) ){ iTrack.CellID()[0] = jTrack.CellID()[0]; } } //cout<<"merged ID: "<iTrack.NCells() ){ iTrack.CellID()[1] = jTrack.CellID()[1]; } AliHLTTPCCAEndPoint &p0 = ID2Point(iTrack.PointID()[0]); AliHLTTPCCAEndPoint &p1 = ID2Point(iTrack.PointID()[1]); if( p0.Link() == iTrack.PointID()[1] ){ p0.Link() = -1; p1.Link() = -1; } //cout<<" NCells itr/jtr= "<0 ) AliHLTTPCCADisplay::Instance().Ask(); #endif #ifdef DRAWXX AliHLTTPCCADisplay::Instance().ClearView(); AliHLTTPCCADisplay::Instance().DrawSlice( this ); for( Int_t iRow=0; iRowLink()>=0; iID = ic->Link(), ic = &ID2Cell(iID) ){ //cout<<"itr="<NHits(); iHit++ ){ AliHLTTPCCAHit &h = row.GetCellHit(*ic,iHit); // check for wrong hits { Float_t ddy = t0.GetY() - h.Y(); Float_t ddz = t0.GetZ() - h.Z(); Float_t dd = ddy*ddy+ddz*ddz; if( dd 3.5*3.5*(/*t0.GetErr2Y() + */h.ErrY()*h.ErrY() ) ) continue;//SG!!! //if( dz*dz > 3.5*3.5*(/*t0.GetErr2Z() + */h.ErrZ()*h.ErrZ() ) ) continue; //if( !t0.Filter2( h.Y(), h.Z(), h.ErrY()*h.ErrY(), h.ErrZ()*h.ErrZ() ) ) continue; if( !t.TransportToX( row.X() ) ) continue; //* Update the track if( first ){ t.Cov()[ 0] = .5*.5; t.Cov()[ 1] = 0; t.Cov()[ 2] = .5*.5; t.Cov()[ 3] = 0; t.Cov()[ 4] = 0; t.Cov()[ 5] = .2*.2; t.Cov()[ 6] = 0; t.Cov()[ 7] = 0; t.Cov()[ 8] = 0; t.Cov()[ 9] = .2*.2; t.Cov()[10] = 0; t.Cov()[11] = 0; t.Cov()[12] = 0; t.Cov()[13] = 0; t.Cov()[14] = .2*.2; t.Chi2() = 0; t.NDF() = -5; } if( t.Filter2( h.Y(), h.Z(), h.ErrY()*h.ErrY(), h.ErrZ()*h.ErrZ() ) ) first = 0; else continue; fOutTrackHits[fNOutTrackHits] = h.ID(); fNOutTrackHits++; if( fNOutTrackHits>fNHitsTotal ){ cout<<"fNOutTrackHits>fNHitsTotal"<=3 ){ p0.Param().ConstructXYZ3(sp0,sp1,sp2,p0.Param().CosPhi(), t0); p2.Param().ConstructXYZ3(sp2,sp1,sp0,p2.Param().CosPhi(), t0); //p2.Param() = p0.Param(); //p2.Param().TransportToX(row2.X()); //p2.Param().Par()[1] = -p2.Param().Par()[1]; //p2.Param().Par()[4] = -p2.Param().Par()[4]; } else { p0.Param().X() = row0.X(); p0.Param().Y() = c0.Y(); p0.Param().Z() = c0.Z(); p0.Param().Err2Y() = c0.ErrY()*c0.ErrY(); p0.Param().Err2Z() = c0.ErrZ()*c0.ErrZ(); p2.Param().X() = row2.X(); p2.Param().Y() = c2.Y(); p2.Param().Z() = c2.Z(); p2.Param().Err2Y() = c2.ErrY()*c2.ErrY(); p2.Param().Err2Z() = c2.ErrZ()*c2.ErrZ(); } }