]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.cxx
0490f9662c190623fd4be6f5f81795242f60b6c0
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterAccessHLTOUT.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE 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   AliHLTTPCClusterAccessHLTOUT.h
20 /// @author Matthias Richter
21 /// @date   2011-06-06
22 /// @brief  Interface to HLT TPC clusters
23 ///
24
25 #include "AliHLTTPCClusterAccessHLTOUT.h"
26 #include "AliHLTTPCDataCompressionDecoder.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliHLTTPCClusterDataFormat.h"
29 #include "AliHLTTPCRawCluster.h"
30 #include "AliHLTTPCTransform.h"
31 #include "AliHLTOUT.h"
32 #include "AliHLTComponent.h"
33 #include "AliHLTErrorGuard.h"
34 #include "AliHLTDataInflater.h"
35 #include "AliLog.h"
36 #include "AliHLTSystem.h"
37 #include "AliHLTPluginBase.h"
38 #include "AliTPCclusterMI.h"
39 #include "AliTPCClustersRow.h"
40 #include "AliTPCParam.h"
41 #include "TClonesArray.h"
42 #include "TString.h"
43 #include <cstdlib>
44 #include <string>
45 #include <memory>
46 #include <iostream>
47 #include <iomanip>
48
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTTPCClusterAccessHLTOUT)
51
52 AliHLTTPCClusterAccessHLTOUT::AliHLTTPCClusterAccessHLTOUT()
53   : TObject()
54   , fVerbosity(0)
55   , fClusters(NULL)
56   , fCurrentSector(-1)
57   , fpDecoder(NULL)
58   , fTPCParam(NULL)
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
67 AliHLTTPCClusterAccessHLTOUT::~AliHLTTPCClusterAccessHLTOUT()
68 {
69   // destructor
70   if (fClusters) {
71     fClusters->Clear();
72     delete fClusters;
73     fClusters=NULL;
74   }
75   if (fpDecoder) {
76     fpDecoder->Clear();
77     delete fpDecoder;
78     fpDecoder=NULL;
79   }
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   }
87 }
88
89 void AliHLTTPCClusterAccessHLTOUT::Execute(const char *method,  const char *params, Int_t *error)
90 {
91   /// inherited from TObject: abstract command interface
92   if (strcmp(method, "read")==0) {
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     }
110     if (error) *error=iResult;
111     return;
112   }
113 }
114
115 TObject* AliHLTTPCClusterAccessHLTOUT::FindObject(const char *name) const
116 {
117   /// inherited from TObject: return the cluster array if name id "clusterarray"
118   if (strcmp(name, "clusterarray")==0) {
119     if (fCurrentSector<0) return NULL;
120     return fClusters->GetSectorArray(fCurrentSector);
121   }
122   return TObject::FindObject(name);
123 }
124
125 void 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
155 void AliHLTTPCClusterAccessHLTOUT::Clear(Option_t * option)
156 {
157   /// inherited from TObject: cleanup
158   if (strcmp(option, "event")==0) {
159     if (fClusters) fClusters->Clear();
160     fCurrentSector=-1;
161   }
162 }
163
164 void AliHLTTPCClusterAccessHLTOUT::Print(Option_t *option) const
165 {
166   /// inherited from TObject
167   if (fClusters) fClusters->Print(option);
168 }
169
170 int AliHLTTPCClusterAccessHLTOUT::ProcessClusters(const char* params)
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;
176   TString strparams(params);
177   int sector=-1;
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();
183     // the offline code enumerates first the 36 inner (partitions 0+1) and then 36 outer
184     // sectors (partitions 2-5)
185     if (argument.BeginsWith("sector=")) {
186       argument.ReplaceAll("sector=", "");
187       sector=argument.Atoi();
188     }
189   }
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   }
198
199   if (!fClusters) {
200     fClusters=new AliRawClusterContainer;
201   }
202   if (!fClusters) return -ENOMEM;
203
204   if (fCurrentSector>=0) {
205     // cluster container already filled
206     fCurrentSector=sector;
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();
214   }
215
216   // fill the cluster container
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");
225     return -EACCES;
226   }
227
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();
239   decoder.SetVerbosity(fVerbosity);
240   //decoder.EnableClusterMerger();
241
242   bool bNextBlock=false;
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
258       if ((iResult=decoder.AddClusterMCData(&desc))<0) {
259         return iResult;
260       }
261     }
262     if (desc.fDataType==AliHLTTPCDefinitions::RemainingClusterIdsDataType() ||
263         desc.fDataType==AliHLTTPCDefinitions::ClusterIdTracksDataType()) {
264       // add cluster ids
265       if ((iResult=decoder.AddClusterIds(&desc))<0) {
266         return iResult;
267       }
268     }
269   }
270
271   bool bHavePartitionRawData=false;
272   bool bHavePartitionCompressedData=false;
273   vector<bool> bHavePartitionData(216, false);
274
275   // read data
276   iResult=-ENODATA;
277   int nExtractedClusters=0;
278   for (bNextBlock=(pHLTOUT->SelectFirstDataBlock()>=0);
279        bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
280     decoder.SetPadShift(0.0);
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) &&
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);
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       }
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       }
350       iResult=decoder.ReadClustersPartition(fClusters->BeginRemainingClusterBlock(0, desc.fSpecification),
351                                             reinterpret_cast<AliHLTUInt8_t*>(desc.fPtr),
352                                             desc.fSize,
353                                             desc.fSpecification);
354       if (iResult>0) nExtractedClusters+=iResult;
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;
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;
380     }
381   }
382
383   pSystem->ReleaseHLTOUT(pHLTOUT);
384
385   if (iResult<0) return iResult;
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 //   }
395
396   fCurrentSector=sector;
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();
404 }
405
406 AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::AliRawClusterContainer()
407   : fClusterMaps()
408   , fSectorArray(new TClonesArray(AliTPCclusterMI::Class()))
409   , fIterator()
410
411 {
412   /// constructor
413   for (int i=0; i<72; i++) {
414     fClusterMaps.push_back(new AliRawClusterEntryVector);
415     fClusterMaps.back()->reserve(30000);
416   }
417 }
418
419 AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::~AliRawClusterContainer()
420 {
421   /// dectructor
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   }
434 }
435
436 AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification)
437 {
438   /// iterator of remaining clusters block of specification
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);
443   AliHLTUInt8_t partition=AliHLTTPCDefinitions::GetMinPatchNr(specification);
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
451   fIterator=iterator(this);
452   return fIterator;
453 }
454
455 AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::BeginTrackModelClusterBlock(int /*count*/)
456 {
457   /// iterator of track model clusters
458   fIterator=iterator(this);
459   return fIterator;
460 }
461
462 AliHLTTPCClusterAccessHLTOUT::AliRawClusterEntry* AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::NextCluster(int slice, int partition)
463 {
464   /// load next cluster from array of the sepcific sector
465   unsigned sector=partition<2?slice:slice+36;
466   if (fClusterMaps.size()<=sector || 
467       fClusterMaps[sector]==NULL) {
468     AliErrorClass(Form("no cluster array available for sector %d", sector));
469     return NULL;
470   }
471   AliRawClusterEntryVector& map=*(fClusterMaps[sector]);
472   map.push_back(AliRawClusterEntry());
473   return &map.back();
474 }
475
476 void  AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::Clear(Option_t* /*option*/)
477 {
478   /// internal cleanup
479   {
480     for (vector<AliRawClusterEntryVector*>::iterator i=fClusterMaps.begin(); i!=fClusterMaps.end(); i++)
481       if (*i) (*i)->clear();
482   }
483   if (fSectorArray) fSectorArray->Clear();
484 }
485
486 TObjArray* AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::GetSectorArray(unsigned sector) const
487 {
488   /// get the cluster array for a sector
489   if (fClusterMaps.size()<=sector) return NULL;
490   if (fSectorArray &&
491       FillSectorArray(fSectorArray, sector)<0) {
492     fSectorArray->Clear();
493   }
494   return fSectorArray;
495 }
496
497 int 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];
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;
509     if (!pCluster) break;
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);    
523     }
524     nFilled++;
525   }
526
527   return 0;
528 }
529
530 void AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::Print(Option_t *option) const
531 {
532   /// inherited from TObject
533   cout << "AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer" << endl;
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) {
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;
542         if (bAll) {
543           for (unsigned iCluster=0; iCluster<map.size(); iCluster++) {
544             AliHLTTPCRawCluster &cluster = map[iCluster].fCluster;
545             cout << "    AliTPCclusterMI:"
546                  << "  row="    << cluster.GetPadRow() 
547                  << "  pad="    << cluster.GetPad()
548                  << "  time="   << cluster.GetTime()
549                  << "  charge=" << cluster.GetCharge()
550                  << "  maxq="   << cluster.GetQMax()
551                  << endl;
552           }
553         }
554       }
555     }
556   }
557   cout.flags(coutflags); // restore the original flags
558 }
559
560 AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator& AliHLTTPCClusterAccessHLTOUT::AliRawClusterContainer::iterator::Next(int slice, int partition)
561 {
562   // switch to next cluster
563   if (!fData) {
564     fEntry=NULL;
565     return *this;
566   }
567   if (fClusterNo>=0 && !fEntry) {
568     // end was reached before
569     return *this;
570   }
571   fEntry=fData->NextCluster(slice, partition);
572
573   // offline uses row number in physical sector, inner sector consists of
574   // partitions 0 and 1, outer sector of partition 2-5
575   fRowOffset=partition<2?0:AliHLTTPCTransform::GetFirstRow(2);
576   return *this;
577 }