]>
Commit | Line | Data |
---|---|---|
f4ee4ed8 | 1 | // $Id$ |
2 | ||
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: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
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 | //************************************************************************** | |
18 | ||
19 | /// @file AliHLTTPCHWCFSpacePointContainer.cxx | |
20 | /// @author Matthias Richter | |
21 | /// @date 2011-08-08 | |
22 | /// @brief Helper class for handling of HLT TPC cluster data blocks from the | |
23 | /// HW ClusterFinder | |
24 | /// @note Class is a duplicate of AliHLTTPCHWCFSpacePointContainer and should | |
25 | /// be merged with it in a generic way | |
26 | ||
27 | #include "AliHLTTPCHWCFSpacePointContainer.h" | |
28 | #include "AliHLTErrorGuard.h" | |
29 | #include "AliHLTTPCDefinitions.h" | |
30 | #include "AliHLTTPCSpacePointData.h" | |
31 | #include "AliHLTTPCRawCluster.h" | |
32 | #include "AliHLTTPCTransform.h" | |
33 | #include "AliHLTComponent.h" | |
34 | #include "AliHLTTemplates.h" | |
35 | #include "AliRawDataHeader.h" | |
36 | #include "TMath.h" | |
37 | #include <memory> | |
38 | #include <algorithm> | |
39 | ||
40 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
41 | ClassImp(AliHLTTPCHWCFSpacePointContainer) | |
42 | ||
43 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointContainer() | |
44 | : AliHLTSpacePointContainer() | |
45 | , fClusters() | |
46 | , fSelections() | |
47 | , fDecoders() | |
48 | { | |
49 | // see header file for class documentation | |
50 | // or | |
51 | // refer to README to build package | |
52 | // or | |
53 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
54 | } | |
55 | ||
56 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointContainer(const AliHLTTPCHWCFSpacePointContainer& c) | |
57 | : AliHLTSpacePointContainer(c) | |
58 | , fClusters(c.fClusters.begin(), c.fClusters.end()) | |
59 | , fSelections() | |
60 | , fDecoders() | |
61 | { | |
62 | /// copy constructor | |
63 | } | |
64 | ||
65 | AliHLTTPCHWCFSpacePointContainer& AliHLTTPCHWCFSpacePointContainer::operator=(const AliHLTTPCHWCFSpacePointContainer& c) | |
66 | { | |
67 | /// assignment operator | |
68 | if (&c==this) return *this; | |
69 | AliHLTSpacePointContainer::operator=(c); | |
70 | fClusters=c.fClusters; | |
71 | ||
72 | return *this; | |
73 | } | |
74 | ||
75 | AliHLTTPCHWCFSpacePointContainer::~AliHLTTPCHWCFSpacePointContainer() | |
76 | { | |
77 | // destructor | |
78 | Clear(); | |
79 | } | |
80 | ||
81 | int AliHLTTPCHWCFSpacePointContainer::AddInputBlock(const AliHLTComponentBlockData* pDesc) | |
82 | { | |
83 | // add input block to the collection | |
84 | if (!pDesc) return -EINVAL; | |
85 | int count=0; | |
86 | if (pDesc->fDataType!=AliHLTTPCDefinitions::fgkHWClustersDataType) { | |
87 | HLTWarning("ignoring data block of type %s", AliHLTComponent::DataType2Text(pDesc->fDataType).c_str()); | |
88 | return 0; | |
89 | } | |
90 | if (!pDesc->fPtr) return -ENODATA; | |
91 | if (pDesc->fSize<=sizeof(AliRawDataHeader)) return 0; | |
92 | ||
93 | AliHLTUInt32_t *buffer=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr); | |
94 | // skip the first 8 32-bit CDH words | |
95 | buffer += 8; | |
96 | UInt_t bufferSize32 = ((Int_t)pDesc->fSize - sizeof(AliRawDataHeader) )/sizeof(AliHLTUInt32_t); | |
97 | ||
98 | std::auto_ptr<AliHLTTPCHWCFData> pDecoder(new AliHLTTPCHWCFData); | |
99 | if (!pDecoder.get()) return -ENOMEM; | |
100 | ||
101 | if (pDecoder->Init(reinterpret_cast<AliHLTUInt8_t*>(buffer), bufferSize32*sizeof(AliHLTUInt32_t))<0 || | |
596c3446 | 102 | (pDecoder->CheckVersion()<0 && (int)bufferSize32>pDecoder->GetRCUTrailerSize())) { |
f4ee4ed8 | 103 | HLTError("data block of type %s corrupted: can not decode format", |
104 | AliHLTComponent::DataType2Text(pDesc->fDataType).c_str()); | |
105 | return -EBADMSG; | |
106 | } | |
107 | ||
108 | UInt_t nofClusters=pDecoder->GetNumberOfClusters(); | |
109 | ||
110 | AliHLTUInt8_t minslice = AliHLTTPCDefinitions::GetMinSliceNr( pDesc->fSpecification ); | |
111 | AliHLTUInt8_t minpart = AliHLTTPCDefinitions::GetMinPatchNr( pDesc->fSpecification ); | |
112 | ||
113 | for (UInt_t i=0; i<nofClusters; i++) { | |
114 | AliHLTUInt32_t clusterID=~(AliHLTUInt32_t)0; | |
115 | // cluster ID from slice, partition and index | |
116 | clusterID=AliHLTTPCSpacePointData::GetID(minslice, minpart, i); | |
117 | ||
118 | if (fClusters.find(clusterID)==fClusters.end()) { | |
119 | // new cluster | |
120 | fClusters[clusterID]=AliHLTTPCHWCFSpacePointProperties(pDecoder.get(), i); | |
121 | count++; | |
122 | } else { | |
123 | HLTError("cluster with ID 0x%08x already existing, skipping cluster %d of data block 0x%08x", | |
124 | clusterID, i, pDesc->fSpecification); | |
125 | } | |
126 | } | |
127 | ||
128 | fDecoders.push_back(pDecoder.release()); | |
129 | ||
130 | return count; | |
131 | } | |
132 | ||
133 | int AliHLTTPCHWCFSpacePointContainer::GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const | |
134 | { | |
135 | // get array of cluster IDs | |
136 | tgt.clear(); | |
137 | transform(fClusters.begin(), fClusters.end(), back_inserter(tgt), HLT::AliGetKey()); | |
138 | return tgt.size(); | |
139 | } | |
140 | ||
141 | bool AliHLTTPCHWCFSpacePointContainer::Check(AliHLTUInt32_t clusterID) const | |
142 | { | |
143 | // check if the cluster is available | |
144 | return fClusters.find(clusterID)!=fClusters.end(); | |
145 | } | |
146 | ||
147 | const vector<AliHLTUInt32_t>* AliHLTTPCHWCFSpacePointContainer::GetClusterIDs(AliHLTUInt32_t mask) | |
148 | { | |
149 | // get array of cluster IDs filtered by mask | |
150 | if (fSelections.find(mask)!=fSelections.end()) { | |
151 | // return existing selection | |
152 | return fSelections.find(mask)->second; | |
153 | } | |
154 | // create new collection | |
155 | vector<AliHLTUInt32_t>* selected=new vector<AliHLTUInt32_t>; | |
156 | if (!selected) return NULL; | |
157 | UInt_t slice=AliHLTTPCSpacePointData::GetSlice(mask); | |
158 | UInt_t partition=AliHLTTPCSpacePointData::GetPatch(mask); | |
159 | //HLTInfo("creating collection 0x%08x", mask); | |
160 | ||
161 | // the first cluster with number 0 has equal ID to mask unless | |
162 | // the mask selects multiple partitions/slices | |
163 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(mask); | |
164 | bool bAll=false; | |
165 | if (slice>=(unsigned)AliHLTTPCTransform::GetNSlice() || | |
166 | partition>=(unsigned)AliHLTTPCTransform::GetNumberOfPatches()) { | |
167 | cl=fClusters.begin(); | |
168 | bAll=true; | |
169 | } | |
170 | for (; cl!=fClusters.end(); cl++) { | |
171 | UInt_t s=AliHLTTPCSpacePointData::GetSlice(cl->first); | |
172 | UInt_t p=AliHLTTPCSpacePointData::GetPatch(cl->first); | |
173 | if ((slice>=(unsigned)AliHLTTPCTransform::GetNSlice() || s==slice) && | |
174 | (partition>=(unsigned)AliHLTTPCTransform::GetNumberOfPatches() || p==partition)) { | |
175 | selected->push_back(cl->first); | |
176 | } else if (!bAll) { | |
177 | // no need to continue, we are out of the range | |
178 | break; | |
179 | } | |
180 | } | |
181 | //HLTInfo("collection 0x%08x with %d spacepoints", mask, selected->size()); | |
182 | fSelections[mask]=selected; | |
183 | return selected; | |
184 | } | |
185 | ||
186 | float AliHLTTPCHWCFSpacePointContainer::GetX(AliHLTUInt32_t clusterID) const | |
187 | { | |
188 | // get X coordinate | |
189 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
190 | if (cl==fClusters.end() || | |
191 | cl->second.Decoder()==NULL) return 0.0; | |
192 | // FIXME: understand deviation from the nominal x value | |
193 | // there is a small deviation in the x coordinate - padrow number correlation | |
194 | // in principle, the clusterfinder only uses the mapping to set the x parameter. | |
195 | // now extracting the x value from the padrow no. | |
196 | //return cl->second.Decoder()->fX; | |
197 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
198 | return AliHLTTPCTransform::Row2X(cl->second.Decoder()->GetPadRow(index)); | |
199 | } | |
200 | ||
201 | float AliHLTTPCHWCFSpacePointContainer::GetXWidth(AliHLTUInt32_t clusterID) const | |
202 | { | |
203 | // get error for X coordinate | |
204 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
205 | if (cl==fClusters.end() || | |
206 | cl->second.Decoder()==NULL) return 0.0; | |
207 | return 0.0; // fixed in padrow number | |
208 | } | |
209 | ||
210 | float AliHLTTPCHWCFSpacePointContainer::GetY(AliHLTUInt32_t clusterID) const | |
211 | { | |
212 | // get Y coordinate | |
213 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
214 | if (cl==fClusters.end() || | |
215 | cl->second.Decoder()==NULL) return 0.0; | |
216 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
217 | return cl->second.Decoder()->GetPad(index); | |
218 | } | |
219 | ||
220 | float AliHLTTPCHWCFSpacePointContainer::GetYWidth(AliHLTUInt32_t clusterID) const | |
221 | { | |
222 | // get error for Y coordinate | |
223 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
224 | if (cl==fClusters.end() || | |
225 | cl->second.Decoder()==NULL) return 0.0; | |
226 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
227 | return cl->second.Decoder()->GetSigmaY2(index); | |
228 | } | |
229 | ||
230 | float AliHLTTPCHWCFSpacePointContainer::GetZ(AliHLTUInt32_t clusterID) const | |
231 | { | |
232 | // get Z coordinate | |
233 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
234 | if (cl==fClusters.end() || | |
235 | cl->second.Decoder()==NULL) return 0.0; | |
236 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
237 | return cl->second.Decoder()->GetTime(index); | |
238 | } | |
239 | ||
240 | float AliHLTTPCHWCFSpacePointContainer::GetZWidth(AliHLTUInt32_t clusterID) const | |
241 | { | |
242 | // get error for Z coordinate | |
243 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
244 | if (cl==fClusters.end() || | |
245 | cl->second.Decoder()==NULL) return 0.0; | |
246 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
247 | return cl->second.Decoder()->GetSigmaZ2(index); | |
248 | } | |
249 | ||
250 | float AliHLTTPCHWCFSpacePointContainer::GetCharge(AliHLTUInt32_t clusterID) const | |
251 | { | |
252 | // get charge | |
253 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID); | |
254 | if (cl==fClusters.end() || | |
255 | cl->second.Decoder()==NULL) return 0.0; | |
256 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
257 | return cl->second.Decoder()->GetCharge(index); | |
258 | } | |
259 | ||
260 | float AliHLTTPCHWCFSpacePointContainer::GetPhi(AliHLTUInt32_t clusterID) const | |
261 | { | |
262 | // get charge | |
263 | ||
264 | // phi can be derived directly from the id, no need to search | |
265 | // for existing cluster | |
266 | int slice=AliHLTTPCSpacePointData::GetSlice(clusterID); | |
267 | return ( slice + 0.5 ) * TMath::Pi() / 9.0; | |
268 | } | |
269 | ||
270 | void AliHLTTPCHWCFSpacePointContainer::Clear(Option_t * option) | |
271 | { | |
272 | // clear the object and reset pointer references | |
273 | fClusters.clear(); | |
274 | ||
275 | for (std::map<AliHLTUInt32_t, vector<AliHLTUInt32_t>*>::iterator selection=fSelections.begin(); | |
276 | selection!=fSelections.end(); selection++) { | |
277 | if (selection->second) delete selection->second; | |
278 | } | |
279 | fSelections.clear(); | |
280 | ||
281 | AliHLTSpacePointContainer::Clear(option); | |
282 | } | |
283 | ||
284 | void AliHLTTPCHWCFSpacePointContainer::Print(ostream& out, Option_t */*option*/) const | |
285 | { | |
286 | // print to stream | |
287 | out << "AliHLTTPCHWCFSpacePointContainer::Print" << endl; | |
288 | out << "n clusters: " << fClusters.size() << endl; | |
289 | for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin(); | |
290 | cl!=fClusters.end(); cl++) { | |
291 | out << " " << cl->first << cl->second << endl; | |
292 | } | |
293 | } | |
294 | ||
295 | AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMask(AliHLTUInt32_t mask, bool /*bAlloc*/) const | |
296 | { | |
297 | /// create a collection of clusters for a space point mask | |
298 | std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer); | |
299 | if (!c.get()) return NULL; | |
300 | ||
301 | UInt_t slice=AliHLTTPCSpacePointData::GetSlice(mask); | |
302 | UInt_t partition=AliHLTTPCSpacePointData::GetPatch(mask); | |
303 | for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin(); | |
304 | cl!=fClusters.end(); cl++) { | |
305 | UInt_t s=AliHLTTPCSpacePointData::GetSlice(cl->first); | |
306 | UInt_t p=AliHLTTPCSpacePointData::GetPatch(cl->first); | |
307 | if ((slice>=(unsigned)AliHLTTPCTransform::GetNSlice() || s==slice) && | |
308 | (partition>=(unsigned)AliHLTTPCTransform::GetNumberOfPatches() || p==partition)) { | |
309 | c->fClusters[cl->first]=cl->second; | |
310 | } | |
311 | } | |
312 | return c.release(); | |
313 | } | |
314 | ||
315 | AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByTrack(int trackId, bool /*bAlloc*/) const | |
316 | { | |
317 | /// create a collection of clusters for a specific track | |
318 | std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer); | |
319 | if (!c.get()) return NULL; | |
320 | ||
321 | HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetTrackId,trackId)); | |
322 | return c.release(); | |
323 | } | |
324 | ||
325 | AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMC(int mcId, bool /*bAlloc*/) const | |
326 | { | |
327 | /// create a collection of clusters for a specific MC track | |
328 | std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer); | |
329 | if (!c.get()) return NULL; | |
330 | ||
331 | HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetMCId,mcId)); | |
332 | return c.release(); | |
333 | } | |
334 | ||
335 | AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UsedClusters(bool /*bAlloc*/) const | |
336 | { | |
337 | /// create a collection of all used clusters | |
338 | std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer); | |
339 | if (!c.get()) return NULL; | |
340 | ||
341 | HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,true)); | |
342 | return c.release(); | |
343 | } | |
344 | ||
345 | AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UnusedClusters(bool /*bAlloc*/) const | |
346 | { | |
347 | /// create a collection of all unused clusters | |
348 | std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer); | |
349 | if (!c.get()) return NULL; | |
350 | ||
351 | HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,false)); | |
352 | return c.release(); | |
353 | } | |
354 | ||
355 | int AliHLTTPCHWCFSpacePointContainer::MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize) | |
356 | { | |
357 | /// mark the clusters with specified IDs as used | |
358 | if (!clusterIDs) return -EINVAL; | |
359 | int iCount=0; | |
360 | for (int i=0; i<arraySize; i++) { | |
361 | if (fClusters.find(clusterIDs[i])==fClusters.end()) continue; | |
362 | fClusters[clusterIDs[i]].MarkUsed(); | |
363 | iCount++; | |
364 | } | |
365 | return iCount; | |
366 | } | |
367 | ||
368 | int AliHLTTPCHWCFSpacePointContainer::SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize) | |
369 | { | |
370 | /// set track id for specified clusters | |
371 | if (!clusterIDs) return -EINVAL; | |
372 | int iCount=0; | |
373 | for (int i=0; i<arraySize; i++) { | |
374 | if (fClusters.find(clusterIDs[i])==fClusters.end()) continue; | |
375 | fClusters[clusterIDs[i]].SetTrackId(trackID); | |
376 | iCount++; | |
377 | } | |
378 | return iCount; | |
379 | } | |
380 | ||
381 | int AliHLTTPCHWCFSpacePointContainer::GetTrackID(AliHLTUInt32_t clusterID) const | |
382 | { | |
383 | /// get track id for specified cluster | |
384 | map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator element=fClusters.find(clusterID); | |
385 | if (element==fClusters.end()) return -1; | |
386 | return element->second.GetTrackId(); | |
387 | } | |
388 | ||
389 | int AliHLTTPCHWCFSpacePointContainer::SetMCID(int mcID, const AliHLTUInt32_t* clusterIDs, int arraySize) | |
390 | { | |
391 | /// set mc id for specified clusters | |
392 | if (!clusterIDs) return -EINVAL; | |
393 | int iCount=0; | |
394 | for (int i=0; i<arraySize; i++) { | |
395 | if (fClusters.find(clusterIDs[i])==fClusters.end()) continue; | |
396 | fClusters[clusterIDs[i]].SetMCId(mcID); | |
397 | iCount++; | |
398 | } | |
399 | return iCount; | |
400 | } | |
401 | ||
402 | int AliHLTTPCHWCFSpacePointContainer::Write(AliHLTUInt8_t* outputPtr, AliHLTUInt32_t size, AliHLTComponentBlockDataList& outputBlocks, const char* /*option*/) const | |
403 | { | |
404 | /// write blocks to HLT component output | |
405 | if (!outputPtr) return -EINVAL; | |
406 | int iResult=0; | |
407 | AliHLTUInt32_t capacity=size; | |
408 | size=0; | |
409 | ||
410 | for (int slice=0; slice<AliHLTTPCTransform::GetNSlice(); slice++) { | |
411 | for (int part=0; part<AliHLTTPCTransform::GetNPatches(); part++) { | |
412 | AliHLTUInt32_t mask=AliHLTTPCSpacePointData::GetID(slice,part,0); | |
413 | // FIXME: make GetClusterIDs a const function and handle the cast there | |
414 | const vector<AliHLTUInt32_t>* collection=const_cast<AliHLTTPCHWCFSpacePointContainer*>(this)->GetClusterIDs(mask); | |
415 | if (!collection) continue; | |
416 | if (size+sizeof(AliHLTTPCRawClusterData)+collection->size()*sizeof(AliHLTTPCRawCluster)>capacity) { | |
417 | ALIHLTERRORGUARD(1,"too little space to write cluster output block"); | |
418 | return -ENOSPC; | |
419 | } | |
420 | AliHLTTPCRawClusterData* blockout=reinterpret_cast<AliHLTTPCRawClusterData*>(outputPtr+size); | |
421 | blockout->fVersion=0; | |
422 | blockout->fCount=0; | |
423 | vector<AliHLTUInt32_t>::const_iterator clusterID=collection->begin(); | |
424 | if (clusterID!=collection->end()) { | |
425 | std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(*clusterID); | |
426 | for (; clusterID!=collection->end(); clusterID++, cl++) { | |
427 | if (cl->first!=*clusterID) cl=fClusters.find(*clusterID); | |
428 | if (cl==fClusters.end() || cl->second.Decoder()==NULL) continue; | |
429 | AliHLTTPCRawCluster& c=blockout->fClusters[blockout->fCount]; | |
430 | int index=AliHLTTPCSpacePointData::GetNumber(cl->first); | |
431 | int padrow=cl->second.Decoder()->GetPadRow(index); | |
432 | if (padrow<0) { | |
433 | // something wrong here, padrow is stored in the cluster header | |
434 | // word which has bit pattern 0x3 in bits bit 30 and 31 which was | |
435 | // not recognized | |
436 | ALIHLTERRORGUARD(1, "can not read cluster header word"); | |
437 | break; | |
438 | } | |
439 | padrow+=AliHLTTPCTransform::GetFirstRow(part); | |
440 | c.SetPadRow(padrow); | |
441 | c.SetCharge(cl->second.Decoder()->GetCharge(index)); | |
442 | // FIXME: the HW ClusterFinder returns only the sum | |
443 | // sum(q_i*pad_i*pad_i)/sum(q_i) | |
444 | // where the mean needs to be subtracted, not yet in the decoder | |
445 | // but should be implemented there | |
446 | float pad =cl->second.Decoder()->GetPad(index); | |
447 | float time =cl->second.Decoder()->GetTime(index); | |
448 | float sigmaY2=cl->second.Decoder()->GetSigmaY2(index); | |
449 | float sigmaZ2=cl->second.Decoder()->GetSigmaZ2(index); | |
450 | sigmaY2-=pad*pad; | |
451 | sigmaZ2-=time*time; | |
452 | c.SetPad(pad); | |
453 | c.SetTime(time); | |
454 | c.SetSigmaY2(sigmaY2); | |
455 | c.SetSigmaZ2(sigmaZ2); | |
456 | c.SetQMax(cl->second.Decoder()->GetQMax(index)); | |
457 | blockout->fCount++; | |
458 | } | |
459 | } | |
460 | AliHLTComponent_BlockData bd; | |
461 | AliHLTComponent::FillBlockData(bd); | |
462 | bd.fOffset = size; | |
463 | bd.fSize = sizeof(AliHLTTPCRawClusterData)+blockout->fCount*sizeof(AliHLTTPCRawCluster); | |
464 | bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, part, part); | |
465 | bd.fDataType = AliHLTTPCDefinitions::fgkRawClustersDataType; | |
466 | outputBlocks.push_back(bd); | |
467 | ||
468 | size += bd.fSize; | |
469 | } | |
470 | } | |
471 | ||
472 | if (iResult<0) return iResult; | |
473 | return size; | |
474 | } | |
475 | ||
476 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties() | |
477 | : fDecoder(NULL) | |
478 | , fIndex(-1) | |
479 | , fUsed(false) | |
480 | , fTrackId(-1) | |
481 | , fMCId(-1) | |
482 | { | |
483 | // constructor | |
484 | } | |
485 | ||
486 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index) | |
487 | : fDecoder(pDecoder) | |
488 | , fIndex(index) | |
489 | , fUsed(false) | |
490 | , fTrackId(-1) | |
491 | , fMCId(-1) | |
492 | { | |
493 | // constructor | |
494 | } | |
495 | ||
496 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src) | |
497 | : fDecoder(src.fDecoder) | |
498 | , fIndex(src.fIndex) | |
499 | , fUsed(src.fUsed) | |
500 | , fTrackId(src.fTrackId) | |
501 | , fMCId(src.fMCId) | |
502 | { | |
503 | // copy constructor | |
504 | } | |
505 | ||
506 | AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::operator=(const AliHLTTPCHWCFSpacePointProperties& src) | |
507 | { | |
508 | // assignment operator | |
509 | if (&src==this) return *this; | |
510 | fDecoder=src.fDecoder; | |
511 | fIndex=src.fIndex; | |
512 | fUsed=src.fUsed; | |
513 | fTrackId=src.fTrackId; | |
514 | fMCId=src.fMCId; | |
515 | ||
516 | return *this; | |
517 | } | |
518 | ||
519 | void AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::Print(ostream& out, Option_t */*option*/) const | |
520 | { | |
521 | // print info | |
522 | if (!Decoder()) { | |
523 | out << "no data"; | |
524 | return; | |
525 | } | |
526 | const AliHLTTPCHWCFData* decoder=Decoder(); | |
527 | out << " " << decoder->GetPadRow(fIndex) << " " << decoder->GetPad(fIndex) << " " << decoder->GetTime(fIndex) | |
528 | << " " << decoder->GetSigmaY2(fIndex) << " " << decoder->GetSigmaZ2(fIndex) | |
529 | << " " << decoder->GetCharge(fIndex) << " " << decoder->GetQMax(fIndex) | |
530 | << " " << fTrackId << " " << fMCId << " " << fUsed; | |
531 | } | |
532 | ||
533 | ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p) | |
534 | { | |
535 | p.Print(out); | |
536 | return out; | |
537 | } |