5 #ifndef ALIHLTHOMERMANAGER_H
6 #define ALIHLTHOMERMANAGER_H
8 /* This file is property of and copyright by the ALICE HLT Project *
9 * ALICE Experiment at CERN, All rights reserved. *
10 * See cxx source for full Copyright notice
13 /** @file AliHLTHOMERManager.h
14 @author Jochen Thaeder
15 @author Svein Lindal <slindal@fys.uio.no>
17 @brief Manager for HOMER in aliroot
21 #include "TClonesArray.h"
25 #include "AliHLTHOMERSourceDesc.h"
26 #include "AliHLTHOMERBlockDesc.h"
27 #include "AliHLTHOMERReader.h"
28 #include "AliHLTHOMERProxyHandler.h"
30 #include "AliHLTLoggingVariadicFree.h"
34 class AliHLTHOMERLibManager;
37 * @class AliHLTHOMERManager
38 * This Class should handle the communication
39 * from the HLT to aliroot. The HLT sends data via
40 * the HOMER interface on several TCP ports of nodes
41 * in the CERN GPN and DCS network.
42 * All this communication is hidden from the user.
44 * Right now, a xml file ( SCC1 ) is used to get the
45 * configuration, this will/ has to change to a proxy
46 * running on dedicated nodes.
48 * @ingroup alihlt_homer
51 class AliHLTHOMERManager : public AliHLTLogging
55 /** default constructor */
59 virtual ~AliHLTHOMERManager();
64 /** Create Sources List from HOMER-Proxy */
65 virtual Int_t CreateSourcesList();
67 /** Set state of a source */
68 void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
70 /** Get pointer to source List */
71 TList* GetSourceList() { return fSourceList; }
73 /** Connect to HOMER sources, of a certain detector. */
74 Int_t ConnectHOMER( TString detector="ALL" );
76 /** Disconnect from HOMER sources */
77 void DisconnectHOMER();
79 /** Reconnect from HOMER sources */
80 Int_t ReconnectHOMER( TString detector);
83 /** Loads the next Event, after being connected */
84 virtual Int_t NextEvent();
86 /** Loads the next Cycle, after being connected */
87 virtual Int_t NextCycle() { return NextEvent(); }
90 ULong_t GetEventID() { return fEventId; }
92 Int_t GetNAvailableEvents() { return fNEventsAvailable;}
94 /** Get pointer to last requested BlockList */
95 TList* GetBlockList() { return fBlockList; }
96 TList* GetAsyncBlockList() { return fAsyncBlockList; }
98 /** Navigate backwards in event buffer */
99 Int_t NavigateEventBufferBack();
101 /** Navigate forwards in event buffer */
102 Int_t NavigateEventBufferFwd();
104 /** Set and get the string used to select triggers */
105 void SetTriggerString ( TString triggerString ) { fTriggerString = triggerString; }
107 /** Get TriggerString */
108 TString GetTriggerString () { return fTriggerString; }
110 void SetBlockOwner(Bool_t owner) { fBlockList->SetOwner(owner); }
111 Bool_t GetBlockOwner() const { return fBlockList->IsOwner(); }
115 /** Dynamic loader manager for the HOMER library */
116 AliHLTHOMERLibManager* fLibManager; //! transient
118 /** Indicates, if a sources have changes, so that one has to reconnect. */
119 Bool_t fStateHasChanged; // see above
121 Bool_t Connected() const { return fConnected; }
125 /** copy constructor prohibited */
126 AliHLTHOMERManager(const AliHLTHOMERManager&);
128 /** assignment operator prohibited */
129 AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
131 //==============Connection to homer ==========================
133 /** Create a readout list for Hostname and ports */
134 void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts,
135 UInt_t &sourceCount, TString detector );
137 /** Checks if already connected to HOMER sources */
138 Bool_t IsConnected() { return fConnected; }
140 /** Create and add Block List to Buffer */
141 void AddBlockListToBuffer();
143 /** Add bocks to asynchronous BlockList */
144 void AddToAsyncBlockList();
145 void AddToBlockList();
148 //============ Block Handling ====================
150 /** Get pointer to block list in event buffer */
151 TList* GetBlockListEventBuffer( );
153 /** Get Number of blocks in current event */
154 ULong_t GetNBlks() { return fNBlks; }
156 /** Handle Blocks and fill them in event buffer or asyncronous BlockList */
157 Int_t HandleBlocks();
159 /** Check is block are from syncronous source */
160 Bool_t IsSyncBlocks();
162 /** Get pointer to block ndx in current event */
163 void* GetBlk( Int_t ndx );
165 /** Get pointer to current block in current event */
166 void* GetBlk() { return GetBlk(fCurrentBlk); }
168 /** Get first block in current event */
169 void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
171 /** Get next block in current event */
172 void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
174 /** Get size of block ndx */
175 ULong_t GetBlkSize( Int_t ndx );
177 /** Get size of current block */
178 ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
180 /** Get origin of block ndx */
181 TString GetBlkOrigin( Int_t ndx );
183 /** Get origin of current block */
184 TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
186 /** Get type of block ndx */
187 TString GetBlkType( Int_t ndx );
189 /** Get type of current block */
190 TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
192 //Get specification of block at ndx in bufferindex
193 ULong_t GetBlkSpecification( Int_t ndx );
195 /** Get specification of current block */
196 ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); }
198 //Check if requested in eve
199 Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
201 //Check trigger decision
202 Bool_t CheckTriggerDecision();
204 AliHLTHOMERProxyHandler * fProxyHandler; /** Proxy Handler to get the list of sources */ //! transient
205 AliHLTHOMERReader* fCurrentReader; /** Pointer to current HOMER reader */ //! transient
206 TList* fReaderList; /** List to pointer of HOMER readers */
209 TList* fSourceList; /** List to HOMER sources */
210 ULong_t fNBlks; /** Number of blockes in current event */
211 ULong64_t fEventID[BUFFERSIZE]; /** EventID of current event */
213 ULong_t fCurrentBlk; /** Current block in current event */
214 TList* fAsyncBlockList; /** List containing asychronous blocks */
215 TList* fBlockList; /** List containing asychronous blocks */
217 // == event buffer ==
218 TClonesArray * fEventBuffer; /** Event Buffer */
219 Int_t fBufferTopIdx; /** Buffer index to last received event */
220 Int_t fBufferLowIdx; /** Buffer index to last received event */
221 Int_t fCurrentBufferIdx; /** Buffer index to current event */
222 Int_t fNavigateBufferIdx; // Navigate index through event buffer */
223 Int_t fNEventsAvailable; //Number of available events
225 Bool_t fConnected; /** Shows connection status */
226 TString fTriggerString; /** String indicating which trigger should be used to select events */
227 Int_t fNEventsNotTriggered; /** Number Events not triggered, before next triggered event is found */
229 Bool_t fRetryNextEvent; /** Retry reading next event */
231 Bool_t fIsBlockOwner;
233 ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources.