4 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 *
5 // Author: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
6 // Author: 2010 Svein Lindal <slindal@fys.uio.no> *
7 // for The ALICE HLT Project. *
11 /** @file AliEveHOMERManager.cxx
12 @author Jochen Thaeder, Svein Lindal <slindal@fys.uio.no>
14 @brief Manager for HOMER online
22 #include "TEveManager.h"
24 #include "TEveScene.h"
25 #include "TEveProjectionManager.h"
26 #include "TEveBrowser.h"
28 #include "AliEveHOMERManager.h"
29 #include "AliHLTHOMERBlockDesc.h"
30 #include "AliHLTHOMERManager.h"
31 #include "AliHLTTriggerDecision.h"
32 #include "AliHLTEvePhos.h"
33 #include "AliHLTEveEmcal.h"
34 #include "AliHLTEveTPC.h"
35 #include "AliHLTEveHLT.h"
36 #include "AliHLTEveITS.h"
37 #include "AliHLTEveISPD.h"
38 #include "AliHLTEveISSD.h"
39 #include "AliHLTEveISDD.h"
40 #include "AliHLTEveTRD.h"
41 #include "AliHLTEveMuon.h"
42 #include "AliHLTEveAny.h"
43 #include "AliEveHOMERSourceList.h"
47 ClassImp(AliEveHOMERManager)
50 * ---------------------------------------------------------------------------------
51 * Constructor / Destructor
52 * ---------------------------------------------------------------------------------
55 //##################################################################################
56 AliEveHOMERManager::AliEveHOMERManager() :
57 TEveElementList("Homer Manager"),
66 fRPhiEventScene(NULL),
67 fRhoZEventScene(NULL),
69 // fSourceListTimer(NULL),
81 fEventLoopStarted(kFALSE),
82 fCenterProjectionsAtPrimaryVertex(kFALSE),
86 // see header file for class documentation
88 // refer to README to build package
90 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
92 fTimer = new TTimer();
93 fTimer->Connect("Timeout()", "AliEveHOMERManager", this, "NextHOMEREvent()" );
95 //fSourceListTimer = new TTimer();
97 fPhosElement = new AliHLTEvePhos();
98 fPhosElement->SetEventManager(this);
100 fEmcalElement = new AliHLTEveEmcal();
101 fEmcalElement->SetEventManager(this);
103 fTPCElement = new AliHLTEveTPC();
104 fTPCElement->SetEventManager(this);
106 fHLTElement = new AliHLTEveHLT();
107 fHLTElement->SetEventManager(this);
109 fITSElement = new AliHLTEveITS();
110 fITSElement->SetEventManager(this);
112 fISPDElement = new AliHLTEveISPD();
113 fISPDElement->SetEventManager(this);
115 fISDDElement = new AliHLTEveISDD();
116 fISDDElement->SetEventManager(this);
118 fISSDElement = new AliHLTEveISSD();
119 fISSDElement->SetEventManager(this);
121 fTRDElement = new AliHLTEveTRD();
122 fTRDElement->SetEventManager(this);
126 //##################################################################################
127 AliEveHOMERManager::~AliEveHOMERManager() {
128 // see header file for class documentation
131 DestroyDetectorElements();
137 void AliEveHOMERManager::DestroyDetectorElements(){
138 //See header file for documentation
148 delete fEmcalElement;
149 fEmcalElement = NULL;
193 * ---------------------------------------------------------------------------------
195 * ---------------------------------------------------------------------------------
198 //##################################################################################
199 Int_t AliEveHOMERManager::CreateEveSourcesList() {
200 // see header file for class documentation
204 Int_t iResult = CreateSourcesList();
206 // fStateHasChanged = kTRUE;
208 HLTDebug(Form("iResult XXX %d", iResult));
213 HLTDebug(Form("iResult %d", iResult));
215 HLTInfo(Form("delete source list", iResult));
220 HLTInfo(Form("cleared source list", iResult));
224 // -- Create new AliEVE sources list
226 HLTInfo(Form("no source list", iResult));
227 fSrcList = new AliEveHOMERSourceList("HLT Sources");
228 fSrcList->SetManager(this);
230 AddElement(fSrcList);
233 //HLTInfo(Form("createbytype", iResult));
234 fSrcList->CreateByDet();
236 HLTDebug(Form("Done createing source list %d", iResult));
243 //##################################################################################
244 Int_t AliEveHOMERManager::CreateEveSourcesListLoop() {
245 // see header file for class documentation
249 for ( Int_t retry = 0; retry < fRetryCount ; retry++ ) {
251 iResult = CreateEveSourcesList();
254 HLTInfo("Source list successfully created.");
257 else if (iResult == 1) {
258 HLTWarning( Form("Couldn't find active services, sleeping %d s before making attempt %d out of %d", fRetrySleeptime, retry, fRetryCount) ) ;
260 else if (iResult == 2) {
261 HLTWarning( Form("Services List empty, sleeping %d s before making new attempt.", fRetrySleeptime) ) ;
264 HLTError( Form("Other problem ... \n") );
268 //fSourceListTimer->Start(fRetrySleeptime, kFALSE);
269 sleep(fRetrySleeptime);
274 HLTWarning( Form("Couldn't find active services.") );
281 //##################################################################################
282 Int_t AliEveHOMERManager::ConnectEVEtoHOMER( TString detector ) {
283 // see header file for class documentation
286 fStateHasChanged = fSrcList->GetSelectedSources();
287 HLTInfo(Form("has state changed % d", fStateHasChanged));
288 return ConnectHOMER(detector);
292 //##################################################################################
293 Int_t AliEveHOMERManager::ReConnectHOMER( TString /*detector*/ ){
294 // see header file for class documentation
299 iResult = CreateEveSourcesListLoop();
300 HLTInfo("Created new source list, reconnect to HOMER");
301 iResult = ConnectEVEtoHOMER();
303 HLTError(Form("Error reconnecting."));
310 //_____________________________________________________________________________________
311 Int_t AliEveHOMERManager::NextHOMEREvent() {
312 //See header file for documentation
319 HLTInfo("Failed getting next event, trying to reconnect");
320 iResult = ReConnectHOMER();
321 return NextHOMEREvent();
324 return ProcessEvent();
329 //______________________________________________________________________________________________
330 Int_t AliEveHOMERManager::ProcessEvent() {
332 //We have a new event, reset display items (need to check if there really is anything interesting in event before resetting. ie not just histos)
336 AliHLTHOMERBlockDesc * block = NULL;
339 //Process the SYNCED block list
340 if ( GetBlockList() == NULL) {
341 printf ("onlineDisplay: No regular BlockList ... \n");
347 if (GetBlockList()->IsEmpty() ) {
348 printf ("onlineDisplay: No Sync Blocks in list ... \n");
354 TIter next(GetBlockList());
355 while ((block = (AliHLTHOMERBlockDesc*)next())) {
362 //Read out histograms and elements from detectors outside physics 1 partition
363 TIter anext(GetAsyncBlockList());
365 while ( (block = (AliHLTHOMERBlockDesc*)anext()) ) {
375 void AliEveHOMERManager::UpdateDisplay() {
376 //See header file for documentation
377 fPhosElement->UpdateElements();
378 fEmcalElement->UpdateElements();
379 fTPCElement->UpdateElements();
380 fHLTElement->UpdateElements();
381 fITSElement->UpdateElements();
382 fISSDElement->UpdateElements();
383 fISDDElement->UpdateElements();
384 fISPDElement->UpdateElements();
385 fTRDElement->UpdateElements();
386 if(fAnyElement) fAnyElement->UpdateElements();
387 if(fMuonElement) fMuonElement->UpdateElements();
390 // -- Set EventID in Window Title
391 TString winTitle("Eve Main Window -- Event ID : ");
392 winTitle += Form("0x%016X ", GetEventID() );
393 GetEveManager()->GetBrowser()->SetWindowName(winTitle);
395 //==============================================================================
396 // -- Import global scene into projection scenes
397 //==============================================================================
399 // XXX Primary vertex ... to be retrieved from the ESD
400 Double_t x[3] = { 0, 0, 0 };
402 TEveElement* top = GetEveManager()->GetCurrentEvent();
404 if (fRPhiManager && top) {
405 fRPhiEventScene->DestroyElements();
406 if (fCenterProjectionsAtPrimaryVertex)
407 fRPhiManager->SetCenter(x[0], x[1], x[2]);
408 fRPhiManager->ImportElements(top, fRPhiEventScene);
411 if (fRhoZManager && top) {
412 fRhoZEventScene->DestroyElements();
413 if (fCenterProjectionsAtPrimaryVertex)
414 fRhoZManager->SetCenter(x[0], x[1], x[2]);
415 fRhoZManager->ImportElements(top, fRhoZEventScene);
420 GetEveManager()->Redraw3D(0,1); // (0, 1)
421 GetEveManager()->EnableRedraw();
425 void AliEveHOMERManager::ProcessBlock(AliHLTHOMERBlockDesc * block) {
426 //See header file for documentation
429 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
430 printf( "Detector : %s\n", block->GetDetector().Data() );
431 printf( "Datatype : %s\n", block->GetDataType().Data() );
432 if (block->IsTObject() )
433 printf( "Is TObject of class: %s\n", block->GetClassName().Data() );
434 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
440 if ( ! block->GetDetector().CompareTo("PHOS") )
441 fPhosElement->ProcessBlock(block);
443 else if ( ! block->GetDetector().CompareTo("EMCA") )
444 fEmcalElement->ProcessBlock(block);
446 else if ( ! block->GetDetector().CompareTo("TPC") )
447 fTPCElement->ProcessBlock(block);
449 else if ( ! block->GetDetector().CompareTo("HLT") )
450 fHLTElement->ProcessBlock(block);
452 else if ( ! block->GetDetector().CompareTo("ITS") )
453 fITSElement->ProcessBlock(block);
455 else if ( ! block->GetDetector().CompareTo("ISDD") )
456 fISDDElement->ProcessBlock(block);
458 else if ( ! block->GetDetector().CompareTo("ISPD") )
459 fISPDElement->ProcessBlock(block);
461 else if ( ! block->GetDetector().CompareTo("ISSD") )
462 fISSDElement->ProcessBlock(block);
464 else if ( ! block->GetDetector().CompareTo("TRD") )
465 fTRDElement->ProcessBlock(block);
467 else if ( ! block->GetDetector().CompareTo("MUON") ) {
473 fAnyElement = new AliHLTEveAny();
474 fAnyElement->SetEventManager(this);
476 fAnyElement->ProcessBlock(block);
483 if ( ! block->GetDetector().CompareTo("MUON") ) {
485 fMuonElement = new AliHLTEveMuon();
486 fMuonElement->SetEventManager(this);
488 fMuonElement->ProcessBlock(block);
494 void AliEveHOMERManager::ResetDisplay () {
495 //See header file for documentation
498 fPhosElement->ResetElements();
501 fEmcalElement->ResetElements();
504 fTPCElement->ResetElements();
507 fHLTElement->ResetElements();
510 fITSElement->ResetElements();
513 fISPDElement->ResetElements();
516 fISDDElement->ResetElements();
519 fISSDElement->ResetElements();
522 fTRDElement->ResetElements();
525 fAnyElement->ResetElements();
528 fMuonElement->ResetElements();
533 void AliEveHOMERManager::StartLoop() {
534 //See header file for documentation
535 //fTimer->SetCommand("NextEvent()", "AliEveHOMERManager", this);
536 SetEventLoopStarted(kTRUE);
540 void AliEveHOMERManager::StopLoop() {
541 //See header file for documentation
543 SetEventLoopStarted(kFALSE);
546 // void AliEveHOMERManager::TimeOut(Int_t sec) {
548 // TTimer t(sec*1000, kFALSE);
550 // cout << "Start timer for " << sec << " seconds" << endl;
552 // while (!t.CheckTimer(gSystem->Now()))
553 // gSystem->Sleep(100); // 100 ms sleep
555 // cout << "Timed out." << endl;