LCOV - code coverage report
Current view: top level - HLT/TPCLib/comp - AliHLTTPCDataCompressionFilterComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 74 9.5 %
Date: 2016-06-14 17:26:59 Functions: 7 17 41.2 %

          Line data    Source code
       1             : // $Id$
       2             : //**************************************************************************
       3             : //* This file is property of and copyright by the ALICE HLT Project        * 
       4             : //* ALICE Experiment at CERN, All rights reserved.                         *
       5             : //*                                                                        *
       6             : //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
       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             : /// @file   AliHLTTPCDataCompressionFilterComponent.cxx
      19             : /// @author Matthias Richter
      20             : /// @date   2011-08-08
      21             : /// @brief  TPC component for data compression
      22             : ///
      23             : 
      24             : #include "AliHLTTPCDataCompressionFilterComponent.h"
      25             : #include "AliHLTTPCDefinitions.h"
      26             : #include "AliHLTPluginBase.h"
      27             : #include "AliHLTSystem.h"
      28             : #include "AliHLTOUT.h"
      29             : #include "AliLog.h"
      30             : 
      31           6 : ClassImp(AliHLTTPCDataCompressionFilterComponent)
      32             : 
      33             : AliHLTTPCDataCompressionFilterComponent::AliHLTTPCDataCompressionFilterComponent()
      34           3 :   : AliHLTProcessor()
      35          15 : {
      36           6 : }
      37             : 
      38             : AliHLTTPCDataCompressionFilterComponent::~AliHLTTPCDataCompressionFilterComponent()
      39          12 : {
      40             :   /// destructor
      41          12 : }
      42             : 
      43             : 
      44             : const char* AliHLTTPCDataCompressionFilterComponent::GetComponentID()
      45             : {
      46             :   /// inherited from AliHLTComponent: id of the component
      47         408 :   return "TPCDataCompressorFilter";
      48             : }
      49             : 
      50             : 
      51             : void AliHLTTPCDataCompressionFilterComponent::GetInputDataTypes( AliHLTComponentDataTypeList& tgtList)
      52             : {
      53             :   /// inherited from AliHLTComponent: list of data types in the vector reference
      54           0 :   tgtList.clear();
      55           0 :   tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
      56           0 :   tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
      57           0 : }
      58             : 
      59             : AliHLTComponentDataType AliHLTTPCDataCompressionFilterComponent::GetOutputDataType()
      60             : {
      61             :   /// inherited from AliHLTComponent: output data type of the component.
      62           0 :   return kAliHLTMultipleDataType;
      63             : }
      64             : 
      65             : int AliHLTTPCDataCompressionFilterComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
      66             : {
      67             :   /// inherited from AliHLTComponent: multiple output data types of the component.
      68           0 :   tgtList.clear();
      69           0 :   tgtList.push_back(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
      70           0 :   tgtList.push_back(AliHLTTPCDefinitions::RemainingClusterIdsDataType());
      71           0 :   return tgtList.size();
      72             : }
      73             : 
      74             : void AliHLTTPCDataCompressionFilterComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
      75             : {
      76             :   /// inherited from AliHLTComponent: output data size estimator
      77           0 :   constBase=0;
      78           0 :   inputMultiplier=1.;  // there should not be more data than input
      79           0 : }
      80             : 
      81             : AliHLTComponent* AliHLTTPCDataCompressionFilterComponent::Spawn()
      82             : {
      83             :   /// inherited from AliHLTComponent: spawn function.
      84           0 :   return new AliHLTTPCDataCompressionFilterComponent;
      85           0 : }
      86             : 
      87             : int AliHLTTPCDataCompressionFilterComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, 
      88             :                                                 AliHLTComponentTriggerData& /*trigData*/)
      89             : {
      90             :   /// inherited from AliHLTProcessor: data processing
      91           0 :   if (!IsDataEvent()) return 0;
      92             : 
      93           0 :   if (GetFirstInputBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())!=NULL) {
      94             :     // This component is only used in conjunction with an emulation chain for compressed
      95             :     // partition cluster blocks. Blocks which are missing in HLTOUT but are existing in
      96             :     // the data stream from the parent, are forwarded. This scheme allows to automatically
      97             :     // create missing partitions in the compressed data from raw data (e.g. if an input
      98             :     // link of the HLT is broken and raw data recorded), and add it to the HLTOUT to
      99             :     // have a consistent data set. This requires individual cluster data blocks, track
     100             :     // model compression can not be used in the emulation because the clusters can not be
     101             :     // related to a particular partition.
     102           0 :     AliFatalClass("compressed track cluster data blocks can not be mixed. aborting");
     103           0 :     return -EBADF;
     104             :   }
     105             : 
     106           0 :   std::map<AliHLTUInt32_t, bool> hltoutmap;
     107             :   bool bHaveMap=false;
     108             : 
     109           0 :   for (const AliHLTComponentBlockData* pDesc=GetFirstInputBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType());
     110           0 :        pDesc!=NULL; pDesc=GetNextInputBlock()) {
     111           0 :     if (!bHaveMap) {
     112           0 :       InitMapFromHLTOUT(hltoutmap);
     113             :       bHaveMap=true;
     114           0 :     }
     115           0 :     if (hltoutmap.find(pDesc->fSpecification)!=hltoutmap.end()) {
     116             :       // block existing in HLTOUT
     117             :       continue;
     118             :     }
     119           0 :     Forward(pDesc);
     120           0 :     HLTInfo("inserting block 0x%08x", pDesc->fSpecification);
     121             :   }
     122             : 
     123             :   return 0;
     124           0 : }
     125             : 
     126             : int AliHLTTPCDataCompressionFilterComponent::InitMapFromHLTOUT(std::map<AliHLTUInt32_t, bool>& hltoutmap)
     127             : {
     128             :   // check the HLTOUT for availability of compressed data blocks
     129           0 :   AliHLTSystem* pSystem=AliHLTPluginBase::GetInstance();
     130           0 :   if (!pSystem) {
     131             :     // global system not initialized
     132           0 :     return -ENODEV;
     133             :   }
     134           0 :   AliHLTOUT* pHLTOUT=pSystem->RequestHLTOUT();
     135           0 :   if (!pHLTOUT) {
     136             :     // not HLTOUT, hence not clusters
     137           0 :     return 0;
     138             :   }
     139             : 
     140           0 :   for (bool bNextBlock=(pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::RemainingClustersCompressedDataType())>=0);
     141           0 :        bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
     142           0 :     AliHLTComponentDataType dt=kAliHLTVoidDataType;
     143           0 :     AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
     144           0 :     if (pHLTOUT->GetDataBlockDescription(dt, spec)<0)
     145           0 :       continue;
     146             : 
     147           0 :     hltoutmap[spec]=true;
     148           0 :   }
     149             : 
     150           0 :   for (bool bNextBlock=(pHLTOUT->SelectFirstDataBlock(AliHLTTPCDefinitions::ClusterTracksCompressedDataType())>=0);
     151           0 :        bNextBlock; bNextBlock=(pHLTOUT->SelectNextDataBlock()>=0)) {
     152             :     // the first version of this component will not implement support for track model compression data blocks
     153             :     // to implement it
     154             :     // - decode data
     155             :     // - sort into index grid
     156             :     // - check if there is at least one cluster in a partition, that is a sufficient condition
     157             :     //   to decide whether a partition was included or not
     158             :     // The best would be to implement a class which supports the AliHLTTPCDataCompressionDecoder
     159             :     // interface and stores unpacked data in AliHLTTPCRawCluster format and fills the index
     160             :     // grid at the same time
     161           0 :     AliFatalClass("this functionality needs to be implemented");
     162             :   }
     163             :     
     164           0 :   return 0;
     165           0 : }
     166             : 
     167             : int AliHLTTPCDataCompressionFilterComponent::DoInit( int argc, const char** argv )
     168             : {
     169             :   /// inherited from AliHLTComponent: component initialisation and argument scan.
     170             :   int iResult=0;
     171             : 
     172             :   // component configuration
     173             :   //Stage 1: default initialization.
     174             :   //No default values until now.
     175             : 
     176             :   //Stage 2: OCDB. - disabled
     177             :   //TString cdbPath("HLT/ConfigTPC/");
     178             :   //cdbPath += GetComponentID();
     179             :   //
     180             :   //iResult = ConfigureFromCDBTObjString(cdbPath);
     181             :   //if (iResult < 0) 
     182             :   //  return iResult;
     183             : 
     184             :   //Stage 3: command line arguments.
     185           0 :   if (argc && (iResult = ConfigureFromArgumentString(argc, argv)) < 0)
     186           0 :     return iResult;
     187             : 
     188           0 :   return iResult;
     189           0 : }
     190             : 
     191             : int AliHLTTPCDataCompressionFilterComponent::DoDeinit()
     192             : {
     193             :   /// inherited from AliHLTComponent: component cleanup
     194             :   int iResult=0;
     195             : 
     196           0 :   return iResult;
     197             : }
     198             : 
     199             : int AliHLTTPCDataCompressionFilterComponent::ScanConfigurationArgument(int argc, const char** argv)
     200             : {
     201             :   /// inherited from AliHLTComponent: argument scan
     202             :   int iResult=0;
     203           0 :   if (argc<1) return 0;
     204             :   int bMissingParam=0;
     205             :   int i=0;
     206           0 :   TString argument=argv[i];
     207             : 
     208             :   do {
     209             :     // -mode
     210           0 :     if (argument.CompareTo("-mode")==0) {
     211           0 :       if ((bMissingParam=(++i>=argc))) break;
     212           0 :       TString parameter=argv[i];
     213           0 :       if (parameter.IsDigit()) {
     214             : 
     215           0 :         return 2;
     216             :       } else {
     217           0 :         HLTError("invalid parameter for argument %s, expecting number instead of %s", argument.Data(), parameter.Data());
     218           0 :         return -EPROTO;
     219             :       }
     220           0 :     }
     221             : 
     222             :   } while (0); // using do-while only to have break available
     223             : 
     224           0 :   if (bMissingParam) {
     225           0 :     HLTError("missing parameter for argument %s", argument.Data());
     226             :     iResult=-EPROTO;
     227           0 :   }
     228             : 
     229           0 :   return iResult;
     230           0 : }

Generated by: LCOV version 1.11