* AliHLTHOMERBlockDesc holds now a copy of the data
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.h
CommitLineData
06272c83 1//-*- Mode: C++ -*-
2
3// $Id: AliHLTHOMERManager.h $
4
ae17e63c 5#ifndef ALIHLTHOMERMANAGER_H
6#define ALIHLTHOMERMANAGER_H
06272c83 7
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
11 */
12
13/** @file AliHLTHOMERManager.h
14 @author Jochen Thaeder
15 @date
16 @brief Manager for HOMER in aliroot
17*/
18
19
ea9a0e13 20#include "TClonesArray.h"
06272c83 21#include "TString.h"
22#include "TList.h"
23
24#include "AliHLTHOMERSourceDesc.h"
25#include "AliHLTHOMERBlockDesc.h"
26#include "AliHLTHOMERReader.h"
27#include "AliHLTHOMERProxyHandler.h"
28
b6bb7ca3 29#include "AliHLTLoggingVariadicFree.h"
06272c83 30
ea9a0e13 31#define BUFFERSIZE 10
32
06272c83 33class AliHLTHOMERLibManager;
34
35/**
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.
42 *
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.
46 *
47 * @ingroup alihlt_homer
48 */
49
a82a31af 50class AliHLTHOMERManager : public AliHLTLogging
e728e5ba 51{
06272c83 52public:
53
54 /*
55 * ---------------------------------------------------------------------------------
56 * Constructor / Destructor
57 * ---------------------------------------------------------------------------------
58 */
59
60 /** default constructor */
61 AliHLTHOMERManager();
62
63 /** destructor */
64 virtual ~AliHLTHOMERManager();
65
66 /** Initialize
67 * @return 0 on success, <0 for failure
68 */
69 Int_t Initialize();
70
71 /*
72 * ---------------------------------------------------------------------------------
73 * Source Handling - public
74 * ---------------------------------------------------------------------------------
75 */
76
77 /** Create Sources List from HOMER-Proxy
ae17e63c 78 * @return 0 on success, <0 for failure, 1 for no active service
06272c83 79 */
80 virtual Int_t CreateSourcesList();
81
82 /** Set state of a source
83 * @param source Pointer to AliHLTHOMERSourceDesc object.
84 * @param state New (selected/not selected) state.
85 */
86 void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
87
88 /** Get pointer to source List */
89 TList* GetSourceList() { return fSourceList; }
90
91 /*
92 * ---------------------------------------------------------------------------------
93 * Connection Handling - public
94 * ---------------------------------------------------------------------------------
95 */
96
4faff50e 97 /** Connect to HOMER sources, of a certain detector.
06272c83 98 * which gets created when state has changed
4faff50e 99 * @param detector Detector to be connected to
100 * @return 0 on success, <0 for failure
06272c83 101 */
e728e5ba 102 Int_t ConnectHOMER( TString detector="ALL" );
06272c83 103
104 /** Disconnect from HOMER sources */
105 void DisconnectHOMER();
106
107 /** Reconnect from HOMER sources
4faff50e 108 * @param detector Detector to be connected to
109 * @return 0 on success, <0 for failure
06272c83 110 */
4faff50e 111 Int_t ReconnectHOMER( TString detector);
06272c83 112
113 /*
114 * ---------------------------------------------------------------------------------
115 * Event Handling - public
116 * ---------------------------------------------------------------------------------
117 */
118
119 /** Loads the next Event, after being connected
120 * @return 0 on success, <0 for failure
121 */
122 virtual Int_t NextEvent();
123
4faff50e 124 /** Loads the next Cycle, after being connected
125 * @return 0 on success, <0 for failure
126 */
127 virtual Int_t NextCycle() { return NextEvent(); }
128
06272c83 129 /** Get event ID */
ea9a0e13 130 ULong_t GetEventID() { return fEventID[fCurrentBufferIdx]; }
131
132 /* ---------------------------------------------------------------------------------
133 * Buffer Handling - public
134 * ---------------------------------------------------------------------------------
135 */
136
137 /** Get pointer to last requested BlockList
138 * @return ptr to buffer, NULL if buffer boundary reached
139 */
140 TList* GetBlockList() { return GetBlockListEventBuffer(fCurrentBufferIdx); }
141
142 /** Navigate backwards in event buffer
143 * @return index in buffer, -1 if boundary reached
144 */
145 Int_t NavigateEventBufferBack();
146
147 /** Navigate forwards in event buffer
148 * @return index in buffer, -1 if boundary reached
149 */
150 Int_t NavigateEventBufferFwd();
06272c83 151
06272c83 152 ///////////////////////////////////////////////////////////////////////////////////
153
154protected:
155
156 /** Dynamic loader manager for the HOMER library */
157 AliHLTHOMERLibManager* fLibManager; //! transient
158
a82a31af 159 /** Indicates, if a sources have changes,
160 * so that one has to reconnect. */
161 Bool_t fStateHasChanged; // see above
162
06272c83 163 ///////////////////////////////////////////////////////////////////////////////////
164
165private:
166
167 /** copy constructor prohibited */
168 AliHLTHOMERManager(const AliHLTHOMERManager&);
169
170 /** assignment operator prohibited */
171 AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
172
173 /*
174 * ---------------------------------------------------------------------------------
175 * Connection Handling - private
176 * ---------------------------------------------------------------------------------
177 */
178
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
4faff50e 183 * @param detector detector to be selected
06272c83 184 */
185 void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts,
4faff50e 186 UInt_t &sourceCount, TString detector );
06272c83 187
188 /** Checks if already connected to HOMER sources */
189 Bool_t IsConnected() { return fConnected; }
190
191 /* ---------------------------------------------------------------------------------
ea9a0e13 192 * Buffer Handling - private
06272c83 193 * ---------------------------------------------------------------------------------
194 */
195
ea9a0e13 196 /** Create and add Block List to Buffer */
197 void AddBlockListToBuffer();
06272c83 198
ea9a0e13 199 /** Get pointer to block list in event buffer
200 * @return ptr to buffer, NULL if not present
201 */
202 TList* GetBlockListEventBuffer( Int_t idx );
203
06272c83 204 /*
205 * ---------------------------------------------------------------------------------
206 * Block Handling - private
207 * ---------------------------------------------------------------------------------
208 */
209
210 /** Get Number of blocks in current event */
211 ULong_t GetNBlks() { return fNBlks; }
212
213 // ----------------------------------------------------
214
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
218 */
219 void* GetBlk( Int_t ndx );
220
221 /** Get pointer to current block in current event */
222 void* GetBlk() { return GetBlk(fCurrentBlk); }
223
224 /** Get first block in current event */
225 void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
226
227 /** Get next block in current event */
228 void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
229
230 // ----------------------------------------------------
231
232 /** Get size of block ndx
233 * @param ndx Block index
234 * @return returns size blk, 0 otherwise
235 */
236 ULong_t GetBlkSize( Int_t ndx );
237
238 /** Get size of current block */
239 ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
240
241 // ----------------------------------------------------
242
243 /** Get origin of block ndx
244 * @param ndx Block index
245 * @return origin of block
246 */
247 TString GetBlkOrigin( Int_t ndx );
248
249 /** Get origin of current block */
250 TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
251
252 // ----------------------------------------------------
253
254 /** Get type of block ndx
255 * @param ndx Block index
256 * @return type of block
257 */
258 TString GetBlkType( Int_t ndx );
259
260 /** Get type of current block */
261 TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
262
263 // ----------------------------------------------------
264
265 /** Get specification of block ndx
266 * @param ndx Block index
267 * @return specification of block
268 */
269 ULong_t GetBlkSpecification( Int_t ndx );
270
271 /** Get specification of current block */
272 ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); }
273
274 // ----------------------------------------------------
275
276 /** Checks if current Block should was requested
277 * @return returns kTRUE, if block should was requested
278 */
279 Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
280
281 /*
282 * ---------------------------------------------------------------------------------
283 * Members - private
284 * ---------------------------------------------------------------------------------
285 */
286
287 /** Proxy Handler to get the list of sources */
ea9a0e13 288 AliHLTHOMERProxyHandler *fProxyHandler; //! transient
06272c83 289
290 // == connection ==
291
292 /** Pointer to HOMER reader */
ea9a0e13 293 AliHLTHOMERReader *fReader; //! transient
06272c83 294
295 // == sources ==
296
297 /** List to HOMER sources */
ea9a0e13 298 TList *fSourceList; //! transient
06272c83 299
300 // == events ==
301
302 /** Number of blockes in current event */
ea9a0e13 303 ULong_t fNBlks; // see above
06272c83 304
305 /** EventID of current event */
ea9a0e13 306 ULong64_t fEventID[BUFFERSIZE]; // see above
06272c83 307
308 /** Current block in current event */
ea9a0e13 309 ULong_t fCurrentBlk; // see above
310
311 // == event buffer ==
06272c83 312
ea9a0e13 313 /** Event Buffer */
314 TClonesArray *fEventBuffer; // see above
315
316 /** Buffer index to last received event */
317 Int_t fBufferTopIdx; // see above
318
319 /** Buffer index to last received event */
320 Int_t fBufferLowIdx; // see above
321
322 /** Buffer index to current event */
323 Int_t fCurrentBufferIdx; // see above
324
325 /** Navigate index through event buffer */
326 Int_t fNavigateBufferIdx; // see above
327
06272c83 328 // == states ==
329
330 /** Shows connection status */
ea9a0e13 331 Bool_t fConnected; // see above
06272c83 332
06272c83 333
ea9a0e13 334 ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources.
06272c83 335};
336
337#endif