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