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