]>
Commit | Line | Data |
---|---|---|
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" | |
220b9d66 | 19 | #include "AliHLTEveMultCorr.h" |
30e7579c | 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" | |
30e7579c | 28 | #include "TThread.h" |
29 | ||
30 | ClassImp(AliEveHLTEventManager); | |
31 | ||
32 | AliEveHLTEventManager::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), | |
220b9d66 | 53 | fMultCorrElement(NULL), |
30e7579c | 54 | fAnyElement(NULL), |
55 | fEventLoopStarted(kFALSE), | |
56 | fCenterProjectionsAtPrimaryVertex(kFALSE), | |
57 | fShowBarrel(kTRUE), | |
58 | fShowMuon(kFALSE), | |
359ecc79 | 59 | fRunNumber(666), |
cc87822c | 60 | fEventId(-1) |
30e7579c | 61 | { |
62 | // see header file for class documentation | |
63 | // or | |
64 | // refer to README to build package | |
65 | // or | |
66 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
67 | ||
68 | fTimer = new TTimer(); | |
69 | fTimer->Connect("Timeout()", "AliEveHLTEventManager", this, "NextEvent()" ); | |
70 | ||
71 | } | |
72 | ||
73 | AliEveHLTEventManager::~AliEveHLTEventManager() { | |
74 | ||
75 | //DestroyElements(); | |
76 | //DestroyDetectorElements(); | |
77 | ||
78 | } | |
79 | ||
80 | ||
81 | void AliEveHLTEventManager::DestroyDetectorElements(){ | |
82 | //See header file for documentation | |
83 | ||
84 | if (fPhosElement) | |
85 | delete fPhosElement; | |
86 | fPhosElement = NULL; | |
87 | ||
88 | if(fEmcalElement) | |
89 | delete fEmcalElement; | |
90 | fEmcalElement = NULL; | |
91 | ||
92 | if(fTPCElement) | |
93 | delete fTPCElement; | |
94 | fTPCElement = NULL; | |
95 | ||
96 | if(fHLTElement) | |
97 | delete fHLTElement; | |
98 | fHLTElement = NULL; | |
99 | ||
100 | if(fITSElement) | |
101 | delete fITSElement; | |
102 | fITSElement = NULL; | |
103 | ||
104 | if(fISSDElement) | |
105 | delete fISSDElement; | |
106 | fISSDElement = NULL; | |
107 | ||
108 | if(fISDDElement) | |
109 | delete fISDDElement; | |
110 | fISDDElement = NULL; | |
111 | ||
112 | if(fISPDElement) | |
113 | delete fISPDElement; | |
114 | fISPDElement = NULL; | |
115 | ||
116 | if(fTRDElement) | |
117 | delete fTRDElement; | |
118 | fTRDElement = NULL; | |
119 | ||
120 | if(fMuonElement) | |
121 | delete fMuonElement; | |
122 | fMuonElement = NULL; | |
220b9d66 | 123 | |
124 | if(fMultCorrElement) | |
125 | delete fMultCorrElement; | |
126 | fMultCorrElement = NULL; | |
30e7579c | 127 | |
128 | if(fAnyElement) | |
129 | delete fAnyElement; | |
130 | fAnyElement = NULL; | |
131 | ||
132 | ||
133 | } | |
239fdf4e | 134 | |
30e7579c | 135 | ///_______________________________________________________________________________________ |
136 | void AliEveHLTEventManager::ConnectEventBuffer() { | |
137 | GetEventBuffer()->ConnectToSource(); | |
138 | } | |
139 | ||
140 | ||
141 | ///___________________________________________________________________________________________ | |
142 | void AliEveHLTEventManager::StartBufferMonitor() { | |
143 | AliEveEventBuffer * buffer = GetEventBuffer(); | |
239fdf4e | 144 | buffer->StartBufferMonitor(); |
30e7579c | 145 | } |
239fdf4e | 146 | |
30e7579c | 147 | //______________________________________________________________________________________________ |
148 | Int_t AliEveHLTEventManager::ProcessEvent(AliESDEvent * event) { | |
149 | ||
150 | //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 | 151 | |
152 | gEve->DisableRedraw(); | |
153 | ||
359ecc79 | 154 | event->GetStdContent(); |
8676f4b1 | 155 | // -- Set EventID in Window Title |
156 | TString winTitle("Eve Main Window"); | |
cc87822c | 157 | SetRunNumber(event->GetRunNumber()); |
158 | SetEventId(GetEventBuffer()->GetEventId()); | |
159 | winTitle += Form("-- Run Number: %d", GetRunNumber()); | |
5d5e744e | 160 | winTitle += Form("-- Event ID : 0x%016llu", GetEventId() ); |
8676f4b1 | 161 | GetEveManager()->GetBrowser()->SetWindowName(winTitle); |
162 | ||
30e7579c | 163 | if(!fHLTElement) { |
164 | fHLTElement = new AliHLTEveHLT(); | |
165 | fHLTElement->SetEventManager(this); | |
166 | gEve->AddElement(fHLTElement); | |
167 | } | |
168 | fHLTElement->ProcessEsdEvent(event); | |
169 | ||
170 | if(!fPhosElement) CreatePhosElement(); | |
171 | fPhosElement->ProcessEvent(event); | |
172 | ||
173 | if(!fEmcalElement) CreateEmcalElement(); | |
174 | fEmcalElement->ProcessEvent(event); | |
f4719a27 | 175 | |
176 | gEve->FullRedraw3D(0, 1); | |
b088c0a1 | 177 | gEve->EnableRedraw(); |
178 | ||
30e7579c | 179 | return 0; |
180 | ||
181 | } | |
182 | ||
183 | ||
184 | ||
185 | //______________________________________________________________________________________________ | |
186 | Int_t AliEveHLTEventManager::ProcessEvent(TList * blockList) { | |
187 | ||
188 | //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) | |
189 | ||
190 | if(!blockList) { | |
191 | cout << "Block list is NULL pointer, return " << endl; | |
192 | return -1; | |
193 | } | |
194 | ||
f4719a27 | 195 | gEve->DisableRedraw(); |
d5bb2040 | 196 | |
30e7579c | 197 | AliHLTHOMERBlockDesc * block = NULL; |
198 | TIter next(blockList); | |
199 | while ((block = (AliHLTHOMERBlockDesc*)next())) { | |
200 | cout <<"Process Block"<<endl; | |
201 | ProcessBlock(block); | |
202 | } | |
30e7579c | 203 | |
d5bb2040 | 204 | |
30e7579c | 205 | return 0; |
206 | ||
207 | } | |
239fdf4e | 208 | ///___________________________________________________________________________________________ |
30e7579c | 209 | |
210 | void 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(); | |
d48add50 | 242 | |
243 | if(!block->GetDataType().CompareTo("ALIESDV0")) { | |
244 | AliESDEvent * event = dynamic_cast<AliESDEvent *>(block->GetTObject()); | |
245 | if(event) { | |
246 | ProcessEvent(event); | |
247 | } | |
220b9d66 | 248 | |
249 | } else if(!(block->GetDataType().CompareTo("ROOTTOBJ"))) { | |
250 | ||
251 | if(!fMultCorrElement) CreateMultCorrElement(); | |
252 | fMultCorrElement->ProcessBlock(block); | |
253 | ||
d48add50 | 254 | } else { |
255 | fHLTElement->ProcessBlock(block); | |
256 | } | |
30e7579c | 257 | } |
258 | ||
259 | else if ( ! block->GetDetector().CompareTo("ITS") ) { | |
260 | if(!fITSElement) CreateITSElement(); | |
261 | fITSElement->ProcessBlock(block); | |
262 | } | |
263 | ||
264 | else if ( ! block->GetDetector().CompareTo("ISDD") ) { | |
265 | if(!fISDDElement) CreateISDDElement(); | |
266 | fISDDElement->ProcessBlock(block); | |
267 | } | |
268 | ||
269 | else if ( ! block->GetDetector().CompareTo("ISPD") ) { | |
270 | if(!fISPDElement) CreateISPDElement(); | |
271 | fISPDElement->ProcessBlock(block); | |
272 | } | |
273 | ||
274 | else if ( ! block->GetDetector().CompareTo("ISSD") ) { | |
275 | if(!fISSDElement) CreateISSDElement(); | |
276 | fISSDElement->ProcessBlock(block); | |
277 | } | |
278 | ||
279 | else if ( ! block->GetDetector().CompareTo("TRD") ) { | |
280 | if(!fTRDElement) CreateTRDElement(); | |
281 | fTRDElement->ProcessBlock(block); | |
282 | } | |
283 | ||
284 | else if ( ! block->GetDetector().CompareTo("MUON") ) { | |
285 | //Do Nothing | |
f4719a27 | 286 | if(!block->GetDataType().CompareTo("ROOTHIST")) { |
287 | if(!fMuonElement) { | |
288 | fMuonElement = new AliHLTEveMuon(); | |
289 | fMuonElement->SetEventManager(this); | |
290 | gEve->AddElement(fMuonElement); | |
291 | } | |
292 | fMuonElement->ProcessBlock(block); | |
293 | } | |
294 | ||
30e7579c | 295 | } else { |
296 | if(!fAnyElement) { | |
297 | fAnyElement = new AliHLTEveAny(); | |
298 | fAnyElement->SetEventManager(this); | |
299 | } | |
300 | fAnyElement->ProcessBlock(block); | |
301 | } | |
302 | ||
303 | } | |
304 | ||
305 | ||
306 | if(fShowMuon) { | |
307 | if ( ! block->GetDetector().CompareTo("MUON") ) { | |
308 | if(!fMuonElement) { | |
309 | fMuonElement = new AliHLTEveMuon(); | |
310 | fMuonElement->SetEventManager(this); | |
311 | gEve->AddElement(fMuonElement); | |
312 | } | |
313 | fMuonElement->ProcessBlock(block); | |
314 | } | |
315 | } | |
316 | ||
317 | } | |
318 | ||
319 | void AliEveHLTEventManager::ResetDisplay () { | |
320 | //See header file for documentation | |
321 | ||
322 | if(fPhosElement) | |
323 | fPhosElement->ResetElements(); | |
324 | ||
325 | if(fEmcalElement) | |
326 | fEmcalElement->ResetElements(); | |
327 | ||
328 | if(fTPCElement) | |
329 | fTPCElement->ResetElements(); | |
330 | ||
331 | if(fHLTElement) | |
332 | fHLTElement->ResetElements(); | |
333 | ||
334 | if(fITSElement) | |
335 | fITSElement->ResetElements(); | |
336 | ||
337 | if(fISPDElement) | |
338 | fISPDElement->ResetElements(); | |
339 | ||
340 | if(fISDDElement) | |
341 | fISDDElement->ResetElements(); | |
342 | ||
343 | if(fISSDElement) | |
344 | fISSDElement->ResetElements(); | |
345 | ||
346 | if (fTRDElement) | |
347 | fTRDElement->ResetElements(); | |
348 | ||
349 | if(fAnyElement) | |
350 | fAnyElement->ResetElements(); | |
351 | ||
352 | if(fMuonElement) | |
353 | fMuonElement->ResetElements(); | |
354 | ||
355 | } | |
356 | ||
357 | ||
358 | void AliEveHLTEventManager::PrintScreens() { | |
359 | // //See header file for documentation | |
360 | ||
cf331698 | 361 | Float_t scale = 4.f; |
362 | //Int_t width = 4000; | |
363 | //Int_t height = 2000; | |
364 | ||
5d5e744e | 365 | fEveManager->GetDefaultGLViewer()->SavePictureScale(Form("run_%d_0x%016llu_3D.gif", fRunNumber, GetEventId()), scale); |
366 | fRhoZViewer->GetGLViewer()->SavePictureScale(Form("run_%d_0x%016llu_RhoZ.gif", fRunNumber, GetEventId()), scale); | |
367 | fRPhiViewer->GetGLViewer()->SavePictureScale(Form("run_%d_0x%016llu_RPhi.gif", fRunNumber, GetEventId()), scale); | |
30e7579c | 368 | return; |
369 | } | |
370 | ||
371 | ||
372 | void AliEveHLTEventManager::StartLoop() { | |
373 | //See header file for documentation | |
374 | //fTimer->SetCommand("NextEvent()", "AliEveHLTEventManager", this); | |
d63d227e | 375 | NextEvent(); |
30e7579c | 376 | SetEventLoopStarted(kTRUE); |
ce63b00c | 377 | fTimer->Start(45000); |
30e7579c | 378 | } |
379 | ||
380 | void AliEveHLTEventManager::StopLoop() { | |
381 | //See header file for documentation | |
382 | fTimer->Stop(); | |
383 | SetEventLoopStarted(kFALSE); | |
384 | } | |
385 | ||
386 | ||
387 | // void AliEveHLTEventManager::NavigateBack() { | |
388 | ||
389 | // if (fHomerManager->NavigateEventBufferBack()) { | |
390 | // //return -1; | |
391 | // } else { | |
392 | ||
393 | // TList * blockList = fHomerManager->GetBlockList(); | |
394 | // if(blockList) { | |
395 | // ProcessEvent(blockList); | |
396 | // } else { | |
397 | // cout << "BALLE Error blocklist NULL pointer even though it's navigateable"<<endl; | |
398 | // } | |
399 | // } | |
400 | ||
401 | // } | |
402 | ||
403 | // void AliEveHLTEventManager::NavigateFwd() { | |
404 | ||
405 | // if (fHomerManager->NavigateEventBufferFwd()) { | |
406 | // cout << "No event available" << endl; | |
407 | // return; | |
408 | // //return -1; | |
409 | // } else { | |
410 | // cout << "Getting block list" << endl; | |
411 | // TList * blockList = fHomerManager->GetBlockList(); | |
412 | // if (blockList){ | |
413 | // ProcessEvent(blockList); | |
414 | // } else { | |
415 | // cout << "blockList is NULL pointer"<<endl; | |
416 | // } | |
417 | // } | |
418 | ||
419 | // } | |
420 | ||
421 | void AliEveHLTEventManager::UpdateDisplay() { | |
422 | //See header file for documentation | |
fc482d0c | 423 | cout << "AliHLTEventManager::UpdateDisplay(); " <<endl; |
30e7579c | 424 | if(fPhosElement) fPhosElement->UpdateElements(); |
425 | if(fEmcalElement) fEmcalElement->UpdateElements(); | |
426 | if(fTPCElement) fTPCElement->UpdateElements(); | |
427 | if(fHLTElement) fHLTElement->UpdateElements(); | |
428 | if(fITSElement) fITSElement->UpdateElements(); | |
429 | if(fISSDElement) fISSDElement->UpdateElements(); | |
430 | if(fISDDElement) fISDDElement->UpdateElements(); | |
431 | if(fISPDElement) fISPDElement->UpdateElements(); | |
432 | if(fTRDElement) fTRDElement->UpdateElements(); | |
433 | if(fAnyElement) fAnyElement->UpdateElements(); | |
434 | if(fMuonElement) fMuonElement->UpdateElements(); | |
7031af42 | 435 | if(fMultCorrElement) fMultCorrElement->UpdateElements(); |
30e7579c | 436 | |
437 | ||
30e7579c | 438 | //============================================================================== |
439 | // -- Import global scene into projection scenes | |
440 | //============================================================================== | |
441 | ||
442 | Double_t x[3] = { 0, 0, 0 }; | |
443 | ||
444 | TEveElement* top = GetEveManager()->GetCurrentEvent(); | |
445 | ||
446 | if (fRPhiManager && top) { | |
447 | fRPhiEventScene->DestroyElements(); | |
448 | if (fCenterProjectionsAtPrimaryVertex) | |
449 | fRPhiManager->SetCenter(x[0], x[1], x[2]); | |
450 | fRPhiManager->ImportElements(top, fRPhiEventScene); | |
451 | } | |
452 | ||
453 | if (fRhoZManager && top) { | |
454 | fRhoZEventScene->DestroyElements(); | |
455 | if (fCenterProjectionsAtPrimaryVertex) | |
456 | fRhoZManager->SetCenter(x[0], x[1], x[2]); | |
457 | fRhoZManager->ImportElements(top, fRhoZEventScene); | |
458 | } | |
459 | ||
460 | ||
461 | //Redraw the display | |
462 | GetEveManager()->Redraw3D(0,1); // (0, 1) | |
463 | GetEveManager()->EnableRedraw(); | |
464 | ||
465 | } | |
466 | ||
467 | void AliEveHLTEventManager::SaveEveryThing() { | |
468 | ||
fc482d0c | 469 | //Print the screens |
cc87822c | 470 | PrintScreens(); |
fc482d0c | 471 | //Save block lists to file |
cc87822c | 472 | GetEventBuffer()->WriteToFile(GetRunNumber()); |
30e7579c | 473 | } |
474 | ||
475 | ||
476 | ||
477 | void AliEveHLTEventManager::CreatePhosElement() { | |
478 | fPhosElement = new AliHLTEvePhos(); | |
479 | fPhosElement->SetEventManager(this); | |
480 | gEve->AddElement(fPhosElement); | |
481 | } | |
482 | ||
220b9d66 | 483 | void AliEveHLTEventManager::CreateMultCorrElement() { |
484 | fMultCorrElement = new AliHLTEveMultCorr("MultCorr"); | |
485 | fMultCorrElement->SetEventManager(this); | |
486 | gEve->AddElement(fMultCorrElement); | |
487 | } | |
488 | ||
30e7579c | 489 | void AliEveHLTEventManager::CreateEmcalElement() { |
490 | fEmcalElement = new AliHLTEveEmcal(); | |
491 | fEmcalElement->SetEventManager(this); | |
492 | gEve->AddElement(fEmcalElement); | |
493 | } | |
494 | void AliEveHLTEventManager::CreateTPCElement() { | |
495 | fTPCElement = new AliHLTEveTPC(); | |
496 | fTPCElement->SetEventManager(this); | |
497 | gEve->AddElement(fTPCElement); | |
498 | } | |
499 | void AliEveHLTEventManager::CreateITSElement() { | |
500 | fITSElement = new AliHLTEveITS(); | |
501 | fITSElement->SetEventManager(this); | |
502 | gEve->AddElement(fITSElement); | |
503 | } | |
504 | void AliEveHLTEventManager::CreateISPDElement() { | |
505 | fISPDElement = new AliHLTEveISPD(); | |
506 | fISPDElement->SetEventManager(this); | |
507 | gEve->AddElement(fISPDElement); | |
508 | } | |
509 | void AliEveHLTEventManager::CreateISDDElement() { | |
510 | fISDDElement = new AliHLTEveISDD(); | |
511 | fISDDElement->SetEventManager(this); | |
512 | gEve->AddElement(fISSDElement); | |
513 | } | |
514 | void AliEveHLTEventManager::CreateISSDElement() { | |
515 | fISSDElement = new AliHLTEveISSD(); | |
516 | fISSDElement->SetEventManager(this); | |
517 | gEve->AddElement(fISSDElement); | |
518 | } | |
519 | void AliEveHLTEventManager::CreateTRDElement() { | |
520 | fTRDElement = new AliHLTEveTRD(); | |
521 | fTRDElement->SetEventManager(this); | |
522 | gEve->AddElement(fTRDElement); | |
523 | } | |
524 | void AliEveHLTEventManager::CreateHLTElement() { | |
525 | fHLTElement = new AliHLTEveHLT(); | |
526 | fHLTElement->SetEventManager(this); | |
527 | gEve->AddElement(fHLTElement); | |
528 | } | |
529 | ||
530 |