fix coding violation
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManagerHomer.cxx
CommitLineData
30e7579c 1// Author: 2010 Svein Lindal <slindal@fys.uio.no> *
2// for The ALICE HLT Project. *
3
4#include "AliHLTEveHLT.h"
5#include "AliHLTEvePhos.h"
6#include "AliHLTEveEmcal.h"
7
8
9#include "AliESDEvent.h"
10#include "AliEveHLTEventManager.h"
11#include "AliEveEventBufferOffline.h"
12#include "AliEveHLTEventManagerHomer.h"
13#include "TList.h"
14#include "AliEveHOMERManager.h"
15#include "TEveManager.h"
55f78c0d 16#include "TTimer.h"
17#include "TGLOverlayButton.h"
c3a37082 18#include "TGLViewer.h"
30e7579c 19
20ClassImp(AliEveHLTEventManagerHomer)
21
22AliEveHLTEventManagerHomer::AliEveHLTEventManagerHomer() :
23 AliEveHLTEventManager(),
55f78c0d 24 fEventBuffer(NULL),
25 fNextEventTimer(NULL),
26 fInfoButton(NULL)
30e7579c 27{
28 // see header file for class documentation
55f78c0d 29
30e7579c 30 fEventBuffer = new AliEveEventBufferHomer();
11757805 31 fEventBuffer->StartBufferMonitor();
55f78c0d 32
33 fNextEventTimer = new TTimer();
34 fNextEventTimer->Connect("Timeout()", "AliEveHLTEventManagerHomer", this, "TryNextEvent()" );
35
c3a37082 36 fInfoButton = new TGLOverlayButton(dynamic_cast<TGLViewerBase*>(gEve->GetDefaultGLViewer()), "", 0, 540, 210, 25);
37 fInfoButton->SetAlphaValues(0.0, 0.8);
38
30e7579c 39
40
41}
42
43
44AliEveHLTEventManagerHomer::~AliEveHLTEventManagerHomer() {
45
46 //DestroyElements();
47 //DestroyDetectorElements();
48 if(fEventBuffer)
49 delete fEventBuffer;
50 fEventBuffer = NULL;
51
52}
53
0ddb492b 54///________________________________________________________________________________
55void AliEveHLTEventManagerHomer::ProcessList(TList * blockList) {
56
57 ProcessEvent(blockList);
58 UpdateDisplay();
59
60}
55f78c0d 61void AliEveHLTEventManagerHomer::NextEvent() {
62 fNextEventTimer->Start(1000);
63}
30e7579c 64
65///________________________________________________________________________________
55f78c0d 66void AliEveHLTEventManagerHomer::TryNextEvent() {
30e7579c 67 //See header file for documentation
55f78c0d 68
69 if ( fEventBuffer->LockMutex() ) {
c3a37082 70 fInfoButton->SetAlphaValues(0.8, 0.8);
71 fInfoButton->SetText("Waiting for buffer...");
72 gEve->Redraw3D(kFALSE);
55f78c0d 73 cout << "try again in 1 sec"<<endl;
d63d227e 74 return;
55f78c0d 75 }
c3a37082 76 fInfoButton->SetAlphaValues(0.8, 0.8);
77
55f78c0d 78 fNextEventTimer->Stop();
79
80 cout << "Mutex is freeee!!"<<endl;
cc87822c 81 TList * aSyncEvent = fEventBuffer->GetASyncEvent();
82 TList * event = static_cast<TList*>(fEventBuffer->NextEvent());
83 if(event) {
84 cout << "Got the event, reset the display " <<endl;
c3a37082 85 fInfoButton->SetText("Reset display..");
cc87822c 86 ResetDisplay();
87 cout << "Process event"<<endl;
c3a37082 88 fInfoButton->SetText("Processing event..");
cc87822c 89 ProcessEvent(event);
90 if(aSyncEvent) {
91 cout << "Process asynchroneous event" << endl;
92 ProcessEvent(aSyncEvent);
93 } else {
94 cout << "Could not get async event"<<endl;
95 }
96
97 cout << "Upate the display"<<endl;
c3a37082 98 fInfoButton->SetText("Updating display...");
cc87822c 99 UpdateDisplay();
100
30e7579c 101 } else {
0ddb492b 102 cout << "couldn't get the sync event"<<endl;
1b74166c 103 fInfoButton->SetAlphaValues(0.8, 0.8);
104 fInfoButton->SetText("Waiting for buffer...");
c3a37082 105 fEventBuffer->UnLockMutex();
106 fEventBuffer->CreateBufferThread();
1b74166c 107 fNextEventTimer->Start(3000);
108 return;
c3a37082 109 }
765675f2 110
c3a37082 111 fInfoButton->SetAlphaValues(0.0, 0.0);
112 fInfoButton->SetText("Done..");
765675f2 113 fEventBuffer->UnLockMutex();
c3a37082 114
30e7579c 115}
116
117
118///____________________________________________________________________________________
119void AliEveHLTEventManagerHomer::NavigateFwd() {
120 //See header file for documentation
121 TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Fwd());
122 if(fEvent) {
0ddb492b 123 ResetDisplay();
30e7579c 124 ProcessEvent(fEvent);
0ddb492b 125 UpdateDisplay();
30e7579c 126 } else {
127 cout << "couldn't get the fwd event"<<endl;
128 }
129}
130
131
132///______________________________________________________________________________________
133void AliEveHLTEventManagerHomer::NavigateBack() {
134 //See header file for documentation
135 TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Back());
136 if(fEvent) {
0ddb492b 137 ResetDisplay();
30e7579c 138 ProcessEvent(fEvent);
0ddb492b 139 UpdateDisplay();
30e7579c 140 } else {
141 cout << "couldn't get the back event"<<endl;
142 }
143}
144