saveViews extended to print trigger classes, displaying of logo fixed. Cleanup of...
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / alifakedisplay.cxx
CommitLineData
164d3d29 1#include "AliStorageEventManager.h"
2#include "AliStorageTypes.h"
3#include "AliESDEvent.h"
4#include "AliESDRun.h"
5
b686c9db 6#include "AliRawEventHeaderBase.h"
7
164d3d29 8#include <iostream>
9
10#include <TThread.h>
a7f93de6 11#include <TFile.h>
164d3d29 12
13using namespace std;
14
15/* parameters:
68242b61 16
17 0 - connect directly to reconstruction socket
18 1 - connect to Storage Manager and ask for last event
19 2 - connect to alieventserver, receive in thread and use in main thread
20
21 */
164d3d29 22
23// global variables:
24AliESDEvent *currentEvent[2];
25TTree *currentTree[2];
0790c3e6 26TMutex myMutex;
164d3d29 27int eventInUse=1;
28int writingToEventIndex=0;
29bool isNewEventAvaliable=false;
30//-----------------
31
32static void* GetNextEvent(void*);
33
34int main(int argc, char **argv)
35{
68242b61 36 if(argc<2)
37 {
38 cout<<"Usage: alifakedisplay <mode>"<<endl;
39 cout<<"mode:"<<endl;
40 cout<<"0 - connect directly to reconstruction socket"<<endl;
41 cout<<"1 - connect to Storage Manager and ask for last event"<<endl;
42 cout<<"3 - connect to Storage Manager, download list of perm events and ask for them in loop"<<endl;
43 return 0;
44 }
45
46 storageSockets socket;
47 AliStorageEventManager *manager = AliStorageEventManager::GetEventManagerInstance();
48 AliESDEvent *event;
a7f93de6 49 struct recPointsStruct *files;
68242b61 50
51 if(atoi(argv[1])==0)
52 {
a7f93de6 53 manager->CreateSocket(EVENTS_SERVER_SUB);
54 manager->CreateSocket(ITS_POINTS_SUB);
68242b61 55 cout<<"Socket created"<<endl;
56 while(1)
57 {
58 cout<<"waiting for event..."<<flush;
a7f93de6 59 event = manager->GetEvent(EVENTS_SERVER_SUB);
68242b61 60
61 if(event)
62 {
63 cout<<"Received event. Run:"<<event->GetRunNumber()<<"\t event:"<<event->GetEventNumberInFile()<<endl;
64
65 cout<<event->GetPeriodNumber()<<endl;
66 cout<<event->GetOrbitNumber()<<endl;
67 cout<<event->GetBunchCrossNumber()<<endl;
b686c9db 68 cout<<AliRawEventHeaderBase::GetTypeName(event->GetEventType())<<endl;
68242b61 69 for(int i=0;i<100;i++)
70 {
71 if(strcmp(event->GetESDRun()->GetTriggerClass(i),"")){
72 cout<<event->GetESDRun()->GetTriggerClass(i)<<endl;}
73 }
a7f93de6 74 delete event;event=0;
68242b61 75 }
76 else
77 {
78 cout<<"NO EVENT"<<endl;
79 }
a7f93de6 80
81 // Receiving RecPoints:
82 /*
83
84 files = manager->GetFiles(ITS_POINTS_SUB);
85
86
87 cout<<"Received file."<<endl;
88
89 //file->Write("ITS.RecPoints.root",kOverwrite);
90 if(files->files[0]){files->files[0]->SaveAs("ITS.RecPoints.root","recreate");}
91 if(files->files[1]){files->files[1]->SaveAs("TOF.RecPoints.root","recreate");}
92 if(files->files[2]){files->files[2]->SaveAs("galice.root","recreate");}
93
94 for(int i=0;i<10;i++)
95 {
96 if(files->files[i])
97 {
98 files->files[i]->Close();
99 delete files->files[i];files->files[i]=0;
100 }
101 }
102 sleep(2);
103 */
68242b61 104 }
105 }
106 else if(atoi(argv[1])==1)
107 {
108 socket = SERVER_COMMUNICATION_REQ;
109 manager->CreateSocket(socket);
110 while(1)
111 {
112 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
113 requestMessage->messageType = REQUEST_GET_LAST_EVENT;
114
115 manager->Send(requestMessage,socket);
116 event = manager->GetEvent(socket);
117 if(event)
118 {
119 cout<<"Last event - Run:"<<event->GetRunNumber()<<"\t event:"<<event->GetEventNumberInFile()<<endl;
120
121 delete event;
122 }
123 else
124 {
125 cout<<"NO EVENT"<<endl;
126 }
127 sleep(1);
128 }
129 }
130 else if(atoi(argv[1])==2)
131 {
132 TThread *getEventThread = new TThread("getEventThread",GetNextEvent,nullptr);
133 getEventThread->Run();
134
135 int counter=0;
136
137 while(1)
138 {
164d3d29 139 counter++;
140 if(isNewEventAvaliable)
141 {
68242b61 142 cout<<"new event"<<endl;
143 myMutex.Lock();
144 if(writingToEventIndex == 0) eventInUse = 0;
145 else if(writingToEventIndex == 1) eventInUse = 1;
146 cout<<"Using:"<<eventInUse<<endl;
147
148 if(currentEvent[eventInUse])
164d3d29 149 {
68242b61 150 if(currentEvent[eventInUse]->GetRunNumber() >= 0)
151 {
152 cout<<"CURRENT EVENT:"<<currentEvent[eventInUse]->GetEventNumberInFile()<<endl;
153 }
164d3d29 154 }
68242b61 155 isNewEventAvaliable = false;
156 myMutex.UnLock();
164d3d29 157 }
158 else{cout<<"No new event is avaliable."<<endl;}
68242b61 159
164d3d29 160 sleep(2);
68242b61 161 }
162 }
163 else if(atoi(argv[1])==3)
164 {
165 socket = SERVER_COMMUNICATION_REQ;
166 manager->CreateSocket(socket);
167
168
169 struct listRequestStruct list;
170 list.runNumber[0]=0;
171 list.runNumber[1]=999999;
172 list.eventNumber[0]=0;
173 list.eventNumber[1]=999999;
174 list.marked[0]=1;
175 list.marked[1]=1;
176 list.multiplicity[0]=1;
177 list.multiplicity[1]=999999;
178 strcpy(list.system[0],"p-p");
179 strcpy(list.system[1],"A-A");
180 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
181 requestMessage->messageType = REQUEST_LIST_EVENTS;
182 requestMessage->list = list;
183
184 manager->Send(requestMessage,socket);
185 vector<serverListStruct> receivedList = manager->GetServerListVector(socket,3000);
186
187 cout<<"FAKE DISPLAY -- received list of marked events"<<endl;
188
189 for(int i=0;i<receivedList.size();i++){
190 cout<<"ev:"<<receivedList[i].eventNumber<<endl;
191 }
164d3d29 192
68242b61 193 int iter=0;
194 while(1)
195 {
196 if(iter<receivedList.size())
197 {
198 struct eventStruct mark;
199 mark.runNumber = receivedList[iter].runNumber;
200 mark.eventNumber = receivedList[iter].eventNumber;
201
202 requestMessage->messageType = REQUEST_GET_EVENT;
203 requestMessage->event = mark;
204
205 manager->Send(requestMessage,socket);
206 event = manager->GetEvent(socket);
207
208 if(event)
209 {
210 cout<<"i:"<<iter<<"\tevent:"<<event->GetEventNumberInFile()<<endl;
211 }
212 else
213 {
214 cout<<"Received NO event"<<endl;
215 }
216 iter++;
217 sleep(1);
218 }
219 else{iter=0;}
220 }
221 }
222
223 return 0;
164d3d29 224}
225
226void* GetNextEvent(void*)
227{
68242b61 228 AliStorageEventManager *eventManager = AliStorageEventManager::GetEventManagerInstance();
229 eventManager->CreateSocket(EVENTS_SERVER_SUB);
230
231 currentEvent[0]=0;
232 currentEvent[1]=0;
233 currentTree[0]=0;
234 currentTree[1]=0;
235 AliESDEvent *tmpEvent;
236
237 while(1)
164d3d29 238 {
68242b61 239 //if(tmpEvent){delete tmpEvent;tmpEvent=0;}
240 tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB);
241
242 if(tmpEvent)
164d3d29 243 {
68242b61 244 if(tmpEvent->GetRunNumber()>=0)
245 {
246 myMutex.Lock();
247 if(eventInUse == 0){writingToEventIndex = 1;}
248 else if(eventInUse == 1){writingToEventIndex = 0;}
249
250 if(currentEvent[writingToEventIndex])
251 {
252 delete currentEvent[writingToEventIndex];
253 currentEvent[writingToEventIndex]=0;
254 }
255 currentEvent[writingToEventIndex] = tmpEvent;
256 isNewEventAvaliable = true;
257 myMutex.UnLock();
258 }
259 }
260 }
164d3d29 261}