LCOV - code coverage report
Current view: top level - HLT/BASE/util - AliHLTRootFileStreamerComponent.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 54 14.8 %
Date: 2016-06-14 17:26:59 Functions: 6 11 54.5 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : //**************************************************************************
       4             : //* This file is property of and copyright by the                          * 
       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   AliHLTRootFileStreamerComponent.cxx
      20             : /// @author Matthias Richter
      21             : /// @date   
      22             : /// @brief  Save objects in a ROOT memory file
      23             : ///
      24             : 
      25             : #include "AliHLTRootFileStreamerComponent.h"
      26             : #include "TString.h"
      27             : 
      28             : /** ROOT macro for the implementation of ROOT specific class methods */
      29           8 : ClassImp(AliHLTRootFileStreamerComponent)
      30             : 
      31             : AliHLTRootFileStreamerComponent::AliHLTRootFileStreamerComponent()
      32             :   :
      33           3 :   AliHLTProcessor(),
      34           3 :   fDataType(kAliHLTVoidDataType),
      35           3 :   fSpecification(~(AliHLTUInt32_t)0)
      36          15 : {
      37             :   // The RootFileStreamer provides a stand alone component to write incoming
      38             :   // TObject like structures into a ROOT memory file. A ROOT memory file is
      39             :   // a ROOT file stored in memory instead on disk (AliHLTMemoryFile) The file
      40             :   // is published via the output stream. On the receiver side the file can
      41             :   // be directly written to disk and appears like a normal root file.
      42             :   //
      43             :   // Component ID: \b ROOTFileStreamer                                    <br>
      44             :   // Library: \b libAliHLTUtil.so                                         <br>
      45             :   // Input Data Types: ::kAliHLTAnyDataType                               <br>
      46             :   // Output Data Types: according to component arguments,
      47             :   //                    ::kAliHLTVoidDataType by default                  <br>
      48           6 : }
      49             : 
      50             : AliHLTRootFileStreamerComponent::~AliHLTRootFileStreamerComponent()
      51          12 : {
      52             :   // destructor
      53          12 : }
      54             : 
      55             : void AliHLTRootFileStreamerComponent::GetInputDataTypes( AliHLTComponentDataTypeList& list)
      56             : {
      57             :   // overloaded from AliHLTComponent
      58           0 :   list.clear();
      59           0 :   list.push_back(kAliHLTAllDataTypes);
      60           0 : }
      61             : 
      62             : AliHLTComponentDataType AliHLTRootFileStreamerComponent::GetOutputDataType()
      63             : {
      64             :   // overloaded from AliHLTComponent
      65           0 :   return fDataType;
      66             : }
      67             : 
      68             : void AliHLTRootFileStreamerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
      69             : {
      70             :   // overloaded from AliHLTComponent
      71           0 :   constBase=500;
      72           0 :   inputMultiplier=5.0;
      73           0 : }
      74             : 
      75             : int AliHLTRootFileStreamerComponent::DoInit( int argc, const char** argv )
      76             : {
      77             :   // overloaded from AliHLTComponent: initialization
      78             : 
      79             :   int iResult=0;
      80           0 :   TString argument="";
      81             :   int bMissingParam=0;
      82           0 :   for (int i=0; i<argc && iResult>=0; i++) {
      83           0 :     argument=argv[i];
      84           0 :     if (argument.IsNull()) continue;
      85             : 
      86             :     // -datatype
      87           0 :     if (argument.CompareTo("-datatype")==0) {
      88           0 :       if ((bMissingParam=(++i>=argc))) break;
      89           0 :       memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
      90           0 :       if ((bMissingParam=(++i>=argc))) break;
      91           0 :       memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
      92             : 
      93             :       // -dataspec
      94           0 :     } else if (argument.CompareTo("-dataspec")==0) {
      95           0 :       if ((bMissingParam=(++i>=argc))) break;
      96           0 :       TString parameter(argv[i]);
      97           0 :       parameter.Remove(TString::kLeading, ' '); // remove all blanks
      98           0 :       if (parameter.IsDigit()) {
      99           0 :         fSpecification=(AliHLTUInt32_t)parameter.Atoi();
     100           0 :       } else if (parameter.BeginsWith("0x") &&
     101           0 :                  parameter.Replace(0,2,"",0).IsHex()) {
     102           0 :         sscanf(parameter.Data(),"%x", &fSpecification);
     103             :       } else {
     104           0 :         HLTError("wrong parameter for argument %s, number expected", argument.Data());
     105             :         iResult=-EINVAL;
     106             :       }
     107           0 :     } else {
     108           0 :       HLTError("unknown argument %s", argument.Data());
     109           0 :       break;
     110             :     }
     111             :   }
     112           0 :   if (bMissingParam) {
     113           0 :     HLTError("missing parameter for argument %s", argument.Data());
     114             :     iResult=-EINVAL;
     115           0 :   }
     116             :   return iResult;
     117           0 : }
     118             : 
     119             : int AliHLTRootFileStreamerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
     120             :                                             AliHLTComponentTriggerData& /*trigData*/ )
     121             : {
     122             :   // overloaded from AliHLTProcessor: event processing
     123             :   int iResult=0;
     124           0 :   AliHLTMemoryFile* pFile=CreateMemoryFile(fDataType,fSpecification);
     125           0 :   if (pFile) {
     126             :     int count=0;
     127           0 :     for (const TObject* pObj=GetFirstInputObject();
     128           0 :          pObj && iResult>=0;
     129           0 :          pObj=GetNextInputObject()) {
     130           0 :       iResult=Write(pFile, pObj);
     131           0 :       if (iResult) {
     132           0 :         count++;
     133             :         HLTDebug("wrote object of class %s, data type %s", pObj->ClassName(), (DataType2Text(GetDataType(pObj)).c_str())); 
     134           0 :       }
     135             :     }
     136           0 :     HLTInfo("wrote %d object(s) from %d input blocks to file", count, GetNumberOfInputBlocks());
     137           0 :     iResult=CloseMemoryFile(pFile);
     138           0 :   } else {
     139             :     iResult=-ENOMEM;
     140             :   }
     141           0 :   return iResult;
     142             : }

Generated by: LCOV version 1.11