3 // $Id: AliHLTHOMERManager.h $
\r
5 #ifndef ALIHLTHOMERMANAGER_H
\r
6 #define ALIHLTHOMERMANAGER_H
\r
8 /* This file is property of and copyright by the ALICE HLT Project *
\r
9 * ALICE Experiment at CERN, All rights reserved. *
\r
10 * See cxx source for full Copyright notice
\r
13 /** @file AliHLTHOMERManager.h
\r
14 @author Jochen Thaeder
\r
16 @brief Manager for HOMER in aliroot
\r
20 #include "TClonesArray.h"
\r
21 #include "TString.h"
\r
24 #include "AliHLTHOMERSourceDesc.h"
\r
25 #include "AliHLTHOMERBlockDesc.h"
\r
26 #include "AliHLTHOMERReader.h"
\r
27 #include "AliHLTHOMERProxyHandler.h"
\r
29 #include "AliHLTLoggingVariadicFree.h"
\r
31 #define BUFFERSIZE 100
\r
33 class AliHLTHOMERLibManager;
\r
36 * @class AliHLTHOMERManager
\r
37 * This Class should handle the communication
\r
38 * from the HLT to aliroot. The HLT sends data via
\r
39 * the HOMER interface on several TCP ports of nodes
\r
40 * in the CERN GPN and DCS network.
\r
41 * All this communication is hidden from the user.
\r
43 * Right now, a xml file ( SCC1 ) is used to get the
\r
44 * configuration, this will/ has to change to a proxy
\r
45 * running on dedicated nodes.
\r
47 * @ingroup alihlt_homer
\r
50 class AliHLTHOMERManager : public AliHLTLogging
\r
55 * ---------------------------------------------------------------------------------
\r
56 * Constructor / Destructor
\r
57 * ---------------------------------------------------------------------------------
\r
60 /** default constructor */
\r
61 AliHLTHOMERManager();
\r
64 virtual ~AliHLTHOMERManager();
\r
67 * @return 0 on success, <0 for failure
\r
72 * ---------------------------------------------------------------------------------
\r
73 * Source Handling - public
\r
74 * ---------------------------------------------------------------------------------
\r
77 /** Create Sources List from HOMER-Proxy
\r
78 * @return 0 on success, <0 for failure, 1 for no active service
\r
80 virtual Int_t CreateSourcesList();
\r
82 /** Set state of a source
\r
83 * @param source Pointer to AliHLTHOMERSourceDesc object.
\r
84 * @param state New (selected/not selected) state.
\r
86 void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
\r
88 /** Get pointer to source List */
\r
89 TList* GetSourceList() { return fSourceList; }
\r
92 * ---------------------------------------------------------------------------------
\r
93 * Connection Handling - public
\r
94 * ---------------------------------------------------------------------------------
\r
97 /** Connect to HOMER sources, of a certain detector.
\r
98 * which gets created when state has changed
\r
99 * @param detector Detector to be connected to
\r
100 * @return 0 on success, <0 for failure
\r
102 Int_t ConnectHOMER( TString detector="ALL" );
\r
104 /** Disconnect from HOMER sources */
\r
105 void DisconnectHOMER();
\r
107 /** Reconnect from HOMER sources
\r
108 * @param detector Detector to be connected to
\r
109 * @return 0 on success, <0 for failure
\r
111 Int_t ReconnectHOMER( TString detector);
\r
114 * ---------------------------------------------------------------------------------
\r
115 * Event Handling - public
\r
116 * ---------------------------------------------------------------------------------
\r
119 /** Loads the next Event, after being connected
\r
120 * @return 0 on success, <0 for failure
\r
122 virtual Int_t NextEvent();
\r
124 /** Loads the next Cycle, after being connected
\r
125 * @return 0 on success, <0 for failure
\r
127 virtual Int_t NextCycle() { return NextEvent(); }
\r
129 /** Get event ID */
\r
130 ULong_t GetEventID() { return fEventID[fCurrentBufferIdx]; }
\r
132 /* ---------------------------------------------------------------------------------
\r
133 * Buffer Handling - public
\r
134 * ---------------------------------------------------------------------------------
\r
137 /** Get pointer to last requested BlockList
\r
138 * @return ptr to buffer, NULL if buffer boundary reached
\r
140 TList* GetBlockList() { return GetBlockListEventBuffer(fCurrentBufferIdx); }
\r
142 /** Get pointer to last asynchrounous BlockList
\r
143 * @return ptr to buffer, NULL if none present
\r
145 TList* GetAsyncBlockList() {
\r
146 cout << "Returning asyncblocklist size : " <<
\r
147 fAsyncBlockList->GetSize() << endl;
\r
148 return fAsyncBlockList;
\r
151 /** Navigate backwards in event buffer
\r
152 * @return index in buffer, -1 if boundary reached
\r
154 Int_t NavigateEventBufferBack();
\r
156 /** Navigate forwards in event buffer
\r
157 * @return index in buffer, -1 if boundary reached
\r
159 Int_t NavigateEventBufferFwd();
\r
161 /* ---------------------------------------------------------------------------------
\r
162 * Trigger Handling - public
\r
163 * ---------------------------------------------------------------------------------
\r
166 /** Set and get the string used to select triggers
\r
167 * @param triggerString Trigger selection string
\r
169 void SetTriggerString ( TString triggerString ) { fTriggerString = triggerString; }
\r
171 /** Get TriggerString */
\r
172 TString GetTriggerString () { return fTriggerString; }
\r
174 ///////////////////////////////////////////////////////////////////////////////////
\r
178 /** Dynamic loader manager for the HOMER library */
\r
179 AliHLTHOMERLibManager* fLibManager; //! transient
\r
181 /** Indicates, if a sources have changes,
\r
182 * so that one has to reconnect. */
\r
183 Bool_t fStateHasChanged; // see above
\r
185 ///////////////////////////////////////////////////////////////////////////////////
\r
189 /** copy constructor prohibited */
\r
190 AliHLTHOMERManager(const AliHLTHOMERManager&);
\r
192 /** assignment operator prohibited */
\r
193 AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
\r
196 * ---------------------------------------------------------------------------------
\r
197 * Connection Handling - private
\r
198 * ---------------------------------------------------------------------------------
\r
201 /** Create a readout list for Hostname and ports
\r
202 * @param socurceHostnames Array of selected hostnames
\r
203 * @param socurcePorts Array of selected ports
\r
204 * @param socurceCount Number of selected hostname:port
\r
205 * @param detector detector to be selected
\r
207 void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts,
\r
208 UInt_t &sourceCount, TString detector );
\r
210 /** Checks if already connected to HOMER sources */
\r
211 Bool_t IsConnected() { return fConnected; }
\r
213 /* ---------------------------------------------------------------------------------
\r
214 * Buffer Handling - private
\r
215 * ---------------------------------------------------------------------------------
\r
218 /** Create and add Block List to Buffer */
\r
219 void AddBlockListToBuffer();
\r
221 /** Add bocks to asynchronous BlockList */
\r
222 void AddToAsyncBlockList();
\r
224 /** Get pointer to block list in event buffer
\r
225 * @return ptr to buffer, NULL if not present
\r
227 TList* GetBlockListEventBuffer( Int_t idx );
\r
230 * ---------------------------------------------------------------------------------
\r
231 * Block Handling - private
\r
232 * ---------------------------------------------------------------------------------
\r
235 /** Get Number of blocks in current event */
\r
236 ULong_t GetNBlks() { return fNBlks; }
\r
238 // ----------------------------------------------------
\r
240 /** Handle Blocks and fill them in event buffer or asyncronous BlockList
\r
241 * @return 0 on success, <0 for failure
\r
243 Int_t HandleBlocks();
\r
245 /** Check is block are from syncronous source
\r
246 * @return kTRUE, if asyncronous kFALSE
\r
248 Bool_t IsSyncBlocks();
\r
250 // ----------------------------------------------------
\r
252 /** Get pointer to block ndx in current event
\r
253 * @param ndx Block index
\r
254 * @return returns pointer to blk, NULL if no block present
\r
256 void* GetBlk( Int_t ndx );
\r
258 /** Get pointer to current block in current event */
\r
259 void* GetBlk() { return GetBlk(fCurrentBlk); }
\r
261 /** Get first block in current event */
\r
262 void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
\r
264 /** Get next block in current event */
\r
265 void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
\r
267 // ----------------------------------------------------
\r
269 /** Get size of block ndx
\r
270 * @param ndx Block index
\r
271 * @return returns size blk, 0 otherwise
\r
273 ULong_t GetBlkSize( Int_t ndx );
\r
275 /** Get size of current block */
\r
276 ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
\r
278 // ----------------------------------------------------
\r
280 /** Get origin of block ndx
\r
281 * @param ndx Block index
\r
282 * @return origin of block
\r
284 TString GetBlkOrigin( Int_t ndx );
\r
286 /** Get origin of current block */
\r
287 TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
\r
289 // ----------------------------------------------------
\r
291 /** Get type of block ndx
\r
292 * @param ndx Block index
\r
293 * @return type of block
\r
295 TString GetBlkType( Int_t ndx );
\r
297 /** Get type of current block */
\r
298 TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
\r
300 // ----------------------------------------------------
\r
302 /** Get specification of block ndx
\r
303 * @param ndx Block index
\r
304 * @return specification of block
\r
306 ULong_t GetBlkSpecification( Int_t ndx );
\r
308 /** Get specification of current block */
\r
309 ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); }
\r
311 // ----------------------------------------------------
\r
313 /** Checks if current Block should was requested
\r
314 * @return returns kTRUE, if block should was requested
\r
316 Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
\r
318 /* ---------------------------------------------------------------------------------
\r
319 * Trigger Handling - private
\r
320 * ---------------------------------------------------------------------------------
\r
323 /** Loops over the data block from all the readers in the readerlist until
\r
324 * a triggerdecsision has been found
\r
325 * Locates the triggerdecision required by fTriggerString and checks if it triggered
\r
326 * @return returns kTRUE, if event was triggered, kFALSE otherwise
\r
328 Bool_t CheckTriggerDecision();
\r
331 * ---------------------------------------------------------------------------------
\r
332 * Members - private
\r
333 * ---------------------------------------------------------------------------------
\r
336 /** Proxy Handler to get the list of sources */
\r
337 AliHLTHOMERProxyHandler *fProxyHandler; //! transient
\r
339 // == connection ==
\r
341 /** Pointer to current HOMER reader */
\r
342 AliHLTHOMERReader *fCurrentReader; //! transient
\r
344 /** List to pointer of HOMER readers */
\r
345 TList *fReaderList; //! transient
\r
349 /** List to HOMER sources */
\r
350 TList *fSourceList; //! transient
\r
354 /** Number of blockes in current event */
\r
355 ULong_t fNBlks; // see above
\r
357 /** EventID of current event */
\r
358 ULong64_t fEventID[BUFFERSIZE]; // see above
\r
360 /** Current block in current event */
\r
361 ULong_t fCurrentBlk; // see above
\r
363 // == Asynchronous BlockList ==
\r
365 /** List containing asychronous blocks */
\r
366 TList *fAsyncBlockList; // see above
\r
368 // == event buffer ==
\r
370 /** Event Buffer */
\r
371 TClonesArray *fEventBuffer; // see above
\r
373 /** Buffer index to last received event */
\r
374 Int_t fBufferTopIdx; // see above
\r
376 /** Buffer index to last received event */
\r
377 Int_t fBufferLowIdx; // see above
\r
379 /** Buffer index to current event */
\r
380 Int_t fCurrentBufferIdx; // see above
\r
382 /** Navigate index through event buffer */
\r
383 Int_t fNavigateBufferIdx; // see above
\r
387 /** Shows connection status */
\r
388 Bool_t fConnected; // see above
\r
390 // == trigger selection ==
\r
392 /** String indicating which trigger should be used to select events */
\r
393 TString fTriggerString; // see above
\r
395 /** Number Events not triggered, before next triggered event is found */
\r
396 Int_t fNEventsNotTriggered; // see above
\r
398 /** Retry reading next event */
\r
399 Bool_t fRetryNextEvent; // see above
\r
401 ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources.
\r