]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveHLT/AliEveHLTEventManager.cxx
Fixed busy error
[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
30e7579c 9#include "AliHLTEvePhos.h"
10#include "AliHLTEveEmcal.h"
11#include "AliHLTEveTPC.h"
12#include "AliHLTEveHLT.h"
13#include "AliHLTEveITS.h"
14#include "AliHLTEveISPD.h"
15#include "AliHLTEveISSD.h"
16#include "AliHLTEveISDD.h"
17#include "AliHLTEveTRD.h"
18#include "AliHLTEveMuon.h"
19#include "AliHLTEveAny.h"
20
21#include "AliEveHLTEventManager.h"
22#include "AliEveHOMERManager.h"
23#include "AliEveEventBuffer.h"
24
25#include "TList.h"
26#include "TTimer.h"
27
28#include "TThread.h"
29
30ClassImp(AliEveHLTEventManager);
31
32AliEveHLTEventManager::AliEveHLTEventManager() :
33 TEveElementList("Event Manager"),
34 fGeoManager(NULL),
35 fEveManager(NULL),
36 fRPhiManager(NULL),
37 fRhoZManager(NULL),
38 fRPhiEventScene(NULL),
39 fRhoZEventScene(NULL),
40 fRhoZViewer(NULL),
41 fRPhiViewer(NULL),
42 fTimer(NULL),
43 fPhosElement(NULL),
44 fEmcalElement(NULL),
45 fTPCElement(NULL),
46 fHLTElement(NULL),
47 fITSElement(NULL),
48 fISPDElement(NULL),
49 fISSDElement(NULL),
50 fISDDElement(NULL),
51 fTRDElement(NULL),
52 fMuonElement(NULL),
53 fAnyElement(NULL),
54 fEventLoopStarted(kFALSE),
55 fCenterProjectionsAtPrimaryVertex(kFALSE),
56 fShowBarrel(kTRUE),
57 fShowMuon(kFALSE),
cc87822c 58 fRunNumber(-1),
59 fEventId(-1)
30e7579c 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");
cc87822c 151 SetRunNumber(event->GetRunNumber());
152 SetEventId(GetEventBuffer()->GetEventId());
153 winTitle += Form("-- Run Number: %d", GetRunNumber());
154 winTitle += Form("-- Event ID : 0x%016lX ", GetEventId() );
8676f4b1 155 GetEveManager()->GetBrowser()->SetWindowName(winTitle);
156
157
30e7579c 158
159 cout << "reset()"<<endl;
160
161 ResetDisplay();
162
163 cout << "process()"<<endl;
164 if(!fHLTElement) {
165 fHLTElement = new AliHLTEveHLT();
166 fHLTElement->SetEventManager(this);
167 gEve->AddElement(fHLTElement);
168 }
169 fHLTElement->ProcessEsdEvent(event);
170
171 if(!fPhosElement) CreatePhosElement();
172 fPhosElement->ProcessEvent(event);
173
174 if(!fEmcalElement) CreateEmcalElement();
175 fEmcalElement->ProcessEvent(event);
176
177 cout << "update()"<<endl;
178 UpdateDisplay();
179
b088c0a1 180 gEve->Redraw3D(0, 1);
181 gEve->EnableRedraw();
182
30e7579c 183 return 0;
184
185}
186
187
188
189//______________________________________________________________________________________________
190Int_t AliEveHLTEventManager::ProcessEvent(TList * blockList) {
191
192 //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)
193
194 if(!blockList) {
195 cout << "Block list is NULL pointer, return " << endl;
196 return -1;
197 }
198
30e7579c 199 AliHLTHOMERBlockDesc * block = NULL;
200 TIter next(blockList);
201 while ((block = (AliHLTHOMERBlockDesc*)next())) {
202 cout <<"Process Block"<<endl;
203 ProcessBlock(block);
204 }
30e7579c 205
206 return 0;
207
208}
239fdf4e 209///___________________________________________________________________________________________
30e7579c 210
211void AliEveHLTEventManager::ProcessBlock(AliHLTHOMERBlockDesc * block) {
212 //See header file for documentation
213
214#if 1//DEBUG
215 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
216 printf( "Detector : %s\n", block->GetDetector().Data() );
217 printf( "Datatype : %s\n", block->GetDataType().Data() );
218 if (block->IsTObject() )
219 printf( "Is TObject of class: %s\n", block->GetClassName().Data() );
220 printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n");
221#endif
222
223
224 if(fShowBarrel) {
225
226 if ( ! block->GetDetector().CompareTo("PHOS") ) {
227 if(!fPhosElement) CreatePhosElement();
228 fPhosElement->ProcessBlock(block);
229 }
230
231 else if ( ! block->GetDetector().CompareTo("EMCA") ) {
232 if(!fEmcalElement) CreateEmcalElement();
233 fEmcalElement->ProcessBlock(block);
234 }
235
236 else if ( ! block->GetDetector().CompareTo("TPC") ) {
237 if(!fTPCElement) CreateTPCElement();
238 fTPCElement->ProcessBlock(block);
239 }
240
241 else if ( ! block->GetDetector().CompareTo("HLT") ) {
242 if(!fHLTElement) CreateHLTElement();
d48add50 243
244 if(!block->GetDataType().CompareTo("ALIESDV0")) {
245 AliESDEvent * event = dynamic_cast<AliESDEvent *>(block->GetTObject());
246 if(event) {
247 ProcessEvent(event);
248 }
249 } else {
250 fHLTElement->ProcessBlock(block);
251 }
30e7579c 252 }
253
254 else if ( ! block->GetDetector().CompareTo("ITS") ) {
255 if(!fITSElement) CreateITSElement();
256 fITSElement->ProcessBlock(block);
257 }
258
259 else if ( ! block->GetDetector().CompareTo("ISDD") ) {
260 if(!fISDDElement) CreateISDDElement();
261 fISDDElement->ProcessBlock(block);
262 }
263
264 else if ( ! block->GetDetector().CompareTo("ISPD") ) {
265 if(!fISPDElement) CreateISPDElement();
266 fISPDElement->ProcessBlock(block);
267 }
268
269 else if ( ! block->GetDetector().CompareTo("ISSD") ) {
270 if(!fISSDElement) CreateISSDElement();
271 fISSDElement->ProcessBlock(block);
272 }
273
274 else if ( ! block->GetDetector().CompareTo("TRD") ) {
275 if(!fTRDElement) CreateTRDElement();
276 fTRDElement->ProcessBlock(block);
277 }
278
279 else if ( ! block->GetDetector().CompareTo("MUON") ) {
280 //Do Nothing
281 } else {
282 if(!fAnyElement) {
283 fAnyElement = new AliHLTEveAny();
284 fAnyElement->SetEventManager(this);
285 }
286 fAnyElement->ProcessBlock(block);
287 }
288
289 }
290
291
292 if(fShowMuon) {
293 if ( ! block->GetDetector().CompareTo("MUON") ) {
294 if(!fMuonElement) {
295 fMuonElement = new AliHLTEveMuon();
296 fMuonElement->SetEventManager(this);
297 gEve->AddElement(fMuonElement);
298 }
299 fMuonElement->ProcessBlock(block);
300 }
301 }
302
303}
304
305void AliEveHLTEventManager::ResetDisplay () {
306 //See header file for documentation
307
308 if(fPhosElement)
309 fPhosElement->ResetElements();
310
311 if(fEmcalElement)
312 fEmcalElement->ResetElements();
313
314 if(fTPCElement)
315 fTPCElement->ResetElements();
316
317 if(fHLTElement)
318 fHLTElement->ResetElements();
319
320 if(fITSElement)
321 fITSElement->ResetElements();
322
323 if(fISPDElement)
324 fISPDElement->ResetElements();
325
326 if(fISDDElement)
327 fISDDElement->ResetElements();
328
329 if(fISSDElement)
330 fISSDElement->ResetElements();
331
332 if (fTRDElement)
333 fTRDElement->ResetElements();
334
335 if(fAnyElement)
336 fAnyElement->ResetElements();
337
338 if(fMuonElement)
339 fMuonElement->ResetElements();
340
341}
342
343
344void AliEveHLTEventManager::PrintScreens() {
345// //See header file for documentation
346
cc87822c 347 fEveManager->GetDefaultGLViewer()->SavePicture(Form("%d_0x%016lX_3D.gif", fRunNumber, GetEventId()));
348 fRhoZViewer->GetGLViewer()->SavePicture(Form("%d_0x%016lX_RhoZ.gif", fRunNumber, GetEventId()));
349 fRPhiViewer->GetGLViewer()->SavePicture(Form("%d_0x%016lX_RPhi.gif", fRunNumber, GetEventId()));
30e7579c 350 return;
351}
352
353
354void AliEveHLTEventManager::StartLoop() {
355 //See header file for documentation
356 //fTimer->SetCommand("NextEvent()", "AliEveHLTEventManager", this);
d63d227e 357 NextEvent();
30e7579c 358 SetEventLoopStarted(kTRUE);
d63d227e 359 fTimer->Start(15000);
30e7579c 360}
361
362void AliEveHLTEventManager::StopLoop() {
363 //See header file for documentation
364 fTimer->Stop();
365 SetEventLoopStarted(kFALSE);
366}
367
368
369// void AliEveHLTEventManager::NavigateBack() {
370
371// if (fHomerManager->NavigateEventBufferBack()) {
372// //return -1;
373// } else {
374
375// TList * blockList = fHomerManager->GetBlockList();
376// if(blockList) {
377// ProcessEvent(blockList);
378// } else {
379// cout << "BALLE Error blocklist NULL pointer even though it's navigateable"<<endl;
380// }
381// }
382
383// }
384
385// void AliEveHLTEventManager::NavigateFwd() {
386
387// if (fHomerManager->NavigateEventBufferFwd()) {
388// cout << "No event available" << endl;
389// return;
390// //return -1;
391// } else {
392// cout << "Getting block list" << endl;
393// TList * blockList = fHomerManager->GetBlockList();
394// if (blockList){
395// ProcessEvent(blockList);
396// } else {
397// cout << "blockList is NULL pointer"<<endl;
398// }
399// }
400
401// }
402
403void AliEveHLTEventManager::UpdateDisplay() {
404 //See header file for documentation
405 if(fPhosElement) fPhosElement->UpdateElements();
406 if(fEmcalElement) fEmcalElement->UpdateElements();
407 if(fTPCElement) fTPCElement->UpdateElements();
408 if(fHLTElement) fHLTElement->UpdateElements();
409 if(fITSElement) fITSElement->UpdateElements();
410 if(fISSDElement) fISSDElement->UpdateElements();
411 if(fISDDElement) fISDDElement->UpdateElements();
412 if(fISPDElement) fISPDElement->UpdateElements();
413 if(fTRDElement) fTRDElement->UpdateElements();
414 if(fAnyElement) fAnyElement->UpdateElements();
415 if(fMuonElement) fMuonElement->UpdateElements();
416
417
30e7579c 418 //==============================================================================
419 // -- Import global scene into projection scenes
420 //==============================================================================
421
422 Double_t x[3] = { 0, 0, 0 };
423
424 TEveElement* top = GetEveManager()->GetCurrentEvent();
425
426 if (fRPhiManager && top) {
427 fRPhiEventScene->DestroyElements();
428 if (fCenterProjectionsAtPrimaryVertex)
429 fRPhiManager->SetCenter(x[0], x[1], x[2]);
430 fRPhiManager->ImportElements(top, fRPhiEventScene);
431 }
432
433 if (fRhoZManager && top) {
434 fRhoZEventScene->DestroyElements();
435 if (fCenterProjectionsAtPrimaryVertex)
436 fRhoZManager->SetCenter(x[0], x[1], x[2]);
437 fRhoZManager->ImportElements(top, fRhoZEventScene);
438 }
439
440
441 //Redraw the display
442 GetEveManager()->Redraw3D(0,1); // (0, 1)
443 GetEveManager()->EnableRedraw();
444
445}
446
447void AliEveHLTEventManager::SaveEveryThing() {
448
cc87822c 449 PrintScreens();
450
451 GetEventBuffer()->WriteToFile(GetRunNumber());
30e7579c 452 //Save everything to file
453 //fEventBuffer->SaveBlockList();
454 //fEventBuffer->SaveAsyncBlockList();
455
456
457}
458
459
460
461void AliEveHLTEventManager::CreatePhosElement() {
462 fPhosElement = new AliHLTEvePhos();
463 fPhosElement->SetEventManager(this);
464 gEve->AddElement(fPhosElement);
465}
466
467void AliEveHLTEventManager::CreateEmcalElement() {
468 fEmcalElement = new AliHLTEveEmcal();
469 fEmcalElement->SetEventManager(this);
470 gEve->AddElement(fEmcalElement);
471}
472void AliEveHLTEventManager::CreateTPCElement() {
473 fTPCElement = new AliHLTEveTPC();
474 fTPCElement->SetEventManager(this);
475 gEve->AddElement(fTPCElement);
476}
477void AliEveHLTEventManager::CreateITSElement() {
478 fITSElement = new AliHLTEveITS();
479 fITSElement->SetEventManager(this);
480 gEve->AddElement(fITSElement);
481}
482void AliEveHLTEventManager::CreateISPDElement() {
483 fISPDElement = new AliHLTEveISPD();
484 fISPDElement->SetEventManager(this);
485 gEve->AddElement(fISPDElement);
486}
487void AliEveHLTEventManager::CreateISDDElement() {
488 fISDDElement = new AliHLTEveISDD();
489 fISDDElement->SetEventManager(this);
490 gEve->AddElement(fISSDElement);
491}
492void AliEveHLTEventManager::CreateISSDElement() {
493 fISSDElement = new AliHLTEveISSD();
494 fISSDElement->SetEventManager(this);
495 gEve->AddElement(fISSDElement);
496}
497void AliEveHLTEventManager::CreateTRDElement() {
498 fTRDElement = new AliHLTEveTRD();
499 fTRDElement->SetEventManager(this);
500 gEve->AddElement(fTRDElement);
501}
502void AliEveHLTEventManager::CreateHLTElement() {
503 fHLTElement = new AliHLTEveHLT();
504 fHLTElement->SetEventManager(this);
505 gEve->AddElement(fHLTElement);
506}
507
508