Fixing bugs in Event Display
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / alistorageminimalexample.cxx
CommitLineData
164d3d29 1#include "AliStorageEventManager.h"
164d3d29 2#include <iostream>
3#include <TFile.h>
fae81379 4#include <TThread.h>
5
6
7using namespace std;
8
9AliESDEvent *fCurrentEvent[2];
10TTree *fCurrentTree[2];
11TMutex fMutex;
12int fEventInUse = 1;
13int fWritingToEventIndex = 0;
14bool fIsNewEventAvaliable = false;
164d3d29 15
16
17int main()
18{
fae81379 19 AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
20 eventManager->CreateSocket(EVENTS_SERVER_SUB);
21
22 fCurrentEvent[0]=0;
23 fCurrentEvent[1]=0;
24 fCurrentTree[0]=0;
25 fCurrentTree[1]=0;
26 AliESDEvent *tmpEvent = NULL;
27
28 while(1)
29 {
30 tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB);
31
32 if(tmpEvent)
33 {
34 if(tmpEvent->GetRunNumber()>=0)
35 {
36 fMutex.Lock();
37 if(fEventInUse == 0){fWritingToEventIndex = 1;}
38 else if(fEventInUse == 1){fWritingToEventIndex = 0;}
39 cout<<"Received new event"<<endl;
40 if(fCurrentEvent[fWritingToEventIndex])
41 {
42 delete fCurrentEvent[fWritingToEventIndex];
43 fCurrentEvent[fWritingToEventIndex]=0;
44 }
45 fCurrentEvent[fWritingToEventIndex] = tmpEvent;
46 fIsNewEventAvaliable = true;
47 fMutex.UnLock();
48 }
49 }
50 }
164d3d29 51 return 0;
52}