]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveHLTEventManagerHomer.cxx
Updated buffer handling with mutex and faster response
[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
19 ClassImp(AliEveHLTEventManagerHomer)
20
21 AliEveHLTEventManagerHomer::AliEveHLTEventManagerHomer() : 
22   AliEveHLTEventManager(),
23   fEventBuffer(NULL), 
24   fNextEventTimer(NULL),
25   fInfoButton(NULL)
26 {
27   // see header file for class documentation
28
29   fEventBuffer = new AliEveEventBufferHomer();
30   fEventBuffer->StartBufferMonitor();
31     
32   fNextEventTimer = new TTimer();
33   fNextEventTimer->Connect("Timeout()", "AliEveHLTEventManagerHomer", this, "TryNextEvent()" );
34    
35   
36
37 }
38
39  
40 AliEveHLTEventManagerHomer::~AliEveHLTEventManagerHomer() {
41
42   //DestroyElements();
43   //DestroyDetectorElements();  
44   if(fEventBuffer)
45     delete fEventBuffer;
46   fEventBuffer = NULL;
47
48 }
49
50 ///________________________________________________________________________________
51 void AliEveHLTEventManagerHomer::ProcessList(TList * blockList) {
52
53   ProcessEvent(blockList);
54   UpdateDisplay();
55
56 }
57 void AliEveHLTEventManagerHomer::NextEvent() {
58   fNextEventTimer->Start(1000);
59 }
60
61 ///________________________________________________________________________________
62 void AliEveHLTEventManagerHomer::TryNextEvent() {
63   //See header file for documentation
64     
65   if ( fEventBuffer->LockMutex() ) {
66     cout << "try again in 1 sec"<<endl;
67     return;
68   }
69   
70   fNextEventTimer->Stop();
71     
72   cout << "Mutex is freeee!!"<<endl;
73   TList * aSyncEvent = fEventBuffer->GetASyncEvent();
74   TList * event = static_cast<TList*>(fEventBuffer->NextEvent());
75   if(event) {
76     cout << "Got the event, reset the display " <<endl;
77     ResetDisplay();
78     cout << "Process event"<<endl;
79     ProcessEvent(event);
80     if(aSyncEvent) {
81       cout  << "Process asynchroneous event" << endl;
82       ProcessEvent(aSyncEvent);
83     }  else {
84       cout << "Could not get async event"<<endl;
85     }
86     
87     cout << "Upate the display"<<endl;
88     UpdateDisplay();
89   
90   } else {
91     cout << "couldn't get the sync event"<<endl;
92   }
93   
94   
95   fEventBuffer->UnLockMutex();
96 }
97
98
99 ///____________________________________________________________________________________
100 void AliEveHLTEventManagerHomer::NavigateFwd() {
101   //See header file for documentation
102   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Fwd());
103   if(fEvent) {
104     ResetDisplay();
105     ProcessEvent(fEvent);
106     UpdateDisplay();
107   } else {
108     cout << "couldn't get the fwd event"<<endl;
109   }
110 }
111
112
113 ///______________________________________________________________________________________
114 void AliEveHLTEventManagerHomer::NavigateBack() {
115   //See header file for documentation
116   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Back());
117   if(fEvent) {
118     ResetDisplay();
119     ProcessEvent(fEvent);
120     UpdateDisplay();
121   } else {
122     cout << "couldn't get the back event"<<endl;
123   }
124 }
125