]>
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()); | |
160 | winTitle += Form("-- Event ID : 0x%016lX ", 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); | |
30e7579c | 175 | |
b088c0a1 | 176 | gEve->Redraw3D(0, 1); |
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 | ||
d5bb2040 | 195 | |
30e7579c | 196 | AliHLTHOMERBlockDesc * block = NULL; |
197 | TIter next(blockList); | |
198 | while ((block = (AliHLTHOMERBlockDesc*)next())) { | |
199 | cout <<"Process Block"<<endl; | |
200 | ProcessBlock(block); | |
201 | } | |
30e7579c | 202 | |
d5bb2040 | 203 | |
30e7579c | 204 | return 0; |
205 | ||
206 | } | |
239fdf4e | 207 | ///___________________________________________________________________________________________ |
30e7579c | 208 | |
209 | void AliEveHLTEventManager::ProcessBlock(AliHLTHOMERBlockDesc * block) { | |
210 | //See header file for documentation | |
211 | ||
212 | #if 1//DEBUG | |
213 | printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n"); | |
214 | printf( "Detector : %s\n", block->GetDetector().Data() ); | |
215 | printf( "Datatype : %s\n", block->GetDataType().Data() ); | |
216 | if (block->IsTObject() ) | |
217 | printf( "Is TObject of class: %s\n", block->GetClassName().Data() ); | |
218 | printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n"); | |
219 | #endif | |
220 | ||
221 | ||
222 | if(fShowBarrel) { | |
223 | ||
224 | if ( ! block->GetDetector().CompareTo("PHOS") ) { | |
225 | if(!fPhosElement) CreatePhosElement(); | |
226 | fPhosElement->ProcessBlock(block); | |
227 | } | |
228 | ||
229 | else if ( ! block->GetDetector().CompareTo("EMCA") ) { | |
230 | if(!fEmcalElement) CreateEmcalElement(); | |
231 | fEmcalElement->ProcessBlock(block); | |
232 | } | |
233 | ||
234 | else if ( ! block->GetDetector().CompareTo("TPC") ) { | |
235 | if(!fTPCElement) CreateTPCElement(); | |
236 | fTPCElement->ProcessBlock(block); | |
237 | } | |
238 | ||
239 | else if ( ! block->GetDetector().CompareTo("HLT") ) { | |
240 | if(!fHLTElement) CreateHLTElement(); | |
d48add50 | 241 | |
242 | if(!block->GetDataType().CompareTo("ALIESDV0")) { | |
243 | AliESDEvent * event = dynamic_cast<AliESDEvent *>(block->GetTObject()); | |
244 | if(event) { | |
245 | ProcessEvent(event); | |
246 | } | |
220b9d66 | 247 | |
248 | } else if(!(block->GetDataType().CompareTo("ROOTTOBJ"))) { | |
249 | ||
250 | if(!fMultCorrElement) CreateMultCorrElement(); | |
251 | fMultCorrElement->ProcessBlock(block); | |
252 | ||
d48add50 | 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 | ||
309 | void 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 | ||
348 | void AliEveHLTEventManager::PrintScreens() { | |
349 | // //See header file for documentation | |
350 | ||
cf331698 | 351 | Float_t scale = 4.f; |
352 | //Int_t width = 4000; | |
353 | //Int_t height = 2000; | |
354 | ||
355 | fEveManager->GetDefaultGLViewer()->SavePictureScale(Form("run_%d_0x%016lX_3D.gif", fRunNumber, GetEventId()), scale); | |
356 | fRhoZViewer->GetGLViewer()->SavePictureScale(Form("run_%d_0x%016lX_RhoZ.gif", fRunNumber, GetEventId()), scale); | |
357 | fRPhiViewer->GetGLViewer()->SavePictureScale(Form("run_%d_0x%016lX_RPhi.gif", fRunNumber, GetEventId()), scale); | |
30e7579c | 358 | return; |
359 | } | |
360 | ||
361 | ||
362 | void AliEveHLTEventManager::StartLoop() { | |
363 | //See header file for documentation | |
364 | //fTimer->SetCommand("NextEvent()", "AliEveHLTEventManager", this); | |
d63d227e | 365 | NextEvent(); |
30e7579c | 366 | SetEventLoopStarted(kTRUE); |
ce63b00c | 367 | fTimer->Start(45000); |
30e7579c | 368 | } |
369 | ||
370 | void AliEveHLTEventManager::StopLoop() { | |
371 | //See header file for documentation | |
372 | fTimer->Stop(); | |
373 | SetEventLoopStarted(kFALSE); | |
374 | } | |
375 | ||
376 | ||
377 | // void AliEveHLTEventManager::NavigateBack() { | |
378 | ||
379 | // if (fHomerManager->NavigateEventBufferBack()) { | |
380 | // //return -1; | |
381 | // } else { | |
382 | ||
383 | // TList * blockList = fHomerManager->GetBlockList(); | |
384 | // if(blockList) { | |
385 | // ProcessEvent(blockList); | |
386 | // } else { | |
387 | // cout << "BALLE Error blocklist NULL pointer even though it's navigateable"<<endl; | |
388 | // } | |
389 | // } | |
390 | ||
391 | // } | |
392 | ||
393 | // void AliEveHLTEventManager::NavigateFwd() { | |
394 | ||
395 | // if (fHomerManager->NavigateEventBufferFwd()) { | |
396 | // cout << "No event available" << endl; | |
397 | // return; | |
398 | // //return -1; | |
399 | // } else { | |
400 | // cout << "Getting block list" << endl; | |
401 | // TList * blockList = fHomerManager->GetBlockList(); | |
402 | // if (blockList){ | |
403 | // ProcessEvent(blockList); | |
404 | // } else { | |
405 | // cout << "blockList is NULL pointer"<<endl; | |
406 | // } | |
407 | // } | |
408 | ||
409 | // } | |
410 | ||
411 | void AliEveHLTEventManager::UpdateDisplay() { | |
412 | //See header file for documentation | |
fc482d0c | 413 | cout << "AliHLTEventManager::UpdateDisplay(); " <<endl; |
30e7579c | 414 | if(fPhosElement) fPhosElement->UpdateElements(); |
415 | if(fEmcalElement) fEmcalElement->UpdateElements(); | |
416 | if(fTPCElement) fTPCElement->UpdateElements(); | |
417 | if(fHLTElement) fHLTElement->UpdateElements(); | |
418 | if(fITSElement) fITSElement->UpdateElements(); | |
419 | if(fISSDElement) fISSDElement->UpdateElements(); | |
420 | if(fISDDElement) fISDDElement->UpdateElements(); | |
421 | if(fISPDElement) fISPDElement->UpdateElements(); | |
422 | if(fTRDElement) fTRDElement->UpdateElements(); | |
423 | if(fAnyElement) fAnyElement->UpdateElements(); | |
424 | if(fMuonElement) fMuonElement->UpdateElements(); | |
7031af42 | 425 | if(fMultCorrElement) fMultCorrElement->UpdateElements(); |
30e7579c | 426 | |
427 | ||
30e7579c | 428 | //============================================================================== |
429 | // -- Import global scene into projection scenes | |
430 | //============================================================================== | |
431 | ||
432 | Double_t x[3] = { 0, 0, 0 }; | |
433 | ||
434 | TEveElement* top = GetEveManager()->GetCurrentEvent(); | |
435 | ||
436 | if (fRPhiManager && top) { | |
437 | fRPhiEventScene->DestroyElements(); | |
438 | if (fCenterProjectionsAtPrimaryVertex) | |
439 | fRPhiManager->SetCenter(x[0], x[1], x[2]); | |
440 | fRPhiManager->ImportElements(top, fRPhiEventScene); | |
441 | } | |
442 | ||
443 | if (fRhoZManager && top) { | |
444 | fRhoZEventScene->DestroyElements(); | |
445 | if (fCenterProjectionsAtPrimaryVertex) | |
446 | fRhoZManager->SetCenter(x[0], x[1], x[2]); | |
447 | fRhoZManager->ImportElements(top, fRhoZEventScene); | |
448 | } | |
449 | ||
450 | ||
451 | //Redraw the display | |
452 | GetEveManager()->Redraw3D(0,1); // (0, 1) | |
453 | GetEveManager()->EnableRedraw(); | |
454 | ||
455 | } | |
456 | ||
457 | void AliEveHLTEventManager::SaveEveryThing() { | |
458 | ||
fc482d0c | 459 | //Print the screens |
cc87822c | 460 | PrintScreens(); |
fc482d0c | 461 | //Save block lists to file |
cc87822c | 462 | GetEventBuffer()->WriteToFile(GetRunNumber()); |
30e7579c | 463 | } |
464 | ||
465 | ||
466 | ||
467 | void AliEveHLTEventManager::CreatePhosElement() { | |
468 | fPhosElement = new AliHLTEvePhos(); | |
469 | fPhosElement->SetEventManager(this); | |
470 | gEve->AddElement(fPhosElement); | |
471 | } | |
472 | ||
220b9d66 | 473 | void AliEveHLTEventManager::CreateMultCorrElement() { |
474 | fMultCorrElement = new AliHLTEveMultCorr("MultCorr"); | |
475 | fMultCorrElement->SetEventManager(this); | |
476 | gEve->AddElement(fMultCorrElement); | |
477 | } | |
478 | ||
30e7579c | 479 | void AliEveHLTEventManager::CreateEmcalElement() { |
480 | fEmcalElement = new AliHLTEveEmcal(); | |
481 | fEmcalElement->SetEventManager(this); | |
482 | gEve->AddElement(fEmcalElement); | |
483 | } | |
484 | void AliEveHLTEventManager::CreateTPCElement() { | |
485 | fTPCElement = new AliHLTEveTPC(); | |
486 | fTPCElement->SetEventManager(this); | |
487 | gEve->AddElement(fTPCElement); | |
488 | } | |
489 | void AliEveHLTEventManager::CreateITSElement() { | |
490 | fITSElement = new AliHLTEveITS(); | |
491 | fITSElement->SetEventManager(this); | |
492 | gEve->AddElement(fITSElement); | |
493 | } | |
494 | void AliEveHLTEventManager::CreateISPDElement() { | |
495 | fISPDElement = new AliHLTEveISPD(); | |
496 | fISPDElement->SetEventManager(this); | |
497 | gEve->AddElement(fISPDElement); | |
498 | } | |
499 | void AliEveHLTEventManager::CreateISDDElement() { | |
500 | fISDDElement = new AliHLTEveISDD(); | |
501 | fISDDElement->SetEventManager(this); | |
502 | gEve->AddElement(fISSDElement); | |
503 | } | |
504 | void AliEveHLTEventManager::CreateISSDElement() { | |
505 | fISSDElement = new AliHLTEveISSD(); | |
506 | fISSDElement->SetEventManager(this); | |
507 | gEve->AddElement(fISSDElement); | |
508 | } | |
509 | void AliEveHLTEventManager::CreateTRDElement() { | |
510 | fTRDElement = new AliHLTEveTRD(); | |
511 | fTRDElement->SetEventManager(this); | |
512 | gEve->AddElement(fTRDElement); | |
513 | } | |
514 | void AliEveHLTEventManager::CreateHLTElement() { | |
515 | fHLTElement = new AliHLTEveHLT(); | |
516 | fHLTElement->SetEventManager(this); | |
517 | gEve->AddElement(fHLTElement); | |
518 | } | |
519 | ||
520 |