]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
make component suitible for child overloads for specific detector implementations...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Feb 2012 20:36:47 +0000 (20:36 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Feb 2012 20:36:47 +0000 (20:36 +0000)
HLT/BASE/util/AliHLTRawReaderPublisherComponent.cxx
HLT/BASE/util/AliHLTRawReaderPublisherComponent.h

index 8ae7a1e196a84b2e43da66badc393adbc3f56820..70fc3b6d7e0ef37fc67bf37381120f6bbe81b0bb 100644 (file)
@@ -1,11 +1,10 @@
 // $Id$
 
 ///**************************************************************************
-///* This file is property of and copyright by the ALICE HLT Project        * 
+///* This file is property of and copyright by the                          * 
 ///* ALICE Experiment at CERN, All rights reserved.                         *
 ///*                                                                        *
 ///* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
-///*                  for The ALICE HLT Project.                            *
 ///*                                                                        *
 ///* Permission to use, copy, modify and distribute this software and its   *
 ///* documentation strictly for non-commercial purposes is hereby granted   *
 /// @file   AliHLTRawReaderPublisherComponent.cxx
 /// @author Matthias Richter
 /// @date   
-/// @brief  A general tree publisher component for the AliRawReader.
-///
-
-// see header file for class documentation
-// or
-// refer to README to build package
-// or
-// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+/// @brief  Publisher component for raw data blocks through the AliRawReader
+///         of the offline environment
 
 #include "AliHLTRawReaderPublisherComponent.h"
 #include "AliRawReader.h"
@@ -50,59 +43,105 @@ AliHLTRawReaderPublisherComponent::AliHLTRawReaderPublisherComponent()
   fSpecification(kAliHLTVoidDataSpec),
   fSkipEmpty(kFALSE)
 {
-  // see header file for class documentation
-  // or
-  // refer to README to build package
-  // or
-  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  // contructor
 }
 
 AliHLTRawReaderPublisherComponent::~AliHLTRawReaderPublisherComponent()
 {
-  // see header file for class documentation
+  // destructor
 }
 
 const char* AliHLTRawReaderPublisherComponent::GetComponentID()
 {
-  // see header file for class documentation
+  /// inherited from AliHLTComponent: id of the component
   return "AliRawReaderPublisher";
 }
 
 AliHLTComponentDataType AliHLTRawReaderPublisherComponent::GetOutputDataType()
 {
-  // see header file for class documentation
+  /// inherited from AliHLTComponent: output data type of the component.
   return fDataType;
 }
 
 void AliHLTRawReaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
 {
-  // see header file for class documentation
+  /// inherited from AliHLTComponent: output data size estimator
   constBase=fMaxSize;
   inputMultiplier=1;
 }
 
 AliHLTComponent* AliHLTRawReaderPublisherComponent::Spawn()
 {
-  // see header file for class documentation
+  /// inherited from AliHLTComponent: spawn function.
   return new AliHLTRawReaderPublisherComponent;
 }
 
 int AliHLTRawReaderPublisherComponent::DoInit( int argc, const char** argv )
 {
-  // see header file for class documentation
+  /// inherited from AliHLTComponent: component initialisation and argument scan.
   int iResult=0;
 
   // scan arguments
-  TString argument="";
+  if (argc && (iResult = ConfigureFromArgumentString(argc, argv)) < 0)
+    return iResult;
+
+  if (!fDetector.IsNull()) {
+    int ddloffset=-1;
+    int ddlcount=-1;
+    if ((ddloffset=AliDAQ::DdlIDOffset(fDetector))<0 || 
+       (ddlcount=AliDAQ::NumberOfDdls(fDetector))<0) {
+      return -EINVAL;
+    }
+    if (fMinEquId<0) fMinEquId=ddloffset;
+    else fMinEquId+=ddloffset;
+
+    if (fMaxEquId<0 || fMaxEquId>ddlcount) fMaxEquId=ddloffset+ddlcount;
+    else fMaxEquId+=ddloffset;
+  }
+
+  if (fMinEquId>fMaxEquId) fMaxEquId=fMinEquId;
+
+  if (fMinEquId<0) {
+    AliErrorStream() << "equipment id required, use \'-equipmentid\' or \'-detector\' option" << endl;
+    return -EINVAL;
+  }
+
+  AliHLTUInt32_t dummy;
+  if (fMinEquId!=fMaxEquId && GetSpecificationFromEquipmentId(0, dummy)==-ENOSYS) {
+    AliWarningStream() << "publication of multiple equipment ids needs implementation of a child and function GetSpecificationFromEquipmentId to set correct specifications" << endl;
+    //return -EINVAL;
+  }
+
+  if (GetRawReader()!=NULL) {
+  } else {
+    AliErrorStream() << "RawReader instance needed" << endl;
+    return -EINVAL;
+  }
+
+  return iResult;
+}
+
+int AliHLTRawReaderPublisherComponent::DoDeinit()
+{
+  /// inherited from AliHLTComponent: component cleanup
+  int iResult=0;
+  return iResult;
+}
+
+int AliHLTRawReaderPublisherComponent::ScanConfigurationArgument(int argc, const char** argv)
+{
+  /// inherited from AliHLTComponent: argument scan
+  if (argc<1) return 0;
   int bMissingParam=0;
-  for (int i=0; i<argc && iResult>=0; i++) {
-    argument=argv[i];
-    if (argument.IsNull()) continue;
+  int i=0;
+  TString argument=argv[i];
 
+  do {
     // -detector
     if (argument.CompareTo("-detector")==0) {
       if ((bMissingParam=(++i>=argc))) break;
       fDetector=argv[i];
+      return 2;
 
       // -equipmentid, -minid
     } else if (argument.CompareTo("-equipmentid")==0 ||
@@ -112,9 +151,10 @@ int AliHLTRawReaderPublisherComponent::DoInit( int argc, const char** argv )
       parameter.Remove(TString::kLeading, ' '); // remove all blanks
       if (parameter.IsDigit()) {
        fMinEquId=(AliHLTUInt32_t)parameter.Atoi();
+       return 2;
       } else {
        HLTError("wrong parameter for argument %s, number expected", argument.Data());
-       iResult=-EINVAL;
+       return -EINVAL;
       }
 
       // -maxid
@@ -124,22 +164,26 @@ int AliHLTRawReaderPublisherComponent::DoInit( int argc, const char** argv )
       parameter.Remove(TString::kLeading, ' '); // remove all blanks
       if (parameter.IsDigit()) {
        fMaxEquId=(AliHLTUInt32_t)parameter.Atoi();
+       return 2;
       } else {
        HLTError("wrong parameter for argument %s, number expected", argument.Data());
-       iResult=-EINVAL;
+       return -EINVAL;
       }
 
       // -verbose
     } else if (argument.CompareTo("-verbose")==0) {
       fVerbosity++;
+      return 1;
 
       // -silent
     } else if (argument.CompareTo("-silent")==0) {
       fVerbosity=0;
+      return 1;
 
       // -skipempty
     } else if (argument.CompareTo("-skipempty")==0) {
       fSkipEmpty=kTRUE;
+      return 1;
 
       // -datatype
     } else if (argument.CompareTo("-datatype")==0) {
@@ -147,6 +191,7 @@ int AliHLTRawReaderPublisherComponent::DoInit( int argc, const char** argv )
       memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
       if ((bMissingParam=(++i>=argc))) break;
       memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
+      return 3;
 
       // -dataspec
     } else if (argument.CompareTo("-dataspec")==0) {
@@ -160,61 +205,17 @@ int AliHLTRawReaderPublisherComponent::DoInit( int argc, const char** argv )
        sscanf(parameter.Data(),"%x", &fSpecification);
       } else {
        HLTError("wrong parameter for argument %s, number expected", argument.Data());
-       iResult=-EINVAL;
+       return -EINVAL;
       }
-    } else {
-      HLTError("unknown argument %s", argument.Data());
-      iResult=-EINVAL;
+      return 2;
     }
-  }
+  } while (0); // using do-while only to have break available
   if (bMissingParam) {
     HLTError("missing parameter for argument %s", argument.Data());
-    iResult=-EINVAL;
-  }
-
-  if (iResult<0) return iResult;
-
-  if (!fDetector.IsNull()) {
-    int ddloffset=-1;
-    int ddlcount=-1;
-    if ((ddloffset=AliDAQ::DdlIDOffset(fDetector))<0 || 
-       (ddlcount=AliDAQ::NumberOfDdls(fDetector))<0) {
-      return -EINVAL;
-    }
-    if (fMinEquId<0) fMinEquId=ddloffset;
-    else fMinEquId+=ddloffset;
-
-    if (fMaxEquId<0 || fMaxEquId>ddlcount) fMaxEquId=ddloffset+ddlcount;
-    else fMaxEquId+=ddloffset;
-  }
-
-  if (fMinEquId>fMaxEquId) fMaxEquId=fMinEquId;
-
-  if (fMinEquId<0) {
-    AliErrorStream() << "equipment id required, use \'-equipmentid\' or \'-detector\' option" << endl;
     return -EINVAL;
   }
 
-  AliHLTUInt32_t dummy;
-  if (fMinEquId!=fMaxEquId && GetSpecificationFromEquipmentId(0, dummy)==-ENOSYS) {
-    AliWarningStream() << "publication of multiple equipment ids needs implementation of a child and function GetSpecificationFromEquipmentId to set correct specifications" << endl;
-    //return -EINVAL;
-  }
-
-  if (GetRawReader()!=NULL) {
-  } else {
-    AliErrorStream() << "RawReader instance needed" << endl;
-    return -EINVAL;
-  }
-
-  return iResult;
-}
-
-int AliHLTRawReaderPublisherComponent::DoDeinit()
-{
-  // see header file for class documentation
-  int iResult=0;
-  return iResult;
+  return -EPROTO;
 }
 
 int AliHLTRawReaderPublisherComponent::GetEvent(const AliHLTComponentEventData& /*evtData*/, 
@@ -223,7 +224,7 @@ int AliHLTRawReaderPublisherComponent::GetEvent(const AliHLTComponentEventData&
                                                AliHLTUInt32_t& size, 
                                                vector<AliHLTComponentBlockData>& outputBlocks)
 {
-  // see header file for class documentation
+  /// inherited from AliHLTDataSource: get the event
   int iResult=0;
   AliHLTUInt32_t capacity=size;
   size=0;
@@ -251,17 +252,18 @@ int AliHLTRawReaderPublisherComponent::GetEvent(const AliHLTComponentEventData&
       }
       unsigned int readSize=pRawReader->GetDataSize()+sizeof(AliRawDataHeader);
       int id=pRawReader->GetEquipmentId();
-      if (fVerbosity>0) {
-       AliInfo(Form("got header for id %d, size %d", id, readSize));
-      } else {
-       AliDebug(0, Form("got header for id %d, size %d", id, readSize));
-      }
       if (fMinEquId>id || fMaxEquId<id) {
        AliError(Form("id %d returned from RawReader is outside range [%d,%d]", id, fMinEquId, fMaxEquId));
        continue;
       }
       processedIds.push_back(id);
-      if (!IsSelected(id)) continue;
+      bool isSelected=IsSelected(id);
+      if (fVerbosity>0) {
+       AliInfo(Form("got header for id %d, size %d, %s", id, readSize, isSelected?"selected":"discarded"));
+      } else {
+       AliDebug(0, Form("got header for id %d, size %d", id, readSize));
+      }
+      if (!isSelected) continue;
       if (readSize+offset<=capacity) {
        memcpy(outputPtr+offset, pHeader, sizeof(AliRawDataHeader));
        if (readSize>sizeof(AliRawDataHeader)) {
@@ -340,6 +342,7 @@ int AliHLTRawReaderPublisherComponent::GetEvent(const AliHLTComponentEventData&
 }
 
 int AliHLTRawReaderPublisherComponent::GetSpecificationFromEquipmentId(int id, AliHLTUInt32_t& specification) const {
-  // see header file for class documentation
+  /// get the data specification from the equipment id
+  /// default method just returns the equipment id
   return specification=id;
 }
index 416005943f70d0e3d65c5168cd28bef82b4467e7..f85dbb72e80dd1a225196e536b9d21b67108e70f 100644 (file)
@@ -3,7 +3,7 @@
 
 #ifndef ALIHLTRAWREADERPUBLISHERCOMPONENT_H
 #define ALIHLTRAWREADERPUBLISHERCOMPONENT_H
-//* This file is property of and copyright by the ALICE HLT Project        * 
+//* This file is property of and copyright by the                          * 
 //* ALICE Experiment at CERN, All rights reserved.                         *
 //* See cxx source for full Copyright notice                               *
 
@@ -126,16 +126,15 @@ class AliHLTRawReaderPublisherComponent : public AliHLTOfflineDataSource {
   virtual AliHLTComponent* Spawn();
 
  protected:
-  /**
-   * Init method.
-   */
+  /// inherited from AliHLTComponent: component initialisation and argument scan.
   int DoInit( int argc, const char** argv );
 
-  /**
-   * Deinit method.
-   */
+  /// inherited from AliHLTComponent: component cleanup
   int DoDeinit();
 
+  /// inherited from AliHLTComponent: scan configuration argument
+  int ScanConfigurationArgument(int argc, const char** argv);
+
   /**
    * Data source method.
    * @param [in] evtData       event data structure
@@ -154,20 +153,26 @@ class AliHLTRawReaderPublisherComponent : public AliHLTOfflineDataSource {
 
   using AliHLTOfflineDataSource::GetEvent;
 
+  /// check if block is selected for publishing
+  /// default method returns true, childs can overload to discard blocks
   virtual bool IsSelected(int /*equipmentId*/) const {return true;}
 
+  int GetVerbosity() const {return fVerbosity;}
+
  protected:
+  /// get the data specification from the equipment id
+  /// default method just returns the equipment id
   virtual int GetSpecificationFromEquipmentId(int id, AliHLTUInt32_t &specification) const;
 
+  /** max output block size, estimated during DoInit */
+  Int_t                   fMaxSize;                                //!transient
+
  private:
   /** copy constructor prohibited */
   AliHLTRawReaderPublisherComponent(const AliHLTRawReaderPublisherComponent&);
   /** assignment operator prohibited */
   AliHLTRawReaderPublisherComponent& operator=(const AliHLTRawReaderPublisherComponent&);
 
-  /** max output block size, estimated during DoInit */
-  Int_t                   fMaxSize;                                //!transient
-
   /** detector string */
   TString                 fDetector;                               //!transient
 
@@ -189,7 +194,7 @@ class AliHLTRawReaderPublisherComponent : public AliHLTOfflineDataSource {
   /** skip the generation of empty data blocks */
   Bool_t                  fSkipEmpty;                              //!transient
 
-  ClassDef(AliHLTRawReaderPublisherComponent, 1);
+  ClassDef(AliHLTRawReaderPublisherComponent, 0);
 };
 
 #endif