// @(#) $Id: AliHLTTPCCATrackletSelector.cxx,v 1.4 2010/08/09 17:51:15 mzyzak Exp $ // ************************************************************************** // 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. * // * // Developed by: Igor Kulakov * // Maksym Zyzak * // * // 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. * // * //*************************************************************************** //#define USE_ARBB //#define USE_CALL #include "AliHLTTPCCATrackletSelector.h" #include "AliHLTTPCCATrack.h" #include "AliHLTTPCCATracker.h" #include "AliHLTTPCCATrackParamVector.h" #include "AliHLTTPCCATracklet.h" #include "AliHLTTPCCAMath.h" #include "AliHLTTPCCAParameters.h" #include #undef USE_TBB #ifdef USE_TBB #include #endif //USE_TBB #ifndef NVALGRIND #include #endif #include "debug.h" #ifdef USE_ARBB #include using namespace arbb; #endif // USE_ARBB #ifdef DRAW3 #include "AliHLTTPCCADisplay.h" #endif //DRAW using std::endl; dense AliHLTTPCCATrackletSelector::TakeOwnHits( AliHLTTPCCARowHit::TDense<1>& row, const dense& hitIndices, const dense& mask, const dense& weights ) { const usize taskSize = mask.length(); const dense storedWeights = gather( row.Weight(), hitIndices, static_cast(0), fill( 0, taskSize ), mask ); const dense own = storedWeights == weights && mask; const dense takenMarker = fill(std::numeric_limits::max(), taskSize); row.SetWeight( scatter( takenMarker, hitIndices, row.Weight(), own ) ); return own; } // AliHLTTPCCATrackletSelector::TakeOwnHits() void AliHLTTPCCATrackletSelector::run_ArBB( nested_my& rowsData, const AliHLTTPCCATrackletVector_ArBB& trackletVector, AliHLTTPCCATrack_ArBB& tracks ) { const u16 taskSize = trackletVector.NHits().length(); const dense zero = fill( 0, taskSize ); const dense tNHits = trackletVector.NHits(); const dense &valid = tNHits > 0; const dense kMaximumSharedPerHits = fill( 1 / AliHLTTPCCAParameters::MinimumHitsPerShared, taskSize ); const dense &firstRow = trackletVector.FirstRow(); const dense &lastRow = trackletVector.LastRow(); dense tNHitsNew = zero; //const dense &weight = SliceData::CalculateHitWeight( tNHits, trackletVectorIndices ); const dense weight = ( static_cast< dense >(tNHits) << 8 ) | ( indices(0, taskSize, 1) & 0 ); // TODO function tracks.Resize(taskSize); //const int nRows = fTracker.Param().NRows(); // number of rows (Tracker global) // dense gap( zero ); // count how many rows are missing a hit // CHECKME gaps was not checked here dense nShared( zero ); const TRowI_ArBB minRowIndex = min_reduce(firstRow); const TRowI_ArBB maxRowIndex = max_reduce(lastRow); _for ( TRowI_ArBB rowIndex = minRowIndex, rowIndex <= maxRowIndex, ++rowIndex ) { _if ( rowsData.lengths()[rowIndex] <= 0 ) { _continue; } _end_if; AliHLTTPCCARowHit::TDense<1> row = rowsData.segment(rowIndex); // ++gap; const dense &hitIndexes = trackletVector.HitIndexAtRow( rowIndex ); // hit index for the current row const dense validHits = valid && ( hitIndexes >= 0 ); const dense own = TakeOwnHits( row, hitIndexes, validHits, weight ); rowsData = replace_segment( rowsData, rowIndex, row ); const dense sharedOK = nShared < static_cast< dense >( static_cast< dense >(tNHitsNew) * kMaximumSharedPerHits ); const dense outHit = validHits && ( own || sharedOK ); _for ( u16 i = 0, i < taskSize, ++i ) { // TODO optimize _if ( outHit[i] ) { // TODO rid of if const dense maskI = outHit && indices(0, taskSize, 1) == i; tracks.SetHitId( tracks.fNumberOfHits[i], fill(rowIndex,taskSize), hitIndexes, maskI ); tracks.fNumberOfHits = select( maskI, tracks.fNumberOfHits + 1, tracks.fNumberOfHits ); // } _else_if ( gap[i] > AliHLTTPCCAParameters::MaximumRowGap ) { // _if ( tracks.fNumberOfHits[i] >= AliHLTTPCCAParameters::MinimumHitsForTrack ) { // // tracks[i] = new Track; // // fTracks[++numberOfTracks] = tracks[i]; // } _else { // tracks.fNumberOfHits[i] = 0; // } _end_if; } _end_if; } _end_for; // gap = select( outHit, 0, gap ); tNHitsNew = select( outHit, tNHitsNew + 1, tNHitsNew ); // tNHitsNew = select( gap > AliHLTTPCCAParameters::MaximumRowGap, 0, tNHitsNew ); nShared = select( !own && outHit, nShared + 1, nShared ); } _end_for; // rowIndex tracks.fParam = trackletVector.Param(); dense packMask = tracks.fNumberOfHits >= AliHLTTPCCAParameters::MinimumHitsForTrack; _if ( !any( packMask ) ) { // leave one element in the dense (otherwise arbb doesn't work) packMask[0] = true; tracks.fNumberOfHits[0] = 0; } _end_if; tracks.Pack( packMask ); } // run_ArBB void AliHLTTPCCATrackletSelector::run() { run_ArBB( fRows_ArBB, fTrackletVectors_ArBB, fTracks ); }