21 #include "AliHLTTPCCASliceDataVector.h"
22 #include "AliHLTTPCCAClusterData.h"
23 #include "AliHLTTPCCAMath.h"
25 #include "AliHLTTPCCAHit.h"
26 #include "AliHLTTPCCAParam.h"
27 #include "MemoryAssignmentHelpers.h"
38 const float tan = CAMath::Tan( p.DAlpha() / 2.f );
39 for (
int i = 0; i < p.NRows(); ++i ) {
41 fRows[i].fMaxY = tan * p.RowX( i );
53 int numberOfHitsWithPadding = 0;
55 numberOfHitsWithPadding += NextMultipleOf<VectorAlignment>( data.
NumberOfClusters( row ) );
59 const int firstHitInBinSize = 23 * numberOfRows + AliHLTTPCCAParameters::GridCreationCoeff * 4 * fNumberOfHits;
60 const int memorySize =
62 2 * numberOfHitsWithPadding *
sizeof( short ) +
64 2 * numberOfHitsWithPadding *
sizeof( StoredFloat ) +
66 numberOfHitsWithPadding *
sizeof( short ) +
68 NextMultipleOf<VectorAlignment>( firstHitInBinSize *
sizeof(
short ) ) +
70 2 * numberOfHitsWithPadding *
sizeof(
int );
72 if ( fMemorySize < memorySize ) {
73 fMemorySize = memorySize;
74 if (fMemory)
delete[] fMemory;
75 fMemory =
new char[fMemorySize + 7 * VectorAlignment];
81 StoredFloat *hitDataY;
82 StoredFloat *hitDataZ;
84 int *clusterDataIndex;
85 unsigned short *hitWeights;
86 unsigned short *firstHitInBin;
89 AssignMemoryAligned<VectorAlignment>( linkUpData, mem, numberOfHitsWithPadding );
90 AssignMemoryAligned<VectorAlignment>( linkDownData, mem, numberOfHitsWithPadding );
91 AssignMemoryAligned<VectorAlignment>( hitDataY, mem, numberOfHitsWithPadding );
92 AssignMemoryAligned<VectorAlignment>( hitDataZ, mem, numberOfHitsWithPadding );
93 AssignMemoryAligned<VectorAlignment>( hitDataIsUsed, mem, numberOfHitsWithPadding );
98 AssignMemoryAligned<VectorAlignment>( firstHitInBin, mem, firstHitInBinSize );
99 AssignMemoryAligned<VectorAlignment>( hitWeights, mem, numberOfHitsWithPadding );
100 AssignMemoryAligned<VectorAlignment>( clusterDataIndex, mem, numberOfHitsWithPadding );
106 for (
int rowIndex = 0; rowIndex < data.
FirstRow(); ++rowIndex ) {
108 row.fGrid.CreateEmpty();
110 row.fLinkUpData = linkUpData;
111 row.fLinkDownData = linkDownData;
112 row.fHitDataY = hitDataY;
113 row.fHitDataZ = hitDataZ;
114 row.fHitDataIsUsed = hitDataIsUsed;
115 row.fClusterDataIndex = clusterDataIndex;
116 row.fHitWeights = hitWeights;
117 row.fFirstHitInBin = firstHitInBin;
123 int gridContentOffset = 0;
125 int binCreationMemorySize = 103 * 2 + fNumberOfHits;
128 int hitNumberOffset = 0;
130 for (
int rowIndex = data.
FirstRow(); rowIndex <= data.
LastRow(); ++rowIndex ) {
132 const int clusterDataOffset = data.
RowOffset( rowIndex );
134 assert( data.
NumberOfClusters( rowIndex ) < ( 1 << (
sizeof(
unsigned short ) * 8 - 1 ) ) );
137 row.fLinkUpData = &linkUpData[hitNumberOffset];
138 row.fLinkDownData = &linkDownData[hitNumberOffset];
139 row.fHitDataY = &hitDataY[hitNumberOffset];
140 row.fHitDataZ = &hitDataZ[hitNumberOffset];
141 row.fHitDataIsUsed = &hitDataIsUsed[hitNumberOffset];
142 row.fClusterDataIndex = &clusterDataIndex[hitNumberOffset];
143 row.fHitWeights = &hitWeights[hitNumberOffset];
144 row.fHitNumberOffset = hitNumberOffset;
146 row.fFirstHitInBin = &firstHitInBin[gridContentOffset];
148 createGrid( &row, data, clusterDataOffset );
150 const int numberOfBins = grid.N();
152 int binCreationMemorySizeNew;
153 if ( ( binCreationMemorySizeNew = numberOfBins * 2 + 6 + row.fNHits ) > binCreationMemorySize ) {
154 binCreationMemorySize = binCreationMemorySizeNew;
155 binCreationMemory.
Resize( binCreationMemorySize );
162 for (
unsigned int bin = 0; bin < row.fGrid.N() + 3; ++bin ) {
166 for (
int hitIndex = 0; hitIndex < row.fNHits; ++hitIndex ) {
167 const int globalHitIndex = clusterDataOffset + hitIndex;
168 const unsigned short bin = row.fGrid.GetBin( data.
Y( globalHitIndex ), data.
Z( globalHitIndex ) );
169 bins[hitIndex] = bin;
173 unsigned short n = 0;
174 for (
int bin = 0; bin < numberOfBins + 3; ++bin ) {
179 for (
int hitIndex = 0; hitIndex < row.fNHits; ++hitIndex ) {
180 const unsigned short bin = bins[hitIndex];
181 assert( bin < numberOfBins + 3 );
183 const unsigned short ind = c[bin] + filled[bin];
184 assert( ind < row.fNHits );
185 const int globalHitIndex = clusterDataOffset + hitIndex;
188 row.fClusterDataIndex[ind] = globalHitIndex;
189 row.fHitDataY[ind] = data.
Y( globalHitIndex );
190 row.fHitDataZ[ind] = data.
Z( globalHitIndex );
191 row.fHitDataIsUsed[ind] = 0;
194 for (
int i = 0; i < numberOfBins; ++i ) {
195 row.fFirstHitInBin[i] = c[i];
197 const unsigned short a = c[numberOfBins];
199 const int nn = numberOfBins + grid.Ny() + 3;
200 ASSERT( static_cast<int>( gridContentOffset ) + nn - 1 < firstHitInBinSize,
201 static_cast<int>( gridContentOffset ) <<
" + " << nn <<
" - 1 < " << firstHitInBinSize);
202 for (
int i = numberOfBins; i < nn; ++i ) {
203 row.fFirstHitInBin[i] = a;
206 gridContentOffset += nn;
207 hitNumberOffset += NextMultipleOf<VectorAlignment>( row.fNHits );
210 for (
int rowIndex = data.
LastRow() + 1; rowIndex < AliHLTTPCCAParameters::MaxNumberOfRows8; ++rowIndex ) {
212 row.fGrid.CreateEmpty();
214 row.fLinkUpData = &linkUpData[hitNumberOffset];
215 row.fLinkDownData = &linkDownData[hitNumberOffset];
216 row.fHitDataY = &hitDataY[hitNumberOffset];
217 row.fHitDataZ = &hitDataZ[hitNumberOffset];
218 row.fHitDataIsUsed = &hitDataIsUsed[hitNumberOffset];
219 row.fClusterDataIndex = &clusterDataIndex[hitNumberOffset];
220 row.fHitWeights = &hitWeights[hitNumberOffset];
221 row.fFirstHitInBin = &firstHitInBin[gridContentOffset];
227 const ushort_v v0( Vc::Zero );
228 const unsigned short *
const end = fRows[fParam->NRows()].fHitWeights;
229 for (
unsigned short *mem = fRows[0].fHitWeights; mem < end; mem += v0.
Size ) {
236 const short_v v0( -1 );
237 const short *
const end1 = fRows[fParam->NRows()].fLinkUpData;
238 for (
short *mem = fRows[0].fLinkUpData; mem < end1; mem += v0.
Size ) {
241 const short *
const end2 = fRows[fParam->NRows()].fLinkDownData;
242 for (
short *mem = fRows[0].fLinkDownData; mem < end2; mem += v0.
Size ) {
251 #include "BinaryStoreHelper.h"
253 void AliHLTTPCCASliceData::StoreToFile( FILE *f )
const
255 BinaryStoreWrite( fNumberOfHits, f );
257 const int size = fMemorySize;
259 assert( size <= fMemorySize );
260 BinaryStoreWrite( size, f );
261 BinaryStoreWrite( static_cast<Byte_t>( reinterpret_cast<unsigned long>( fMemory ) & 0xff ), f );
262 BinaryStoreWrite( fMemory, size, f );
264 for (
int i = 0; i < 200; ++i ) {
265 fRows[i].StoreToFile( f, fMemory );
269 void AliHLTTPCCASliceData::RestoreFromFile( FILE *f )
271 BinaryStoreRead( fNumberOfHits, f );
273 BinaryStoreRead( fMemorySize, f );
275 BinaryStoreRead( alignment, f );
276 fMemory =
new char[fMemorySize + 256];
277 const Byte_t offset = alignment -
static_cast<Byte_t
>(
reinterpret_cast<unsigned long>( fMemory ) & 0xff );
278 BinaryStoreRead( fMemory + offset, fMemorySize, f );
280 for (
int i = 0; i < 200; ++i ) {
281 fRows[i].RestoreFromFile( f, fMemory + offset );
int RowOffset(unsigned int rowIndex) const
void InitFromClusterData(const AliHLTTPCCAClusterData &data)
int NumberOfClusters() const