double pz = T0[5];
double d[6] = { fParam[0] - T0[0], fParam[1] - T0[1], fParam[2] - T0[2],
- fParam[3] - T0[3], fParam[4] - T0[4], fParam[5] - T0[5]
- };
+ fParam[3] - T0[3], fParam[4] - T0[4], fParam[5] - T0[5]
+ };
T0[0] = T0[0] + sB * px + cB * py;
T0[1] = T0[1] - cB * px + sB * py;
z2 = m[2] - fParam[2];
double mS[6] = { c00 + V[0] + G[0], c10 + V[1] + G[1], c11 + V[2] + G[2],
- c20 + V[3] + G[3], c21 + V[4] + G[4], c22 + V[5] + G[5]
- };
+ c20 + V[3] + G[3], c21 + V[4] + G[4], c22 + V[5] + G[5]
+ };
double mSi[6];
mSi[0] = mS[4] * mS[4] - mS[2] * mS[5];
mSi[1] = mS[1] * mS[5] - mS[3] * mS[4];
--- /dev/null
+/*
+ Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) version 3.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#include "AliHLTTPCCAClusterData.h"
+#include "AliHLTTPCSpacePointData.h"
+#include "AliHLTTPCCAMath.h"
+#include <iostream>
+
+void AliHLTTPCCAClusterData::readEvent( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
+ int numberOfClusters, double ClusterZCut )
+{
+ if ( numberOfClusters <= 0 ) {
+ fSlice = -1;
+ fFirstRow = 0;
+ fLastRow = -1;
+ return;
+ }
+ fSlice = clusters[0]->fID >> 25;
+ fFirstRow = clusters[0]->fPadRow;
+ fLastRow = fFirstRow;
+ int row = fFirstRow;
+ for ( int i = 0; i < row; ++i ) {
+ fNumberOfClusters.push_back( 0 );
+ fRowOffset.push_back( 0 );
+ }
+ fRowOffset.push_back( 0 );
+ for ( int i = 0; i < numberOfClusters; ++i ) {
+ AliHLTTPCSpacePointData *data = clusters[i];
+
+ if ( CAMath::Abs( data->fZ ) > ClusterZCut ) continue;
+
+ while ( row < data->fPadRow ) {
+ fNumberOfClusters.push_back( fData.size() - fRowOffset.back() );
+ fRowOffset.push_back( fData.size() );
+ ++row;
+ }
+ Data d = { data->fX, data->fY, data->fZ, data->fID, data->fPadRow };
+ fData.push_back( d );
+ }
+ fNumberOfClusters.push_back( fData.size() - fRowOffset.back() );
+ fLastRow = row; // the last seen row is the last row in this slice
+}
+
+void AliHLTTPCCAClusterData::readEvent( const AliHLTTPCCAGBHit *hits, int *offset, int numberOfClusters )
+{
+ fSlice = hits[*offset].ISlice();
+ fFirstRow = hits[*offset].IRow(); // the data is row sorted first in the slice, so this is our first row
+ fLastRow = fFirstRow;
+ int row = fFirstRow;
+ for ( int i = 0; i < row; ++i ) {
+ fNumberOfClusters.push_back( 0 );
+ fRowOffset.push_back( 0 );
+ }
+ fRowOffset.push_back( 0 );
+ for ( int &i = *offset; i < numberOfClusters; ++i ) {
+ const AliHLTTPCCAGBHit &hit = hits[i];
+ if ( hit.ISlice() != fSlice ) {
+ // the data is slice sorted first so we're done gathering our data
+ break;
+ }
+ while ( row < hit.IRow() ) {
+ fNumberOfClusters.push_back( fData.size() - fRowOffset.back() );
+ fRowOffset.push_back( fData.size() );
+ ++row;
+ }
+ Data d = { hit.X(), hit.Y(), hit.Z(), hit.ID(), hit.IRow() };
+ fData.push_back( d );
+ }
+ fNumberOfClusters.push_back( fData.size() - fRowOffset.back() );
+ fLastRow = row; // the last seen row is the last row in this slice
+}
--- /dev/null
+/*
+ Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) version 3.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef CLUSTERDATA_H
+#define CLUSTERDATA_H
+
+#include <vector>
+#include "AliHLTTPCCAGBHit.h"
+#include "AliHLTArray.h"
+
+class AliHLTTPCSpacePointData;
+
+/**
+ * Cluster data which keeps history about changes
+ *
+ * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
+ */
+class AliHLTTPCCAClusterData
+{
+ public:
+ /**
+ * Construct AliHLTTPCCAClusterData object from AliHLTTPCSpacePointData array.
+ */
+ AliHLTTPCCAClusterData( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
+ int numberOfClusters, double ClusterZCut )
+ : fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData()
+ { readEvent( clusters, numberOfClusters, ClusterZCut ); }
+
+
+ /**
+ * Construct AliHLTTPCCAClusterData object from GBHit array.
+ */
+ AliHLTTPCCAClusterData( const AliHLTTPCCAGBHit *hits, int *offset, int numberOfClusters )
+ : fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {
+ readEvent( hits, offset, numberOfClusters );
+ }
+
+ AliHLTTPCCAClusterData(): fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {}
+
+ void readEvent( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
+ int numberOfClusters, double ClusterZCut );
+ void readEvent( const AliHLTTPCCAGBHit *hits, int *offset, int numberOfClusters );
+
+ /**
+ * "remove" one cluster and "add" two new ones, keeping history.
+ */
+ //void Split( int index, /* TODO: need some parameters how to split */ );
+
+ // TODO: some access to history of merges and splits
+
+ /**
+ * The slice index this data belongs to
+ */
+ int Slice() const { return fSlice; }
+
+ /**
+ * The first row index that contains a cluster.
+ */
+ int FirstRow() const { return fFirstRow; }
+
+ /**
+ * The last row index that contains a cluster.
+ */
+ int LastRow() const { return fLastRow; }
+
+ /**
+ * Return the number of clusters in this slice.
+ */
+ int NumberOfClusters() const { return fData.size(); }
+
+ /**
+ * Return the number of clusters in the given row, for this slice.
+ */
+ int NumberOfClusters( unsigned int rowIndex ) const { return rowIndex < fNumberOfClusters.size() ? fNumberOfClusters[rowIndex] : 0; }
+
+ /**
+ * Return the index of the first cluster in the given row.
+ *
+ * Supports calls with rowIndex greater than the available number of rows. In that case it
+ * returns NumberOfClusters.
+ *
+ * To iterate over the clusters in one row do:
+ * \code
+ * AliHLTTPCCAClusterData cd;
+ * const int lastClusterIndex = cd.RowOffset( rowIndex + 1 );
+ * for ( int hitIndex = cd.RowOffset( rowIndex ); hitIndex < lastClusterIndex; ++hitIndex )
+ * \endcode
+ */
+ int RowOffset( unsigned int rowIndex ) const { return rowIndex < fRowOffset.size() ? fRowOffset[rowIndex] : fData.size(); }
+
+ /**
+ * Return the x coordinate of the given cluster.
+ */
+ float X( int index ) const { return fData[index].fX; }
+
+ /**
+ * Return the y coordinate of the given cluster.
+ */
+ float Y( int index ) const { return fData[index].fY; }
+
+ /**
+ * Return the z coordinate of the given cluster.
+ */
+ float Z( int index ) const { return fData[index].fZ; }
+
+ /**
+ * Return the global ID of the given cluster.
+ */
+ int Id( int index ) const { return fData[index].fId; }
+
+ /**
+ * Return the row number/index of the given cluster.
+ */
+ int RowNumber( int index ) const { return fData[index].fRow; }
+
+ private:
+ /** TODO
+ * "remove" two clusters and "add" a new one, keeping history.
+ */
+ void Merge( int index1, int index2 );
+
+ struct Data {
+ float fX;
+ float fY;
+ float fZ;
+ int fId;
+ int fRow;
+ };
+
+ int fSlice; // the slice index this data belongs to
+ int fFirstRow; // see FirstRow()
+ int fLastRow; // see LastRow()
+ std::vector<int> fNumberOfClusters; // list of NumberOfClusters per row for NumberOfClusters(int)
+ std::vector<int> fRowOffset; // see RowOffset()
+ std::vector<Data> fData; // list of data of clusters
+};
+
+typedef AliHLTTPCCAClusterData ClusterData;
+
+#endif // CLUSTERDATA_H
#define ClassDef(name,id)
#define ClassImp(name)
-typedef char char; //Signed Character 1 byte (char)
typedef unsigned char UChar_t; //Unsigned Character 1 byte (unsigned char)
-typedef short short; //Signed Short integer 2 bytes (short)
-typedef unsigned short unsigned short; //Unsigned Short integer 2 bytes (unsigned short)
-#ifdef R__INT16
-typedef long int; //Signed integer 4 bytes
-typedef unsigned long unsigned int; //Unsigned integer 4 bytes
-#else
-typedef int int; //Signed integer 4 bytes (int)
-typedef unsigned int unsigned int; //Unsigned integer 4 bytes (unsigned int)
-#endif
#ifdef R__B64 // Note: Long_t and ULong_t are currently not portable types
typedef int Seek_t; //File pointer (int)
typedef long Long_t; //Signed long integer 8 bytes (long)
typedef long Long_t; //Signed long integer 4 bytes (long)
typedef unsigned long ULong_t; //Unsigned long integer 4 bytes (unsigned long)
#endif
-typedef float float; //Float 4 bytes (float)
typedef float Float16_t; //Float 4 bytes written with a truncated mantissa
-typedef double double; //Double 8 bytes
typedef double Double32_t; //Double 8 bytes in memory, written as a 4 bytes float
typedef char Text_t; //General string (char)
-typedef bool bool; //Boolean (0=false, 1=true) (bool)
typedef unsigned char Byte_t; //Byte (8 bits) (unsigned char)
typedef short Version_t; //Class version identifier (short)
typedef const char Option_t; //Option string (const char)
#endif
+/*
+ * Helper for compile-time verification of correct API usage
+ */
+namespace
+{
+ template<bool> struct HLTTPCCA_STATIC_ASSERT_FAILURE;
+ template<> struct HLTTPCCA_STATIC_ASSERT_FAILURE<true> {};
+}
+
+#define HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b) a##b
+#define HLTTPCCA_STATIC_ASSERT_CONCAT(a, b) HLTTPCCA_STATIC_ASSERT_CONCAT_HELPER(a, b)
+#define STATIC_ASSERT(cond, msg) \
+ typedef HLTTPCCA_STATIC_ASSERT_FAILURE<cond> HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__); \
+ HLTTPCCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__) Error_##msg; \
+ (void) Error_##msg
+
+namespace
+{
+ template<typename T1>
+ void UNUSED_PARAM1( const T1 & ) {}
+ template<typename T1, typename T2>
+ void UNUSED_PARAM2( const T1 &, const T2 & ) {}
+ template<typename T1, typename T2, typename T3>
+ void UNUSED_PARAM3( const T1 &, const T2 &, const T3 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4>
+ void UNUSED_PARAM4( const T1 &, const T2 &, const T3 &, const T4 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ void UNUSED_PARAM5( const T1 &, const T2 &, const T3 &, const T4 &, const T5 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+ void UNUSED_PARAM6( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
+ void UNUSED_PARAM7( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
+ void UNUSED_PARAM8( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 & ) {}
+ template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
+ void UNUSED_PARAM9( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &, const T9 & ) {}
+}
#endif
void SetZ( double v ) { fZ = v; }
static bool CompareHitDS( const AliHLTTPCCADisplayTmpHit &a,
- const AliHLTTPCCADisplayTmpHit &b ) {
+ const AliHLTTPCCADisplayTmpHit &b ) {
return ( a.fS < b.fS );
}
static bool CompareHitZ( const AliHLTTPCCADisplayTmpHit &a,
- const AliHLTTPCCADisplayTmpHit &b ) {
+ const AliHLTTPCCADisplayTmpHit &b ) {
return ( a.fZ < b.fZ );
}
void AliHLTTPCCADisplay::Ask()
{
- // whait for the pressed key, when "r" pressed, don't ask anymore
+ // wait for the pressed key, when "r" pressed, don't ask anymore
char symbol;
if ( fAsk ) {
Update();
void AliHLTTPCCADisplay::DrawGBHit( AliHLTTPCCAGBTracker &tracker, int iHit, int color, Size_t width )
{
// draw hit
- AliHLTTPCCAGBHit &h = tracker.Hits()[iHit];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[iHit];
AliHLTTPCCATracker &slice = tracker.Slices()[h.ISlice()];
SetSliceTransform( &slice );
if ( width < 0 ) width = .3;
for ( int iHit = 0; iHit < tracker.NHits(); iHit++ ) {
- AliHLTTPCCAGBHit &h = tracker.Hits()[iHit];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[iHit];
int imc = fPerf->HitLabels()[h.ID()].fLab[0];
AliHLTTPCCAMCTrack *mc = ( imc >= 0 ) ? &( fPerf->MCTracks()[imc] ) : 0;
if ( fDrawOnlyRef && ( !mc || ( mc->P() < 1 ) ) ) continue;
float z0 = row.Grid().ZMin();
float stepY = row.HstepY();
float stepZ = row.HstepZ();
- const uint4* tmpint4 = fSlice->RowData() + row.FullOffset();
- const ushort2 *hits = reinterpret_cast<const ushort2*>( tmpint4 );
- ushort2 hh = hits[iHit];
float x = row.X();
- float y = y0 + hh.x * stepY;
- float z = z0 + hh.y * stepZ;
+ float y = y0 + fSlice->HitDataY( row, iHit ) * stepY;
+ float z = z0 + fSlice->HitDataZ( row, iHit ) * stepZ;
SetSliceTransform( fSlice );
if ( color < 0 ) {
if ( fPerf && fGB ) {
- int id = fGB->FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->HitInputIDs()[row.FirstHit()+iHit];
- AliHLTTPCCAGBHit &h = fGB->Hits()[id];
+ int id = fGB->FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->HitInputID( row, iHit );
+ const AliHLTTPCCAGBHit &h = fGB->Hits()[id];
int lab = fPerf->HitLabels()[h.ID()].fLab[0];
color = GetColor( lab + 1 );
if ( lab >= 0 ) {
fLine.SetLineWidth( width );
int colUp = colorUp >= 0 ? colorUp : kMagenta;
int colDn = colorDn >= 0 ? colorDn : kBlack;
- if ( iRow < 1 || iRow >= fSlice->Param().NRows() - 1 ) return;
+ if ( iRow < 2 || iRow >= fSlice->Param().NRows() - 2 ) return;
const AliHLTTPCCARow& row = fSlice->Row( iRow );
- const AliHLTTPCCARow& rowUp = fSlice->Row( iRow + 1 );
- const AliHLTTPCCARow& rowDn = fSlice->Row( iRow - 1 );
+ const AliHLTTPCCARow& rowUp = fSlice->Row( iRow + 2 );
+ const AliHLTTPCCARow& rowDn = fSlice->Row( iRow - 2 );
- int id = fSlice->HitInputIDs()[row.FirstHit()+iHit];
- AliHLTTPCCAGBHit &h = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id];
- short iUp = ( ( short* )( fSlice->RowData() + row.FullOffset() ) )[row.FullLinkOffset()+iHit];
- short iDn = ( ( short* )( fSlice->RowData() + row.FullOffset() ) )[row.FullLinkOffset()+row.NHits()+iHit];
+ int id = fSlice->HitInputID( row, iHit );
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id];
+ short iUp = fSlice->HitLinkUpData( row, iHit );
+ short iDn = fSlice->HitLinkDownData( row, iHit );
if ( iUp >= 0 ) {
- int id1 = fSlice->HitInputIDs()[rowUp.FirstHit()+iUp];
- AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
+ int id1 = fSlice->HitInputID( rowUp, iUp );
+ const AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
double vx, vy, vx1, vy1;
Slice2View( h.X(), h.Y(), &vx, &vy );
Slice2View( h1.X(), h1.Y(), &vx1, &vy1 );
fLine.DrawLine( h.Z() - 1., vy, h1.Z() - 1., vy1 );
}
if ( iDn >= 0 ) {
- int id1 = fSlice->HitInputIDs()[rowDn.FirstHit()+iDn];
- AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
+ int id1 = fSlice->HitInputID( rowDn, iDn );
+ const AliHLTTPCCAGBHit &h1 = tracker.Hits()[tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id1];
double vx, vy, vx1, vy1;
Slice2View( h.X(), h.Y(), &vx, &vy );
Slice2View( h1.X(), h1.Y(), &vx1, &vy1 );
int nla = 0;
//std::cout<<"\n\nTrack hits mc: "<<std::endl;
for ( int ihit = 0; ihit < NHits; ihit++ ) {
- AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
}
lmax = 0;
for ( int ihit = 0; ihit < NHits; ihit++ ) {
- AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[ihit].ID()];
AliHLTTPCCAPerformance::AliHLTTPCCAHitLabel &l = fPerf->HitLabels()[h.ID()];
if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
) lmax++;
}
bool AliHLTTPCCADisplay::DrawTrack( AliHLTTPCCATrackParam t, double Alpha, const AliHLTTPCCADisplayTmpHit *vHits,
- int NHits, int color, int width, bool pPoint )
+ int NHits, int color, int width, bool pPoint )
{
// draw track
for ( int iHit = 0; iHit < NHits; iHit++ ) {
- AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[vHits[iHit].ID()];
double hCos = TMath::Cos( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
double hSin = TMath::Sin( alpha - tracker.Slices()[h.ISlice()].Param().Alpha() );
int iHit = hitstore[iRow];
if ( iHit < 0 ) continue;
const AliHLTTPCCARow &row = fSlice->Row( iRow );
- int id = fSlice->HitInputIDs()[row.FirstHit()+iHit];
+ int id = fSlice->HitInputID( row, iHit );
int iGBHit = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
- AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[iGBHit];
vHits[nHits].SetID( iGBHit );
vHits[nHits].SetS( 0 );
vHits[nHits].SetZ( h.Z() );
for ( int ih = 0; ih < track.NHits(); ih++ ) {
int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHits()[track.FirstHitRef()+ih];
- AliHLTTPCCAGBHit &h = tracker.Hits()[id];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
vHits[ih].SetID( id );
vHits[ih].SetS( 0 );
vHits[ih].SetZ( h.Z() );
for ( int ih = 0; ih < track.NHits(); ih++ ) {
int id = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + fSlice->OutTrackHits()[track.FirstHitRef()+ih];
- AliHLTTPCCAGBHit &h = tracker.Hits()[id];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[id];
vHits[ih].SetID( id );
vHits[ih].SetS( 0 );
vHits[ih].SetZ( h.Z() );
{
// draw slice track
- AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
+ const AliHLTTPCCATrack &track = fSlice->Tracks()[itr];
if ( track.NHits() < 2 ) return;
AliHLTTPCCAGBTracker &tracker = *fGB;
AliHLTTPCCADisplayTmpHit vHits[200];
for ( int ith = 0; ith < track.NHits(); ith++ ) {
- int ic = ( fSlice->TrackHits()[track.FirstHitID()+ith] );
- const AliHLTTPCCARow &row = fSlice->ID2Row( ic );
- int ih = fSlice->ID2IHit( ic );
- int id = fSlice->HitInputIDs()[row.FirstHit()+ih];
+ AliHLTTPCCAHitId ic = ( fSlice->TrackHits()[track.FirstHitID()+ith] );
+ const AliHLTTPCCARow &row = fSlice->Row( ic );
+ int ih = ic.HitIndex();
+ int id = fSlice->HitInputID( row, ih );
int gbID = tracker.FirstSliceHit()[fSlice->Param().ISlice()] + id;
- AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[gbID];
vHits[ith].SetID( gbID );
vHits[ith].SetS( 0 );
vHits[ith].SetZ( h.Z() );
for ( int ih = 0; ih < track.NHits(); ih++ ) {
int i = tracker.TrackHits()[ track.FirstHitRef() + ih];
- AliHLTTPCCAGBHit &h = tracker.Hits()[i];
+ const AliHLTTPCCAGBHit &h = tracker.Hits()[i];
vHits[ih].SetID( i );
vHits[ih].SetS( 0 );
vHits[ih].SetZ( h.Z() );
for ( int ih = 0; ih < track.NHits(); ih++ ) {
int i = tracker.TrackHits()[ track.FirstHitRef() + ih];
- AliHLTTPCCAGBHit *h = &( tracker.Hits()[i] );
+ const AliHLTTPCCAGBHit *h = &( tracker.Hits()[i] );
vHits[ih].SetID( i );
vHits[ih].SetS( 0 );
vHits[ih].SetZ( h->Z() );
sort( vHits, vHits + track.NHits(), AliHLTTPCCADisplayTmpHit::CompareHitZ );
int colorY = color;
{
- AliHLTTPCCAGBHit &h1 = tracker.Hits()[ vHits[0].ID()];
- AliHLTTPCCAGBHit &h2 = tracker.Hits()[ vHits[track.NHits()-1].ID()];
+ const AliHLTTPCCAGBHit &h1 = tracker.Hits()[ vHits[0].ID()];
+ const AliHLTTPCCAGBHit &h2 = tracker.Hits()[ vHits[track.NHits()-1].ID()];
if ( color < 0 ) color = GetColorZ( ( h1.Z() + h2.Z() ) / 2. );
double gx1, gy1, gx2, gy2;
Slice2View( h1.X(), h1.Y(), &gx1, &gy1 );
// YX
{
- AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[0].ID()];
- AliHLTTPCCAGBHit &h2 = tracker.Hits()[vHits[track.NHits()-1].ID()];
+ const AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[0].ID()];
+ const AliHLTTPCCAGBHit &h2 = tracker.Hits()[vHits[track.NHits()-1].ID()];
float x1, y1, z1, x2, y2, z2;
double vx1, vy1, vx2, vy2;
}
// ZX
- double py[track.NHits()], pz[track.NHits()];
+ AliHLTResizableArray<double> py( track.NHits() ), pz( track.NHits() );
for ( int iHit = 0; iHit < track.NHits(); iHit++ ) {
- AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[iHit].ID()];
+ const AliHLTTPCCAGBHit &h1 = tracker.Hits()[vHits[iHit].ID()];
float x1, y1, z1;
double vx1, vy1;
if ( h1.ISlice() != oldSlice ) {
fZX->cd();
- pl.DrawPolyLine( track.NHits(), pz, py );
+ pl.DrawPolyLine( track.NHits(), pz.Data(), py.Data() );
fLine.SetLineWidth( 1 );
delete[] vHits;
#ifdef XXX
const AliHLTTPCCARow &row = fSlice->Row( iRow );
- AliHLTTPCCAHit &h = row.Hits()[iHit];
- AliHLTTPCCAHit &hyz = row.HitsYZ()[iHit];
+ const AliHLTTPCCAHit &h = row.Hits()[iHit];
+ const AliHLTTPCCAHit &hyz = row.HitsYZ()[iHit];
double x = row.X();
double y = hyz.Y();
if ( fSlice->HitLinksDown()[] >= 0 ) {
iRow1 = iRow - 1;
iHit1 = h.LinkDown();
- AliHLTTPCCARow &row1 = fSlice->Rows()[iRow1];
+ const AliHLTTPCCARow &row1 = fSlice->Rows()[iRow1];
AliHLTTPCCAHitYZ &h1 = row1.HitsYZ()[iHit1];
x1 = row1.X();
y1 = h1.Y();
if ( h.LinkUp() >= 0 ) {
iRow2 = iRow + 1;
iHit2 = h.LinkUp();
- AliHLTTPCCARow &row2 = fSlice->Rows()[iRow2];
+ const AliHLTTPCCARow &row2 = fSlice->Rows()[iRow2];
AliHLTTPCCAHitYZ &h2 = row2.HitsYZ()[iHit2];
x2 = row2.X();
y2 = h2.Y();
int iHit = 0;
for ( int ih = 0; ih < track.NHits(); ih++ ) {
int i = fSlice->TrackHits()[iID];
- AliHLTTPCCAHit *h = &( fSlice->ID2Hit( i ) );
- AliHLTTPCCARow &row = fSlice->ID2Row( i );
+ const AliHLTTPCCAHit *h = &( fSlice->ID2Hit( i ) );
+ const AliHLTTPCCARow &row = fSlice->ID2Row( i );
vHits[iHit].ID() = i;
vHits[iHit].S() = t.GetS( row.X(), h->Y() );
vHits[iHit].Z() = h->Z();
sort( vHits, vHits + track.NHits(), AliHLTTPCCADisplayTmpHit::CompareHitZ );
//cout<<"Draw track, nhits = "<<nhits<<endl;
{
- AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[0].ID() );
- AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[track.NHits()-1].ID() );
+ const AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[0].ID() );
+ const AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[track.NHits()-1].ID() );
if ( color < 0 ) color = GetColorZ( ( c1.Z() + c2.Z() ) / 2. );
}
fMarker.SetMarkerSize( 1. );
/*
for( int i=0; i<3; i++){
- AliHLTTPCCAHit &c1 = fSlice->ID2Hit(track.HitID()[i]);
- AliHLTTPCCARow &row1 = fSlice->ID2Row(track.HitID()[i]);
+ const AliHLTTPCCAHit &c1 = fSlice->ID2Hit(track.HitID()[i]);
+ const AliHLTTPCCARow &row1 = fSlice->ID2Row(track.HitID()[i]);
double vx1, vy1;
Slice2View(row1.X(), c1.Y(), &vx1, &vy1 );
fYX->cd();
//DrawTrackletPoint( fSlice->ID2Point(track.PointID()[1]).Param(), kBlack);//color );
//cout<<"DrawTrack end points x = "<<fSlice->ID2Point(track.PointID()[0]).Param().GetX()<<" "<<fSlice->ID2Point(track.PointID()[1]).Param().GetX()<<endl;
for ( int iHit = 0; iHit < track.NHits() - 1; iHit++ ) {
- AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[iHit].ID() );
- AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[iHit+1].ID() );
- AliHLTTPCCARow &row1 = fSlice->ID2Row( vHits[iHit].ID() );
- AliHLTTPCCARow &row2 = fSlice->ID2Row( vHits[iHit+1].ID() );
+ const AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[iHit].ID() );
+ const AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[iHit+1].ID() );
+ const AliHLTTPCCARow &row1 = fSlice->ID2Row( vHits[iHit].ID() );
+ const AliHLTTPCCARow &row2 = fSlice->ID2Row( vHits[iHit+1].ID() );
float x1, y1, z1, x2, y2, z2;
t.GetDCAPoint( row1.X(), c1.Y(), c1.Z(), x1, y1, z1, fSlice->Param().Bz() );
t.GetDCAPoint( row2.X(), c2.Y(), c2.Z(), x2, y2, z2, fSlice->Param().Bz() );
}
for ( int iHit = 0; iHit < track.NHits() - 1; iHit++ ) {
- AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[iHit].ID() );
- AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[iHit+1].ID() );
- AliHLTTPCCARow &row1 = fSlice->ID2Row( vHits[iHit].ID() );
- AliHLTTPCCARow &row2 = fSlice->ID2Row( vHits[iHit+1].ID() );
+ const AliHLTTPCCAHit &c1 = fSlice->ID2Hit( vHits[iHit].ID() );
+ const AliHLTTPCCAHit &c2 = fSlice->ID2Hit( vHits[iHit+1].ID() );
+ const AliHLTTPCCARow &row1 = fSlice->ID2Row( vHits[iHit].ID() );
+ const AliHLTTPCCARow &row2 = fSlice->ID2Row( vHits[iHit+1].ID() );
//if( DrawHits ) ConnectHits( fSlice->ID2IRow(vHits[iHit].ID()),c1,
//fSlice->ID2IRow(vHits[iHit+1].ID()),c2, color );
void DrawSliceOutTrack( AliHLTTPCCATrackParam &t, double Alpha, int itr, int color = -1, int width = -1 );
void DrawSliceTrack( int itr, int color = -1 );
bool DrawTrack( AliHLTTPCCATrackParam t, double Alpha, const AliHLTTPCCADisplayTmpHit *vHits,
- int NHits, int color = -1, int width = -1, bool pPoint = 0 );
+ int NHits, int color = -1, int width = -1, bool pPoint = 0 );
void DrawGBTrack( int itr, int color = -1, int width = -1 );
void DrawGBTrackFast( AliHLTTPCCAGBTracker &tracker, int itr, int color = -1 );
#include "AliHLTTPCCADataCompressor.h"
#include "AliHLTTPCCAMath.h"
#include "AliHLTTPCCATrackLinearisation.h"
+#include "AliHLTTPCCAClusterData.h"
#include "TStopwatch.h"
//#define DRAW
AliHLTTPCCADisplay::Instance().Ask();
#endif //DRAW
+ if ( fNHits <= 0 ) return;
std::sort( fHits, fHits + fNHits, AliHLTTPCCAGBHit::Compare );
for ( int i = 0; i < fNHits; i++ ) fExt2IntHitID[fHits[i].ID()] = i;
- // Read hits, row by row
-
- int nHitsTotal = fNHits;
- float *hitX = new float [nHitsTotal];
- float *hitY = new float [nHitsTotal];
- float *hitZ = new float [nHitsTotal];
-
- int *sliceNHits = new int[ fNSlices ];
- int **rowNHits = new int* [fNSlices];
- for ( int i = 0; i < fNSlices; i++ ) rowNHits[i] = new int[200];
-
- for ( int is = 0; is < fNSlices; is++ ) {
- sliceNHits[is] = 0;
- for ( int ir = 0; ir < 200; ir++ ) rowNHits[is][ir] = 0;
- }
-
- for ( int ih = 0; ih < nHitsTotal; ih++ ) {
- AliHLTTPCCAGBHit &h = fHits[ih];
- sliceNHits[h.ISlice()]++;
- rowNHits[h.ISlice()][h.IRow()]++;
- }
-
- int firstSliceHit = 0;
- for ( int is = 0; is < fNSlices; is++ ) {
- fFirstSliceHit[is] = firstSliceHit;
- int rowFirstHits[200];
- int firstRowHit = 0;
- for ( int ir = 0; ir < 200; ir++ ) {
- rowFirstHits[ir] = firstRowHit;
- for ( int ih = 0; ih < rowNHits[is][ir]; ih++ ) {
- AliHLTTPCCAGBHit &h = fHits[firstSliceHit + firstRowHit + ih];
- hitX[firstRowHit + ih] = h.X();
- hitY[firstRowHit + ih] = h.Y();
- hitZ[firstRowHit + ih] = h.Z();
+ AliHLTResizableArray<ClusterData> clusterData( fNSlices );
+ {
+ int offset = 0;
+ int nextSlice = 0;
+ int numberOfUsedSlices = 0;
+ do {
+ fFirstSliceHit[nextSlice] = offset;
+ AliHLTTPCCAClusterData &data = clusterData[numberOfUsedSlices++];
+ data.readEvent( fHits, &offset, fNHits );
+
+ while ( nextSlice < data.Slice() ) {
+ fSlices[nextSlice++].StartEvent();
+ fFirstSliceHit[nextSlice] = fFirstSliceHit[nextSlice - 1];
}
- firstRowHit += rowNHits[is][ir];
+ ++nextSlice;
+ // give the data to the slice tracker
+ fSlices[data.Slice()].ReadEvent( &data );
+ } while ( offset < fNHits );
+ while ( nextSlice < fNSlices ) {
+ fFirstSliceHit[nextSlice] = offset;
+ fSlices[nextSlice++].StartEvent();
}
- fSlices[is].ReadEvent( rowFirstHits, &*rowNHits[is], hitX, hitY, hitZ, sliceNHits[is] );
-
- //int data[ rowNHits[is]]
- //AliHLTTPCCAEventHeader event;
-
- firstSliceHit += sliceNHits[is];
- }
-
- if ( sliceNHits ) delete[] sliceNHits;
- if ( rowNHits ) {
- for ( int i = 0; i < fNSlices; i++ ) delete[] rowNHits[i];
- delete[] rowNHits;
}
- delete[] hitX;
- hitX = 0;
- if ( hitY ) delete[] hitY;
- hitY = 0;
- if ( hitZ ) delete[] hitZ;
- hitZ = 0;
-
- if ( fNHits <= 0 ) return;
-
TStopwatch timer1;
TStopwatch timer2;
//std::cout<<"Start CA reconstruction"<<std::endl;
unsigned int iSlice = AliHLTTPCCADataCompressor::IDsrc2ISlice( iDsrc );
unsigned int iRow = AliHLTTPCCADataCompressor::IDsrc2IRow( iDsrc );
unsigned int iClu = AliHLTTPCCADataCompressor::IDsrc2IClu( iDsrc );
- fTrackHits[nTrackHits+icl] = fFirstSliceHit[iSlice] + fSlices[iSlice].Row( iRow ).FirstHit() + iClu;
+ fTrackHits[nTrackHits++] = fFirstSliceHit[iSlice] + fSlices[iSlice].Row( iRow ).HitNumberOffset() + iClu;
}
- nTrackHits += track.NClusters();
fNTracks++;
}
bool AliHLTTPCCAGBTracker::FitTrack( AliHLTTPCCATrackParam &T, AliHLTTPCCATrackParam t0,
- float &Alpha, int hits[], int &NTrackHits,
- bool dir )
+ float &Alpha, int hits[], int &NTrackHits,
+ bool dir )
{
// Fit the track
out << NHits() << std::endl;
for ( int ih = 0; ih < NHits(); ih++ ) {
- AliHLTTPCCAGBHit &h = fHits[ih];
+ const AliHLTTPCCAGBHit &h = fHits[ih];
out << h.X() << " ";
out << h.Y() << " ";
out << h.Z() << " ";
fSliceTrackerTime = fTime;
fStatTime[0] += fTime;
fStatNEvents++;
- if ( fTrackHits ) delete[] fTrackHits;
+ delete[] fTrackHits;
fTrackHits = 0;
int nTrackHits = 0;
in >> nTrackHits;
for ( int ih = 0; ih < nTrackHits; ih++ ) {
in >> TrackHits()[ih];
}
- if ( fTracks ) delete[] fTracks;
+ delete[] fTracks;
fTracks = 0;
in >> fNTracks;
fTracks = new AliHLTTPCCAGBTrack[fNTracks];
#include "AliHLTTPCCADef.h"
#include "AliHLTTPCCATrackParam.h"
+#include "AliHLTTPCCATracker.h"
+#include "AliHLTTPCCAGBHit.h"
+#include "AliHLTTPCCAGBTrack.h"
#if !defined(HLTCA_GPUCODE)
#include <iostream>
#endif
-class AliHLTTPCCATracker;
-class AliHLTTPCCAGBTrack;
-class AliHLTTPCCAGBHit;
class TParticle;
class TProfile;
class AliHLTTPCCATrackParam;
void Merge();
AliHLTTPCCATracker *Slices() const { return fSlices; }
- AliHLTTPCCAGBHit *Hits() const { return fHits; }
+ const AliHLTTPCCATracker &Slice( int index ) const { return fSlices[index]; }
+ const AliHLTTPCCAGBHit *Hits() const { return fHits; }
+ const AliHLTTPCCAGBHit &Hit( int index ) const { return fHits[index]; }
int Ext2IntHitID( int i ) const { return fExt2IntHitID[i]; }
-
int NHits() const { return fNHits; }
int NSlices() const { return fNSlices; }
double Time() const { return fTime; }
double StatTime( int iTimer ) const { return fStatTime[iTimer]; }
int StatNEvents() const { return fStatNEvents; }
int NTracks() const { return fNTracks; }
- AliHLTTPCCAGBTrack *Tracks() const { return fTracks; }
- int *TrackHits() const { return fTrackHits; }
+ AliHLTTPCCAGBTrack *Tracks() { return fTracks; }
+ const AliHLTTPCCAGBTrack &Track( int i ) const { return fTracks[i]; }
+ int *TrackHits() { return fTrackHits; }
+ int TrackHit( int i ) const { return fTrackHits[i]; }
bool FitTrack( AliHLTTPCCATrackParam &T, AliHLTTPCCATrackParam t0,
- float &Alpha, int hits[], int &NTrackHits,
- bool dir );
+ float &Alpha, int hits[], int &NTrackHits,
+ bool dir );
void WriteSettings( std::ostream &out ) const;
void ReadSettings( std::istream &in );
#include "AliHLTTPCCAGrid.h"
#include "AliHLTTPCCAMath.h"
+#include <assert.h>
#include <iostream>
-GPUd() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, unsigned int n )
+GPUd() void AliHLTTPCCAGrid::CreateEmpty()
{
- //* Create the grid
+ fYMin = 0.f;
+ fYMax = 1.f;
+ fZMin = 0.f;
+ fZMax = 1.f;
- fYMin = CAMath::Min( yMin, yMax );
- fYMax = CAMath::Max( yMin, yMax ) + .1;
- fZMin = CAMath::Min( zMin, zMax );
- fZMax = CAMath::Max( zMin, zMax ) + .1;
- fNy = ( unsigned int ) CAMath::Sqrt( CAMath::Abs( ( float ) n ) );
- fNy = CAMath::Max( fNy, 1 );
- fNz = fNy;
- fN = fNy * fNz;
- fStepYInv = ( fYMax - fYMin );
- fStepZInv = ( fZMax - fZMin );
- //int ky = (fNy>1) ?fNy-1 :1;
- //int kz = (fNz>1) ?fNz-1 :1;
- fStepYInv = ( fStepYInv > 1.e-4 ) ? fNy / fStepYInv : 1;
- fStepZInv = ( fStepZInv > 1.e-4 ) ? fNz / fStepZInv : 1;
+ fNy = 0;
+ fNz = 0;
+ fN = 0;
+
+ fStepYInv = 1.f;
+ fStepZInv = 1.f;
}
+
GPUd() void AliHLTTPCCAGrid::Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz )
{
//* Create the grid
+ fYMin = yMin;
+ fZMin = zMin;
- fYMin = CAMath::Min( yMin, yMax );
- fYMax = CAMath::Max( yMin, yMax ) + .1;
- fZMin = CAMath::Min( zMin, zMax );
- fZMax = CAMath::Max( zMin, zMax ) + .1;
- fStepYInv = 1. / sy;
- fStepZInv = 1. / sz;
+ fStepYInv = 1.f / sy;
+ fStepZInv = 1.f / sz;
+
+ fNy = static_cast<unsigned int>( ( yMax - fYMin ) * fStepYInv + 1.f );
+ fNz = static_cast<unsigned int>( ( zMax - fZMin ) * fStepZInv + 1.f );
+
+ fN = fNy * fNz;
- fNy = ( unsigned int ) ( ( fYMax - fYMin ) * fStepYInv + 1 );
- fNz = ( unsigned int ) ( ( fZMax - fZMin ) * fStepZInv + 1 );
fYMax = fYMin + fNy * sy;
fZMax = fZMin + fNz * sz;
- fN = fNy * fNz;
}
-GPUd() unsigned int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
+
+GPUd() int AliHLTTPCCAGrid::GetBin( float Y, float Z ) const
{
//* get the bin pointer
+ const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
+ const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
+ const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
+ assert( bin >= 0 );
+ assert( bin < static_cast<int>( fN ) );
+ return bin;
+}
- int bbY = ( int ) CAMath::FMulRZ( Y - fYMin, fStepYInv );
- int bbZ = ( int ) CAMath::FMulRZ( Z - fZMin, fStepZInv );
- if ( bbY < 0 ) bbY = 0;
- else if ( bbY >= ( int )fNy ) bbY = fNy - 1;
- if ( bbZ < 0 ) bbZ = 0;
- else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1;
- int bin = CAMath::Mul24( bbZ, fNy ) + bbY;
- return ( unsigned int ) bin;
+int AliHLTTPCCAGrid::GetBinBounded( float Y, float Z ) const
+{
+ //* get the bin pointer
+ const int yBin = static_cast<int>( CAMath::FMulRZ( Y - fYMin, fStepYInv ) );
+ const int zBin = static_cast<int>( CAMath::FMulRZ( Z - fZMin, fStepZInv ) );
+ const int bin = CAMath::Mul24( zBin, fNy ) + yBin;
+ if ( bin < 0 ) return 0;
+ if ( bin >= static_cast<int>( fN ) ) return fN - 1;
+ return bin;
}
-GPUd() void AliHLTTPCCAGrid::GetBin( float Y, float Z, unsigned int &bY, unsigned int &bZ ) const
+GPUd() void AliHLTTPCCAGrid::GetBin( float Y, float Z, int *bY, int *bZ ) const
{
//* get the bin pointer
else if ( bbY >= ( int )fNy ) bbY = fNy - 1;
if ( bbZ < 0 ) bbZ = 0;
else if ( bbZ >= ( int )fNz ) bbZ = fNz - 1;
- bY = ( unsigned int ) bbY;
- bZ = ( unsigned int ) bbZ;
+ *bY = ( unsigned int ) bbY;
+ *bZ = ( unsigned int ) bbZ;
}
* @class AliHLTTPCCAGrid
*
* 2-dimensional grid of pointers.
- * pointers to (y,z)-like objects are assigned to the corresponding grig bin
+ * pointers to (y,z)-like objects are assigned to the corresponding grid bin
* used by AliHLTTPCCATracker to speed-up the hit operations
* grid axis are named Z,Y to be similar to TPC row coordinates.
*/
class AliHLTTPCCAGrid
{
public:
-
- GPUd() void Create( float yMin, float yMax, float zMin, float zMax, unsigned int n );
+ GPUd() void CreateEmpty();
GPUd() void Create( float yMin, float yMax, float zMin, float zMax, float sy, float sz );
- GPUd() unsigned int GetBin( float Y, float Z ) const;
- GPUd() void GetBin( float Y, float Z, unsigned int &bY, unsigned int &bZ ) const ;
-
- GPUd() unsigned int GetBinNoCheck( float Y, float Z ) const {
- unsigned int bY = ( unsigned int ) ( ( Y - fYMin ) * fStepYInv );
- unsigned int bZ = ( unsigned int ) ( ( Z - fZMin ) * fStepZInv );
- return bZ*fNy + bY;
- }
-
- GPUd() void GetBinNoCheck( float Y, float Z, unsigned int &bY, unsigned int &bZ ) const {
- bY = ( unsigned int ) ( ( Y - fYMin ) * fStepYInv );
- bZ = ( unsigned int ) ( ( Z - fZMin ) * fStepZInv );
- }
-
+ GPUd() int GetBin( float Y, float Z ) const;
+ /**
+ * returns -1 if the row is empty == no hits
+ */
+ GPUd() int GetBinBounded( float Y, float Z ) const;
+ GPUd() void GetBin( float Y, float Z, int *bY, int *bZ ) const;
GPUd() unsigned int N() const { return fN; }
GPUd() unsigned int Ny() const { return fNy; }
#include "AliHLTTPCCAHitArea.h"
#include "AliHLTTPCCATracker.h"
+#include "AliHLTTPCCAGrid.h"
#include "AliHLTTPCCAHit.h"
-
-/*
-GPUd() void AliHLTTPCCAHitAreaInit( AliHLTTPCCAHitArea &a, AliHLTTPCCAGrid &grid, const unsigned short *content, unsigned int hitoffset, float y, float z, float dy, float dz )
-{
- // initialisation
-
- a.HitOffset() = hitoffset;
- a.Y() = y;
- a.Z() = z;
- a.MinZ() = z-dz;
- a.MaxZ() = z+dz;
- a.MinY() = y-dy;
- a.MaxY() = y+dy;
- unsigned int bYmin, bZmin, bYmax;
- grid.GetBin(a.MinY(), a.MinZ(), bYmin, bZmin);
- grid.GetBin(a.MaxY(), a.MaxZ(), bYmax, a.BZmax());
- a.BDY() = bYmax - bYmin + 1;
- a.Ny() = grid.Ny();
- a.IndYmin() = bZmin*a.Ny() + bYmin;
- a.Iz() = bZmin;
- a.HitYfst() = content[a.IndYmin()];
- a.HitYlst() = content[a.IndYmin() + a.BDY()];
- a.Ih() = a.HitYfst();
-}
-*/
+#include "AliHLTTPCCARow.h"
-GPUd() void AliHLTTPCCAHitArea::Init( const AliHLTTPCCAGrid &grid, const unsigned short *content, unsigned int hitoffset, float y, float z, float dy, float dz )
+GPUd() void AliHLTTPCCAHitArea::Init( const AliHLTTPCCARow &row, const AliHLTTPCCASliceData &slice, float y, float z,
+ float dy, float dz )
{
//initialisation
-
- fHitOffset = hitoffset;
+ const AliHLTTPCCAGrid &grid = row.Grid();
+ fHitOffset = row.HitNumberOffset();
fY = y;
fZ = z;
fMinZ = z - dz;
fMaxZ = z + dz;
fMinY = y - dy;
fMaxY = y + dy;
- unsigned int bYmin, bZmin, bYmax;
- grid.GetBin( fMinY, fMinZ, bYmin, bZmin );
- grid.GetBin( fMaxY, fMaxZ, bYmax, fBZmax );
- fBDY = bYmax - bYmin + 1;
+ int bYmin, bZmin, bYmax; // boundary bin indexes
+ grid.GetBin( fMinY, fMinZ, &bYmin, &bZmin );
+ grid.GetBin( fMaxY, fMaxZ, &bYmax, &fBZmax );
+ fBDY = bYmax - bYmin + 1; // bin index span in y direction
fNy = grid.Ny();
- fIndYmin = bZmin * fNy + bYmin;
+ fIndYmin = bZmin * fNy + bYmin; // same as grid.GetBin(fMinY, fMinZ), i.e. the smallest bin index of interest
+ // fIndYmin + fBDY then is the largest bin index of interest with the same Z
fIz = bZmin;
- fHitYfst = content[fIndYmin];
- fHitYlst = content[fIndYmin + fBDY];
+
+ // for given fIz (which is min atm.) get
+ fHitYfst = slice.FirstHitInBin( row, fIndYmin ); // first and
+ fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY ); // last hit index in the bin
fIh = fHitYfst;
}
-
-GPUd() int AliHLTTPCCAHitArea::GetNext( AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, const unsigned short *content, AliHLTTPCCAHit &h )
+GPUd() int AliHLTTPCCAHitArea::GetNext( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
+ const AliHLTTPCCASliceData &slice, AliHLTTPCCAHit *h )
{
// get next hit index
- float y0 = row.Grid().YMin();
- float z0 = row.Grid().ZMin();
- float stepY = row.HstepY();
- float stepZ = row.HstepZ();
- const uint4* tmpint4 = tracker.RowData() + row.FullOffset();
- const ushort2 *hits = reinterpret_cast<const ushort2*>( tmpint4 );
+
+ // min coordinate
+ const float y0 = row.Grid().YMin();
+ const float z0 = row.Grid().ZMin();
+
+ // step vector
+ const float stepY = row.HstepY();
+ const float stepZ = row.HstepZ();
int ret = -1;
do {
while ( fIh >= fHitYlst ) {
- if ( fIz >= fBZmax ) return -1;
- fIz++;
+ if ( fIz >= fBZmax ) {
+ return -1;
+ }
+ // go to next z and start y from the min again
+ ++fIz;
fIndYmin += fNy;
- fHitYfst = content[fIndYmin];
- fHitYlst = content[fIndYmin + fBDY];
+ fHitYfst = slice.FirstHitInBin( row, fIndYmin );
+ fHitYlst = slice.FirstHitInBin( row, fIndYmin + fBDY );
fIh = fHitYfst;
}
- {
- ushort2 hh = hits[fIh];
- h.SetY( y0 + hh.x*stepY );
- h.SetZ( z0 + hh.y*stepZ );
- }
- //h = tracker.Hits()[ fHitOffset + fIh ];
+ h->SetY( y0 + tracker.HitDataY( row, fIh ) * stepY );
+ h->SetZ( z0 + tracker.HitDataZ( row, fIh ) * stepZ );
- if ( 1 && ( h.Z() > fMaxZ || h.Z() < fMinZ || h.Y() < fMinY || h.Y() > fMaxY ) ) { //SG!!!
+ if ( 1 && ( h->Z() > fMaxZ || h->Z() < fMinZ || h->Y() < fMinY || h->Y() > fMaxY ) ) { //SG!!!
fIh++;
continue;
}
}
-
-GPUd() int AliHLTTPCCAHitArea::GetBest( AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, const unsigned short *content, AliHLTTPCCAHit &h )
+/*
+int AliHLTTPCCAHitArea::GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
+ const int *content, AliHLTTPCCAHit *h)
{
// get closest hit in the area
int best = -1;
return best;
}
-
+*/
class AliHLTTPCCAGrid;
class AliHLTTPCCATracker;
class AliHLTTPCCARow;
+class AliHLTTPCCASliceData;
/**
* @class ALIHLTTPCCAHitArea
*
+ * This class is used to _iterate_ over the hit data via GetNext
*/
class AliHLTTPCCAHitArea
{
public:
+ GPUd() void Init( const AliHLTTPCCARow &row, const AliHLTTPCCASliceData &slice, float y, float z, float dy, float dz );
- GPUd() void Init( const AliHLTTPCCAGrid &grid, const unsigned short *content, unsigned int hitoffset, float y, float z, float dy, float dz );
+ /**
+ * look up the next hit in the requested area.
+ * Sets h to the coordinates and returns the index for the hit data
+ */
+ int GetNext( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
+ const AliHLTTPCCASliceData &slice, AliHLTTPCCAHit *h );
+ /**
+ * look up the best hit in the next hits in the requested area.
+ * Sets h to the coordinates and returns the index for the hit data
+ *
+ int GetBest( const AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row,
+ const int *content, AliHLTTPCCAHit *h);
+ */
- GPUd() int GetNext( AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, const unsigned short *content, AliHLTTPCCAHit &h );
-
- GPUd() int GetBest( AliHLTTPCCATracker &tracker, const AliHLTTPCCARow &row, const unsigned short *content, AliHLTTPCCAHit &h );
-
- GPUhd() float Y() const { return fY;}
- GPUhd() float Z() const { return fZ;}
- GPUhd() float MinZ() const { return fMinZ;}
- GPUhd() float MaxZ() const { return fMaxZ;}
- GPUhd() float MinY() const { return fMinY;}
- GPUhd() float MaxY() const { return fMaxY;}
- GPUhd() unsigned int BZmax() const { return fBZmax;}
- GPUhd() unsigned int BDY() const { return fBDY;}
- GPUhd() unsigned int IndYmin() const { return fIndYmin;}
- GPUhd() unsigned int Iz() const { return fIz;}
- GPUhd() unsigned int HitYfst() const { return fHitYfst;}
- GPUhd() unsigned int HitYlst() const { return fHitYlst;}
- GPUhd() unsigned int Ih() const { return fIh;}
- GPUhd() unsigned int Ny() const { return fNy;}
- GPUhd() unsigned int HitOffset() const { return fHitOffset;}
+ float Y() const { return fY; }
+ float Z() const { return fZ; }
+ float MinZ() const { return fMinZ; }
+ float MaxZ() const { return fMaxZ; }
+ float MinY() const { return fMinY; }
+ float MaxY() const { return fMaxY; }
+ int BZmax() const { return fBZmax; }
+ int BDY() const { return fBDY; }
+ int IndYmin() const { return fIndYmin; }
+ int Iz() const { return fIz; }
+ int HitYfst() const { return fHitYfst; }
+ int HitYlst() const { return fHitYlst; }
+ int Ih() const { return fIh; }
+ int Ny() const { return fNy; }
+ int HitOffset() const { return fHitOffset; }
protected:
-
- float fY, fZ, fMinZ, fMaxZ, fMinY, fMaxY; // search coordinates
- unsigned int fBZmax, fBDY, fIndYmin, fIz, fHitYfst, fHitYlst, fIh, fNy; // !
- unsigned int fHitOffset; // global hit offset
+ float fY; // search coordinates
+ float fZ; // search coordinates
+ float fMinZ; // search coordinates
+ float fMaxZ; // search coordinates
+ float fMinY; // search coordinates
+ float fMaxY; // search coordinates
+ int fBZmax; // maximal Z bin index
+ int fBDY; // Y distance of bin indexes
+ int fIndYmin; // minimum index for
+ int fIz; // current Z bin index (incremented while iterating)
+ int fHitYfst; //
+ int fHitYlst; //
+ int fIh; // some XXX index in the hit data
+ int fNy; // Number of bins in Y direction
+ int fHitOffset; // global hit offset XXX what's that?
};
#endif
--- /dev/null
+/*
+ Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) version 3.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef ALIHLTTPCCAHITID_H
+#define ALIHLTTPCCAHITID_H
+
+class AliHLTTPCCAHitId
+{
+ public:
+ inline void Set( int row, int hit ) { fId = ( hit << 8 ) | row; }
+ inline int RowIndex() const { return fId & 0xff; }
+ inline int HitIndex() const { return fId >> 8; }
+
+ private:
+ int fId;
+};
+
+#endif // ALIHLTTPCCAHITID_H
bool AliHLTTPCCAMerger::FitTrack( AliHLTTPCCATrackParam &T, float &Alpha,
- AliHLTTPCCATrackParam t0, float Alpha0,
- int hits[], int &NTrackHits, bool dir )
+ AliHLTTPCCATrackParam t0, float Alpha0,
+ int hits[], int &NTrackHits, bool dir )
{
// Fit the track
float AliHLTTPCCAMerger::GetChi2( float x1, float y1, float a00, float a10, float a11,
- float x2, float y2, float b00, float b10, float b11 )
+ float x2, float y2, float b00, float b10, float b11 )
{
//* Calculate Chi2/ndf deviation
float chi2ys = GetChi2( t1.Y(), c * t1.SinPhi(), t1.Cov()[0], c * t1.Cov()[3], t1.Cov()[5],
- t2.Y(), t2.SinPhi(), t2.Cov()[0], t2.Cov()[3], t2.Cov()[5] );
+ t2.Y(), t2.SinPhi(), t2.Cov()[0], t2.Cov()[3], t2.Cov()[5] );
if ( chi2ys > factor2ys ) continue;
float chi2zt = GetChi2( t1.Z(), c * t1.DzDs(), t1.Cov()[2], c * t1.Cov()[7], t1.Cov()[9],
- t2.Z(), t2.DzDs(), t2.Cov()[2], t2.Cov()[7], t2.Cov()[9] );
+ t2.Z(), t2.DzDs(), t2.Cov()[2], t2.Cov()[7], t2.Cov()[9] );
if ( chi2zt > factor2zt ) continue;
if ( 1 ) {// merging track segments withing one slice
- AliHLTTPCCABorderTrack bord[maxNSliceTracks*10];
+ AliHLTResizableArray<AliHLTTPCCABorderTrack> bord( maxNSliceTracks*10 );
AliHLTTPCCASliceTrackInfo *tmpT = new AliHLTTPCCASliceTrackInfo[maxNSliceTracks];
AliHLTTPCCAClusterInfo *tmpH = new AliHLTTPCCAClusterInfo[fMaxClusterInfos];
for ( int iSlice = 0; iSlice < fgkNSlices; iSlice++ ) {
int nBord = 0;
- MakeBorderTracks( iSlice, 4, bord, nBord );
- SplitBorderTracks( iSlice, bord, nBord, iSlice, bord, nBord );
+ MakeBorderTracks( iSlice, 4, bord.Data(), nBord );
+ SplitBorderTracks( iSlice, bord.Data(), nBord, iSlice, bord.Data(), nBord );
int nTr = 0, nH = 0;
int sliceFirstClusterRef = 0;
const AliHLTTPCCAMergerOutput * Output() const { return fOutput; }
bool FitTrack( AliHLTTPCCATrackParam &T, float &Alpha,
- AliHLTTPCCATrackParam t0, float Alpha0, int hits[], int &NHits, bool dir = 0 );
+ AliHLTTPCCATrackParam t0, float Alpha0, int hits[], int &NHits, bool dir = 0 );
private:
int iSlice2, AliHLTTPCCABorderTrack B2[], int N2 );
static float GetChi2( float x1, float y1, float a00, float a10, float a11,
- float x2, float y2, float b00, float b10, float b11 );
+ float x2, float y2, float b00, float b10, float b11 );
void UnpackSlices();
void Merging();
if ( s.fIRow <= s.fNRows - 3 ) {
s.fIRowUp = s.fIRow + 2;
s.fIRowDn = s.fIRow - 2;
- s.fFirstHit = tracker.Row( s.fIRow ).FirstHit();
- const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
- const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
- const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
- s.fHitLinkUp = ( ( short* )( tracker.RowData() + row.FullOffset() ) ) + row.FullLinkOffset();
- s.fHitLinkDn = s.fHitLinkUp + row.NHits();
- s.fDnHitLinkUp = ( ( short* )( tracker.RowData() + rowDn.FullOffset() ) ) + rowDn.FullLinkOffset();
- s.fUpHitLinkDn = ( ( short* )( tracker.RowData() + rowUp.FullOffset() ) ) + rowUp.FullLinkOffset() + rowUp.NHits();
-
s.fNHits = tracker.Row( s.fIRow ).NHits();
}
}
} else if ( iSync == 1 ) {
if ( s.fIRow <= s.fNRows - 3 ) {
+ const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
+ const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
+ const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
+ // - look at up link, if it's valid but the down link in the row above doesn't link to us remove
+ // the link
+ // - look at down link, if it's valid but the up link in the row below doesn't link to us remove
+ // the link
for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
- int up = s.fHitLinkUp[ih];
+ int up = tracker.HitLinkUpData( row, ih );
if ( up >= 0 ) {
- short upDn = s.fUpHitLinkDn[up];
- if ( ( upDn != ih ) ) s.fHitLinkUp[ih] = -1;
+ short upDn = tracker.HitLinkDownData( rowUp, up );
+ if ( ( upDn != ih ) ) tracker.SetHitLinkUpData( row, ih, -1 );
}
- int dn = s.fHitLinkDn[ih];
+ int dn = tracker.HitLinkDownData( row, ih );
if ( dn >= 0 ) {
- short dnUp = s.fDnHitLinkUp[dn];
- if ( dnUp != ih ) s.fHitLinkDn[ih] = -1;
+ short dnUp = tracker.HitLinkUpData( rowDn, dn );
+ if ( dnUp != ih ) tracker.SetHitLinkDownData( row, ih, -1 );
}
}
}
public:
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCASharedMemory()
- : fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ), fNHits( 0 ), fHitLinkDn( 0 ), fHitLinkUp( 0 ), fUpHitLinkDn( 0 ), fDnHitLinkUp( 0 ), fFirstHit( 0 ) {}
+ : fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ), fNHits( 0 ) {}
AliHLTTPCCASharedMemory( const AliHLTTPCCASharedMemory& /*dummy*/ )
- : fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ), fNHits( 0 ), fHitLinkDn( 0 ), fHitLinkUp( 0 ), fUpHitLinkDn( 0 ), fDnHitLinkUp( 0 ), fFirstHit( 0 ) {}
+ : fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ), fNHits( 0 ) {}
AliHLTTPCCASharedMemory& operator=( const AliHLTTPCCASharedMemory& /*dummy*/ ) { return *this; }
#endif
protected:
int fIRowDn; // current row index
int fNRows; // number of rows
int fNHits; // number of hits
- short *fHitLinkDn; // links to the previous row
- short *fHitLinkUp; // links to the next row
- short *fUpHitLinkDn; // links from next row
- short *fDnHitLinkUp; // links from previous row
- int fFirstHit; // index of the first row hit in global arrays
};
GPUd() static int NThreadSyncPoints() { return 1; }
s.fIRow = iBlock;
if ( s.fIRow < s.fNRows ) {
const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
- s.fFirst = row.FirstHit();
s.fNHits = row.NHits();
- s.fHitLinkUp = ( ( short* )( tracker.RowData() + row.FullOffset() ) ) + row.FullLinkOffset();
- s.fHitLinkDn = s.fHitLinkUp + row.NHits();
-
if ( ( s.fIRow >= 2 ) && ( s.fIRow <= s.fNRows - 3 ) ) {
s.fIRowUp = s.fIRow + 2;
s.fIRowDn = s.fIRow - 2;
- s.fFirstDn = tracker.Row( s.fIRowDn ).FirstHit();
- s.fFirstUp = tracker.Row( s.fIRowUp ).FirstHit();
- float xDn = tracker.Row( s.fIRowDn ).X();
- float x = tracker.Row( s.fIRow ).X();
- float xUp = tracker.Row( s.fIRowUp ).X();
+
+ // references to the rows above and below
+ const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
+ const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
+
+ // the axis perpendicular to the rows
+ const float xDn = rowDn.X();
+ const float x = row.X();
+ const float xUp = rowUp.X();
+
+ // number of hits in rows above and below
s.fUpNHits = tracker.Row( s.fIRowUp ).NHits();
- s.fDnNHits = s.fFirst - s.fFirstDn;
+ s.fDnNHits = tracker.Row( s.fIRowDn ).NHits();
+
+ // distance of the rows (absolute and relative)
s.fUpDx = xUp - x;
s.fDnDx = xDn - x;
s.fUpTx = xUp / x;
s.fDnTx = xDn / x;
+ // UpTx/DnTx is used to move the HitArea such that central events are preferred (i.e. vertices
+ // coming from y = 0, z = 0).
+
s.fGridUp = tracker.Row( s.fIRowUp ).Grid();
s.fGridDn = tracker.Row( s.fIRowDn ).Grid();
}
} else if ( iSync == 1 ) {
if ( s.fIRow < s.fNRows ) {
if ( ( s.fIRow == 0 ) || ( s.fIRow == s.fNRows - 1 ) || ( s.fIRow == 1 ) || ( s.fIRow == s.fNRows - 2 ) ) {
+ const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
- s.fHitLinkUp[ih] = -1;
- s.fHitLinkDn[ih] = -1;
+ tracker.SetHitLinkUpData( row, ih, -1 );
+ tracker.SetHitLinkDownData( row, ih, -1 );
}
} else {
const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
- const unsigned short *gContentUp = ( reinterpret_cast<const unsigned short*>( tracker.RowData() + rowUp.FullOffset() ) ) + rowUp.FullGridOffset();
- const unsigned short *gContentDn = ( reinterpret_cast<const unsigned short*>( tracker.RowData() + rowDn.FullOffset() ) ) + rowDn.FullGridOffset();
for ( unsigned int ih = iThread; ih < s.fGridUp.N() + s.fGridUp.Ny() + 2; ih += nThreads ) {
- s.fGridContentUp[ih] = gContentUp[ih];
+ s.fGridContentUp[ih] = tracker.FirstHitInBin( rowUp, ih );
}
for ( unsigned int ih = iThread; ih < s.fGridDn.N() + s.fGridDn.Ny() + 2; ih += nThreads ) {
- s.fGridContentDn[ih] = gContentDn[ih];
+ s.fGridContentDn[ih] = tracker.FirstHitInBin( rowDn, ih );
}
}
}
const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
const AliHLTTPCCARow &rowUp = tracker.Row( s.fIRowUp );
const AliHLTTPCCARow &rowDn = tracker.Row( s.fIRowDn );
- float y0 = row.Grid().YMin();
- float z0 = row.Grid().ZMin();
- float stepY = row.HstepY();
- float stepZ = row.HstepZ();
- const uint4* tmpint4 = tracker.RowData() + row.FullOffset();
- const ushort2 *hits = reinterpret_cast<const ushort2*>( tmpint4 );
+ const float y0 = row.Grid().YMin();
+ const float z0 = row.Grid().ZMin();
+ const float stepY = row.HstepY();
+ const float stepZ = row.HstepZ();
for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
if ( s.fDnNHits > 0 && s.fUpNHits > 0 ) {
int nNeighUp = 0;
- AliHLTTPCCAHit h0;
- {
- ushort2 hh = hits[ih];
- h0.SetY( y0 + hh.x*stepY );
- h0.SetZ( z0 + hh.y*stepZ );
- }
- //h0 = tracker.Hits()[ s.fFirst + ih ];
- float y = h0.Y();
- float z = h0.Z();
+ // coordinates of the hit in the current row
+ const float y = y0 + tracker.HitDataY( row, ih ) * stepY;
+ const float z = z0 + tracker.HitDataZ( row, ih ) * stepZ;
AliHLTTPCCAHitArea areaDn, areaUp;
- areaUp.Init( s.fGridUp, s.fGridContentUp, s.fFirstUp, y*s.fUpTx, z*s.fUpTx, kAreaSize, kAreaSize );
- areaDn.Init( s.fGridDn, s.fGridContentDn, s.fFirstDn, y*s.fDnTx, z*s.fDnTx, kAreaSize, kAreaSize );
+ // TODO: for NVIDIA GPUs it should use the GridContentUp/-Dn that got copied into shared mem
+ areaUp.Init( rowUp, tracker.Data(), y*s.fUpTx, z*s.fUpTx, kAreaSize, kAreaSize );
+ areaDn.Init( rowDn, tracker.Data(), y*s.fDnTx, z*s.fDnTx, kAreaSize, kAreaSize );
do {
AliHLTTPCCAHit h;
- int i = areaUp.GetNext( tracker, rowUp, s.fGridContentUp, h );
+ int i = areaUp.GetNext( tracker, rowUp, tracker.Data(), &h );
if ( i < 0 ) break;
neighUp[nNeighUp] = ( unsigned short ) i;
yzUp[nNeighUp] = CAMath::MakeFloat2( s.fDnDx * ( h.Y() - y ), s.fDnDx * ( h.Z() - z ) );
do {
AliHLTTPCCAHit h;
- int i = areaDn.GetNext( tracker, rowDn, s.fGridContentDn, h );
+ int i = areaDn.GetNext( tracker, rowDn, tracker.Data(), &h );
if ( i < 0 ) break;
nNeighDn++;
}
- s.fHitLinkUp[ih] = linkUp;
- s.fHitLinkDn[ih] = linkDn;
+ tracker.SetHitLinkUpData( row, ih, linkUp );
+ tracker.SetHitLinkDownData( row, ih, linkDn );
#ifdef DRAW
std::cout << "Links for row " << s.fIRow << ", hit " << ih << ": " << linkUp << " " << linkDn << std::endl;
if ( s.fIRow == 22 && ih == 5 ) {
public:
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCASharedMemory()
- : fGridUp(), fGridDn(), fNHits( 0 ), fUpNHits( 0 ), fDnNHits( 0 ), fUpDx( 0 ), fDnDx( 0 ), fUpTx( 0 ), fDnTx( 0 ), fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fFirst( 0 ), fFirstDn( 0 ), fFirstUp( 0 ), fNRows( 0 ), fHitLinkUp( 0 ), fHitLinkDn( 0 ) {}
+ : fGridUp(), fGridDn(), fNHits( 0 ), fUpNHits( 0 ), fDnNHits( 0 ), fUpDx( 0 ), fDnDx( 0 ), fUpTx( 0 ), fDnTx( 0 ), fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ) {}
AliHLTTPCCASharedMemory( const AliHLTTPCCASharedMemory& /*dummy*/ )
- : fGridUp(), fGridDn(), fNHits( 0 ), fUpNHits( 0 ), fDnNHits( 0 ), fUpDx( 0 ), fDnDx( 0 ), fUpTx( 0 ), fDnTx( 0 ), fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fFirst( 0 ), fFirstDn( 0 ), fFirstUp( 0 ), fNRows( 0 ), fHitLinkUp( 0 ), fHitLinkDn( 0 ) {}
+ : fGridUp(), fGridDn(), fNHits( 0 ), fUpNHits( 0 ), fDnNHits( 0 ), fUpDx( 0 ), fDnDx( 0 ), fUpTx( 0 ), fDnTx( 0 ), fIRow( 0 ), fIRowUp( 0 ), fIRowDn( 0 ), fNRows( 0 ) {}
AliHLTTPCCASharedMemory& operator=( const AliHLTTPCCASharedMemory& /*dummy*/ ) { return *this; }
#endif
protected:
int fIRow; // row number
int fIRowUp; // next row number
int fIRowDn;// previous row number
- int fFirst; // index of the first hit
- int fFirstDn; // index of the first hit in the next row
- int fFirstUp;// index of the first hit in the previous row
int fNRows; // number of rows
- short *fHitLinkUp; // links to the next row
- short *fHitLinkDn; // links to the previous row
float2 fA[256][20]; // temp memory
unsigned short fB[256][20]; // temp memory
unsigned short fGridContentUp[7000]; // grid content for the next row
fhPullQPt( 0 ),
fhPullYS( 0 ),
fhPullZT( 0 ),
- fhCluShared( 0 ),
- fhCluResY( 0 ),
- fhCluResZ( 0 ),
- fhCluErrY( 0 ),
- fhCluErrZ( 0 ),
- fhCluPullY( 0 ),
- fhCluPullZ( 0 ),
- fhCluResY1( 0 ),
- fhCluResZ1( 0 ),
- fhCluErrY1( 0 ),
- fhCluErrZ1( 0 ),
- fhCluPullY1( 0 ),
- fhCluPullZ1( 0 ),
- fhCluOrigErrY( 0 ),
- fhCluOrigErrZ( 0 ),
- fhCluOrigPullY( 0 ),
- fhCluOrigPullZ( 0 ),
- fhCluOrigResY1( 0 ),
- fhCluOrigResZ1( 0 ),
- fhCluOrigErrY1( 0 ),
- fhCluOrigErrZ1( 0 ),
- fhCluOrigPullY1( 0 ),
- fhCluOrigPullZ1( 0 ),
+ fhHitErrY( 0 ),
+ fhHitErrZ( 0 ),
+ fhHitResY( 0 ),
+ fhHitResZ( 0 ),
+ fhHitPullY( 0 ),
+ fhHitPullZ( 0 ),
+ fhHitShared( 0 ),
+ fhHitResY1( 0 ),
+ fhHitResZ1( 0 ),
+ fhHitPullY1( 0 ),
+ fhHitPullZ1( 0 ),
fhCellPurity( 0 ),
fhCellNHits( 0 ),
fhCellPurityVsN( 0 ),
fhPullQPt( 0 ),
fhPullYS( 0 ),
fhPullZT( 0 ),
- fhCluShared( 0 ),
- fhCluResY( 0 ),
- fhCluResZ( 0 ),
- fhCluErrY( 0 ),
- fhCluErrZ( 0 ),
- fhCluPullY( 0 ),
- fhCluPullZ( 0 ),
- fhCluResY1( 0 ),
- fhCluResZ1( 0 ),
- fhCluErrY1( 0 ),
- fhCluErrZ1( 0 ),
- fhCluPullY1( 0 ),
- fhCluPullZ1( 0 ),
- fhCluOrigErrY( 0 ),
- fhCluOrigErrZ( 0 ),
- fhCluOrigPullY( 0 ),
- fhCluOrigPullZ( 0 ),
- fhCluOrigResY1( 0 ),
- fhCluOrigResZ1( 0 ),
- fhCluOrigErrY1( 0 ),
- fhCluOrigErrZ1( 0 ),
- fhCluOrigPullY1( 0 ),
- fhCluOrigPullZ1( 0 ),
+ fhHitErrY( 0 ),
+ fhHitErrZ( 0 ),
+ fhHitResY( 0 ),
+ fhHitResZ( 0 ),
+ fhHitPullY( 0 ),
+ fhHitPullZ( 0 ),
+ fhHitShared( 0 ),
+ fhHitResY1( 0 ),
+ fhHitResZ1( 0 ),
+ fhHitPullY1( 0 ),
+ fhHitPullZ1( 0 ),
fhCellPurity( 0 ),
fhCellNHits( 0 ),
fhCellPurityVsN( 0 ),
p.SetTime( Time );
p.SetISlice( iSlice );
float sx, sy, sz;
- fTracker->Slices()[iSlice].Param().Global2Slice( X, Y, Z, &sx, &sy, &sz );
+ fTracker->Slice( iSlice ).Param().Global2Slice( X, Y, Z, &sx, &sy, &sz );
p.SetSx( sx );
p.SetSy( sy );
p.SetSz( sz );
gDirectory->mkdir( "Clusters" );
gDirectory->cd( "Clusters" );
- fhCluShared = new TProfile( "fhCluSharedf", "% of shared Clusters vs row", 160, 0., 160. );
-
- fhCluResY = new TH1D( "resCluY", "Y cluster resoltion [cm]", 100, -2., 2. );
- fhCluResZ = new TH1D( "resCluZ", "Z cluster resoltion [cm]", 100, -2., 2. );
- fhCluErrY = new TH1D( "errCluY", "Y cluster error [cm]", 100, 0., 1. );
- fhCluErrZ = new TH1D( "errCluZ", "Z cluster error [cm]", 100, 0., 1. );
- fhCluPullY = new TH1D( "pullCluY", "Y cluster pull", 50, -10., 10. );
- fhCluPullZ = new TH1D( "pullCluZ", "Z cluster pull", 50, -10., 10. );
-
- fhCluResY1 = new TH1D( "mcFast_resCluY", "Y cluster resoltion [cm], Pt>1", 100, -2., 2. );
- fhCluResZ1 = new TH1D( "mcFast_resCluZ", "Z cluster resoltion [cm], Pt>1", 100, -2., 2. );
- fhCluErrY1 = new TH1D( "mcFast_errCluY", "Y cluster error [cm], Pt>1", 100, 0., 1. );
- fhCluErrZ1 = new TH1D( "mcFast_errCluZ", "Z cluster error [cm], Pt>1", 100, 0., 1. );
- fhCluPullY1 = new TH1D( "mcFast_pullCluY", "Y cluster pull, Pt>1", 50, -10., 10. );
- fhCluPullZ1 = new TH1D( "mcFast_pullCluZ", "Z cluster pull, Pt>1", 50, -10., 10. );
-
- gDirectory->mkdir( "OriginalErrors" );
- gDirectory->cd( "OriginalErrors" );
-
- fhCluOrigErrY = new TH1D( "orig_errCluY", "original Y cluster error [cm]", 100, 0., 1. );
- fhCluOrigErrZ = new TH1D( "orig_errCluZ", "original Z cluster error [cm]", 100, 0., 1. );
- fhCluOrigPullY = new TH1D( "orig_pullCluY", "original Y cluster pull", 50, -10., 10. );
- fhCluOrigPullZ = new TH1D( "orig_pullCluZ", "original Z cluster pull", 50, -10., 10. );
- fhCluOrigErrY1 = new TH1D( "orig_mcFast_errCluY", "original Y cluster error [cm], Pt>1", 100, 0., 1. );
- fhCluOrigErrZ1 = new TH1D( "orig_mcFast_errCluZ", "original Z cluster error [cm], Pt>1", 100, 0., 1. );
- fhCluOrigPullY1 = new TH1D( "orig_mcFast_pullCluY", "original Y cluster pull, Pt>1", 50, -10., 10. );
- fhCluOrigPullZ1 = new TH1D( "orig_mcFast_pullCluZ", "original Z cluster pull, Pt>1", 50, -10., 10. );
+ fhHitShared = new TProfile( "fhHitSharedf", "fhHitShared vs row", 160, 0., 160. );
+
+ fhHitResY = new TH1D( "resHitY", "Y cluster resoltion [cm]", 100, -2., 2. );
+ fhHitResZ = new TH1D( "resHitZ", "Z cluster resoltion [cm]", 100, -2., 2. );
+ fhHitPullY = new TH1D( "pullHitY", "Y cluster pull", 50, -10., 10. );
+ fhHitPullZ = new TH1D( "pullHitZ", "Z cluster pull", 50, -10., 10. );
+
+ fhHitResY1 = new TH1D( "resHitY1", "Y cluster resoltion [cm]", 100, -2., 2. );
+ fhHitResZ1 = new TH1D( "resHitZ1", "Z cluster resoltion [cm]", 100, -2., 2. );
+ fhHitPullY1 = new TH1D( "pullHitY1", "Y cluster pull", 50, -10., 10. );
+ fhHitPullZ1 = new TH1D( "pullHitZ1", "Z cluster pull", 50, -10., 10. );
+
+ fhHitErrY = new TH1D( "HitErrY", "Y cluster error [cm]", 100, 0., 1. );
+ fhHitErrZ = new TH1D( "HitErrZ", "Z cluster error [cm]", 100, 0., 1. );
- gDirectory->cd( ".." );
gDirectory->cd( ".." );
gDirectory->mkdir( "Cells" );
// Efficiency and quality of the found neighbours
std::cout << "Link performance..." << std::endl;
if ( !fTracker ) return;
- AliHLTTPCCATracker &slice = fTracker->Slices()[iSlice];
-
- const int *id = slice.HitInputIDs();
+ const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
- int mcType[fNMCTracks];
+ AliHLTResizableArray<int> mcType( fNMCTracks );
for ( int imc = 0; imc < fNMCTracks; imc++ ) {
if ( fMCTracks[imc].P() < .2 ) { mcType[imc] = -1; continue; }
const AliHLTTPCCARow &rowUp = slice.Row( iRow + 2 );
const AliHLTTPCCARow &rowDn = slice.Row( iRow - 2 );
- int gbHits [row.NHits()];
- int gbHitsUp[rowUp.NHits()];
- int gbHitsDn[rowDn.NHits()];
+ AliHLTResizableArray<int> gbHits ( row.NHits() );
+ AliHLTResizableArray<int> gbHitsUp( rowUp.NHits() );
+ AliHLTResizableArray<int> gbHitsDn( rowDn.NHits() );
- for ( int ih = 0; ih < row.NHits() ; ih++ ) gbHits [ih] = fTracker->FirstSliceHit()[iSlice] + id[row .FirstHit()+ih];
- for ( int ih = 0; ih < rowUp.NHits(); ih++ ) gbHitsUp[ih] = fTracker->FirstSliceHit()[iSlice] + id[rowUp.FirstHit()+ih];
- for ( int ih = 0; ih < rowDn.NHits(); ih++ ) gbHitsDn[ih] = fTracker->FirstSliceHit()[iSlice] + id[rowDn.FirstHit()+ih];
+ for ( int ih = 0; ih < row.NHits() ; ih++ ) gbHits [ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( row , ih );
+ for ( int ih = 0; ih < rowUp.NHits(); ih++ ) gbHitsUp[ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( rowUp, ih );
+ for ( int ih = 0; ih < rowDn.NHits(); ih++ ) gbHitsDn[ih] = fTracker->FirstSliceHit()[iSlice] + slice.HitInputID( rowDn, ih );
for ( int imc = 0; imc < fNMCTracks; imc++ ) {
mcGbHitsUp[imc].fNHits = 0;
}
}
- short *linkUp = ( ( short* )( slice.RowData() + row.FullOffset() ) ) + row.FullLinkOffset();
- short *linkDn = linkUp + row.NHits();
-
//float dxUp = rowUp.X() - row.X();
//float dxDn = row.X() - rowDn.X();
float tUp = rowUp.X() / row.X();
for ( int ih = 0; ih < row.NHits(); ih++ ) {
- int up = linkUp[ih];
- int dn = linkDn[ih];
+ int up = slice.HitLinkUpData( row, ih );
+ int dn = slice.HitLinkDownData( row, ih );
- AliHLTTPCCAGBHit &h = fTracker->Hits()[gbHits[ih]];
+ const AliHLTTPCCAGBHit &h = fTracker->Hits()[gbHits[ih]];
AliHLTTPCCAHitLabel &l = fHitLabels[h.ID()];
int isMC = -1;
float dyMin = 1.e8, dzMin = 1.e8;
for ( int i = 0; i < mcGbHitsUp[imc].fNHits; i++ ) {
- AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsUp[imc].fID[i]];
+ const AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsUp[imc].fID[i]];
float dy = TMath::Abs( h1.Y() - yUp );
float dz = TMath::Abs( h1.Z() - zUp );
if ( dy*dy + dz*dz < dyMin*dyMin + dzMin*dzMin ) {
dyMin = 1.e8;
dzMin = 1.e8;
for ( int i = 0; i < mcGbHitsDn[imc].fNHits; i++ ) {
- AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsDn[imc].fID[i]];
+ const AliHLTTPCCAGBHit &h1 = fTracker->Hits()[mcGbHitsDn[imc].fID[i]];
float dy = TMath::Abs( h1.Y() - yDn );
float dz = TMath::Abs( h1.Z() - zDn );
if ( dy*dy + dz*dz < dyMin*dyMin + dzMin*dzMin ) {
bool found = 0;
if ( up >= 0 && dn >= 0 ) {
//std::cout<<"row, ih, mc, up, dn = "<<iRow<<" "<<ih<<" "<<imc<<" "<<up<<" "<<dn<<std::endl;
- AliHLTTPCCAGBHit &hUp = fTracker->Hits()[gbHitsUp[up]];
- AliHLTTPCCAGBHit &hDn = fTracker->Hits()[gbHitsDn[dn]];
+ const AliHLTTPCCAGBHit &hUp = fTracker->Hits()[gbHitsUp[up]];
+ const AliHLTTPCCAGBHit &hDn = fTracker->Hits()[gbHitsDn[dn]];
AliHLTTPCCAHitLabel &lUp = fHitLabels[hUp.ID()];
AliHLTTPCCAHitLabel &lDn = fHitLabels[hDn.ID()];
bool foundUp = 0, foundDn = 0;
int nRecTot = 0, nGhost = 0, nRecOut = 0;
int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
- AliHLTTPCCATracker &slice = fTracker->Slices()[iSlice];
+ const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
int firstSliceHit = fTracker->FirstSliceHit()[iSlice];
int endSliceHit = fTracker->NHits();
}
- int traN = *slice.NTracklets();
+ int traN = slice.NTracklets();
int *traLabels = 0;
double *traPurity = 0;
int nHits = 0;
{
- int id = slice.TrackletStartHits()[itr];
- int iRow = AliHLTTPCCATracker::ID2IRow( id );
- int ih = AliHLTTPCCATracker::ID2IHit( id );
+ const AliHLTTPCCAHitId &id = slice.TrackletStartHit( itr );
+ int iRow = id.RowIndex();
+ int ih = id.HitIndex();
while ( ih >= 0 ) {
const AliHLTTPCCARow &row = slice.Row( iRow );
- hits[nHits] = firstSliceHit + slice.HitInputIDs()[row.FirstHit()+ih];
+ hits[nHits] = firstSliceHit + slice.HitInputID( row, ih );
nHits++;
- short *linkUp = ( ( short* )( slice.RowData() + row.FullOffset() ) ) + row.FullLinkOffset();
- ih = linkUp[ih];
+ ih = slice.HitLinkUpData( row, ih );
iRow++;
}
}
int nRecTot = 0, nGhost = 0, nRecOut = 0;
int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
- AliHLTTPCCATracker &slice = fTracker->Slices()[iSlice];
+ const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
int firstSliceHit = fTracker->FirstSliceHit()[iSlice];
int endSliceHit = fTracker->NHits();
}
}
- int traN = *slice.NTracklets();
+ int traN = slice.NTracklets();
int *traLabels = 0;
double *traPurity = 0;
traLabels = new int[traN];
traLabels[itr] = -1;
traPurity[itr] = 0;
- AliHLTTPCCATracklet &t = slice.Tracklets()[itr];
+ const AliHLTTPCCATracklet &t = slice.Tracklet( itr );
int nHits = t.NHits();
if ( nHits < 10 ) continue;
for ( int irow = firstRow; irow <= lastRow; irow++ ) {
int ih = t.RowHit( irow );
if ( ih < 0 ) continue;
- int index = firstSliceHit + slice.HitInputIDs()[slice.Row( irow ).FirstHit()+ih];
+ int index = firstSliceHit + slice.HitInputID( slice.Row( irow ), ih );
AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
for ( int irow = firstRow; irow <= lastRow; irow++ ) {
int ih = t.RowHit( irow );
if ( ih < 0 ) continue;
- int index = firstSliceHit + slice.HitInputIDs()[slice.Row( irow ).FirstHit()+ih];
+ int index = firstSliceHit + slice.HitInputID( slice.Row( irow ), ih );
AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
) lmax++;
int nRecTot = 0, nGhost = 0, nRecOut = 0;
int nMCAll = 0, nRecAll = 0, nClonesAll = 0;
int nMCRef = 0, nRecRef = 0, nClonesRef = 0;
- AliHLTTPCCATracker &slice = fTracker->Slices()[iSlice];
+ const AliHLTTPCCATracker &slice = fTracker->Slice( iSlice );
int firstSliceHit = 0;
for ( ; firstSliceHit < fTracker->NHits(); firstSliceHit++ ) {
- if ( fTracker->Hits()[firstSliceHit].ISlice() == iSlice ) break;
+ if ( fTracker->Hit( firstSliceHit ).ISlice() == iSlice ) break;
}
int endSliceHit = firstSliceHit;
for ( ; endSliceHit < fTracker->NHits(); endSliceHit++ ) {
- if ( fTracker->Hits()[endSliceHit].ISlice() != iSlice ) break;
+ if ( fTracker->Hit( endSliceHit ).ISlice() != iSlice ) break;
}
for ( int imc = 0; imc < fNMCTracks; imc++ ) fMCTracks[imc].SetNHits( 0 );
for ( int ih = firstSliceHit; ih < endSliceHit; ih++ ) {
- int id = fTracker->Hits()[ih].ID();
+ int id = fTracker->Hit( ih ).ID();
if ( id < 0 || id > fNHits ) break;
AliHLTTPCCAHitLabel &l = fHitLabels[id];
if ( l.fLab[0] >= 0 ) fMCTracks[l.fLab[0]].SetNHits( fMCTracks[l.fLab[0]].NHits() + 1 );
for ( int itr = 0; itr < traN; itr++ ) {
traLabels[itr] = -1;
traPurity[itr] = 0;
- AliHLTTPCCAOutTrack &tCA = slice.OutTracks()[itr];
+ const AliHLTTPCCAOutTrack &tCA = slice.OutTrack( itr );
int nhits = tCA.NHits();
int *lb = new int[nhits*3];
int nla = 0;
//cout<<"\nHit labels:"<<endl;
for ( int ihit = 0; ihit < nhits; ihit++ ) {
- int index = firstSliceHit + slice.OutTrackHits()[tCA.FirstHitRef()+ihit];
- AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
+ const int index = firstSliceHit + slice.OutTrackHit( tCA.FirstHitRef() + ihit );
+ const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
//cout<<l.fLab[0]<<" "<<l.fLab[1]<<" "<<l.fLab[2]<<endl;
if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
}
lmax = 0;
for ( int ihit = 0; ihit < nhits; ihit++ ) {
- int index = firstSliceHit + slice.OutTrackHits()[tCA.FirstHitRef()+ihit];
- AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
+ const int index = firstSliceHit + slice.OutTrackHit( tCA.FirstHitRef() + ihit );
+ const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
) lmax++;
}
for ( int itr = 0; itr < traN; itr++ ) {
traLabels[itr] = -1;
traPurity[itr] = 0;
- AliHLTTPCCAGBTrack &tCA = fTracker->Tracks()[itr];
- int nhits = tCA.NHits();
+ const AliHLTTPCCAGBTrack &tCA = fTracker->Track( itr );
+ const int nhits = tCA.NHits();
int *lb = new int[nhits*3];
int nla = 0;
for ( int ihit = 0; ihit < nhits; ihit++ ) {
- int index = fTracker->TrackHits()[tCA.FirstHitRef()+ihit];
- AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
+ const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
+ const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
if ( l.fLab[0] >= 0 ) lb[nla++] = l.fLab[0];
if ( l.fLab[1] >= 0 ) lb[nla++] = l.fLab[1];
if ( l.fLab[2] >= 0 ) lb[nla++] = l.fLab[2];
}
lmax = 0;
for ( int ihit = 0; ihit < nhits; ihit++ ) {
- int index = fTracker->TrackHits()[tCA.FirstHitRef()+ihit];
- AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hits()[index].ID()];
+ const int index = fTracker->TrackHit( tCA.FirstHitRef() + ihit );
+ const AliHLTTPCCAHitLabel &l = fHitLabels[fTracker->Hit( index ).ID()];
if ( l.fLab[0] == labmax || l.fLab[1] == labmax || l.fLab[2] == labmax
) lmax++;
}
nGhost++;
continue;
}
- AliHLTTPCCAGBTrack &tCA = fTracker->Tracks()[itr];
+ const AliHLTTPCCAGBTrack &tCA = fTracker->Track( itr );
AliHLTTPCCAMCTrack &mc = fMCTracks[traLabels[itr]];
mc.SetNReconstructed( mc.NReconstructed() + 1 );
// track resolutions
while ( mc.Set() == 2 && TMath::Abs( mc.TPCPar()[0] ) + TMath::Abs( mc.TPCPar()[1] ) > 1 ) {
if ( traPurity[itr] < .90 ) break;
- AliHLTTPCCAGBTrack &t = fTracker->Tracks()[itr];
+ const AliHLTTPCCAGBTrack &t = fTracker->Track( itr );
AliHLTTPCCATrackParam p = t.Param();
double cosA = TMath::Cos( t.Alpha() );
double sinA = TMath::Sin( t.Alpha() );
double mcPt = 1. / TMath::Abs( mcQPt );
if ( mcPt < 1. ) break;
if ( t.NHits() < 50 ) break;
- double bz = fTracker->Slices()[0].Param().Bz();
+ double bz = fTracker->Slice( 0 ).Param().Bz();
if ( !p.TransportToXWithMaterial( mcX, bz ) ) break;
if ( p.GetCosPhi()*mcEx < 0 ) { // change direction
mcSinPhi = -mcSinPhi;
{
int nHits = fTracker->NHits();
for ( int ih = 0; ih < nHits; ih++ ) {
- AliHLTTPCCAGBHit &hit = fTracker->Hits()[ih];
+ const AliHLTTPCCAGBHit &hit = fTracker->Hit( ih );
AliHLTTPCCAHitLabel &l = fHitLabels[hit.ID()];
- fhCluOrigErrY->Fill( hit.ErrY() );
- fhCluOrigErrZ->Fill( hit.ErrZ() );
+ fhHitErrY->Fill( hit.ErrY() );
+ fhHitErrZ->Fill( hit.ErrZ() );
int nmc = 0;
for ( int il = 0; il < 3; il++ ) if ( l.fLab[il] >= 0 ) nmc++;
- if ( nmc == 1 ) {
- fhCluShared->Fill( hit.IRow(), 0 );
- AliHLTTPCCAMCTrack &track = fMCTracks[l.fLab[0]];
- if ( track.Pt() >= 1 ) {
- fhCluOrigErrY1->Fill( hit.ErrY() );
- fhCluOrigErrZ1->Fill( hit.ErrZ() );
- }
- } else if ( nmc > 1 ) fhCluShared->Fill( hit.IRow(), 1 );
+ if ( nmc == 1 ) fhHitShared->Fill( hit.IRow(), 0 );
+ else if ( nmc > 1 ) fhHitShared->Fill( hit.IRow(), 1 );
}
}
for ( int ih = 0; ih < fNHits; ih++ ) {
- AliHLTTPCCAGBHit &hit = fTracker->Hits()[ih];
- AliHLTTPCCAHitLabel &l = fHitLabels[ih];
+ const AliHLTTPCCAGBHit &hit = fTracker->Hit( ih );
+ const AliHLTTPCCAHitLabel &l = fHitLabels[ih];
if ( l.fLab[0] < 0 || l.fLab[0] >= fNMCTracks
|| l.fLab[1] >= 0 || l.fLab[2] >= 0 ) continue;
double dz = p2.Sz() - p1.Sz();
if ( TMath::Abs( dx ) > 1.e-8 && TMath::Abs( p1.Sx() - hit.X() ) < 2. && TMath::Abs( p2.Sx() - hit.X() ) < 2. ) {
double sx = hit.X();
- double sy = p1.Sy() + dy / dx * ( sx - p1.Sx() );
+ //double sy = p1.Sy() + dy/dx*(sx-p1.Sx());
double sz = p1.Sz() + dz / dx * ( sx - p1.Sx() );
- float errY, errZ;
+ //float errY, errZ;
{
- float sinPhi = dy / TMath::Sqrt( dx * dx + dy * dy );
- float cosPhi = dx / TMath::Sqrt( dx * dx + dy * dy );
- float dzDs = dz / TMath::Sqrt( dx * dx + dy * dy );
- fTracker->Slices()[hit.ISlice()].Param().GetClusterErrors2( hit.IRow(), sz, sinPhi, cosPhi, dzDs, errY, errZ );
- errY = TMath::Sqrt( errY );
- errZ = TMath::Sqrt( errZ );
+ AliHLTTPCCATrackParam t;
+ t.SetZ( sz );
+ t.SetSinPhi( dy / TMath::Sqrt( dx*dx + dy*dy ) );
+ t.SetSignCosPhi( dx );
+ t.SetDzDs( dz / TMath::Sqrt( dx*dx + dy*dy ) );
+ //fTracker->GetErrors2(hit,t,errY, errZ );
+ //errY = TMath::Sqrt(errY);
+ //errZ = TMath::Sqrt(errZ);
}
-
- float oErrY = hit.ErrY();
- float oErrZ = hit.ErrZ();
-
- fhCluErrY->Fill( errY );
- fhCluErrZ->Fill( errZ );
- fhCluResY->Fill( ( hit.Y() - sy ) );
- fhCluResZ->Fill( ( hit.Z() - sz ) );
- fhCluPullY->Fill( ( hit.Y() - sy ) / errY );
- fhCluPullZ->Fill( ( hit.Z() - sz ) / errZ );
- fhCluOrigPullY->Fill( ( hit.Y() - sy ) / oErrY );
- fhCluOrigPullZ->Fill( ( hit.Z() - sz ) / oErrZ );
- if ( track.Pt() >= 1. ) {
- fhCluErrY1->Fill( errY );
- fhCluErrZ1->Fill( errZ );
- fhCluResY1->Fill( ( hit.Y() - sy ) );
- fhCluResZ1->Fill( ( hit.Z() - sz ) );
- fhCluPullY1->Fill( ( hit.Y() - sy ) / errY );
- fhCluPullZ1->Fill( ( hit.Z() - sz ) / errZ );
- fhCluOrigPullY1->Fill( ( hit.Y() - sy ) / oErrY );
- fhCluOrigPullZ1->Fill( ( hit.Z() - sz ) / oErrZ );
+ /*
+ fhHitResY->Fill((hit.Y()-sy));
+ fhHitResZ->Fill((hit.Z()-sz));
+ fhHitPullY->Fill((hit.Y()-sy)/errY);
+ fhHitPullZ->Fill((hit.Z()-sz)/errZ);
+ if( track.Pt()>=1. ){
+ fhHitResY1->Fill((hit.Y()-sy));
+ fhHitResZ1->Fill((hit.Z()-sz));
+ fhHitPullY1->Fill((hit.Y()-sy)/errY);
+ fhHitPullZ1->Fill((hit.Z()-sz)/errZ);
}
+ */
}
}
}
*fhPullYS, //* sqrt(chi2/ndf) deviation of the track parameters Y and SinPhi at the TPC entrance
*fhPullZT; //* sqrt(chi2/ndf) deviation of the track parameters Z and DzDs at the TPC entrance
- TProfile *fhCluShared; //* ratio of the shared clusters
-
TH1D
- *fhCluResY, //* cluster resolution Y
- *fhCluResZ, //* cluster resolution Z
- *fhCluErrY, //* cluster error in Y
- *fhCluErrZ, //* cluster error in Z
- *fhCluPullY, //* cluster pull Y
- *fhCluPullZ, //* cluster pull Z
- *fhCluResY1, //* cluster resolution Y, Pt>1
- *fhCluResZ1, //* cluster resolution Z, Pt>1
- *fhCluErrY1, //* cluster error in Y, Pt>1
- *fhCluErrZ1, //* cluster error in Z, Pt>1
- *fhCluPullY1,//* cluster pull Y, Pt>1
- *fhCluPullZ1,//* cluster pull Z, Pt>1
- *fhCluOrigErrY, //* cluster original error in Y
- *fhCluOrigErrZ, //* cluster original error in Z
- *fhCluOrigPullY, //* cluster original pull Y
- *fhCluOrigPullZ, //* cluster original pull Z
- *fhCluOrigResY1, //* cluster original resolution Y, Pt>1
- *fhCluOrigResZ1, //* cluster original resolution Z, Pt>1
- *fhCluOrigErrY1, //* cluster original error in Y, Pt>1
- *fhCluOrigErrZ1, //* cluster original error in Z, Pt>1
- *fhCluOrigPullY1,//* cluster original pull Y, Pt>1
- *fhCluOrigPullZ1;//* cluster original pull Z, Pt>1
+ *fhHitErrY, //* hit error in Y
+ *fhHitErrZ,//* hit error in Z
+ *fhHitResY,//* hit resolution Y
+ *fhHitResZ,//* hit resolution Z
+ *fhHitPullY,//* hit pull Y
+ *fhHitPullZ;//* hit pull Z
+ TProfile *fhHitShared; //* ratio of the shared clusters
+ TH1D
+ *fhHitResY1,//* hit resolution Y, pt>1GeV
+ *fhHitResZ1,//* hit resolution Z, pt>1GeV
+ *fhHitPullY1,//* hit pull Y, pt>1GeV
+ *fhHitPullZ1;//* hit pull Z, pt>1GeV
TH1D
*fhCellPurity,//* cell purity
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCARow::AliHLTTPCCARow()
:
- fFirstHit( 0 ), fNHits( 0 ), fX( 0 ), fMaxY( 0 ), fGrid(),
+ fNHits( 0 ), fX( 0 ), fMaxY( 0 ), fGrid(),
fHy0( 0 ), fHz0( 0 ), fHstepY( 0 ), fHstepZ( 0 ), fHstepYi( 0 ), fHstepZi( 0 ),
- fFullSize( 0 ), fFullOffset( 0 ), fFullGridOffset( 0 ), fFullLinkOffset( 0 )
+ fFullSize( 0 ), fHitNumberOffset( 0 ), fFirstHitInBinOffset( 0 )
{
// dummy constructor
}
*/
class AliHLTTPCCARow
{
+ friend class AliHLTTPCCASliceData;
public:
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCARow();
#endif
- GPUhd() int FirstHit() const { return fFirstHit; }
GPUhd() int NHits() const { return fNHits; }
GPUhd() float X() const { return fX; }
GPUhd() float MaxY() const { return fMaxY; }
GPUhd() const AliHLTTPCCAGrid &Grid() const { return fGrid; }
- GPUhd() float Hy0() const { return fHy0;}
- GPUhd() float Hz0() const { return fHz0;}
- GPUhd() float HstepY() const { return fHstepY;}
- GPUhd() float HstepZ() const { return fHstepZ;}
- GPUhd() float HstepYi() const { return fHstepYi;}
- GPUhd() float HstepZi() const { return fHstepZi;}
- GPUhd() int FullSize() const { return fFullSize;}
- GPUhd() int FullOffset() const { return fFullOffset;}
- GPUhd() int FullGridOffset() const { return fFullGridOffset;}
- GPUhd() int FullLinkOffset() const { return fFullLinkOffset;}
-
- GPUhd() void SetFirstHit( int v ) { fFirstHit = v; }
- GPUhd() void SetNHits( int v ) { fNHits = v; }
- GPUhd() void SetX( float v ) { fX = v; }
- GPUhd() void SetMaxY( float v ) { fMaxY = v; }
- GPUhd() void SetGrid( const AliHLTTPCCAGrid &v ) { fGrid = v; }
-
- GPUhd() void SetHy0( float v ) { fHy0 = v;}
- GPUhd() void SetHz0( float v ) { fHz0 = v;}
- GPUhd() void SetHstepY( float v ) { fHstepY = v;}
- GPUhd() void SetHstepZ( float v ) { fHstepZ = v;}
- GPUhd() void SetHstepYi( float v ) { fHstepYi = v;}
- GPUhd() void SetHstepZi( float v ) { fHstepZi = v;}
- GPUhd() void SetFullSize( int v ) { fFullSize = v;}
- GPUhd() void SetFullOffset( int v ) { fFullOffset = v;}
- GPUhd() void SetFullGridOffset( int v ) { fFullGridOffset = v;}
- GPUhd() void SetFullLinkOffset( int v ) { fFullLinkOffset = v;}
+ GPUhd() float Hy0() const { return fHy0; }
+ GPUhd() float Hz0() const { return fHz0; }
+ GPUhd() float HstepY() const { return fHstepY; }
+ GPUhd() float HstepZ() const { return fHstepZ; }
+ GPUhd() float HstepYi() const { return fHstepYi; }
+ GPUhd() float HstepZi() const { return fHstepZi; }
+ GPUhd() int FullSize() const { return fFullSize; }
+ GPUhd() int HitNumberOffset() const { return fHitNumberOffset; }
+ GPUhd() unsigned int FirstHitInBinOffset() const { return fFirstHitInBinOffset; }
private:
-
- int fFirstHit; // index of the first hit in the hit array
int fNHits; // number of hits
float fX; // X coordinate of the row
float fMaxY; // maximal Y coordinate of the row
AliHLTTPCCAGrid fGrid; // grid of hits
- float fHy0, fHz0, fHstepY, fHstepZ, fHstepYi, fHstepZi; // temporary variables
- int fFullSize, fFullOffset, fFullGridOffset, fFullLinkOffset; // temporary variables
+ // hit packing:
+ float fHy0; // offset
+ float fHz0; // offset
+ float fHstepY; // step size
+ float fHstepZ; // step size
+ float fHstepYi; // inverse step size
+ float fHstepZi; // inverse step size
+ int fFullSize; // size of this row in Tracker::fRowData
+ int fHitNumberOffset; // index of the first hit in the hit array, used as
+ // offset in AliHLTTPCCASliceData::LinkUp/DownData/HitDataY/...
+ unsigned int fFirstHitInBinOffset; // offset in Tracker::fRowData to find the FirstHitInBin
};
#endif
--- /dev/null
+/*
+ Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) version 3.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#include "AliHLTTPCCASliceData.h"
+#include "AliHLTTPCCAClusterData.h"
+#include "AliHLTTPCCAMath.h"
+#include "AliHLTArray.h"
+#include "AliHLTTPCCAHit.h"
+#include "AliHLTTPCCAParam.h"
+#include "MemoryAssignmentHelpers.h"
+#include <iostream>
+
+// calculates an approximation for 1/sqrt(x)
+// Google for 0x5f3759df :)
+static inline float fastInvSqrt( float _x )
+{
+ union { float f; int i; } x = { _x };
+ const float xhalf = 0.5f * x.f;
+ x.i = 0x5f3759df - ( x.i >> 1 );
+ x.f = x.f * ( 1.5f - xhalf * x.f * x.f );
+ return x.f;
+}
+
+inline void AliHLTTPCCASliceData::createGrid( AliHLTTPCCARow *row, const AliHLTTPCCAClusterData &data )
+{
+ if ( row->NHits() <= 0 ) { // no hits or invalid data
+ // grid coordinates don't matter, since there are no hits
+ row->fGrid.CreateEmpty();
+ return;
+ }
+
+ float yMin = 1.e3f;
+ float yMax = -1.e3f;
+ float zMin = 1.e3f;
+ float zMax = -1.e3f;
+ for ( int i = row->fHitNumberOffset; i < row->fHitNumberOffset + row->fNHits; ++i ) {
+ const float y = data.Y( i );
+ const float z = data.Z( i );
+ if ( yMax < y ) yMax = y;
+ if ( yMin > y ) yMin = y;
+ if ( zMax < z ) zMax = z;
+ if ( zMin > z ) zMin = z;
+ }
+
+ const float norm = fastInvSqrt( row->fNHits );
+ row->fGrid.Create( yMin, yMax, zMin, zMax,
+ CAMath::Max( ( yMax - yMin ) * norm, 2.f ),
+ CAMath::Max( ( zMax - zMin ) * norm, 2.f ) );
+}
+
+inline void AliHLTTPCCASliceData::PackHitData( AliHLTTPCCARow *row, const AliHLTArray<AliHLTTPCCAHit> &binSortedHits )
+{
+ static const float shortPackingConstant = 1.f / 65535.f;
+ const float y0 = row->fGrid.YMin();
+ const float z0 = row->fGrid.ZMin();
+ const float stepY = ( row->fGrid.YMax() - y0 ) * shortPackingConstant;
+ const float stepZ = ( row->fGrid.ZMax() - z0 ) * shortPackingConstant;
+ const float stepYi = 1.f / stepY;
+ const float stepZi = 1.f / stepZ;
+
+ row->fHy0 = y0;
+ row->fHz0 = z0;
+ row->fHstepY = stepY;
+ row->fHstepZ = stepZ;
+ row->fHstepYi = stepYi;
+ row->fHstepZi = stepZi;
+
+ for ( int hitIndex = 0; hitIndex < row->fNHits; ++hitIndex ) {
+ // bin sorted index!
+ const int globalHitIndex = row->fHitNumberOffset + hitIndex;
+ const AliHLTTPCCAHit &hh = binSortedHits[globalHitIndex];
+ const float xx = ( ( hh.Y() - y0 ) * stepYi ) + .5 ;
+ const float yy = ( ( hh.Z() - z0 ) * stepZi ) + .5 ;
+ if ( xx < 0 || yy < 0 || xx >= 65536 || yy >= 65536 ) {
+ std::cout << "!!!! hit packing error!!! " << xx << " " << yy << " " << std::endl;
+ }
+ // HitData is bin sorted
+ fHitDataY[row->fHitNumberOffset + hitIndex] = xx;
+ fHitDataZ[row->fHitNumberOffset + hitIndex] = yy;
+ }
+}
+
+void AliHLTTPCCASliceData::Clear()
+{
+ fNumberOfHits = 0;
+}
+
+void AliHLTTPCCASliceData::InitializeRows( const AliHLTTPCCAParam &p )
+{
+ for ( int i = 0; i < p.NRows(); ++i ) {
+ fRows[i].fX = p.RowX( i );
+ fRows[i].fMaxY = CAMath::Tan( p.DAlpha() / 2. ) * fRows[i].fX;
+ }
+}
+
+void AliHLTTPCCASliceData::InitFromClusterData( const AliHLTTPCCAClusterData &data )
+{
+ ////////////////////////////////////
+ // 1. prepare arrays
+ ////////////////////////////////////
+
+ fNumberOfHits = data.NumberOfClusters();
+
+ /* TODO Vectorization
+ for ( int rowIndex = data.FirstRow(); rowIndex <= data.LastRow(); ++rowIndex ) {
+ int NumberOfClusters( int rowIndex ) const;
+ }
+ const int memorySize = fNumberOfHits * sizeof( short_v::Type )
+ */
+ const int numberOfRows = data.LastRow() - data.FirstRow();
+ enum { VectorAlignment = sizeof( int ) };
+ const int numberOfHitsPlusAlignment = NextMultipleOf < VectorAlignment / sizeof( int ) > ( fNumberOfHits );
+ const int memorySize =
+ // LinkData, HitData
+ numberOfHitsPlusAlignment * 4 * sizeof( short ) +
+ // FirstHitInBin
+ NextMultipleOf<VectorAlignment>( ( 23 * numberOfRows + 4 * fNumberOfHits ) * sizeof( int ) ) +
+ // HitWeights, ClusterDataIndex
+ numberOfHitsPlusAlignment * 2 * sizeof( int );
+
+ if ( fMemorySize < memorySize ) {
+ fMemorySize = memorySize;
+ delete[] fMemory;
+ fMemory = new char[fMemorySize + 4];// VectorAlignment];
+ }
+
+ char *mem = fMemory;
+ AssignMemory( fLinkUpData, mem, numberOfHitsPlusAlignment );
+ AssignMemory( fLinkDownData, mem, numberOfHitsPlusAlignment );
+ AssignMemory( fHitDataY, mem, numberOfHitsPlusAlignment );
+ AssignMemory( fHitDataZ, mem, numberOfHitsPlusAlignment );
+ AssignMemory( fFirstHitInBin, mem, 23 * numberOfRows + 4 * fNumberOfHits );
+ AssignMemory( fHitWeights, mem, numberOfHitsPlusAlignment );
+ AssignMemory( fClusterDataIndex, mem, numberOfHitsPlusAlignment );
+
+ ////////////////////////////////////
+ // 2. fill HitData and FirstHitInBin
+ ////////////////////////////////////
+
+ for ( int rowIndex = 0; rowIndex < data.FirstRow(); ++rowIndex ) {
+ AliHLTTPCCARow &row = fRows[rowIndex];
+ row.fGrid.CreateEmpty();
+ row.fNHits = 0;
+ row.fFullSize = 0;
+ row.fHitNumberOffset = 0;
+ row.fFirstHitInBinOffset = 0;
+
+ row.fHy0 = 0.f;
+ row.fHz0 = 0.f;
+ row.fHstepY = 1.f;
+ row.fHstepZ = 1.f;
+ row.fHstepYi = 1.f;
+ row.fHstepZi = 1.f;
+ }
+ for ( int rowIndex = data.LastRow() + 1; rowIndex < 160; ++rowIndex ) {
+ AliHLTTPCCARow &row = fRows[rowIndex];
+ row.fGrid.CreateEmpty();
+ row.fNHits = 0;
+ row.fFullSize = 0;
+ row.fHitNumberOffset = 0;
+ row.fFirstHitInBinOffset = 0;
+
+ row.fHy0 = 0.f;
+ row.fHz0 = 0.f;
+ row.fHstepY = 1.f;
+ row.fHstepZ = 1.f;
+ row.fHstepYi = 1.f;
+ row.fHstepZi = 1.f;
+ }
+
+ AliHLTResizableArray<AliHLTTPCCAHit> binSortedHits( fNumberOfHits );
+
+ int gridContentOffset = 0;
+
+ int binCreationMemorySize = 103 * 2 + fNumberOfHits;
+ AliHLTResizableArray<unsigned short> binCreationMemory( binCreationMemorySize );
+
+ for ( int rowIndex = data.FirstRow(); rowIndex <= data.LastRow(); ++rowIndex ) {
+ AliHLTTPCCARow &row = fRows[rowIndex];
+
+ row.fNHits = data.NumberOfClusters( rowIndex );
+ assert( row.fNHits < ( 1 << sizeof( unsigned short ) * 8 ) );
+ row.fHitNumberOffset = data.RowOffset( rowIndex );
+ row.fFirstHitInBinOffset = gridContentOffset;
+
+ createGrid( &row, data );
+ const AliHLTTPCCAGrid &grid = row.fGrid;
+ const int numberOfBins = grid.N();
+
+ int binCreationMemorySizeNew;
+ if ( ( binCreationMemorySizeNew = numberOfBins * 2 + 6 + row.fNHits ) > binCreationMemorySize ) {
+ binCreationMemorySize = binCreationMemorySizeNew;
+ binCreationMemory.Resize( binCreationMemorySize );
+ }
+
+ AliHLTArray<unsigned short> c = binCreationMemory; // number of hits in all previous bins
+ AliHLTArray<unsigned short> bins = c + ( numberOfBins + 3 ); // cache for the bin index for every hit in this row
+ AliHLTArray<unsigned short> filled = bins + row.fNHits; // counts how many hits there are per bin
+
+ for ( unsigned int bin = 0; bin < row.fGrid.N() + 3; ++bin ) {
+ filled[bin] = 0; // initialize filled[] to 0
+ }
+
+ for ( int hitIndex = 0; hitIndex < row.fNHits; ++hitIndex ) {
+ const int globalHitIndex = row.fHitNumberOffset + hitIndex;
+ const unsigned short bin = row.fGrid.GetBin( data.Y( globalHitIndex ), data.Z( globalHitIndex ) );
+ bins[hitIndex] = bin;
+ ++filled[bin];
+ }
+
+ unsigned short n = 0;
+ for ( int bin = 0; bin < numberOfBins + 3; ++bin ) {
+ c[bin] = n;
+ n += filled[bin];
+ }
+
+ for ( int hitIndex = 0; hitIndex < row.fNHits; ++hitIndex ) {
+ const unsigned short bin = bins[hitIndex];
+ --filled[bin];
+ const unsigned short ind = c[bin] + filled[bin]; // generate an index for this hit that is >= c[bin] and < c[bin + 1]
+ const int globalBinsortedIndex = row.fHitNumberOffset + ind;
+ const int globalHitIndex = row.fHitNumberOffset + hitIndex;
+
+ // allows to find the global hit index / coordinates from a global bin sorted hit index
+ fClusterDataIndex[globalBinsortedIndex] = globalHitIndex;
+ binSortedHits[globalBinsortedIndex].SetY( data.Y( globalHitIndex ) );
+ binSortedHits[globalBinsortedIndex].SetZ( data.Z( globalHitIndex ) );
+ }
+
+ PackHitData( &row, binSortedHits );
+
+ for ( int i = 0; i < numberOfBins; ++i ) {
+ fFirstHitInBin[row.fFirstHitInBinOffset + i] = c[i]; // global bin-sorted hit index
+ }
+ const unsigned short a = c[numberOfBins];
+ // grid.N is <= row.fNHits
+ const int nn = numberOfBins + grid.Ny() + 3;
+ for ( int i = numberOfBins; i < nn; ++i ) {
+ assert( row.fFirstHitInBinOffset + i < 23 * numberOfRows + 4 * fNumberOfHits );
+ fFirstHitInBin[row.fFirstHitInBinOffset + i] = a;
+ }
+
+ row.fFullSize = nn;
+ gridContentOffset += nn;
+ }
+
+#if 0
+ //SG cell finder - test code
+
+ if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
+ fTmpHitInputIDs = new int [NHits];
+ const float areaY = .5;
+ const float areaZ = .5;
+ int newRowNHitsTotal = 0;
+ bool *usedHits = new bool [NHits];
+ for ( int iHit = 0; iHit < NHits; iHit++ ) usedHits[iHit] = 0;
+ for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
+ rowHeaders[iRow*2 ] = newRowNHitsTotal; // new first hit
+ rowHeaders[iRow*2+1] = 0; // new N hits
+ int newRowNHits = 0;
+ int oldRowFirstHit = RowFirstHit[iRow];
+ int oldRowLastHit = oldRowFirstHit + RowNHits[iRow];
+ for ( int iHit = oldRowFirstHit; iHit < oldRowLastHit; iHit++ ) {
+ if ( usedHits[iHit] ) continue;
+ float x0 = X[iHit];
+ float y0 = Y[iHit];
+ float z0 = Z[iHit];
+ float cx = x0;
+ float cy = y0;
+ float cz = z0;
+ int nclu = 1;
+ usedHits[iHit] = 1;
+ if ( 0 ) for ( int jHit = iHit + 1; jHit < oldRowLastHit; jHit++ ) {//SG!!!
+ //if( usedHits[jHit] ) continue;
+ float dy = Y[jHit] - y0;
+ float dz = Z[jHit] - z0;
+ if ( CAMath::Abs( dy ) < areaY && CAMath::Abs( dz ) < areaZ ) {
+ cx += X[jHit];
+ cy += Y[jHit];
+ cz += Z[jHit];
+ nclu++;
+ usedHits[jHit] = 1;
+ }
+ }
+ int id = newRowNHitsTotal + newRowNHits;
+ hitsXYZ[id*3+0 ] = cx / nclu;
+ hitsXYZ[id*3+1 ] = cy / nclu;
+ hitsXYZ[id*3+2 ] = cz / nclu;
+ fTmpHitInputIDs[id] = iHit;
+ newRowNHits++;
+ }
+ rowHeaders[iRow*2+1] = newRowNHits;
+ newRowNHitsTotal += newRowNHits;
+ }
+ NHitsTotal() = newRowNHitsTotal;
+ reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2] = newRowNHitsTotal;
+
+ delete[] usedHits;
+#endif
+}
+
+void AliHLTTPCCASliceData::ClearHitWeights()
+{
+#ifdef ENABLE_VECTORIZATION
+ const int_v v0( Zero );
+ const int *const end = fHitWeights + fNumberOfHits;
+ for ( int *mem = fHitWeights; mem < end; mem += v0.Size ) {
+ v0.store( mem );
+ }
+#else
+ for ( int i = 0; i < fNumberOfHits; ++i ) {
+ fHitWeights[i] = 0;
+ }
+#endif
+}
+
+void AliHLTTPCCASliceData::ClearLinks()
+{
+#ifdef ENABLE_VECTORIZATION
+ const short_v v0( -1 );
+ const short *const end1 = fLinkUpData + fNumberOfHits;
+ for ( short *mem = fLinkUpData; mem < end; mem += v0.Size ) {
+ v0.store( mem );
+ }
+ const short *const end2 = fLinkDownData + fNumberOfHits;
+ for ( short *mem = fLinkDownData; mem < end; mem += v0.Size ) {
+ v0.store( mem );
+ }
+#else
+ for ( int i = 0; i < fNumberOfHits; ++i ) {
+ fLinkUpData[i] = -1;
+ }
+ for ( int i = 0; i < fNumberOfHits; ++i ) {
+ fLinkDownData[i] = -1;
+ }
+#endif
+}
+
--- /dev/null
+/*
+ Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) version 3.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef SLICEDATA_H
+#define SLICEDATA_H
+
+#include "AliHLTTPCCARow.h"
+#include "AliHLTTPCCAMath.h"
+
+typedef int int_v;
+typedef unsigned int uint_v;
+typedef short short_v;
+typedef unsigned short ushort_v;
+typedef float float_v;
+
+class AliHLTTPCCAClusterData;
+template<typename T, int Dim> class AliHLTArray;
+class AliHLTTPCCAHit;
+class AliHLTTPCCAParam;
+
+/**
+ * Data abstraction class for the Slice Tracker.
+ *
+ * Different architectures implement this for the most efficient loads and stores. All access to the
+ * data happens through inline functions so that access to the data has no extra costs.
+ */
+class AliHLTTPCCASliceData
+{
+ public:
+ AliHLTTPCCASliceData()
+ : fNumberOfHits( 0 ), fMemorySize( 0 ), fMemory( 0 ), fLinkUpData( 0 ),
+ fLinkDownData( 0 ), fHitDataY( 0 ), fHitDataZ( 0 ), fClusterDataIndex( 0 ),
+ fFirstHitInBin( 0 ), fHitWeights( 0 ) {}
+
+ void InitializeRows( const AliHLTTPCCAParam ¶meters );
+
+ /**
+ * (Re)Create the data that is tuned for optimal performance of the algorithm from the cluster
+ * data.
+ */
+ void InitFromClusterData( const AliHLTTPCCAClusterData &data );
+
+ /**
+ * Clear the slice data (e.g. for an empty slice)
+ */
+ void Clear();
+
+ /**
+ * Return the number of hits in this slice.
+ */
+ int NumberOfHits() const { return fNumberOfHits; }
+
+ /**
+ * Access to the hit links.
+ *
+ * The links values give the hit index in the row above/below. Or -1 if there is no link.
+ */
+ short_v HitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex ) const;
+ short_v HitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex ) const;
+ void SetHitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex,
+ const short_v &value );
+ void SetHitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex,
+ const short_v &value );
+
+ /**
+ * Reset all links to -1.
+ */
+ void ClearLinks();
+
+ /**
+ * Return the y and z coordinate(s) of the given hit(s).
+ */
+ // TODO return float_v
+ short_v HitDataY( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const;
+ short_v HitDataZ( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const;
+
+ /**
+ * For a given bin index, content tells how many hits there are in the preceding bins. This maps
+ * directly to the hit index in the given row.
+ *
+ * \param binIndexes in the range 0 to row.Grid.N + row.Grid.Ny + 3.
+ */
+ ushort_v FirstHitInBin( const AliHLTTPCCARow &row, ushort_v binIndexes ) const;
+
+ /**
+ * If the given weight is higher than what is currently stored replace with the new weight.
+ */
+ void MaximizeHitWeight( const AliHLTTPCCARow &row, uint_v hitIndex, int_v weight );
+
+ /**
+ * Return the maximal weight the given hit got from one tracklet
+ */
+ int_v HitWeight( const AliHLTTPCCARow &row, uint_v hitIndex ) const;
+
+ /**
+ * Reset all hit weights to 0.
+ */
+ void ClearHitWeights();
+
+ /**
+ * Returns the index in the original AliHLTTPCCAClusterData object of the given hit
+ */
+ int_v ClusterDataIndex( const AliHLTTPCCARow &row, uint_v hitIndex ) const;
+
+ /**
+ * Return the row object for the given row index.
+ */
+ const AliHLTTPCCARow &Row( int rowIndex ) const;
+
+ private:
+ void createGrid( AliHLTTPCCARow *row, const AliHLTTPCCAClusterData &data );
+ void PackHitData( AliHLTTPCCARow *row, const AliHLTArray<AliHLTTPCCAHit, 1> &binSortedHits );
+
+ AliHLTTPCCARow fRows[200]; // The row objects needed for most accessor functions
+
+ int fNumberOfHits; // the number of hits in this slice
+ int fMemorySize; // size of the allocated memory in bytes
+ char *fMemory; // pointer to the allocated memory where all the following arrays reside in
+
+ short *fLinkUpData; // hit index in the row above which is linked to the given (global) hit index
+ short *fLinkDownData; // hit index in the row below which is linked to the given (global) hit index
+
+ unsigned short *fHitDataY; // packed y coordinate of the given (global) hit index
+ unsigned short *fHitDataZ; // packed z coordinate of the given (global) hit index
+
+ int *fClusterDataIndex; // see ClusterDataIndex()
+
+ /*
+ * The size of the array is row.Grid.N + row.Grid.Ny + 3. The row.Grid.Ny + 3 is an optimization
+ * to remove the need for bounds checking. The last values are the same as the entry at [N - 1].
+ */
+ unsigned short *fFirstHitInBin; // see FirstHitInBin
+
+ int *fHitWeights; // the weight of the longest tracklet crossed the cluster
+
+};
+
+inline short_v AliHLTTPCCASliceData::HitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex ) const
+{
+ return fLinkUpData[row.fHitNumberOffset + hitIndex];
+}
+
+inline short_v AliHLTTPCCASliceData::HitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex ) const
+{
+ return fLinkDownData[row.fHitNumberOffset + hitIndex];
+}
+
+inline void AliHLTTPCCASliceData::SetHitLinkUpData ( const AliHLTTPCCARow &row, const short_v &hitIndex, const short_v &value )
+{
+ fLinkUpData[row.fHitNumberOffset + hitIndex] = value;
+}
+
+inline void AliHLTTPCCASliceData::SetHitLinkDownData( const AliHLTTPCCARow &row, const short_v &hitIndex, const short_v &value )
+{
+ fLinkDownData[row.fHitNumberOffset + hitIndex] = value;
+}
+
+inline short_v AliHLTTPCCASliceData::HitDataY( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const
+{
+ return fHitDataY[row.fHitNumberOffset + hitIndex];
+}
+
+inline short_v AliHLTTPCCASliceData::HitDataZ( const AliHLTTPCCARow &row, const uint_v &hitIndex ) const
+{
+ return fHitDataZ[row.fHitNumberOffset + hitIndex];
+}
+
+inline ushort_v AliHLTTPCCASliceData::FirstHitInBin( const AliHLTTPCCARow &row, ushort_v binIndexes ) const
+{
+ return fFirstHitInBin[row.fFirstHitInBinOffset + binIndexes];
+}
+
+inline int_v AliHLTTPCCASliceData::ClusterDataIndex( const AliHLTTPCCARow &row, uint_v hitIndex ) const
+{
+ return fClusterDataIndex[row.fHitNumberOffset + hitIndex];
+}
+
+inline const AliHLTTPCCARow &AliHLTTPCCASliceData::Row( int rowIndex ) const
+{
+ return fRows[rowIndex];
+}
+
+inline void AliHLTTPCCASliceData::MaximizeHitWeight( const AliHLTTPCCARow &row, uint_v hitIndex, int_v weight )
+{
+ CAMath::AtomicMax( &fHitWeights[row.fHitNumberOffset + hitIndex], weight );
+}
+
+inline int_v AliHLTTPCCASliceData::HitWeight( const AliHLTTPCCARow &row, uint_v hitIndex ) const
+{
+ return fHitWeights[row.fHitNumberOffset + hitIndex];
+}
+
+typedef AliHLTTPCCASliceData SliceData;
+
+#endif // SLICEDATA_H
-// @(#) $Id: AliHLTTPCCAUsedHitsInitialiser.cxx 27042 2008-07-02 12:06:02Z richterm $
+// @(#) $Id$
// **************************************************************************
// This file is property of and copyright by the ALICE HLT Project *
// ALICE Experiment at CERN, All rights reserved. *
// *
//***************************************************************************
-#include "AliHLTTPCCAUsedHitsInitialiser.h"
-#include "AliHLTTPCCATracker.h"
+#include "AliHLTTPCCASliceOutput.h"
+#include "MemoryAssignmentHelpers.h"
+GPUhd() int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
+{
+ // calculate the amount of memory [bytes] needed for the event
+
+ const int kClusterDataSize = sizeof( unsigned int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t );
+
+ return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
+}
-void AliHLTTPCCAUsedHitsInitialiser::Thread
-( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
- AliHLTTPCCASharedMemory &s, AliHLTTPCCATracker &tracker )
+GPUhd() void AliHLTTPCCASliceOutput::SetPointers()
{
- // initialise used hit flags with 0
+ // set all pointers
- if ( iSync == 0 ) {
- if ( iThread == 0 ) {
- s.fNHits = tracker.NHitsTotal();
- s.fUsedHits = tracker.HitWeights();
- s.fNThreadsTotal = nThreads * nBlocks;
- s.fIh0 = nThreads * iBlock;
- }
- } else if ( iSync == 1 ) {
- for ( int ih = s.fIh0 + iThread; ih < s.fNHits; ih += s.fNThreadsTotal ) s.fUsedHits[ih] = 0;
- }
+ char *mem = &fMemory[0];
+ AssignMemory( fTracks, mem, fNTracks );
+ AssignMemory( fClusterUnpackedYZ, mem, fNTrackClusters );
+ AssignMemory( fClusterUnpackedX, mem, fNTrackClusters );
+ AssignMemory( fClusterIDrc, mem, fNTrackClusters );
+ AssignMemory( fClusterPackedYZ, mem, fNTrackClusters );
+ AssignMemory( fClusterPackedAmp, mem, fNTrackClusters );
}
float2 *fClusterUnpackedYZ; // pointer to cluster coordinates (temporary data, for debug proposes)
float *fClusterUnpackedX; // pointer to cluster coordinates (temporary data, for debug proposes)
UChar_t *fClusterPackedAmp; // pointer to packed cluster amplitudes
-
+ char fMemory[1]; // the memory where the pointers above point into
};
-
-
-GPUhd() inline int AliHLTTPCCASliceOutput::EstimateSize( int nOfTracks, int nOfTrackClusters )
-{
- // calculate the amount of memory [bytes] needed for the event
-
- const int kClusterDataSize = sizeof( unsigned int ) + sizeof( unsigned short ) + sizeof( float2 ) + sizeof( float ) + sizeof( UChar_t );
-
- return sizeof( AliHLTTPCCASliceOutput ) + sizeof( AliHLTTPCCASliceTrack )*nOfTracks + kClusterDataSize*nOfTrackClusters;
-}
-
-
-GPUhd() inline void AliHLTTPCCASliceOutput::SetPointers()
-{
- // set all pointers
-
- fTracks = ( AliHLTTPCCASliceTrack* )( ( &fClusterPackedAmp ) + 1 );
- fClusterUnpackedYZ = ( float2* ) ( fTracks + fNTracks );
- fClusterUnpackedX = ( float* ) ( fClusterUnpackedYZ + fNTrackClusters );
- fClusterIDrc = ( unsigned int* ) ( fClusterUnpackedX + fNTrackClusters );
- fClusterPackedYZ = ( unsigned short* )( fClusterIDrc + fNTrackClusters );
- fClusterPackedAmp = ( UChar_t* ) ( fClusterPackedYZ + fNTrackClusters );
-}
-
#endif
if ( s.fIRow <= s.fNRows - 4 ) {
s.fNHits = tracker.Row( s.fIRow ).NHits();
if ( s.fNHits >= 10240 ) s.fNHits = 10230;
-
- const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
- s.fHitLinkUp = ( ( short* )( tracker.RowData() + row.FullOffset() ) ) + row.FullLinkOffset();
- s.fHitLinkDown = s.fHitLinkUp + row.NHits();
-
} else s.fNHits = -1;
}
} else if ( iSync == 1 ) {
+ const AliHLTTPCCARow &row = tracker.Row( s.fIRow );
for ( int ih = iThread; ih < s.fNHits; ih += nThreads ) {
- if ( ( s.fHitLinkDown[ih] < 0 ) && ( s.fHitLinkUp[ih] >= 0 ) ) {
+ if ( ( tracker.HitLinkDownData( row, ih ) < 0 ) && ( tracker.HitLinkUpData( row, ih ) >= 0 ) ) {
int oldNRowStartHits = CAMath::AtomicAdd( &s.fNRowStartHits, 1 );
- s.fRowStartHits[oldNRowStartHits] = AliHLTTPCCATracker::IRowIHit2ID( s.fIRow, ih );
+ s.fRowStartHits[oldNRowStartHits].Set( s.fIRow, ih );
}
}
} else if ( iSync == 2 ) {
s.fNOldStartHits = CAMath::AtomicAdd( tracker.NTracklets(), s.fNRowStartHits );
}
} else if ( iSync == 3 ) {
- int *startHits = tracker.TrackletStartHits();
+ AliHLTTPCCAHitId *const startHits = tracker.TrackletStartHits();
for ( int ish = iThread; ish < s.fNRowStartHits; ish += nThreads ) {
startHits[s.fNOldStartHits+ish] = s.fRowStartHits[ish];
}
#define ALIHLTTPCCASTARTHITSFINDER_H
#include "AliHLTTPCCADef.h"
+#include "AliHLTTPCCAHitId.h"
class AliHLTTPCCATracker;
public:
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCASharedMemory()
- : fIRow( 0 ), fNRows( 0 ), fNHits( 0 ), fHitLinkDown( 0 ), fHitLinkUp( 0 ), fNOldStartHits( 0 ), fNRowStartHits( 0 ) {}
+ : fIRow( 0 ), fNRows( 0 ), fNHits( 0 ), fNOldStartHits( 0 ), fNRowStartHits( 0 ) {}
AliHLTTPCCASharedMemory( const AliHLTTPCCASharedMemory& /*dummy*/ )
- : fIRow( 0 ), fNRows( 0 ), fNHits( 0 ), fHitLinkDown( 0 ), fHitLinkUp( 0 ), fNOldStartHits( 0 ), fNRowStartHits( 0 ) {}
+ : fIRow( 0 ), fNRows( 0 ), fNHits( 0 ), fNOldStartHits( 0 ), fNRowStartHits( 0 ) {}
AliHLTTPCCASharedMemory& operator=( const AliHLTTPCCASharedMemory& /*dummy*/ ) { return *this; }
#endif
protected:
int fIRow; // row index
int fNRows; // n rows
int fNHits; // n hits in the row
- short *fHitLinkDown; // pointer to down link array
- short *fHitLinkUp; // pointer to the up link array
- int fRowStartHits[10240]; // temp. array for the start hits
+ AliHLTTPCCAHitId fRowStartHits[10240]; // temp. array for the start hits
int fNOldStartHits; // n start hits from other jobs
int fNRowStartHits; // n start hits for this row
};
#include "AliHLTTPCCAMath.h"
-void AliHLTTPCCATrackConvertor::GetExtParam( const AliHLTTPCCATrackParam &T1, AliExternalTrackParam &T2, double alpha )
+bool AliHLTTPCCATrackConvertor::GetExtParam( const AliHLTTPCCATrackParam &T1, AliExternalTrackParam &T2, double alpha )
{
//* Convert from AliHLTTPCCATrackParam to AliExternalTrackParam parameterisation,
//* the angle alpha is the global angle of the local X axis
+ bool ok = T1.CheckNumericalQuality();
+
double par[5], cov[15];
for ( int i = 0; i < 5; i++ ) par[i] = T1.GetPar()[i];
for ( int i = 0; i < 15; i++ ) cov[i] = T1.GetCov()[i];
cov[10] = -cov[10];
cov[11] = -cov[11];
}
+
+ if ( CAMath::Abs( par[4] ) < 1.e-5 ) par[4] = 1.e-5; // some other software will crash if q/Pt==0
+ if ( CAMath::Abs( par[4] ) > 0.08 ) ok = 0; // some other software will crash if q/Pt is too big
+
T2.Set( ( double ) T1.GetX(), alpha, par, cov );
+
+ return ok;
}
void AliHLTTPCCATrackConvertor::SetExtParam( AliHLTTPCCATrackParam &T1, const AliExternalTrackParam &T2 )
AliHLTTPCCATrackConvertor() {}
- static void GetExtParam( const AliHLTTPCCATrackParam &T1, AliExternalTrackParam &T2, double alpha );
+ static bool GetExtParam( const AliHLTTPCCATrackParam &T1, AliExternalTrackParam &T2, double alpha );
static void SetExtParam( AliHLTTPCCATrackParam &T1, const AliExternalTrackParam &T2 );
};
float ex1i = 1. / ex1;
float d[5] = { 0,
- 0,
- fP[2] - t0.SinPhi(),
- fP[3] - t0.DzDs(),
- fP[4] - t0.QPt()
- };
+ 0,
+ fP[2] - t0.SinPhi(),
+ fP[3] - t0.DzDs(),
+ fP[4] - t0.QPt()
+ };
//float H0[5] = { 1,0, h2, 0, h4 };
//float H1[5] = { 0, 1, 0, dS, 0 };
return 1;
}
-
GPUd() bool AliHLTTPCCATrackParam::Filter( float y, float z, float err2Y, float err2Z, float maxSinPhi )
{
//* Add the y,z measurement with the Kalman filter
return 1;
}
+GPUd() bool AliHLTTPCCATrackParam::CheckNumericalQuality() const
+{
+ //* Check that the track parameters and covariance matrix are reasonable
+
+ bool ok = finite( fX ) && finite( fSignCosPhi ) && finite( fChi2 ) && finite( fNDF );
+
+ const float *c = Cov();
+ for ( int i = 0; i < 15; i++ ) ok = ok && finite( c[i] );
+ for ( int i = 0; i < 5; i++ ) ok = ok && finite( Par()[i] );
+ if ( c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0 ) ok = 0;
+ if ( c[0] > 5. || c[2] > 5. || c[5] > 2. || c[9] > 2 || c[14] > 2. ) ok = 0;
+
+ if ( CAMath::Abs( SinPhi() ) > .99 ) ok = 0;
+ if ( CAMath::Abs( QPt() ) > 1. / 0.05 ) ok = 0;
+
+ return ok;
+}
#if !defined(HLTCA_GPUCODE)
GPUd() bool TransportToXWithMaterial( float x, float Bz, float maxSinPhi = .999 );
GPUd() bool TransportToX( float x, AliHLTTPCCATrackLinearisation &t0,
- float Bz, float maxSinPhi = .999, float *DL = 0 );
+ float Bz, float maxSinPhi = .999, float *DL = 0 );
GPUd() bool TransportToX( float x, float sinPhi0, float cosPhi0, float Bz, float maxSinPhi = .999 );
GPUd() bool TransportToXWithMaterial( float x, AliHLTTPCCATrackLinearisation &t0,
- AliHLTTPCCATrackFitParam &par, float Bz, float maxSinPhi = .999 );
+ AliHLTTPCCATrackFitParam &par, float Bz, float maxSinPhi = .999 );
GPUd() bool TransportToXWithMaterial( float x,
- AliHLTTPCCATrackFitParam &par, float Bz, float maxSinPhi = .999 );
+ AliHLTTPCCATrackFitParam &par, float Bz, float maxSinPhi = .999 );
GPUd() static float ApproximateBetheBloch( float beta2 );
GPUd() static float BetheBlochGeant( float bg,
- float kp0 = 2.33,
- float kp1 = 0.20,
- float kp2 = 3.00,
- float kp3 = 173e-9,
- float kp4 = 0.49848
- );
+ float kp0 = 2.33,
+ float kp1 = 0.20,
+ float kp2 = 3.00,
+ float kp3 = 173e-9,
+ float kp4 = 0.49848
+ );
GPUd() static float BetheBlochSolid( float bg );
GPUd() static float BetheBlochGas( float bg );
GPUd() bool Rotate( float alpha, AliHLTTPCCATrackLinearisation &t0, float maxSinPhi = .999 );
GPUd() bool Filter( float y, float z, float err2Y, float err2Z, float maxSinPhi = .999 );
+ GPUd() bool CheckNumericalQuality() const;
GPUd() void Print() const;
#include "AliHLTTPCCATracklet.h"
#include "AliHLTTPCCAMath.h"
#include "AliHLTTPCCAHit.h"
+#include "MemoryAssignmentHelpers.h"
#include "TStopwatch.h"
#include "AliHLTTPCCAHitArea.h"
#include "AliHLTTPCCATrackletConstructor.h"
#include "AliHLTTPCCATrackletSelector.h"
#include "AliHLTTPCCAProcess.h"
-#include "AliHLTTPCCAUsedHitsInitialiser.h"
#include "AliHLTTPCCASliceTrack.h"
#include "AliHLTTPCCASliceOutput.h"
#include "AliHLTTPCCADataCompressor.h"
+#include "AliHLTTPCCAClusterData.h"
#include "AliHLTTPCCATrackParam.h"
AliHLTTPCCATracker::AliHLTTPCCATracker()
:
fParam(),
- fNHitsTotal( 0 ),
+ fClusterData( 0 ),
+ fData(),
fCommonMemory( 0 ),
fCommonMemorySize( 0 ),
fHitMemory( 0 ),
fHitMemorySize( 0 ),
fTrackMemory( 0 ),
fTrackMemorySize( 0 ),
- fInputEvent( 0 ),
- fInputEventSize( 0 ),
- fRowData( 0 ),
- fRowDataSize( 0 ),
- fHitInputIDs( 0 ),
- fHitWeights( 0 ),
fNTracklets( 0 ),
fTrackletStartHits( 0 ),
fTracklets( 0 ),
fNOutTracks( 0 ),
fOutTracks( 0 ),
fNOutTrackHits( 0 ),
- fOutTrackHits( 0 ),
- fTmpHitInputIDs( 0 )
+ fOutTrackHits( 0 )
{
// constructor
}
-AliHLTTPCCATracker::AliHLTTPCCATracker( const AliHLTTPCCATracker& )
- :
- fParam(),
- fNHitsTotal( 0 ),
- fCommonMemory( 0 ),
- fCommonMemorySize( 0 ),
- fHitMemory( 0 ),
- fHitMemorySize( 0 ),
- fTrackMemory( 0 ),
- fTrackMemorySize( 0 ),
- fInputEvent( 0 ),
- fInputEventSize( 0 ),
- fRowData( 0 ),
- fRowDataSize( 0 ),
- fHitInputIDs( 0 ),
- fHitWeights( 0 ),
- fNTracklets( 0 ),
- fTrackletStartHits( 0 ),
- fTracklets( 0 ),
- fNTracks( 0 ),
- fTracks( 0 ),
- fNTrackHits( 0 ),
- fTrackHits( 0 ),
- fOutput( 0 ),
- fNOutTracks( 0 ),
- fOutTracks( 0 ),
- fNOutTrackHits( 0 ),
- fOutTrackHits( 0 ),
- fTmpHitInputIDs( 0 )
-{
- // dummy
-}
-
-AliHLTTPCCATracker &AliHLTTPCCATracker::operator=( const AliHLTTPCCATracker& )
-{
- // dummy
- fCommonMemory = 0;
- fHitMemory = 0;
- fTrackMemory = 0;
- return *this;
-}
-
GPUd() AliHLTTPCCATracker::~AliHLTTPCCATracker()
{
// destructor
- if ( fCommonMemory ) delete[] fCommonMemory;
- if ( fHitMemory ) delete[] fHitMemory;
- if ( fTrackMemory ) delete[] fTrackMemory;
- if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
+ delete[] fCommonMemory;
+ delete[] fHitMemory;
+ delete[] fTrackMemory;
}
#endif
// initialisation
fParam = param;
fParam.Update();
- for ( int irow = 0; irow < fParam.NRows(); irow++ ) {
- fRows[irow].SetX( fParam.RowX( irow ) );
- fRows[irow].SetMaxY( CAMath::Tan( fParam.DAlpha() / 2. )*fRows[irow].X() );
- }
+ fData.InitializeRows( fParam );
+
StartEvent();
}
{
// start new event and fresh the memory
+ SetupCommonMemory();
+ *fNTrackHits = 0;
+}
+
+void AliHLTTPCCATracker::SetupCommonMemory()
+{
if ( !fCommonMemory ) {
SetPointersCommon(); // just to calculate the size
+ // the 1600 extra bytes are not used unless fCommonMemorySize increases with a later event
fCommonMemory = reinterpret_cast<char*> ( new uint4 [ fCommonMemorySize/sizeof( uint4 ) + 100] );
SetPointersCommon();// set pointers
}
- if ( fHitMemory ) delete[] fHitMemory;
+ delete[] fHitMemory;
fHitMemory = 0;
- if ( fTrackMemory ) delete[] fTrackMemory;
+ delete[] fTrackMemory;
fTrackMemory = 0;
- fNHitsTotal = 0;
+ fData.Clear();
*fNTracklets = 0;
*fNTracks = 0 ;
*fNTrackHits = 0;
*fNOutTracks = 0;
*fNOutTrackHits = 0;
- if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
- fTmpHitInputIDs = 0;
}
-
-
GPUhd() void AliHLTTPCCATracker::SetPointersCommon()
{
// set all pointers to the event memory
- ULong_t mem = ( ULong_t ) fCommonMemory;
- unsigned int sI = sizeof( int );
-
- // set common memory
-
- fNTracklets = ( int* ) mem;
- mem += sI;
- fNTracks = ( int* ) mem;
- mem += sI;
- fNTrackHits = ( int* ) mem;
- mem += sI;
- fNOutTracks = ( int* ) mem;
- mem += sI;
- fNOutTrackHits = ( int* ) mem;
- mem += sI;
+ char *mem = fCommonMemory;
+ AssignMemory( fNTracklets, mem, 1 );
+ AssignMemory( fNTracks, mem, 1 );
+ AssignMemory( fNTrackHits, mem, 1 );
+ AssignMemory( fNOutTracks, mem, 1 );
+ AssignMemory( fNOutTrackHits, mem, 1 );
// calculate the size
- fCommonMemorySize = mem - ( ULong_t ) fCommonMemory;
+ fCommonMemorySize = mem - fCommonMemory;
}
{
// set all pointers to the event memory
- int gridSizeTotal = 2 * ( 2 * MaxNHits + 10 * Param().NRows() );
- //gridSizeTotal *=100;//SG!!!
-
- ULong_t mem = ( ULong_t ) fHitMemory;
- unsigned int sI = sizeof( int );
- unsigned int sF = sizeof( float );
- unsigned int sS = sizeof( short );
- unsigned int s4 = sizeof( uint4 );
-
- // set input event
-
- mem = ( mem / s4 + 1 ) * s4;
- fInputEvent = ( char* ) mem;
- fInputEventSize = ( 1 + fParam.NRows() * 2 + 1 ) * sI + ( MaxNHits * 3 ) * sF;
- mem += fInputEventSize;
-
- // set cluster data for TPC rows
-
- mem = ( mem / s4 + 1 ) * s4;
- fRowData = ( uint4* ) mem;
- fRowDataSize = ( 2 * MaxNHits * sS + // yz
- gridSizeTotal * sS + // grid
- 2 * MaxNHits * sS + // link up,link down
- fParam.NRows() * s4 // row alignment
- );
- mem += fRowDataSize;
+ char *mem = fHitMemory;
// extra arrays for tpc clusters
- mem = ( mem / sI + 1 ) * sI;
-
- fHitInputIDs = ( int* ) mem;
- mem += MaxNHits * sI;
-
- fTrackletStartHits = ( int* ) mem;
- mem += MaxNHits * sI;
-
- fHitWeights = ( int* ) mem;
- mem += MaxNHits * sI;
+ AssignMemory( fTrackletStartHits, mem, MaxNHits );
// arrays for track hits
- fTrackHits = ( int* ) mem;
- mem += 10 * MaxNHits * sI;//SG!!!
+ AssignMemory( fTrackHits, mem, 10 * MaxNHits );
- fOutTrackHits = ( int* ) mem;
- mem += 10 * MaxNHits * sI; //SG!!!
+ AssignMemory( fOutTrackHits, mem, 10 * MaxNHits );
// calculate the size
- fHitMemorySize = mem - ( ULong_t ) fHitMemory;
+ fHitMemorySize = mem - fHitMemory;
}
{
// set all pointers to the tracks memory
- ULong_t mem = ( ULong_t ) fTrackMemory;
+ char *mem = fTrackMemory;
// memory for tracklets
- mem = ( mem / sizeof( AliHLTTPCCATracklet ) + 1 ) * sizeof( AliHLTTPCCATracklet );
- fTracklets = ( AliHLTTPCCATracklet * ) mem;
- mem += MaxNTracks * sizeof( AliHLTTPCCATracklet );
+ AssignMemory( fTracklets, mem, MaxNTracks );
// memory for selected tracks
- mem = ( mem / sizeof( AliHLTTPCCATrack ) + 1 ) * sizeof( AliHLTTPCCATrack );
- fTracks = ( AliHLTTPCCATrack* ) mem;
- mem += MaxNTracks * sizeof( AliHLTTPCCATrack );
+ AssignMemory( fTracks, mem, MaxNTracks );
// memory for output
- mem = ( mem / sizeof( AliHLTTPCCASliceOutput ) + 1 ) * sizeof( AliHLTTPCCASliceOutput );
- fOutput = ( AliHLTTPCCASliceOutput* ) mem;
+ AlignTo < sizeof( void * ) > ( mem );
+ fOutput = reinterpret_cast<AliHLTTPCCASliceOutput *>( mem );
mem += AliHLTTPCCASliceOutput::EstimateSize( MaxNTracks, MaxNHits );
// memory for output tracks
- mem = ( mem / sizeof( AliHLTTPCCAOutTrack ) + 1 ) * sizeof( AliHLTTPCCAOutTrack );
-
- fOutTracks = ( AliHLTTPCCAOutTrack* ) mem;
- mem += MaxNTracks * sizeof( AliHLTTPCCAOutTrack );
+ AssignMemory( fOutTracks, mem, MaxNTracks );
// calculate the size
- fTrackMemorySize = mem - ( ULong_t ) fTrackMemory;
+ fTrackMemorySize = mem - fTrackMemory;
}
-
-GPUd() void AliHLTTPCCATracker::ReadEvent( const int *RowFirstHit, const int *RowNHits, const float *X, const float *Y, const float *Z, int NHits )
+void AliHLTTPCCATracker::ReadEvent( AliHLTTPCCAClusterData *clusterData )
{
- //* Read event
+ fClusterData = clusterData;
StartEvent();
- fNHitsTotal = NHits;
+ //* Convert input hits, create grids, etc.
+ fData.InitFromClusterData( *clusterData );
{
- SetPointersHits( NHits ); // to calculate the size
+ SetPointersHits( fData.NumberOfHits() ); // to calculate the size
fHitMemory = reinterpret_cast<char*> ( new uint4 [ fHitMemorySize/sizeof( uint4 ) + 100] );
- SetPointersHits( NHits ); // set pointers for hits
+ SetPointersHits( fData.NumberOfHits() ); // set pointers for hits
*fNTracklets = 0;
*fNTracks = 0 ;
*fNOutTracks = 0;
*fNOutTrackHits = 0;
}
-
- reinterpret_cast<int*>( fInputEvent )[0] = fParam.NRows();
- reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2] = NHits;
- int *rowHeaders = reinterpret_cast<int*>( fInputEvent ) + 1;
- float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
- for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
- rowHeaders[iRow*2 ] = RowFirstHit[iRow];
- rowHeaders[iRow*2+1] = RowNHits[iRow];
- }
- for ( int iHit = 0; iHit < NHits; iHit++ ) {
- hitsXYZ[iHit*3 ] = X[iHit];
- hitsXYZ[iHit*3+1] = Y[iHit];
- hitsXYZ[iHit*3+2] = Z[iHit];
- }
-
- //SG cell finder - test code
-
- if ( fTmpHitInputIDs ) delete[] fTmpHitInputIDs;
- fTmpHitInputIDs = new int [NHits];
- const float areaY = .5;
- const float areaZ = .5;
- int newRowNHitsTotal = 0;
- bool *usedHits = new bool [NHits];
- for ( int iHit = 0; iHit < NHits; iHit++ ) usedHits[iHit] = 0;
- for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
- rowHeaders[iRow*2 ] = newRowNHitsTotal; // new first hit
- rowHeaders[iRow*2+1] = 0; // new N hits
- int newRowNHits = 0;
- int oldRowFirstHit = RowFirstHit[iRow];
- int oldRowLastHit = oldRowFirstHit + RowNHits[iRow];
- for ( int iHit = oldRowFirstHit; iHit < oldRowLastHit; iHit++ ) {
- if ( usedHits[iHit] ) continue;
- float x0 = X[iHit];
- float y0 = Y[iHit];
- float z0 = Z[iHit];
- float cx = x0;
- float cy = y0;
- float cz = z0;
- int nclu = 1;
- usedHits[iHit] = 1;
- if ( 0 ) for ( int jHit = iHit + 1; jHit < oldRowLastHit; jHit++ ) {//SG!!!
- //if( usedHits[jHit] ) continue;
- float dy = Y[jHit] - y0;
- float dz = Z[jHit] - z0;
- if ( CAMath::Abs( dy ) < areaY && CAMath::Abs( dz ) < areaZ ) {
- cx += X[jHit];
- cy += Y[jHit];
- cz += Z[jHit];
- nclu++;
- usedHits[jHit] = 1;
- }
- }
- int id = newRowNHitsTotal + newRowNHits;
- hitsXYZ[id*3+0 ] = cx / nclu;
- hitsXYZ[id*3+1 ] = cy / nclu;
- hitsXYZ[id*3+2 ] = cz / nclu;
- fTmpHitInputIDs[id] = iHit;
- newRowNHits++;
- }
- rowHeaders[iRow*2+1] = newRowNHits;
- newRowNHitsTotal += newRowNHits;
- }
- fNHitsTotal = newRowNHitsTotal;
- reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2] = newRowNHitsTotal;
-
- delete[] usedHits;
- SetupRowData();
-}
-
-
-GPUd() void AliHLTTPCCATracker::SetupRowData()
-{
- //* Convert input hits, create grids, etc.
-
- fNHitsTotal = reinterpret_cast<int*>( fInputEvent )[1+fParam.NRows()*2];
- int *rowHeaders = reinterpret_cast<int*>( fInputEvent ) + 1;
- float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
-
- for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
-
- AliHLTTPCCARow &row = fRows[iRow];
- row.SetFirstHit( rowHeaders[iRow*2] );
- row.SetNHits( rowHeaders[iRow*2+1] );
- float yMin = 1.e3, yMax = -1.e3, zMin = 1.e3, zMax = -1.e3;
- int nGrid = row.NHits();
- for ( int i = 0; i < row.NHits(); i++ ) {
- int j = row.FirstHit() + i;
- float y = hitsXYZ[j*3+1];
- float z = hitsXYZ[j*3+2];
- if ( yMax < y ) yMax = y;
- if ( yMin > y ) yMin = y;
- if ( zMax < z ) zMax = z;
- if ( zMin > z ) zMin = z;
- }
- if ( nGrid <= 0 ) {
- yMin = yMax = zMin = zMax = 0;
- nGrid = 1;
- }
-
- AliHLTTPCCAGrid grid;
- grid.Create( yMin, yMax, zMin, zMax, nGrid );
-
- float sy = ( CAMath::Abs( grid.StepYInv() ) > 1.e-4 ) ? 1. / grid.StepYInv() : 1;
- float sz = ( CAMath::Abs( grid.StepZInv() ) > 1.e-4 ) ? 1. / grid.StepZInv() : 1;
-
- //cout<<"grid n = "<<row.Grid().N()<<" "<<sy<<" "<<sz<<" "<<yMin<<" "<<yMax<<" "<<zMin<<" "<<zMax<<endl;
-
- bool recreate = 0;
- if ( sy < 2. ) { recreate = 1; sy = 2; }
- if ( sz < 2. ) { recreate = 1; sz = 2; }
- //recreate = 1;//SG!!!
- //sy=2;
- //sz=2;
- if ( recreate ) grid.Create( yMin, yMax, zMin, zMax, sy, sz );
- row.SetGrid( grid );
- }
-
-
- AliHLTTPCCAHit *ffHits = new AliHLTTPCCAHit[ fNHitsTotal ];
-
- int rowDataOffset = 0;
-
- for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
-
- AliHLTTPCCARow &row = fRows[iRow];
- const AliHLTTPCCAGrid &grid = row.Grid();
-
- int *c = new int [grid.N() + 3 + 10];
- int *bins = new int [row.NHits()];
- int *filled = new int [row.Grid().N() + 3 + 10 ];
-
- for ( unsigned int bin = 0; bin < row.Grid().N() + 3; bin++ ) filled[bin] = 0;
-
- for ( int i = 0; i < row.NHits(); i++ ) {
- int j = row.FirstHit() + i;
- int bin = row.Grid().GetBin( hitsXYZ[3*j+1], hitsXYZ[3*j+2] );
- bins[i] = bin;
- filled[bin]++;
- }
-
- {
- int n = 0;
- for ( unsigned int bin = 0; bin < row.Grid().N() + 3; bin++ ) {
- c[bin] = n;
- n += filled[bin];
- }
- }
-
- for ( int i = 0; i < row.NHits(); i++ ) {
- int bin = bins[i];
- int ind = c[bin] + filled[bin] - 1;
-
- AliHLTTPCCAHit &h = ffHits[row.FirstHit()+ind];
- fHitInputIDs[row.FirstHit()+ind] = fTmpHitInputIDs[row.FirstHit()+i];
- h.SetY( hitsXYZ[3*( row.FirstHit()+i )+1] );
- h.SetZ( hitsXYZ[3*( row.FirstHit()+i )+2] );
- filled[bin]--;
- }
-
- {
- float y0 = row.Grid().YMin();
- float stepY = ( row.Grid().YMax() - y0 ) * ( 1. / 65535. );
- float z0 = row.Grid().ZMin();
- float stepZ = ( row.Grid().ZMax() - z0 ) * ( 1. / 65535. );
- if ( stepY < 1.e-4 ) stepY = 1.e-4;
- if ( stepZ < 1.e-4 ) stepZ = 1.e-4;
- float stepYi = 1. / stepY;
- float stepZi = 1. / stepZ;
-
- row.SetHy0( y0 );
- row.SetHz0( z0 );
- row.SetHstepY( stepY );
- row.SetHstepZ( stepZ );
- row.SetHstepYi( stepYi );
- row.SetHstepZi( stepZi );
-
- row.SetFullOffset( rowDataOffset );
- ushort2 *p = ( ushort2* )( fRowData + row.FullOffset() );
- for ( int ih = 0; ih < row.NHits(); ih++ ) {
- int ihTot = row.FirstHit() + ih;
- AliHLTTPCCAHit &hh = ffHits[ihTot];
- float xx = ( ( hh.Y() - y0 ) * stepYi );
- float yy = ( ( hh.Z() - z0 ) * stepZi );
- if ( xx < 0 || yy < 0 || xx >= 65536 || yy >= 65536 ) {
- std::cout << "!!!! hit packing error!!! " << xx << " " << yy << " " << std::endl;
- }
- p[ih].x = ( unsigned short ) xx;
- p[ih].y = ( unsigned short ) yy;
- }
- int size = row.NHits() * sizeof( ushort2 );
-
- row.SetFullGridOffset( row.NHits()*2 );
- unsigned short *p1 = ( ( unsigned short * )p ) + row.FullGridOffset();
-
- int n = grid.N();
- for ( int i = 0; i < n; i++ ) {
- p1[i] = c[i];
- }
- unsigned short a = c[n];
- int nn = n + grid.Ny() + 3;
- for ( int i = n; i < nn; i++ ) p1[i] = a;
-
- size += ( nn ) * sizeof( unsigned short );
- row.SetFullLinkOffset( row.NHits()*2 + nn );
- size += row.NHits() * 2 * sizeof( short );
-
- if ( size % 16 ) size = size / sizeof( uint4 ) + 1;
- else size = size / sizeof( uint4 );
- row.SetFullSize( size );
- //cout<<iRow<<", "<<row.fNHits<<"= "<<size*16<<"b: "<<row.fFullOffset<<" "<<row.fFullSize<<" "<<row.fFullGridOffset<<" "<<row.fFullLinkOffset<<std::endl;
-
- rowDataOffset += size;
- }
- if ( c ) delete[] c;
- if ( bins ) delete[] bins;
- if ( filled ) delete[] filled;
- }
- delete[] ffHits;
}
-
GPUh() void AliHLTTPCCATracker::Reconstruct()
{
//* reconstruction of event
- //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<fNHitsTotal<<std::endl;
+ //std::cout<<"Reconstruct slice "<<fParam.ISlice()<<", nHits="<<NHitsTotal()<<std::endl;
fTimers[0] = 0; // find neighbours
fTimers[1] = 0; // construct tracklets
TStopwatch timer0;
- //SetupRowData();
- if ( fNHitsTotal < 1 ) {
+ if ( NHitsTotal() < 1 ) {
{
SetPointersTracks( 1, 1 ); // to calculate the size
fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
AliHLTTPCCADisplay::Instance().SetSliceView();
AliHLTTPCCADisplay::Instance().SetCurrentSlice( this );
AliHLTTPCCADisplay::Instance().DrawSlice( this, 1 );
- if ( fNHitsTotal > 0 ) {
+ if ( NHitsTotal() > 0 ) {
AliHLTTPCCADisplay::Instance().DrawSliceHits( kRed, .5 );
AliHLTTPCCADisplay::Instance().Ask();
}
#ifdef DRAW
- if ( fNHitsTotal > 0 ) {
+ if ( NHitsTotal() > 0 ) {
AliHLTTPCCADisplay::Instance().DrawSliceLinks( -1, -1, 1 );
AliHLTTPCCADisplay::Instance().Ask();
}
int nStartHits = *fNTracklets;
int nThreads = 128;
- int nBlocks = fNHitsTotal / nThreads + 1;
+ int nBlocks = NHitsTotal() / nThreads + 1;
if ( nBlocks < 12 ) {
nBlocks = 12;
- nThreads = fNHitsTotal / 12 + 1;
+ nThreads = NHitsTotal() / 12 + 1;
if ( nThreads % 32 ) nThreads = ( nThreads / 32 + 1 ) * 32;
}
- nThreads = fNHitsTotal;
+ nThreads = NHitsTotal();
nBlocks = 1;
- AliHLTTPCCAProcess<AliHLTTPCCAUsedHitsInitialiser>( nBlocks, nThreads, *this );
+ fData.ClearHitWeights();
+ //AliHLTTPCCAProcess<AliHLTTPCCAUsedHitsInitialiser>( nBlocks, nThreads, *this );
{
- SetPointersTracks( nStartHits, fNHitsTotal ); // to calculate the size
+ SetPointersTracks( nStartHits, NHitsTotal() ); // to calculate the size
fTrackMemory = reinterpret_cast<char*> ( new uint4 [ fTrackMemorySize/sizeof( uint4 ) + 100] );
- SetPointersTracks( nStartHits, fNHitsTotal ); // set pointers for hits
+ SetPointersTracks( nStartHits, NHitsTotal() ); // set pointers for hits
}
int nMemThreads = AliHLTTPCCATrackletConstructor::NMemThreads();
AliHLTTPCCAProcess1<AliHLTTPCCATrackletConstructor>( nBlocks, nMemThreads + nThreads, *this );
- //std::cout<<"Slice "<<Param().ISlice()<<": NHits="<<fNHitsTotal<<", NTracklets="<<*NTracklets()<<std::endl;
+ //std::cout<<"Slice "<<Param().ISlice()<<": NHits="<<NHitsTotal()<<", NTracklets="<<*NTracklets()<<std::endl;
{
nThreads = 128;
TStopwatch timer;
- //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<fNHitsTotal<<std::endl;
-
+ //cout<<"output: nTracks = "<<*fNTracks<<", nHitsTotal="<<NHitsTotal()<<std::endl;
fOutput->SetNTracks( *fNTracks );
fOutput->SetNTrackClusters( *fNTrackHits );
fOutput->SetPointers();
- float *hitsXYZ = reinterpret_cast<float*>( fInputEvent ) + 1 + fParam.NRows() * 2 + 1;
-
int nStoredHits = 0;
for ( int iTr = 0; iTr < *fNTracks; iTr++ ) {
int iID = iTrack.FirstHitID();
for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
- int ic = ( fTrackHits[iID+ith] );
- int iRow = ID2IRow( ic );
- int ih = ID2IHit( ic );
+ const AliHLTTPCCAHitId &ic = fTrackHits[iID + ith];
+ int iRow = ic.RowIndex();
+ int ih = ic.HitIndex();
- const AliHLTTPCCARow &row = fRows[iRow];
+ const AliHLTTPCCARow &row = fData.Row( iRow );
//float y0 = row.Grid().YMin();
//float z0 = row.Grid().ZMin();
//float y = y0 + hh.x*stepY;
//float z = z0 + hh.y*stepZ;
- int inpIDtot = fHitInputIDs[row.FirstHit()+ih];
- int inpID = inpIDtot - row.FirstHit();
+ int inpIDtot = fData.ClusterDataIndex( row, ih );
+ int inpID = inpIDtot - fClusterData->RowOffset( iRow );
+
+ if ( inpIDtot < 0 || inpIDtot >= fClusterData->NumberOfClusters() ) {
+ //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
+ //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
+ //abort();
+ continue;
+ }
+ if ( inpID < 0 || inpID >= fClusterData->NumberOfClusters( iRow ) ) {
+ //std::cout << inpIDtot << ", " << fClusterData->NumberOfClusters()
+ //<< "; " << inpID << ", " << fClusterData->NumberOfClusters( iRow ) << std::endl;
+ //abort();
+ continue;
+ }
- float origX = hitsXYZ[inpIDtot*3+0];
- float origY = hitsXYZ[inpIDtot*3+1];
- float origZ = hitsXYZ[inpIDtot*3+2];
+ float origX = fClusterData->X( inpIDtot );
+ float origY = fClusterData->Y( inpIDtot );
+ float origZ = fClusterData->Z( inpIDtot );
unsigned int hIDrc = AliHLTTPCCADataCompressor::IRowIClu2IDrc( iRow, inpID );
unsigned short hPackedYZ = 0;
UChar_t hPackedAmp = 0;
- float2 hUnpackedYZ = CAMath::MakeFloat2( origY, origZ );
+ float2 hUnpackedYZ;
+ hUnpackedYZ.x = origY;
+ hUnpackedYZ.y = origZ;
float hUnpackedX = origX;
fOutput->SetClusterIDrc( nStoredHits, hIDrc );
for ( int iTr = 0; iTr < *fNTracks; iTr++ ) {
- AliHLTTPCCATrack &iTrack = fTracks[iTr];
+ const AliHLTTPCCATrack &iTrack = fTracks[iTr];
- //cout<<"iTr = "<<iTr<<", nHits="<<iTrack.NHits()<<std::endl;
+ //std::cout<<"iTr = "<<iTr<<", nHits="<<iTrack.NHits()<<std::endl;
//if( !iTrack.Alive() ) continue;
if ( iTrack.NHits() < 3 ) continue;
int nOutTrackHitsOld = *fNOutTrackHits;
for ( int ith = 0; ith < iTrack.NHits(); ith++ ) {
- int ic = ( fTrackHits[iID+ith] );
- const AliHLTTPCCARow &row = ID2Row( ic );
- int ih = ID2IHit( ic );
- fOutTrackHits[*fNOutTrackHits] = fHitInputIDs[row.FirstHit()+ih];
+ const AliHLTTPCCAHitId &ic = fTrackHits[iID + ith];
+ const AliHLTTPCCARow &row = Row( ic );
+ int ih = ic.HitIndex();
+ fOutTrackHits[*fNOutTrackHits] = HitInputID( row, ih );
( *fNOutTrackHits )++;
- //cout<<"write i,row,hit,id="<<ith<<", "<<ID2IRow(ic)<<", "<<ih<<", "<<fHitInputIDs[row.FirstHit()+ih]<<std::endl;
- if ( *fNOutTrackHits >= 10*fNHitsTotal ) {
- std::cout << "fNOutTrackHits>fNHitsTotal" << std::endl;
+ //std::cout<<"write i,row,hit,id="<<ith<<", "<<ID2IRow(ic)<<", "<<ih<<", "<<HitInputID( row, ih )<<std::endl;
+ if ( *fNOutTrackHits >= 10*NHitsTotal() ) {
+ std::cout << "fNOutTrackHits>NHitsTotal()" << std::endl;
//exit(0);
return;//SG!!!
}
fTimers[5] += timer.CpuTime();
}
-GPUh() void AliHLTTPCCATracker::FitTrackFull( AliHLTTPCCATrack &/**/, float * /**/ ) const
+GPUh() void AliHLTTPCCATracker::FitTrackFull( const AliHLTTPCCATrack &/**/, float * /**/ ) const
{
// fit track with material
#ifdef XXX
int iID = iTrack.FirstHitID();
for ( int ih = 0; ih < iTrack.NHits(); ih++, iID++ ) {
- int *ic = &( fTrackHits[iID] );
- int iRow = ID2IRow( *ic );
- AliHLTTPCCARow &row = fRows[iRow];
+ const AliHLTTPCCAHitId &ic = fTrackHits[iID];
+ int iRow = ic.rowIndex();
+ const AliHLTTPCCARow &row = fData.Row( iRow );
if ( !t0.TransportToX( row.X() ) ) continue;
float dy, dz;
- AliHLTTPCCAHit &h = ID2Hit( *ic );
+ const AliHLTTPCCAHit &h = ic.hitIndex();
// check for wrong hits
if ( 0 ) {
#endif
}
-GPUh() void AliHLTTPCCATracker::FitTrack( AliHLTTPCCATrack &/*track*/, float */*t0[]*/ ) const
+GPUh() void AliHLTTPCCATracker::FitTrack( const AliHLTTPCCATrack &/*track*/, float * /*t0[]*/ ) const
{
//* Fit the track
#ifdef XXX
AliHLTTPCCAEndPoint &p2 = ID2Point( track.PointID()[1] );
- AliHLTTPCCAHit &c0 = ID2Hit( fTrackHits[p0.TrackHitID()].HitID() );
- AliHLTTPCCAHit &c1 = ID2Hit( fTrackHits[track.HitID()[1]].HitID() );
- AliHLTTPCCAHit &c2 = ID2Hit( fTrackHits[p2.TrackHitID()].HitID() );
- AliHLTTPCCARow &row0 = ID2Row( fTrackHits[p0.TrackHitID()].HitID() );
- AliHLTTPCCARow &row1 = ID2Row( fTrackHits[track.HitID()[1]].HitID() );
- AliHLTTPCCARow &row2 = ID2Row( fTrackHits[p2.TrackHitID()].HitID() );
+ const AliHLTTPCCAHit &c0 = ID2Hit( fTrackHits[p0.TrackHitID()].HitID() );
+ const AliHLTTPCCAHit &c1 = ID2Hit( fTrackHits[track.HitID()[1]].HitID() );
+ const AliHLTTPCCAHit &c2 = ID2Hit( fTrackHits[p2.TrackHitID()].HitID() );
+ const AliHLTTPCCARow &row0 = ID2Row( fTrackHits[p0.TrackHitID()].HitID() );
+ const AliHLTTPCCARow &row1 = ID2Row( fTrackHits[track.HitID()[1]].HitID() );
+ const AliHLTTPCCARow &row2 = ID2Row( fTrackHits[p2.TrackHitID()].HitID() );
float sp0[5] = {row0.X(), c0.Y(), c0.Z(), c0.ErrY(), c0.ErrZ() };
float sp1[5] = {row1.X(), c1.Y(), c1.Z(), c1.ErrY(), c1.ErrZ() };
float sp2[5] = {row2.X(), c2.Y(), c2.Z(), c2.ErrY(), c2.ErrZ() };
- //cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
+ //std::cout<<"Fit track, points ="<<sp0[0]<<" "<<sp0[1]<<" / "<<sp1[0]<<" "<<sp1[1]<<" / "<<sp2[0]<<" "<<sp2[1]<<std::endl;
if ( track.NHits() >= 3 ) {
p0.Param().ConstructXYZ3( sp0, sp1, sp2, p0.Param().CosPhi(), t0 );
p2.Param().ConstructXYZ3( sp2, sp1, sp0, p2.Param().CosPhi(), t0 );
}
-
GPUd() void AliHLTTPCCATracker::GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const
{
//
{
// write event to the file
for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
- out << fRows[iRow].FirstHit() << " " << fRows[iRow].NHits() << std::endl;
+ out << fData.Row( iRow ).HitNumberOffset() << " " << fData.Row( iRow ).NHits() << std::endl;
}
- out << fNHitsTotal << std::endl;
+ out << NHitsTotal() << std::endl;
- float *y = new float [fNHitsTotal];
- float *z = new float [fNHitsTotal];
+ AliHLTResizableArray<float> y( NHitsTotal() ), z( NHitsTotal() );
for ( int iRow = 0; iRow < fParam.NRows(); iRow++ ) {
- AliHLTTPCCARow &row = fRows[iRow];
+ const AliHLTTPCCARow &row = Row( iRow );
float y0 = row.Grid().YMin();
float z0 = row.Grid().ZMin();
float stepY = row.HstepY();
float stepZ = row.HstepZ();
- const uint4* tmpint4 = RowData() + row.FullOffset();
- const ushort2 *hits = reinterpret_cast<const ushort2*>( tmpint4 );
- for ( int ih = 0; ih < fRows[iRow].NHits(); ih++ ) {
- int ihTot = row.FirstHit() + ih;
- int id = fHitInputIDs[ihTot];
- ushort2 hh = hits[ih];
- y[id] = y0 + hh.x * stepY;
- z[id] = z0 + hh.y * stepZ;
+ for ( int ih = 0; ih < fData.Row( iRow ).NHits(); ih++ ) {
+ int id = HitInputID( row, ih );
+ y[id] = y0 + HitDataY( row, ih ) * stepY;
+ z[id] = z0 + HitDataZ( row, ih ) * stepZ;
}
}
- for ( int ih = 0; ih < fNHitsTotal; ih++ ) {
+ for ( int ih = 0; ih < NHitsTotal(); ih++ ) {
out << y[ih] << " " << z[ih] << std::endl;
}
- delete[] y;
- delete[] z;
-}
-
-GPUh() void AliHLTTPCCATracker::ReadEvent( std::istream &in )
-{
- //* Read event from file
-
- int *rowFirstHit = new int[ Param().NRows()];
- int *rowNHits = new int [ Param().NRows()];
-
- for ( int iRow = 0; iRow < Param().NRows(); iRow++ ) {
- in >> rowFirstHit[iRow] >> rowNHits[iRow];
- }
- int nHits;
- in >> nHits;
-
- float *y = new float[ nHits ];
- float *z = new float[ nHits ];
- for ( int ih = 0; ih < nHits; ih++ ) {
- in >> y[ih] >> z[ih];
- }
- //ReadEvent( rowFirstHit, rowNHits, y, z, nHits );
- if ( rowFirstHit ) delete[] rowFirstHit;
- if ( rowNHits )delete[] rowNHits;
- if ( y )delete[] y;
- if ( z )delete[] z;
}
GPUh() void AliHLTTPCCATracker::WriteTracks( std::ostream &out )
#include "AliHLTTPCCARow.h"
#include "AliHLTTPCCAHit.h"
#include <iostream>
+#include "AliHLTArray.h"
+#include "AliHLTTPCCAHitId.h"
+#include "AliHLTTPCCASliceData.h"
+#include "AliHLTTPCCATracklet.h"
+#include "AliHLTTPCCAOutTrack.h"
class AliHLTTPCCATrack;
-class AliHLTTPCCAOutTrack;
class AliHLTTPCCATrackParam;
-class AliHLTTPCCATracklet;
+class AliHLTTPCCAClusterData;
class AliHLTTPCCASliceOutput;
/**
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCATracker();
- AliHLTTPCCATracker( const AliHLTTPCCATracker& );
- AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );
GPUd() ~AliHLTTPCCATracker();
#endif
GPUd() void StartEvent();
- GPUd() void ReadEvent( const int *RowFirstHit, const int *RowNHits, const float *X, const float *Y, const float *Z, int NHits );
-
- GPUd() void SetupRowData();
+ void ReadEvent( AliHLTTPCCAClusterData *clusterData );
void Reconstruct();
void WriteOutput();
GPUd() void GetErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const;
GPUd() void GetErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const;
- GPUhd() static int IRowIHit2ID( int iRow, int iHit ) {
- return ( iHit << 8 ) + iRow;
- }
- GPUhd() static int ID2IRow( int HitID ) {
- return ( HitID % 256 );
- }
- GPUhd() static int ID2IHit( int HitID ) {
- return ( HitID >> 8 );
- }
-
- //GPUhd() AliHLTTPCCAHit &ID2Hit( int HitID ) {
- //return fHits[fRows[HitID%256].FirstHit() + (HitID>>8)];
- //}
- GPUhd() const AliHLTTPCCARow &ID2Row( int HitID ) const {
- return fRows[HitID%256];
- }
+ void FitTrack( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
+ void FitTrackFull( const AliHLTTPCCATrack &track, float *t0 = 0 ) const;
- void FitTrack( AliHLTTPCCATrack &track, float *t0 = 0 ) const;
- void FitTrackFull( AliHLTTPCCATrack &track, float *t0 = 0 ) const;
GPUhd() void SetPointersCommon();
GPUhd() void SetPointersHits( int MaxNHits );
GPUhd() void SetPointersTracks( int MaxNTracks, int MaxNHits );
#if !defined(HLTCA_GPUCODE)
GPUh() void WriteEvent( std::ostream &out );
- GPUh() void ReadEvent( std::istream &in );
GPUh() void WriteTracks( std::ostream &out ) ;
GPUh() void ReadTracks( std::istream &in );
#endif
GPUhd() const AliHLTTPCCAParam &Param() const { return fParam; }
GPUhd() void SetParam( const AliHLTTPCCAParam &v ) { fParam = v; }
- GPUhd() const AliHLTTPCCARow &Row( int i ) const { return fRows[i]; }
+ GPUhd() const SliceData &Data() const { return fData; }
+ GPUhd() const AliHLTTPCCARow &Row( int rowIndex ) const { return fData.Row( rowIndex ); }
+ GPUhd() const AliHLTTPCCARow &Row( const AliHLTTPCCAHitId &HitId ) const { return fData.Row( HitId.RowIndex() ); }
+
GPUhd() double Timer( int i ) const { return fTimers[i]; }
GPUhd() void SetTimer( int i, double v ) { fTimers[i] = v; }
- GPUhd() int NHitsTotal() const { return fNHitsTotal;}
+ GPUhd() int NHitsTotal() const { return fData.NumberOfHits(); }
- GPUhd() const char *InputEvent() const { return fInputEvent; }
- GPUhd() int InputEventSize() const { return fInputEventSize; }
+ inline void SetHitLinkUpData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkUpData( row, hitIndex, v ); }
+ inline void SetHitLinkDownData( const AliHLTTPCCARow &row, int hitIndex, short v ) { fData.SetHitLinkDownData( row, hitIndex, v ); }
+ inline short HitLinkUpData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkUpData( row, hitIndex ); }
+ inline short HitLinkDownData( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.HitLinkDownData( row, hitIndex ); }
+
+ inline int FirstHitInBin( const AliHLTTPCCARow &row, int binIndex ) const { return fData.FirstHitInBin( row, binIndex ); }
+
+ inline unsigned short HitDataY( const AliHLTTPCCARow &row, int hitIndex ) const {
+ return fData.HitDataY( row, hitIndex );
+ }
+ inline unsigned short HitDataZ( const AliHLTTPCCARow &row, int hitIndex ) const {
+ return fData.HitDataZ( row, hitIndex );
+ }
- GPUhd() const uint4 *RowData() const { return fRowData; }
- GPUhd() int RowDataSize() const { return fRowDataSize; }
+ int HitInputID( const AliHLTTPCCARow &row, int hitIndex ) const { return fData.ClusterDataIndex( row, hitIndex ); }
+
+ /**
+ * The hit weight is used to determine whether a hit belongs to a certain tracklet or another one
+ * competing for the same hit. The tracklet that has a higher weight wins. Comparison is done
+ * using the the number of hits in the tracklet (the more hits it has the more it keeps). If
+ * tracklets have the same number of hits then it doesn't matter who gets it, but it should be
+ * only one. So a unique number (row index is good) is added in the least significant part of
+ * the weight
+ */
+ static inline int CalculateHitWeight( int NHits, int unique ) {
+ return ( NHits << 16 ) + unique;
+ }
+ inline void MaximizeHitWeight( const AliHLTTPCCARow &row, int hitIndex, int weight ) {
+ fData.MaximizeHitWeight( row, hitIndex, weight );
+ }
+ inline int HitWeight( const AliHLTTPCCARow &row, int hitIndex ) const {
+ return fData.HitWeight( row, hitIndex );
+ }
- GPUhd() int *HitInputIDs() const { return fHitInputIDs; }
- GPUhd() int *HitWeights() const { return fHitWeights; }
+ GPUhd() int NTracklets() const { return *fNTracklets; }
+ GPUhd() int *NTracklets() { return fNTracklets; }
- GPUhd() int *NTracklets() const { return fNTracklets; }
- GPUhd() int *TrackletStartHits() const { return fTrackletStartHits; }
+ GPUhd() const AliHLTTPCCAHitId &TrackletStartHit( int i ) const { return fTrackletStartHits[i]; }
+ GPUhd() AliHLTTPCCAHitId *TrackletStartHits() const { return fTrackletStartHits; }
+ GPUhd() const AliHLTTPCCATracklet &Tracklet( int i ) const { return fTracklets[i]; }
GPUhd() AliHLTTPCCATracklet *Tracklets() const { return fTracklets;}
GPUhd() int *NTracks() const { return fNTracks; }
GPUhd() AliHLTTPCCATrack *Tracks() const { return fTracks; }
GPUhd() int *NTrackHits() const { return fNTrackHits; }
- GPUhd() int *TrackHits() const { return fTrackHits; }
+ GPUhd() AliHLTTPCCAHitId *TrackHits() const { return fTrackHits; }
GPUhd() const AliHLTTPCCASliceOutput * Output() const { return fOutput; }
GPUhd() int *NOutTracks() const { return fNOutTracks; }
GPUhd() AliHLTTPCCAOutTrack *OutTracks() const { return fOutTracks; }
+ GPUhd() const AliHLTTPCCAOutTrack &OutTrack( int index ) const { return fOutTracks[index]; }
GPUhd() int *NOutTrackHits() const { return fNOutTrackHits; }
GPUhd() int *OutTrackHits() const { return fOutTrackHits; }
+ GPUhd() int OutTrackHit( int i ) const { return fOutTrackHits[i]; }
- GPUh() void SetCommonMemory( char * const mem ) { fCommonMemory = mem; }
private:
+ void SetupCommonMemory();
AliHLTTPCCAParam fParam; // parameters
- AliHLTTPCCARow fRows[200];// array of hit rows
double fTimers[10]; // running CPU time for different parts of the algorithm
- // event
+ /** A pointer to the ClusterData object that the SliceData was created from. This can be used to
+ * merge clusters from inside the SliceTracker code and recreate the SliceData. */
+ AliHLTTPCCAClusterData *fClusterData; // ^
+ AliHLTTPCCASliceData fData; // The SliceData object. It is used to encapsulate the storage in memory from the access
- int fNHitsTotal;// total number of hits in event
+ // event
char *fCommonMemory; // common event memory
int fCommonMemorySize; // size of the event memory [bytes]
char *fTrackMemory; // event memory for tracks
int fTrackMemorySize; // size of the event memory [bytes]
- char *fInputEvent; // input event
- int fInputEventSize; // size of the input event [bytes]
-
- uint4 *fRowData; // TPC rows: clusters, grid, links to neighbours
- int fRowDataSize; // size of the row data
-
- int *fHitInputIDs; // cluster index in InputEvent
- int *fHitWeights; // the weight of the longest tracklet crossed the cluster
int *fNTracklets; // number of tracklets
- int *fTrackletStartHits; // start hits for the tracklets
+ AliHLTTPCCAHitId *fTrackletStartHits; // start hits for the tracklets
AliHLTTPCCATracklet *fTracklets; // tracklets
//
int *fNTracks; // number of reconstructed tracks
AliHLTTPCCATrack *fTracks; // reconstructed tracks
int *fNTrackHits; // number of track hits
- int *fTrackHits; // array of track hit numbers
+ AliHLTTPCCAHitId *fTrackHits; // array of track hit numbers
// output
int *fNOutTrackHits; // number of hits in fOutTrackHits array
int *fOutTrackHits; // output array of ID's of the reconstructed hits
- //temporary
-
- int *fTmpHitInputIDs; // temporary step
-
+ // disable copy
+ AliHLTTPCCATracker( const AliHLTTPCCATracker& );
+ AliHLTTPCCATracker &operator=( const AliHLTTPCCATracker& );
};
#include "AliHLTTPCCAOutTrack.h"
#include "AliHLTTPCCAParam.h"
#include "AliHLTTPCCATrackConvertor.h"
+#include "AliHLTArray.h"
#include "AliHLTTPCSpacePointData.h"
#include "AliHLTTPCClusterDataFormat.h"
#include "TObjString.h"
#include "TObjArray.h"
#include "AliHLTTPCCASliceOutput.h"
+#include "AliHLTTPCCAClusterData.h"
const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkTrackletsDataType = AliHLTComponentDataTypeInitializer( "CATRACKL", kAliHLTDataOriginTPC );
{
// Configure the CA tracker component
- const double kCLight = 0.000299792458;
- fSolenoidBz = 5.*kCLight;
+ fSolenoidBz = 5;
fMinNTrackClusters = 0;
fClusterZCut = 500.;
fFullTime = 0;
{
//* Set parameters
- const double kCLight = 0.000299792458;
-
int iResult = 0;
if ( !arguments ) return iResult;
if ( argument.IsNull() ) {
} else if ( argument.CompareTo( "-solenoidBz" ) == 0 ) {
if ( ( bMissingParam = ( ++i >= pTokens->GetEntries() ) ) ) break;
- fSolenoidBz = kCLight * ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
+ fSolenoidBz = ( ( TObjString* )pTokens->At( i ) )->GetString().Atof();
HLTInfo( "Magnetic Field set to: %f", fSolenoidBz );
} else if ( argument.CompareTo( "-minNClustersOnTrack" ) == 0 ||
argument.CompareTo( "-minNTrackClusters" ) == 0 ) {
{
std::vector<int> slices;
std::vector<int>::iterator slIter;
- std::vector<unsigned int> sliceCnts;
- std::vector<unsigned int>::iterator slCntIter;
+ std::vector<unsigned> sliceCnts;
+ std::vector<unsigned>::iterator slCntIter;
for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
iter = blocks + ndx;
Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
"Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
evtData.fEventID, evtData.fEventID );
- unsigned int maxCntSlice = 0;
+ unsigned maxCntSlice = 0;
slCntIter = sliceCnts.begin();
for ( slIter = slices.begin(); slIter != slices.end(); slIter++, slCntIter++ ) {
Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
"Total %d hits to read for slice %d", nHitsTotal, slice );
- AliHLTTPCSpacePointData** vOrigClusters = new AliHLTTPCSpacePointData* [ nHitsTotal];
+ AliHLTResizableArray<AliHLTTPCSpacePointData *> vOrigClusters( nHitsTotal );
int nClusters = 0;
}
}
- // sort clusters since they are not sorted fore some reason
-
- sort( vOrigClusters, vOrigClusters + nClusters, CompareClusters );
-
- float *vHitStoreX = new float [nHitsTotal]; // hit X coordinates
- float *vHitStoreY = new float [nHitsTotal]; // hit Y coordinates
- float *vHitStoreZ = new float [nHitsTotal]; // hit Z coordinates
- int *vHitStoreIntID = new int [nHitsTotal]; // hit ID's
- int *vHitStoreID = new int [nHitsTotal]; // hit ID's
- int *vHitRowID = new int [nHitsTotal]; // hit ID's
+ // sort clusters since they are not sorted for some reason
- int nHits = 0;
+ // candidate for parallelization should this become an issue, can use tbb::parallel_sort
+ sort( vOrigClusters.Data(), ( vOrigClusters + nClusters ).Data(), CompareClusters );
- {
- int rowNHits[200];
- int rowFirstHits[200];
- for ( int ir = 0; ir < 200; ir++ ) rowNHits[ir] = 0;
- int oldRow = -1;
- for ( int i = 0; i < nClusters; i++ ) {
- AliHLTTPCSpacePointData* pSP = vOrigClusters[i];
- if ( oldRow >= 0 && pSP->fPadRow < oldRow )
- HLTError( "CA: clusters from row %d are readed twice", oldRow );
-
- if ( TMath::Abs( pSP->fZ ) > fClusterZCut ) continue;
-
- vHitStoreX[nHits] = pSP->fX;
- vHitStoreY[nHits] = pSP->fY;
- vHitStoreZ[nHits] = pSP->fZ;
- vHitStoreIntID[nHits] = nHits;
- vHitStoreID[nHits] = pSP->fID;
- vHitRowID[nHits] = pSP->fPadRow;
- nHits++;
- rowNHits[pSP->fPadRow]++;
- }
-
- int firstRowHit = 0;
- for ( int ir = 0; ir < 200; ir++ ) {
- rowFirstHits[ir] = firstRowHit;
- firstRowHit += rowNHits[ir];
- }
-
- fTracker->ReadEvent( rowFirstHits, rowNHits, vHitStoreX, vHitStoreY, vHitStoreZ, nHits );
- }
-
- if ( vOrigClusters ) delete[] vOrigClusters;
+ ClusterData clusterData( vOrigClusters, nClusters, fClusterZCut );
+ fTracker->ReadEvent( &clusterData );
// reconstruct the event
int iLastHit = iFirstHit;
for ( int ih = 0; ih < t.NHits(); ih++ ) {
int hitID = fTracker->OutTrackHits()[t.FirstHitRef() + ih ];
- int iRow = vHitRowID[hitID];
+ int iRow = clusterData.RowNumber( hitID );
if ( iRow < iFirstRow ) { iFirstRow = iRow; iFirstHit = hitID; }
if ( iRow > iLastRow ) { iLastRow = iRow; iLastHit = hitID; }
}
AliHLTTPCCATrackParam par = t.StartPoint();
- par.TransportToX( vHitStoreX[iFirstHit], .99 );
+ par.TransportToX( clusterData.X( iFirstHit ), .99 );
AliExternalTrackParam tp;
AliHLTTPCCATrackConvertor::GetExtParam( par, tp, 0 );
currOutTracklet->fPsierr = h * h * tp.GetSigmaSnp2();
currOutTracklet->fTglerr = tp.GetSigmaTgl2();
- if ( par.TransportToX( vHitStoreX[iLastHit], .99 ) ) {
+ if ( par.TransportToX( clusterData.X( iLastHit ), .99 ) ) {
currOutTracklet->fLastX = par.GetX();
currOutTracklet->fLastY = par.GetY();
currOutTracklet->fLastZ = par.GetZ();
} else {
- currOutTracklet->fLastX = vHitStoreX[iLastHit];
- currOutTracklet->fLastY = vHitStoreY[iLastHit];
- currOutTracklet->fLastZ = vHitStoreZ[iLastHit];
+ currOutTracklet->fLastX = clusterData.X( iLastHit );
+ currOutTracklet->fLastY = clusterData.Y( iLastHit );
+ currOutTracklet->fLastZ = clusterData.Z( iLastHit );
}
//if( currOutTracklet->fLastX<10. ) {
- //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",vHitStoreX[iLastHit],vHitStoreY[iLastHit],vHitStoreZ[iLastHit],
+ //HLTError("CA last point: hitxyz=%f,%f,%f, track=%f,%f,%f, tracklet=%f,%f,%f, nhits=%d",clusterData.X( iLastHit ),clusterData.Y( iLastHit],clusterData.Z( iLastHit],
//par.GetX(), par.GetY(),par.GetZ(),currOutTracklet->fLastX,currOutTracklet->fLastY ,currOutTracklet->fLastZ, t.NHits());
//}
#ifdef INCLUDE_TPC_HOUGH
#ifdef ROWHOUGHPARAMS
currOutTracklet->fTrackID = 0;
- currOutTracklet->fRowRange1 = vHitRowID[iFirstHit];
- currOutTracklet->fRowRange2 = vHitRowID[iLastHit];
+ currOutTracklet->fRowRange1 = clusterData.RowNumber( iFirstHit );
+ currOutTracklet->fRowRange2 = clusterData.RowNumber( iLastHit );
currOutTracklet->fSector = slice;
currOutTracklet->fPID = 211;
#endif
currOutTracklet->fNPoints = t.NHits();
for ( int i = 0; i < t.NHits(); i++ ) {
- currOutTracklet->fPointIDs[i] = vHitStoreID[fTracker->OutTrackHits()[t.FirstHitRef()+i]];
+ currOutTracklet->fPointIDs[i] = clusterData.Id( fTracker->OutTrackHits()[t.FirstHitRef()+i] );
}
currOutTracklet = ( AliHLTTPCTrackSegmentData* )( ( Byte_t * )currOutTracklet + dSize );
}
}
- if ( vHitStoreX ) delete[] vHitStoreX;
- if ( vHitStoreY ) delete[] vHitStoreY;
- if ( vHitStoreZ ) delete[] vHitStoreZ;
- if ( vHitStoreIntID ) delete[] vHitStoreIntID;
- if ( vHitStoreID ) delete[] vHitStoreID;
- if ( vHitRowID ) delete[] vHitRowID;
-
if ( mySize > 0 ) {
AliHLTComponentBlockData bd;
FillBlockData( bd );
// Public functions to implement AliHLTComponent's interface.
// These functions are required for the registration process
- /** @see component interface @ref AliHLTComponent::GetComponentID */
+ /** @see component interface @ref AliHLTComponent::GetComponentID */
const char* GetComponentID() ;
/** @see component interface @ref AliHLTComponent::GetInputDataTypes */
/** @see component interface @ref AliHLTProcessor::DoEvent */
int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
- AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
- AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
+ AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
private:
s.fItr0 = nTrPerBlock * iBlock;
s.fItr1 = s.fItr0 + nTrPerBlock;
if ( s.fItr1 > nTracks ) s.fItr1 = nTracks;
- s.fUsedHits = tracker.HitWeights();
s.fMinStartRow = 158;
s.fMaxStartRow = 0;
}
unsigned int kThread = iThread % 32;//& 00000020;
if ( SAVE() ) for ( int i = 0; i < 160; i++ ) tracklet.SetRowHit( i, -1 );
- int id = tracker.TrackletStartHits()[r.fItr];
- r.fStartRow = AliHLTTPCCATracker::ID2IRow( id );
+ AliHLTTPCCAHitId id = tracker.TrackletStartHits()[r.fItr];
+ r.fStartRow = id.RowIndex();
r.fEndRow = r.fStartRow;
r.fFirstRow = r.fStartRow;
r.fLastRow = r.fFirstRow;
- r.fCurrIH = AliHLTTPCCATracker::ID2IHit( id );
+ r.fCurrIH = id.HitIndex();
CAMath::AtomicMin( &s.fMinStartRow32[kThread], r.fStartRow );
CAMath::AtomicMax( &s.fMaxStartRow32[kThread], r.fStartRow );
if ( r.fIsMemThread ) {
const AliHLTTPCCARow &row = tracker.Row( iRow );
bool jr = !r.fCurrentData;
- int n = row.FullSize();
- const uint4* gMem = tracker.RowData() + row.FullOffset();
- uint4 *sMem = s.fData[jr];
- for ( int i = iThread; i < n; i += NMemThreads() ) sMem[i] = gMem[i];
+
+ // copy hits, grid content and links
+
+ // FIXME: inefficient copy
+ const int numberOfHits = row.NHits();
+ ushort2 *sMem1 = reinterpret_cast<ushort2 *>( s.fData[jr] );
+ for ( int i = iThread; i < numberOfHits; i += NMemThreads() ) {
+ sMem1[i].x = tracker.HitDataY( row, i );
+ sMem1[i].y = tracker.HitDataZ( row, i );
+ }
+ short *sMem2 = reinterpret_cast<short *>( s.fData[jr] ) + 2 * numberOfHits;
+ for ( int i = iThread; i < numberOfHits; i += NMemThreads() ) {
+ sMem2[i] = tracker.HitLinkUpData( row, i );
+ }
+
+ unsigned short *sMem3 = reinterpret_cast<unsigned short *>( s.fData[jr] ) + 3 * numberOfHits;
+ const int n = row.FullSize(); // + grid content size
+ for ( int i = iThread; i < n; i += NMemThreads() ) {
+ sMem3[i] = tracker.FirstHitInBin( row, i );
+ }
}
}
for ( int iRow = 0; iRow < 160; iRow++ ) {
int ih = tracklet.RowHit( iRow );
if ( ih >= 0 ) {
- int ihTot = tracker.Row( iRow ).FirstHit() + ih;
- CAMath::AtomicMax( tracker.HitWeights() + ihTot, w );
+ tracker.MaximizeHitWeight( tracker.Row( iRow ), ih, w );
}
}
}
ushort2 hh = reinterpret_cast<ushort2*>( tmpint4 )[r.fCurrIH];
int oldIH = r.fCurrIH;
- r.fCurrIH = reinterpret_cast<short*>( tmpint4 )[row.FullLinkOffset() + r.fCurrIH];
+ r.fCurrIH = reinterpret_cast<short*>( tmpint4 )[2 * row.NHits() + r.fCurrIH]; // read from linkup data
float x = row.X();
float y = y0 + hh.x * stepY;
tParam.SetSinPhi( dy*ri );
tParam.SetSignCosPhi( dx );
tParam.SetDzDs( dz*ri );
- std::cout << "Init. errors... " << r.fItr << std::endl;
+ //std::cout << "Init. errors... " << r.fItr << std::endl;
tracker.GetErrors2( iRow, tParam, err2Y, err2Z );
- std::cout << "Init. errors = " << err2Y << " " << err2Z << std::endl;
+ //std::cout << "Init. errors = " << err2Y << " " << err2Z << std::endl;
tParam.SetCov( 0, err2Y );
tParam.SetCov( 2, err2Z );
}
//#endif
break;
}
+ if ( row.NHits() < 1 ) {
+ // skip empty row
+ break;
+ }
if ( drawSearch ) {
//#ifdef DRAW
std::cout << "tracklet " << r.fItr << " after transport to row " << iRow << " : " << std::endl;
int best = -1;
{ // search for the closest hit
+ const int fIndYmin = row.Grid().GetBinBounded( fY - 1.f, fZ - 1.f );
+ assert( fIndYmin >= 0 );
int ds;
int fY0 = ( int ) ( ( fY - y0 ) * stepYi );
int ds0 = ( ( ( int )1 ) << 30 );
ds = ds0;
- unsigned int fIndYmin;
unsigned int fHitYfst = 1, fHitYlst = 0, fHitYfst1 = 1, fHitYlst1 = 0;
- fIndYmin = row.Grid().GetBin( ( float )( fY - 1. ), ( float )( fZ - 1. ) );
if ( drawSearch ) {
#ifdef DRAW
std::cout << " tracklet " << r.fItr << ", row " << iRow << ": grid N=" << row.Grid().N() << std::endl;
{
int nY = row.Grid().Ny();
- unsigned short *sGridP = ( reinterpret_cast<unsigned short*>( tmpint4 ) ) + row.FullGridOffset();
+ unsigned short *sGridP = ( reinterpret_cast<unsigned short*>( tmpint4 ) ) + 3 * row.NHits();
fHitYfst = sGridP[fIndYmin];
fHitYlst = sGridP[fIndYmin+2];
fHitYfst1 = sGridP[fIndYmin+nY];
fHitYlst1 = sGridP[fIndYmin+nY+2];
+ assert( fHitYfst <= row.NHits() );
+ assert( fHitYlst <= row.NHits() );
+ assert( fHitYfst1 <= row.NHits() );
+ assert( fHitYlst1 <= row.NHits() );
if ( drawSearch ) {
#ifdef DRAW
std::cout << " Grid, row " << iRow << ": nHits=" << row.NHits() << ", grid n=" << row.Grid().N() << ", c[n]=" << sGridP[row.Grid().N()] << std::endl;
//#endif
}
for ( unsigned int fIh = fHitYfst; fIh < fHitYlst; fIh++ ) {
+ assert( fIh < row.NHits() );
ushort2 hh = hits[fIh];
int ddy = ( int )( hh.x ) - fY0;
int ddz = ( int )( hh.y ) - fZ0;
public:
#if !defined(HLTCA_GPUCODE)
AliHLTTPCCASharedMemory()
- : fItr0( 0 ), fItr1( 0 ), fNRows( 0 ), fUsedHits( 0 ), fMinStartRow( 0 ), fMaxStartRow( 0 ) {}
+ : fItr0( 0 ), fItr1( 0 ), fNRows( 0 ), fMinStartRow( 0 ), fMaxStartRow( 0 ) {}
AliHLTTPCCASharedMemory( const AliHLTTPCCASharedMemory& /*dummy*/ )
- : fItr0( 0 ), fItr1( 0 ), fNRows( 0 ), fUsedHits( 0 ), fMinStartRow( 0 ), fMaxStartRow( 0 ) {}
+ : fItr0( 0 ), fItr1( 0 ), fNRows( 0 ), fMinStartRow( 0 ), fMaxStartRow( 0 ) {}
AliHLTTPCCASharedMemory& operator=( const AliHLTTPCCASharedMemory& /*dummy*/ ) { return *this; }
#endif
protected:
int fItr0; // start track index
int fItr1; // end track index
int fNRows; // n rows
- int *fUsedHits; // array of used hits
int fMinStartRow; // min start row
int fMinStartRow32[32]; // min start row for each thread in warp
int fMaxStartRow; // max start row
}
} else if ( iSync == 1 ) {
AliHLTTPCCATrack tout;
- int trackHits[160];
+ AliHLTTPCCAHitId trackHits[160];
for ( int itr = s.fItr0 + iThread; itr < s.fNTracklets; itr += s.fNThreadsTotal ) {
gap++;
int ih = tracklet.RowHit( irow );
if ( ih >= 0 ) {
- int ihTot = tracker.Row( irow ).FirstHit() + ih;
- bool own = ( tracker.HitWeights()[ihTot] <= w );
+ const AliHLTTPCCARow &row = tracker.Row( irow );
+ bool own = ( tracker.HitWeight( row, ih ) <= w );
bool sharedOK = ( ( tout.NHits() < 0 ) || ( nShared < tout.NHits() * kMaxShared ) );
if ( own || sharedOK ) {//SG!!!
gap = 0;
- int th = AliHLTTPCCATracker::IRowIHit2ID( irow, ih );
- trackHits[tout.NHits()] = th;
+ trackHits[tout.NHits()].Set( irow, ih );
tout.SetNHits( tout.NHits() + 1 );
if ( !own ) nShared++;
}
+++ /dev/null
-//-*- Mode: C++ -*-
-// ************************************************************************
-// This file is property of and copyright by the ALICE HLT Project *
-// ALICE Experiment at CERN, All rights reserved. *
-// See cxx source for full Copyright notice *
-// *
-//*************************************************************************
-
-#ifndef ALIHLTTPCCAUSEDHITSINITIALISER_H
-#define ALIHLTTPCCAUSEDHITSINITIALISER_H
-
-
-#include "AliHLTTPCCADef.h"
-
-class AliHLTTPCCATracker;
-
-/**
- * @class AliHLTTPCCAUsedHitsInitialiser
- *
- */
-class AliHLTTPCCAUsedHitsInitialiser
-{
- public:
- class AliHLTTPCCASharedMemory
- {
- friend class AliHLTTPCCAUsedHitsInitialiser;
- public:
-#if !defined(HLTCA_GPUCODE)
- AliHLTTPCCASharedMemory()
- : fNHits( 0 ), fUsedHits( 0 ), fNThreadsTotal( 0 ), fIh0( 0 ) {}
-
- AliHLTTPCCASharedMemory( const AliHLTTPCCASharedMemory& /*dummy*/ )
- : fNHits( 0 ), fUsedHits( 0 ), fNThreadsTotal( 0 ), fIh0( 0 ) {}
- AliHLTTPCCASharedMemory& operator=( const AliHLTTPCCASharedMemory& /*dummy*/ ) { return *this; }
-#endif
- protected:
- int fNHits; // n hits
- int *fUsedHits; // pointer to the used hits array
- int fNThreadsTotal; // total n threads
- int fIh0; // start hit index for the thread
- };
-
- GPUd() static int NThreadSyncPoints() { return 3; }
-
- GPUd() static void Thread( int nBlocks, int nThreads, int iBlock, int iThread, int iSync,
- AliHLTTPCCASharedMemory &smem, AliHLTTPCCATracker &tracker );
-
-};
-
-
-#endif
AliHLTTPCCATrackParam t0 = par;
for ( int ih = 0; ih < nhits; ih++ ) {
int index = fHLTTracker->TrackHits()[tCA.FirstHitRef()+firstHit+ih];
- AliHLTTPCCAGBHit &h = fHLTTracker->Hits()[index];
+ const AliHLTTPCCAGBHit &h = fHLTTracker->Hits()[index];
int extIndex = h.ID();
tTPC.SetClusterIndex( ih, extIndex );
}
AliTPCtrack tt( *esd );
- AliHLTTPCCATrackConvertor::GetExtParam( t, tt, alpha );
- esd->UpdateTrackParams( &tt, AliESDtrack::kTPCrefit );
+ if ( AliHLTTPCCATrackConvertor::GetExtParam( t, tt, alpha ) ) {
+ if ( t.X() > 50 ) esd->UpdateTrackParams( &tt, AliESDtrack::kTPCrefit );
+ }
}
}
return 0;
bool ok = fHLTTracker->FitTrack( t, t0, alpha, hits, nHits, 1 );
if ( ok && nHits > 15 ) {
AliTPCtrack tt( *esd );
- AliHLTTPCCATrackConvertor::GetExtParam( t, tt, alpha );
- esd->UpdateTrackParams( &tt, AliESDtrack::kTPCout );
+ if ( AliHLTTPCCATrackConvertor::GetExtParam( t, tt, alpha ) ) {
+ if ( t.X() > 50 ) esd->UpdateTrackParams( &tt, AliESDtrack::kTPCout );
+ }
}
}
return 0;
--- /dev/null
+#ifndef MEMORYASSIGNMENTHELPERS_H
+#define MEMORYASSIGNMENTHELPERS_H
+
+#include <assert.h>
+
+template<unsigned int X>
+static inline void AlignTo( char *&mem )
+{
+ STATIC_ASSERT( ( X & ( X - 1 ) ) == 0, X_needs_to_be_a_multiple_of_2 );
+ const int offset = reinterpret_cast<unsigned long>( mem ) & ( X - 1 );
+ if ( offset > 0 ) {
+ mem += ( X - offset );
+ }
+ //assert( ( reinterpret_cast<unsigned long>( mem ) & ( X - 1 ) ) == 0 );
+}
+
+template<unsigned int X>
+static inline unsigned int NextMultipleOf( unsigned int value )
+{
+ STATIC_ASSERT( ( X & ( X - 1 ) ) == 0, X_needs_to_be_a_multiple_of_2 );
+ const int offset = value & ( X - 1 );
+ if ( offset > 0 ) {
+ return value + X - offset;
+ }
+ return value;
+}
+
+template<typename T, unsigned int Alignment> static T *AssignMemory( char *&mem, unsigned int size )
+{
+ STATIC_ASSERT( ( Alignment & ( Alignment - 1 ) ) == 0, Alignment_needs_to_be_a_multiple_of_2 );
+ AlignTo<Alignment> ( mem );
+ T *r = reinterpret_cast<T *>( mem );
+ mem += size * sizeof( T );
+ return r;
+}
+
+template<typename T, unsigned int Alignment> static inline T *AssignMemory( char *&mem, unsigned int stride, unsigned int count )
+{
+ assert( 0 == ( stride & ( Alignment - 1 ) ) );
+ return AssignMemory<T, Alignment>( mem, stride * count );
+}
+
+template<typename T, unsigned int Alignment> static T *_assignMemory( char *&mem, unsigned int size )
+{
+ STATIC_ASSERT( ( Alignment & ( Alignment - 1 ) ) == 0, Alignment_needs_to_be_a_multiple_of_2 );
+ AlignTo<Alignment>( mem );
+ T *r = reinterpret_cast<T *>( mem );
+ mem += size * sizeof( T );
+ return r;
+}
+
+template<typename T> static inline void AssignMemory( T *&dst, char *&mem, int count )
+{
+ dst = _assignMemory < T, ( sizeof( T ) & ( sizeof( T ) - 1 ) ) == 0 && sizeof( T ) <= 16 ? sizeof( T ) : sizeof( void * ) > ( mem, count );
+}
+
+#endif // MEMORYASSIGNMENTHELPERS_H