3 // $Id: AliHLTHOMERManager.h $
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
16 @brief Manager for HOMER in aliroot
20 #include "TClonesArray.h"
24 #include "AliHLTHOMERSourceDesc.h"
25 #include "AliHLTHOMERBlockDesc.h"
26 #include "AliHLTHOMERReader.h"
27 #include "AliHLTHOMERProxyHandler.h"
29 #include "AliHLTLoggingVariadicFree.h"
33 class AliHLTHOMERLibManager;
36 * @class AliHLTHOMERManager
37 * This Class should handle the communication
38 * from the HLT to aliroot. The HLT sends data via
39 * the HOMER interface on several TCP ports of nodes
40 * in the CERN GPN and DCS network.
41 * All this communication is hidden from the user.
43 * Right now, a xml file ( SCC1 ) is used to get the
44 * configuration, this will/ has to change to a proxy
45 * running on dedicated nodes.
47 * @ingroup alihlt_homer
50 class AliHLTHOMERManager : public AliHLTLogging
55 * ---------------------------------------------------------------------------------
56 * Constructor / Destructor
57 * ---------------------------------------------------------------------------------
60 /** default constructor */
64 virtual ~AliHLTHOMERManager();
67 * @return 0 on success, <0 for failure
72 * ---------------------------------------------------------------------------------
73 * Source Handling - public
74 * ---------------------------------------------------------------------------------
77 /** Create Sources List from HOMER-Proxy
78 * @return 0 on success, <0 for failure, 1 for no active service
80 virtual Int_t CreateSourcesList();
82 /** Set state of a source
83 * @param source Pointer to AliHLTHOMERSourceDesc object.
84 * @param state New (selected/not selected) state.
86 void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
88 /** Get pointer to source List */
89 TList* GetSourceList() { return fSourceList; }
92 * ---------------------------------------------------------------------------------
93 * Connection Handling - public
94 * ---------------------------------------------------------------------------------
97 /** Connect to HOMER sources, of a certain detector.
98 * which gets created when state has changed
99 * @param detector Detector to be connected to
100 * @return 0 on success, <0 for failure
102 Int_t ConnectHOMER( TString detector="ALL" );
104 /** Disconnect from HOMER sources */
105 void DisconnectHOMER();
107 /** Reconnect from HOMER sources
108 * @param detector Detector to be connected to
109 * @return 0 on success, <0 for failure
111 Int_t ReconnectHOMER( TString detector);
114 * ---------------------------------------------------------------------------------
115 * Event Handling - public
116 * ---------------------------------------------------------------------------------
119 /** Loads the next Event, after being connected
120 * @return 0 on success, <0 for failure
122 virtual Int_t NextEvent();
124 /** Loads the next Cycle, after being connected
125 * @return 0 on success, <0 for failure
127 virtual Int_t NextCycle() { return NextEvent(); }
130 ULong_t GetEventID() { return fEventID[fCurrentBufferIdx]; }
132 /* ---------------------------------------------------------------------------------
133 * Buffer Handling - public
134 * ---------------------------------------------------------------------------------
137 /** Get pointer to last requested BlockList
138 * @return ptr to buffer, NULL if buffer boundary reached
140 TList* GetBlockList() { return GetBlockListEventBuffer(fCurrentBufferIdx); }
142 /** Navigate backwards in event buffer
143 * @return index in buffer, -1 if boundary reached
145 Int_t NavigateEventBufferBack();
147 /** Navigate forwards in event buffer
148 * @return index in buffer, -1 if boundary reached
150 Int_t NavigateEventBufferFwd();
152 ///////////////////////////////////////////////////////////////////////////////////
156 /** Dynamic loader manager for the HOMER library */
157 AliHLTHOMERLibManager* fLibManager; //! transient
159 /** Indicates, if a sources have changes,
160 * so that one has to reconnect. */
161 Bool_t fStateHasChanged; // see above
163 ///////////////////////////////////////////////////////////////////////////////////
167 /** copy constructor prohibited */
168 AliHLTHOMERManager(const AliHLTHOMERManager&);
170 /** assignment operator prohibited */
171 AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
174 * ---------------------------------------------------------------------------------
175 * Connection Handling - private
176 * ---------------------------------------------------------------------------------
179 /** Create a readout list for Hostname and ports
180 * @param socurceHostnames Array of selected hostnames
181 * @param socurcePorts Array of selected ports
182 * @param socurceCount Number of selected hostname:port
183 * @param detector detector to be selected
185 void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts,
186 UInt_t &sourceCount, TString detector );
188 /** Checks if already connected to HOMER sources */
189 Bool_t IsConnected() { return fConnected; }
191 /* ---------------------------------------------------------------------------------
192 * Buffer Handling - private
193 * ---------------------------------------------------------------------------------
196 /** Create and add Block List to Buffer */
197 void AddBlockListToBuffer();
199 /** Get pointer to block list in event buffer
200 * @return ptr to buffer, NULL if not present
202 TList* GetBlockListEventBuffer( Int_t idx );
205 * ---------------------------------------------------------------------------------
206 * Block Handling - private
207 * ---------------------------------------------------------------------------------
210 /** Get Number of blocks in current event */
211 ULong_t GetNBlks() { return fNBlks; }
213 // ----------------------------------------------------
215 /** Get pointer to block ndx in current event
216 * @param ndx Block index
217 * @return returns pointer to blk, NULL if no block present
219 void* GetBlk( Int_t ndx );
221 /** Get pointer to current block in current event */
222 void* GetBlk() { return GetBlk(fCurrentBlk); }
224 /** Get first block in current event */
225 void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
227 /** Get next block in current event */
228 void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
230 // ----------------------------------------------------
232 /** Get size of block ndx
233 * @param ndx Block index
234 * @return returns size blk, 0 otherwise
236 ULong_t GetBlkSize( Int_t ndx );
238 /** Get size of current block */
239 ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
241 // ----------------------------------------------------
243 /** Get origin of block ndx
244 * @param ndx Block index
245 * @return origin of block
247 TString GetBlkOrigin( Int_t ndx );
249 /** Get origin of current block */
250 TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
252 // ----------------------------------------------------
254 /** Get type of block ndx
255 * @param ndx Block index
256 * @return type of block
258 TString GetBlkType( Int_t ndx );
260 /** Get type of current block */
261 TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
263 // ----------------------------------------------------
265 /** Get specification of block ndx
266 * @param ndx Block index
267 * @return specification of block
269 ULong_t GetBlkSpecification( Int_t ndx );
271 /** Get specification of current block */
272 ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); }
274 // ----------------------------------------------------
276 /** Checks if current Block should was requested
277 * @return returns kTRUE, if block should was requested
279 Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
282 * ---------------------------------------------------------------------------------
284 * ---------------------------------------------------------------------------------
287 /** Proxy Handler to get the list of sources */
288 AliHLTHOMERProxyHandler *fProxyHandler; //! transient
292 /** Pointer to HOMER reader */
293 AliHLTHOMERReader *fReader; //! transient
297 /** List to HOMER sources */
298 TList *fSourceList; //! transient
302 /** Number of blockes in current event */
303 ULong_t fNBlks; // see above
305 /** EventID of current event */
306 ULong64_t fEventID[BUFFERSIZE]; // see above
308 /** Current block in current event */
309 ULong_t fCurrentBlk; // see above
311 // == event buffer ==
314 TClonesArray *fEventBuffer; // see above
316 /** Buffer index to last received event */
317 Int_t fBufferTopIdx; // see above
319 /** Buffer index to last received event */
320 Int_t fBufferLowIdx; // see above
322 /** Buffer index to current event */
323 Int_t fCurrentBufferIdx; // see above
325 /** Navigate index through event buffer */
326 Int_t fNavigateBufferIdx; // see above
330 /** Shows connection status */
331 Bool_t fConnected; // see above
334 ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources.