]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveHLTEventManagerHomer.cxx
-Add info button
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManagerHomer.cxx
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"
16 #include "TTimer.h"
17 #include "TGLOverlayButton.h"
18 #include "TGLViewer.h"
19
20 ClassImp(AliEveHLTEventManagerHomer)
21
22 AliEveHLTEventManagerHomer::AliEveHLTEventManagerHomer() : 
23   AliEveHLTEventManager(),
24   fEventBuffer(NULL), 
25   fNextEventTimer(NULL),
26   fInfoButton(NULL)
27 {
28   // see header file for class documentation
29
30   fEventBuffer = new AliEveEventBufferHomer();
31   fEventBuffer->StartBufferMonitor();
32     
33   fNextEventTimer = new TTimer();
34   fNextEventTimer->Connect("Timeout()", "AliEveHLTEventManagerHomer", this, "TryNextEvent()" );
35    
36   fInfoButton = new TGLOverlayButton(dynamic_cast<TGLViewerBase*>(gEve->GetDefaultGLViewer()),  "", 0, 540, 210, 25);
37     fInfoButton->SetAlphaValues(0.0, 0.8);
38   
39   
40
41 }
42
43  
44 AliEveHLTEventManagerHomer::~AliEveHLTEventManagerHomer() {
45
46   //DestroyElements();
47   //DestroyDetectorElements();  
48   if(fEventBuffer)
49     delete fEventBuffer;
50   fEventBuffer = NULL;
51
52 }
53
54 ///________________________________________________________________________________
55 void AliEveHLTEventManagerHomer::ProcessList(TList * blockList) {
56
57   ProcessEvent(blockList);
58   UpdateDisplay();
59
60 }
61 void AliEveHLTEventManagerHomer::NextEvent() {
62   fNextEventTimer->Start(1000);
63 }
64
65 ///________________________________________________________________________________
66 void AliEveHLTEventManagerHomer::TryNextEvent() {
67   //See header file for documentation
68     
69   if ( fEventBuffer->LockMutex() ) {
70     fInfoButton->SetAlphaValues(0.8, 0.8);
71     fInfoButton->SetText("Waiting for buffer...");
72     gEve->Redraw3D(kFALSE);
73     cout << "try again in 1 sec"<<endl;
74     return;
75   }
76   fInfoButton->SetAlphaValues(0.8, 0.8);
77
78   fNextEventTimer->Stop();
79     
80   cout << "Mutex is freeee!!"<<endl;
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;
85     fInfoButton->SetText("Reset display..");
86     ResetDisplay();
87     cout << "Process event"<<endl;
88     fInfoButton->SetText("Processing event..");
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;
98     fInfoButton->SetText("Updating display...");
99     UpdateDisplay();
100   
101   } else {
102     cout << "couldn't get the sync event"<<endl;
103     fEventBuffer->UnLockMutex();
104     fEventBuffer->CreateBufferThread();
105     fNextEventTimer->Start(1000);
106   
107   }
108   
109   fInfoButton->SetAlphaValues(0.0, 0.0);
110   fInfoButton->SetText("Done..");
111   fEventBuffer->UnLockMutex();
112
113 }
114
115
116 ///____________________________________________________________________________________
117 void AliEveHLTEventManagerHomer::NavigateFwd() {
118   //See header file for documentation
119   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Fwd());
120   if(fEvent) {
121     ResetDisplay();
122     ProcessEvent(fEvent);
123     UpdateDisplay();
124   } else {
125     cout << "couldn't get the fwd event"<<endl;
126   }
127 }
128
129
130 ///______________________________________________________________________________________
131 void AliEveHLTEventManagerHomer::NavigateBack() {
132   //See header file for documentation
133   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Back());
134   if(fEvent) {
135     ResetDisplay();
136     ProcessEvent(fEvent);
137     UpdateDisplay();
138   } else {
139     cout << "couldn't get the back event"<<endl;
140   }
141 }
142