]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/util/AliHLTFilePublisher.h
* AliHLTRootFilePublisher
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTFilePublisher.h
index 36d00bfe2c82e0ca93cde3fe77c66cfedd68cf99..a0e02a7d4174acca5a3e7ad95a9586d6186df03c 100644 (file)
@@ -3,9 +3,9 @@
 
 #ifndef ALIHLTFILEPUBLISHER_H
 #define ALIHLTFILEPUBLISHER_H
-/* This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- * See cxx source for full Copyright notice                               */
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//* See cxx source for full Copyright notice                               *
 
 /** @file   AliHLTFilePublisher.h
     @author Matthias Richter
 */
 
 #include "AliHLTDataSource.h"
-#include <TFile.h>
 #include <TList.h>
+class TFile;
 
 /**
  * @class AliHLTFilePublisher
  * An HLT data source component which publishes data from one or a sequence
  * of files.<br>
  *
+ * <h2>General properties:</h2>
+ *
  * Component ID: \b FilePublisher <br>
- * Library: \b libAliHLTUtil.
+ * Library: \b libAliHLTUtil.so     <br>
+ * Input Data Types: none <br>
+ * Output Data Types: according to arguments <br>
  *
- * Mandatory arguments: <br>
- * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
+ * <h2>Mandatory arguments:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
  * \li -datafile     <i> filename      </i>
  * \li -datafilelist <i> file pattern  </i> <br>
  *      not yet implemented
  * \li -nextevent
  *      indicate files published by the next event
  *
- * Optional arguments:<br>
+ * <h2>Optional arguments:</h2>
+ * \li -open_files_at_start
+ *      Opens all files during component initialisation rather than as needed
+ *      during event processing. Note: this feature may result in the system
+ *      running out of file handles if a large number of files was specified.
+ *
+ * <h2>Configuration:</h2>
+ * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
+ * Configuration by component arguments.
+ *
+ * <h2>Default CDB entries:</h2>
+ * The component loads no CDB entries.
+ *
+ * <h2>Performance:</h2>
+ * The component does not process any event data.
+ *
+ * <h2>Memory consumption:</h2>
+ * The component does not process any event data.
+ *
+ * <h2>Output size:</h2>
+ * According to the available data. The component is an AliHLTDataSource
+ * and inteded to be used in the AliHLTSystem framework only. The component
+ * implements the standard AliHLTSystem adaptive buffer allocation. 
  *
  * The component needs at least one argument \em -datafile or \em -datafilelist.
  * Both can occur multiple times. The \em -datatype and \em -dataspec
@@ -47,7 +73,8 @@
  * \em -datatype/spec.
  * All files er published within one event, unless the \em -nexevent specifies
  * where to break into multiple events.
- * @ingroup alihlt_component
+ *
+ * @ingroup alihlt_util_components
  */
 class AliHLTFilePublisher : public AliHLTDataSource  {
  public:
@@ -58,15 +85,27 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
 
   const char* GetComponentID();
   AliHLTComponentDataType GetOutputDataType();
+  int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
   AliHLTComponent* Spawn();
 
   /**
    * Open all files.
    * Opens all files for all events from the event list @ref fEvents and adds TFile
-   * opjects to the internal list.
+   * objects to the internal list. It also calculates the maximum event size required.
+   * @param keepOpen  If this flag is true then the files are kept open, otherwise
+   *                  this method will close the files afterwards.
+   */
+  int OpenFiles(bool keepOpen);
+
+  /** Get List of Events, needed in the RootFilePublisher.*/
+  TList* GetEventList() { return &fEvents;} 
+  
+  /** Set if root files instead of raw files should be read,
+   *  needed in the RootFilePublisher.
+   *  @param isRaw  kTRUE if raw file, kFALSE for rootfile
    */
-  int OpenFiles();
+  void SetIsRawFile( Bool_t isRaw ) { fIsRaw = isRaw; }
 
  protected:
   /**
@@ -93,7 +132,9 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
                        AliHLTComponentTriggerData& trigData,
                        AliHLTUInt8_t* outputPtr, 
                        AliHLTUInt32_t& size,
-                       vector<AliHLTComponentBlockData>& outputBlocks );
+                       AliHLTComponentBlockDataList& outputBlocks );
+
+  using AliHLTDataSource::GetEvent;
 
   /**
    * Scan one argument and adjacent parameters.
@@ -108,7 +149,6 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
    */
   virtual int ScanArgument(int argc, const char** argv);
 
- protected:
   /**
    * Get the data type which is set for the current file
    */
@@ -125,6 +165,7 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
   /** prohibit assignment operator */
   AliHLTFilePublisher& operator=(const AliHLTFilePublisher&);
 
+ protected:
   /**
    * File descriptor.
    */
@@ -133,7 +174,7 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
     /** constructor not implemented */
     FileDesc();
     /** constructor to use */
-    FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec);
+    FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec, Bool_t isRaw=kTRUE);
     /** destructor */
     ~FileDesc();
 
@@ -143,10 +184,15 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
      */
     int OpenFile();
 
+    /**
+     * Close the file handle.
+     */
+    void CloseFile();
+
     /**
      * Get name of the file.
      */
-    const char* GetName() {return fName.Data();}
+    const char* GetName() const {return fName.Data();}
 
     /**
      * Set data type.
@@ -160,8 +206,8 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
 
     // implicite type conversions
     operator TFile*() const   {return fpInstance;}
-    operator AliHLTComponentDataType() {return fDataType;}
-    operator AliHLTUInt32_t() {return fSpecification;}
+    operator AliHLTComponentDataType() const {return fDataType;}
+    operator AliHLTUInt32_t() const {return fSpecification;}
 
   private:
     /** prohibited copy constructor */
@@ -169,6 +215,8 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
     /** prohibited copy operator */
     FileDesc& operator=(FileDesc&);
 
+    /** is raw (kTRUE) or root (kFALSE) file */
+    Bool_t fIsRaw;                                                 //! transient     
     /** file name */
     TString                 fName;                                 //! transient
     /** file instance */
@@ -228,8 +276,17 @@ class AliHLTFilePublisher : public AliHLTDataSource  {
   TList fEvents;                                                   //! transient
 
   /** the maximum buffer size i.e. size of the biggest file */
-  Int_t                   fMaxSize;                                //! transient
+  Int_t fMaxSize;                                                  //! transient
+  
+  /** Flag specifying if all the files should be opened during initialisation.  */
+  bool fOpenFilesAtStart;                                          //! transient
+
+  /** output data types  */
+  AliHLTComponentDataTypeList fOutputDataTypes;                    //! transient
+
+  /** Is raw file (kTRUE) [default] or root file (kFALSE). */
+  Bool_t fIsRaw;                                                   //! transient     
 
-  ClassDef(AliHLTFilePublisher, 1)
+  ClassDef(AliHLTFilePublisher, 3)
 };
 #endif