]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTHOMERManager.h
From Svein Lindal:
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.h
1 //-*- Mode: C++ -*-
2
3 // $Id: AliHLTHOMERManager.h $
4
5 #ifndef ALIHLTHOMERMANAGER_H
6 #define ALIHLTHOMERMANAGER_H
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
20 #include "TString.h"
21 #include "TList.h"
22
23 #include "AliHLTHOMERSourceDesc.h"
24 #include "AliHLTHOMERBlockDesc.h"
25 #include "AliHLTHOMERReader.h"
26 #include "AliHLTHOMERProxyHandler.h"
27
28 #include "AliHLTLoggingVariadicFree.h"
29
30 class AliHLTHOMERLibManager;
31
32 /**
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.
39  * 
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.
43  *
44  * @ingroup alihlt_homer
45  */
46
47 class AliHLTHOMERManager : public AliHLTLogging 
48 {
49 public:
50   
51   /*
52    * ---------------------------------------------------------------------------------
53    *                            Constructor / Destructor
54    * ---------------------------------------------------------------------------------
55    */
56
57   /** default constructor */
58   AliHLTHOMERManager();
59
60   /** destructor */
61   virtual ~AliHLTHOMERManager();
62
63   /** Initialize 
64    *  @return 0 on success, <0 for failure
65    */
66   Int_t Initialize();
67
68   /*
69    * ---------------------------------------------------------------------------------
70    *                            Source Handling - public
71    * ---------------------------------------------------------------------------------
72    */
73
74   /** Create Sources List from HOMER-Proxy 
75    *  @return 0 on success, <0 for failure, 1 for no active service
76    */
77   virtual Int_t CreateSourcesList();
78
79   /** Set state of a source 
80    *  @param source      Pointer to AliHLTHOMERSourceDesc object.
81    *  @param state       New (selected/not selected) state.
82    */
83   void   SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
84
85   /** Get pointer to source List */
86   TList* GetSourceList() { return fSourceList; }
87
88   /*
89    * ---------------------------------------------------------------------------------
90    *                            Connection Handling - public
91    * ---------------------------------------------------------------------------------
92    */
93
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
98    */
99   Int_t ConnectHOMER( TString detector="ALL" );
100
101   /** Disconnect from HOMER sources */
102   void  DisconnectHOMER();
103
104   /** Reconnect from HOMER sources 
105    *  @param detector    Detector to be connected to
106    *  @return            0 on success, <0 for failure
107    */
108   Int_t ReconnectHOMER( TString detector);
109
110   /*
111    * ---------------------------------------------------------------------------------
112    *                            Event Handling - public
113    * ---------------------------------------------------------------------------------
114    */
115
116   /** Loads the next Event, after being connected 
117    *  @return 0 on success, <0 for failure
118    */
119   virtual Int_t NextEvent();
120
121   /** Loads the next Cycle, after being connected 
122    *  @return 0 on success, <0 for failure
123    */
124   virtual Int_t NextCycle() { return NextEvent(); }
125
126   /** Get event ID */
127   ULong_t GetEventID() { return fEventID; }    // Get event ID
128
129   /** Get pointer to block List */
130   TList* GetBlockList() { return fBlockList; } // Get pointer to block List
131   
132   ///////////////////////////////////////////////////////////////////////////////////
133
134 protected:
135
136   /** Dynamic loader manager for the HOMER library */
137   AliHLTHOMERLibManager* fLibManager;             //! transient
138
139   /** Indicates, if a sources have changes, 
140    *  so that one has to reconnect. */
141   Bool_t    fStateHasChanged;                     //  see above
142
143   ///////////////////////////////////////////////////////////////////////////////////
144
145 private:
146
147   /** copy constructor prohibited */
148   AliHLTHOMERManager(const AliHLTHOMERManager&);
149
150   /** assignment operator prohibited */
151   AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
152
153   /*
154    * ---------------------------------------------------------------------------------
155    *                            Connection Handling - private
156    * ---------------------------------------------------------------------------------
157    */
158
159   /** Create a readout list for Hostname and ports 
160    *  @param socurceHostnames   Array of selected hostnames
161    *  @param socurcePorts       Array of selected ports
162    *  @param socurceCount       Number of selected hostname:port
163    *  @param detector           detector to be selected
164    */
165   void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
166                           UInt_t &sourceCount, TString detector );
167
168   /** Checks if already connected to HOMER sources */
169   Bool_t IsConnected() { return fConnected; }  
170   
171   /* ---------------------------------------------------------------------------------
172    *                            Event Handling - private
173    * ---------------------------------------------------------------------------------
174    */
175
176   /** Create a TList of blocks, which have been readout */
177   void CreateBlockList();
178
179   /*
180    * ---------------------------------------------------------------------------------
181    *                            Block Handling - private
182    * ---------------------------------------------------------------------------------
183    */
184
185   /** Get Number of blocks in current event */
186   ULong_t GetNBlks() { return fNBlks; }
187
188   // ----------------------------------------------------
189
190   /** Get pointer to block ndx in current event 
191    *  @param ndx        Block index
192    *  @return           returns pointer to blk, NULL if no block present
193    */
194   void* GetBlk( Int_t ndx );
195
196   /** Get pointer to current block in current event */
197   void* GetBlk() { return GetBlk(fCurrentBlk); }
198
199   /** Get first block in current event */
200   void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
201
202   /** Get next block in current event */
203   void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
204
205   // ----------------------------------------------------
206
207   /** Get size of block ndx 
208    *  @param ndx        Block index
209    *  @return           returns size blk, 0 otherwise
210    */
211   ULong_t GetBlkSize( Int_t ndx );
212
213   /** Get size of current block */ 
214   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
215
216   // ---------------------------------------------------- 
217
218   /** Get origin of block ndx 
219    *  @param ndx        Block index
220    *  @return           origin of block
221    */
222   TString GetBlkOrigin( Int_t ndx );
223
224   /** Get origin of current block */
225   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
226
227   // ----------------------------------------------------
228
229   /** Get type of block ndx 
230    *  @param ndx        Block index
231    *  @return           type of block
232    */
233   TString GetBlkType( Int_t ndx ); 
234
235   /** Get type of current block */
236   TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
237   
238   // ----------------------------------------------------
239   
240   /** Get specification of block ndx 
241    *  @param ndx        Block index
242    *  @return           specification of block
243    */
244   ULong_t GetBlkSpecification( Int_t ndx );
245
246   /** Get specification of current block */
247   ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
248
249   // ----------------------------------------------------
250
251   /** Checks if current Block should was requested 
252    *  @return           returns kTRUE, if block should was requested
253    */
254   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
255
256   /*
257    * ---------------------------------------------------------------------------------
258    *                            Members - private
259    * ---------------------------------------------------------------------------------
260    */
261
262   /** Proxy Handler to get the list of sources */
263   AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
264
265   // == connection ==
266
267   /** Pointer to HOMER reader */
268   AliHLTHOMERReader* fReader;                        //! transient 
269
270   // == sources ==
271
272   /** List to HOMER sources */
273   TList    *fSourceList;                             //! transient
274   
275   // == blocks ==
276
277   /** List to HOMER blocks */
278   TList    *fBlockList;                              //! transient
279
280   // == events ==
281
282   /** Number of blockes in current event */
283   ULong_t   fNBlks;                                  //  see above
284
285   /** EventID of current event */
286   ULong64_t fEventID;                                //  see above
287
288   /** Current block in current event */
289   ULong_t   fCurrentBlk;                             //  see above
290
291   // == states ==
292   
293   /** Shows connection status */
294   Bool_t    fConnected;                              //  see above
295
296
297   ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
298 };
299
300 #endif