]>
Commit | Line | Data |
---|---|---|
6de2bc40 | 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 | // ************************************************************************** | |
4acc2401 | 16 | |
17 | #include "AliHLTTPCCAClusterData.h" | |
4acc2401 | 18 | #include "AliHLTTPCCAMath.h" |
7be9b0d7 | 19 | #include <algorithm> |
20 | #include "AliHLTArray.h" | |
b22af1bf | 21 | #include "AliHLTTPCCAGPUConfig.h" |
4acc2401 | 22 | |
16b802c5 | 23 | void AliHLTTPCCAClusterData::StartReading( int sliceIndex, int guessForNumberOfClusters ) |
4acc2401 | 24 | { |
16b802c5 | 25 | // Start reading of event - initialisation |
26 | ||
27 | fSliceIndex = sliceIndex; | |
28 | fFirstRow = 0; | |
29 | fLastRow = 0; | |
30 | fData.clear(); | |
b22af1bf | 31 | fNumberOfClusters.reserve( HLTCA_ROW_COUNT + 1 ); |
32 | fRowOffset.reserve( HLTCA_ROW_COUNT + 1 ); | |
b8139972 | 33 | fData.reserve( CAMath::Max( 64, guessForNumberOfClusters ) ); |
16b802c5 | 34 | } |
35 | ||
36 | ||
37 | void AliHLTTPCCAClusterData::FinishReading() | |
38 | { | |
39 | // finish event reading - data sorting, etc. | |
40 | ||
41 | std::sort( fData.begin(), fData.end(), CompareClusters ); | |
42 | if ( fData.size() ) fFirstRow = fData[0].fRow; | |
43 | ||
44 | fNumberOfClusters.clear(); | |
45 | fRowOffset.clear(); | |
46 | ||
4acc2401 | 47 | int row = fFirstRow; |
48 | for ( int i = 0; i < row; ++i ) { | |
49 | fNumberOfClusters.push_back( 0 ); | |
50 | fRowOffset.push_back( 0 ); | |
51 | } | |
52 | fRowOffset.push_back( 0 ); | |
16b802c5 | 53 | for ( unsigned int ic = 0; ic < fData.size(); ++ic ) { |
54 | Data &cluster = fData[ic]; | |
55 | while ( row < cluster.fRow ) { | |
56 | fNumberOfClusters.push_back( ic - fRowOffset.back() ); | |
57 | fRowOffset.push_back( ic ); | |
4acc2401 | 58 | ++row; |
59 | } | |
4acc2401 | 60 | } |
61 | fNumberOfClusters.push_back( fData.size() - fRowOffset.back() ); | |
62 | fLastRow = row; // the last seen row is the last row in this slice | |
63 | } | |
16b802c5 | 64 | |
7be9b0d7 | 65 | template <class T> void AliHLTTPCCAClusterData::WriteEventVector(const std::vector<T> &data, std::ostream &out) const |
66 | { | |
67 | AliHLTResizableArray<T> tmpData(data.size()); | |
68 | unsigned i; | |
69 | for (i = 0;i < data.size();i++) | |
70 | { | |
71 | tmpData[i] = data[i]; | |
72 | } | |
73 | i = data.size(); | |
74 | out.write((char*) &i, sizeof(i)); | |
75 | out.write((char*) &tmpData[0], i * sizeof(T)); | |
76 | } | |
77 | ||
78 | template <class T> void AliHLTTPCCAClusterData::ReadEventVector(std::vector<T> &data, std::istream &in, int MinSize) | |
79 | { | |
80 | int i; | |
81 | in.read((char*) &i, sizeof(i)); | |
82 | data.reserve(AliHLTTPCCAMath::Max(MinSize, i)); | |
83 | data.resize(i); | |
84 | AliHLTResizableArray<T> tmpData(i); | |
85 | in.read((char*) &tmpData[0], i * sizeof(T)); | |
86 | for (int j = 0;j < i;j++) | |
87 | { | |
8566066c | 88 | #ifdef HLTCA_STANDALONE |
89 | if (tmpData[j].fRow < 0 || tmpData[j].fRow >= HLTCA_ROW_COUNT) | |
90 | { | |
8566066c | 91 | exit(1); |
92 | } | |
93 | #endif | |
7be9b0d7 | 94 | data[j] = tmpData[j]; |
95 | } | |
96 | } | |
97 | ||
98 | void AliHLTTPCCAClusterData::WriteEvent(std::ostream &out) const | |
99 | { | |
100 | WriteEventVector<Data>(fData, out); | |
101 | } | |
102 | ||
103 | void AliHLTTPCCAClusterData::ReadEvent(std::istream &in) | |
104 | { | |
105 | fData.clear(); | |
106 | ReadEventVector<Data>(fData, in, 64); | |
107 | } | |
16b802c5 | 108 |