]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx
- input of cluster compression component is changed to AliHLTTPCRawCluster format;
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterAccessHLTOUT.cxx
CommitLineData
c54aa300 1// $Id$
2
3//**************************************************************************
0cfe753c 4//* This file is property of and copyright by the ALICE Project *
c54aa300 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 AliHLTTPCClusterAccessHLTOUT.h
20/// @author Matthias Richter
21/// @date 2011-06-06
22/// @brief Interface to HLT TPC clusters
23///
24
25#include "AliHLTTPCClusterAccessHLTOUT.h"
b60d3f6a 26#include "AliHLTTPCDataCompressionDecoder.h"
c54aa300 27#include "AliHLTTPCDefinitions.h"
28#include "AliHLTTPCClusterDataFormat.h"
5e75f4e0 29#include "AliHLTTPCRawCluster.h"
61e66346 30#include "AliHLTTPCTransform.h"
c54aa300 31#include "AliHLTOUT.h"
81e7f739 32#include "AliHLTComponent.h"
73db5fa6 33#include "AliHLTErrorGuard.h"
61e66346 34#include "AliHLTDataInflater.h"
c54aa300 35#include "AliLog.h"
36#include "AliHLTSystem.h"
37#include "AliHLTPluginBase.h"
38#include "AliTPCclusterMI.h"
de2b5702 39#include "AliTPCClustersRow.h"
40#include "AliTPCParam.h"
c54aa300 41#include "TClonesArray.h"
27dc742d 42#include "TString.h"
81e7f739 43#include <cstdlib>
44#include <string>
45#include <memory>
b60d3f6a 46#include <iostream>
47#include <iomanip>
c54aa300 48
49/** ROOT macro for the implementation of ROOT specific class methods */
50ClassImp(AliHLTTPCClusterAccessHLTOUT)
51
52AliHLTTPCClusterAccessHLTOUT::AliHLTTPCClusterAccessHLTOUT()
53 : TObject()
81e7f739 54 , fVerbosity(0)
c54aa300 55 , fClusters(NULL)
b60d3f6a 56 , fCurrentSector(-1)
768dad20 57 , fpDecoder(NULL)
de2b5702 58 , fTPCParam(NULL)
c54aa300 59{
60 // see header file for class documentation
61 // or
62 // refer to README to build package
63 // or
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65}
66
67AliHLTTPCClusterAccessHLTOUT::~AliHLTTPCClusterAccessHLTOUT()
68{
69 // destructor
70 if (fClusters) {
71 fClusters->Clear();
72 delete fClusters;
73 fClusters=NULL;
74 }
768dad20 75 if (fpDecoder) {
76 fpDecoder->Clear();
77 delete fpDecoder;
78 fpDecoder=NULL;
79 }
de2b5702 80 if (fTPCParam) {
81 // FIXME: a copy of the TPCParam object is not possible because there is
82 // no appropriate copy constructor or assignment operator, using as
83 // external pointer
84 //delete fTPCParam;
85 fTPCParam=NULL;
86 }
c54aa300 87}
88
81e7f739 89void AliHLTTPCClusterAccessHLTOUT::Execute(const char *method, const char *params, Int_t *error)
c54aa300 90{
91 /// inherited from TObject: abstract command interface
92 if (strcmp(method, "read")==0) {
81e7f739 93 int iResult=ProcessClusters(params);
94 if (error) *error=iResult;
95 return;
96 }
97 if (strcmp(method, "verbosity")==0) {
98 int iResult=0;
99 if (params) {
100 char* dummy;
101 int value=strtol(params, &dummy, 0);
102 if (dummy==NULL) {
103 fVerbosity=value;
104 } else {
105 AliError("invalid argument for command 'verbosity', expecting string with number");
106 }
107 } else {
108 iResult=-EINVAL;
109 }
c54aa300 110 if (error) *error=iResult;
111 return;
112 }
113}
114
115TObject* AliHLTTPCClusterAccessHLTOUT::FindObject(const char *name) const
116{
117 /// inherited from TObject: return the cluster array if name id "clusterarray"
b60d3f6a 118 if (strcmp(name, "clusterarray")==0) {
119 if (fCurrentSector<0) return NULL;
120 return fClusters->GetSectorArray(fCurrentSector);
121 }
c54aa300 122 return TObject::FindObject(name);
123}
124
de2b5702 125void AliHLTTPCClusterAccessHLTOUT::Copy(TObject &object) const
126{
127 /// inherited from TObject: supports writing of data to AliTPCClustersRow
128 AliTPCClustersRow* rowcl=dynamic_cast<AliTPCClustersRow*>(&object);
129 if (rowcl) {
130 int index=rowcl->GetID();
131 if (!fTPCParam) {
132 AliFatal("TPCParam object not initialized, use 'Copy()' funtion to initialize");
133 return;
134 }
135 int sector=-1;
136 int row=-1;
137 if (!fTPCParam->AdjustSectorRow(index, sector, row)) {
138 AliFatal(Form("failed to get sector and row for index %d", index));
139 return;
140 }
141 fClusters->FillSectorArray(rowcl->GetArray(), sector, row);
142 return;
143 }
144 AliTPCParam* tpcparam=dynamic_cast<AliTPCParam*>(&object);
145 if (tpcparam) {
146 // FIXME: can nor make a copy of the TPCparam object because
147 // there is no appropriate copy constructor or assignment operator
148 const_cast<AliHLTTPCClusterAccessHLTOUT*>(this)->fTPCParam=tpcparam;
149 return;
150 }
151 return TObject::Copy(object);
152}
153
154
b60d3f6a 155void AliHLTTPCClusterAccessHLTOUT::Clear(Option_t * option)
c54aa300 156{
157 /// inherited from TObject: cleanup
b60d3f6a 158 if (strcmp(option, "event")==0) {
159 if (fClusters) fClusters->Clear();
160 fCurrentSector=-1;
161 }
c54aa300 162}
163
b60d3f6a 164void AliHLTTPCClusterAccessHLTOUT::Print(Option_t *option) const
c54aa300 165{
166 /// inherited from TObject
b60d3f6a 167 if (fClusters) fClusters->Print(option);
c54aa300 168}
169
81e7f739 170int AliHLTTPCClusterAccessHLTOUT::ProcessClusters(const char* params)
c54aa300 171{
172 /// process the cluster data from HLTOUT and fill array
173 /// the cluster data can be in many different formats, e.g.
174 /// raw or compressed
175 int iResult=0;
81e7f739 176 TString strparams(params);
b60d3f6a 177 int sector=-1;
81e7f739 178 std::auto_ptr<TObjArray> tokens(strparams.Tokenize(" "));
179 if (!tokens.get()) return -ENOMEM;
180 for (int i=0; i< tokens->GetEntriesFast(); i++) {
181 if (!tokens->At(i)) continue;
182 TString argument=tokens->At(i)->GetName();
b60d3f6a 183 // the offline code enumerates first the 36 inner (partitions 0+1) and then 36 outer
184 // sectors (partitions 2-5)
81e7f739 185 if (argument.BeginsWith("sector=")) {
186 argument.ReplaceAll("sector=", "");
b60d3f6a 187 sector=argument.Atoi();
81e7f739 188 }
189 }
b60d3f6a 190 if (sector<0) {
191 AliError("invalid argument, please specify \"sector=sectorno\"");
192 return -EINVAL;
193 }
194 if (sector>=76) {
195 AliError(Form("invalid sector number %d", sector));
196 return -EINVAL;
197 }
81e7f739 198
c54aa300 199 if (!fClusters) {
de2b5702 200 fClusters=new AliRawClusterContainer;
c54aa300 201 }
202 if (!fClusters) return -ENOMEM;
203
b60d3f6a 204 if (fCurrentSector>=0) {
205 // cluster container already filled
206 fCurrentSector=sector;
de2b5702 207// TObjArray* pArray=fClusters->GetSectorArray(fCurrentSector);
208// if (!pArray) {
209// AliError(Form("can not get cluster array for sector %d", sector));
210// return -ENOBUFS;
211// }
212// if (fVerbosity>0) AliInfo(Form("converted %d cluster(s) for sector %d", pArray->GetEntriesFast() ,sector));
213 return 0; //pArray->GetEntriesFast();
b60d3f6a 214 }
215
216 // fill the cluster container
c54aa300 217 AliHLTSystem* pSystem=AliHLTPluginBase::GetInstance();
218 if (!pSystem) {
219 AliError("can not access HLT system");
220 return -ENODEV;
221 }
222 AliHLTOUT* pHLTOUT=pSystem->RequestHLTOUT();
223 if (!pHLTOUT) {
224 AliError("can not access HLTOUT");
b60d3f6a 225 return -EACCES;
c54aa300 226 }
227
768dad20 228 if (!fpDecoder) {
229 fpDecoder=new AliHLTTPCDataCompressionDecoder;
230 }
231
232 if (!fpDecoder) {
233 AliError("failed to create decoder instance");
234 return -ENODEV;
235 }
236
237 AliHLTTPCDataCompressionDecoder& decoder=*fpDecoder;
238 decoder.Clear();
efa1bd1b 239 decoder.SetVerbosity(fVerbosity);
49bdc466 240 //decoder.EnableClusterMerger();
efa1bd1b 241
b60d3f6a 242 bool bNextBlock=false;
b60d3f6a 243 // add cluster id and mc information data blocks
244 for (bNextBlock=(pHLTOUT->SelectFirstDataBlock()>=0);
245 bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
246 AliHLTComponentBlockData desc;
247 // FIXME: extend HLTOUT to get the full descriptor
248 const AliHLTUInt8_t* buffer=NULL;
249 if ((iResult=pHLTOUT->GetDataBuffer(buffer, desc.fSize))<0) {
250 continue;
251 }
252 desc.fPtr=(void*)buffer;
253 if (pHLTOUT->GetDataBlockDescription(desc.fDataType, desc.fSpecification)<0) {
254 continue;
255 }
256 if (desc.fDataType==AliHLTTPCDefinitions::AliHLTDataTypeClusterMCInfo()) {
257 // add mc information
efa1bd1b 258 if ((iResult=decoder.AddClusterMCData(&desc))<0) {
b60d3f6a 259 return iResult;
81e7f739 260 }
b60d3f6a 261 }
262 if (desc.fDataType==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
263 desc.fDataType==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
264 // add cluster ids
efa1bd1b 265 if ((iResult=decoder.AddClusterIds(&desc))<0) {
b60d3f6a 266 return iResult;
81e7f739 267 }
b60d3f6a 268 }
269 }
270
14f37d68 271 bool bHavePartitionRawData=false;
272 bool bHavePartitionCompressedData=false;
273 vector<bool> bHavePartitionData(216, false);
274
b60d3f6a 275 // read data
276 iResult=-ENODATA;
af9e48d7 277 int nExtractedClusters=0;
b60d3f6a 278 for (bNextBlock=(pHLTOUT->SelectFirstDataBlock()>=0);
279 bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
14f37d68 280 decoder.SetPadShift(0.0);
b60d3f6a 281 AliHLTComponentBlockData desc;
282 // FIXME: extend HLTOUT to get the full descriptor with one call
283 const AliHLTUInt8_t* buffer=NULL;
284 if ((iResult=pHLTOUT->GetDataBuffer(buffer, desc.fSize))<0) {
285 continue;
286 }
287 desc.fPtr=(void*)buffer;
288 if (pHLTOUT->GetDataBlockDescription(desc.fDataType, desc.fSpecification)<0) {
289 continue;
290 }
291 if (!TestBit(kSkipPartitionClusters) &&
14f37d68 292 (desc.fDataType==AliHLTTPCDefinitions::RawClustersDataType())) {
293 // This is a special handling of data blocks produced with v5-01-Release
294 // The pad shift by 0.5 was not included in the data but was applied in the
295 // unpacking in this class. Changed in r51306, the next tag containing this
296 // change in the online system is v5-01-Rev-07. There are only very few runs
297 // of Sep 2011 with recorded clusters not containing the 0.5 shift
298 // There was also a chenge in the data type of the compressed partition
299 // cluster blocks which helps to identify the blocks which need the pad shift
300 // here
301 if (desc.fSize<sizeof(AliHLTTPCRawClusterData)) continue;
302 const AliHLTTPCRawClusterData* clusterData = reinterpret_cast<const AliHLTTPCRawClusterData*>(buffer);
303 if (!clusterData) continue;
304 if (clusterData->fVersion==1) {
305 // compressed clusters without the pad shift
306 // no raw clusters (version==0) have ever been recorded
307 decoder.SetPadShift(0.5);
308 }
309 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(desc.fSpecification);
310 AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(desc.fSpecification);
311 if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(desc.fSpecification) ||
312 partition!=AliHLTTPCDefinitions::GetMaxPatchNr(desc.fSpecification)) {
313 AliFatal(Form("inconsistent cluster data: can not handle blocks containing multiple partitions, "
314 "block specification 0x%08x", desc.fSpecification));
315 }
316 iResult=decoder.ReadClustersPartition(fClusters->BeginRemainingClusterBlock(0, desc.fSpecification),
317 reinterpret_cast<AliHLTUInt8_t*>(desc.fPtr),
318 desc.fSize,
319 desc.fSpecification);
be2dd46a 320 if (iResult>=0) nExtractedClusters+=iResult;
321 else {
322 AliFatal(Form("processing of cluster block 0x%08x failed with error code %d", desc.fSpecification, iResult));
323 }
14f37d68 324 unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
325 if (index>=bHavePartitionData.size()) bHavePartitionData.resize(index, false);
326 if (bHavePartitionData[index]) {
327 AliFatal(Form("inconsistent cluster data: multiple data blocks of identical specification indicate a failure "
328 "in the production of the data. Probably an HLT emulation chain is executed in the reconstruction "
329 "and produces data in addition to HLTOUT. Option 'ignore-hltout' is required in that case; "
330 "block specification 0x%08x", desc.fSpecification));
331 }
332 bHavePartitionData[index]=true;
333 if (bHavePartitionCompressedData) {
334 AliFatal(Form("inconsistent cluster data: both compressed and raw cluster blocks present in HLTOUT, indicates a failure "
335 "in the production of the data. Probably an HLT emulation chain is executed in the reconstruction "
336 "and produces data in addition to HLTOUT. Option 'ignore-hltout' is required in that case; "
337 "block specification 0x%08x", desc.fSpecification));
338 }
339 bHavePartitionRawData=true;
340 continue;
341 } else if (!TestBit(kSkipPartitionClusters) &&
342 (desc.fDataType==AliHLTTPCDefinitions::RemainingClustersCompressedDataType())) {
343 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(desc.fSpecification);
344 AliHLTUInt8_t partition = AliHLTTPCDefinitions::GetMinPatchNr(desc.fSpecification);
345 if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr(desc.fSpecification) ||
346 partition!=AliHLTTPCDefinitions::GetMaxPatchNr(desc.fSpecification)) {
347 AliFatal(Form("inconsistent cluster data: can not handle blocks containing multiple partitions, "
348 "block specification 0x%08x", desc.fSpecification));
349 }
b60d3f6a 350 iResult=decoder.ReadClustersPartition(fClusters->BeginRemainingClusterBlock(0, desc.fSpecification),
351 reinterpret_cast<AliHLTUInt8_t*>(desc.fPtr),
352 desc.fSize,
353 desc.fSpecification);
af9e48d7 354 if (iResult>0) nExtractedClusters+=iResult;
14f37d68 355 unsigned index=slice*AliHLTTPCTransform::GetNumberOfPatches()+partition;
356 if (index>=bHavePartitionData.size()) bHavePartitionData.resize(index, false);
357 if (bHavePartitionData[index]) {
358 AliFatal(Form("inconsistent cluster data: multiple data blocks of identical specification indicate a failure "
359 "in the production of the data. Probably an HLT emulation chain is executed in the reconstruction "
360 "and produces data in addition to HLTOUT. Option 'ignore-hltout' is required in that case; "
361 "block specification 0x%08x", desc.fSpecification));
362 }
363 bHavePartitionData[index]=true;
364 bHavePartitionData[index]=true;
365 if (bHavePartitionRawData) {
366 AliFatal(Form("inconsistent cluster data: both compressed and raw cluster blocks present in HLTOUT, indicates a failure "
367 "in the production of the data. Probably an HLT emulation chain is executed in the reconstruction "
368 "and produces data in addition to HLTOUT. Option 'ignore-hltout' is required in that case; "
369 "block specification 0x%08x", desc.fSpecification));
370 }
371 bHavePartitionCompressedData=true;
b60d3f6a 372 continue;
373 } else if (!TestBit(kSkipTrackClusters) &&
374 desc.fDataType==AliHLTTPCDefinitions::ClusterTracksCompressedDataType()) {
375 iResult=decoder.ReadTrackModelClustersCompressed(fClusters->BeginTrackModelClusterBlock(0),
376 reinterpret_cast<AliHLTUInt8_t*>(desc.fPtr),
377 desc.fSize,
378 desc.fSpecification);
379 continue;
81e7f739 380 }
c54aa300 381 }
382
383 pSystem->ReleaseHLTOUT(pHLTOUT);
b60d3f6a 384
385 if (iResult<0) return iResult;
de2b5702 386// if (fVerbosity>0) {
387// int nConvertedClusters=0;
388// for (int s=0; s<72; s++) {
389// TObjArray* pArray=fClusters->GetSectorArray(s);
390// if (!pArray) continue;
391// nConvertedClusters+=pArray->GetEntriesFast();
392// }
393// AliInfo(Form("extracted HLT clusters: %d, converted HLT clusters: %d", nExtractedClusters, nConvertedClusters));
394// }
af9e48d7 395
b60d3f6a 396 fCurrentSector=sector;
de2b5702 397// TObjArray* pArray=fClusters->GetSectorArray(fCurrentSector);
398// if (!pArray) {
399// AliError(Form("can not get cluster array for sector %d", sector));
400// return -ENOBUFS;
401// }
402// if (fVerbosity>0) AliInfo(Form("converted %d cluster(s) for sector %d", pArray->GetEntriesFast() ,sector));
403 return 0; //pArray->GetEntriesFast();
c54aa300 404}
405
de2b5702 406AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::AliRawClusterContainer()
21786b17 407 : fClusterMaps()
de2b5702 408 , fSectorArray(new TClonesArray(AliTPCclusterMI::Class()))
b60d3f6a 409 , fIterator()
410
411{
412 /// constructor
413 for (int i=0; i<72; i++) {
de2b5702 414 fClusterMaps.push_back(new AliRawClusterEntryVector);
1088d780 415 fClusterMaps.back()->reserve(30000);
b60d3f6a 416 }
417}
418
de2b5702 419AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::~AliRawClusterContainer()
b60d3f6a 420{
421 /// dectructor
de2b5702 422 {
423 for (vector<AliRawClusterEntryVector*>::iterator i=fClusterMaps.begin(); i!=fClusterMaps.end(); i++) {
424 if (*i) {
425 delete *i;
426 }
427 }
428 }
429 if (fSectorArray) {
430 fSectorArray->Clear();
431 delete fSectorArray;
432 fSectorArray=NULL;
433 }
b60d3f6a 434}
435
9ecd3e73 436AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification)
b60d3f6a 437{
438 /// iterator of remaining clusters block of specification
de2b5702 439
440 // reserve space in the array of all clusters
441 // reserve space in the map of the partition
442 unsigned index=AliHLTTPCDefinitions::GetMinSliceNr(specification);
b60d3f6a 443 AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(specification);
de2b5702 444 if (partition>=2) index+=36;
445 if (index<fClusterMaps.size() &&
446 fClusterMaps[index]!=NULL &&
447 fClusterMaps[index]->size()+count>fClusterMaps[index]->capacity()) {
448 fClusterMaps[index]->reserve(fClusterMaps[index]->size()+count);
449 }
450
b60d3f6a 451 fIterator=iterator(this);
452 return fIterator;
453}
454
de2b5702 455AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::BeginTrackModelClusterBlock(int /*count*/)
b60d3f6a 456{
457 /// iterator of track model clusters
b60d3f6a 458 fIterator=iterator(this);
459 return fIterator;
460}
461
de2b5702 462AliHLTTPCClusterAccessHLTOUT::AliRawClusterEntry* AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::NextCluster(int slice, int partition)
b60d3f6a 463{
464 /// load next cluster from array of the sepcific sector
465 unsigned sector=partition<2?slice:slice+36;
21786b17 466 if (fClusterMaps.size()<=sector ||
de2b5702 467 fClusterMaps[sector]==NULL) {
b60d3f6a 468 AliErrorClass(Form("no cluster array available for sector %d", sector));
469 return NULL;
470 }
de2b5702 471 AliRawClusterEntryVector& map=*(fClusterMaps[sector]);
21786b17 472 map.push_back(AliRawClusterEntry());
de2b5702 473 return &map.back();
b60d3f6a 474}
475
de2b5702 476void AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::Clear(Option_t* /*option*/)
b60d3f6a 477{
478 /// internal cleanup
b60d3f6a 479 {
de2b5702 480 for (vector<AliRawClusterEntryVector*>::iterator i=fClusterMaps.begin(); i!=fClusterMaps.end(); i++)
481 if (*i) (*i)->clear();
b60d3f6a 482 }
de2b5702 483 if (fSectorArray) fSectorArray->Clear();
b60d3f6a 484}
485
de2b5702 486TObjArray* AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::GetSectorArray(unsigned sector) const
b60d3f6a 487{
488 /// get the cluster array for a sector
de2b5702 489 if (fClusterMaps.size()<=sector) return NULL;
490 if (fSectorArray &&
491 FillSectorArray(fSectorArray, sector)<0) {
492 fSectorArray->Clear();
493 }
494 return fSectorArray;
b60d3f6a 495}
496
de2b5702 497int AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::FillSectorArray(TClonesArray* pSectorArray, unsigned sector, int row) const
498{
499 /// fill the cluster array for a sector and specific row if specified
500 if (!pSectorArray) return -EINVAL;
501 if (fClusterMaps.size()<=sector) return -ERANGE;
502 pSectorArray->Clear();
503
504 AliRawClusterEntryVector& map=*fClusterMaps[sector];
21786b17 505 unsigned nFilled=0;
506 for (unsigned i=0; i<map.size(); i++) {
507 if (row>=0 && map[i].fCluster.GetPadRow()!=row) continue;
508 AliTPCclusterMI* pCluster=new ((*pSectorArray)[nFilled]) AliTPCclusterMI;
de2b5702 509 if (!pCluster) break;
21786b17 510
511 pCluster->SetRow(map[i].fCluster.GetPadRow());
512 pCluster->SetPad(map[i].fCluster.GetPad());
513 pCluster->SetTimeBin(map[i].fCluster.GetTime());
514 pCluster->SetSigmaY2(map[i].fCluster.GetSigmaY2());
515 pCluster->SetSigmaZ2(map[i].fCluster.GetSigmaZ2());
516 pCluster->SetQ(map[i].fCluster.GetCharge());
517 pCluster->SetMax(map[i].fCluster.GetQMax());
518
519 for (int k=0; k<3; k++) {
520 // TODO: sort the labels according to the weight in order to assign the most likely mc label
521 // to the first component
522 pCluster->SetLabel(map[i].fMC.fClusterID[k].fMCID, k);
de2b5702 523 }
21786b17 524 nFilled++;
de2b5702 525 }
526
527 return 0;
528}
529
530void AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::Print(Option_t *option) const
b60d3f6a 531{
532 /// inherited from TObject
de2b5702 533 cout << "AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer" << endl;
b60d3f6a 534 ios::fmtflags coutflags=cout.flags(); // backup cout status flags
535 bool bAll=false;
536 if ((bAll=(strcmp(option, "full")==0)) ||
537 strcmp(option, "short")==0) {
de2b5702 538 for (unsigned iArray=0; iArray<fClusterMaps.size(); iArray++) {
539 if (fClusterMaps[iArray]) {
540 AliRawClusterEntryVector& map=*fClusterMaps[iArray];
541 cout << " sector " << setfill(' ') << setw(2) << iArray << ": " << map.size() << endl;
b60d3f6a 542 if (bAll) {
de2b5702 543 for (unsigned iCluster=0; iCluster<map.size(); iCluster++) {
21786b17 544 AliHLTTPCRawCluster &cluster = map[iCluster].fCluster;
b60d3f6a 545 cout << " AliTPCclusterMI:"
21786b17 546 << " row=" << cluster.GetPadRow()
547 << " pad=" << cluster.GetPad()
548 << " time=" << cluster.GetTime()
549 << " charge=" << cluster.GetCharge()
550 << " maxq=" << cluster.GetQMax()
b60d3f6a 551 << endl;
552 }
553 }
554 }
555 }
556 }
557 cout.flags(coutflags); // restore the original flags
558}
559
de2b5702 560AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator::Next(int slice, int partition)
b60d3f6a 561{
562 // switch to next cluster
563 if (!fData) {
de2b5702 564 fEntry=NULL;
b60d3f6a 565 return *this;
566 }
de2b5702 567 if (fClusterNo>=0 && !fEntry) {
b60d3f6a 568 // end was reached before
569 return *this;
570 }
de2b5702 571 fEntry=fData->NextCluster(slice, partition);
572
b60d3f6a 573 // offline uses row number in physical sector, inner sector consists of
574 // partitions 0 and 1, outer sector of partition 2-5
27dc742d 575 fRowOffset=partition<2?0:AliHLTTPCTransform::GetFirstRow(2);
b60d3f6a 576 return *this;
577}