]>
Commit | Line | Data |
---|---|---|
1ad3c9f4 | 1 | //-*- Mode: C++ -*- |
2 | ||
6fe8cb30 | 3 | // $Id$ |
1ad3c9f4 | 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 | |
fd2adb88 | 15 | @author Svein Lindal <slindal@fys.uio.no> |
16 | @date October 2010 | |
1ad3c9f4 | 17 | @brief Manager for HOMER in aliroot |
18 | */ | |
19 | ||
20 | ||
21 | #include "TClonesArray.h" | |
22 | #include "TString.h" | |
23 | #include "TList.h" | |
24 | ||
25 | #include "AliHLTHOMERSourceDesc.h" | |
26 | #include "AliHLTHOMERBlockDesc.h" | |
27 | #include "AliHLTHOMERReader.h" | |
28 | #include "AliHLTHOMERProxyHandler.h" | |
29 | ||
30 | #include "AliHLTLoggingVariadicFree.h" | |
31 | ||
fd2adb88 | 32 | #define BUFFERSIZE 15 |
1ad3c9f4 | 33 | |
34 | class AliHLTHOMERLibManager; | |
35 | ||
36 | /** | |
37 | * @class AliHLTHOMERManager | |
38 | * This Class should handle the communication | |
39 | * from the HLT to aliroot. The HLT sends data via | |
40 | * the HOMER interface on several TCP ports of nodes | |
41 | * in the CERN GPN and DCS network. | |
42 | * All this communication is hidden from the user. | |
43 | * | |
44 | * Right now, a xml file ( SCC1 ) is used to get the | |
45 | * configuration, this will/ has to change to a proxy | |
46 | * running on dedicated nodes. | |
47 | * | |
48 | * @ingroup alihlt_homer | |
49 | */ | |
50 | ||
51 | class AliHLTHOMERManager : public AliHLTLogging | |
52 | { | |
53 | public: | |
54 | ||
1ad3c9f4 | 55 | /** default constructor */ |
56 | AliHLTHOMERManager(); | |
57 | ||
58 | /** destructor */ | |
59 | virtual ~AliHLTHOMERManager(); | |
60 | ||
fd2adb88 | 61 | /** Initialize */ |
1ad3c9f4 | 62 | Int_t Initialize(); |
63 | ||
fd2adb88 | 64 | /** Create Sources List from HOMER-Proxy */ |
1ad3c9f4 | 65 | virtual Int_t CreateSourcesList(); |
66 | ||
fd2adb88 | 67 | /** Set state of a source */ |
1ad3c9f4 | 68 | void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state); |
69 | ||
70 | /** Get pointer to source List */ | |
71 | TList* GetSourceList() { return fSourceList; } | |
72 | ||
fd2adb88 | 73 | /** Connect to HOMER sources, of a certain detector. */ |
1ad3c9f4 | 74 | Int_t ConnectHOMER( TString detector="ALL" ); |
75 | ||
76 | /** Disconnect from HOMER sources */ | |
77 | void DisconnectHOMER(); | |
78 | ||
fd2adb88 | 79 | /** Reconnect from HOMER sources */ |
1ad3c9f4 | 80 | Int_t ReconnectHOMER( TString detector); |
81 | ||
1ad3c9f4 | 82 | |
fd2adb88 | 83 | /** Loads the next Event, after being connected */ |
1ad3c9f4 | 84 | virtual Int_t NextEvent(); |
85 | ||
fd2adb88 | 86 | /** Loads the next Cycle, after being connected */ |
1ad3c9f4 | 87 | virtual Int_t NextCycle() { return NextEvent(); } |
88 | ||
89 | /** Get event ID */ | |
71453f7e | 90 | ULong_t GetEventID() { return fEventId; } |
1ad3c9f4 | 91 | |
fd2adb88 | 92 | Int_t GetNAvailableEvents() { return fNEventsAvailable;} |
93 | ||
94 | /** Get pointer to last requested BlockList */ | |
95 | TList* GetBlockList() { return fBlockList; } | |
6c1e30ef | 96 | TList* GetAsyncBlockList() { return fAsyncBlockList; } |
1ad3c9f4 | 97 | |
fd2adb88 | 98 | /** Navigate backwards in event buffer */ |
1ad3c9f4 | 99 | Int_t NavigateEventBufferBack(); |
100 | ||
fd2adb88 | 101 | /** Navigate forwards in event buffer */ |
1ad3c9f4 | 102 | Int_t NavigateEventBufferFwd(); |
103 | ||
fd2adb88 | 104 | /** Set and get the string used to select triggers */ |
1ad3c9f4 | 105 | void SetTriggerString ( TString triggerString ) { fTriggerString = triggerString; } |
106 | ||
107 | /** Get TriggerString */ | |
108 | TString GetTriggerString () { return fTriggerString; } | |
109 | ||
fd2adb88 | 110 | void SetBlockOwner(Bool_t owner) { fBlockList->SetOwner(owner); } |
111 | Bool_t GetBlockOwner() const { return fBlockList->IsOwner(); } | |
1ad3c9f4 | 112 | |
113 | protected: | |
114 | ||
115 | /** Dynamic loader manager for the HOMER library */ | |
116 | AliHLTHOMERLibManager* fLibManager; //! transient | |
117 | ||
fd2adb88 | 118 | /** Indicates, if a sources have changes, so that one has to reconnect. */ |
1ad3c9f4 | 119 | Bool_t fStateHasChanged; // see above |
120 | ||
fd2adb88 | 121 | Bool_t Connected() const { return fConnected; } |
1ad3c9f4 | 122 | |
123 | private: | |
124 | ||
125 | /** copy constructor prohibited */ | |
126 | AliHLTHOMERManager(const AliHLTHOMERManager&); | |
127 | ||
128 | /** assignment operator prohibited */ | |
129 | AliHLTHOMERManager& operator=(const AliHLTHOMERManager&); | |
130 | ||
fd2adb88 | 131 | //==============Connection to homer ========================== |
132 | ||
133 | /** Create a readout list for Hostname and ports */ | |
1ad3c9f4 | 134 | void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, |
135 | UInt_t &sourceCount, TString detector ); | |
136 | ||
137 | /** Checks if already connected to HOMER sources */ | |
138 | Bool_t IsConnected() { return fConnected; } | |
1ad3c9f4 | 139 | |
140 | /** Create and add Block List to Buffer */ | |
141 | void AddBlockListToBuffer(); | |
142 | ||
143 | /** Add bocks to asynchronous BlockList */ | |
144 | void AddToAsyncBlockList(); | |
fd2adb88 | 145 | void AddToBlockList(); |
146 | ||
1ad3c9f4 | 147 | |
fd2adb88 | 148 | //============ Block Handling ==================== |
149 | ||
150 | /** Get pointer to block list in event buffer */ | |
366495c9 | 151 | TList* GetBlockListEventBuffer( ); |
1ad3c9f4 | 152 | |
1ad3c9f4 | 153 | /** Get Number of blocks in current event */ |
154 | ULong_t GetNBlks() { return fNBlks; } | |
155 | ||
fd2adb88 | 156 | /** Handle Blocks and fill them in event buffer or asyncronous BlockList */ |
1ad3c9f4 | 157 | Int_t HandleBlocks(); |
158 | ||
fd2adb88 | 159 | /** Check is block are from syncronous source */ |
1ad3c9f4 | 160 | Bool_t IsSyncBlocks(); |
161 | ||
fd2adb88 | 162 | /** Get pointer to block ndx in current event */ |
1ad3c9f4 | 163 | void* GetBlk( Int_t ndx ); |
164 | ||
165 | /** Get pointer to current block in current event */ | |
166 | void* GetBlk() { return GetBlk(fCurrentBlk); } | |
167 | ||
168 | /** Get first block in current event */ | |
169 | void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); } | |
170 | ||
171 | /** Get next block in current event */ | |
172 | void* GetNextBlk() { return GetBlk(++fCurrentBlk); } | |
173 | ||
fd2adb88 | 174 | /** Get size of block ndx */ |
1ad3c9f4 | 175 | ULong_t GetBlkSize( Int_t ndx ); |
176 | ||
177 | /** Get size of current block */ | |
178 | ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); } | |
179 | ||
fd2adb88 | 180 | /** Get origin of block ndx */ |
1ad3c9f4 | 181 | TString GetBlkOrigin( Int_t ndx ); |
182 | ||
183 | /** Get origin of current block */ | |
184 | TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); } | |
185 | ||
fd2adb88 | 186 | /** Get type of block ndx */ |
1ad3c9f4 | 187 | TString GetBlkType( Int_t ndx ); |
188 | ||
189 | /** Get type of current block */ | |
190 | TString GetBlkType() { return GetBlkType( fCurrentBlk ); } | |
191 | ||
fd2adb88 | 192 | //Get specification of block at ndx in bufferindex |
1ad3c9f4 | 193 | ULong_t GetBlkSpecification( Int_t ndx ); |
194 | ||
195 | /** Get specification of current block */ | |
196 | ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } | |
197 | ||
fd2adb88 | 198 | //Check if requested in eve |
1ad3c9f4 | 199 | Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block ); |
fd2adb88 | 200 | |
201 | //Check trigger decision | |
1ad3c9f4 | 202 | Bool_t CheckTriggerDecision(); |
fd2adb88 | 203 | |
204 | AliHLTHOMERProxyHandler * fProxyHandler; /** Proxy Handler to get the list of sources */ //! transient | |
205 | AliHLTHOMERReader* fCurrentReader; /** Pointer to current HOMER reader */ //! transient | |
206 | TList* fReaderList; /** List to pointer of HOMER readers */ | |
1ad3c9f4 | 207 | |
208 | // == sources == | |
fd2adb88 | 209 | TList* fSourceList; /** List to HOMER sources */ |
210 | ULong_t fNBlks; /** Number of blockes in current event */ | |
211 | ULong64_t fEventID[BUFFERSIZE]; /** EventID of current event */ | |
71453f7e | 212 | ULong64_t fEventId; |
fd2adb88 | 213 | ULong_t fCurrentBlk; /** Current block in current event */ |
214 | TList* fAsyncBlockList; /** List containing asychronous blocks */ | |
215 | TList* fBlockList; /** List containing asychronous blocks */ | |
1ad3c9f4 | 216 | |
217 | // == event buffer == | |
fd2adb88 | 218 | TClonesArray * fEventBuffer; /** Event Buffer */ |
219 | Int_t fBufferTopIdx; /** Buffer index to last received event */ | |
220 | Int_t fBufferLowIdx; /** Buffer index to last received event */ | |
221 | Int_t fCurrentBufferIdx; /** Buffer index to current event */ | |
222 | Int_t fNavigateBufferIdx; // Navigate index through event buffer */ | |
223 | Int_t fNEventsAvailable; //Number of available events | |
1ad3c9f4 | 224 | |
fd2adb88 | 225 | Bool_t fConnected; /** Shows connection status */ |
226 | TString fTriggerString; /** String indicating which trigger should be used to select events */ | |
227 | Int_t fNEventsNotTriggered; /** Number Events not triggered, before next triggered event is found */ | |
1ad3c9f4 | 228 | |
fd2adb88 | 229 | Bool_t fRetryNextEvent; /** Retry reading next event */ |
1ad3c9f4 | 230 | |
fd2adb88 | 231 | Bool_t fIsBlockOwner; |
1ad3c9f4 | 232 | |
233 | ClassDef(AliHLTHOMERManager, 1); // Manage connections to HLT data-sources. | |
234 | }; | |
235 | ||
236 | #endif |