bayesian PID + several bugfixes + small enhancements
[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"
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"
ba027032 35#include "AliHLTDataDeflater.h"
f4ee4ed8 36#include "AliRawDataHeader.h"
71300445 37#include "AliLog.h"
f4ee4ed8 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
71300445 418 for (int slice=0; slice<AliHLTTPCTransform::GetNSlice() && iResult>=0; slice++) {
419 for (int part=0; part<AliHLTTPCTransform::GetNPatches() && iResult>=0; part++) {
f4ee4ed8 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");
71300445 426 iResult=-ENOSPC;
427 break;
f4ee4ed8 428 }
429 AliHLTTPCRawClusterData* blockout=reinterpret_cast<AliHLTTPCRawClusterData*>(outputPtr+size);
430 blockout->fVersion=0;
431 blockout->fCount=0;
ba027032 432
433 if (pDeflater) {
434 pDeflater->Clear();
435 pDeflater->InitBitDataOutput(reinterpret_cast<AliHLTUInt8_t*>(blockout->fClusters), capacity-size-sizeof(AliHLTTPCRawClusterData));
436 blockout->fVersion=pDeflater->GetDeflaterVersion();
437 }
438
71300445 439 unsigned lastPadRow=0;
f4ee4ed8 440 vector<AliHLTUInt32_t>::const_iterator clusterID=collection->begin();
441 if (clusterID!=collection->end()) {
442 std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(*clusterID);
71300445 443 for (; clusterID!=collection->end(); clusterID++, (cl!=fClusters.end())?cl++:cl) {
f4ee4ed8 444 if (cl->first!=*clusterID) cl=fClusters.find(*clusterID);
445 if (cl==fClusters.end() || cl->second.Decoder()==NULL) continue;
f4ee4ed8 446 int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
447 int padrow=cl->second.Decoder()->GetPadRow(index);
448 if (padrow<0) {
449 // something wrong here, padrow is stored in the cluster header
450 // word which has bit pattern 0x3 in bits bit 30 and 31 which was
451 // not recognized
452 ALIHLTERRORGUARD(1, "can not read cluster header word");
453 break;
454 }
ba027032 455
f4ee4ed8 456 // FIXME: the HW ClusterFinder returns only the sum
457 // sum(q_i*pad_i*pad_i)/sum(q_i)
458 // where the mean needs to be subtracted, not yet in the decoder
459 // but should be implemented there
460 float pad =cl->second.Decoder()->GetPad(index);
461 float time =cl->second.Decoder()->GetTime(index);
462 float sigmaY2=cl->second.Decoder()->GetSigmaY2(index);
463 float sigmaZ2=cl->second.Decoder()->GetSigmaZ2(index);
464 sigmaY2-=pad*pad;
465 sigmaZ2-=time*time;
ba027032 466
467 if (!pDeflater) {
468 AliHLTTPCRawCluster& c=blockout->fClusters[blockout->fCount];
469 padrow+=AliHLTTPCTransform::GetFirstRow(part);
470 c.SetPadRow(padrow);
471 c.SetCharge(cl->second.Decoder()->GetCharge(index));
472 c.SetPad(pad);
473 c.SetTime(time);
474 c.SetSigmaY2(sigmaY2);
475 c.SetSigmaZ2(sigmaZ2);
476 c.SetQMax(cl->second.Decoder()->GetQMax(index));
477 } else {
71300445 478 AliHLTUInt64_t padrow64=cl->second.Decoder()->GetPadRow(index);
479 // enable if padrows are ordered
480 if (padrow64>=lastPadRow) {
481 // padrow64-=lastPadRow;
482 // lastPadRow+=padrow64;
483 } else {
484 // AliFatal("padrows not ordered");
485 }
486
487 AliHLTUInt64_t pad64
488 =(AliHLTUInt64_t)round(pad*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kPad].fScale);
489 AliHLTUInt64_t time64
490 =(AliHLTUInt64_t)round(time*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kTime].fScale);
491 AliHLTUInt64_t sigmaY264
492 =(AliHLTUInt64_t)round(sigmaY2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaY2].fScale);
493 AliHLTUInt64_t sigmaZ264
494 =(AliHLTUInt64_t)round(sigmaZ2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaZ2].fScale);
495 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPadRow , padrow64);
496 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPad , pad64);
497 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kTime , time64);
498 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaY2, sigmaY264);
499 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaZ2, sigmaZ264);
500 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kCharge , cl->second.Decoder()->GetCharge(index));
501 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kQMax , cl->second.Decoder()->GetQMax(index));
ba027032 502 }
f4ee4ed8 503 blockout->fCount++;
504 }
505 }
506 AliHLTComponent_BlockData bd;
507 AliHLTComponent::FillBlockData(bd);
508 bd.fOffset = size;
ba027032 509 if (!pDeflater) {
510 bd.fSize = sizeof(AliHLTTPCRawClusterData)+blockout->fCount*sizeof(AliHLTTPCRawCluster);
511 } else {
512 pDeflater->Pad8Bits();
513 bd.fSize = sizeof(AliHLTTPCRawClusterData)+pDeflater->GetBitDataOutputSizeBytes();
514 pDeflater->CloseBitDataOutput();
515 }
f4ee4ed8 516 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, part, part);
517 bd.fDataType = AliHLTTPCDefinitions::fgkRawClustersDataType;
518 outputBlocks.push_back(bd);
519
520 size += bd.fSize;
521 }
522 }
523
524 if (iResult<0) return iResult;
525 return size;
526}
527
528AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties()
529 : fDecoder(NULL)
530 , fIndex(-1)
531 , fUsed(false)
532 , fTrackId(-1)
533 , fMCId(-1)
534{
535 // constructor
536}
537
538AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index)
539 : fDecoder(pDecoder)
540 , fIndex(index)
541 , fUsed(false)
542 , fTrackId(-1)
543 , fMCId(-1)
544{
545 // constructor
546}
547
548AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src)
549 : fDecoder(src.fDecoder)
550 , fIndex(src.fIndex)
551 , fUsed(src.fUsed)
552 , fTrackId(src.fTrackId)
553 , fMCId(src.fMCId)
554{
555 // copy constructor
556}
557
558AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::operator=(const AliHLTTPCHWCFSpacePointProperties& src)
559{
560 // assignment operator
561 if (&src==this) return *this;
562 fDecoder=src.fDecoder;
563 fIndex=src.fIndex;
564 fUsed=src.fUsed;
565 fTrackId=src.fTrackId;
566 fMCId=src.fMCId;
567
568 return *this;
569}
570
571void AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::Print(ostream& out, Option_t */*option*/) const
572{
573 // print info
574 if (!Decoder()) {
575 out << "no data";
576 return;
577 }
578 const AliHLTTPCHWCFData* decoder=Decoder();
579 out << " " << decoder->GetPadRow(fIndex) << " " << decoder->GetPad(fIndex) << " " << decoder->GetTime(fIndex)
580 << " " << decoder->GetSigmaY2(fIndex) << " " << decoder->GetSigmaZ2(fIndex)
581 << " " << decoder->GetCharge(fIndex) << " " << decoder->GetQMax(fIndex)
582 << " " << fTrackId << " " << fMCId << " " << fUsed;
583}
584
585ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p)
586{
587 p.Print(out);
588 return out;
589}