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