]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTHOMERManager.h
Adding the new detector MFT (Antonio Uras)
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.h
index 7cc33b627548e9730433422c4fbc811756817954..f9e868b746183a6fe4ef9b9f554df0041ca86a4f 100644 (file)
@@ -1,6 +1,6 @@
 //-*- Mode: C++ -*-
 
-// $Id: AliHLTHOMERManager.h $
+// $Id$
 
 #ifndef ALIHLTHOMERMANAGER_H
 #define ALIHLTHOMERMANAGER_H
 
 /** @file   AliHLTHOMERManager.h
     @author Jochen Thaeder
-    @date
+    @author Svein Lindal <slindal@fys.uio.no>
+    @date   October 2010
     @brief  Manager for HOMER in aliroot
 */
 
 
+#include "TClonesArray.h"
 #include "TString.h"
 #include "TList.h"
 
@@ -25,7 +27,9 @@
 #include "AliHLTHOMERReader.h"
 #include "AliHLTHOMERProxyHandler.h"
 
-#include "AliHLTLogging.h"
+#include "AliHLTLoggingVariadicFree.h"
+
+#define BUFFERSIZE 15
 
 class AliHLTHOMERLibManager;
 
@@ -44,98 +48,77 @@ class AliHLTHOMERLibManager;
  * @ingroup alihlt_homer
  */
 
-class AliHLTHOMERManager : public TObject, public AliHLTLogging {
+class AliHLTHOMERManager : public AliHLTLogging 
+{
 public:
   
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Constructor / Destructor
-   * ---------------------------------------------------------------------------------
-   */
-
   /** default constructor */
   AliHLTHOMERManager();
 
   /** destructor */
   virtual ~AliHLTHOMERManager();
 
-  /** Initialize 
-   *  @return 0 on success, <0 for failure
-   */
+  /** Initialize */
   Int_t Initialize();
 
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Source Handling - public
-   * ---------------------------------------------------------------------------------
-   */
-
-  /** Create Sources List from HOMER-Proxy 
-   *  @return 0 on success, <0 for failure, 1 for no active service
-   */
+  /** Create Sources List from HOMER-Proxy */
   virtual Int_t CreateSourcesList();
 
-  /** Set state of a source 
-   *  @param source      Pointer to AliHLTHOMERSourceDesc object.
-   *  @param state       New (selected/not selected) state.
-   */
+  /** Set state of a source */
   void   SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
 
   /** Get pointer to source List */
   TList* GetSourceList() { return fSourceList; }
 
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Connection Handling - public
-   * ---------------------------------------------------------------------------------
-   */
-
-  /** Connect to HOMER sources, of a certain detector.
-   *  which gets created when state has changed 
-   *  @param detector    Detector to be connected to
-   *  @return            0 on success, <0 for failure
-   */
-  Int_t ConnectHOMER( TString detector );
+  /** Connect to HOMER sources, of a certain detector. */
+  Int_t ConnectHOMER( TString detector="ALL" );
 
   /** Disconnect from HOMER sources */
   void  DisconnectHOMER();
 
-  /** Reconnect from HOMER sources 
-   *  @param detector    Detector to be connected to
-   *  @return            0 on success, <0 for failure
-   */
+  /** Reconnect from HOMER sources */
   Int_t ReconnectHOMER( TString detector);
 
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Event Handling - public
-   * ---------------------------------------------------------------------------------
-   */
 
-  /** Loads the next Event, after being connected 
-   *  @return 0 on success, <0 for failure
-   */
+  /** Loads the next Event, after being connected */
   virtual Int_t NextEvent();
 
-  /** Loads the next Cycle, after being connected 
-   *  @return 0 on success, <0 for failure
-   */
+  /** Loads the next Cycle, after being connected */
   virtual Int_t NextCycle() { return NextEvent(); }
 
   /** Get event ID */
-  ULong_t GetEventID() { return fEventID; }    // Get event ID
+  ULong_t GetEventID() { return fEventId; }
 
-  /** Get pointer to block List */
-  TList* GetBlockList() { return fBlockList; } // Get pointer to block List
+  Int_t GetNAvailableEvents() { return fNEventsAvailable;}
   
-  ///////////////////////////////////////////////////////////////////////////////////
+  /** Get pointer to last requested BlockList */
+  TList* GetBlockList() { return fBlockList; }
+  TList* GetAsyncBlockList() { return fAsyncBlockList; }
+
+  /** Navigate backwards in event buffer */
+  Int_t  NavigateEventBufferBack();
+
+  /** Navigate forwards in event buffer */
+  Int_t  NavigateEventBufferFwd();
+
+  /** Set and get the string used to select triggers */
+  void SetTriggerString ( TString triggerString ) { fTriggerString = triggerString; }
+
+  /** Get TriggerString */
+  TString GetTriggerString () { return fTriggerString; }
+
+  void SetBlockOwner(Bool_t owner) { fBlockList->SetOwner(owner); }
+  Bool_t GetBlockOwner() const { return fBlockList->IsOwner(); }
 
 protected:
 
   /** Dynamic loader manager for the HOMER library */
   AliHLTHOMERLibManager* fLibManager;             //! transient
 
-  ///////////////////////////////////////////////////////////////////////////////////
+  /** Indicates, if a sources have changes,  so that one has to reconnect. */
+  Bool_t    fStateHasChanged;                     //  see above
+
+  Bool_t Connected() const { return fConnected; }
 
 private:
 
@@ -145,47 +128,38 @@ private:
   /** assignment operator prohibited */
   AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
 
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Connection Handling - private
-   * ---------------------------------------------------------------------------------
-   */
-
-  /** Create a readout list for Hostname and ports 
-   *  @param socurceHostnames   Array of selected hostnames
-   *  @param socurcePorts       Array of selected ports
-   *  @param socurceCount       Number of selected hostname:port
-   *  @param detector           detector to be selected
-   */
+  //==============Connection to homer ==========================
+
+  /** Create a readout list for Hostname and ports */
   void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
                          UInt_t &sourceCount, TString detector );
 
   /** Checks if already connected to HOMER sources */
   Bool_t IsConnected() { return fConnected; }  
-  
-  /* ---------------------------------------------------------------------------------
-   *                            Event Handling - private
-   * ---------------------------------------------------------------------------------
-   */
 
-  /** Create a TList of blocks, which have been readout */
-  void CreateBlockList();
+  /** Create and add Block List to Buffer */
+  void AddBlockListToBuffer();
 
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Block Handling - private
-   * ---------------------------------------------------------------------------------
-   */
+  /** Add bocks to asynchronous BlockList */
+  void AddToAsyncBlockList();
+  void AddToBlockList();
 
+
+  //============ Block Handling ====================
+
+  /** Get pointer to block list in event buffer */
+  TList* GetBlockListEventBuffer( );
+    
   /** Get Number of blocks in current event */
   ULong_t GetNBlks() { return fNBlks; }
 
-  // ----------------------------------------------------
+  /** Handle Blocks and fill them in event buffer or asyncronous BlockList */
+  Int_t HandleBlocks();
 
-  /** Get pointer to block ndx in current event 
-   *  @param ndx        Block index
-   *  @return           returns pointer to blk, NULL if no block present
-   */
+  /** Check is block are from syncronous source */
+  Bool_t IsSyncBlocks();
+
+  /** Get pointer to block ndx in current event */
   void* GetBlk( Int_t ndx );
 
   /** Get pointer to current block in current event */
@@ -197,102 +171,66 @@ private:
   /** Get next block in current event */
   void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
 
-  // ----------------------------------------------------
-
-  /** Get size of block ndx 
-   *  @param ndx        Block index
-   *  @return           returns size blk, 0 otherwise
-   */
+  /** Get size of block ndx */
   ULong_t GetBlkSize( Int_t ndx );
 
   /** Get size of current block */ 
   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
 
-  // ---------------------------------------------------- 
-
-  /** Get origin of block ndx 
-   *  @param ndx        Block index
-   *  @return           origin of block
-   */
+  /** Get origin of block ndx  */
   TString GetBlkOrigin( Int_t ndx );
 
   /** Get origin of current block */
   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
 
-  // ----------------------------------------------------
-
-  /** Get type of block ndx 
-   *  @param ndx        Block index
-   *  @return           type of block
-   */
+  /** Get type of block ndx */
   TString GetBlkType( Int_t ndx ); 
 
   /** Get type of current block */
   TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
   
-  // ----------------------------------------------------
-  
-  /** Get specification of block ndx 
-   *  @param ndx        Block index
-   *  @return           specification of block
-   */
+  //Get specification of block at ndx in bufferindex
   ULong_t GetBlkSpecification( Int_t ndx );
 
   /** Get specification of current block */
   ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
 
-  // ----------------------------------------------------
-
-  /** Checks if current Block should was requested 
-   *  @return           returns kTRUE, if block should was requested
-   */
+  //Check if requested in eve
   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
-
-  /*
-   * ---------------------------------------------------------------------------------
-   *                            Members - private
-   * ---------------------------------------------------------------------------------
-   */
-
-  /** Proxy Handler to get the list of sources */
-  AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
-
-  // == connection ==
-
-  /** Pointer to HOMER reader */
-  AliHLTHOMERReader* fReader;                        //! transient 
+    
+  //Check trigger decision
+  Bool_t CheckTriggerDecision();
+  
+  AliHLTHOMERProxyHandler * fProxyHandler;  /** Proxy Handler to get the list of sources */  //! transient 
+  AliHLTHOMERReader* fCurrentReader;   /** Pointer to current HOMER reader */ //! transient 
+  TList* fReaderList;                 /** List to pointer of HOMER readers */
 
   // == sources ==
-
-  /** List to HOMER sources */
-  TList    *fSourceList;                             //! transient
+  TList* fSourceList;                /** List to HOMER sources */
+  ULong_t fNBlks;                    /** Number of blockes in current event */
+  ULong64_t fEventID[BUFFERSIZE];    /** EventID of current event */
+  ULong64_t fEventId;
+  ULong_t fCurrentBlk;               /** Current block in current event */
+  TList* fAsyncBlockList;            /** List containing asychronous blocks */
+  TList* fBlockList;            /** List containing asychronous blocks */
+
+  // == event buffer ==
+  TClonesArray     * fEventBuffer;  /** Event Buffer */
+  Int_t  fBufferTopIdx;             /** Buffer index to last received event */
+  Int_t  fBufferLowIdx;             /** Buffer index to last received event */
+  Int_t  fCurrentBufferIdx;         /** Buffer index to current event */
+  Int_t  fNavigateBufferIdx;        //  Navigate index through event buffer */
+  Int_t  fNEventsAvailable;         //Number of available events
   
-  // == blocks ==
-
-  /** List to HOMER blocks */
-  TList    *fBlockList;                              //! transient
-
-  // == events ==
-
-  /** Number of blockes in current event */
-  ULong_t   fNBlks;                                  //  see above
-
-  /** EventID of current event */
-  ULong64_t fEventID;                                //  see above
-
-  /** Current block in current event */
-  ULong_t   fCurrentBlk;                             //  see above
-
-  // == states ==
+  Bool_t fConnected;                /** Shows connection status */
+  TString fTriggerString;           /** String indicating which trigger should be used to select events */
+  Int_t  fNEventsNotTriggered;      /** Number Events not triggered, before next triggered event is found */
   
-  /** Shows connection status */
-  Bool_t    fConnected;                              //  see above
+  Bool_t fRetryNextEvent;           /** Retry reading next event */
 
-  /** Indicates, if a sources have changes, 
-   *  so that one has to reconnect. */
-  Bool_t    fStateHasChanged;                        //  see above
+  Bool_t fIsBlockOwner;
 
-  ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
+  ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources.
 };
 
 #endif