]>
Commit | Line | Data |
---|---|---|
06272c83 | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AliHLTHOMERManager.cxx $ | |
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
18 | ||
19 | /** @file AliHLTHOMERManager.cxx | |
20 | @author Jochen Thaeder | |
21 | @date | |
22 | @brief Manger for HOMER in aliroot | |
23 | */ | |
24 | ||
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #if __GNUC__>= 3 | |
32 | using namespace std; | |
33 | #endif | |
34 | ||
ea9a0e13 | 35 | #define EVE_DEBUG 0 |
06272c83 | 36 | |
37 | #include "AliHLTHOMERManager.h" | |
38 | // -- -- -- -- -- -- -- | |
39 | #include "AliHLTHOMERLibManager.h" | |
40 | #include "AliHLTHOMERSourceDesc.h" | |
41 | #include "AliHLTHOMERBlockDesc.h" | |
e728e5ba | 42 | // -- -- -- -- -- -- -- |
06272c83 | 43 | ClassImp(AliHLTHOMERManager) |
44 | ||
45 | /* | |
46 | * --------------------------------------------------------------------------------- | |
47 | * Constructor / Destructor | |
48 | * --------------------------------------------------------------------------------- | |
49 | */ | |
50 | ||
51 | //################################################################################## | |
52 | AliHLTHOMERManager::AliHLTHOMERManager() : | |
53 | fLibManager(new AliHLTHOMERLibManager), | |
a82a31af | 54 | fStateHasChanged(kTRUE), |
06272c83 | 55 | fProxyHandler(NULL), |
56 | fReader(NULL), | |
57 | fSourceList(NULL), | |
06272c83 | 58 | fNBlks(0), |
ea9a0e13 | 59 | fEventID(), |
06272c83 | 60 | fCurrentBlk(0), |
ea9a0e13 | 61 | fEventBuffer(NULL), |
62 | fBufferTopIdx(-1), | |
63 | fBufferLowIdx(-1), | |
64 | fCurrentBufferIdx(-1), | |
65 | fNavigateBufferIdx(-1), | |
a82a31af | 66 | fConnected(kFALSE) { |
06272c83 | 67 | // see header file for class documentation |
68 | // or | |
69 | // refer to README to build package | |
70 | // or | |
71 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
72 | ||
73 | } | |
74 | ||
75 | //################################################################################## | |
76 | AliHLTHOMERManager::~AliHLTHOMERManager() { | |
77 | // see header file for class documentation | |
78 | ||
79 | if ( fLibManager ) { | |
80 | if ( fReader ) | |
81 | fLibManager->DeleteReader(fReader); | |
82 | delete fLibManager; | |
83 | fLibManager = NULL; | |
84 | fReader = NULL; | |
85 | } | |
86 | ||
87 | if ( fProxyHandler != NULL ) | |
88 | delete fProxyHandler; | |
89 | fProxyHandler = NULL; | |
90 | ||
91 | if ( fSourceList != NULL ) | |
92 | delete fSourceList; | |
93 | fSourceList = NULL; | |
94 | ||
ea9a0e13 | 95 | if ( fEventBuffer ) { |
96 | fEventBuffer->Clear(); | |
97 | delete fEventBuffer; | |
98 | } | |
99 | ||
06272c83 | 100 | } |
101 | ||
102 | //################################################################################## | |
103 | Int_t AliHLTHOMERManager::Initialize() { | |
104 | // see header file for class documentation | |
105 | ||
106 | Int_t iResult = 0; | |
107 | ||
108 | if ( !fProxyHandler ) | |
109 | fProxyHandler = new AliHLTHOMERProxyHandler(); | |
110 | ||
111 | if ( fProxyHandler ) { | |
112 | iResult = fProxyHandler->Initialize(); | |
113 | if (iResult) | |
b6bb7ca3 | 114 | HLTError(Form("Initialize of ProxyHandler failed.")); |
06272c83 | 115 | } |
116 | else { | |
117 | iResult = -1; | |
b6bb7ca3 | 118 | HLTError(Form("Creating of ProxyHandler failed.")); |
06272c83 | 119 | } |
120 | ||
ea9a0e13 | 121 | // -- Initialize Event Buffer |
122 | if ( !fEventBuffer ) { | |
123 | fEventBuffer = new TClonesArray( "TList", BUFFERSIZE ); | |
124 | } | |
125 | ||
5de5a293 | 126 | for ( Int_t idx = 0; idx < BUFFERSIZE; ++idx ) { |
ea9a0e13 | 127 | new ((*fEventBuffer)[idx]) TList(); |
128 | (reinterpret_cast<TList*>((*fEventBuffer)[idx]))->SetOwner(kTRUE); | |
129 | ||
130 | fEventID[idx] = 0; | |
131 | } | |
132 | ||
06272c83 | 133 | return iResult; |
134 | } | |
135 | ||
136 | /* | |
137 | * --------------------------------------------------------------------------------- | |
138 | * Source Handling | |
139 | * --------------------------------------------------------------------------------- | |
140 | */ | |
141 | ||
142 | //################################################################################## | |
143 | Int_t AliHLTHOMERManager::CreateSourcesList() { | |
144 | // see header file for class documentation | |
145 | ||
146 | Int_t iResult = 0; | |
147 | ||
148 | if ( fSourceList != NULL ) | |
149 | delete fSourceList; | |
150 | fSourceList = NULL; | |
151 | ||
152 | fSourceList = new TList(); | |
153 | fSourceList->SetOwner( kTRUE ); | |
154 | ||
155 | iResult = fProxyHandler->FillSourceList( fSourceList ); | |
ae17e63c | 156 | if ( iResult < 0 ) { |
b6bb7ca3 | 157 | HLTWarning(Form("There have been errors, while creating the sources list.")); |
06272c83 | 158 | } |
ae17e63c | 159 | else if ( iResult > 0 ) { |
b6bb7ca3 | 160 | HLTWarning(Form("No active services found.")); |
ae17e63c | 161 | } |
9e78371d | 162 | else if ( fSourceList->IsEmpty() ) { |
163 | HLTWarning(Form("No active services in the list.")); | |
164 | iResult = 2; | |
165 | } | |
06272c83 | 166 | else { |
b6bb7ca3 | 167 | HLTInfo(Form("New sources list created.")); |
06272c83 | 168 | |
169 | // -- New SourceList has been created | |
170 | // --> All Sources are new --> State has changed | |
171 | fStateHasChanged = kTRUE; | |
172 | } | |
173 | ||
174 | return iResult; | |
175 | } | |
176 | ||
177 | //################################################################################## | |
178 | void AliHLTHOMERManager::SetSourceState( AliHLTHOMERSourceDesc * source, Bool_t state ) { | |
179 | // see header file for class documentation | |
180 | ||
181 | if ( source->IsSelected() != state ) { | |
182 | source->SetState( state ); | |
183 | fStateHasChanged = kTRUE; | |
184 | } | |
185 | ||
186 | return; | |
187 | } | |
188 | ||
189 | /* | |
190 | * --------------------------------------------------------------------------------- | |
ea9a0e13 | 191 | * Connection Handling - public |
06272c83 | 192 | * --------------------------------------------------------------------------------- |
193 | */ | |
194 | ||
195 | //################################################################################## | |
e728e5ba | 196 | Int_t AliHLTHOMERManager::ConnectHOMER( TString detector ){ |
06272c83 | 197 | // see header file for class documentation |
198 | ||
199 | Int_t iResult = 0; | |
200 | ||
9e78371d | 201 | // -- Check if LibManager is present |
202 | if ( ! fLibManager ) { | |
203 | HLTError(Form("No LibManager present.")); | |
204 | return -1; | |
205 | } | |
206 | ||
06272c83 | 207 | // -- Check if already connected and state has not changed |
208 | if ( fStateHasChanged == kFALSE && IsConnected() ) { | |
b6bb7ca3 | 209 | HLTInfo(Form("No need for reconnection.")); |
06272c83 | 210 | return iResult; |
211 | } | |
9e78371d | 212 | |
06272c83 | 213 | // -- If already connected, disconnect before connect |
214 | if ( IsConnected() ) | |
215 | DisconnectHOMER(); | |
9e78371d | 216 | |
06272c83 | 217 | // -- Create the Readoutlist |
218 | UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()]; | |
219 | const char ** sourceHostnames = new const char* [fSourceList->GetEntries()]; | |
220 | UInt_t sourceCount = 0; | |
9e78371d | 221 | |
4faff50e | 222 | CreateReadoutList( sourceHostnames, sourcePorts, sourceCount, detector ); |
06272c83 | 223 | if ( sourceCount == 0 ) { |
b6bb7ca3 | 224 | HLTError(Form("No sources selected, aborting.")); |
9e78371d | 225 | return -2; |
06272c83 | 226 | } |
227 | ||
228 | // *** Connect to data sources | |
9e78371d | 229 | if ( !fReader ) |
06272c83 | 230 | fReader = fLibManager->OpenReader( sourceCount, sourceHostnames, sourcePorts ); |
9e78371d | 231 | |
06272c83 | 232 | iResult = fReader->GetConnectionStatus(); |
233 | if ( iResult ) { | |
234 | // -- Connection failed | |
235 | ||
236 | UInt_t ndx = fReader->GetErrorConnectionNdx(); | |
237 | ||
238 | if ( ndx < sourceCount ) { | |
b6bb7ca3 | 239 | HLTError(Form("Error establishing connection to TCP source %s:%hu: %s (%d)", |
e728e5ba | 240 | sourceHostnames[ndx], sourcePorts[ndx], strerror(iResult), iResult)); |
06272c83 | 241 | } |
242 | else { | |
b6bb7ca3 | 243 | HLTError(Form("Error establishing connection to unknown source with index %d: %s (%d)", |
e728e5ba | 244 | ndx, strerror(iResult), iResult)); |
06272c83 | 245 | } |
246 | ||
247 | if ( fReader ) | |
248 | fLibManager->DeleteReader( fReader ); | |
249 | fReader = NULL; | |
250 | } | |
251 | else { | |
252 | // -- Connection ok - set reader | |
253 | fConnected = kTRUE; | |
254 | ||
b6bb7ca3 | 255 | HLTInfo(Form("Connection established.")); |
06272c83 | 256 | } |
257 | ||
258 | delete[] sourceHostnames; | |
259 | delete[] sourcePorts; | |
260 | ||
261 | return iResult; | |
262 | } | |
263 | ||
264 | //################################################################################## | |
265 | void AliHLTHOMERManager::DisconnectHOMER(){ | |
266 | // see header file for class documentation | |
267 | ||
268 | if ( ! IsConnected() ) | |
269 | return; | |
270 | ||
271 | if ( fReader ) | |
272 | fLibManager->DeleteReader( fReader ); | |
273 | fReader = NULL; | |
274 | ||
275 | fStateHasChanged = kTRUE; | |
276 | fConnected = kFALSE; | |
277 | ||
b6bb7ca3 | 278 | HLTInfo(Form("Connection closed.")); |
06272c83 | 279 | |
280 | return; | |
281 | } | |
282 | ||
283 | //################################################################################## | |
4faff50e | 284 | Int_t AliHLTHOMERManager::ReconnectHOMER( TString detector="" ){ |
06272c83 | 285 | // see header file for class documentation |
286 | ||
287 | Int_t iResult = 0; | |
288 | ||
289 | if ( IsConnected() ) | |
290 | DisconnectHOMER(); | |
291 | ||
4faff50e | 292 | iResult = ConnectHOMER(detector); |
06272c83 | 293 | if ( iResult ) { |
b6bb7ca3 | 294 | HLTError(Form("Error reconnecting.")); |
06272c83 | 295 | } |
296 | ||
297 | return iResult; | |
298 | } | |
299 | ||
300 | /* | |
301 | * --------------------------------------------------------------------------------- | |
302 | * Event Handling - public | |
303 | * --------------------------------------------------------------------------------- | |
304 | */ | |
305 | ||
06272c83 | 306 | //################################################################################## |
307 | Int_t AliHLTHOMERManager::NextEvent(){ | |
308 | // see header file for class documentation | |
309 | ||
310 | Int_t iResult = 0; | |
311 | Int_t iRetryCount = 0; | |
9e78371d | 312 | |
313 | if ( !IsConnected() || fStateHasChanged ) | |
314 | ConnectHOMER(); | |
315 | ||
316 | if ( !fReader || !IsConnected() ) { | |
b6bb7ca3 | 317 | HLTWarning(Form( "Not connected yet." )); |
06272c83 | 318 | return -1; |
319 | } | |
320 | ||
321 | // fReader->SetEventRequestAdvanceTime( 20000000 /*timeout in us*/ ); | |
322 | ||
323 | // -- Read next event data and error handling for HOMER (error codes and empty blocks) | |
324 | while( 1 ) { | |
325 | ||
326 | iResult = fReader->ReadNextEvent( 40000000 /*timeout in us*/); | |
327 | ||
328 | if ( iResult == 111 || iResult == 32 || iResult == 6 ) { | |
b6bb7ca3 | 329 | HLTError(Form("No Connection to source %d: %s (%d)", |
e728e5ba | 330 | fReader->GetErrorConnectionNdx(), strerror(iResult), iResult)); |
06272c83 | 331 | return -iResult; |
332 | } | |
333 | else if ( iResult == 110 ) { | |
703482d8 | 334 | HLTError(Form("Timeout occured, reading event from source %d: %s (%d)", |
e728e5ba | 335 | fReader->GetErrorConnectionNdx(), strerror(iResult), iResult)); |
06272c83 | 336 | return -iResult; |
337 | } | |
338 | else if ( iResult == 56) { | |
339 | ++iRetryCount; | |
340 | ||
341 | if ( iRetryCount >= 20 ) { | |
b6bb7ca3 | 342 | HLTError(Form("Retry Failed: Error reading event from source %d: %s (%d)", |
e728e5ba | 343 | fReader->GetErrorConnectionNdx(), strerror(iResult), iResult)); |
06272c83 | 344 | return -iResult; |
345 | } | |
346 | else { | |
b6bb7ca3 | 347 | HLTError(Form("Retry: Error reading event from source %d: %s (%d)", |
e728e5ba | 348 | fReader->GetErrorConnectionNdx(), strerror(iResult), iResult)); |
06272c83 | 349 | continue; |
350 | } | |
351 | } | |
352 | else if ( iResult ) { | |
b6bb7ca3 | 353 | HLTError(Form("General Error reading event from source %d: %s (%d)", |
e728e5ba | 354 | fReader->GetErrorConnectionNdx(), strerror(iResult), iResult)); |
06272c83 | 355 | fConnected = kFALSE; |
356 | return -iResult; | |
357 | } | |
358 | else { | |
359 | break; | |
360 | } | |
361 | } // while( 1 ) { | |
362 | ||
363 | // -- Get blockCnt and eventID | |
364 | fNBlks = static_cast<ULong_t>(fReader->GetBlockCnt()); | |
ea9a0e13 | 365 | ULong_t eventID = static_cast<ULong64_t>(fReader->GetEventID()); |
06272c83 | 366 | fCurrentBlk = 0; |
367 | ||
ea9a0e13 | 368 | HLTInfo(Form("Event 0x%016LX (%Lu) with %lu blocks", eventID,eventID, fNBlks)); |
06272c83 | 369 | |
370 | #if EVE_DEBUG | |
371 | // Loop for Debug only | |
372 | for ( ULong_t ii = 0; ii < fNBlks; ii++ ) { | |
373 | Char_t tmp1[9], tmp2[5]; | |
374 | memset( tmp1, 0, 9 ); | |
375 | memset( tmp2, 0, 5 ); | |
376 | void *tmp11 = tmp1; | |
377 | ULong64_t* tmp12 = static_cast<ULong64_t*>(tmp11); | |
e728e5ba | 378 | *tmp12 = fReader->GetBlockDataType(ii); |
06272c83 | 379 | void *tmp21 = tmp2; |
380 | ULong_t* tmp22 = static_cast<ULong_t*>(tmp21); | |
e728e5ba | 381 | *tmp22 = fReader->GetBlockDataOrigin(ii); |
b6bb7ca3 | 382 | HLTInfo(Form( "Block %lu length: %lu - type: %s - origin: %s - spec 0x%08X", |
e728e5ba | 383 | ii, fReader->GetBlockDataLength(ii), tmp1, tmp2, fReader->GetBlockDataSpec(ii) )); |
06272c83 | 384 | } // end for ( ULong_t ii = 0; ii < fNBlks; ii++ ) { |
385 | #endif | |
386 | ||
387 | // -- Create BlockList | |
74682ab7 | 388 | if ( fNBlks > 0 ) { |
ea9a0e13 | 389 | HLTInfo(Form("Add Block List to buffer")); |
390 | AddBlockListToBuffer(); | |
74682ab7 | 391 | } |
392 | else { | |
ea9a0e13 | 393 | HLTWarning(Form("Event 0x%016LX (%Lu) with %lu blocks", eventID, eventID, fNBlks)); |
74682ab7 | 394 | } |
395 | ||
06272c83 | 396 | return iResult; |
397 | } | |
398 | ||
ea9a0e13 | 399 | /* --------------------------------------------------------------------------------- |
400 | * Buffer Handling - public | |
401 | * --------------------------------------------------------------------------------- | |
402 | */ | |
403 | ||
404 | //################################################################################## | |
405 | Int_t AliHLTHOMERManager::NavigateEventBufferBack() { | |
406 | // see header file for class documentation | |
407 | ||
408 | // -- reached the end of the buffer | |
409 | if ( fNavigateBufferIdx == fBufferLowIdx ) | |
410 | return -1; | |
411 | ||
412 | Int_t newIdx = fNavigateBufferIdx - 1; | |
413 | if ( newIdx == -1 ) | |
414 | newIdx = BUFFERSIZE-1; | |
415 | ||
416 | fCurrentBufferIdx = fNavigateBufferIdx = newIdx; | |
417 | ||
418 | return newIdx; | |
419 | } | |
420 | ||
421 | //################################################################################## | |
422 | Int_t AliHLTHOMERManager::NavigateEventBufferFwd() { | |
423 | // see header file for class documentation | |
424 | ||
425 | // -- reached the top of the buffer | |
426 | if ( fNavigateBufferIdx == fBufferTopIdx ) | |
427 | return -1; | |
428 | ||
429 | Int_t newIdx = fNavigateBufferIdx + 1; | |
430 | if ( newIdx == BUFFERSIZE ) | |
431 | newIdx = 0; | |
432 | ||
433 | fCurrentBufferIdx = fNavigateBufferIdx = newIdx; | |
434 | ||
435 | return newIdx; | |
436 | } | |
437 | ||
438 | /////////////////////////////////////////////////////////////////////////////////// | |
439 | ||
06272c83 | 440 | /* |
441 | * --------------------------------------------------------------------------------- | |
442 | * Connection Handling - private | |
443 | * --------------------------------------------------------------------------------- | |
444 | */ | |
445 | ||
446 | //################################################################################## | |
4faff50e | 447 | void AliHLTHOMERManager::CreateReadoutList( const char** sourceHostnames, UShort_t *sourcePorts, |
448 | UInt_t &sourceCount, TString detector ){ | |
06272c83 | 449 | // see header file for class documentation |
450 | ||
451 | AliHLTHOMERSourceDesc * source= NULL; | |
452 | ||
453 | // -- Read all sources and check if they should be read out | |
454 | TIter next( fSourceList ); | |
455 | while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) { | |
456 | ||
e728e5ba | 457 | // -- If detector NO detector name given |
458 | if ( ! detector.CompareTo("ALL") ) { | |
459 | // -- Continue if source is not selected | |
460 | if ( ! source->IsSelected() ) | |
4faff50e | 461 | continue; |
462 | } | |
e728e5ba | 463 | // -- DetectorName given |
4faff50e | 464 | else { |
e728e5ba | 465 | // -- Continue if detector name doesn't match |
466 | if ( detector.CompareTo(source->GetDetector()) ) | |
4faff50e | 467 | continue; |
e728e5ba | 468 | else |
469 | source->Select(); | |
4faff50e | 470 | } |
06272c83 | 471 | |
472 | Bool_t exists = kFALSE; | |
473 | ||
474 | // -- Loop over existing entries and check if entry is already in readout list | |
475 | for ( UInt_t ii = 0; ii < sourceCount; ii++ ){ | |
476 | if ( !strcmp( sourceHostnames[ii], source->GetHostname().Data() ) | |
477 | && sourcePorts[ii] == source->GetPort() ) { | |
478 | exists = kTRUE; | |
479 | break; | |
480 | } | |
481 | } | |
482 | ||
483 | // -- Add new entires to readout list | |
484 | if ( ! exists ) { | |
485 | sourcePorts[sourceCount] = source->GetPort(); | |
486 | sourceHostnames[sourceCount] = source->GetHostname().Data(); | |
487 | sourceCount++; | |
488 | } | |
489 | ||
490 | } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) { | |
491 | ||
492 | fStateHasChanged = kFALSE; | |
493 | ||
494 | return; | |
495 | } | |
496 | ||
497 | /* | |
498 | * --------------------------------------------------------------------------------- | |
ea9a0e13 | 499 | * Buffer Handling - private |
06272c83 | 500 | * --------------------------------------------------------------------------------- |
501 | */ | |
502 | ||
06272c83 | 503 | //################################################################################## |
ea9a0e13 | 504 | void AliHLTHOMERManager::AddBlockListToBuffer() { |
06272c83 | 505 | // see header file for class documentation |
506 | ||
ea9a0e13 | 507 | // -- Set Top mark |
508 | ++fBufferTopIdx; | |
509 | if ( fBufferTopIdx == BUFFERSIZE ) | |
510 | fBufferTopIdx = 0; | |
511 | ||
512 | // -- Change the low mark if necessary | |
513 | if ( fBufferLowIdx == -1 ) | |
514 | fBufferLowIdx = 0; | |
515 | else if ( fBufferTopIdx == fBufferLowIdx ) { | |
516 | ++fBufferLowIdx; | |
517 | if ( fBufferLowIdx == BUFFERSIZE ) | |
518 | fBufferLowIdx = 0; | |
519 | } | |
520 | ||
521 | fNavigateBufferIdx = fCurrentBufferIdx = fBufferTopIdx; | |
522 | ||
523 | // -- Fill EventID | |
524 | fEventID[fBufferTopIdx] = static_cast<ULong64_t>(fReader->GetEventID()); | |
06272c83 | 525 | |
ea9a0e13 | 526 | // -- Clear Buffer slot |
527 | (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Clear(); | |
06272c83 | 528 | |
529 | GetFirstBlk(); | |
530 | ||
531 | // -- Fill block list | |
532 | do { | |
533 | ||
534 | // -- Create new block | |
535 | AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc(); | |
536 | block->SetBlock( GetBlk(), GetBlkSize(), GetBlkOrigin(), | |
537 | GetBlkType(), GetBlkSpecification() ); | |
538 | ||
539 | // -- Check sources list if block is requested | |
d8691591 | 540 | if ( CheckIfRequested( block ) ) { |
ea9a0e13 | 541 | (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Add( block ); |
d8691591 | 542 | } |
06272c83 | 543 | else { |
9e78371d | 544 | // XXX HACK Jochen |
ea9a0e13 | 545 | (reinterpret_cast<TList*>((*fEventBuffer)[fBufferTopIdx]))->Add( block ); |
9e78371d | 546 | // delete block; |
547 | // block = NULL; | |
06272c83 | 548 | } |
549 | ||
550 | } while( GetNextBlk() ); | |
ea9a0e13 | 551 | |
06272c83 | 552 | return; |
553 | } | |
554 | ||
ea9a0e13 | 555 | //################################################################################## |
556 | TList* AliHLTHOMERManager::GetBlockListEventBuffer( Int_t idx ) { | |
557 | // see header file for class documentation | |
558 | ||
559 | if ( idx == -1 ) | |
560 | return NULL; | |
561 | ||
562 | return reinterpret_cast<TList*>((*fEventBuffer)[idx]); | |
563 | } | |
564 | ||
06272c83 | 565 | /* |
566 | * --------------------------------------------------------------------------------- | |
ea9a0e13 | 567 | * Block Handling - private |
06272c83 | 568 | * --------------------------------------------------------------------------------- |
569 | */ | |
570 | ||
571 | //################################################################################## | |
572 | void* AliHLTHOMERManager::GetBlk( Int_t ndx ) { | |
573 | // see header file for class documentation | |
574 | // Get pointer to current block in current event | |
575 | ||
576 | if ( !fReader || !IsConnected() ) { | |
b6bb7ca3 | 577 | HLTError(Form("Not connected yet.")); |
06272c83 | 578 | return NULL; |
579 | } | |
580 | if ( ndx < static_cast<Int_t>(fNBlks) ) | |
581 | return const_cast<void*> (fReader->GetBlockData(ndx)); | |
582 | else | |
583 | return NULL; | |
584 | } | |
585 | ||
586 | //################################################################################## | |
587 | ULong_t AliHLTHOMERManager::GetBlkSize( Int_t ndx ) { | |
588 | // see header file for class documentation | |
589 | ||
590 | if ( !fReader || !IsConnected() ) { | |
b6bb7ca3 | 591 | HLTError(Form("Not connected yet.")); |
06272c83 | 592 | return 0; |
593 | } | |
594 | ||
595 | if ( ndx < static_cast<Int_t>(fNBlks) ) | |
596 | return static_cast<ULong_t> (fReader->GetBlockDataLength(ndx)); | |
597 | else | |
598 | return 0; | |
599 | } | |
600 | ||
601 | //################################################################################## | |
602 | TString AliHLTHOMERManager::GetBlkOrigin( Int_t ndx ) { | |
603 | // see header file for class documentation | |
604 | ||
605 | TString origin = ""; | |
606 | ||
607 | // -- Check for Connection | |
608 | if ( !fReader || ! IsConnected() ) { | |
b6bb7ca3 | 609 | HLTError(Form("Not connected yet.")); |
06272c83 | 610 | return origin; |
611 | } | |
612 | ||
613 | // -- Check block index | |
614 | if ( ndx >= static_cast<Int_t>(fNBlks) ) { | |
b6bb7ca3 | 615 | HLTError(Form("Block index %d out of range.", ndx )); |
06272c83 | 616 | return origin; |
617 | } | |
618 | ||
619 | // -- Get origin | |
620 | union{ | |
621 | UInt_t data; | |
622 | Char_t array[4]; | |
623 | } reverseOrigin; | |
624 | ||
625 | reverseOrigin.data = static_cast<UInt_t>(fReader->GetBlockDataOrigin(ndx)); | |
626 | ||
627 | // -- Reverse the order | |
628 | for (Int_t ii = 3; ii >= 0; ii-- ) | |
629 | if ( reverseOrigin.array[ii] != ' ') | |
630 | origin.Append( reverseOrigin.array[ii] ); | |
631 | ||
632 | origin.Remove( TString::kTrailing, ' ' ); | |
633 | ||
634 | return origin; | |
635 | } | |
636 | ||
637 | //################################################################################## | |
638 | TString AliHLTHOMERManager::GetBlkType( Int_t ndx ) { | |
639 | // see header file for class documentation | |
640 | ||
641 | TString type = ""; | |
642 | ||
643 | // -- Check for Connection | |
644 | if ( !fReader || ! IsConnected() ) { | |
b6bb7ca3 | 645 | HLTError(Form("Not connected yet.")); |
06272c83 | 646 | return type; |
647 | } | |
648 | ||
649 | // -- Check block index | |
650 | if ( ndx >= static_cast<Int_t>(fNBlks) ) { | |
b6bb7ca3 | 651 | HLTError(Form("Block index %d out of range.", ndx )); |
06272c83 | 652 | return type; |
653 | } | |
654 | ||
655 | // -- Get type | |
656 | union{ | |
657 | ULong64_t data; | |
658 | Char_t array[8]; | |
659 | } reverseType; | |
660 | ||
661 | reverseType.data = static_cast<ULong64_t> (fReader->GetBlockDataType(ndx)); | |
662 | ||
663 | // -- Reverse the order | |
664 | for (Int_t ii = 7; ii >= 0; ii-- ) | |
665 | if ( reverseType.array[ii] != ' ') | |
666 | type.Append( reverseType.array[ii] ); | |
667 | ||
668 | type.Remove( TString::kTrailing, ' ' ); | |
669 | ||
670 | return type; | |
671 | } | |
672 | ||
673 | //################################################################################## | |
674 | ULong_t AliHLTHOMERManager::GetBlkSpecification( Int_t ndx ) { | |
675 | // see header file for class documentation | |
676 | ||
677 | // -- Check for Connection | |
678 | if ( !fReader || ! IsConnected() ) { | |
b6bb7ca3 | 679 | HLTError(Form("Not connected yet.")); |
06272c83 | 680 | return 0; |
681 | } | |
682 | ||
683 | // -- Check block index | |
684 | if ( ndx >= static_cast<Int_t>(fNBlks) ) { | |
b6bb7ca3 | 685 | HLTError(Form("Block index %d out of range.", ndx )); |
06272c83 | 686 | return 0; |
687 | } | |
688 | ||
689 | return static_cast<ULong_t>(fReader->GetBlockDataSpec(ndx)); | |
690 | } | |
691 | ||
692 | //################################################################################## | |
693 | Bool_t AliHLTHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) { | |
694 | // see header file for class documentation | |
695 | ||
696 | Bool_t requested = kFALSE; | |
697 | ||
698 | AliHLTHOMERSourceDesc * source= NULL; | |
699 | ||
700 | // -- Read all sources and check if they should be read out | |
701 | TIter next( fSourceList ); | |
702 | while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) { | |
703 | ||
704 | // -- Check if source is selected | |
705 | if ( ! source->IsSelected() ) | |
706 | continue; | |
9e78371d | 707 | |
06272c83 | 708 | // -- Check if detector matches |
709 | if ( source->GetSourceName().CompareTo( block->GetBlockName() ) ) | |
710 | continue; | |
711 | ||
712 | requested = kTRUE; | |
713 | break; | |
714 | ||
715 | } // while ( ( source = dynamic_cast<AliHLTHOMERSourceDesc*>(next()) ) ) { | |
716 | ||
9e78371d | 717 | #if EVE_DEBUG |
06272c83 | 718 | if ( requested ) { |
b6bb7ca3 | 719 | HLTInfo(Form("Block requested : %s", block->GetBlockName().Data())); |
06272c83 | 720 | } |
721 | else { | |
b6bb7ca3 | 722 | HLTInfo(Form("Block NOT requested : %s", block->GetBlockName().Data())); |
06272c83 | 723 | } |
724 | #endif | |
725 | ||
726 | return requested; | |
727 | } | |
728 |