]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAClusterData.h
style changes
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAClusterData.h
1 // **************************************************************************
2 // * This file is property of and copyright by the ALICE HLT Project        *
3 // * All rights reserved.                                                   *
4 // *                                                                        *
5 // * Primary Authors:                                                       *
6 // *     Copyright 2009       Matthias Kretz <kretz@kde.org>                *
7 // *                                                                        *
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 // **************************************************************************
16
17 #ifndef ALIHLTTPCCACLUSTERDATA_H
18 #define ALIHLTTPCCACLUSTERDATA_H
19
20 #include <vector>
21
22 /**
23  * Cluster data which keeps history about changes
24  *
25  * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
26  */
27 class AliHLTTPCCAClusterData
28 {
29   public:
30
31     AliHLTTPCCAClusterData(): fSliceIndex( 0 ), fFirstRow( 0 ), fLastRow( 0 ), fNumberOfClusters(), fRowOffset(), fData() {}
32
33     /**
34      * prepare for the reading of event
35      */
36     void StartReading( int sliceIndex, int guessForNumberOfClusters = 256 );
37
38     /**
39      *  read next cluster
40      */
41     void ReadCluster( int id, int iRow, float x, float y, float z, float amp ) {
42       Data d = { id, iRow, x, y, z, amp};
43       fData.push_back( d );
44     }
45
46     /**
47      * finish the reading of event
48      */
49     void FinishReading();
50
51
52     /**
53      * "remove" one cluster and "add" two new ones, keeping history.
54      */
55     //void Split( int index, /* TODO: need some parameters how to split */ );
56
57     // TODO: some access to history of merges and splits
58
59     /**
60      * The slice index this data belongs to
61      */
62     int SliceIndex() const { return fSliceIndex; }
63
64     /**
65      * The first row index that contains a cluster.
66      */
67     int FirstRow() const { return fFirstRow; }
68
69     /**
70      * The last row index that contains a cluster.
71      */
72     int LastRow() const { return fLastRow; }
73
74     /**
75      * Return the number of clusters in this slice.
76      */
77     int NumberOfClusters() const { return fData.size(); }
78
79     /**
80      * Return the number of clusters in the given row, for this slice.
81      */
82     int NumberOfClusters( unsigned int rowIndex ) const { return rowIndex < fNumberOfClusters.size() ? fNumberOfClusters[rowIndex] : 0; }
83
84     /**
85      * Return the index of the first cluster in the given row.
86      *
87      * Supports calls with rowIndex greater than the available number of rows. In that case it
88      * returns NumberOfClusters.
89      *
90      * To iterate over the clusters in one row do:
91      * \code
92      * AliHLTTPCCAClusterData cd;
93      * const int lastClusterIndex = cd.RowOffset( rowIndex + 1 );
94      * for ( int hitIndex = cd.RowOffset( rowIndex ); hitIndex < lastClusterIndex; ++hitIndex )
95      * \endcode
96      */
97     int RowOffset( unsigned int rowIndex ) const { return rowIndex < fRowOffset.size() ? fRowOffset[rowIndex] : fData.size(); }
98
99     /**
100      * Return the x coordinate of the given cluster.
101      */
102     float X( int index ) const { return fData[index].fX; }
103
104     /**
105      * Return the y coordinate of the given cluster.
106      */
107     float Y( int index ) const { return fData[index].fY; }
108
109     /**
110      * Return the z coordinate of the given cluster.
111      */
112     float Z( int index ) const { return fData[index].fZ; }
113
114     /**
115      * Return the amplitude of the given cluster.
116      */
117     float Amp( int index ) const { return fData[index].fAmp; }
118
119     /**
120      * Return the global ID of the given cluster.
121      */
122     int Id( int index ) const { return fData[index].fId; }
123
124     /**
125      * Return the row number/index of the given cluster.
126      */
127     int RowNumber( int index ) const { return fData[index].fRow; }
128
129     struct Data {
130       int fId;
131       int fRow;
132       float fX;
133       float fY;
134       float fZ;
135       float fAmp;
136     };
137
138     Data *GetClusterData( int index ) { return &( fData[index] ); }
139
140   private:
141     /** TODO
142      * "remove" two clusters and "add" a new one, keeping history.
143      */
144     void Merge( int index1, int index2 );
145
146
147     static bool CompareClusters( const Data &a, const Data &b ) { return ( a.fRow < b.fRow ); }
148
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
155 };
156
157 typedef AliHLTTPCCAClusterData ClusterData;
158
159 #endif // CLUSTERDATA_H