Line data Source code
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 "AliHLTTPCCADef.h"
21 :
22 : #if !defined(__OPENCL__) || defined(HLTCA_HOSTCODE)
23 : #include <iostream>
24 : #include <vector>
25 :
26 : /**
27 : * Cluster data which keeps history about changes
28 : *
29 : * The algorithm doesn't work on this data. Instead the AliHLTTPCCASliceData is created from this.
30 : */
31 : class AliHLTTPCCAClusterData
32 : {
33 : public:
34 :
35 0 : AliHLTTPCCAClusterData(): fSliceIndex( 0 ), fData( NULL ), fNumberOfClusters(0), fAllocated(0) {}
36 : ~AliHLTTPCCAClusterData();
37 :
38 : struct Data {
39 : int fId;
40 : int fRow;
41 : float fX;
42 : float fY;
43 : float fZ;
44 : float fAmp;
45 : };
46 :
47 : /**
48 : * prepare for the reading of event
49 : */
50 : void StartReading( int sliceIndex, int guessForNumberOfClusters = 256 );
51 :
52 : /**
53 : * read next cluster
54 : */
55 : void ReadCluster( int id, int iRow, float x, float y, float z, float amp ) {
56 0 : if (fNumberOfClusters >= fAllocated) Allocate(fNumberOfClusters + 64);
57 : Data d = { id, iRow, x, y, z, amp};
58 0 : fData[fNumberOfClusters++] = d;
59 0 : }
60 :
61 0 : Data* Clusters() { return(fData); }
62 0 : void SetNumberOfClusters(int number) {fNumberOfClusters = number;}
63 :
64 : /**
65 : * Read/Write Events from/to file
66 : */
67 : void ReadEvent(std::istream &in);
68 : void WriteEvent(std::ostream &out) const;
69 : template <class T> void ReadEventVector(T* &data, std::istream &in, int MinSize = 0);
70 : template <class T> void WriteEventVector(const T* const &data, std::ostream &out) const;
71 :
72 : /**
73 : * "remove" one cluster and "add" two new ones, keeping history.
74 : */
75 : //void Split( int index, /* TODO: need some parameters how to split */ );
76 :
77 : // TODO: some access to history of merges and splits
78 :
79 : /**
80 : * The slice index this data belongs to
81 : */
82 0 : int SliceIndex() const { return fSliceIndex; }
83 :
84 : /**
85 : * Return the number of clusters in this slice.
86 : */
87 0 : int NumberOfClusters() const { return (int) fNumberOfClusters; }
88 :
89 : /**
90 : * Return the x coordinate of the given cluster.
91 : */
92 0 : float X( int index ) const { return fData[index].fX; }
93 :
94 : /**
95 : * Return the y coordinate of the given cluster.
96 : */
97 0 : float Y( int index ) const { return fData[index].fY; }
98 :
99 : /**
100 : * Return the z coordinate of the given cluster.
101 : */
102 0 : float Z( int index ) const { return fData[index].fZ; }
103 :
104 : /**
105 : * Return the amplitude of the given cluster.
106 : */
107 0 : float Amp( int index ) const { return fData[index].fAmp; }
108 :
109 : /**
110 : * Return the global ID of the given cluster.
111 : */
112 0 : int Id( int index ) const { return fData[index].fId; }
113 :
114 : /**
115 : * Return the row number/index of the given cluster.
116 : */
117 0 : int RowNumber( int index ) const { return fData[index].fRow; }
118 :
119 0 : Data *GetClusterData( int index ) { return &( fData[index] ); }
120 :
121 : private:
122 : AliHLTTPCCAClusterData(AliHLTTPCCAClusterData&): fSliceIndex( 0 ), fData( NULL ), fNumberOfClusters(0), fAllocated(0) {}
123 : AliHLTTPCCAClusterData& operator=( const AliHLTTPCCAClusterData& );
124 :
125 : /** TODO
126 : * "remove" two clusters and "add" a new one, keeping history.
127 : */
128 : void Merge( int index1, int index2 );
129 :
130 : void Allocate( int number);
131 : static bool CompareClusters( const Data &a, const Data &b ) { return ( a.fRow == b.fRow ? (a.fY < b.fY) : (a.fRow < b.fRow) ); }
132 :
133 : int fSliceIndex; // the slice index this data belongs to
134 : Data* fData; // list of data of clusters
135 : int fNumberOfClusters; //Current number of clusters stored in fData
136 : int fAllocated; //Number of clusters that can be stored in fData
137 : };
138 :
139 : typedef AliHLTTPCCAClusterData ClusterData;
140 :
141 : #endif
142 :
143 : #endif // CLUSTERDATA_H
|