// $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"
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 ||
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
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) {
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) {
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*/,
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;
}
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)) {
}
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;
}
#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 *
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
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
/** skip the generation of empty data blocks */
Bool_t fSkipEmpty; //!transient
- ClassDef(AliHLTRawReaderPublisherComponent, 1);
+ ClassDef(AliHLTRawReaderPublisherComponent, 0);
};
#endif