2 Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) version 3.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
25 #include "AliHLTTPCCAGBHit.h"
26 #include "AliHLTArray.h"
28 class AliHLTTPCSpacePointData;
31 * Cluster data which keeps history about changes
33 * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
35 class AliHLTTPCCAClusterData
39 * Construct AliHLTTPCCAClusterData object from AliHLTTPCSpacePointData array.
41 AliHLTTPCCAClusterData( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
42 int numberOfClusters, double ClusterZCut )
43 : fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData()
44 { readEvent( clusters, numberOfClusters, ClusterZCut ); }
48 * Construct AliHLTTPCCAClusterData object from GBHit array.
50 AliHLTTPCCAClusterData( const AliHLTTPCCAGBHit *hits, int *offset, int numberOfClusters )
51 : fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {
52 readEvent( hits, offset, numberOfClusters );
55 AliHLTTPCCAClusterData(): fSlice( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {}
57 void readEvent( const AliHLTArray<AliHLTTPCSpacePointData *> &clusters,
58 int numberOfClusters, double ClusterZCut );
59 void readEvent( const AliHLTTPCCAGBHit *hits, int *offset, int numberOfClusters );
62 * "remove" one cluster and "add" two new ones, keeping history.
64 //void Split( int index, /* TODO: need some parameters how to split */ );
66 // TODO: some access to history of merges and splits
69 * The slice index this data belongs to
71 int Slice() const { return fSlice; }
74 * The first row index that contains a cluster.
76 int FirstRow() const { return fFirstRow; }
79 * The last row index that contains a cluster.
81 int LastRow() const { return fLastRow; }
84 * Return the number of clusters in this slice.
86 int NumberOfClusters() const { return fData.size(); }
89 * Return the number of clusters in the given row, for this slice.
91 int NumberOfClusters( unsigned int rowIndex ) const { return rowIndex < fNumberOfClusters.size() ? fNumberOfClusters[rowIndex] : 0; }
94 * Return the index of the first cluster in the given row.
96 * Supports calls with rowIndex greater than the available number of rows. In that case it
97 * returns NumberOfClusters.
99 * To iterate over the clusters in one row do:
101 * AliHLTTPCCAClusterData cd;
102 * const int lastClusterIndex = cd.RowOffset( rowIndex + 1 );
103 * for ( int hitIndex = cd.RowOffset( rowIndex ); hitIndex < lastClusterIndex; ++hitIndex )
106 int RowOffset( unsigned int rowIndex ) const { return rowIndex < fRowOffset.size() ? fRowOffset[rowIndex] : fData.size(); }
109 * Return the x coordinate of the given cluster.
111 float X( int index ) const { return fData[index].fX; }
114 * Return the y coordinate of the given cluster.
116 float Y( int index ) const { return fData[index].fY; }
119 * Return the z coordinate of the given cluster.
121 float Z( int index ) const { return fData[index].fZ; }
124 * Return the global ID of the given cluster.
126 int Id( int index ) const { return fData[index].fId; }
129 * Return the row number/index of the given cluster.
131 int RowNumber( int index ) const { return fData[index].fRow; }
135 * "remove" two clusters and "add" a new one, keeping history.
137 void Merge( int index1, int index2 );
147 int fSlice; // the slice index this data belongs to
148 int fFirstRow; // see FirstRow()
149 int fLastRow; // see LastRow()
150 std::vector<int> fNumberOfClusters; // list of NumberOfClusters per row for NumberOfClusters(int)
151 std::vector<int> fRowOffset; // see RowOffset()
152 std::vector<Data> fData; // list of data of clusters
155 typedef AliHLTTPCCAClusterData ClusterData;
157 #endif // CLUSTERDATA_H