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