]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/AliEveHOMERManager.cxx
Comment code, hide public data-members.
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEveHOMERManager.cxx
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
059c30e4 9/**************************************************************************
10 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
11 * *
12 * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
13 * for The ALICE HLT Project. *
14 * *
15 * Permission to use, copy, modify and distribute this software and its *
16 * documentation strictly for non-commercial purposes is hereby granted *
17 * without fee, provided that the above copyright notice appears in all *
18 * copies and that both the copyright notice and this permission notice *
19 * appear in the supporting documentation. The authors make no claims *
20 * about the suitability of this software for any purpose. It is *
21 * provided "as is" without express or implied warranty. *
22 **************************************************************************/
23
d810d0de 24/** @file AliEveHOMERManager.cxx
059c30e4 25 @author Jochen Thaeder
26 @date
27 @brief Manger for HOMER in offline
28*/
29
30#if __GNUC__>= 3
31 using namespace std;
32#endif
33
d810d0de 34#include "AliEveHOMERManager.h"
059c30e4 35
36#define use_aliroot
37#define use_root
38#define ROWHOUGHPARAMS
39#define use_reconstruction
40#define use_newio
41#define ROOTVERSION "unchecked"
42#define ALIROOTVERSION "unchecked"
43#define __ROOT__
44#define USE_ALILOG
45#define LINUX
46
47#include "AliHLTHOMERLibManager.h"
48
49#include "AliHLTHOMERSourceDesc.h"
50#include "AliHLTHOMERBlockDesc.h"
51
d810d0de 52#include "AliEveHOMERSource.h"
6612c5b3 53
059c30e4 54#include "AliLog.h"
55
56#include "TString.h"
57#include <TApplication.h>
58#include "Riostream.h"
59#include "TXMLAttr.h"
60#include "TCollection.h"
61#include "TList.h"
62#include "TObjString.h"
63#include "TObjArray.h"
64
6612c5b3 65// ------------
66#include "AliTPCCalibPedestal.h"
67#include "AliTPCCalibPulser.h"
68#include "AliTPCCalibCE.h"
69#include "AliTPCPreprocessorOnline.h"
70#include "AliTPCCalROC.h"
71// ------------
d810d0de 72ClassImp(AliEveHOMERManager)
059c30e4 73
74/*
75 * ---------------------------------------------------------------------------------
76 * Constructor / Destructor
77 * ---------------------------------------------------------------------------------
78 */
79
80//##################################################################################
d810d0de 81AliEveHOMERManager::AliEveHOMERManager( TString xmlFile ) :
82 TEveElementList("AliEveHOMERManager"),
059c30e4 83
84 fLibManager(new AliHLTHOMERLibManager),
85 fXMLFile(xmlFile),
86 fXMLParser(NULL),
87 fRootNode(NULL),
88 fSourceList(NULL),
89 fReader(NULL),
90 fBlockList(NULL),
91 fNBlks(0),
92 fEventID(0),
93 fCurrentBlk(0),
94 fConnected(kFALSE),
6612c5b3 95 fStateHasChanged(kTRUE),
96 fTPCPre(NULL) {
059c30e4 97 // see header file for class documentation
98 // or
99 // refer to README to build package
100 // or
101 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
102}
103
104//##################################################################################
d810d0de 105AliEveHOMERManager::AliEveHOMERManager( const AliEveHOMERManager& m) :
84aff7a4 106 TEveElementList(m.GetName(), m.GetTitle())
059c30e4 107{
108 // see header file for class documentation
109
110 AliError( Form( "copy constructor to be tested." ) );
111}
112
113//##################################################################################
d810d0de 114AliEveHOMERManager& AliEveHOMERManager::operator=( const AliEveHOMERManager& ) {
059c30e4 115 // see header file for class documentation
116
117 AliError( Form( "assignment constructor to be tested." ) );
118 return *this;
119}
120
121//##################################################################################
d810d0de 122AliEveHOMERManager::~AliEveHOMERManager() {
059c30e4 123 // see header file for class documentation
124
125 if ( fLibManager ) {
126 if ( fReader )
127 fLibManager->DeleteReader(fReader);
128 delete fLibManager;
129 fLibManager = NULL;
130 fReader = NULL;
131 }
132
133 if ( fXMLParser )
134 delete fXMLParser;
135 fXMLParser = NULL;
136
137 if ( fSourceList != NULL )
138 delete fSourceList;
139 fSourceList = NULL;
140
141 if ( fBlockList != NULL )
142 delete fBlockList;
143 fBlockList = NULL;
6612c5b3 144
145 if ( fTPCPre != NULL )
146 delete fTPCPre;
147 fTPCPre = NULL;
059c30e4 148}
149
150/*
151 * ---------------------------------------------------------------------------------
152 * Source Handling
153 * ---------------------------------------------------------------------------------
154 */
155
156//##################################################################################
d810d0de 157Int_t AliEveHOMERManager::CreateHOMERSourcesList() {
059c30e4 158 // see header file for class documentation
159
160 // -- Initialize XML parser
161 if ( fXMLParser != NULL )
162 delete fXMLParser;
163 fXMLParser = NULL;
164
165 fXMLParser = new TDOMParser();
166 fXMLParser->SetValidate( kFALSE );
167
168 Int_t iResult = fXMLParser->ParseFile( fXMLFile );
169 if ( iResult < 0 ) {
170 iResult = 1;
171 AliError( Form("Parsing file with error: %s", fXMLParser->GetParseCodeMessage( fXMLParser->GetParseCode() )) );
172 return iResult;
173 }
174
175 // -- Initialize sources list
176 DestroyElements();
177 if ( fSourceList != NULL )
178 delete fSourceList;
179 fSourceList = NULL;
180
181 fSourceList = new TList();
182 fSourceList->SetOwner( kTRUE );
183
184 // -- Set ROOT node
185 fRootNode = fXMLParser->GetXMLDocument()->GetRootNode();
186
187 TXMLNode * node = NULL;
188 TXMLNode * prevNode = fRootNode->GetChildren();
189
190 // -- Loop over all nodes
191 while ( ( node = prevNode->GetNextNode() ) ) {
192 prevNode = node;
193
194 // -- Find only "Process" nodes, otherwise continue to next node
195 if ( strcmp( node->GetNodeName(), "Proc" ) != 0 )
196 continue;
197
198 // -- Get Attributes of current node
199 TList *attrList = node->GetAttributes();
200 TXMLAttr *attr = 0;
201 TIter next(attrList);
202
203 while ( ( attr = (TXMLAttr*)next() ) ) {
204
205 // -- Find "ID" attribute, otherwise continue to next attribute
206 if ( strcmp( attr->GetName(), "ID" ) != 0 )
207 continue;
208
209 TString nodeId( attr->GetValue() );
6612c5b3 210
211 // -- Find only TDS processes
212 TObjArray * nodeIdTok = nodeId.Tokenize("_");
213
214 for ( Int_t ii=0 ; ii < nodeIdTok->GetEntries() ; ii++ ) {
215 if ( ! ( (TObjString*) nodeIdTok->At(ii) )->GetString().CompareTo("TDS") ) {
216 iResult = GetTDSAttributes( node->GetChildren() );
217 if ( iResult ) {
218 AliError( Form("Error processing TDS process : %s", nodeId.Data()) );
219 }
059c30e4 220 }
6612c5b3 221 }
059c30e4 222 } // while ( ( attr = (TXMLAttr*)next() ) ) {
223
224 } // while ( ( node = prevNode->GetNextNode() ) ) {
225
226 // -- New SourceList has been created --> All Sources are new --> State has changed
227 fStateHasChanged = kTRUE;
228
229 TIter next(fSourceList);
230 AliHLTHOMERSourceDesc* src = 0;
231 while ((src = (AliHLTHOMERSourceDesc*) next())) {
d810d0de 232 AliEveHOMERSource* re = new AliEveHOMERSource
6612c5b3 233 (src,
234 Form("%s-%s-%s %s", src->GetDetector().Data(), src->GetSubDetector().Data(),
059c30e4 235 src->GetSubSubDetector().Data(), src->GetDataType().Data()),
6612c5b3 236 "Title?\nNot.");
059c30e4 237 AddElement(re);
238 }
239
240 if ( iResult ) {
241 AliWarning( Form("There have been errors, while creating the sources list.") );
242 }
243 else {
244 AliInfo( Form("New sources list created.") );
245 }
246
247 return iResult;
248}
249
250//##################################################################################
d810d0de 251void AliEveHOMERManager::SetSourceState( AliHLTHOMERSourceDesc * source, Bool_t state ) {
059c30e4 252 // see header file for class documentation
253
254 if ( source->IsSelected() != state ) {
255 source->SetState( state );
256 fStateHasChanged = kTRUE;
257 }
258
259 return;
260}
261
262//##################################################################################
d810d0de 263Int_t AliEveHOMERManager::GetTDSAttributes( TXMLNode * xmlNode ) {
059c30e4 264 // see header file for class documentation
265
266 Int_t iResult = 0;
267
268 TXMLNode * attrNode = NULL;
269 TXMLNode * prevNode = xmlNode;
270
271 TString xmlHostname = 0;
272 TString xmlPort = 0;
273
274 TString hostname = 0;
275 Int_t port = 0;
276
277 // -- Get hostname and port from TDS node out of XML
278 while ( ( attrNode = prevNode->GetNextNode() ) ) {
279 prevNode = attrNode;
280
281 // -- Get port out of the commandline
282 if ( strcmp( attrNode->GetNodeName(), "Cmd" ) == 0 ) {
283 TString cmd( attrNode->GetText() );
284
285 TObjArray * cmdTok = cmd.Tokenize(" ");
286 xmlPort = ((TObjString*) cmdTok->At(2))->GetString();
287 }
288 // -- Get hostname
289 else if ( strcmp( attrNode->GetNodeName(), "Node" ) == 0 )
290 xmlHostname = attrNode->GetText();
291
292 } // while ( ( attrNode = prevNode->GetNextNode() ) ) {
293
294 // -- Resolve hostname and port information
295 iResult = ResolveHostPortInformation ( xmlHostname, xmlPort, hostname, port );
296 if ( iResult == 1 ) {
297 AliError( Form("Error resolving hostname : %s", xmlHostname.Data()) );
298 return iResult;
299 }
300 else if ( iResult == 2 ) {AliInfo( Form("Connection established") );
301 AliError( Form("Error resolving port : %s", xmlPort.Data()) );
302 return iResult;
303 }
304
305 // -- Reset loop to TDS node
306 prevNode = xmlNode;
307
308 // -- Get Sources out of XML, resolve sources, add to sources ListxmlHostname.Data()
309 while ( ( attrNode = prevNode->GetNextNode() ) ) {
310 prevNode = attrNode;
311
312 // Find only "Parent" tags, otherwise continue to next tag
313 if ( strcmp( attrNode->GetNodeName(), "Parent" ) != 0 )
314 continue;
315
316 TString xmlParent = attrNode->GetText();
317
318 AliHLTHOMERSourceDesc * source = new AliHLTHOMERSourceDesc( hostname, port );
319
320 if ( ResolveSourceInformation( xmlParent, source ) ) {
321 iResult = 3;
322 AliError( Form("Error resolving source : %s", xmlParent.Data()) );
323
324 delete source;
325 }
326 else {
327 fSourceList->Add( source );
328 AliInfo( Form("New Source added : %s", xmlParent.Data()) );
329 }
330
331 } // while ( ( attrNode = prevNode->GetNextNode() ) ) {
332
333 return iResult;
334}
335
336//##################################################################################
d810d0de 337Int_t AliEveHOMERManager::ResolveHostPortInformation ( TString xmlHostname, TString xmlPort, TString &hostname, Int_t &port ) {
059c30e4 338 // see header file for class documentation
339
340 Int_t iResult = 1;
341
342 // *** Resolve hostname
343
344 TXMLNode * node = NULL;
345 TXMLNode * prevNode = fRootNode->GetChildren();
6612c5b3 346 TString nodeName = 0;
059c30e4 347 while ( ( node = prevNode->GetNextNode() ) && iResult == 1 ) {
348 prevNode = node;
349
350 // -- Find only "Node" nodes, otherwise continue
351 if ( strcmp( node->GetNodeName(), "Node" ) != 0 )
352 continue;
353
354 // -- Get Attributes of current node
355 TList *attrList = node->GetAttributes();
356 TXMLAttr *attr = 0;
357 TIter next(attrList);
358
359 TString nodeId = 0;
6612c5b3 360 // TString nodeName = 0;
059c30e4 361
362 // Get "nodeID" and "nodeName" of this "Node" node
363 while ( ( attr = (TXMLAttr*)next() ) ) {
364 if ( strcmp( attr->GetName(), "ID" ) == 0 )
365 nodeId = attr->GetValue();
366 else if ( strcmp( attr->GetName(), "hostname" ) == 0 )
367 nodeName = attr->GetValue();
368 }
369
370 // -- if this is not the correct nodeID continue
371 if ( nodeId != xmlHostname )
372 continue;
373
374 // -- Set hostname
6612c5b3 375
376 // TEMP FIX
377 // hostname = nodeName;
378 hostname = "alihlt-dcs0";
379
059c30e4 380 iResult = 0;
381
382 break;
383
384 } // while ( ( node = prevNode->GetNextNode() ) ) {
385
386 if ( iResult ) {
387 AliError( Form("Error resolving hostname : %s", xmlHostname.Data()) );
388 return iResult;
389 }
390
391 // *** Resolve port
392
393 if ( xmlPort.IsDigit() ) {
6612c5b3 394
395 if ( nodeName.CompareTo("feptriggerdet") ==0 ){
396 if ( xmlPort.CompareTo("49152") == 0 ){
397 port = 58140;
398 } else if ( xmlPort.CompareTo("49153") == 0 ){
399 port = 58141;
400 }
401 } else if ( nodeName.CompareTo("fepfmdaccorde") == 0 ){
402 if ( xmlPort.CompareTo("49152") == 0 ){
403 port = 58144;
404 } else if ( xmlPort.CompareTo("49153") == 0 ){
405 port = 58145;
406 }
407 } else if ( nodeName.CompareTo("feptpcao15") == 0 ){
408 if ( xmlPort.CompareTo("49152") == 0 ){
409 port = 50340;
410 } else if ( xmlPort.CompareTo("49153") == 0 ){
411 port = 50341;
412 }
413 } else if ( nodeName.CompareTo("alihlt-dcs0") == 0 ){
414 port = xmlPort.Atoi();
415 }
059c30e4 416 }
417 else {
418 AliError ( Form("Error resolving port : %s", xmlPort.Data()) );
419 iResult = 2;
420 }
421
422 // *** Summary
423
424 if ( !iResult ) {
425 AliInfo( Form("%s:%i resolved out of %s:%s", hostname.Data(), port, xmlHostname.Data(), xmlPort.Data()) );
426 }
427
428 return iResult;
429}
430
431//##################################################################################
d810d0de 432Int_t AliEveHOMERManager::ResolveSourceInformation( TString xmlParent, AliHLTHOMERSourceDesc *source ) {
059c30e4 433 // see header file for class documentation
434
435 Int_t iResult = 0;
436
437 if ( ! xmlParent.Contains( "_" ) ) {
438 AliError( Form("Source %s could not be resolved", xmlParent.Data() ) );
439 iResult = 1;
440
441 return iResult;
442 }
443
444 TObjArray * parentTokens = xmlParent.Tokenize("_");
445
446 Int_t nEntries = parentTokens->GetEntries();
447
448 TString detector = ((TObjString*) parentTokens->At(0) )->GetString();
449 TString subDetector = "";
450 TString subSubDetector = "";
451 TString dataType = "";
452 ULong_t specification = 0;
453
454 TString name = ((TObjString*) parentTokens->At(1) )->GetString();
455 TString objName = "";
456
457 if ( nEntries == 3 )
458 subDetector = ((TObjString*) parentTokens->At(2) )->GetString();
459 else if ( nEntries == 4 ) {
460 subDetector = ((TObjString*) parentTokens->At(2) )->GetString();
461 subSubDetector = ((TObjString*) parentTokens->At(3) )->GetString();
462 }
463
464 // -- Corecct TPC subdetector, because in we have somtimes "A","C"
465 if ( ! detector.CompareTo("TPC") ) {
466 if ( subDetector.BeginsWith('A') ) {
467 subDetector.Remove( TString::kLeading, 'A' );
468 }
469 else if ( subDetector.BeginsWith('C') ) {
470 subDetector.Remove( TString::kLeading, 'C' );
471 Int_t tmp = subDetector.Atoi() + 18;
472 subDetector = "";
473 subDetector += tmp;
474 }
475 }
476
477 // -- Remove Leading '0' in sub detector and subsubdetector
478 subDetector.Remove( TString::kLeading, '0' );
479 subSubDetector.Remove( TString::kLeading, '0' );
480
481 // -- Set Object Names
482
483 // **** General ****
6612c5b3 484 if ( name == "RP" || name == "FP" || name == "Relay" ) {
059c30e4 485 objName = "";
486 dataType = "DDL_RAW";
487 specification = 0;
488 }
489
490 // **** TPC ****
491 else if ( detector == "TPC" ) {
492
493 if ( name == "CalibPedestal" ) {
494 objName = "AliTPCCalibPedestal";
495 dataType = "HIS_CAL";
496 specification = 0;
497 }
498 else if ( name == "CalibPulser" ) {
499 objName = "AliTPCCalibPulser";
500 dataType = "HIS_CAL";
501 specification = 0;
502 }
6612c5b3 503 else if ( name == "CF" || name == "RelayCF" ) {
504 objName = "AliHLTTPCClusterDataFormat";
505 dataType = "CLUSTERS";
506 specification = 0;
507 }
508 else if ( name == "ESDConv" ) {
509 objName = "AliESDEvent";
510 dataType = "ESD_TREE";
511 specification = 0;
512 }
513
059c30e4 514 } // if ( detector == "TPC" ) {
515
516 // **** TRD ****
517 else if ( detector == "TRD" ) {
518
519 if ( name == "foo" ) {
520 objName = "bar";
521 dataType = "FOO_BAR";
522 specification = 0;
523 }
524 } // else if ( detector == "TRD" ) {
525
526 // **** PHOS ****
527 else if ( detector == "PHOS" ) {
528
529 } // else if ( detector == "PHOS" ) {
530
531 // **** DIMU ****
532 else if ( detector == "MUON" ) {
533
534 } // else if ( detector == "MUON" ) {
535
536 // -- Fill object
537 source->SetSourceName( name, objName );
538 source->SetSourceType( specification, dataType );
539 source->SetDetectors( detector, subDetector, subSubDetector );
540
541
542 AliInfo( Form("Set Source %s , Type %s, ClassName %s .", name.Data(), dataType.Data(), objName.Data()) );
6612c5b3 543 AliInfo( Form(" Detector %s , SubDetector : %s, SubSubDetector %s .",
544 detector.Data(), subDetector.Data(), subSubDetector.Data()) );
059c30e4 545
546 return iResult;
547}
548
549/*
550 * ---------------------------------------------------------------------------------
551 * Connection Handling
552 * ---------------------------------------------------------------------------------
553 */
554
555//##################################################################################
d810d0de 556Int_t AliEveHOMERManager::ConnectHOMER(){
059c30e4 557 // see header file for class documentation
558
559 Int_t iResult = 0;
560
561 // -- Check if already connected and state has not changed
562 if ( fStateHasChanged == kFALSE && IsConnected() ) {
563 AliInfo( Form("No need for reconnection.") );
564 return iResult;
565 }
566
567 // -- If already connected, disconnect before connect
568 if ( IsConnected() )
569 DisconnectHOMER();
570
571 // *** Create the Readoutlist
572
573 UShort_t* sourcePorts = new UShort_t [fSourceList->GetEntries()];
574 const char ** sourceHostnames = new const char* [fSourceList->GetEntries()];
575 UInt_t sourceCount = 0;
576
577 CreateReadoutList( sourceHostnames, sourcePorts, sourceCount );
578
579 if ( sourceCount == 0 ) {
580 AliError(Form("No sources selected, aborting.") );
581 return iResult;
582 }
583
584 // *** Connect to data sources
585
586 if ( !fReader ) {
587 if ( fLibManager )
588 fReader = fLibManager->OpenReader( sourceCount, sourceHostnames, sourcePorts );
589 }
590
591 iResult = fReader->GetConnectionStatus();
592
593 if ( iResult ) {
594 // -- Connection failed
595
596 UInt_t ndx = fReader->GetErrorConnectionNdx();
597
598 if ( ndx < sourceCount ) {
599 AliError( Form("Error : Error establishing connection to TCP source %s:%hu: %s (%d)",
600 sourceHostnames[ndx], sourcePorts[ndx], strerror(iResult), iResult) );
601 }
602 else {
603 AliError( Form("Error : Error establishing connection to unknown source with index %d: %s (%d)",
604 ndx, strerror(iResult), iResult) );
605 }
606
607 if ( fReader )
608 fLibManager->DeleteReader( fReader );
609 fReader = NULL;
610
611 }
612 else {
613 // -- Connection ok - set reader
614 fConnected = kTRUE;
615
616 AliInfo( Form("Connection established") );
617 }
618
619 delete[] sourceHostnames;
620 delete[] sourcePorts;
621
622
623 // -- Get next event
624 if ( ! iResult )
625 NextEvent();
626
627 return iResult;
628}
629
630//##################################################################################
d810d0de 631void AliEveHOMERManager::DisconnectHOMER(){
059c30e4 632 // see header file for class documentation
633
634 if ( ! IsConnected() )
635 return;
636
637 if ( fReader )
638 fLibManager->DeleteReader( fReader );
639 fReader = NULL;
640
641 fStateHasChanged = kTRUE;
642 fConnected = kFALSE;
643
644 AliInfo( Form("Connection closed") );
645
646 return;
647}
648
649//##################################################################################
d810d0de 650Int_t AliEveHOMERManager::ReconnectHOMER(){
059c30e4 651 // see header file for class documentation
652
653 Int_t iResult = 0;
654
655 if ( IsConnected() )
656 DisconnectHOMER();
657
658 iResult = ConnectHOMER();
659 if ( iResult ) {
660 AliError( Form("Error connecting.") );
661 }
662
663 return iResult;
664}
665
666
667//##################################################################################
d810d0de 668void AliEveHOMERManager::CreateReadoutList( const char** sourceHostnames, UShort_t *sourcePorts, UInt_t &sourceCount ){
059c30e4 669 // see header file for class documentation
670
671 AliHLTHOMERSourceDesc * source= NULL;
672
673 // -- Read all sources and check if they should be read out
674 TIter next( fSourceList );
675 while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
676
677 if ( ! source->IsSelected() )
678 continue;
679
680 Bool_t exists = kFALSE;
681
682 // -- Loop over existing entries and check if entry is already in readout list
683 for ( UInt_t ii = 0; ii < sourceCount; ii++ ){
684 if ( !strcmp( sourceHostnames[ii], source->GetHostname().Data() ) && sourcePorts[ii] == source->GetPort() ) {
685 exists = kTRUE;
686 break;
687 }
688 }
689
690 // -- Add new entires to readout list
691 if ( ! exists ) {
692 sourcePorts[sourceCount] = source->GetPort();
693 sourceHostnames[sourceCount] = source->GetHostname().Data();
694 sourceCount++;
695 }
696
697 } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
698
699 fStateHasChanged = kFALSE;
700
701 return;
702}
703
704/*
705 * ---------------------------------------------------------------------------------
d810d0de 706 * AliEveEventManager Handling
059c30e4 707 * ---------------------------------------------------------------------------------
708 */
709
710//##################################################################################
d810d0de 711Int_t AliEveHOMERManager::NextEvent(){
059c30e4 712 // see header file for class documentation
713
714 Int_t iResult = 0;
715
716 if ( !fReader || ! IsConnected() ) {
717 AliWarning( Form( "Not connected yet." ) );
718 return 1;
719 }
720
721 // -- Read next event data and error handling for HOMER (error codes and empty blocks)
722 while( 1 ) {
6612c5b3 723 iResult = fReader->ReadNextEvent( 20000000 /*timeout in us*/);
059c30e4 724
725 if ( iResult == 111 || iResult == 32 || iResult == 6 ) {
726 Int_t ndx = fReader->GetErrorConnectionNdx();
727 AliError( Form("Error, No Connection to source %d: %s (%d)", ndx, strerror(iResult), iResult) );
728
729 return 2;
730 }
731 else if ( iResult == 110 ) {
732 Int_t ndx = fReader->GetErrorConnectionNdx();
733 AliError( Form("Timout occured, reading event from source %d: %s (%d)", ndx, strerror(iResult), iResult) );
734 return 3;
735 }
736 else if ( iResult == 56) {
737 Int_t ndx = fReader->GetErrorConnectionNdx();
738 AliError( Form("Error reading event from source %d: %s (%d) -- IRESULTRY", ndx, strerror(iResult), iResult) );
739 continue;
740 }
741 else if ( iResult ) {
742 Int_t ndx = fReader->GetErrorConnectionNdx();
743 AliError( Form("General Error reading event from source %d: %s (%d)", ndx, strerror(iResult), iResult) );
744 return 2;
745 }
746 else {
747 break;
748 }
749 } // while( 1 ) {
750
751 if ( iResult )
752 return iResult;
753
754
755 // -- Get blockCnt and eventID
756 fNBlks = (ULong_t) fReader->GetBlockCnt();
757 fEventID = (ULong64_t) fReader->GetEventID();
758 fCurrentBlk = 0;
759
d810d0de 760 AliInfo( Form("AliEveEventManager 0x%016LX (%Lu) with %lu blocks", fEventID, fEventID, fNBlks) );
059c30e4 761
6612c5b3 762#if 1
763
059c30e4 764 // Loop for Debug only
765 for ( ULong_t i = 0; i < fNBlks; i++ ) {
766 Char_t tmp1[9], tmp2[5];
767 memset( tmp1, 0, 9 );
768 memset( tmp2, 0, 5 );
769 void *tmp11 = tmp1;
770 ULong64_t* tmp12 = (ULong64_t*)tmp11;
771 *tmp12 = fReader->GetBlockDataType( i );
772 void *tmp21 = tmp2;
773 ULong_t* tmp22 = (ULong_t*)tmp21;
774 *tmp22 = fReader->GetBlockDataOrigin( i );
775 AliInfo( Form("Block %lu length: %lu - type: %s - origin: %s",i, fReader->GetBlockDataLength( i ), tmp1, tmp2) );
776 } // end for ( ULong_t i = 0; i < fNBlks; i++ ) {
6612c5b3 777
059c30e4 778#endif
779
780 // -- Create BlockList
781 CreateBlockList();
782
783 return iResult;
784}
785
786//##################################################################################
d810d0de 787Int_t AliEveHOMERManager::CreateBlockList() {
059c30e4 788 // see header file for class documentation
789
790 Int_t iResult = 0;
791
792 // -- Initialize block list
793 if ( fBlockList != NULL )
794 delete fBlockList;
795 fBlockList = NULL;
796
797 fBlockList = new TList();
798 fBlockList->SetOwner( kTRUE );
799
800 void* iter = GetFirstBlk();
801
802 // -- Fill block list
803 while ( iter != NULL ){
804
805 // -- Create new block
806 AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc( GetBlk(), GetBlkSize(), GetBlkOrigin(),
807 GetBlkType(), GetBlkSpecification() );
808
809 // -- Check sources list if block is requested
810 if ( CheckIfRequested( block ) )
811 fBlockList->Add( block );
812 else
813 delete block;
814
815 iter = GetNextBlk();
816
817 } // while ( iter != NULL ){
818
819 return iResult;
820}
821
822/*
823 * ---------------------------------------------------------------------------------
824 * BlockHandling
825 * ---------------------------------------------------------------------------------
826 */
827
828//##################################################################################
d810d0de 829void* AliEveHOMERManager::GetBlk( Int_t ndx ) {
059c30e4 830 // see header file for class documentation
831
832 void* data = NULL;
833
834 if ( !fReader || ! IsConnected() ) {
835 AliError( Form("Not connected yet.") );
836 }
837 else {
838 if ( ( ndx ) < (Int_t) fNBlks )
839 data = (void*) fReader->GetBlockData( ndx );
840 }
841
842 return data;
843}
844
845//##################################################################################
d810d0de 846ULong_t AliEveHOMERManager::GetBlkSize( Int_t ndx ) {
059c30e4 847 // see header file for class documentation
848
849 ULong_t length = 0;
850
851 if ( !fReader || ! IsConnected() ) {
852 AliError( Form("Not connected yet.") );
853 }
854 else {
855 if ( ( ndx ) < (Int_t) fNBlks )
856 length = (ULong_t) fReader->GetBlockDataLength( ndx );
857 }
858
859 return length;
860}
861
862//##################################################################################
d810d0de 863TString AliEveHOMERManager::GetBlkOrigin( Int_t ndx ) {
059c30e4 864 // see header file for class documentation
865
866 TString origin = "";
867
868 // -- Check for Connection
869 if ( !fReader || ! IsConnected() ) {
870 AliError( Form("Not connected yet.") );
871 return origin;
872 }
873
874 // -- Check block index
875 if ( ( ndx ) >= (Int_t) fNBlks ) {
876 AliError( Form("Block index %d out of range.", ndx ) );
877 return origin;
878 }
879
880 // -- Get origin
881 union{
882 UInt_t data;
883 Char_t array[4];
884 } reverseOrigin;
885
886 reverseOrigin.data = (UInt_t) fReader->GetBlockDataOrigin( ndx );
887
888 // -- Reverse the order
889 for (Int_t ii = 3; ii >= 0; ii-- )
890 if ( reverseOrigin.array[ii] != ' ')
891 origin.Append( reverseOrigin.array[ii] );
892
893 return origin;
894}
895
896//##################################################################################
d810d0de 897TString AliEveHOMERManager:: GetBlkType( Int_t ndx ) {
059c30e4 898 // see header file for class documentation
899
900 TString type = "";
901
902 // -- Check for Connection
903 if ( !fReader || ! IsConnected() ) {
904 AliError( Form("Not connected yet.") );
905 return type;
906 }
907
908 // -- Check blockk index
909 if ( ( ndx ) >= (Int_t) fNBlks ) {
910 AliError( Form("Block index %d out of range.", ndx ) );
911 return type;
912 }
913
914 // -- Get type
915 union{
916 ULong64_t data;
917 Char_t array[8];
918 } reverseType;
919
920 reverseType.data = (ULong64_t) fReader->GetBlockDataType( ndx );
921
922 // -- Reverse the order
923 for (Int_t ii = 7; ii >= 0; ii-- )
924 if ( reverseType.array[ii] != ' ')
925 type.Append( reverseType.array[ii] );
926
927 return type;
928}
929
930
931//##################################################################################
d810d0de 932ULong_t AliEveHOMERManager:: GetBlkSpecification( Int_t ndx ) {
059c30e4 933 // see header file for class documentation
934
935 ULong_t spec = 0;
936
937
938 // -- Check for Connection
939 if ( !fReader || ! IsConnected() ) {
940 AliError( Form("Not connected yet.") );
941 return spec;
942 }
943
944 // -- Check blockk index
945 if ( ( ndx ) >= (Int_t) fNBlks ) {
946 AliError( Form("Block index %d out of range.", ndx ) );
947 return spec;
948 }
949
950 spec = (ULong_t) fReader->GetBlockDataSpec( ndx );
951
952 return spec;
953}
954
955//##################################################################################
d810d0de 956Bool_t AliEveHOMERManager::CheckIfRequested( AliHLTHOMERBlockDesc * block ) {
059c30e4 957 // see header file for class documentation
958
959 Bool_t requested = kFALSE;
960
961 AliHLTHOMERSourceDesc * source= NULL;
962
963 // -- Read all sources and check if they should be read out
964 TIter next( fSourceList );
965 while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
966
967 if ( ! source->IsSelected() )
968 continue;
969
970 if ( source->GetDetector().CompareTo( block->GetDetector() ) )
971 continue;
972
973 if ( source->GetDataType().CompareTo( block->GetDataType() ) )
974 continue;
975
976 if ( ! block->HasSubDetectorRange() ) {
6612c5b3 977
978 if ( source->GetSubDetector().Atoi() != block->GetSubDetector().Atoi() )
059c30e4 979 continue;
980
981 if ( ! block->HasSubSubDetectorRange() ) {
982
6612c5b3 983 // if ( source->GetSubSubDetector().Atoi() != block->GetSubSubDetector().Atoi() )
984 // continue;
059c30e4 985
986 } // if ( ! block->HasSubSubDetectorRange ) {
987 } // if ( ! block->HasSubDetectorRange ) {
988
989 requested = kTRUE;
990
991 } // while ( ( source = (AliHLTHOMERSourceDesc*)next() ) ) {
992
993 if ( requested) {
994 AliInfo( Form("Block requested : %s - %s : %s/%s -> %s ", block->GetDetector().Data(), block->GetDataType().Data(),
995 block->GetSubDetector().Data(), block->GetSubSubDetector().Data(), block->GetClassName().Data() ) );
996 }
6612c5b3 997 else
998 AliInfo( Form("Block NOT requested : %s - %s : %s/%s -> %s ", block->GetDetector().Data(), block->GetDataType().Data(), block->GetSubDetector().Data(), block->GetSubSubDetector().Data(), block->GetClassName().Data() ) );
059c30e4 999
1000 return requested;
1001}
1002
1003//##################################################################################
d810d0de 1004void AliEveHOMERManager::TestSelect() {
059c30e4 1005 // see header file for class documentation
1006
1007 for (Int_t ii =0; ii < fSourceList->GetEntries() ; ii++ ) {
1008 if ( (ii%2) == 0 )
1009 ((AliHLTHOMERSourceDesc*) fSourceList->At(ii))->Select();
1010 }
1011}
1012
6612c5b3 1013//##################################################################################
d810d0de 1014void AliEveHOMERManager::TestSelectClass( TString objectName ) {
6612c5b3 1015 // see header file for class documentation
1016
1017 TList* srcList = GetSourceList();
1018
1019 AliHLTHOMERSourceDesc *desc = 0;
1020
1021 TIter next(srcList);
1022
1023 while ( ( desc = (AliHLTHOMERSourceDesc*)next() ) ) {
1024 if ( ! desc->GetClassName().CompareTo( objectName ) )
1025 desc->Select();
1026 }
1027}
1028
1029//##################################################################################
d810d0de 1030void AliEveHOMERManager::SelectRawTPC() {
6612c5b3 1031 // see header file for class documentation
1032
1033 TList* srcList = GetSourceList();
1034
1035 AliHLTHOMERSourceDesc *desc = 0;
1036
1037 TIter next(srcList);
1038
1039 while ( ( desc = (AliHLTHOMERSourceDesc*)next() ) ) {
1040 if ( ! desc->GetDataType().CompareTo( "DDL_RAW" ) ) {
1041 desc->Select();
1042 }
1043 }
1044}
1045
1046//##################################################################################
d810d0de 1047void AliEveHOMERManager::SelectClusterTPC() {
6612c5b3 1048 // see header file for class documentation
1049
1050 TList* srcList = GetSourceList();
1051
1052 AliHLTHOMERSourceDesc *desc = 0;
1053
1054 TIter next(srcList);
1055
1056 while ( ( desc = (AliHLTHOMERSourceDesc*)next() ) ) {
1057 if ( ! desc->GetDataType().CompareTo( "CLUSTERS" ) ) {
1058 desc->Select();
1059 }
1060 }
1061}
1062
1063//##################################################################################
d810d0de 1064void AliEveHOMERManager::SelectESDTPC() {
6612c5b3 1065 // see header file for class documentation
1066
1067 TList* srcList = GetSourceList();
1068
1069 AliHLTHOMERSourceDesc *desc = 0;
1070
1071 TIter next(srcList);
1072
1073 while ( ( desc = (AliHLTHOMERSourceDesc*)next() ) ) {
1074 if ( ! desc->GetDataType().CompareTo( "ESD_TREE" ) ) {
1075 desc->Select();
1076 }
1077 }
1078}
1079//##################################################################################
d810d0de 1080void AliEveHOMERManager::DumpTPCCalib(TString objectName, Bool_t dumpToFile) {
6612c5b3 1081 // see header file for class documentation
1082
1083 if ( fTPCPre != NULL )
1084 delete fTPCPre;
1085
1086 fTPCPre = new AliTPCPreprocessorOnline();
1087
1088 TList* blockList = GetBlockList();
1089
1090 AliHLTHOMERBlockDesc *desc = 0;
1091
1092 TIter next(blockList);
1093
1094 while ( ( desc = (AliHLTHOMERBlockDesc*)next() ) ) {
1095 if ( ! desc->IsTObject() )
1096 continue;
1097
1098 Int_t sectorTPC = 0;
1099
1100 if ( desc->GetSubSubDetector().Atoi() <= 1 ) {
1101 sectorTPC = desc->GetSubDetector().Atoi();
1102 }
1103 else {
1104 sectorTPC = 36 + desc->GetSubDetector().Atoi();
1105 }
1106
1107 if ( ! objectName.CompareTo( desc->GetClassName() ) ){
1108
1109 //
1110 // AliTPCCalibPedestal
1111 //
1112
1113 if ( ! objectName.CompareTo( "AliTPCCalibPedestal" ) ) {
1114 AliTPCCalROC* calROC = NULL;
1115
1116 AliTPCCalibPedestal * cal = (AliTPCCalibPedestal*) desc->GetTObject();
1117 if ( cal == NULL ) {
1118 cout << "error 1" << endl;
1119 continue;
1120 }
1121
1122 cal->Analyse();
1123
1124 calROC = cal->GetCalRocRMS(sectorTPC);
1125 if ( calROC == NULL ) {
1126 cout << "error 2" << endl;
1127 continue;
1128 }
1129
1130 calROC->SetName(Form("RMS_ROC%d", sectorTPC));
1131 fTPCPre->AddComponent((TObject*) calROC );
059c30e4 1132
6612c5b3 1133 calROC = cal->GetCalRocPedestal(sectorTPC);
1134 if ( calROC == NULL ) {
1135 cout << "error 3" << endl;
1136 continue;
1137 }
1138
1139
1140 calROC->SetName(Form("Pedestal_ROC%d", sectorTPC));
1141 cout << "added" << endl;
1142 fTPCPre->AddComponent((TObject*) calROC );
1143 }
1144
1145 //
1146 // AliTPCCalibPulser
1147 //
1148 /*
1149 else if ( ! objectName.CompareTo( "AliTPCCalibPulser" ) ) {
1150 AliTPCCalROC* calROC = NULL;
1151
1152 AliTPCCalibPulser * cal = (AliTPCCalibPulser*) desc->GetTObject();
1153
1154 cal->Analyse();
1155
1156 calROC = cal->GetCalRocT0(sectorTPC);
1157 calROC->SetName(Form("T0_ROC%d", sectorTPC));
1158 fTPCPre->AddComponent((TObject*) calROC );
1159
1160 calROC = cal->GetCalRocQ(sectorTPC);
1161 calROC->SetName(Form("Q_ROC%d", sectorTPC));
1162 fTPCPre->AddComponent((TObject*) calROC );
1163
1164 calROC = cal->GetCalRocRMS(sectorTPC);
1165 calROC->SetName(Form("RMS_ROC%d", sectorTPC));
1166 fTPCPre->AddComponent((TObject*) calROC );
1167
1168 calROC = cal->GetCalRocOutliers(sectorTPC);
1169 calROC->SetName(Form("Outliers_ROC%d", sectorTPC));
1170 fTPCPre->AddComponent((TObject*) calROC );
1171 }
1172
1173*/
1174 //
1175 // AliTPCCalibCE
1176 //
1177 /*
1178 else if ( ! objectName.CompareTo( "AliTPCCalibCE" ) ) {
1179 AliTPCCalROC* calROC = NULL;
1180
1181 AliTPCCalibPulser * cal = (AliTPCCalibPulser*) desc->GetTObject();
1182
1183 cal->Analyse();
1184
1185 calROC = cal->GetCalRocT0(sectorTPC);
1186 calROC->SetName(Form("T0_ROC%d", sectorTPC));
1187 fTPCPre->AddComponent((TObject*) calROC );
1188
1189 calROC = cal->GetCalRocQ(sectorTPC);
1190 calROC->SetName(Form("Q_ROC%d", sectorTPC));
1191 fTPCPre->AddComponent((TObject*) calROC );
1192
1193 calROC = cal->GetCalRocRMS(sectorTPC);
1194 calROC->SetName(Form("RMS_ROC%d", sectorTPC));
1195 fTPCPre->AddComponent((TObject*) calROC );
1196
1197 calROC = cal->GetCalRocOutliers(sectorTPC);
1198 calROC->SetName(Form("Outliers_ROC%d", sectorTPC));
1199 fTPCPre->AddComponent((TObject*) calROC );
1200 }
1201 */
1202 } // if ( ! objectName.CompareTo( desc->GetClassName() ) ) {
1203
1204 } // while ( ( desc = (AliHLTHOMERBlockDesc*)next() ) ) {
1205
1206 if ( dumpToFile ) {
1207
1208 fTPCPre->DumpToFile("pedestals.root");
1209 cout << "DUMP" << endl;
1210 }
1211
1212
1213}