]>
Commit | Line | Data |
---|---|---|
1ad3c9f4 | 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 "TClonesArray.h" | |
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 | ||
29 | #include "AliHLTLoggingVariadicFree.h" | |
30 | ||
6c1e30ef | 31 | #define BUFFERSIZE 10 |
1ad3c9f4 | 32 | |
33 | class 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 | ||
50 | class AliHLTHOMERManager : public AliHLTLogging | |
51 | { | |
52 | public: | |
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 | |
78 | * @return 0 on success, <0 for failure, 1 for no active service | |
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 | ||
97 | /** Connect to HOMER sources, of a certain detector. | |
98 | * which gets created when state has changed | |
99 | * @param detector Detector to be connected to | |
100 | * @return 0 on success, <0 for failure | |
101 | */ | |
102 | Int_t ConnectHOMER( TString detector="ALL" ); | |
103 | ||
104 | /** Disconnect from HOMER sources */ | |
105 | void DisconnectHOMER(); | |
106 | ||
107 | /** Reconnect from HOMER sources | |
108 | * @param detector Detector to be connected to | |
109 | * @return 0 on success, <0 for failure | |
110 | */ | |
111 | Int_t ReconnectHOMER( TString detector); | |
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 | ||
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 | ||
129 | /** Get event ID */ | |
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 | /** Get pointer to last asynchrounous BlockList | |
143 | * @return ptr to buffer, NULL if none present | |
144 | */ | |
6c1e30ef | 145 | TList* GetAsyncBlockList() { return fAsyncBlockList; } |
1ad3c9f4 | 146 | |
147 | /** Navigate backwards in event buffer | |
148 | * @return index in buffer, -1 if boundary reached | |
149 | */ | |
150 | Int_t NavigateEventBufferBack(); | |
151 | ||
152 | /** Navigate forwards in event buffer | |
153 | * @return index in buffer, -1 if boundary reached | |
154 | */ | |
155 | Int_t NavigateEventBufferFwd(); | |
156 | ||
157 | /* --------------------------------------------------------------------------------- | |
158 | * Trigger Handling - public | |
159 | * --------------------------------------------------------------------------------- | |
160 | */ | |
161 | ||
162 | /** Set and get the string used to select triggers | |
163 | * @param triggerString Trigger selection string | |
164 | */ | |
165 | void SetTriggerString ( TString triggerString ) { fTriggerString = triggerString; } | |
166 | ||
167 | /** Get TriggerString */ | |
168 | TString GetTriggerString () { return fTriggerString; } | |
169 | ||
170 | /////////////////////////////////////////////////////////////////////////////////// | |
171 | ||
172 | protected: | |
173 | ||
174 | /** Dynamic loader manager for the HOMER library */ | |
175 | AliHLTHOMERLibManager* fLibManager; //! transient | |
176 | ||
177 | /** Indicates, if a sources have changes, | |
178 | * so that one has to reconnect. */ | |
179 | Bool_t fStateHasChanged; // see above | |
180 | ||
181 | /////////////////////////////////////////////////////////////////////////////////// | |
182 | ||
183 | private: | |
184 | ||
185 | /** copy constructor prohibited */ | |
186 | AliHLTHOMERManager(const AliHLTHOMERManager&); | |
187 | ||
188 | /** assignment operator prohibited */ | |
189 | AliHLTHOMERManager& operator=(const AliHLTHOMERManager&); | |
190 | ||
191 | /* | |
192 | * --------------------------------------------------------------------------------- | |
193 | * Connection Handling - private | |
194 | * --------------------------------------------------------------------------------- | |
195 | */ | |
196 | ||
197 | /** Create a readout list for Hostname and ports | |
198 | * @param socurceHostnames Array of selected hostnames | |
199 | * @param socurcePorts Array of selected ports | |
200 | * @param socurceCount Number of selected hostname:port | |
201 | * @param detector detector to be selected | |
202 | */ | |
203 | void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, | |
204 | UInt_t &sourceCount, TString detector ); | |
205 | ||
206 | /** Checks if already connected to HOMER sources */ | |
207 | Bool_t IsConnected() { return fConnected; } | |
208 | ||
209 | /* --------------------------------------------------------------------------------- | |
210 | * Buffer Handling - private | |
211 | * --------------------------------------------------------------------------------- | |
212 | */ | |
213 | ||
214 | /** Create and add Block List to Buffer */ | |
215 | void AddBlockListToBuffer(); | |
216 | ||
217 | /** Add bocks to asynchronous BlockList */ | |
218 | void AddToAsyncBlockList(); | |
219 | ||
220 | /** Get pointer to block list in event buffer | |
221 | * @return ptr to buffer, NULL if not present | |
222 | */ | |
223 | TList* GetBlockListEventBuffer( Int_t idx ); | |
224 | ||
225 | /* | |
226 | * --------------------------------------------------------------------------------- | |
227 | * Block Handling - private | |
228 | * --------------------------------------------------------------------------------- | |
229 | */ | |
230 | ||
231 | /** Get Number of blocks in current event */ | |
232 | ULong_t GetNBlks() { return fNBlks; } | |
233 | ||
234 | // ---------------------------------------------------- | |
235 | ||
236 | /** Handle Blocks and fill them in event buffer or asyncronous BlockList | |
237 | * @return 0 on success, <0 for failure | |
238 | */ | |
239 | Int_t HandleBlocks(); | |
240 | ||
241 | /** Check is block are from syncronous source | |
242 | * @return kTRUE, if asyncronous kFALSE | |
243 | */ | |
244 | Bool_t IsSyncBlocks(); | |
245 | ||
246 | // ---------------------------------------------------- | |
247 | ||
248 | /** Get pointer to block ndx in current event | |
249 | * @param ndx Block index | |
250 | * @return returns pointer to blk, NULL if no block present | |
251 | */ | |
252 | void* GetBlk( Int_t ndx ); | |
253 | ||
254 | /** Get pointer to current block in current event */ | |
255 | void* GetBlk() { return GetBlk(fCurrentBlk); } | |
256 | ||
257 | /** Get first block in current event */ | |
258 | void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); } | |
259 | ||
260 | /** Get next block in current event */ | |
261 | void* GetNextBlk() { return GetBlk(++fCurrentBlk); } | |
262 | ||
263 | // ---------------------------------------------------- | |
264 | ||
265 | /** Get size of block ndx | |
266 | * @param ndx Block index | |
267 | * @return returns size blk, 0 otherwise | |
268 | */ | |
269 | ULong_t GetBlkSize( Int_t ndx ); | |
270 | ||
271 | /** Get size of current block */ | |
272 | ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); } | |
273 | ||
274 | // ---------------------------------------------------- | |
275 | ||
276 | /** Get origin of block ndx | |
277 | * @param ndx Block index | |
278 | * @return origin of block | |
279 | */ | |
280 | TString GetBlkOrigin( Int_t ndx ); | |
281 | ||
282 | /** Get origin of current block */ | |
283 | TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); } | |
284 | ||
285 | // ---------------------------------------------------- | |
286 | ||
287 | /** Get type of block ndx | |
288 | * @param ndx Block index | |
289 | * @return type of block | |
290 | */ | |
291 | TString GetBlkType( Int_t ndx ); | |
292 | ||
293 | /** Get type of current block */ | |
294 | TString GetBlkType() { return GetBlkType( fCurrentBlk ); } | |
295 | ||
296 | // ---------------------------------------------------- | |
297 | ||
298 | /** Get specification of block ndx | |
299 | * @param ndx Block index | |
300 | * @return specification of block | |
301 | */ | |
302 | ULong_t GetBlkSpecification( Int_t ndx ); | |
303 | ||
304 | /** Get specification of current block */ | |
305 | ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } | |
306 | ||
307 | // ---------------------------------------------------- | |
308 | ||
309 | /** Checks if current Block should was requested | |
310 | * @return returns kTRUE, if block should was requested | |
311 | */ | |
312 | Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block ); | |
313 | ||
314 | /* --------------------------------------------------------------------------------- | |
315 | * Trigger Handling - private | |
316 | * --------------------------------------------------------------------------------- | |
317 | */ | |
318 | ||
319 | /** Loops over the data block from all the readers in the readerlist until | |
320 | * a triggerdecsision has been found | |
321 | * Locates the triggerdecision required by fTriggerString and checks if it triggered | |
322 | * @return returns kTRUE, if event was triggered, kFALSE otherwise | |
323 | */ | |
324 | Bool_t CheckTriggerDecision(); | |
325 | ||
326 | /* | |
327 | * --------------------------------------------------------------------------------- | |
328 | * Members - private | |
329 | * --------------------------------------------------------------------------------- | |
330 | */ | |
331 | ||
332 | /** Proxy Handler to get the list of sources */ | |
333 | AliHLTHOMERProxyHandler *fProxyHandler; //! transient | |
334 | ||
335 | // == connection == | |
336 | ||
337 | /** Pointer to current HOMER reader */ | |
338 | AliHLTHOMERReader *fCurrentReader; //! transient | |
339 | ||
340 | /** List to pointer of HOMER readers */ | |
341 | TList *fReaderList; //! transient | |
342 | ||
343 | // == sources == | |
344 | ||
345 | /** List to HOMER sources */ | |
346 | TList *fSourceList; //! transient | |
347 | ||
348 | // == events == | |
349 | ||
350 | /** Number of blockes in current event */ | |
351 | ULong_t fNBlks; // see above | |
352 | ||
353 | /** EventID of current event */ | |
354 | ULong64_t fEventID[BUFFERSIZE]; // see above | |
355 | ||
356 | /** Current block in current event */ | |
357 | ULong_t fCurrentBlk; // see above | |
358 | ||
359 | // == Asynchronous BlockList == | |
360 | ||
361 | /** List containing asychronous blocks */ | |
362 | TList *fAsyncBlockList; // see above | |
363 | ||
364 | // == event buffer == | |
365 | ||
366 | /** Event Buffer */ | |
367 | TClonesArray *fEventBuffer; // see above | |
368 | ||
369 | /** Buffer index to last received event */ | |
370 | Int_t fBufferTopIdx; // see above | |
371 | ||
372 | /** Buffer index to last received event */ | |
373 | Int_t fBufferLowIdx; // see above | |
374 | ||
375 | /** Buffer index to current event */ | |
376 | Int_t fCurrentBufferIdx; // see above | |
377 | ||
378 | /** Navigate index through event buffer */ | |
379 | Int_t fNavigateBufferIdx; // see above | |
380 | ||
381 | // == states == | |
382 | ||
383 | /** Shows connection status */ | |
384 | Bool_t fConnected; // see above | |
385 | ||
386 | // == trigger selection == | |
387 | ||
388 | /** String indicating which trigger should be used to select events */ | |
389 | TString fTriggerString; // see above | |
390 | ||
391 | /** Number Events not triggered, before next triggered event is found */ | |
392 | Int_t fNEventsNotTriggered; // see above | |
393 | ||
394 | /** Retry reading next event */ | |
395 | Bool_t fRetryNextEvent; // see above | |
396 | ||
397 | ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources. | |
398 | }; | |
399 | ||
400 | #endif |