1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Copyright 2009 Matthias Kretz <kretz@kde.org> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 #ifndef ALIHLTTPCCACLUSTERDATA_H
18 #define ALIHLTTPCCACLUSTERDATA_H
21 #include "AliHLTArray.h"
23 class AliHLTTPCSpacePointData;
26 * Cluster data which keeps history about changes
28 * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
30 class AliHLTTPCCAClusterData
34 * Construct AliHLTTPCCAClusterData object from AliHLTTPCSpacePointData array.
36 AliHLTTPCCAClusterData( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
37 int numberOfClusters, double ClusterZCut )
38 : fSliceIndex( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData()
39 { readEvent( clusters, numberOfClusters, ClusterZCut ); }
42 AliHLTTPCCAClusterData(): fSliceIndex( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {}
44 void readEvent( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
45 int numberOfClusters, double ClusterZCut );
48 * prepare for the reading of event
50 void StartReading( int sliceIndex, int guessForNumberOfClusters = 256 );
55 void ReadCluster( int id, int iRow, float X, float Y, float Z, float Amp ) {
56 Data d = { id, iRow, X, Y, Z, Amp};
61 * finish the reading of event
67 * "remove" one cluster and "add" two new ones, keeping history.
69 //void Split( int index, /* TODO: need some parameters how to split */ );
71 // TODO: some access to history of merges and splits
74 * The slice index this data belongs to
76 int SliceIndex() const { return fSliceIndex; }
79 * The first row index that contains a cluster.
81 int FirstRow() const { return fFirstRow; }
84 * The last row index that contains a cluster.
86 int LastRow() const { return fLastRow; }
89 * Return the number of clusters in this slice.
91 int NumberOfClusters() const { return fData.size(); }
94 * Return the number of clusters in the given row, for this slice.
96 int NumberOfClusters( unsigned int rowIndex ) const { return rowIndex < fNumberOfClusters.size() ? fNumberOfClusters[rowIndex] : 0; }
99 * Return the index of the first cluster in the given row.
101 * Supports calls with rowIndex greater than the available number of rows. In that case it
102 * returns NumberOfClusters.
104 * To iterate over the clusters in one row do:
106 * AliHLTTPCCAClusterData cd;
107 * const int lastClusterIndex = cd.RowOffset( rowIndex + 1 );
108 * for ( int hitIndex = cd.RowOffset( rowIndex ); hitIndex < lastClusterIndex; ++hitIndex )
111 int RowOffset( unsigned int rowIndex ) const { return rowIndex < fRowOffset.size() ? fRowOffset[rowIndex] : fData.size(); }
114 * Return the x coordinate of the given cluster.
116 float X( int index ) const { return fData[index].fX; }
119 * Return the y coordinate of the given cluster.
121 float Y( int index ) const { return fData[index].fY; }
124 * Return the z coordinate of the given cluster.
126 float Z( int index ) const { return fData[index].fZ; }
129 * Return the amplitude of the given cluster.
131 float Amp( int index ) const { return fData[index].fAmp; }
134 * Return the global ID of the given cluster.
136 int Id( int index ) const { return fData[index].fId; }
139 * Return the row number/index of the given cluster.
141 int RowNumber( int index ) const { return fData[index].fRow; }
145 * "remove" two clusters and "add" a new one, keeping history.
147 void Merge( int index1, int index2 );
158 static bool CompareClusters( const Data &a, const Data &b ) { return ( a.fRow < b.fRow ); }
160 int fSliceIndex; // the slice index this data belongs to
161 int fFirstRow; // see FirstRow()
162 int fLastRow; // see LastRow()
163 std::vector<int> fNumberOfClusters; // list of NumberOfClusters per row for NumberOfClusters(int)
164 std::vector<int> fRowOffset; // see RowOffset()
165 std::vector<Data> fData; // list of data of clusters
168 typedef AliHLTTPCCAClusterData ClusterData;
170 #endif // CLUSTERDATA_H