]>
Commit | Line | Data |
---|---|---|
7e914051 | 1 | // $Id$ |
ff2f0f94 | 2 | |
892210c7 | 3 | //************************************************************************** |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
ff2f0f94 | 18 | |
19 | /** @file AliHLTTPCCompModelDeconverter.cxx | |
20 | @author Timm Steinbeck | |
21 | @date | |
22 | @brief A copy processing component for the HLT. */ | |
23 | ||
24 | #if __GNUC__ >= 3 | |
25 | using namespace std; | |
26 | #endif | |
27 | ||
28 | #include "AliHLTTPCCompModelDeconverter.h" | |
29 | #include "AliHLTTPCTransform.h" | |
30 | #include "AliHLTTPCTrack.h" | |
31 | #include "AliHLTTPCModelTrack.h" | |
32 | #include "AliHLTTPCCompDataCompressorHelper.h" | |
33 | #include <cerrno> | |
34 | ||
35 | AliHLTTPCCompModelDeconverter::AliHLTTPCCompModelDeconverter(): | |
36 | fInputTrackArray("AliHLTTPCModelTrack"), | |
37 | fTrackClusterModelData(0), | |
38 | fTrackClusterModelDataSize(0), | |
39 | fRemainingClustersModelData(0), | |
40 | fRemainingClustersModelDataSize(0) | |
41 | { | |
42 | // see header file for class documentation | |
43 | Init(); | |
44 | } | |
45 | ||
46 | AliHLTTPCCompModelDeconverter::~AliHLTTPCCompModelDeconverter() | |
47 | { | |
48 | // see header file for class documentation | |
49 | } | |
50 | ||
51 | int AliHLTTPCCompModelDeconverter::Init() | |
52 | { | |
53 | // see header file for class documentation | |
54 | fInputTrackArray.Reset(); | |
55 | fTrackClusterModelData = 0; | |
56 | fTrackClusterModelDataSize = 0; | |
57 | fRemainingClustersModelData = 0; | |
58 | fRemainingClustersModelDataSize = 0; | |
59 | return 0; | |
60 | } | |
61 | ||
62 | ||
63 | int AliHLTTPCCompModelDeconverter::SetTrackClusterModelInputData( AliHLTUInt8_t* data, UInt_t size ) | |
64 | { | |
65 | // see header file for class documentation | |
66 | fTrackClusterModelData = data; | |
67 | fTrackClusterModelDataSize = size; | |
68 | ||
69 | AliHLTUInt8_t* inputPtr = fTrackClusterModelData; | |
70 | AliHLTUInt8_t* inputEndPtr = fTrackClusterModelData+fTrackClusterModelDataSize; | |
71 | ||
72 | AliHLTUInt32_t version = *(AliHLTUInt32_t*)inputPtr; | |
73 | inputPtr += sizeof(AliHLTUInt32_t); | |
74 | if ( version != 0 ) | |
75 | { | |
76 | HLTError( "Unsupported version %hu. Only version 0 supported currently.", version ); | |
77 | return EIO; | |
78 | } | |
79 | ||
80 | while ( inputPtr+sizeof(AliHLTTPCTrackModel)+AliHLTTPCTransform::GetNRows()*sizeof(AliHLTTPCClusterModel) <= inputEndPtr ) | |
81 | { | |
82 | AliHLTTPCModelTrack *track = (AliHLTTPCModelTrack*)fInputTrackArray.NextTrack(); | |
83 | if ( !track ) | |
84 | { | |
85 | HLTError( "Error obtaining model track from track array." ); | |
86 | return EIO; | |
87 | } | |
88 | Int_t slice = ((AliHLTTPCClusterModel*)( inputPtr+sizeof(AliHLTTPCTrackModel) ))[ AliHLTTPCTransform::GetNRows()-1 ].fSlice; | |
89 | track->Init(slice,-1); | |
90 | AliHLTTPCTrackModel *model = track->GetModel(); | |
91 | AliHLTTPCClusterModel *clusters = track->GetClusters(); | |
92 | memcpy( model, inputPtr, sizeof(AliHLTTPCTrackModel) ); | |
93 | memcpy( clusters, inputPtr+sizeof(AliHLTTPCTrackModel), AliHLTTPCTransform::GetNRows()*sizeof(AliHLTTPCClusterModel) ); | |
94 | track->FillTrack(); | |
95 | ||
96 | // validation test | |
97 | //HLTInfo("track->GetNClusters() %d GetNPresentClusters() %d", track->GetNClusters(), track->GetNPresentClusters()); | |
98 | ||
99 | inputPtr += sizeof(AliHLTTPCTrackModel)+AliHLTTPCTransform::GetNRows()*sizeof(AliHLTTPCClusterModel); | |
100 | } | |
101 | ||
102 | if ( inputPtr!=inputEndPtr ) | |
103 | { | |
104 | HLTError( "Data format inconsistency on reading track model data." ); | |
105 | return EIO; | |
106 | } | |
107 | ||
108 | return 0; | |
109 | } | |
110 | ||
111 | int AliHLTTPCCompModelDeconverter::SetRemainingClustersModelInputData( AliHLTUInt8_t* data, UInt_t size ) | |
112 | { | |
113 | // see header file for class documentation | |
114 | fRemainingClustersModelData = data; | |
115 | fRemainingClustersModelDataSize = size; | |
116 | ||
117 | AliHLTUInt32_t version = *(AliHLTUInt32_t*)data; | |
118 | if ( version != 0 ) | |
119 | { | |
120 | HLTError( "Unsupported version %hu. Only version 0 supported currently.", version ); | |
121 | return EIO; | |
122 | } | |
123 | return 0; | |
124 | } | |
125 | ||
126 | int AliHLTTPCCompModelDeconverter::DeconvertTracks( AliHLTUInt8_t* data, UInt_t& size ) | |
127 | { | |
128 | // see header file for class documentation | |
129 | AliHLTTPCTrackletData* outPtr = (AliHLTTPCTrackletData*)data; | |
130 | UInt_t blockSize = fInputTrackArray.WriteTracks( outPtr->fTrackletCnt, outPtr->fTracklets ); | |
131 | if ( blockSize >= size ) | |
132 | { | |
133 | HLTError( "Output size is bigger than allowed (%u instead of %u)", | |
134 | (unsigned)blockSize, (unsigned)size ); | |
135 | size = 0; | |
136 | return ENOBUFS; | |
137 | } | |
138 | size = blockSize; | |
139 | ||
140 | ||
141 | UInt_t clusterCounts[36][6]; | |
142 | memset( clusterCounts, 0, sizeof(UInt_t)*36*6 ); | |
143 | ||
144 | AliHLTTPCTrackSegmentData* tracklet = outPtr->fTracklets; | |
145 | ||
146 | // validation test | |
147 | //HLTInfo("fTrackletCnt = %d", outPtr->fTrackletCnt); | |
148 | //HLTInfo("tracklet Points = %d", tracklet->fNPoints); | |
149 | ||
150 | for ( UInt_t ii = 0; ii<outPtr->fTrackletCnt; ii++ ) | |
151 | { | |
152 | // validation test | |
153 | //HLTInfo("Tracklet points %d", tracklet->fNPoints); | |
154 | for ( UInt_t jj=0; jj<tracklet->fNPoints; jj++ ) | |
155 | { | |
156 | //validation test | |
157 | //HLTInfo("Hello World %d !",jj); | |
158 | UInt_t slice, partition; | |
a371a266 | 159 | slice = AliHLTTPCSpacePointData::GetSlice(tracklet->fPointIDs[jj]); |
160 | partition = AliHLTTPCSpacePointData::GetPatch(tracklet->fPointIDs[jj]); | |
161 | tracklet->fPointIDs[jj] = AliHLTTPCSpacePointData::GetID(slice,partition,clusterCounts[slice][partition]); | |
ff2f0f94 | 162 | clusterCounts[slice][partition]++; |
163 | } | |
164 | tracklet = (AliHLTTPCTrackSegmentData*) ( ((AliHLTUInt8_t*)tracklet)+sizeof(AliHLTTPCTrackSegmentData)+tracklet->fNPoints*sizeof(UInt_t) ); | |
165 | } | |
166 | ||
167 | return 0; | |
168 | } | |
169 | ||
170 | int AliHLTTPCCompModelDeconverter::DeconvertClusters( UInt_t slice, UInt_t patch, AliHLTUInt8_t* data, UInt_t& size ) | |
171 | { | |
172 | // see header file for class documentation | |
173 | if ( size<sizeof(AliHLTTPCClusterData) ) | |
174 | return ENOBUFS; | |
175 | Int_t charge; | |
176 | Float_t pad,time,sigmaY2,sigmaZ2; | |
177 | AliHLTTPCClusterData* clusterData = (AliHLTTPCClusterData*)data; | |
178 | clusterData->fSpacePointCnt = 0; | |
179 | AliHLTTPCSpacePointData* clusters = clusterData->fSpacePoints; | |
180 | unsigned long outSize = sizeof(AliHLTTPCClusterData); | |
181 | for(Int_t i=0; i<fInputTrackArray.GetNTracks(); i++) | |
182 | { | |
183 | AliHLTTPCModelTrack *track = (AliHLTTPCModelTrack*)fInputTrackArray.GetCheckedTrack(i); | |
184 | if(!track) | |
185 | continue; | |
186 | for(Int_t padrow=AliHLTTPCTransform::GetFirstRow(patch); padrow <= AliHLTTPCTransform::GetLastRow(patch); padrow++) | |
187 | { | |
188 | if(!track->IsPresent(padrow)) | |
189 | continue; | |
190 | UInt_t thisSlice = track->GetClusterModel(padrow)->fSlice; | |
191 | if ( thisSlice != slice ) | |
192 | continue; | |
193 | if ( clusterData->fSpacePointCnt >= (1<<22) ) | |
194 | { | |
195 | HLTError( "Too many clusters for slice %d patch %d", slice, patch ); | |
196 | break; | |
197 | } | |
198 | if ( size<=outSize+sizeof(AliHLTTPCSpacePointData) ) | |
199 | { | |
200 | HLTError( "Not enough output space (%u bytes)", (unsigned)size ); | |
201 | return ENOBUFS; | |
202 | } | |
203 | track->GetPad(padrow,pad); | |
204 | track->GetTime(padrow,time); | |
205 | track->GetClusterCharge(padrow,charge); | |
206 | //NEW: Get parameters to create parSigma correctly | |
207 | //track->GetCrossingAngleLUT(padrow); | |
208 | //track->CalculateClusterWidths(padrow,kTRUE); // calculates parSigmas (with parametrisation) in raw coordinates | |
209 | //HLTInfo("dangle %f", track->GetCrossingAngleLUT(padrow)); | |
210 | //HLTInfo("dparsigma %f",track->GetParSigmaY2(padrow)); | |
211 | track->GetSigmaY2(padrow,sigmaY2); | |
212 | //AliHLTTPCClusterModel* test1 = track->GetClusterModel(padrow); | |
213 | //HLTInfo("DsigmaY deconv. : %f",test1->fDSigmaY); | |
214 | //HLTInfo("sigmaY2 deconv.: %f",sigmaY2); | |
215 | track->GetSigmaZ2(padrow,sigmaZ2); | |
216 | Float_t xyz[3]; | |
217 | AliHLTTPCTransform::RawHLT2Local( xyz, slice, padrow, pad, time ); | |
218 | clusters[clusterData->fSpacePointCnt].fX = xyz[0]; | |
219 | clusters[clusterData->fSpacePointCnt].fY = xyz[1]; | |
220 | clusters[clusterData->fSpacePointCnt].fZ = xyz[2]; | |
221 | clusters[clusterData->fSpacePointCnt].fPadRow = padrow; | |
222 | clusters[clusterData->fSpacePointCnt].fSigmaY2 = sigmaY2*pow(AliHLTTPCTransform::GetPadPitchWidth(patch),2); | |
223 | clusters[clusterData->fSpacePointCnt].fSigmaZ2 = sigmaZ2*pow(AliHLTTPCTransform::GetZWidth(),2);; | |
224 | clusters[clusterData->fSpacePointCnt].fCharge = charge; | |
f32c30b4 | 225 | clusters[clusterData->fSpacePointCnt].SetUsed(kTRUE); |
226 | clusters[clusterData->fSpacePointCnt].SetTrackNumber(i); | |
a371a266 | 227 | clusters[clusterData->fSpacePointCnt].SetID(slice,patch,clusterData->fSpacePointCnt); |
228 | ||
ff2f0f94 | 229 | clusterData->fSpacePointCnt++; |
230 | outSize += sizeof(AliHLTTPCSpacePointData); | |
231 | } | |
232 | } | |
233 | ||
234 | if ( fRemainingClustersModelDataSize ) | |
235 | { | |
236 | AliHLTUInt8_t* inputPtr = fRemainingClustersModelData+sizeof(AliHLTUInt32_t); | |
237 | AliHLTUInt8_t* inputEndPtr = inputPtr+fRemainingClustersModelDataSize; | |
238 | for ( UInt_t thisSlice=0; thisSlice<36; thisSlice++ ) | |
239 | { | |
240 | for ( UInt_t thisPatch=0; thisPatch<6; thisPatch++ ) | |
241 | { | |
242 | AliHLTUInt8_t rowCount = *inputPtr; | |
243 | inputPtr++; | |
244 | if ( !rowCount ) | |
245 | { | |
246 | if ( thisSlice==slice && thisPatch==patch ) | |
247 | break; | |
248 | continue; | |
249 | } | |
250 | for ( UInt_t jj=0; jj < rowCount; jj++ ) | |
251 | { | |
252 | AliHLTTPCRemainingRow *thisRow = (AliHLTTPCRemainingRow*)inputPtr; | |
253 | if ( inputPtr+sizeof(AliHLTTPCRemainingRow)>inputEndPtr ) | |
254 | { | |
255 | HLTError( "Corrupt input data, cannot read row data for row %u of slice %u, partition %u", (unsigned)jj, (unsigned)thisSlice, (unsigned)thisPatch ); | |
256 | return EIO; | |
257 | } | |
258 | AliHLTTPCRemainingCluster *cl = thisRow->fClusters; | |
259 | if ( inputPtr+sizeof(AliHLTTPCRemainingRow)+thisRow->fNClusters*sizeof(AliHLTTPCRemainingCluster)>inputEndPtr ) | |
260 | { | |
261 | HLTError( "Corrupt input data, unable to read clusters for row %u, slice %u, partition %u", (unsigned)jj, (unsigned)thisSlice, (unsigned)thisPatch ); | |
262 | return EIO; | |
263 | } | |
264 | Int_t padrow = thisRow->fPadRow; | |
265 | if ( slice==thisSlice && patch==thisPatch ) | |
266 | { | |
267 | for ( UInt_t ii=0; ii<thisRow->fNClusters; ii++ ) | |
268 | { | |
269 | Float_t xyz[3]; | |
270 | AliHLTTPCTransform::RawHLT2Local( xyz, slice, padrow, cl[ii].fPad, cl[ii].fTime ); | |
271 | clusters[clusterData->fSpacePointCnt].fX = xyz[0]; | |
272 | clusters[clusterData->fSpacePointCnt].fY = xyz[1]; | |
273 | clusters[clusterData->fSpacePointCnt].fZ = xyz[2]; | |
274 | clusters[clusterData->fSpacePointCnt].fPadRow = padrow; | |
275 | clusters[clusterData->fSpacePointCnt].fSigmaY2 = cl[ii].fSigmaY2*pow(AliHLTTPCTransform::GetPadPitchWidth(patch),2); | |
276 | clusters[clusterData->fSpacePointCnt].fSigmaZ2 = cl[ii].fSigmaZ2*pow(AliHLTTPCTransform::GetZWidth(),2);; | |
277 | clusters[clusterData->fSpacePointCnt].fCharge = cl[ii].fCharge; | |
f32c30b4 | 278 | clusters[clusterData->fSpacePointCnt].SetUsed(kFALSE); |
279 | clusters[clusterData->fSpacePointCnt].SetTrackNumber(-1); | |
a371a266 | 280 | clusters[clusterData->fSpacePointCnt].SetID(slice,patch,clusterData->fSpacePointCnt); |
ff2f0f94 | 281 | clusterData->fSpacePointCnt++; |
282 | outSize += sizeof(AliHLTTPCSpacePointData); | |
283 | } | |
284 | } | |
285 | inputPtr += sizeof(AliHLTTPCRemainingRow)+thisRow->fNClusters*sizeof(AliHLTTPCRemainingCluster); | |
286 | } | |
287 | ||
288 | } | |
289 | if ( thisSlice==slice ) | |
290 | break; | |
291 | } | |
292 | } | |
293 | ||
294 | size = outSize; | |
295 | return 0; | |
296 | } |