LCOV - code coverage report
Current view: top level - HLT/TPCLib - AliHLTTPCHWCFSpacePointContainer.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 499 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 53 1.9 %

          Line data    Source code
       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 "AliHLTTPCGeometry.h"
      33             : #include "AliHLTComponent.h"
      34             : #include "AliHLTTemplates.h"
      35             : #include "AliHLTDataDeflater.h"
      36             : #include "AliHLTCDHWrapper.h"
      37             : #include "AliLog.h"
      38             : #include "TMath.h"
      39             : #include <memory>
      40             : #include <algorithm>
      41             : #include <cmath>
      42             : #include <iostream>
      43             : #include <sstream>
      44             : #include <iomanip>
      45             : 
      46             : 
      47             : /** ROOT macro for the implementation of ROOT specific class methods */
      48           6 : ClassImp(AliHLTTPCHWCFSpacePointContainer)
      49             : 
      50             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointContainer(int mode)
      51           0 :   : AliHLTSpacePointContainer()
      52           0 :   , fClusters()
      53           0 :   , fSelections()
      54           0 :   , fBlocks()
      55           0 :   , fSingleBlock()
      56           0 :   , fMode(mode)
      57           0 :   , fWrittenClusterIds(NULL)
      58           0 : {
      59             :   // see header file for class documentation
      60             :   // or
      61             :   // refer to README to build package
      62             :   // or
      63             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      64           0 :   if (fMode&kModeSingle) {
      65           0 :     fSingleBlock.SetDecoder(new AliHLTTPCHWCFData);
      66           0 :     fSingleBlock.SetGrid(AllocateIndexGrid());
      67           0 :   }
      68           0 : }
      69             : 
      70             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointContainer(const AliHLTTPCHWCFSpacePointContainer& c)
      71           0 :   : AliHLTSpacePointContainer(c)
      72           0 :   , fClusters(c.fClusters.begin(), c.fClusters.end())
      73           0 :   , fSelections()
      74           0 :   , fBlocks()
      75           0 :   , fSingleBlock()
      76           0 :   , fMode(c.fMode)
      77           0 :   , fWrittenClusterIds(NULL)
      78           0 : {
      79             :   /// copy constructor
      80           0 : }
      81             : 
      82             : AliHLTTPCHWCFSpacePointContainer& AliHLTTPCHWCFSpacePointContainer::operator=(const AliHLTTPCHWCFSpacePointContainer& c)
      83             : {
      84             :   /// assignment operator
      85           0 :   if (&c==this) return *this;
      86           0 :   AliHLTSpacePointContainer::operator=(c);
      87           0 :   fClusters=c.fClusters;
      88           0 :   fMode=c.fMode;
      89           0 :   fWrittenClusterIds=NULL;
      90             : 
      91           0 :   return *this;
      92           0 : }
      93             : 
      94           0 : AliHLTTPCHWCFSpacePointContainer::~AliHLTTPCHWCFSpacePointContainer()
      95           0 : {
      96             :   // destructor
      97           0 :   Clear();
      98           0 :   if (fSingleBlock.GetDecoder()) delete fSingleBlock.GetDecoder();
      99           0 :   if (fSingleBlock.GetGrid()) delete fSingleBlock.GetGrid();
     100           0 :   if (fWrittenClusterIds) delete fWrittenClusterIds;
     101           0 : }
     102             : 
     103             : int AliHLTTPCHWCFSpacePointContainer::AddInputBlock(const AliHLTComponentBlockData* pDesc)
     104             : {
     105             :   // add input block to the collection
     106           0 :   if (!pDesc) return -EINVAL;
     107             :   int iResult=0;
     108             :   int count=0;
     109           0 :   if (pDesc->fDataType!=AliHLTTPCDefinitions::fgkHWClustersDataType) {
     110           0 :     HLTWarning("ignoring data block of type %s", AliHLTComponent::DataType2Text(pDesc->fDataType).c_str());
     111           0 :     return 0;
     112             :   }
     113           0 :   if (!pDesc->fPtr) return -ENODATA;
     114           0 :   AliHLTCDHWrapper header(pDesc->fPtr);
     115           0 :   if (pDesc->fSize<=header.GetHeaderSize()) return 0;
     116             : 
     117           0 :   AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( pDesc->fSpecification );
     118           0 :   AliHLTUInt8_t part  = AliHLTTPCDefinitions::GetMinPatchNr( pDesc->fSpecification );
     119             : 
     120           0 :   AliHLTUInt32_t decoderIndex=AliHLTTPCSpacePointData::GetID(slice, part, 0);
     121             : 
     122           0 :   AliHLTUInt32_t *buffer=reinterpret_cast<AliHLTUInt32_t*>(pDesc->fPtr);
     123             :   // skip the first 8 or 10 CDH words
     124           0 :   buffer += header.GetHeaderSize()/sizeof(AliHLTUInt32_t);
     125           0 :   UInt_t bufferSize32 = ((Int_t)pDesc->fSize - header.GetHeaderSize() )/sizeof(AliHLTUInt32_t);
     126             : 
     127             :   AliHLTTPCHWCFData* pDecoder=NULL;
     128             :   AliHLTSpacePointPropertyGrid* pGrid=NULL;
     129           0 :   if (fMode&kModeSingle) {
     130           0 :     pDecoder=fSingleBlock.GetDecoder();
     131           0 :     pGrid=fSingleBlock.GetGrid();
     132           0 :   } else {
     133           0 :     if (fBlocks.find(decoderIndex)!=fBlocks.end()) {
     134           0 :       HLTError("data block of slice %d partition %d already added, skipping data block", slice, part);
     135           0 :       return -EEXIST;
     136             :     }
     137             :   }
     138             : 
     139           0 :   if (!pDecoder) {
     140           0 :     pDecoder=new AliHLTTPCHWCFData;
     141           0 :     if (!pDecoder) return -ENOMEM;
     142             :   }
     143             : 
     144           0 :   if (pDecoder->Init(reinterpret_cast<AliHLTUInt8_t*>(buffer), bufferSize32*sizeof(AliHLTUInt32_t))<0 ||
     145           0 :       (pDecoder->CheckVersion()<0 && (int)(bufferSize32*sizeof(AliHLTUInt32_t))>pDecoder->GetRCUTrailerSize())) {
     146           0 :     HLTError("data block of type %s corrupted: can not decode format",
     147             :              AliHLTComponent::DataType2Text(pDesc->fDataType).c_str());
     148           0 :     return -EBADMSG;
     149             :   }
     150             : 
     151           0 :   if (fMode&kModeSingle && !pGrid) {
     152           0 :     pGrid=AllocateIndexGrid();
     153           0 :     if (!pGrid) {
     154           0 :       delete pDecoder;
     155           0 :       return -ENOMEM;
     156             :     }
     157             :   }
     158             : 
     159           0 :   if (fMode&kModeCreateMap) { // register immediately
     160           0 :   UInt_t nofClusters=pDecoder->GetNumberOfClusters();
     161             : 
     162           0 :   for (UInt_t i=0; i<nofClusters; i++) {
     163           0 :     AliHLTUInt32_t clusterID=~(AliHLTUInt32_t)0;
     164             :     // cluster ID from slice, partition and index
     165           0 :     clusterID=AliHLTTPCSpacePointData::GetID(slice, part, i);
     166             : 
     167           0 :     if (fClusters.find(clusterID)==fClusters.end()) {
     168             :       // new cluster
     169           0 :       fClusters[clusterID]=AliHLTTPCHWCFSpacePointProperties(pDecoder, i);
     170           0 :       count++;
     171           0 :     } else {
     172           0 :       HLTError("cluster with ID 0x%08x already existing, skipping cluster %d of data block 0x%08x",
     173             :                clusterID, i, pDesc->fSpecification);
     174             :     }
     175           0 :   }
     176           0 :   }
     177             : 
     178           0 :   if (pGrid && (iResult=PopulateAccessGrid(pGrid, pDecoder, slice, part))<0) {
     179           0 :     HLTError("failed to populate access grid for block %s 0x%09x: %d",
     180             :              AliHLTComponent::DataType2Text(pDesc->fDataType).c_str(), pDesc->fSpecification, iResult);
     181           0 :     return iResult;
     182             :   }
     183             : 
     184           0 :   if (fMode&kModeSingle) {
     185           0 :     fSingleBlock.SetDecoder(pDecoder);
     186           0 :     fSingleBlock.SetGrid(pGrid);
     187           0 :     fSingleBlock.SetId(decoderIndex);
     188           0 :   } else {
     189           0 :     fBlocks[decoderIndex]=AliHLTTPCHWCFSpacePointBlock(decoderIndex, pDecoder, pGrid);
     190             :   }
     191           0 :   return count;
     192           0 : }
     193             : 
     194             : AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* AliHLTTPCHWCFSpacePointContainer::AllocateIndexGrid()
     195             : {
     196             :   // allocate index grid, one single point to define the dimensions
     197             :   
     198             :   // max 33 padrows, step 1 padrow
     199             :   // max 140 pads, step 2x max delta pad
     200             :   // max 1024 time bins, step 2x max delta time
     201           0 :   return new AliHLTSpacePointPropertyGrid(33, 1.0,
     202           0 :                                           140, 2*AliHLTTPCDefinitions::GetMaxClusterDeltaPad(),
     203           0 :                                           1024, 2*AliHLTTPCDefinitions::GetMaxClusterDeltaTime()
     204             :                                           );
     205           0 : }
     206             : 
     207             : int AliHLTTPCHWCFSpacePointContainer::PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTUInt32_t mask) const
     208             : {
     209             :   // populate an access grid
     210           0 :   if (!pGrid) return -EINVAL;
     211             : 
     212           0 :   pGrid->Clear();
     213             :   
     214           0 :   AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(mask);
     215           0 :   AliHLTUInt8_t partition  = AliHLTTPCDefinitions::GetMinPatchNr(mask);
     216           0 :   AliHLTUInt32_t decoderIndex=AliHLTTPCSpacePointData::GetID(slice, partition, 0);
     217           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock>::const_iterator block=fBlocks.find(decoderIndex);
     218           0 :   if (block==fBlocks.end()) {
     219           0 :     HLTError("can not find data block of id 0x%08x", mask);
     220           0 :     return -ENOENT;
     221             :   }
     222           0 :   return PopulateAccessGrid(pGrid, block->second.GetDecoder(), slice, partition);
     223           0 : }
     224             : 
     225             : int AliHLTTPCHWCFSpacePointContainer::PopulateAccessGrid(AliHLTSpacePointPropertyGrid* pGrid, AliHLTTPCHWCFData* pDecoder,
     226             :                                                          int slice, int partition) const
     227             : {
     228             :   // populate an access grid
     229           0 :   if (!pDecoder) return -EINVAL;
     230             :   int iResult=0;
     231             : 
     232           0 :   if (pDecoder->GetNumberOfClusters()==0) return 0;
     233           0 :   AliHLTTPCHWCFData::iterator cl=pDecoder->begin();
     234           0 :   for (; cl!=pDecoder->end(); ++cl) {
     235           0 :     iResult=pGrid->CountSpacePoint(cl.GetPadRow(), cl.GetPad(), cl.GetTime());
     236           0 :     if (iResult<0)
     237           0 :       HLTError("CountSpacePoint %f %f %f failed: %d", cl.GetPadRow(), cl.GetPad(), cl.GetTime(), iResult);
     238             :   }
     239             :   
     240             :   int count=0;
     241           0 :   cl=pDecoder->begin();
     242           0 :   for (; cl!=pDecoder->end(); ++cl, count++) {
     243           0 :     AliHLTUInt32_t id=AliHLTTPCSpacePointData::GetID(slice, partition, count);
     244           0 :     iResult=pGrid->AddSpacePoint(AliHLTSpacePointProperties(id), cl.GetPadRow(), cl.GetPad(), cl.GetTime());
     245           0 :     if (iResult<0)
     246           0 :       HLTError("AddSpacePoint 0x%08x %f %f %f failed: %d", id, cl.GetPadRow(), cl.GetPad(), cl.GetTime(), iResult);
     247             :   }
     248             : 
     249             :   return 0;
     250           0 : }
     251             : 
     252             : const AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* AliHLTTPCHWCFSpacePointContainer::GetSpacePointPropertyGrid(AliHLTUInt32_t mask) const
     253             : {
     254             :   // get the access grid for a data block
     255           0 :   AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(mask);
     256           0 :   AliHLTUInt8_t part  = AliHLTTPCDefinitions::GetMinPatchNr(mask);
     257           0 :   AliHLTUInt32_t decoderIndex=AliHLTTPCSpacePointData::GetID(slice, part, 0);
     258           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock>::const_iterator block=fBlocks.find(decoderIndex);
     259           0 :   if (block==fBlocks.end()) {
     260           0 :     HLTError("can not find data block of id 0x%08x", mask);
     261           0 :     return NULL;
     262             :   }
     263           0 :   return block->second.GetGrid();
     264           0 : }
     265             : 
     266             : int AliHLTTPCHWCFSpacePointContainer::SetSpacePointPropertyGrid(AliHLTUInt32_t mask, AliHLTSpacePointContainer::AliHLTSpacePointPropertyGrid* pGrid)
     267             : {
     268             :   // set the access grid for a data block
     269           0 :   AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(mask);
     270           0 :   AliHLTUInt8_t part  = AliHLTTPCDefinitions::GetMinPatchNr(mask);
     271           0 :   AliHLTUInt32_t decoderIndex=AliHLTTPCSpacePointData::GetID(slice, part, 0);
     272           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock>::iterator block=fBlocks.find(decoderIndex);
     273           0 :   if (block==fBlocks.end()) {
     274           0 :     HLTError("can not find data block of id 0x%08x", mask);
     275           0 :     return -ENOENT;
     276             :   }
     277           0 :   if (block->second.GetGrid()!=NULL && pGrid!=NULL && block->second.GetGrid()!=pGrid) {
     278             :     // there is trouble ahead because this will delete the index grid instance
     279             :     // but it might be an external pointer supposed to be deleted by someone else
     280           0 :     ALIHLTERRORGUARD(1, "overriding previous instance of index grid, potential memory leak or invalid deallocation ahead");
     281           0 :   }
     282           0 :   block->second.SetGrid(pGrid);
     283           0 :   return 0;
     284           0 : }
     285             : 
     286             : int AliHLTTPCHWCFSpacePointContainer::GetClusterIDs(vector<AliHLTUInt32_t>& tgt) const
     287             : {
     288             :   // get array of cluster IDs
     289           0 :   tgt.clear();
     290           0 :   transform(fClusters.begin(), fClusters.end(), back_inserter(tgt), HLT::AliGetKey());
     291           0 :   return tgt.size();
     292             : }
     293             : 
     294             : bool AliHLTTPCHWCFSpacePointContainer::Check(AliHLTUInt32_t clusterID) const
     295             : {
     296             :   // check if the cluster is available
     297           0 :   return fClusters.find(clusterID)!=fClusters.end();
     298             : }
     299             : 
     300             : const vector<AliHLTUInt32_t>* AliHLTTPCHWCFSpacePointContainer::GetClusterIDs(AliHLTUInt32_t mask)
     301             : {
     302             :   // get array of cluster IDs filtered by mask
     303           0 :   if (fSelections.find(mask)!=fSelections.end()) {
     304             :     // return existing selection
     305           0 :     return fSelections.find(mask)->second;
     306             :   }
     307             :   // create new collection
     308           0 :   vector<AliHLTUInt32_t>* selected=new vector<AliHLTUInt32_t>;
     309           0 :   if (!selected) return NULL;
     310           0 :   UInt_t slice=AliHLTTPCSpacePointData::GetSlice(mask);
     311           0 :   UInt_t partition=AliHLTTPCSpacePointData::GetPatch(mask);
     312             :   //HLTInfo("creating collection 0x%08x", mask);
     313             : 
     314             :   // the first cluster with number 0 has equal ID to mask unless
     315             :   // the mask selects multiple partitions/slices
     316           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(mask);
     317             :   bool bAll=false;
     318           0 :   if (slice>=(unsigned)AliHLTTPCGeometry::GetNSlice() ||
     319           0 :       partition>=(unsigned)AliHLTTPCGeometry::GetNumberOfPatches()) {
     320           0 :     cl=fClusters.begin();
     321             :     bAll=true;
     322           0 :   }
     323           0 :   for (; cl!=fClusters.end(); cl++) {
     324           0 :     UInt_t s=AliHLTTPCSpacePointData::GetSlice(cl->first);
     325           0 :     UInt_t p=AliHLTTPCSpacePointData::GetPatch(cl->first);
     326           0 :     if ((slice>=(unsigned)AliHLTTPCGeometry::GetNSlice() || s==slice) && 
     327           0 :         (partition>=(unsigned)AliHLTTPCGeometry::GetNumberOfPatches() || p==partition)) {
     328           0 :       selected->push_back(cl->first);
     329           0 :     } else if (!bAll) {
     330             :       // no need to continue, we are out of the range
     331           0 :       break;
     332             :     }
     333           0 :   }
     334             :   //HLTInfo("collection 0x%08x with %d spacepoints", mask, selected->size());
     335           0 :   fSelections[mask]=selected;
     336             :   return selected;
     337           0 : }
     338             : 
     339             : float AliHLTTPCHWCFSpacePointContainer::GetX(AliHLTUInt32_t clusterID) const
     340             : {
     341             :   // get X coordinate
     342           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     343           0 :   if (cl==fClusters.end() ||
     344           0 :       cl->second.Decoder()==NULL) return 0.0;
     345             :   // FIXME: understand deviation from the nominal x value
     346             :   // there is a small deviation in the x coordinate - padrow number correlation
     347             :   // in principle, the clusterfinder only uses the mapping to set the x parameter.
     348             :   // now extracting the x value from the padrow no.
     349             :   //return cl->second.Decoder()->fX;
     350           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     351           0 :   return cl->second.Decoder()->GetPadRow(index);
     352           0 : }
     353             : 
     354             : float AliHLTTPCHWCFSpacePointContainer::GetXWidth(AliHLTUInt32_t clusterID) const
     355             : {
     356             :   // get error for X coordinate
     357           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     358           0 :   if (cl==fClusters.end() ||
     359           0 :       cl->second.Decoder()==NULL) return 0.0;
     360           0 :   return 0.0; // fixed in padrow number
     361           0 : }
     362             : 
     363             : float AliHLTTPCHWCFSpacePointContainer::GetY(AliHLTUInt32_t clusterID) const
     364             : {
     365             :   // get Y coordinate
     366           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     367           0 :   if (cl==fClusters.end() ||
     368           0 :       cl->second.Decoder()==NULL) return 0.0;
     369           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     370           0 :   return cl->second.Decoder()->GetPad(index);
     371           0 : }
     372             : 
     373             : float AliHLTTPCHWCFSpacePointContainer::GetYWidth(AliHLTUInt32_t clusterID) const
     374             : {
     375             :   // get error for Y coordinate
     376           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     377           0 :   if (cl==fClusters.end() ||
     378           0 :       cl->second.Decoder()==NULL) return 0.0;
     379           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     380           0 :   return cl->second.Decoder()->GetSigmaY2(index);
     381           0 : }
     382             : 
     383             : float AliHLTTPCHWCFSpacePointContainer::GetZ(AliHLTUInt32_t clusterID) const
     384             : {
     385             :   // get Z coordinate
     386           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     387           0 :   if (cl==fClusters.end() ||
     388           0 :       cl->second.Decoder()==NULL) return 0.0;
     389           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     390           0 :   return cl->second.Decoder()->GetTime(index);
     391           0 : }
     392             : 
     393             : float AliHLTTPCHWCFSpacePointContainer::GetZWidth(AliHLTUInt32_t clusterID) const
     394             : {
     395             :   // get error for Z coordinate
     396           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     397           0 :   if (cl==fClusters.end() ||
     398           0 :       cl->second.Decoder()==NULL) return 0.0;
     399           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     400           0 :   return cl->second.Decoder()->GetSigmaZ2(index);
     401           0 : }
     402             : 
     403             : float AliHLTTPCHWCFSpacePointContainer::GetCharge(AliHLTUInt32_t clusterID) const
     404             : {
     405             :   // get charge
     406           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     407           0 :   if (cl==fClusters.end() ||
     408           0 :       cl->second.Decoder()==NULL) return 0.0;
     409           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     410           0 :   return cl->second.Decoder()->GetCharge(index);
     411           0 : }
     412             : 
     413             : float AliHLTTPCHWCFSpacePointContainer::GetQMax(AliHLTUInt32_t clusterID) const
     414             : {
     415             :   // get charge
     416           0 :   std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.find(clusterID);
     417           0 :   if (cl==fClusters.end() ||
     418           0 :       cl->second.Decoder()==NULL) return 0.0;
     419           0 :   int index=AliHLTTPCSpacePointData::GetNumber(cl->first);
     420           0 :   return cl->second.Decoder()->GetQMax(index);
     421           0 : }
     422             : 
     423             : float AliHLTTPCHWCFSpacePointContainer::GetPhi(AliHLTUInt32_t clusterID) const
     424             : {
     425             :   // get charge
     426             : 
     427             :   // phi can be derived directly from the id, no need to search
     428             :   // for existing cluster
     429           0 :   int slice=AliHLTTPCSpacePointData::GetSlice(clusterID);
     430           0 :   return ( slice + 0.5 ) * TMath::Pi() / 9.0;
     431             : }
     432             : 
     433             : void AliHLTTPCHWCFSpacePointContainer::Clear(Option_t * option)
     434             : {
     435             :   // clear the object and reset pointer references
     436           0 :   fClusters.clear();
     437             : 
     438           0 :   for (std::map<AliHLTUInt32_t, vector<AliHLTUInt32_t>*>::iterator selection=fSelections.begin();
     439           0 :        selection!=fSelections.end(); selection++) {
     440           0 :     if (selection->second) delete selection->second;
     441             :   }
     442           0 :   fSelections.clear();
     443             : 
     444           0 :   for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock>::iterator block=fBlocks.begin();
     445           0 :        block!=fBlocks.end(); block++) {
     446           0 :     if (block->second.GetDecoder()) delete block->second.GetDecoder();
     447           0 :     if (block->second.GetGrid()) delete block->second.GetGrid();
     448             :   }
     449           0 :   fBlocks.clear();
     450             : 
     451           0 :   if (fSingleBlock.GetDecoder()) fSingleBlock.GetDecoder()->Reset();
     452           0 :   if (fSingleBlock.GetGrid()) fSingleBlock.GetGrid()->Clear();
     453             : 
     454           0 :   AliHLTSpacePointContainer::Clear(option);
     455           0 : }
     456             : 
     457             : void AliHLTTPCHWCFSpacePointContainer::Print(ostream& out, Option_t */*option*/) const
     458             : {
     459             :   // print to stream
     460           0 :   std::stringstream str;
     461           0 :   str << "AliHLTTPCHWCFSpacePointContainer::Print" << endl;
     462           0 :   str << "n clusters: " << fClusters.size() << endl;
     463           0 :   for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin();
     464           0 :        cl!=fClusters.end(); cl++) {
     465           0 :     str << " 0x" << hex << setw(8) << setfill('0') << cl->first << dec << cl->second << endl;
     466             :   }
     467           0 :   out << str.str();
     468           0 : }
     469             : 
     470             : AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMask(AliHLTUInt32_t mask, bool /*bAlloc*/) const
     471             : {
     472             :   /// create a collection of clusters for a space point mask
     473           0 :   std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
     474           0 :   if (!c.get()) return NULL;
     475             : 
     476           0 :   UInt_t slice=AliHLTTPCSpacePointData::GetSlice(mask);
     477           0 :   UInt_t partition=AliHLTTPCSpacePointData::GetPatch(mask);
     478           0 :   for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator cl=fClusters.begin();
     479           0 :        cl!=fClusters.end(); cl++) {
     480           0 :     UInt_t s=AliHLTTPCSpacePointData::GetSlice(cl->first);
     481           0 :     UInt_t p=AliHLTTPCSpacePointData::GetPatch(cl->first);
     482           0 :     if ((slice>=(unsigned)AliHLTTPCGeometry::GetNSlice() || s==slice) && 
     483           0 :         (partition>=(unsigned)AliHLTTPCGeometry::GetNumberOfPatches() || p==partition)) {
     484           0 :       c->fClusters[cl->first]=cl->second;
     485           0 :     }
     486             :   }
     487           0 :   return c.release();
     488           0 : }
     489             : 
     490             : AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByTrack(int trackId, bool /*bAlloc*/) const
     491             : {
     492             :   /// create a collection of clusters for a specific track
     493           0 :   std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
     494           0 :   if (!c.get()) return NULL;
     495             : 
     496           0 :   HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetTrackId,trackId));
     497           0 :   return c.release();
     498           0 : }
     499             : 
     500             : AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::SelectByMC(int mcId, bool /*bAlloc*/) const
     501             : {
     502             :   /// create a collection of clusters for a specific MC track
     503           0 :   std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
     504           0 :   if (!c.get()) return NULL;
     505             : 
     506           0 :   HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, int>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::GetMCId,mcId));
     507           0 :   return c.release();
     508           0 : }
     509             : 
     510             : AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UsedClusters(bool /*bAlloc*/) const
     511             : {
     512             :   /// create a collection of all used clusters
     513           0 :   std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
     514           0 :   if (!c.get()) return NULL;
     515             : 
     516           0 :   HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,true));
     517           0 :   return c.release();
     518           0 : }
     519             : 
     520             : AliHLTSpacePointContainer* AliHLTTPCHWCFSpacePointContainer::UnusedClusters(bool /*bAlloc*/) const
     521             : {
     522             :   /// create a collection of all unused clusters
     523           0 :   std::auto_ptr<AliHLTTPCHWCFSpacePointContainer> c(new AliHLTTPCHWCFSpacePointContainer);
     524           0 :   if (!c.get()) return NULL;
     525             : 
     526           0 :   HLT::copy_map_if(fClusters.begin(), fClusters.end(), c->fClusters, HLT::AliHLTUnaryPredicate<AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties, bool>(&AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::IsUsed,false));
     527           0 :   return c.release();
     528           0 : }
     529             : 
     530             : int AliHLTTPCHWCFSpacePointContainer::MarkUsed(const AliHLTUInt32_t* clusterIDs, int arraySize)
     531             : {
     532             :   /// mark the clusters with specified IDs as used
     533           0 :   if (!clusterIDs) return -EINVAL;
     534             :   int iCount=0;
     535           0 :   for (int i=0; i<arraySize; i++) {
     536           0 :     if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
     537           0 :     fClusters[clusterIDs[i]].MarkUsed();
     538           0 :     iCount++;
     539           0 :   }
     540             :   return iCount;
     541           0 : }
     542             : 
     543             : int AliHLTTPCHWCFSpacePointContainer::SetTrackID(int trackID, const AliHLTUInt32_t* clusterIDs, int arraySize)
     544             : {
     545             :   /// set track id for specified clusters
     546           0 :   if (!clusterIDs) return -EINVAL;
     547             :   int iCount=0;
     548           0 :   for (int i=0; i<arraySize; i++) {
     549           0 :     if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
     550           0 :     fClusters[clusterIDs[i]].SetTrackId(trackID);
     551           0 :     iCount++;
     552           0 :   }
     553             :   return iCount;
     554           0 : }
     555             : 
     556             : int AliHLTTPCHWCFSpacePointContainer::GetTrackID(AliHLTUInt32_t clusterID) const
     557             : {
     558             :   /// get track id for specified cluster
     559           0 :   map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointProperties>::const_iterator element=fClusters.find(clusterID);
     560           0 :   if (element==fClusters.end()) return -1;
     561           0 :   return element->second.GetTrackId();
     562           0 : }
     563             : 
     564             : int AliHLTTPCHWCFSpacePointContainer::SetMCID(int mcID, const AliHLTUInt32_t* clusterIDs, int arraySize)
     565             : {
     566             :   /// set mc id for specified clusters
     567           0 :   if (!clusterIDs) return -EINVAL;
     568             :   int iCount=0;
     569           0 :   for (int i=0; i<arraySize; i++) {
     570           0 :     if (fClusters.find(clusterIDs[i])==fClusters.end()) continue;
     571           0 :     fClusters[clusterIDs[i]].SetMCId(mcID);
     572           0 :     iCount++;
     573           0 :   }
     574             :   return iCount;
     575           0 : }
     576             : 
     577             : int AliHLTTPCHWCFSpacePointContainer::Write(AliHLTUInt8_t* outputPtr,
     578             :                                             AliHLTUInt32_t size,
     579             :                                             AliHLTComponentBlockDataList&
     580             :                                             outputBlocks,
     581             :                                             AliHLTDataDeflater* pDeflater,
     582             :                                             const char* option) const
     583             : {
     584             :   /// write blocks to HLT component output
     585             :   AliHLTUInt32_t offset=0;
     586           0 :   if (outputBlocks.size()>0) {
     587           0 :     offset=outputBlocks.back().fOffset+outputBlocks.back().fSize;
     588           0 :   }
     589           0 :   return Write(outputPtr, size, offset, outputBlocks, pDeflater, option);
     590             : }
     591             : 
     592             : int AliHLTTPCHWCFSpacePointContainer::Write(AliHLTUInt8_t* outputPtr,
     593             :                                             AliHLTUInt32_t size,
     594             :                                             AliHLTUInt32_t offset,
     595             :                                             AliHLTComponentBlockDataList&
     596             :                                             outputBlocks,
     597             :                                             AliHLTDataDeflater* pDeflater,
     598             :                                             const char* option) const
     599             : {
     600             :   /// write blocks to HLT component output
     601           0 :   return WriteSorted(outputPtr, size, offset, outputBlocks, pDeflater, option);
     602             : }
     603             : 
     604             : int AliHLTTPCHWCFSpacePointContainer::WriteSorted(AliHLTUInt8_t* outputPtr,
     605             :                                                   AliHLTUInt32_t size,
     606             :                                                   AliHLTUInt32_t offset,
     607             :                                                   AliHLTComponentBlockDataList&
     608             :                                                   outputBlocks,
     609             :                                                   AliHLTDataDeflater* pDeflater,
     610             :                                                   const char* option) const
     611             : {
     612             :   /// write blocks to HLT component output
     613             :   int iResult=0;
     614             : 
     615           0 :   if (fMode&kModeSingle) {
     616           0 :     iResult=WriteSorted(outputPtr, size, offset, fSingleBlock.GetDecoder(), fSingleBlock.GetGrid(), fSingleBlock.GetId(), outputBlocks, pDeflater, option);
     617           0 :   } else {
     618             :     iResult=-ENOENT;
     619           0 :     for (std::map<AliHLTUInt32_t, AliHLTTPCHWCFSpacePointBlock>::const_iterator block=fBlocks.begin();
     620           0 :          block!=fBlocks.end(); block++) {
     621           0 :       AliHLTTPCHWCFData* pDecoder=block->second.GetDecoder();
     622           0 :       AliHLTSpacePointPropertyGrid* pGrid=block->second.GetGrid();
     623           0 :       AliHLTUInt32_t mask=block->first;
     624             :       // FIXME: have to propagate the parameter which block is currently to be written
     625             :       // for now the index grid is only set for that one
     626           0 :       if (!pGrid) continue;
     627           0 :       iResult=WriteSorted(outputPtr, size, offset, pDecoder, pGrid, mask, outputBlocks, pDeflater, option);
     628           0 :       break; // only one is supposed to be written
     629             :     }
     630           0 :     if (iResult==-ENOENT) {
     631           0 :       HLTError("could not find the index grid of the partition to be written");
     632             :     }
     633             :   }
     634           0 :   return iResult;
     635             : }
     636             : 
     637             : int AliHLTTPCHWCFSpacePointContainer::WriteSorted(AliHLTUInt8_t* outputPtr,
     638             :                                                   AliHLTUInt32_t size,
     639             :                                                   AliHLTUInt32_t offset,
     640             :                                                   AliHLTTPCHWCFData* pDecoder,
     641             :                                                   AliHLTSpacePointPropertyGrid* pGrid,
     642             :                                                   AliHLTUInt32_t mask,
     643             :                                                   AliHLTComponentBlockDataList&
     644             :                                                   outputBlocks,
     645             :                                                   AliHLTDataDeflater* pDeflater,
     646             :                                                   const char* option) const
     647             : {
     648             :   /// write blocks to HLT component output
     649           0 :   if (!outputPtr || !pDecoder || !pGrid) return -EINVAL;
     650           0 :   if (pDecoder->GetNumberOfClusters()==0) return 0;
     651           0 :   if (option) {
     652             :     // this is only for sending mc labels in simulation and testing
     653             :     // no impact to real running
     654           0 :     if (!fWrittenClusterIds && strcmp(option, "write-cluster-ids")==0) {
     655           0 :       const_cast<AliHLTTPCHWCFSpacePointContainer*>(this)->fWrittenClusterIds=new vector<AliHLTUInt32_t>;
     656           0 :     }
     657             :   }
     658             :   int iResult=0;
     659             :   AliHLTUInt32_t capacity=size;
     660             :   size=0;
     661             : 
     662           0 :   int slice=AliHLTTPCSpacePointData::GetSlice(mask);
     663           0 :   int part=AliHLTTPCSpacePointData::GetPatch(mask);
     664             : 
     665             :   // Note: the offset parameter is only for the block descriptors, output pointer and size
     666             :   // consider already the offset
     667           0 :   AliHLTTPCRawClusterData* blockout=reinterpret_cast<AliHLTTPCRawClusterData*>(outputPtr+size);
     668           0 :   blockout->fVersion=0;
     669           0 :   blockout->fCount=0;
     670             : 
     671           0 :   if (pDeflater) {
     672           0 :     pDeflater->Clear();
     673           0 :     pDeflater->InitBitDataOutput(reinterpret_cast<AliHLTUInt8_t*>(blockout->fClusters), capacity-size-sizeof(AliHLTTPCRawClusterData));
     674           0 :     blockout->fVersion=pDeflater->GetDeflaterVersion();
     675           0 :     if (fMode&kModeDifferentialPadTime) blockout->fVersion+=2;
     676             :   }
     677             : 
     678             :   unsigned lastPadRow=0;
     679             :   AliHLTUInt64_t lastPad64=0;
     680             :   AliHLTUInt64_t lastTime64=0;
     681           0 :   pDeflater->StartEncoder();
     682           0 :   AliHLTSpacePointPropertyGrid::iterator clusterID=pGrid->begin();
     683           0 :   if (clusterID!=pGrid->end()) {
     684           0 :     for (; clusterID!=pGrid->end(); clusterID++) {
     685           0 :       if (clusterID.Data().fTrackId>-1) {
     686             :         // this is an assigned cluster, skip
     687             :         // TODO: introduce selectors into AliHLTIndexGrid::begin to loop
     688             :         // consistently over entries, e.g. this check has to be done also
     689             :         // in the forwarding of MC labels in
     690             :         // AliHLTTPCDataCompressionComponent::ForwardMCLabels
     691             :         continue;
     692             :       }
     693           0 :       if ((unsigned)slice!=AliHLTTPCSpacePointData::GetSlice(clusterID.Data().fId) ||
     694           0 :           (unsigned)part!=AliHLTTPCSpacePointData::GetPatch(clusterID.Data().fId)) {
     695           0 :         HLTError("cluster index 0x%08x out of slice %d partition %d", clusterID.Data().fId, slice, part);
     696             :       }
     697           0 :       int index=AliHLTTPCSpacePointData::GetNumber(clusterID.Data().fId);
     698           0 :       const AliHLTTPCHWCFData::iterator& input=pDecoder->find(index);
     699           0 :       if (!(input!=pDecoder->end())) continue;
     700           0 :       if (fWrittenClusterIds) fWrittenClusterIds->push_back(clusterID.Data().fId);
     701           0 :       int padrow=input.GetPadRow();
     702           0 :       if (padrow<0) {
     703             :         // something wrong here, padrow is stored in the cluster header
     704             :         // word which has bit pattern 0x3 in bits bit 30 and 31 which was
     705             :         // not recognized
     706           0 :         ALIHLTERRORGUARD(1, "can not read cluster header word");
     707             :         iResult=-EBADF;
     708           0 :         break;
     709             :       }
     710             : 
     711           0 :       float pad =input.GetPad();
     712           0 :       float time =input.GetTime();
     713           0 :       float sigmaY2=input.GetSigmaY2();
     714           0 :       float sigmaZ2=input.GetSigmaZ2();
     715           0 :       if (!pDeflater) {
     716           0 :         AliHLTTPCRawCluster& c=blockout->fClusters[blockout->fCount];
     717           0 :         padrow+=AliHLTTPCGeometry::GetFirstRow(part);
     718           0 :         c.SetPadRow(padrow);
     719           0 :         c.SetCharge(input.GetCharge());
     720           0 :         c.SetPad(pad);  
     721           0 :         c.SetTime(time);
     722           0 :         c.SetSigmaPad2(sigmaY2);
     723           0 :         c.SetSigmaTime2(sigmaZ2);
     724           0 :         c.SetQMax(input.GetQMax());
     725           0 :       } else {
     726           0 :         AliHLTUInt64_t padrow64=input.GetPadRow();
     727           0 :         if (padrow64==lastPadRow) {
     728           0 :           padrow64-=lastPadRow;
     729           0 :         } else if (padrow64>lastPadRow) {
     730           0 :           padrow64-=lastPadRow;
     731           0 :           lastPadRow+=padrow64;
     732           0 :         } else {
     733           0 :           AliFatal("padrows not ordered");
     734             :         }
     735             : 
     736           0 :         AliHLTUInt32_t padType=0;
     737           0 :         AliHLTUInt32_t signdPad=0;
     738           0 :         AliHLTUInt64_t pad64=0;
     739           0 :         if ((fMode&kModeDifferentialPadTime)!=0 && sigmaY2<.00001) {
     740             :           // single pad cluster
     741             :           // use twice the pad position to take account for the 0.5 offset
     742             :           // added in the AliHLTTPCHWCFData decoder in accordance with the
     743             :           // offline definition. Using the factor 2, this offset is not
     744             :           // cut off by rounding
     745           0 :           pad64=(AliHLTUInt64_t)round(2*pad);
     746           0 :           padType=1;
     747           0 :         } else {
     748           0 :         if (!isnan(pad)) pad64=(AliHLTUInt64_t)round(pad*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kPad].fScale);
     749             :         }
     750           0 :         if (fMode&kModeDifferentialPadTime && padType==0) {
     751             :           AliHLTUInt64_t dpad64=0;
     752           0 :           if (pad64<lastPad64) {
     753           0 :             dpad64=lastPad64-pad64;
     754           0 :             signdPad=1;
     755           0 :           } else {
     756           0 :             dpad64=pad64-lastPad64;
     757           0 :             signdPad=0;
     758             :           }
     759           0 :           lastPad64=pad64;
     760           0 :           pad64=dpad64;
     761           0 :         }
     762           0 :         AliHLTUInt32_t signdTime=0;
     763           0 :         AliHLTUInt64_t time64=0;
     764           0 :         if (!isnan(time)) time64=(AliHLTUInt64_t)round(time*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kTime].fScale);
     765           0 :         if (fMode&kModeDifferentialPadTime) {
     766             :           AliHLTUInt64_t dtime64=0;
     767           0 :           if (time64<lastTime64) {
     768           0 :             dtime64=lastTime64-time64;
     769           0 :             signdTime=1;
     770           0 :           } else {
     771           0 :             dtime64=time64-lastTime64;
     772           0 :             signdTime=0;
     773             :           }
     774           0 :           lastTime64=time64;
     775           0 :           time64=dtime64;
     776           0 :         }
     777           0 :         AliHLTUInt64_t sigmaY264=0;
     778           0 :         if (!isnan(sigmaY2)) sigmaY264=(AliHLTUInt64_t)round(sigmaY2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaY2].fScale);
     779           0 :         AliHLTUInt64_t sigmaZ264=0;
     780           0 :         if (!isnan(sigmaZ2)) sigmaZ264=(AliHLTUInt64_t)round(sigmaZ2*AliHLTTPCDefinitions::fgkClusterParameterDefinitions[AliHLTTPCDefinitions::kSigmaZ2].fScale);
     781           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPadRow , padrow64);
     782           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kPad    , pad64);
     783           0 :         if (fMode&kModeDifferentialPadTime) pDeflater->OutputBit(padType);
     784           0 :         if (fMode&kModeDifferentialPadTime && padType==0) pDeflater->OutputBit(signdPad);
     785           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kTime   , time64);
     786           0 :         if (fMode&kModeDifferentialPadTime) pDeflater->OutputBit(signdTime);
     787           0 :         if (padType==0) pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaY2, sigmaY264);
     788           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kSigmaZ2, sigmaZ264);
     789           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kCharge , input.GetCharge());
     790           0 :         pDeflater->OutputParameterBits(AliHLTTPCDefinitions::kQMax   , input.GetQMax());
     791           0 :       }
     792           0 :       blockout->fCount++;
     793           0 :     }
     794             :   }
     795           0 :   pDeflater->StopEncoder();
     796           0 :   AliHLTComponent_BlockData bd;
     797           0 :   AliHLTComponent::FillBlockData(bd);
     798           0 :   bd.fOffset        = size+offset;
     799           0 :   if (!pDeflater) {
     800           0 :     bd.fSize        = sizeof(AliHLTTPCRawClusterData)+blockout->fCount*sizeof(AliHLTTPCRawCluster);
     801           0 :     bd.fDataType    = AliHLTTPCDefinitions::fgkRawClustersDataType;
     802           0 :   } else {
     803           0 :     pDeflater->Pad8Bits();
     804           0 :     bd.fSize        = sizeof(AliHLTTPCRawClusterData)+pDeflater->GetBitDataOutputSizeBytes();
     805           0 :     pDeflater->CloseBitDataOutput();
     806           0 :     bd.fDataType    = AliHLTTPCDefinitions::RemainingClustersCompressedDataType();
     807             :   }
     808           0 :   bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, part, part);
     809           0 :   outputBlocks.push_back(bd);
     810             : 
     811           0 :   size += bd.fSize;
     812             : 
     813           0 :   if (fWrittenClusterIds && fWrittenClusterIds->size()>0) {
     814           0 :     AliHLTComponent::FillBlockData(bd);
     815           0 :     bd.fOffset        = size+offset;
     816           0 :     bd.fSize        = fWrittenClusterIds->size()*sizeof(vector<AliHLTUInt32_t>::value_type);
     817           0 :     if (bd.fSize+size<=capacity) {
     818           0 :       memcpy(outputPtr+size, &(*fWrittenClusterIds)[0], bd.fSize);
     819           0 :       bd.fDataType    = AliHLTTPCDefinitions::RemainingClusterIdsDataType();
     820           0 :       bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(slice, slice, part, part);
     821           0 :       outputBlocks.push_back(bd);    
     822           0 :       size += bd.fSize;
     823           0 :     } else {
     824             :       iResult=-ENOSPC;
     825             :     }
     826           0 :     fWrittenClusterIds->clear();
     827           0 :   }
     828             : 
     829           0 :   if (iResult<0) return iResult;
     830           0 :   return size;
     831           0 : }
     832             : 
     833             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties()
     834           0 :   : fDecoder(NULL)
     835           0 :   , fIndex(-1)
     836           0 :   , fUsed(false)
     837           0 :   , fTrackId(-1)
     838           0 :   , fMCId(-1)
     839           0 : {
     840             :   // constructor
     841           0 : }
     842             : 
     843             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFData* pDecoder, int index)
     844           0 :   : fDecoder(pDecoder)
     845           0 :   , fIndex(index)
     846           0 :   , fUsed(false)
     847           0 :   , fTrackId(-1)
     848           0 :   , fMCId(-1)
     849           0 : {
     850             :   // constructor
     851           0 : }
     852             : 
     853             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::AliHLTTPCHWCFSpacePointProperties(const AliHLTTPCHWCFSpacePointProperties& src)
     854           0 :   : fDecoder(src.fDecoder)
     855           0 :   , fIndex(src.fIndex)
     856           0 :   , fUsed(src.fUsed)
     857           0 :   , fTrackId(src.fTrackId)
     858           0 :   , fMCId(src.fMCId)
     859           0 : {
     860             :   // copy constructor
     861           0 : }
     862             : 
     863             : AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::operator=(const AliHLTTPCHWCFSpacePointProperties& src)
     864             : {
     865             :   // assignment operator
     866           0 :   if (&src==this) return *this;
     867           0 :   fDecoder=src.fDecoder;
     868           0 :   fIndex=src.fIndex;
     869           0 :   fUsed=src.fUsed;
     870           0 :   fTrackId=src.fTrackId;
     871           0 :   fMCId=src.fMCId;
     872             : 
     873           0 :   return *this;
     874           0 : }
     875             : 
     876             : void AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties::Print(ostream& out, Option_t */*option*/) const
     877             : {
     878             :   // print info
     879           0 :   if (!Decoder()) {
     880           0 :     out << "no data";
     881           0 :     return;
     882             :   }
     883           0 :   std::stringstream str;
     884           0 :   const AliHLTTPCHWCFData* decoder=Decoder();
     885           0 :   str.setf(ios::fixed,ios::floatfield);
     886           0 :   str << " " << setfill(' ') << setw(3) << decoder->GetPadRow(fIndex) 
     887           0 :       << " " << setw(8) << setprecision(3) << decoder->GetPad(fIndex)
     888           0 :       << " " << setw(8) << setprecision(3) << decoder->GetTime(fIndex)
     889           0 :       << " " << setw(8) << setprecision(1) << decoder->GetSigmaY2(fIndex) 
     890           0 :       << " " << setw(9) << setprecision(1) << decoder->GetSigmaZ2(fIndex)
     891           0 :       << " " << setw(5) << decoder->GetCharge(fIndex) 
     892           0 :       << " " << setw(5) << decoder->GetQMax(fIndex)
     893           0 :       << " " << fTrackId << " " << fMCId << " " << fUsed;
     894           0 :   out << str.str();
     895           0 : }
     896             : 
     897             : ostream& operator<<(ostream &out, const AliHLTTPCHWCFSpacePointContainer::AliHLTTPCHWCFSpacePointProperties& p)
     898             : {
     899           0 :   p.Print(out);
     900           0 :   return out;
     901             : }

Generated by: LCOV version 1.11