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
23 #include "AliHLTHOMERSourceDesc.h"
24 #include "AliHLTHOMERBlockDesc.h"
25 #include "AliHLTHOMERReader.h"
26 #include "AliHLTHOMERProxyHandler.h"
28 #include "AliHLTLoggingVariadicFree.h"
30 class AliHLTHOMERLibManager;
33 * @class AliHLTHOMERManager
34 * This Class should handle the communication
35 * from the HLT to aliroot. The HLT sends data via
36 * the HOMER interface on several TCP ports of nodes
37 * in the CERN GPN and DCS network.
38 * All this communication is hidden from the user.
40 * Right now, a xml file ( SCC1 ) is used to get the
41 * configuration, this will/ has to change to a proxy
42 * running on dedicated nodes.
44 * @ingroup alihlt_homer
47 class AliHLTHOMERManager : public TObject, public AliHLTLogging
52 * ---------------------------------------------------------------------------------
53 * Constructor / Destructor
54 * ---------------------------------------------------------------------------------
57 /** default constructor */
61 virtual ~AliHLTHOMERManager();
64 * @return 0 on success, <0 for failure
69 * ---------------------------------------------------------------------------------
70 * Source Handling - public
71 * ---------------------------------------------------------------------------------
74 /** Create Sources List from HOMER-Proxy
75 * @return 0 on success, <0 for failure, 1 for no active service
77 virtual Int_t CreateSourcesList();
79 /** Set state of a source
80 * @param source Pointer to AliHLTHOMERSourceDesc object.
81 * @param state New (selected/not selected) state.
83 void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
85 /** Get pointer to source List */
86 TList* GetSourceList() { return fSourceList; }
89 * ---------------------------------------------------------------------------------
90 * Connection Handling - public
91 * ---------------------------------------------------------------------------------
94 /** Connect to HOMER sources, of a certain detector.
95 * which gets created when state has changed
96 * @param detector Detector to be connected to
97 * @return 0 on success, <0 for failure
99 Int_t ConnectHOMER( TString detector="ALL" );
101 /** Disconnect from HOMER sources */
102 void DisconnectHOMER();
104 /** Reconnect from HOMER sources
105 * @param detector Detector to be connected to
106 * @return 0 on success, <0 for failure
108 Int_t ReconnectHOMER( TString detector);
111 * ---------------------------------------------------------------------------------
112 * Event Handling - public
113 * ---------------------------------------------------------------------------------
116 /** Loads the next Event, after being connected
117 * @return 0 on success, <0 for failure
119 virtual Int_t NextEvent();
121 /** Loads the next Cycle, after being connected
122 * @return 0 on success, <0 for failure
124 virtual Int_t NextCycle() { return NextEvent(); }
127 ULong_t GetEventID() { return fEventID; } // Get event ID
129 /** Get pointer to block List */
130 TList* GetBlockList() { return fBlockList; } // Get pointer to block List
132 ///////////////////////////////////////////////////////////////////////////////////
136 /** Dynamic loader manager for the HOMER library */
137 AliHLTHOMERLibManager* fLibManager; //! transient
139 ///////////////////////////////////////////////////////////////////////////////////
143 /** copy constructor prohibited */
144 AliHLTHOMERManager(const AliHLTHOMERManager&);
146 /** assignment operator prohibited */
147 AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
150 * ---------------------------------------------------------------------------------
151 * Connection Handling - private
152 * ---------------------------------------------------------------------------------
155 /** Create a readout list for Hostname and ports
156 * @param socurceHostnames Array of selected hostnames
157 * @param socurcePorts Array of selected ports
158 * @param socurceCount Number of selected hostname:port
159 * @param detector detector to be selected
161 void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts,
162 UInt_t &sourceCount, TString detector );
164 /** Checks if already connected to HOMER sources */
165 Bool_t IsConnected() { return fConnected; }
167 /* ---------------------------------------------------------------------------------
168 * Event Handling - private
169 * ---------------------------------------------------------------------------------
172 /** Create a TList of blocks, which have been readout */
173 void CreateBlockList();
176 * ---------------------------------------------------------------------------------
177 * Block Handling - private
178 * ---------------------------------------------------------------------------------
181 /** Get Number of blocks in current event */
182 ULong_t GetNBlks() { return fNBlks; }
184 // ----------------------------------------------------
186 /** Get pointer to block ndx in current event
187 * @param ndx Block index
188 * @return returns pointer to blk, NULL if no block present
190 void* GetBlk( Int_t ndx );
192 /** Get pointer to current block in current event */
193 void* GetBlk() { return GetBlk(fCurrentBlk); }
195 /** Get first block in current event */
196 void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
198 /** Get next block in current event */
199 void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
201 // ----------------------------------------------------
203 /** Get size of block ndx
204 * @param ndx Block index
205 * @return returns size blk, 0 otherwise
207 ULong_t GetBlkSize( Int_t ndx );
209 /** Get size of current block */
210 ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
212 // ----------------------------------------------------
214 /** Get origin of block ndx
215 * @param ndx Block index
216 * @return origin of block
218 TString GetBlkOrigin( Int_t ndx );
220 /** Get origin of current block */
221 TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
223 // ----------------------------------------------------
225 /** Get type of block ndx
226 * @param ndx Block index
227 * @return type of block
229 TString GetBlkType( Int_t ndx );
231 /** Get type of current block */
232 TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
234 // ----------------------------------------------------
236 /** Get specification of block ndx
237 * @param ndx Block index
238 * @return specification of block
240 ULong_t GetBlkSpecification( Int_t ndx );
242 /** Get specification of current block */
243 ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); }
245 // ----------------------------------------------------
247 /** Checks if current Block should was requested
248 * @return returns kTRUE, if block should was requested
250 Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
253 * ---------------------------------------------------------------------------------
255 * ---------------------------------------------------------------------------------
258 /** Proxy Handler to get the list of sources */
259 AliHLTHOMERProxyHandler *fProxyHandler; //! transient
263 /** Pointer to HOMER reader */
264 AliHLTHOMERReader* fReader; //! transient
268 /** List to HOMER sources */
269 TList *fSourceList; //! transient
273 /** List to HOMER blocks */
274 TList *fBlockList; //! transient
278 /** Number of blockes in current event */
279 ULong_t fNBlks; // see above
281 /** EventID of current event */
282 ULong64_t fEventID; // see above
284 /** Current block in current event */
285 ULong_t fCurrentBlk; // see above
289 /** Shows connection status */
290 Bool_t fConnected; // see above
292 /** Indicates, if a sources have changes,
293 * so that one has to reconnect. */
294 Bool_t fStateHasChanged; // see above
296 ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.