1 // **************************************************************************
2 // * This file is property of and copyright by the ALICE HLT Project *
3 // * All rights reserved. *
5 // * Primary Authors: *
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
23 * Cluster data which keeps history about changes
25 * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
27 class AliHLTTPCCAClusterData
31 AliHLTTPCCAClusterData(): fSliceIndex( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {}
34 * prepare for the reading of event
36 void StartReading( int sliceIndex, int guessForNumberOfClusters = 256 );
41 void ReadCluster( int id, int iRow, float x, float y, float z, float amp ) {
42 Data d = { id, iRow, x, y, z, amp};
47 * finish the reading of event
53 * "remove" one cluster and "add" two new ones, keeping history.
55 //void Split( int index, /* TODO: need some parameters how to split */ );
57 // TODO: some access to history of merges and splits
60 * The slice index this data belongs to
62 int SliceIndex() const { return fSliceIndex; }
65 * The first row index that contains a cluster.
67 int FirstRow() const { return fFirstRow; }
70 * The last row index that contains a cluster.
72 int LastRow() const { return fLastRow; }
75 * Return the number of clusters in this slice.
77 int NumberOfClusters() const { return fData.size(); }
80 * Return the number of clusters in the given row, for this slice.
82 int NumberOfClusters( unsigned int rowIndex ) const { return rowIndex < fNumberOfClusters.size() ? fNumberOfClusters[rowIndex] : 0; }
85 * Return the index of the first cluster in the given row.
87 * Supports calls with rowIndex greater than the available number of rows. In that case it
88 * returns NumberOfClusters.
90 * To iterate over the clusters in one row do:
92 * AliHLTTPCCAClusterData cd;
93 * const int lastClusterIndex = cd.RowOffset( rowIndex + 1 );
94 * for ( int hitIndex = cd.RowOffset( rowIndex ); hitIndex < lastClusterIndex; ++hitIndex )
97 int RowOffset( unsigned int rowIndex ) const { return rowIndex < fRowOffset.size() ? fRowOffset[rowIndex] : fData.size(); }
100 * Return the x coordinate of the given cluster.
102 float X( int index ) const { return fData[index].fX; }
105 * Return the y coordinate of the given cluster.
107 float Y( int index ) const { return fData[index].fY; }
110 * Return the z coordinate of the given cluster.
112 float Z( int index ) const { return fData[index].fZ; }
115 * Return the amplitude of the given cluster.
117 float Amp( int index ) const { return fData[index].fAmp; }
120 * Return the global ID of the given cluster.
122 int Id( int index ) const { return fData[index].fId; }
125 * Return the row number/index of the given cluster.
127 int RowNumber( int index ) const { return fData[index].fRow; }
138 Data *GetClusterData( int index ) { return &( fData[index] ); }
142 * "remove" two clusters and "add" a new one, keeping history.
144 void Merge( int index1, int index2 );
147 static bool CompareClusters( const Data &a, const Data &b ) { return ( a.fRow < b.fRow ); }
149 int fSliceIndex; // the slice index this data belongs to
150 int fFirstRow; // see FirstRow()
151 int fLastRow; // see LastRow()
152 std::vector<int> fNumberOfClusters; // list of NumberOfClusters per row for NumberOfClusters(int)
153 std::vector<int> fRowOffset; // see RowOffset()
154 std::vector<Data> fData; // list of data of clusters
157 typedef AliHLTTPCCAClusterData ClusterData;
159 #endif // CLUSTERDATA_H