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