]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/util/AliHLTFilePublisher.cxx
correct compilation warnings
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTFilePublisher.cxx
index 38ae8e4e449fbaa901d8df00fe6dc5c59fd4f821..1894c1ef989f60fb436677ff8b8f27d2ece99470 100644 (file)
     @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>
 
@@ -41,7 +47,9 @@ AliHLTFilePublisher::AliHLTFilePublisher()
   fpCurrent(NULL),
   fEvents(),
   fMaxSize(0),
-  fOpenFilesAtStart(false)
+  fOpenFilesAtStart(false),
+  fOutputDataTypes(),
+  fIsRaw(kTRUE)
 {
   // see header file for class documentation
   // or
@@ -71,7 +79,17 @@ const char* AliHLTFilePublisher::GetComponentID()
 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 )
@@ -111,7 +129,7 @@ int AliHLTFilePublisher::DoInit( int argc, const char** argv )
       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 {
@@ -125,10 +143,17 @@ int AliHLTFilePublisher::DoInit( int argc, const char** argv )
 
       // -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
@@ -301,9 +326,15 @@ int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& /*evtData*/,
                                   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();
@@ -322,7 +353,7 @@ int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& /*evtData*/,
        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;
@@ -336,6 +367,10 @@ int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& /*evtData*/,
              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
@@ -372,9 +407,10 @@ int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& /*evtData*/,
 //   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),
@@ -415,7 +451,12 @@ 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) {