LCOV - code coverage report
Current view: top level - HLT/TPCLib/tracking-ca - AliHLTTPCCAInputDataCompressorComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 112 8.0 %
Date: 2016-06-14 17:26:59 Functions: 8 20 40.0 %

          Line data    Source code
       1             : // **************************************************************************
       2             : // This file is property of and copyright by the ALICE HLT Project          *
       3             : // ALICE Experiment at CERN, All rights reserved.                           *
       4             : //                                                                          *
       5             : // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
       6             : //                  Ivan Kisel <kisel@kip.uni-heidelberg.de>                *
       7             : //                  for The ALICE HLT Project.                              *
       8             : //                                                                          *
       9             : // Permission to use, copy, modify and distribute this software and its     *
      10             : // documentation strictly for non-commercial purposes is hereby granted     *
      11             : // without fee, provided that the above copyright notice appears in all     *
      12             : // copies and that both the copyright notice and this permission notice     *
      13             : // appear in the supporting documentation. The authors make no claims       *
      14             : // about the suitability of this software for any purpose. It is            *
      15             : // provided "as is" without express or implied warranty.                    *
      16             : //                                                                          *
      17             : //***************************************************************************
      18             : 
      19             : 
      20             : ///////////////////////////////////////////////////////////////////////////////
      21             : //                                                                           //
      22             : // a TPC tracker processing component for the HLT based on CA by Ivan Kisel  //
      23             : //                                                                           //
      24             : ///////////////////////////////////////////////////////////////////////////////
      25             : 
      26             : 
      27             : #include "AliHLTTPCCAInputDataCompressorComponent.h"
      28             : #include "AliHLTTPCCACompressedInputData.h"
      29             : #include "AliHLTTPCGeometry.h"
      30             : #include "AliHLTTPCClusterDataFormat.h"
      31             : #include "AliHLTTPCSpacePointData.h"
      32             : #include "AliHLTTPCDefinitions.h"
      33             : #include "AliHLTTPCCADef.h"
      34             : 
      35             : #if __GNUC__>= 3
      36             : using namespace std;
      37             : #endif
      38             : 
      39           6 : const AliHLTComponentDataType AliHLTTPCCADefinitions::fgkCompressedInputDataType = AliHLTComponentDataTypeInitializer( "CAINPACK", kAliHLTDataOriginTPC );
      40             : 
      41             : /** ROOT macro for the implementation of ROOT specific class methods */
      42           6 : ClassImp( AliHLTTPCCAInputDataCompressorComponent )
      43             : 
      44             : AliHLTTPCCAInputDataCompressorComponent::AliHLTTPCCAInputDataCompressorComponent()
      45             :   :
      46           3 :   AliHLTProcessor(),
      47           3 :   fBenchmark("CAInputCompressor")
      48          15 : {
      49             :   // see header file for class documentation
      50             :   // or
      51             :   // refer to README to build package
      52             :   // or
      53             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      54           6 : }
      55             : 
      56             : AliHLTTPCCAInputDataCompressorComponent::AliHLTTPCCAInputDataCompressorComponent( const AliHLTTPCCAInputDataCompressorComponent& )
      57             :   :
      58           0 :   AliHLTProcessor(),
      59           0 :   fBenchmark("CAInputCompressor")
      60           0 : {
      61             :   // see header file for class documentation
      62           0 :   HLTFatal( "copy constructor untested" );
      63           0 : }
      64             : 
      65             : AliHLTTPCCAInputDataCompressorComponent& AliHLTTPCCAInputDataCompressorComponent::operator=( const AliHLTTPCCAInputDataCompressorComponent& )
      66             : {
      67             :   // see header file for class documentation
      68           0 :   HLTFatal( "assignment operator untested" );
      69           0 :   return *this;
      70             : }
      71             : 
      72             : AliHLTTPCCAInputDataCompressorComponent::~AliHLTTPCCAInputDataCompressorComponent()
      73          18 : {
      74             :   // see header file for class documentation  
      75           9 : }
      76             : 
      77             : //
      78             : // Public functions to implement AliHLTComponent's interface.
      79             : // These functions are required for the registration process
      80             : //
      81             : 
      82             : const char* AliHLTTPCCAInputDataCompressorComponent::GetComponentID()
      83             : {
      84             :   // see header file for class documentation
      85         558 :   return "TPCCAInputDataCompressor";
      86             : }
      87             : 
      88             : void AliHLTTPCCAInputDataCompressorComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list )
      89             : {
      90             :   // see header file for class documentation
      91           0 :   list.clear();
      92           0 :   list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
      93           0 : }
      94             : 
      95             : AliHLTComponentDataType AliHLTTPCCAInputDataCompressorComponent::GetOutputDataType()
      96             : {
      97             :   // see header file for class documentation
      98           0 :   return AliHLTTPCCADefinitions::fgkCompressedInputDataType;
      99             : }
     100             : 
     101             : void AliHLTTPCCAInputDataCompressorComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
     102             : {
     103             :   // define guess for the output data size
     104           0 :   constBase = 200;       // minimum size
     105           0 :   inputMultiplier = 0.25; // size relative to input
     106           0 : }
     107             : 
     108             : AliHLTComponent* AliHLTTPCCAInputDataCompressorComponent::Spawn()
     109             : {
     110             :   // see header file for class documentation
     111           0 :   return new AliHLTTPCCAInputDataCompressorComponent;
     112           0 : }
     113             : 
     114             : 
     115             : 
     116             : 
     117             : int AliHLTTPCCAInputDataCompressorComponent::DoInit( int /*argc*/, const char** /*argv*/ )
     118             : {
     119             :   // Configure the CA tracker component
     120           0 :   fBenchmark.Reset();
     121           0 :   fBenchmark.SetTimer(0,"total");
     122           0 :   fBenchmark.SetTimer(1,"reco");
     123           0 :   return 0;
     124             : }
     125             : 
     126             : 
     127             : int AliHLTTPCCAInputDataCompressorComponent::DoDeinit()
     128             : {
     129             :   // see header file for class documentation
     130           0 :   return 0;
     131             : }
     132             : 
     133             : 
     134             : 
     135             : int AliHLTTPCCAInputDataCompressorComponent::Reconfigure( const char* /*cdbEntry*/, const char* /*chainId*/ )
     136             : {
     137             :   // Reconfigure the component from OCDB .
     138           0 :   return 0;
     139             : }
     140             : 
     141             : 
     142             : 
     143             : int AliHLTTPCCAInputDataCompressorComponent::DoEvent
     144             : (
     145             :   const AliHLTComponentEventData& evtData,
     146             :   const AliHLTComponentBlockData* blocks,
     147             :   AliHLTComponentTriggerData& /*trigData*/,
     148             :   AliHLTUInt8_t* outputPtr,
     149             :   AliHLTUInt32_t& size,
     150             :   vector<AliHLTComponentBlockData>& outputBlocks )
     151             : {
     152             :   //* process event
     153             : 
     154           0 :   AliHLTUInt32_t maxBufferSize = size;
     155           0 :   size = 0; // output size
     156             : 
     157           0 :   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) {
     158           0 :     return 0;
     159             :   }
     160             : 
     161           0 :   fBenchmark.StartNewEvent();
     162           0 :   fBenchmark.Start(0);
     163             : 
     164             :   // Preprocess the data for CA Slice Tracker
     165             : 
     166           0 :   if ( evtData.fBlockCnt <= 0 ) {
     167           0 :     HLTWarning( "no blocks in event" );
     168           0 :     return 0;
     169             :   }
     170             : 
     171             :   Int_t ret = 0;
     172             : 
     173             :   Int_t outTotalSize = 0;
     174             :   Int_t minSlice = 100;
     175             :   Int_t maxSlice = -1;
     176             : 
     177           0 :   for ( unsigned long ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
     178           0 :     const AliHLTComponentBlockData* iter = blocks + ndx;
     179           0 :     if ( iter->fDataType != AliHLTTPCDefinitions::fgkClustersDataType ) continue;    
     180             : 
     181           0 :     fBenchmark.AddInput(iter->fSize);
     182             : 
     183           0 :     if( minSlice>AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ) minSlice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ) ;
     184           0 :     if( maxSlice<AliHLTTPCDefinitions::GetMaxSliceNr( *iter ) ) maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr( *iter ) ;
     185             :       
     186             : 
     187           0 :     AliHLTUInt32_t dSize = 0;
     188             : 
     189           0 :     fBenchmark.Start(1);
     190             :   
     191           0 :     ret = Compress( ( AliHLTTPCClusterData* )( iter->fPtr ), maxBufferSize - outTotalSize,
     192           0 :                     outputPtr+outTotalSize,
     193             :                     dSize );
     194           0 :     fBenchmark.Stop(1);
     195             : 
     196           0 :     if ( ret!=0 ){
     197           0 :       HLTWarning( "Output buffer size exceed (buffer size %d, current size %d)", maxBufferSize );     
     198           0 :       break;
     199             :     }    
     200             :    
     201           0 :     AliHLTComponentBlockData bd;
     202           0 :     FillBlockData( bd );
     203           0 :     bd.fOffset = outTotalSize;
     204           0 :     bd.fSize = dSize;
     205           0 :     bd.fSpecification = iter->fSpecification;
     206           0 :     bd.fDataType = GetOutputDataType();
     207           0 :     outputBlocks.push_back( bd );
     208           0 :     outTotalSize+=dSize;      
     209           0 :     fBenchmark.AddOutput(bd.fSize);
     210           0 :   }
     211             : 
     212           0 :   size = outTotalSize;
     213             :   
     214           0 :   fBenchmark.Stop(0);
     215             :   
     216           0 :   if( maxSlice<0 ) minSlice = -1;
     217             : 
     218             :   // Set log level to "Warning" for on-line system monitorin  
     219             : 
     220           0 :   if( minSlice!=maxSlice ) fBenchmark.SetName(Form("CAInputDataCompressor, slices %d-%d", minSlice, maxSlice));
     221           0 :   else fBenchmark.SetName(Form("CAInputDataCompressor, slice %d", minSlice));
     222             :  
     223           0 :   HLTInfo( fBenchmark.GetStatistics());
     224             :   return ret;
     225           0 : }
     226             : 
     227             : 
     228             : 
     229             : int AliHLTTPCCAInputDataCompressorComponent::Compress( AliHLTTPCClusterData* inputPtr,
     230             :                                                        AliHLTUInt32_t maxBufferSize,
     231             :                                                        AliHLTUInt8_t* outputPtr,
     232             :                                                        AliHLTUInt32_t& outputSize
     233             :                                                        )
     234             : {
     235             :   // Preprocess the data for CA Slice Tracker
     236             : 
     237             :   Int_t ret = 0;
     238           0 :   outputSize = 0;
     239             : 
     240           0 :   AliHLTTPCCACompressedCluster *outCluster = (AliHLTTPCCACompressedCluster*)( outputPtr );
     241             :   AliHLTTPCCACompressedClusterRow *outRow = 0;
     242             : 
     243             :   UShort_t oldId = 0;
     244             : 
     245           0 :   for ( unsigned int i = 0; i < inputPtr->fSpacePointCnt; i++ ){ 
     246           0 :     AliHLTTPCSpacePointData *cluster = &( inputPtr->fSpacePoints[i] );
     247           0 :     UInt_t patch = cluster->GetPatch();
     248           0 :     UInt_t slice = cluster->GetSlice();
     249           0 :     UInt_t row = cluster->fPadRow;
     250           0 :     Double_t rowX = AliHLTTPCGeometry::Row2X( row );
     251           0 :     row = row - AliHLTTPCGeometry::GetFirstRow( patch );
     252           0 :     UShort_t id = (UShort_t)( (slice<<10) +(patch<<6) + row );
     253           0 :     if( i==0 || id!= oldId ){ 
     254             :       // fill new row header    
     255           0 :       outRow = (AliHLTTPCCACompressedClusterRow*) outCluster;
     256           0 :       outCluster = outRow->fClusters;  
     257           0 :       outputSize+= ( ( AliHLTUInt8_t * )outCluster ) -  (( AliHLTUInt8_t * )outRow);
     258           0 :       if ( outputSize >  maxBufferSize ){
     259             :         ret = -ENOSPC;
     260           0 :         outputSize=0;
     261           0 :         break;
     262             :       }
     263           0 :       outRow->fSlicePatchRowID = id; 
     264           0 :       outRow->fNClusters = 0;
     265             :       oldId = id;
     266             :       //cout<<"Fill row: s "<<slice<<" p "<<patch<<" r "<<row<<" x "<<outRow->fX<<":"<<endl;
     267           0 :     }
     268             :     
     269             :     // pack the cluster
     270             :     {
     271             :       // get coordinates in [um]
     272             :         
     273           0 :       Double_t x = (cluster->fX - rowX )*1.e4 + 32768.;
     274           0 :       Double_t y = (cluster->fY)*1.e4 + 8388608.;
     275           0 :       Double_t z = (cluster->fZ)*1.e4 + 8388608.;
     276             :       
     277             :       // truncate if necessary
     278           0 :       if( x<0 ) x = 0; else if( x > 0x0000FFFF ) x = 0x0000FFFF;
     279           0 :       if( y<0 ) y = 0; else if( y > 0x00FFFFFF ) y = 0x00FFFFFF;
     280           0 :       if( z<0 ) z = 0; else if( z > 0x00FFFFFF ) z = 0x00FFFFFF;
     281             :       
     282           0 :       UInt_t ix0 =  ( (UInt_t) x )&0x000000FF;
     283           0 :       UInt_t ix1 = (( (UInt_t) x )&0x0000FF00 )>>8;
     284           0 :       UInt_t iy = ( (UInt_t) y )&0x00FFFFFF;
     285           0 :       UInt_t iz = ( (UInt_t) z )&0x00FFFFFF;
     286             :       
     287           0 :       outputSize+= sizeof( AliHLTTPCCACompressedCluster );
     288           0 :       if ( outputSize > maxBufferSize ){
     289           0 :         outputSize = 0;
     290             :         ret = -ENOSPC;
     291           0 :         break;      
     292             :       }
     293           0 :       outCluster->fP0 = (ix0<<24) + iy;
     294           0 :       outCluster->fP1 = (ix1<<24) + iz;      
     295           0 :       outCluster++;
     296           0 :       outRow->fNClusters++;
     297             :       //cout<<"clu "<<outRow->fNClusters-1<<": "<<cluster->fX<<" "<<cluster->fY<<" "<<cluster->fZ<<" "<<cluster->fID<<endl;
     298           0 :     }
     299           0 :   }
     300             :     
     301           0 :   return ret;
     302             : }

Generated by: LCOV version 1.11