adding option to set number of events for simulation
[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
20e47e30 284 for (std::vector<AliHLTTPCHWCFData*>::iterator decoder=fDecoders.begin();
285 decoder!=fDecoders.end(); decoder++) {
286 if (*decoder) delete *decoder;
287 }
288 fDecoders.clear();
289
f4ee4ed8 290 AliHLTSpacePointContainer::Clear(option);
291}
292
293void AliHLTTPCHWCFSpacePointContainer::Print(ostream& out, Option_t */*option*/) const
294{
295 // print to stream
296 out << "AliHLTTPCHWCFSpacePointContainer::Print" << endl;
297 out << "n clusters: " << fClusters.size() << endl;
298 for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin();
299 cl!=fClusters.end(); cl++) {
300 out << " " << cl->first << cl->second << endl;
301 }
302}
303
304AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMask(AliHLTUInt32_t mask, bool /*bAlloc*/) const
305{
306 /// create a collection of clusters for a space point mask
307 std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
308 if (!c.get()) return NULL;
309
310 UInt_t slice=AliHLTTPCSpacePointData::GetSlice(mask);
311 UInt_t partition=AliHLTTPCSpacePointData::GetPatch(mask);
312 for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin();
313 cl!=fClusters.end(); cl++) {
314 UInt_t s=AliHLTTPCSpacePointData::GetSlice(cl->first);
315 UInt_t p=AliHLTTPCSpacePointData::GetPatch(cl->first);
316 if ((slice>=(unsigned)AliHLTTPCTransform::GetNSlice() || s==slice) &&
317 (partition>=(unsigned)AliHLTTPCTransform::GetNumberOfPatches() || p==partition)) {
318 c->fClusters[cl->first]=cl->second;
319 }
320 }
321 return c.release();
322}
323
324AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByTrack(int trackId, bool /*bAlloc*/) const
325{
326 /// create a collection of clusters for a specific track
327 std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
328 if (!c.get()) return NULL;
329
330 HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetTrackId,trackId));
331 return c.release();
332}
333
334AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMC(int mcId, bool /*bAlloc*/) const
335{
336 /// create a collection of clusters for a specific MC track
337 std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
338 if (!c.get()) return NULL;
339
340 HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetMCId,mcId));
341 return c.release();
342}
343
344AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UsedClusters(bool /*bAlloc*/) const
345{
346 /// create a collection of all used clusters
347 std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
348 if (!c.get()) return NULL;
349
350 HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,true));
351 return c.release();
352}
353
354AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UnusedClusters(bool /*bAlloc*/) const
355{
356 /// create a collection of all unused clusters
357 std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
358 if (!c.get()) return NULL;
359
360 HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,false));
361 return c.release();
362}
363
364int AliHLTTPCHWCFSpacePointContainer::MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize)
365{
366 /// mark the clusters with specified IDs as used
367 if (!clusterIDs) return -EINVAL;
368 int iCount=0;
369 for (int i=0; i<arraySize; i++) {
370 if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
371 fClusters[clusterIDs[i]].MarkUsed();
372 iCount++;
373 }
374 return iCount;
375}
376
377int AliHLTTPCHWCFSpacePointContainer::SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize)
378{
379 /// set track id for specified clusters
380 if (!clusterIDs) return -EINVAL;
381 int iCount=0;
382 for (int i=0; i<arraySize; i++) {
383 if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
384 fClusters[clusterIDs[i]].SetTrackId(trackID);
385 iCount++;
386 }
387 return iCount;
388}
389
390int AliHLTTPCHWCFSpacePointContainer::GetTrackID(AliHLTUInt32_t clusterID) const
391{
392 /// get track id for specified cluster
393 map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator element=fClusters.find(clusterID);
394 if (element==fClusters.end()) return -1;
395 return element->second.GetTrackId();
396}
397
398int AliHLTTPCHWCFSpacePointContainer::SetMCID(int mcID, const AliHLTUInt32_t* clusterIDs, int arraySize)
399{
400 /// set mc id for specified clusters
401 if (!clusterIDs) return -EINVAL;
402 int iCount=0;
403 for (int i=0; i<arraySize; i++) {
404 if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
405 fClusters[clusterIDs[i]].SetMCId(mcID);
406 iCount++;
407 }
408 return iCount;
409}
410
ba027032 411int AliHLTTPCHWCFSpacePointContainer::Write(AliHLTUInt8_t* outputPtr,
412 AliHLTUInt32_t size,
413 AliHLTComponentBlockDataList&
414 outputBlocks,
415 AliHLTDataDeflater* pDeflater,
416 const char* /*option*/) const
f4ee4ed8 417{
418 /// write blocks to HLT component output
419 if (!outputPtr) return -EINVAL;
420 int iResult=0;
421 AliHLTUInt32_t capacity=size;
422 size=0;
423
71300445 424 for (int slice=0; slice<AliHLTTPCTransform::GetNSlice() && iResult>=0; slice++) {
425 for (int part=0; part<AliHLTTPCTransform::GetNPatches() && iResult>=0; part++) {
f4ee4ed8 426 AliHLTUInt32_t mask=AliHLTTPCSpacePointData::GetID(slice,part,0);
427 // FIXME: make GetClusterIDs a const function and handle the cast there
428 const vector<AliHLTUInt32_t>* collection=const_cast<AliHLTTPCHWCFSpacePointContainer*>(this)->GetClusterIDs(mask);
429 if (!collection) continue;
430 if (size+sizeof(AliHLTTPCRawClusterData)+collection->size()*sizeof(AliHLTTPCRawCluster)>capacity) {
431 ALIHLTERRORGUARD(1,"too little space to write cluster output block");
71300445 432 iResult=-ENOSPC;
433 break;
f4ee4ed8 434 }
435 AliHLTTPCRawClusterData* blockout=reinterpret_cast<AliHLTTPCRawClusterData*>(outputPtr+size);
436 blockout->fVersion=0;
437 blockout->fCount=0;
ba027032 438
439 if (pDeflater) {
440 pDeflater->Clear();
441 pDeflater->InitBitDataOutput(reinterpret_cast<AliHLTUInt8_t*>(blockout->fClusters), capacity-size-sizeof(AliHLTTPCRawClusterData));
442 blockout->fVersion=pDeflater->GetDeflaterVersion();
443 }
444
71300445 445 unsigned lastPadRow=0;
f4ee4ed8 446 vector<AliHLTUInt32_t>::const_iterator clusterID=collection->begin();
447 if (clusterID!=collection->end()) {
448 std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(*clusterID);
71300445 449 for (; clusterID!=collection->end(); clusterID++, (cl!=fClusters.end())?cl++:cl) {
20e47e30 450 if (cl!=fClusters.end() && cl->first!=*clusterID) cl=fClusters.find(*clusterID);
f4ee4ed8 451 if (cl==fClusters.end() || cl->second.Decoder()==NULL) continue;
f4ee4ed8 452 int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
453 int padrow=cl->second.Decoder()->GetPadRow(index);
454 if (padrow<0) {
455 // something wrong here, padrow is stored in the cluster header
456 // word which has bit pattern 0x3 in bits bit 30 and 31 which was
457 // not recognized
458 ALIHLTERRORGUARD(1, "can not read cluster header word");
459 break;
460 }
ba027032 461
f4ee4ed8 462 // FIXME: the HW ClusterFinder returns only the sum
463 // sum(q_i*pad_i*pad_i)/sum(q_i)
464 // where the mean needs to be subtracted, not yet in the decoder
465 // but should be implemented there
466 float pad =cl->second.Decoder()->GetPad(index);
467 float time =cl->second.Decoder()->GetTime(index);
468 float sigmaY2=cl->second.Decoder()->GetSigmaY2(index);
469 float sigmaZ2=cl->second.Decoder()->GetSigmaZ2(index);
470 sigmaY2-=pad*pad;
471 sigmaZ2-=time*time;
ba027032 472
473 if (!pDeflater) {
474 AliHLTTPCRawCluster& c=blockout->fClusters[blockout->fCount];
475 padrow+=AliHLTTPCTransform::GetFirstRow(part);
476 c.SetPadRow(padrow);
477 c.SetCharge(cl->second.Decoder()->GetCharge(index));
478 c.SetPad(pad);
479 c.SetTime(time);
480 c.SetSigmaY2(sigmaY2);
481 c.SetSigmaZ2(sigmaZ2);
482 c.SetQMax(cl->second.Decoder()->GetQMax(index));
483 } else {
71300445 484 AliHLTUInt64_t padrow64=cl->second.Decoder()->GetPadRow(index);
485 // enable if padrows are ordered
486 if (padrow64>=lastPadRow) {
487 // padrow64-=lastPadRow;
488 // lastPadRow+=padrow64;
489 } else {
490 // AliFatal("padrows not ordered");
491 }
492
493 AliHLTUInt64_t pad64
494 =(AliHLTUInt64_t)round(pad*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kPad].fScale);
495 AliHLTUInt64_t time64
496 =(AliHLTUInt64_t)round(time*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kTime].fScale);
497 AliHLTUInt64_t sigmaY264
498 =(AliHLTUInt64_t)round(sigmaY2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaY2].fScale);
499 AliHLTUInt64_t sigmaZ264
500 =(AliHLTUInt64_t)round(sigmaZ2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaZ2].fScale);
501 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPadRow , padrow64);
502 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPad , pad64);
503 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kTime , time64);
504 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaY2, sigmaY264);
505 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaZ2, sigmaZ264);
506 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kCharge , cl->second.Decoder()->GetCharge(index));
507 pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kQMax , cl->second.Decoder()->GetQMax(index));
ba027032 508 }
f4ee4ed8 509 blockout->fCount++;
510 }
511 }
512 AliHLTComponent_BlockData bd;
513 AliHLTComponent::FillBlockData(bd);
514 bd.fOffset = size;
ba027032 515 if (!pDeflater) {
516 bd.fSize = sizeof(AliHLTTPCRawClusterData)+blockout->fCount*sizeof(AliHLTTPCRawCluster);
517 } else {
518 pDeflater->Pad8Bits();
519 bd.fSize = sizeof(AliHLTTPCRawClusterData)+pDeflater->GetBitDataOutputSizeBytes();
520 pDeflater->CloseBitDataOutput();
521 }
f4ee4ed8 522 bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, part, part);
523 bd.fDataType = AliHLTTPCDefinitions::fgkRawClustersDataType;
524 outputBlocks.push_back(bd);
525
526 size += bd.fSize;
527 }
528 }
529
530 if (iResult<0) return iResult;
531 return size;
532}
533
534AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties()
535 : fDecoder(NULL)
536 , fIndex(-1)
537 , fUsed(false)
538 , fTrackId(-1)
539 , fMCId(-1)
540{
541 // constructor
542}
543
544AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index)
545 : fDecoder(pDecoder)
546 , fIndex(index)
547 , fUsed(false)
548 , fTrackId(-1)
549 , fMCId(-1)
550{
551 // constructor
552}
553
554AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src)
555 : fDecoder(src.fDecoder)
556 , fIndex(src.fIndex)
557 , fUsed(src.fUsed)
558 , fTrackId(src.fTrackId)
559 , fMCId(src.fMCId)
560{
561 // copy constructor
562}
563
564AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::operator=(const AliHLTTPCHWCFSpacePointProperties& src)
565{
566 // assignment operator
567 if (&src==this) return *this;
568 fDecoder=src.fDecoder;
569 fIndex=src.fIndex;
570 fUsed=src.fUsed;
571 fTrackId=src.fTrackId;
572 fMCId=src.fMCId;
573
574 return *this;
575}
576
577void AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::Print(ostream& out, Option_t */*option*/) const
578{
579 // print info
580 if (!Decoder()) {
581 out << "no data";
582 return;
583 }
584 const AliHLTTPCHWCFData* decoder=Decoder();
585 out << " " << decoder->GetPadRow(fIndex) << " " << decoder->GetPad(fIndex) << " " << decoder->GetTime(fIndex)
586 << " " << decoder->GetSigmaY2(fIndex) << " " << decoder->GetSigmaZ2(fIndex)
587 << " " << decoder->GetCharge(fIndex) << " " << decoder->GetQMax(fIndex)
588 << " " << fTrackId << " " << fMCId << " " << fUsed;
589}
590
591ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p)
592{
593 p.Print(out);
594 return out;
595}