@date
@brief HLT file publisher component implementation. */
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
#if __GNUC__>= 3
using namespace std;
#endif
#include "AliHLTFilePublisher.h"
#include "AliLog.h"
-#include <TObjString.h>
+//#include <TObjString.h>
#include <TMath.h>
#include <TFile.h>
-/** the global object for component registration */
-AliHLTFilePublisher gAliHLTFilePublisher;
/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTFilePublisher)
fpCurrent(NULL),
fEvents(),
fMaxSize(0),
- fOpenFilesAtStart(false)
+ fOpenFilesAtStart(false),
+ fOutputDataTypes(),
+ fIsRaw(kTRUE)
{
// see header file for class documentation
// or
AliHLTComponentDataType AliHLTFilePublisher::GetOutputDataType()
{
// see header file for class documentation
- return kAliHLTVoidDataType;
+ if (fOutputDataTypes.size()==0) return kAliHLTVoidDataType;
+ else if (fOutputDataTypes.size()==1) return fOutputDataTypes[0];
+ return kAliHLTMultipleDataType;
+}
+
+int AliHLTFilePublisher::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
+{
+ // see header file for class documentation
+ tgtList.assign(fOutputDataTypes.begin(), fOutputDataTypes.end());
+ HLTInfo("%s %p provides %d output data types", GetComponentID(), this, fOutputDataTypes.size());
+ return fOutputDataTypes.size();
}
void AliHLTFilePublisher::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
if (!bHaveDatatype) {
HLTWarning("no data type available so far, please set data type and specification before the file name. The first available data type will be set for all files preceding it");
}
- FileDesc* pDesc=new FileDesc(argv[i], currDataType, currSpecification);
+ FileDesc* pDesc=new FileDesc(argv[i], currDataType, currSpecification, fIsRaw);
if (pDesc) {
iResult=InsertFile(pCurrEvent, pDesc);
} else {
// -datatype
} else if (argument.CompareTo("-datatype")==0) {
+ currDataType=kAliHLTVoidDataType;
if ((bMissingParam=(++i>=argc))) break;
memcpy(&currDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i])));
if ((bMissingParam=(++i>=argc))) break;
memcpy(&currDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i])));
+
+ // add all different data types to the list
+ AliHLTComponentDataTypeList::iterator element=fOutputDataTypes.begin();
+ while (element!=fOutputDataTypes.end() && *element!=currDataType) element++;
+ if (element==fOutputDataTypes.end()) fOutputDataTypes.push_back(currDataType);
+
if (bHaveDatatype==0 && pCurrEvent && iResult>=0) {
// this is a workaround to make old tutorials working which contain
// the arguments in the wrong sequence
int AliHLTFilePublisher::InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc)
{
+ // see header file for class documentation
int iResult=0;
if (pDesc) {
if (pCurrEvent==NULL) {
int AliHLTFilePublisher::InsertEvent(EventFiles* &pEvent)
{
+ // see header file for class documentation
int iResult=0;
if (pEvent) {
HLTDebug("Inserted event %p", pEvent);
AliHLTComponentTriggerData& /*trigData*/,
AliHLTUInt8_t* outputPtr,
AliHLTUInt32_t& size,
- vector<AliHLTComponentBlockData>& outputBlocks )
+ AliHLTComponentBlockDataList& outputBlocks )
{
+ // see header file for class documentation
+
+ // process data events only
+ if (!IsDataEvent()) return 0;
+ AliHLTUInt32_t capacity=size;
+ size=0;
+
int iResult=0;
TObjLink *lnk=fpCurrent;
if (lnk==NULL) lnk=fEvents.FirstLink();
if (pFileDesc && (pFile=*pFileDesc)!=NULL) {
int iCopy=pFile->GetSize();
pFile->Seek(0);
- if (iCopy+iTotalSize<=(int)size) {
+ if (iCopy+iTotalSize<=(int)capacity) {
if (pFile->ReadBuffer((char*)outputPtr+iTotalSize, iCopy)!=0) {
// ReadBuffer returns 1 in case of failure and 0 in case of success
iResult=-EIO;
bd.fSpecification=*pFileDesc; // type conversion operator defined
outputBlocks.push_back(bd);
iTotalSize+=iCopy;
+// TString msg;
+// msg.Form("get file %s ", pFile->GetName());
+// msg+="data type \'%s\'";
+// PrintDataTypeContent(bd.fDataType, msg.Data());
}
} else {
// output buffer too small, update GetOutputDataSize for the second trial
// return 0;
// }
-AliHLTFilePublisher::FileDesc::FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec)
+AliHLTFilePublisher::FileDesc::FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec, Bool_t isRaw)
:
TObject(),
+ fIsRaw(isRaw),
fName(name),
fpInstance(NULL),
fDataType(dt),
fSpecification(spec)
{
+ // see header file for class documentation
+ // or
+ // refer to README to build package
+ // or
+ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
}
AliHLTFilePublisher::FileDesc::~FileDesc()
{
+ // see header file for class documentation
CloseFile();
}
void AliHLTFilePublisher::FileDesc::CloseFile()
{
+ // see header file for class documentation
if (fpInstance)
{
// Unfortunately had to use AliLog mechanisms rather that AliHLTLogging because
int AliHLTFilePublisher::FileDesc::OpenFile()
{
+ // see header file for class documentation
int iResult=0;
- TString fullFN= fName + "?filetype=raw";
+
+ TString fullFN="";
+
+ if ( fIsRaw ) fullFN = fName + "?filetype=raw";
+ else fullFN = fName;
+
fpInstance = new TFile(fullFN);
if (fpInstance) {
if (fpInstance->IsZombie()==0) {