New class AliEVEHOMERManager; interface to HLT data sources.
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEVEHOMERManager.cxx
CommitLineData
059c30e4 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
5 * for The ALICE HLT Project. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/** @file AliEVEHOMERManager.cxx
17 @author Jochen Thaeder
18 @date
19 @brief Manger for HOMER in offline
20*/
21
22#if __GNUC__>= 3
23 using namespace std;
24#endif
25
26#include "AliEVEHOMERManager.h"
27
28#define use_aliroot
29#define use_root
30#define ROWHOUGHPARAMS
31#define use_reconstruction
32#define use_newio
33#define ROOTVERSION "unchecked"
34#define ALIROOTVERSION "unchecked"
35#define __ROOT__
36#define USE_ALILOG
37#define LINUX
38
39#include "AliHLTHOMERLibManager.h"
40
41#include "AliHLTHOMERSourceDesc.h"
42#include "AliHLTHOMERBlockDesc.h"
43
44#include "AliLog.h"
45
46#include "TString.h"
47#include <TApplication.h>
48#include "Riostream.h"
49#include "TXMLAttr.h"
50#include "TCollection.h"
51#include "TList.h"
52#include "TObjString.h"
53#include "TObjArray.h"
54
55ClassImp(AliEVEHOMERManager)
56
57/*
58 * ---------------------------------------------------------------------------------
59 * Constructor / Destructor
60 * ---------------------------------------------------------------------------------
61 */
62
63//##################################################################################
64AliEVEHOMERManager::AliEVEHOMERManager( TString xmlFile ) :
65 Reve::RenderElementList("AliEVEHOMERManager"),
66
67 fLibManager(new AliHLTHOMERLibManager),
68 fXMLFile(xmlFile),
69 fXMLParser(NULL),
70 fRootNode(NULL),
71 fSourceList(NULL),
72 fReader(NULL),
73 fBlockList(NULL),
74 fNBlks(0),
75 fEventID(0),
76 fCurrentBlk(0),
77 fConnected(kFALSE),
78 fStateHasChanged(kTRUE) {
79 // see header file for class documentation
80 // or
81 // refer to README to build package
82 // or
83 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
84}
85
86//##################################################################################
87AliEVEHOMERManager::AliEVEHOMERManager( const AliEVEHOMERManager& m) :
88 Reve::RenderElementList(m.GetName(), m.GetTitle())
89{
90 // see header file for class documentation
91
92 AliError( Form( "copy constructor to be tested." ) );
93}
94
95//##################################################################################
96AliEVEHOMERManager& AliEVEHOMERManager::operator=( const AliEVEHOMERManager& ) {
97 // see header file for class documentation
98
99 AliError( Form( "assignment constructor to be tested." ) );
100 return *this;
101}
102
103//##################################################################################
104AliEVEHOMERManager::~AliEVEHOMERManager() {
105 // see header file for class documentation
106
107 if ( fLibManager ) {
108 if ( fReader )
109 fLibManager->DeleteReader(fReader);
110 delete fLibManager;
111 fLibManager = NULL;
112 fReader = NULL;
113 }
114
115 if ( fXMLParser )
116 delete fXMLParser;
117 fXMLParser = NULL;
118
119 if ( fSourceList != NULL )
120 delete fSourceList;
121 fSourceList = NULL;
122
123 if ( fBlockList != NULL )
124 delete fBlockList;
125 fBlockList = NULL;
126}
127
128/*
129 * ---------------------------------------------------------------------------------
130 * Source Handling
131 * ---------------------------------------------------------------------------------
132 */
133
134//##################################################################################
135Int_t AliEVEHOMERManager::CreateHOMERSourcesList() {
136 // see header file for class documentation
137
138 // -- Initialize XML parser
139 if ( fXMLParser != NULL )
140 delete fXMLParser;
141 fXMLParser = NULL;
142
143 fXMLParser = new TDOMParser();
144 fXMLParser->SetValidate( kFALSE );
145
146 Int_t iResult = fXMLParser->ParseFile( fXMLFile );
147 if ( iResult < 0 ) {
148 iResult = 1;
149 AliError( Form("Parsing file with error: %s", fXMLParser->GetParseCodeMessage( fXMLParser->GetParseCode() )) );
150 return iResult;
151 }
152
153 // -- Initialize sources list
154 DestroyElements();
155 if ( fSourceList != NULL )
156 delete fSourceList;
157 fSourceList = NULL;
158
159 fSourceList = new TList();
160 fSourceList->SetOwner( kTRUE );
161
162 // -- Set ROOT node
163 fRootNode = fXMLParser->GetXMLDocument()->GetRootNode();
164
165 TXMLNode * node = NULL;
166 TXMLNode * prevNode = fRootNode->GetChildren();
167
168 // -- Loop over all nodes
169 while ( ( node = prevNode->GetNextNode() ) ) {
170 prevNode = node;
171
172 // -- Find only "Process" nodes, otherwise continue to next node
173 if ( strcmp( node->GetNodeName(), "Proc" ) != 0 )
174 continue;
175
176 // -- Get Attributes of current node
177 TList *attrList = node->GetAttributes();
178 TXMLAttr *attr = 0;
179 TIter next(attrList);
180
181 while ( ( attr = (TXMLAttr*)next() ) ) {
182
183 // -- Find "ID" attribute, otherwise continue to next attribute
184 if ( strcmp( attr->GetName(), "ID" ) != 0 )
185 continue;
186
187 TString nodeId( attr->GetValue() );
188
189 // -- Find only TDS processes
190 if ( nodeId.BeginsWith( "TDS_" ) ) {
191 iResult = GetTDSAttributes( node->GetChildren() );
192 if ( iResult ) {
193 AliError( Form("Error processing TDS process : %s", nodeId.Data()) );
194 }
195 }
196
197 } // while ( ( attr = (TXMLAttr*)next() ) ) {
198
199 } // while ( ( node = prevNode->GetNextNode() ) ) {
200
201 // -- New SourceList has been created --> All Sources are new --> State has changed
202 fStateHasChanged = kTRUE;
203
204 TIter next(fSourceList);
205 AliHLTHOMERSourceDesc* src = 0;
206 while ((src = (AliHLTHOMERSourceDesc*) next())) {
207 Reve::RenderElementObjPtr* re = new Reve::RenderElementObjPtr(src, kFALSE);
208 re->SetRnrElNameTitle
209 (Form("%s-%s-%s %s", src->GetDetector().Data(), src->GetSubDetector().Data(),
210 src->GetSubSubDetector().Data(), src->GetDataType().Data()),
211 "Title");
212 AddElement(re);
213 }
214
215 if ( iResult ) {
216 AliWarning( Form("There have been errors, while creating the sources list.") );
217 }
218 else {
219 AliInfo( Form("New sources list created.") );
220 }
221
222 return iResult;
223}
224
225//##################################################################################
226void AliEVEHOMERManager::SetSourceState( AliHLTHOMERSourceDesc * source, Bool_t state ) {
227 // see header file for class documentation
228
229 if ( source->IsSelected() != state ) {
230 source->SetState( state );
231 fStateHasChanged = kTRUE;
232 }
233
234 return;
235}
236
237//##################################################################################
238Int_t AliEVEHOMERManager::GetTDSAttributes( TXMLNode * xmlNode ) {
239 // see header file for class documentation
240
241 Int_t iResult = 0;
242
243 TXMLNode * attrNode = NULL;
244 TXMLNode * prevNode = xmlNode;
245
246 TString xmlHostname = 0;
247 TString xmlPort = 0;
248
249 TString hostname = 0;
250 Int_t port = 0;
251
252 // -- Get hostname and port from TDS node out of XML
253 while ( ( attrNode = prevNode->GetNextNode() ) ) {
254 prevNode = attrNode;
255
256 // -- Get port out of the commandline
257 if ( strcmp( attrNode->GetNodeName(), "Cmd" ) == 0 ) {
258 TString cmd( attrNode->GetText() );
259
260 TObjArray * cmdTok = cmd.Tokenize(" ");
261 xmlPort = ((TObjString*) cmdTok->At(2))->GetString();
262 }
263 // -- Get hostname
264 else if ( strcmp( attrNode->GetNodeName(), "Node" ) == 0 )
265 xmlHostname = attrNode->GetText();
266
267 } // while ( ( attrNode = prevNode->GetNextNode() ) ) {
268
269 // -- Resolve hostname and port information
270 iResult = ResolveHostPortInformation ( xmlHostname, xmlPort, hostname, port );
271 if ( iResult == 1 ) {
272 AliError( Form("Error resolving hostname : %s", xmlHostname.Data()) );
273 return iResult;
274 }
275 else if ( iResult == 2 ) {AliInfo( Form("Connection established") );
276 AliError( Form("Error resolving port : %s", xmlPort.Data()) );
277 return iResult;
278 }
279
280 // -- Reset loop to TDS node
281 prevNode = xmlNode;
282
283 // -- Get Sources out of XML, resolve sources, add to sources ListxmlHostname.Data()
284 while ( ( attrNode = prevNode->GetNextNode() ) ) {
285 prevNode = attrNode;
286
287 // Find only "Parent" tags, otherwise continue to next tag
288 if ( strcmp( attrNode->GetNodeName(), "Parent" ) != 0 )
289 continue;
290
291 TString xmlParent = attrNode->GetText();
292
293 AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc( hostname, port );
294
295 if ( ResolveSourceInformation( xmlParent, source ) ) {
296 iResult = 3;
297 AliError( Form("Error resolving source : %s", xmlParent.Data()) );
298
299 delete source;
300 }
301 else {
302 fSourceList->Add( source );
303 AliInfo( Form("New Source added : %s", xmlParent.Data()) );
304 }
305
306 } // while ( ( attrNode = prevNode->GetNextNode() ) ) {
307
308 return iResult;
309}
310
311//##################################################################################
312Int_t AliEVEHOMERManager::ResolveHostPortInformation ( TString xmlHostname, TString xmlPort, TString &hostname, Int_t &port ) {
313 // see header file for class documentation
314
315 Int_t iResult = 1;
316
317 // *** Resolve hostname
318
319 TXMLNode * node = NULL;
320 TXMLNode * prevNode = fRootNode->GetChildren();
321
322 while ( ( node = prevNode->GetNextNode() ) && iResult == 1 ) {
323 prevNode = node;
324
325 // -- Find only "Node" nodes, otherwise continue
326 if ( strcmp( node->GetNodeName(), "Node" ) != 0 )
327 continue;
328
329 // -- Get Attributes of current node
330 TList *attrList = node->GetAttributes();
331 TXMLAttr *attr = 0;
332 TIter next(attrList);
333
334 TString nodeId = 0;
335 TString nodeName = 0;
336
337 // Get "nodeID" and "nodeName" of this "Node" node
338 while ( ( attr = (TXMLAttr*)next() ) ) {
339 if ( strcmp( attr->GetName(), "ID" ) == 0 )
340 nodeId = attr->GetValue();
341 else if ( strcmp( attr->GetName(), "hostname" ) == 0 )
342 nodeName = attr->GetValue();
343 }
344
345 // -- if this is not the correct nodeID continue
346 if ( nodeId != xmlHostname )
347 continue;
348
349 // -- Set hostname
350 hostname = nodeName;
351 iResult = 0;
352
353 break;
354
355 } // while ( ( node = prevNode->GetNextNode() ) ) {
356
357 if ( iResult ) {
358 AliError( Form("Error resolving hostname : %s", xmlHostname.Data()) );
359 return iResult;
360 }
361
362 // *** Resolve port
363
364 if ( xmlPort.IsDigit() ) {
365 port = xmlPort.Atoi();
366 }
367 else {
368 AliError ( Form("Error resolving port : %s", xmlPort.Data()) );
369 iResult = 2;
370 }
371
372 // *** Summary
373
374 if ( !iResult ) {
375 AliInfo( Form("%s:%i resolved out of %s:%s", hostname.Data(), port, xmlHostname.Data(), xmlPort.Data()) );
376 }
377
378 return iResult;
379}
380
381//##################################################################################
382Int_t AliEVEHOMERManager::ResolveSourceInformation( TString xmlParent, AliHLTHOMERSourceDesc *source ) {
383 // see header file for class documentation
384
385 Int_t iResult = 0;
386
387 if ( ! xmlParent.Contains( "_" ) ) {
388 AliError( Form("Source %s could not be resolved", xmlParent.Data() ) );
389 iResult = 1;
390
391 return iResult;
392 }
393
394 TObjArray * parentTokens = xmlParent.Tokenize("_");
395
396 Int_t nEntries = parentTokens->GetEntries();
397
398 TString detector = ((TObjString*) parentTokens->At(0) )->GetString();
399 TString subDetector = "";
400 TString subSubDetector = "";
401 TString dataType = "";
402 ULong_t specification = 0;
403
404 TString name = ((TObjString*) parentTokens->At(1) )->GetString();
405 TString objName = "";
406
407 if ( nEntries == 3 )
408 subDetector = ((TObjString*) parentTokens->At(2) )->GetString();
409 else if ( nEntries == 4 ) {
410 subDetector = ((TObjString*) parentTokens->At(2) )->GetString();
411 subSubDetector = ((TObjString*) parentTokens->At(3) )->GetString();
412 }
413
414 // -- Corecct TPC subdetector, because in we have somtimes "A","C"
415 if ( ! detector.CompareTo("TPC") ) {
416 if ( subDetector.BeginsWith('A') ) {
417 subDetector.Remove( TString::kLeading, 'A' );
418 }
419 else if ( subDetector.BeginsWith('C') ) {
420 subDetector.Remove( TString::kLeading, 'C' );
421 Int_t tmp = subDetector.Atoi() + 18;
422 subDetector = "";
423 subDetector += tmp;
424 }
425 }
426
427 // -- Remove Leading '0' in sub detector and subsubdetector
428 subDetector.Remove( TString::kLeading, '0' );
429 subSubDetector.Remove( TString::kLeading, '0' );
430
431 // -- Set Object Names
432
433 // **** General ****
434 if ( name == "RP" || name == "FP" ) {
435 objName = "";
436 dataType = "DDL_RAW";
437 specification = 0;
438 }
439
440 // **** TPC ****
441 else if ( detector == "TPC" ) {
442
443 if ( name == "CalibPedestal" ) {
444 objName = "AliTPCCalibPedestal";
445 dataType = "HIS_CAL";
446 specification = 0;
447 }
448 else if ( name == "CalibPulser" ) {
449 objName = "AliTPCCalibPulser";
450 dataType = "HIS_CAL";
451 specification = 0;
452 }
453 } // if ( detector == "TPC" ) {
454
455 // **** TRD ****
456 else if ( detector == "TRD" ) {
457
458 if ( name == "foo" ) {
459 objName = "bar";
460 dataType = "FOO_BAR";
461 specification = 0;
462 }
463 } // else if ( detector == "TRD" ) {
464
465 // **** PHOS ****
466 else if ( detector == "PHOS" ) {
467
468 } // else if ( detector == "PHOS" ) {
469
470 // **** DIMU ****
471 else if ( detector == "MUON" ) {
472
473 } // else if ( detector == "MUON" ) {
474
475 // -- Fill object
476 source->SetSourceName( name, objName );
477 source->SetSourceType( specification, dataType );
478 source->SetDetectors( detector, subDetector, subSubDetector );
479
480
481 AliInfo( Form("Set Source %s , Type %s, ClassName %s .", name.Data(), dataType.Data(), objName.Data()) );
482
483 return iResult;
484}
485
486/*
487 * ---------------------------------------------------------------------------------
488 * Connection Handling
489 * ---------------------------------------------------------------------------------
490 */
491
492//##################################################################################
493Int_t AliEVEHOMERManager::ConnectHOMER(){
494 // see header file for class documentation
495
496 Int_t iResult = 0;
497
498 // -- Check if already connected and state has not changed
499 if ( fStateHasChanged == kFALSE && IsConnected() ) {
500 AliInfo( Form("No need for reconnection.") );
501 return iResult;
502 }
503
504 // -- If already connected, disconnect before connect
505 if ( IsConnected() )
506 DisconnectHOMER();
507
508 // *** Create the Readoutlist
509
510 UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()];
511 const char ** sourceHostnames = new const char* [fSourceList->GetEntries()];
512 UInt_t sourceCount = 0;
513
514 CreateReadoutList( sourceHostnames, sourcePorts, sourceCount );
515
516 if ( sourceCount == 0 ) {
517 AliError(Form("No sources selected, aborting.") );
518 return iResult;
519 }
520
521 // *** Connect to data sources
522
523 if ( !fReader ) {
524 if ( fLibManager )
525 fReader = fLibManager->OpenReader( sourceCount, sourceHostnames, sourcePorts );
526 }
527
528 iResult = fReader->GetConnectionStatus();
529
530 if ( iResult ) {
531 // -- Connection failed
532
533 UInt_t ndx = fReader->GetErrorConnectionNdx();
534
535 if ( ndx < sourceCount ) {
536 AliError( Form("Error : Error establishing connection to TCP source %s:%hu: %s (%d)",
537 sourceHostnames[ndx], sourcePorts[ndx], strerror(iResult), iResult) );
538 }
539 else {
540 AliError( Form("Error : Error establishing connection to unknown source with index %d: %s (%d)",
541 ndx, strerror(iResult), iResult) );
542 }
543
544 if ( fReader )
545 fLibManager->DeleteReader( fReader );
546 fReader = NULL;
547
548 }
549 else {
550 // -- Connection ok - set reader
551 fConnected = kTRUE;
552
553 AliInfo( Form("Connection established") );
554 }
555
556 delete[] sourceHostnames;
557 delete[] sourcePorts;
558
559
560 // -- Get next event
561 if ( ! iResult )
562 NextEvent();
563
564 return iResult;
565}
566
567//##################################################################################
568void AliEVEHOMERManager::DisconnectHOMER(){
569 // see header file for class documentation
570
571 if ( ! IsConnected() )
572 return;
573
574 if ( fReader )
575 fLibManager->DeleteReader( fReader );
576 fReader = NULL;
577
578 fStateHasChanged = kTRUE;
579 fConnected = kFALSE;
580
581 AliInfo( Form("Connection closed") );
582
583 return;
584}
585
586//##################################################################################
587Int_t AliEVEHOMERManager::ReconnectHOMER(){
588 // see header file for class documentation
589
590 Int_t iResult = 0;
591
592 if ( IsConnected() )
593 DisconnectHOMER();
594
595 iResult = ConnectHOMER();
596 if ( iResult ) {
597 AliError( Form("Error connecting.") );
598 }
599
600 return iResult;
601}
602
603
604//##################################################################################
605void AliEVEHOMERManager::CreateReadoutList( const char** sourceHostnames, UShort_t *sourcePorts, UInt_t &sourceCount ){
606 // see header file for class documentation
607
608 AliHLTHOMERSourceDesc * source= NULL;
609
610 // -- Read all sources and check if they should be read out
611 TIter next( fSourceList );
612 while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
613
614 if ( ! source->IsSelected() )
615 continue;
616
617 Bool_t exists = kFALSE;
618
619 // -- Loop over existing entries and check if entry is already in readout list
620 for ( UInt_t ii = 0; ii < sourceCount; ii++ ){
621 if ( !strcmp( sourceHostnames[ii], source->GetHostname().Data() ) && sourcePorts[ii] == source->GetPort() ) {
622 exists = kTRUE;
623 break;
624 }
625 }
626
627 // -- Add new entires to readout list
628 if ( ! exists ) {
629 sourcePorts[sourceCount] = source->GetPort();
630 sourceHostnames[sourceCount] = source->GetHostname().Data();
631 sourceCount++;
632 }
633
634 } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
635
636 fStateHasChanged = kFALSE;
637
638 return;
639}
640
641/*
642 * ---------------------------------------------------------------------------------
643 * Event Handling
644 * ---------------------------------------------------------------------------------
645 */
646
647//##################################################################################
648Int_t AliEVEHOMERManager::NextEvent(){
649 // see header file for class documentation
650
651 Int_t iResult = 0;
652
653 if ( !fReader || ! IsConnected() ) {
654 AliWarning( Form( "Not connected yet." ) );
655 return 1;
656 }
657
658 // -- Read next event data and error handling for HOMER (error codes and empty blocks)
659 while( 1 ) {
660 iResult = fReader->ReadNextEvent( 5000000 /*timeout in us*/);
661
662 if ( iResult == 111 || iResult == 32 || iResult == 6 ) {
663 Int_t ndx = fReader->GetErrorConnectionNdx();
664 AliError( Form("Error, No Connection to source %d: %s (%d)", ndx, strerror(iResult), iResult) );
665
666 return 2;
667 }
668 else if ( iResult == 110 ) {
669 Int_t ndx = fReader->GetErrorConnectionNdx();
670 AliError( Form("Timout occured, reading event from source %d: %s (%d)", ndx, strerror(iResult), iResult) );
671 return 3;
672 }
673 else if ( iResult == 56) {
674 Int_t ndx = fReader->GetErrorConnectionNdx();
675 AliError( Form("Error reading event from source %d: %s (%d) -- IRESULTRY", ndx, strerror(iResult), iResult) );
676 continue;
677 }
678 else if ( iResult ) {
679 Int_t ndx = fReader->GetErrorConnectionNdx();
680 AliError( Form("General Error reading event from source %d: %s (%d)", ndx, strerror(iResult), iResult) );
681 return 2;
682 }
683 else {
684 break;
685 }
686 } // while( 1 ) {
687
688 if ( iResult )
689 return iResult;
690
691
692 // -- Get blockCnt and eventID
693 fNBlks = (ULong_t) fReader->GetBlockCnt();
694 fEventID = (ULong64_t) fReader->GetEventID();
695 fCurrentBlk = 0;
696
697 AliInfo( Form("Event 0x%016LX (%Lu) with %lu blocks", fEventID, fEventID, fNBlks) );
698
699#if 0
700 /*
701 // Loop for Debug only
702 for ( ULong_t i = 0; i < fNBlks; i++ ) {
703 Char_t tmp1[9], tmp2[5];
704 memset( tmp1, 0, 9 );
705 memset( tmp2, 0, 5 );
706 void *tmp11 = tmp1;
707 ULong64_t* tmp12 = (ULong64_t*)tmp11;
708 *tmp12 = fReader->GetBlockDataType( i );
709 void *tmp21 = tmp2;
710 ULong_t* tmp22 = (ULong_t*)tmp21;
711 *tmp22 = fReader->GetBlockDataOrigin( i );
712 AliInfo( Form("Block %lu length: %lu - type: %s - origin: %s",i, fReader->GetBlockDataLength( i ), tmp1, tmp2) );
713 } // end for ( ULong_t i = 0; i < fNBlks; i++ ) {
714 */
715#endif
716
717 // -- Create BlockList
718 CreateBlockList();
719
720 return iResult;
721}
722
723//##################################################################################
724Int_t AliEVEHOMERManager::CreateBlockList() {
725 // see header file for class documentation
726
727 Int_t iResult = 0;
728
729 // -- Initialize block list
730 if ( fBlockList != NULL )
731 delete fBlockList;
732 fBlockList = NULL;
733
734 fBlockList = new TList();
735 fBlockList->SetOwner( kTRUE );
736
737 void* iter = GetFirstBlk();
738
739 // -- Fill block list
740 while ( iter != NULL ){
741
742 // -- Create new block
743 AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc( GetBlk(), GetBlkSize(), GetBlkOrigin(),
744 GetBlkType(), GetBlkSpecification() );
745
746 // -- Check sources list if block is requested
747 if ( CheckIfRequested( block ) )
748 fBlockList->Add( block );
749 else
750 delete block;
751
752 iter = GetNextBlk();
753
754 } // while ( iter != NULL ){
755
756 return iResult;
757}
758
759/*
760 * ---------------------------------------------------------------------------------
761 * BlockHandling
762 * ---------------------------------------------------------------------------------
763 */
764
765//##################################################################################
766void* AliEVEHOMERManager::GetBlk( Int_t ndx ) {
767 // see header file for class documentation
768
769 void* data = NULL;
770
771 if ( !fReader || ! IsConnected() ) {
772 AliError( Form("Not connected yet.") );
773 }
774 else {
775 if ( ( ndx ) < (Int_t) fNBlks )
776 data = (void*) fReader->GetBlockData( ndx );
777 }
778
779 return data;
780}
781
782//##################################################################################
783ULong_t AliEVEHOMERManager::GetBlkSize( Int_t ndx ) {
784 // see header file for class documentation
785
786 ULong_t length = 0;
787
788 if ( !fReader || ! IsConnected() ) {
789 AliError( Form("Not connected yet.") );
790 }
791 else {
792 if ( ( ndx ) < (Int_t) fNBlks )
793 length = (ULong_t) fReader->GetBlockDataLength( ndx );
794 }
795
796 return length;
797}
798
799//##################################################################################
800TString AliEVEHOMERManager::GetBlkOrigin( Int_t ndx ) {
801 // see header file for class documentation
802
803 TString origin = "";
804
805 // -- Check for Connection
806 if ( !fReader || ! IsConnected() ) {
807 AliError( Form("Not connected yet.") );
808 return origin;
809 }
810
811 // -- Check block index
812 if ( ( ndx ) >= (Int_t) fNBlks ) {
813 AliError( Form("Block index %d out of range.", ndx ) );
814 return origin;
815 }
816
817 // -- Get origin
818 union{
819 UInt_t data;
820 Char_t array[4];
821 } reverseOrigin;
822
823 reverseOrigin.data = (UInt_t) fReader->GetBlockDataOrigin( ndx );
824
825 // -- Reverse the order
826 for (Int_t ii = 3; ii >= 0; ii-- )
827 if ( reverseOrigin.array[ii] != ' ')
828 origin.Append( reverseOrigin.array[ii] );
829
830 return origin;
831}
832
833//##################################################################################
834TString AliEVEHOMERManager:: GetBlkType( Int_t ndx ) {
835 // see header file for class documentation
836
837 TString type = "";
838
839 // -- Check for Connection
840 if ( !fReader || ! IsConnected() ) {
841 AliError( Form("Not connected yet.") );
842 return type;
843 }
844
845 // -- Check blockk index
846 if ( ( ndx ) >= (Int_t) fNBlks ) {
847 AliError( Form("Block index %d out of range.", ndx ) );
848 return type;
849 }
850
851 // -- Get type
852 union{
853 ULong64_t data;
854 Char_t array[8];
855 } reverseType;
856
857 reverseType.data = (ULong64_t) fReader->GetBlockDataType( ndx );
858
859 // -- Reverse the order
860 for (Int_t ii = 7; ii >= 0; ii-- )
861 if ( reverseType.array[ii] != ' ')
862 type.Append( reverseType.array[ii] );
863
864 return type;
865}
866
867
868//##################################################################################
869ULong_t AliEVEHOMERManager:: GetBlkSpecification( Int_t ndx ) {
870 // see header file for class documentation
871
872 ULong_t spec = 0;
873
874
875 // -- Check for Connection
876 if ( !fReader || ! IsConnected() ) {
877 AliError( Form("Not connected yet.") );
878 return spec;
879 }
880
881 // -- Check blockk index
882 if ( ( ndx ) >= (Int_t) fNBlks ) {
883 AliError( Form("Block index %d out of range.", ndx ) );
884 return spec;
885 }
886
887 spec = (ULong_t) fReader->GetBlockDataSpec( ndx );
888
889 return spec;
890}
891
892//##################################################################################
893Bool_t AliEVEHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) {
894 // see header file for class documentation
895
896 Bool_t requested = kFALSE;
897
898 AliHLTHOMERSourceDesc * source= NULL;
899
900 // -- Read all sources and check if they should be read out
901 TIter next( fSourceList );
902 while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
903
904 if ( ! source->IsSelected() )
905 continue;
906
907 if ( source->GetDetector().CompareTo( block->GetDetector() ) )
908 continue;
909
910 if ( source->GetDataType().CompareTo( block->GetDataType() ) )
911 continue;
912
913 if ( ! block->HasSubDetectorRange() ) {
914
915 if ( source->GetSubDetector().CompareTo( block->GetSubDetector() ) )
916 continue;
917
918 if ( ! block->HasSubSubDetectorRange() ) {
919
920 if ( source->GetSubSubDetector().CompareTo( block->GetSubSubDetector() ) )
921 continue;
922
923 } // if ( ! block->HasSubSubDetectorRange ) {
924 } // if ( ! block->HasSubDetectorRange ) {
925
926 requested = kTRUE;
927
928 } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
929
930 if ( requested) {
931 AliInfo( Form("Block requested : %s - %s : %s/%s -> %s ", block->GetDetector().Data(), block->GetDataType().Data(),
932 block->GetSubDetector().Data(), block->GetSubSubDetector().Data(), block->GetClassName().Data() ) );
933 }
934
935 return requested;
936}
937
938//##################################################################################
939void AliEVEHOMERManager::TestSelect() {
940 // see header file for class documentation
941
942 for (Int_t ii =0; ii < fSourceList->GetEntries() ; ii++ ) {
943 if ( (ii%2) == 0 )
944 ((AliHLTHOMERSourceDesc*) fSourceList->At(ii))->Select();
945 }
946}
947
948