]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTHOMERManager.h
* removed HLT logging
[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 "AliHLTLogging.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 TObject//, 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   ///////////////////////////////////////////////////////////////////////////////////
140
141 private:
142
143   /** copy constructor prohibited */
144   AliHLTHOMERManager(const AliHLTHOMERManager&);
145
146   /** assignment operator prohibited */
147   AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
148
149   /*
150    * ---------------------------------------------------------------------------------
151    *                            Connection Handling - private
152    * ---------------------------------------------------------------------------------
153    */
154
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
160    */
161   void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
162                           UInt_t &sourceCount, TString detector );
163
164   /** Checks if already connected to HOMER sources */
165   Bool_t IsConnected() { return fConnected; }  
166   
167   /* ---------------------------------------------------------------------------------
168    *                            Event Handling - private
169    * ---------------------------------------------------------------------------------
170    */
171
172   /** Create a TList of blocks, which have been readout */
173   void CreateBlockList();
174
175   /*
176    * ---------------------------------------------------------------------------------
177    *                            Block Handling - private
178    * ---------------------------------------------------------------------------------
179    */
180
181   /** Get Number of blocks in current event */
182   ULong_t GetNBlks() { return fNBlks; }
183
184   // ----------------------------------------------------
185
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
189    */
190   void* GetBlk( Int_t ndx );
191
192   /** Get pointer to current block in current event */
193   void* GetBlk() { return GetBlk(fCurrentBlk); }
194
195   /** Get first block in current event */
196   void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
197
198   /** Get next block in current event */
199   void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
200
201   // ----------------------------------------------------
202
203   /** Get size of block ndx 
204    *  @param ndx        Block index
205    *  @return           returns size blk, 0 otherwise
206    */
207   ULong_t GetBlkSize( Int_t ndx );
208
209   /** Get size of current block */ 
210   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
211
212   // ---------------------------------------------------- 
213
214   /** Get origin of block ndx 
215    *  @param ndx        Block index
216    *  @return           origin of block
217    */
218   TString GetBlkOrigin( Int_t ndx );
219
220   /** Get origin of current block */
221   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
222
223   // ----------------------------------------------------
224
225   /** Get type of block ndx 
226    *  @param ndx        Block index
227    *  @return           type of block
228    */
229   TString GetBlkType( Int_t ndx ); 
230
231   /** Get type of current block */
232   TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
233   
234   // ----------------------------------------------------
235   
236   /** Get specification of block ndx 
237    *  @param ndx        Block index
238    *  @return           specification of block
239    */
240   ULong_t GetBlkSpecification( Int_t ndx );
241
242   /** Get specification of current block */
243   ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
244
245   // ----------------------------------------------------
246
247   /** Checks if current Block should was requested 
248    *  @return           returns kTRUE, if block should was requested
249    */
250   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
251
252   /*
253    * ---------------------------------------------------------------------------------
254    *                            Members - private
255    * ---------------------------------------------------------------------------------
256    */
257
258   /** Proxy Handler to get the list of sources */
259   AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
260
261   // == connection ==
262
263   /** Pointer to HOMER reader */
264   AliHLTHOMERReader* fReader;                        //! transient 
265
266   // == sources ==
267
268   /** List to HOMER sources */
269   TList    *fSourceList;                             //! transient
270   
271   // == blocks ==
272
273   /** List to HOMER blocks */
274   TList    *fBlockList;                              //! transient
275
276   // == events ==
277
278   /** Number of blockes in current event */
279   ULong_t   fNBlks;                                  //  see above
280
281   /** EventID of current event */
282   ULong64_t fEventID;                                //  see above
283
284   /** Current block in current event */
285   ULong_t   fCurrentBlk;                             //  see above
286
287   // == states ==
288   
289   /** Shows connection status */
290   Bool_t    fConnected;                              //  see above
291
292   /** Indicates, if a sources have changes, 
293    *  so that one has to reconnect. */
294   Bool_t    fStateHasChanged;                        //  see above
295
296   ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
297 };
298
299 #endif