]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveHLT/AliEveHLTEventManager.cxx
Added run number to frame
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManager.cxx
CommitLineData
30e7579c 1#include "TEveManager.h"
2#include "TEveScene.h"
3#include "TEveProjectionManager.h"
4#include "TEveBrowser.h"
5#include "TGLViewer.h"
6#include "TEveViewer.h"
7#include "TEveEventManager.h"
8
9//#include "AliHLTTriggerDecision.h"
10#include "AliHLTEvePhos.h"
11#include "AliHLTEveEmcal.h"
12#include "AliHLTEveTPC.h"
13#include "AliHLTEveHLT.h"
14#include "AliHLTEveITS.h"
15#include "AliHLTEveISPD.h"
16#include "AliHLTEveISSD.h"
17#include "AliHLTEveISDD.h"
18#include "AliHLTEveTRD.h"
19#include "AliHLTEveMuon.h"
20#include "AliHLTEveAny.h"
21
22#include "AliEveHLTEventManager.h"
23#include "AliEveHOMERManager.h"
24#include "AliEveEventBuffer.h"
25
26#include "TList.h"
27#include "TTimer.h"
28
29#include "TThread.h"
30
31ClassImp(AliEveHLTEventManager);
32
33AliEveHLTEventManager::AliEveHLTEventManager() :
34 TEveElementList("Event Manager"),
35 fGeoManager(NULL),
36 fEveManager(NULL),
37 fRPhiManager(NULL),
38 fRhoZManager(NULL),
39 fRPhiEventScene(NULL),
40 fRhoZEventScene(NULL),
41 fRhoZViewer(NULL),
42 fRPhiViewer(NULL),
43 fTimer(NULL),
44 fPhosElement(NULL),
45 fEmcalElement(NULL),
46 fTPCElement(NULL),
47 fHLTElement(NULL),
48 fITSElement(NULL),
49 fISPDElement(NULL),
50 fISSDElement(NULL),
51 fISDDElement(NULL),
52 fTRDElement(NULL),
53 fMuonElement(NULL),
54 fAnyElement(NULL),
55 fEventLoopStarted(kFALSE),
56 fCenterProjectionsAtPrimaryVertex(kFALSE),
57 fShowBarrel(kTRUE),
58 fShowMuon(kFALSE),
59 fRunNumber(-1)
60{
61 // see header file for class documentation
62 // or
63 // refer to README to build package
64 // or
65 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
66
67 fTimer = new TTimer();
68 fTimer->Connect("Timeout()", "AliEveHLTEventManager", this, "NextEvent()" );
69
70}
71
72AliEveHLTEventManager::~AliEveHLTEventManager() {
73
74 //DestroyElements();
75 //DestroyDetectorElements();
76
77}
78
79
80void AliEveHLTEventManager::DestroyDetectorElements(){
81 //See header file for documentation
82
83 if (fPhosElement)
84 delete fPhosElement;
85 fPhosElement = NULL;
86
87 if(fEmcalElement)
88 delete fEmcalElement;
89 fEmcalElement = NULL;
90
91 if(fTPCElement)
92 delete fTPCElement;
93 fTPCElement = NULL;
94
95 if(fHLTElement)
96 delete fHLTElement;
97 fHLTElement = NULL;
98
99 if(fITSElement)
100 delete fITSElement;
101 fITSElement = NULL;
102
103 if(fISSDElement)
104 delete fISSDElement;
105 fISSDElement = NULL;
106
107 if(fISDDElement)
108 delete fISDDElement;
109 fISDDElement = NULL;
110
111 if(fISPDElement)
112 delete fISPDElement;
113 fISPDElement = NULL;
114
115 if(fTRDElement)
116 delete fTRDElement;
117 fTRDElement = NULL;
118
119 if(fMuonElement)
120 delete fMuonElement;
121 fMuonElement = NULL;
122
123 if(fAnyElement)
124 delete fAnyElement;
125 fAnyElement = NULL;
126
127
128}
239fdf4e 129
30e7579c 130///_______________________________________________________________________________________
131void AliEveHLTEventManager::ConnectEventBuffer() {
132 GetEventBuffer()->ConnectToSource();
133}
134
135
136///___________________________________________________________________________________________
137void AliEveHLTEventManager::StartBufferMonitor() {
138 AliEveEventBuffer * buffer = GetEventBuffer();
239fdf4e 139 buffer->StartBufferMonitor();
30e7579c 140}
239fdf4e 141
30e7579c 142//______________________________________________________________________________________________
143Int_t AliEveHLTEventManager::ProcessEvent(AliESDEvent * event) {
144
145 //We have a new event, reset display items (need to check if there really is anything interesting in event before resetting. ie not just histos)
b088c0a1 146
147 gEve->DisableRedraw();
148
8676f4b1 149 // -- Set EventID in Window Title
150 TString winTitle("Eve Main Window");
8de01aa1 151 winTitle += Form("-- Run Number: %d", event->GetRunNumber());
594357d7 152 winTitle += Form("-- Event ID : 0x%016lX ", GetEventBuffer()->GetEventId() );
8676f4b1 153 GetEveManager()->GetBrowser()->SetWindowName(winTitle);
154
155
30e7579c 156
157 cout << "reset()"<<endl;
158
159 ResetDisplay();
160
161 cout << "process()"<<endl;
162 if(!fHLTElement) {
163 fHLTElement = new AliHLTEveHLT();
164 fHLTElement->SetEventManager(this);
165 gEve->AddElement(fHLTElement);
166 }
167 fHLTElement->ProcessEsdEvent(event);
168
169 if(!fPhosElement) CreatePhosElement();
170 fPhosElement->ProcessEvent(event);
171
172 if(!fEmcalElement) CreateEmcalElement();
173 fEmcalElement->ProcessEvent(event);
174
175 cout << "update()"<<endl;
176 UpdateDisplay();
177
b088c0a1 178 gEve->Redraw3D(0, 1);
179 gEve->EnableRedraw();
180
30e7579c 181 return 0;
182
183}
184
185
186
187//______________________________________________________________________________________________
188Int_t AliEveHLTEventManager::ProcessEvent(TList * blockList) {
189
190 //We have a new event, reset display items (need to check if there really is anything interesting in event before resetting. ie not just histos)
191
192 if(!blockList) {
193 cout << "Block list is NULL pointer, return " << endl;
194 return -1;
195 }
196
8676f4b1 197 cout << "ProcessEvent()::reset ()"<<endl;
30e7579c 198 ResetDisplay();
8676f4b1 199 cout << "ProcessEvent() :: done reset()"<<endl;
30e7579c 200 AliHLTHOMERBlockDesc * block = NULL;
201 TIter next(blockList);
202 while ((block = (AliHLTHOMERBlockDesc*)next())) {
203 cout <<"Process Block"<<endl;
204 ProcessBlock(block);
205 }
206
207 cout << "update() "<<endl;
208 UpdateDisplay();
209
210 return 0;
211
212}
239fdf4e 213///___________________________________________________________________________________________
30e7579c 214
215void AliEveHLTEventManager::ProcessBlock(AliHLTHOMERBlockDesc * block) {
216 //See header file for documentation
217
218#if 1//DEBUG
219 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
220 printf( "Detector : %s\n", block->GetDetector().Data() );
221 printf( "Datatype : %s\n", block->GetDataType().Data() );
222 if (block->IsTObject() )
223 printf( "Is TObject of class: %s\n", block->GetClassName().Data() );
224 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
225#endif
226
227
228 if(fShowBarrel) {
229
230 if ( ! block->GetDetector().CompareTo("PHOS") ) {
231 if(!fPhosElement) CreatePhosElement();
232 fPhosElement->ProcessBlock(block);
233 }
234
235 else if ( ! block->GetDetector().CompareTo("EMCA") ) {
236 if(!fEmcalElement) CreateEmcalElement();
237 fEmcalElement->ProcessBlock(block);
238 }
239
240 else if ( ! block->GetDetector().CompareTo("TPC") ) {
241 if(!fTPCElement) CreateTPCElement();
242 fTPCElement->ProcessBlock(block);
243 }
244
245 else if ( ! block->GetDetector().CompareTo("HLT") ) {
246 if(!fHLTElement) CreateHLTElement();
d48add50 247
248 if(!block->GetDataType().CompareTo("ALIESDV0")) {
249 AliESDEvent * event = dynamic_cast<AliESDEvent *>(block->GetTObject());
250 if(event) {
251 ProcessEvent(event);
252 }
253 } else {
254 fHLTElement->ProcessBlock(block);
255 }
30e7579c 256 }
257
258 else if ( ! block->GetDetector().CompareTo("ITS") ) {
259 if(!fITSElement) CreateITSElement();
260 fITSElement->ProcessBlock(block);
261 }
262
263 else if ( ! block->GetDetector().CompareTo("ISDD") ) {
264 if(!fISDDElement) CreateISDDElement();
265 fISDDElement->ProcessBlock(block);
266 }
267
268 else if ( ! block->GetDetector().CompareTo("ISPD") ) {
269 if(!fISPDElement) CreateISPDElement();
270 fISPDElement->ProcessBlock(block);
271 }
272
273 else if ( ! block->GetDetector().CompareTo("ISSD") ) {
274 if(!fISSDElement) CreateISSDElement();
275 fISSDElement->ProcessBlock(block);
276 }
277
278 else if ( ! block->GetDetector().CompareTo("TRD") ) {
279 if(!fTRDElement) CreateTRDElement();
280 fTRDElement->ProcessBlock(block);
281 }
282
283 else if ( ! block->GetDetector().CompareTo("MUON") ) {
284 //Do Nothing
285 } else {
286 if(!fAnyElement) {
287 fAnyElement = new AliHLTEveAny();
288 fAnyElement->SetEventManager(this);
289 }
290 fAnyElement->ProcessBlock(block);
291 }
292
293 }
294
295
296 if(fShowMuon) {
297 if ( ! block->GetDetector().CompareTo("MUON") ) {
298 if(!fMuonElement) {
299 fMuonElement = new AliHLTEveMuon();
300 fMuonElement->SetEventManager(this);
301 gEve->AddElement(fMuonElement);
302 }
303 fMuonElement->ProcessBlock(block);
304 }
305 }
306
307}
308
309void AliEveHLTEventManager::ResetDisplay () {
310 //See header file for documentation
311
312 if(fPhosElement)
313 fPhosElement->ResetElements();
314
315 if(fEmcalElement)
316 fEmcalElement->ResetElements();
317
318 if(fTPCElement)
319 fTPCElement->ResetElements();
320
321 if(fHLTElement)
322 fHLTElement->ResetElements();
323
324 if(fITSElement)
325 fITSElement->ResetElements();
326
327 if(fISPDElement)
328 fISPDElement->ResetElements();
329
330 if(fISDDElement)
331 fISDDElement->ResetElements();
332
333 if(fISSDElement)
334 fISSDElement->ResetElements();
335
336 if (fTRDElement)
337 fTRDElement->ResetElements();
338
339 if(fAnyElement)
340 fAnyElement->ResetElements();
341
342 if(fMuonElement)
343 fMuonElement->ResetElements();
344
345}
346
347
348void AliEveHLTEventManager::PrintScreens() {
349// //See header file for documentation
350
351// fEveManager->GetDefaultGLViewer()->SavePicture(Form("%d_0x%lu_3D.gif", fRunNumber, GetEventID(fCurrentEventIdx)));
352// fRhoZViewer->GetGLViewer()->SavePicture(Form("%d_0x%lu_RhoZ.gif", fRunNumber, GetEventID(fCurrentEventIdx)));
353// fRPhiViewer->GetGLViewer()->SavePicture(Form("%d_0x%lu_RPhi.gif", fRunNumber, GetEventID(fCurrentEventIdx)));
354 return;
355}
356
357
358void AliEveHLTEventManager::StartLoop() {
359 //See header file for documentation
360 //fTimer->SetCommand("NextEvent()", "AliEveHLTEventManager", this);
d63d227e 361 NextEvent();
30e7579c 362 SetEventLoopStarted(kTRUE);
d63d227e 363 fTimer->Start(15000);
30e7579c 364}
365
366void AliEveHLTEventManager::StopLoop() {
367 //See header file for documentation
368 fTimer->Stop();
369 SetEventLoopStarted(kFALSE);
370}
371
372
373// void AliEveHLTEventManager::NavigateBack() {
374
375// if (fHomerManager->NavigateEventBufferBack()) {
376// //return -1;
377// } else {
378
379// TList * blockList = fHomerManager->GetBlockList();
380// if(blockList) {
381// ProcessEvent(blockList);
382// } else {
383// cout << "BALLE Error blocklist NULL pointer even though it's navigateable"<<endl;
384// }
385// }
386
387// }
388
389// void AliEveHLTEventManager::NavigateFwd() {
390
391// if (fHomerManager->NavigateEventBufferFwd()) {
392// cout << "No event available" << endl;
393// return;
394// //return -1;
395// } else {
396// cout << "Getting block list" << endl;
397// TList * blockList = fHomerManager->GetBlockList();
398// if (blockList){
399// ProcessEvent(blockList);
400// } else {
401// cout << "blockList is NULL pointer"<<endl;
402// }
403// }
404
405// }
406
407void AliEveHLTEventManager::UpdateDisplay() {
408 //See header file for documentation
409 if(fPhosElement) fPhosElement->UpdateElements();
410 if(fEmcalElement) fEmcalElement->UpdateElements();
411 if(fTPCElement) fTPCElement->UpdateElements();
412 if(fHLTElement) fHLTElement->UpdateElements();
413 if(fITSElement) fITSElement->UpdateElements();
414 if(fISSDElement) fISSDElement->UpdateElements();
415 if(fISDDElement) fISDDElement->UpdateElements();
416 if(fISPDElement) fISPDElement->UpdateElements();
417 if(fTRDElement) fTRDElement->UpdateElements();
418 if(fAnyElement) fAnyElement->UpdateElements();
419 if(fMuonElement) fMuonElement->UpdateElements();
420
421
30e7579c 422 //==============================================================================
423 // -- Import global scene into projection scenes
424 //==============================================================================
425
426 Double_t x[3] = { 0, 0, 0 };
427
428 TEveElement* top = GetEveManager()->GetCurrentEvent();
429
430 if (fRPhiManager && top) {
431 fRPhiEventScene->DestroyElements();
432 if (fCenterProjectionsAtPrimaryVertex)
433 fRPhiManager->SetCenter(x[0], x[1], x[2]);
434 fRPhiManager->ImportElements(top, fRPhiEventScene);
435 }
436
437 if (fRhoZManager && top) {
438 fRhoZEventScene->DestroyElements();
439 if (fCenterProjectionsAtPrimaryVertex)
440 fRhoZManager->SetCenter(x[0], x[1], x[2]);
441 fRhoZManager->ImportElements(top, fRhoZEventScene);
442 }
443
444
445 //Redraw the display
446 GetEveManager()->Redraw3D(0,1); // (0, 1)
447 GetEveManager()->EnableRedraw();
448
449}
450
451void AliEveHLTEventManager::SaveEveryThing() {
452
453 GetEventBuffer()->WriteToFile();
454 //Save everything to file
455 //fEventBuffer->SaveBlockList();
456 //fEventBuffer->SaveAsyncBlockList();
457
458
459}
460
461
462
463void AliEveHLTEventManager::CreatePhosElement() {
464 fPhosElement = new AliHLTEvePhos();
465 fPhosElement->SetEventManager(this);
466 gEve->AddElement(fPhosElement);
467}
468
469void AliEveHLTEventManager::CreateEmcalElement() {
470 fEmcalElement = new AliHLTEveEmcal();
471 fEmcalElement->SetEventManager(this);
472 gEve->AddElement(fEmcalElement);
473}
474void AliEveHLTEventManager::CreateTPCElement() {
475 fTPCElement = new AliHLTEveTPC();
476 fTPCElement->SetEventManager(this);
477 gEve->AddElement(fTPCElement);
478}
479void AliEveHLTEventManager::CreateITSElement() {
480 fITSElement = new AliHLTEveITS();
481 fITSElement->SetEventManager(this);
482 gEve->AddElement(fITSElement);
483}
484void AliEveHLTEventManager::CreateISPDElement() {
485 fISPDElement = new AliHLTEveISPD();
486 fISPDElement->SetEventManager(this);
487 gEve->AddElement(fISPDElement);
488}
489void AliEveHLTEventManager::CreateISDDElement() {
490 fISDDElement = new AliHLTEveISDD();
491 fISDDElement->SetEventManager(this);
492 gEve->AddElement(fISSDElement);
493}
494void AliEveHLTEventManager::CreateISSDElement() {
495 fISSDElement = new AliHLTEveISSD();
496 fISSDElement->SetEventManager(this);
497 gEve->AddElement(fISSDElement);
498}
499void AliEveHLTEventManager::CreateTRDElement() {
500 fTRDElement = new AliHLTEveTRD();
501 fTRDElement->SetEventManager(this);
502 gEve->AddElement(fTRDElement);
503}
504void AliEveHLTEventManager::CreateHLTElement() {
505 fHLTElement = new AliHLTEveHLT();
506 fHLTElement->SetEventManager(this);
507 gEve->AddElement(fHLTElement);
508}
509
510