2 Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) version 3.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
24 #include "AliHLTTPCCARow.h"
25 #include "AliHLTTPCCAMath.h"
28 typedef unsigned int uint_v;
29 typedef short short_v;
30 typedef unsigned short ushort_v;
31 typedef float float_v;
33 class AliHLTTPCCAClusterData;
34 template<typename T, int Dim> class AliHLTArray;
36 class AliHLTTPCCAParam;
39 * Data abstraction class for the Slice Tracker.
41 * Different architectures implement this for the most efficient loads and stores. All access to the
42 * data happens through inline functions so that access to the data has no extra costs.
44 class AliHLTTPCCASliceData
47 AliHLTTPCCASliceData()
48 : fNumberOfHits( 0 ), fMemorySize( 0 ), fMemory( 0 ), fLinkUpData( 0 ),
49 fLinkDownData( 0 ), fHitDataY( 0 ), fHitDataZ( 0 ), fClusterDataIndex( 0 ),
50 fFirstHitInBin( 0 ), fHitWeights( 0 ) {}
52 void InitializeRows( const AliHLTTPCCAParam ¶meters );
55 * (Re)Create the data that is tuned for optimal performance of the algorithm from the cluster
58 void InitFromClusterData( const AliHLTTPCCAClusterData &data );
61 * Clear the slice data (e.g. for an empty slice)
66 * Return the number of hits in this slice.
68 int NumberOfHits() const { return fNumberOfHits; }
71 * Access to the hit links.
73 * The links values give the hit index in the row above/below. Or -1 if there is no link.
75 short_v HitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex ) const;
76 short_v HitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex ) const;
77 void SetHitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex,
78 const short_v &value );
79 void SetHitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex,
80 const short_v &value );
83 * Reset all links to -1.
88 * Return the y and z coordinate(s) of the given hit(s).
90 // TODO return float_v
91 short_v HitDataY( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const;
92 short_v HitDataZ( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const;
95 * For a given bin index, content tells how many hits there are in the preceding bins. This maps
96 * directly to the hit index in the given row.
98 * \param binIndexes in the range 0 to row.Grid.N + row.Grid.Ny + 3.
100 ushort_v FirstHitInBin( const AliHLTTPCCARow &row, ushort_v binIndexes ) const;
103 * If the given weight is higher than what is currently stored replace with the new weight.
105 void MaximizeHitWeight( const AliHLTTPCCARow &row, uint_v hitIndex, int_v weight );
108 * Return the maximal weight the given hit got from one tracklet
110 int_v HitWeight( const AliHLTTPCCARow &row, uint_v hitIndex ) const;
113 * Reset all hit weights to 0.
115 void ClearHitWeights();
118 * Returns the index in the original AliHLTTPCCAClusterData object of the given hit
120 int_v ClusterDataIndex( const AliHLTTPCCARow &row, uint_v hitIndex ) const;
123 * Return the row object for the given row index.
125 const AliHLTTPCCARow &Row( int rowIndex ) const;
128 void createGrid( AliHLTTPCCARow *row, const AliHLTTPCCAClusterData &data );
129 void PackHitData( AliHLTTPCCARow *row, const AliHLTArray<AliHLTTPCCAHit, 1> &binSortedHits );
131 AliHLTTPCCARow fRows[200]; // The row objects needed for most accessor functions
133 int fNumberOfHits; // the number of hits in this slice
134 int fMemorySize; // size of the allocated memory in bytes
135 char *fMemory; // pointer to the allocated memory where all the following arrays reside in
137 short *fLinkUpData; // hit index in the row above which is linked to the given (global) hit index
138 short *fLinkDownData; // hit index in the row below which is linked to the given (global) hit index
140 unsigned short *fHitDataY; // packed y coordinate of the given (global) hit index
141 unsigned short *fHitDataZ; // packed z coordinate of the given (global) hit index
143 int *fClusterDataIndex; // see ClusterDataIndex()
146 * The size of the array is row.Grid.N + row.Grid.Ny + 3. The row.Grid.Ny + 3 is an optimization
147 * to remove the need for bounds checking. The last values are the same as the entry at [N - 1].
149 unsigned short *fFirstHitInBin; // see FirstHitInBin
151 int *fHitWeights; // the weight of the longest tracklet crossed the cluster
155 inline short_v AliHLTTPCCASliceData::HitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex ) const
157 return fLinkUpData[row.fHitNumberOffset + hitIndex];
160 inline short_v AliHLTTPCCASliceData::HitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex ) const
162 return fLinkDownData[row.fHitNumberOffset + hitIndex];
165 inline void AliHLTTPCCASliceData::SetHitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex, const short_v &value )
167 fLinkUpData[row.fHitNumberOffset + hitIndex] = value;
170 inline void AliHLTTPCCASliceData::SetHitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex, const short_v &value )
172 fLinkDownData[row.fHitNumberOffset + hitIndex] = value;
175 inline short_v AliHLTTPCCASliceData::HitDataY( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const
177 return fHitDataY[row.fHitNumberOffset + hitIndex];
180 inline short_v AliHLTTPCCASliceData::HitDataZ( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const
182 return fHitDataZ[row.fHitNumberOffset + hitIndex];
185 inline ushort_v AliHLTTPCCASliceData::FirstHitInBin( const AliHLTTPCCARow &row, ushort_v binIndexes ) const
187 return fFirstHitInBin[row.fFirstHitInBinOffset + binIndexes];
190 inline int_v AliHLTTPCCASliceData::ClusterDataIndex( const AliHLTTPCCARow &row, uint_v hitIndex ) const
192 return fClusterDataIndex[row.fHitNumberOffset + hitIndex];
195 inline const AliHLTTPCCARow &AliHLTTPCCASliceData::Row( int rowIndex ) const
197 return fRows[rowIndex];
200 inline void AliHLTTPCCASliceData::MaximizeHitWeight( const AliHLTTPCCARow &row, uint_v hitIndex, int_v weight )
202 CAMath::AtomicMax( &fHitWeights[row.fHitNumberOffset + hitIndex], weight );
205 inline int_v AliHLTTPCCASliceData::HitWeight( const AliHLTTPCCARow &row, uint_v hitIndex ) const
207 return fHitWeights[row.fHitNumberOffset + hitIndex];
210 typedef AliHLTTPCCASliceData SliceData;
212 #endif // SLICEDATA_H