LCOV - code coverage report
Current view: top level - HLT/ITS - AliHLTITSCompressRawDataSDDComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 67 11.9 %
Date: 2016-06-14 17:26:59 Functions: 7 14 50.0 %

          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: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
       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   AliHLTITSCompressRawDataSDDComponent.cxx
      20             :     @author Jochen Thaeder <thaeder@kip.uni-heidelberg.de>
      21             :     @date   
      22             :     @brief  Component to run data compression for SDD
      23             : */
      24             : 
      25             : #include "AliHLTITSCompressRawDataSDDComponent.h" 
      26             : 
      27             : #include "AliCDBEntry.h"
      28             : #include "AliCDBManager.h"
      29             : 
      30             : #include <cstdlib>
      31             : #include <cerrno>
      32             : #include "TString.h"
      33             : #include "TObjString.h"
      34             : #include <sys/time.h>
      35             : 
      36             : using namespace std;
      37             : 
      38             : /** ROOT macro for the implementation of ROOT specific class methods */
      39           6 : ClassImp(AliHLTITSCompressRawDataSDDComponent);
      40             : 
      41           3 : AliHLTITSCompressRawDataSDDComponent::AliHLTITSCompressRawDataSDDComponent()
      42             :   :
      43           3 :   fDataCompressor(NULL),
      44          18 :   fRawReader(NULL) {
      45             :   // see header file for class documentation
      46             :   // or
      47             :   // refer to README to build package
      48             :   // or
      49             :   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      50           6 : }
      51             : 
      52          12 : AliHLTITSCompressRawDataSDDComponent::~AliHLTITSCompressRawDataSDDComponent() {
      53             :   // see header file for class documentation
      54          12 : }
      55             : 
      56             : // Public functions to implement AliHLTComponent's interface.
      57             : // These functions are required for the registration process
      58             : 
      59             : const char* AliHLTITSCompressRawDataSDDComponent::GetComponentID()
      60             : {
      61             :   // see header file for class documentation
      62             : 
      63          84 :   return "ITSDataCompressorSDD";
      64             : }
      65             : 
      66             : void AliHLTITSCompressRawDataSDDComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
      67             :   // see header file for class documentation
      68           0 :   list.clear(); 
      69           0 :   list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITS );
      70             : 
      71           0 : }
      72             : 
      73             : AliHLTComponentDataType AliHLTITSCompressRawDataSDDComponent::GetOutputDataType() {
      74             :   // see header file for class documentation
      75           0 :   return (kAliHLTDataTypeDDLRaw| kAliHLTDataOriginITS);
      76             : }
      77             : 
      78             : void AliHLTITSCompressRawDataSDDComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
      79             :   // see header file for class documentation
      80             : 
      81           0 :   constBase = 0;
      82           0 :   inputMultiplier = 0.3;
      83           0 : }
      84             : 
      85             : AliHLTComponent* AliHLTITSCompressRawDataSDDComponent::Spawn() {
      86             :   // see header file for class documentation
      87           0 :   return new AliHLTITSCompressRawDataSDDComponent();
      88           0 : }
      89             :         
      90             : Int_t AliHLTITSCompressRawDataSDDComponent::DoInit( int /*argc*/, const char** /*argv*/ ) {
      91             :   // see header file for class documentation
      92             : 
      93           0 :   if ( fDataCompressor )
      94           0 :     return EINPROGRESS;
      95             : 
      96           0 :   fDataCompressor = new AliITSCompressRawDataSDD();
      97             : 
      98           0 :   if ( fRawReader )
      99           0 :     return EINPROGRESS;
     100             : 
     101           0 :   fRawReader = new AliRawReaderMemory();
     102             : 
     103           0 :   return 0;
     104           0 : }
     105             : 
     106             : Int_t AliHLTITSCompressRawDataSDDComponent::DoDeinit() {
     107             :   // see header file for class documentation
     108             : 
     109           0 :   if ( fRawReader )
     110           0 :     delete fRawReader;
     111           0 :   fRawReader = NULL;
     112             : 
     113           0 :   if ( fDataCompressor )
     114           0 :     delete fDataCompressor;
     115           0 :   fDataCompressor = NULL;
     116             : 
     117           0 :   return 0;
     118             : }
     119             : 
     120             : Int_t AliHLTITSCompressRawDataSDDComponent::DoEvent( const AliHLTComponentEventData& evtData, 
     121             :                                                      const AliHLTComponentBlockData* blocks, 
     122             :                                                      AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
     123             :                                                      AliHLTUInt32_t& size, 
     124             :                                                      vector<AliHLTComponentBlockData>& outputBlocks ) {
     125             :   // see header file for class documentation
     126             : 
     127           0 :   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
     128           0 :     size=0;
     129           0 :     return 0;
     130             :   }
     131             : 
     132             :   // -- Iterator over Data Blocks --
     133             :   const AliHLTComponentBlockData* iter = NULL;
     134             : 
     135             :   // -- Ptr to output shm region --
     136             :   AliHLTUInt8_t* outShmPtr = outputPtr;
     137             : 
     138             :   // -- Initialize out sizes
     139             :   UInt_t offset    = 0;   // offset of current outblock
     140             :   UInt_t mySize    = 0;   // out size produced from current block
     141             :   UInt_t totalSize = 0;   // total out size of this event
     142             :   UInt_t availSize = 0;   // still availible out size for this event
     143             : 
     144             :   // -- Loop over blocks
     145           0 :   for ( ULong_t ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {
     146             : 
     147           0 :     iter = blocks+ndx;
     148             : 
     149             :     mySize = 0;
     150             :     offset = totalSize;
     151           0 :     availSize = size - totalSize;
     152             : 
     153             :     // -- Debug output of datatype --
     154             :     HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
     155             :                evtData.fEventID, evtData.fEventID, 
     156             :                DataType2Text(iter->fDataType).c_str(), 
     157             :                DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD).c_str());
     158             :     
     159             :     // -- Check for the correct data type
     160           0 :     if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginITSSDD) )
     161             :       continue;
     162             :     
     163             :     // -- Set RawReader
     164           0 :     fRawReader->SetMemory( (UChar_t*) iter->fPtr, iter->fSize );
     165             : 
     166             :     // -- Get equipment ID out of specification
     167           0 :     AliHLTUInt32_t spec = iter->fSpecification;
     168             : 
     169             :     Int_t id = 256;
     170           0 :     for ( Int_t ii = 0; ii < 24 ; ii++ ) {
     171           0 :       if ( spec & 0x00000001 ) {
     172           0 :         id += ii;
     173           0 :         break;
     174             :       }
     175           0 :       spec = spec >> 1 ;
     176             :     }
     177             :     
     178             :     // -- Set equipment ID to the raw reader
     179           0 :     fRawReader->SetEquipmentID( id ); 
     180             :     
     181             :     // -- Set raw reader
     182           0 :     fDataCompressor->SetRawReader( fRawReader );
     183             : 
     184             :     // -- Set ptr to output shm
     185           0 :     fDataCompressor->SetPointerToData( (UChar_t*) outShmPtr );
     186             : 
     187             :     // -- Set availible outputspace
     188           0 :     fDataCompressor->SetSize( (UInt_t) availSize );
     189             : 
     190             :     // -- Compress event
     191           0 :     mySize = fDataCompressor->CompressEvent( (UChar_t*) iter->fPtr );
     192             : 
     193             :     // -- Fill output blocks
     194           0 :     AliHLTComponentBlockData bd;
     195           0 :     FillBlockData( bd );
     196           0 :     bd.fOffset = offset;
     197           0 :     bd.fSize = mySize;
     198           0 :     bd.fSpecification = iter->fSpecification;
     199           0 :     bd.fDataType = iter->fDataType;
     200           0 :     outputBlocks.push_back( bd );
     201             : 
     202             :     // -- Increase size counters
     203           0 :     totalSize += mySize;
     204             : 
     205             :     // -- Increase output shm ptr
     206           0 :     outShmPtr += mySize;
     207             : 
     208             :     // -- Check if data was written over allowed buffer
     209           0 :     if ( totalSize > size ) {
     210           0 :       HLTError( "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",  totalSize, size );
     211           0 :       return EMSGSIZE;
     212             :     }
     213             :     
     214           0 :   } //  for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) {    
     215             : 
     216             :   // -- Set total output size
     217           0 :   size = totalSize;
     218             :     
     219           0 :   return 0;
     220           0 : }

Generated by: LCOV version 1.11