]>
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" | |
19 | #include "AliHLTEveAny.h" | |
20 | ||
21 | #include "AliEveHLTEventManager.h" | |
22 | #include "AliEveHOMERManager.h" | |
23 | #include "AliEveEventBuffer.h" | |
24 | ||
25 | #include "TList.h" | |
26 | #include "TTimer.h" | |
27 | ||
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), | |
53 | fAnyElement(NULL), | |
54 | fEventLoopStarted(kFALSE), | |
55 | fCenterProjectionsAtPrimaryVertex(kFALSE), | |
56 | fShowBarrel(kTRUE), | |
57 | fShowMuon(kFALSE), | |
cc87822c | 58 | fRunNumber(-1), |
59 | fEventId(-1) | |
30e7579c | 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 | ||
72 | AliEveHLTEventManager::~AliEveHLTEventManager() { | |
73 | ||
74 | //DestroyElements(); | |
75 | //DestroyDetectorElements(); | |
76 | ||
77 | } | |
78 | ||
79 | ||
80 | void 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 | ///_______________________________________________________________________________________ |
131 | void AliEveHLTEventManager::ConnectEventBuffer() { | |
132 | GetEventBuffer()->ConnectToSource(); | |
133 | } | |
134 | ||
135 | ||
136 | ///___________________________________________________________________________________________ | |
137 | void AliEveHLTEventManager::StartBufferMonitor() { | |
138 | AliEveEventBuffer * buffer = GetEventBuffer(); | |
239fdf4e | 139 | buffer->StartBufferMonitor(); |
30e7579c | 140 | } |
239fdf4e | 141 | |
30e7579c | 142 | //______________________________________________________________________________________________ |
143 | Int_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 | ||
8676f4b1 | 149 | // -- Set EventID in Window Title |
150 | TString winTitle("Eve Main Window"); | |
cc87822c | 151 | SetRunNumber(event->GetRunNumber()); |
152 | SetEventId(GetEventBuffer()->GetEventId()); | |
153 | winTitle += Form("-- Run Number: %d", GetRunNumber()); | |
154 | winTitle += Form("-- Event ID : 0x%016lX ", GetEventId() ); | |
8676f4b1 | 155 | GetEveManager()->GetBrowser()->SetWindowName(winTitle); |
156 | ||
157 | ||
30e7579c | 158 | |
159 | cout << "reset()"<<endl; | |
160 | ||
30e7579c | 161 | cout << "process()"<<endl; |
162 | if(!fHLTElement) { | |
163 | fHLTElement = new AliHLTEveHLT(); | |
164 | fHLTElement->SetEventManager(this); | |
165 | gEve->AddElement(fHLTElement); | |
166 | } | |
167 | fHLTElement->ProcessEsdEvent(event); | |
168 | ||
169 | if(!fPhosElement) CreatePhosElement(); | |
170 | fPhosElement->ProcessEvent(event); | |
171 | ||
172 | if(!fEmcalElement) CreateEmcalElement(); | |
173 | fEmcalElement->ProcessEvent(event); | |
30e7579c | 174 | |
b088c0a1 | 175 | gEve->Redraw3D(0, 1); |
176 | gEve->EnableRedraw(); | |
177 | ||
30e7579c | 178 | return 0; |
179 | ||
180 | } | |
181 | ||
182 | ||
183 | ||
184 | //______________________________________________________________________________________________ | |
185 | Int_t AliEveHLTEventManager::ProcessEvent(TList * blockList) { | |
186 | ||
187 | //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) | |
188 | ||
189 | if(!blockList) { | |
190 | cout << "Block list is NULL pointer, return " << endl; | |
191 | return -1; | |
192 | } | |
193 | ||
d5bb2040 | 194 | |
30e7579c | 195 | AliHLTHOMERBlockDesc * block = NULL; |
196 | TIter next(blockList); | |
197 | while ((block = (AliHLTHOMERBlockDesc*)next())) { | |
198 | cout <<"Process Block"<<endl; | |
199 | ProcessBlock(block); | |
200 | } | |
30e7579c | 201 | |
d5bb2040 | 202 | |
30e7579c | 203 | return 0; |
204 | ||
205 | } | |
239fdf4e | 206 | ///___________________________________________________________________________________________ |
30e7579c | 207 | |
208 | void 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(); | |
d48add50 | 240 | |
241 | if(!block->GetDataType().CompareTo("ALIESDV0")) { | |
242 | AliESDEvent * event = dynamic_cast<AliESDEvent *>(block->GetTObject()); | |
243 | if(event) { | |
244 | ProcessEvent(event); | |
245 | } | |
246 | } else { | |
247 | fHLTElement->ProcessBlock(block); | |
248 | } | |
30e7579c | 249 | } |
250 | ||
251 | else if ( ! block->GetDetector().CompareTo("ITS") ) { | |
252 | if(!fITSElement) CreateITSElement(); | |
253 | fITSElement->ProcessBlock(block); | |
254 | } | |
255 | ||
256 | else if ( ! block->GetDetector().CompareTo("ISDD") ) { | |
257 | if(!fISDDElement) CreateISDDElement(); | |
258 | fISDDElement->ProcessBlock(block); | |
259 | } | |
260 | ||
261 | else if ( ! block->GetDetector().CompareTo("ISPD") ) { | |
262 | if(!fISPDElement) CreateISPDElement(); | |
263 | fISPDElement->ProcessBlock(block); | |
264 | } | |
265 | ||
266 | else if ( ! block->GetDetector().CompareTo("ISSD") ) { | |
267 | if(!fISSDElement) CreateISSDElement(); | |
268 | fISSDElement->ProcessBlock(block); | |
269 | } | |
270 | ||
271 | else if ( ! block->GetDetector().CompareTo("TRD") ) { | |
272 | if(!fTRDElement) CreateTRDElement(); | |
273 | fTRDElement->ProcessBlock(block); | |
274 | } | |
275 | ||
276 | else if ( ! block->GetDetector().CompareTo("MUON") ) { | |
277 | //Do Nothing | |
278 | } else { | |
279 | if(!fAnyElement) { | |
280 | fAnyElement = new AliHLTEveAny(); | |
281 | fAnyElement->SetEventManager(this); | |
282 | } | |
283 | fAnyElement->ProcessBlock(block); | |
284 | } | |
285 | ||
286 | } | |
287 | ||
288 | ||
289 | if(fShowMuon) { | |
290 | if ( ! block->GetDetector().CompareTo("MUON") ) { | |
291 | if(!fMuonElement) { | |
292 | fMuonElement = new AliHLTEveMuon(); | |
293 | fMuonElement->SetEventManager(this); | |
294 | gEve->AddElement(fMuonElement); | |
295 | } | |
296 | fMuonElement->ProcessBlock(block); | |
297 | } | |
298 | } | |
299 | ||
300 | } | |
301 | ||
302 | void AliEveHLTEventManager::ResetDisplay () { | |
303 | //See header file for documentation | |
304 | ||
305 | if(fPhosElement) | |
306 | fPhosElement->ResetElements(); | |
307 | ||
308 | if(fEmcalElement) | |
309 | fEmcalElement->ResetElements(); | |
310 | ||
311 | if(fTPCElement) | |
312 | fTPCElement->ResetElements(); | |
313 | ||
314 | if(fHLTElement) | |
315 | fHLTElement->ResetElements(); | |
316 | ||
317 | if(fITSElement) | |
318 | fITSElement->ResetElements(); | |
319 | ||
320 | if(fISPDElement) | |
321 | fISPDElement->ResetElements(); | |
322 | ||
323 | if(fISDDElement) | |
324 | fISDDElement->ResetElements(); | |
325 | ||
326 | if(fISSDElement) | |
327 | fISSDElement->ResetElements(); | |
328 | ||
329 | if (fTRDElement) | |
330 | fTRDElement->ResetElements(); | |
331 | ||
332 | if(fAnyElement) | |
333 | fAnyElement->ResetElements(); | |
334 | ||
335 | if(fMuonElement) | |
336 | fMuonElement->ResetElements(); | |
337 | ||
338 | } | |
339 | ||
340 | ||
341 | void AliEveHLTEventManager::PrintScreens() { | |
342 | // //See header file for documentation | |
343 | ||
cc87822c | 344 | fEveManager->GetDefaultGLViewer()->SavePicture(Form("%d_0x%016lX_3D.gif", fRunNumber, GetEventId())); |
345 | fRhoZViewer->GetGLViewer()->SavePicture(Form("%d_0x%016lX_RhoZ.gif", fRunNumber, GetEventId())); | |
346 | fRPhiViewer->GetGLViewer()->SavePicture(Form("%d_0x%016lX_RPhi.gif", fRunNumber, GetEventId())); | |
30e7579c | 347 | return; |
348 | } | |
349 | ||
350 | ||
351 | void AliEveHLTEventManager::StartLoop() { | |
352 | //See header file for documentation | |
353 | //fTimer->SetCommand("NextEvent()", "AliEveHLTEventManager", this); | |
d63d227e | 354 | NextEvent(); |
30e7579c | 355 | SetEventLoopStarted(kTRUE); |
ce63b00c | 356 | fTimer->Start(45000); |
30e7579c | 357 | } |
358 | ||
359 | void AliEveHLTEventManager::StopLoop() { | |
360 | //See header file for documentation | |
361 | fTimer->Stop(); | |
362 | SetEventLoopStarted(kFALSE); | |
363 | } | |
364 | ||
365 | ||
366 | // void AliEveHLTEventManager::NavigateBack() { | |
367 | ||
368 | // if (fHomerManager->NavigateEventBufferBack()) { | |
369 | // //return -1; | |
370 | // } else { | |
371 | ||
372 | // TList * blockList = fHomerManager->GetBlockList(); | |
373 | // if(blockList) { | |
374 | // ProcessEvent(blockList); | |
375 | // } else { | |
376 | // cout << "BALLE Error blocklist NULL pointer even though it's navigateable"<<endl; | |
377 | // } | |
378 | // } | |
379 | ||
380 | // } | |
381 | ||
382 | // void AliEveHLTEventManager::NavigateFwd() { | |
383 | ||
384 | // if (fHomerManager->NavigateEventBufferFwd()) { | |
385 | // cout << "No event available" << endl; | |
386 | // return; | |
387 | // //return -1; | |
388 | // } else { | |
389 | // cout << "Getting block list" << endl; | |
390 | // TList * blockList = fHomerManager->GetBlockList(); | |
391 | // if (blockList){ | |
392 | // ProcessEvent(blockList); | |
393 | // } else { | |
394 | // cout << "blockList is NULL pointer"<<endl; | |
395 | // } | |
396 | // } | |
397 | ||
398 | // } | |
399 | ||
400 | void AliEveHLTEventManager::UpdateDisplay() { | |
401 | //See header file for documentation | |
402 | if(fPhosElement) fPhosElement->UpdateElements(); | |
403 | if(fEmcalElement) fEmcalElement->UpdateElements(); | |
404 | if(fTPCElement) fTPCElement->UpdateElements(); | |
405 | if(fHLTElement) fHLTElement->UpdateElements(); | |
406 | if(fITSElement) fITSElement->UpdateElements(); | |
407 | if(fISSDElement) fISSDElement->UpdateElements(); | |
408 | if(fISDDElement) fISDDElement->UpdateElements(); | |
409 | if(fISPDElement) fISPDElement->UpdateElements(); | |
410 | if(fTRDElement) fTRDElement->UpdateElements(); | |
411 | if(fAnyElement) fAnyElement->UpdateElements(); | |
412 | if(fMuonElement) fMuonElement->UpdateElements(); | |
413 | ||
414 | ||
30e7579c | 415 | //============================================================================== |
416 | // -- Import global scene into projection scenes | |
417 | //============================================================================== | |
418 | ||
419 | Double_t x[3] = { 0, 0, 0 }; | |
420 | ||
421 | TEveElement* top = GetEveManager()->GetCurrentEvent(); | |
422 | ||
423 | if (fRPhiManager && top) { | |
424 | fRPhiEventScene->DestroyElements(); | |
425 | if (fCenterProjectionsAtPrimaryVertex) | |
426 | fRPhiManager->SetCenter(x[0], x[1], x[2]); | |
427 | fRPhiManager->ImportElements(top, fRPhiEventScene); | |
428 | } | |
429 | ||
430 | if (fRhoZManager && top) { | |
431 | fRhoZEventScene->DestroyElements(); | |
432 | if (fCenterProjectionsAtPrimaryVertex) | |
433 | fRhoZManager->SetCenter(x[0], x[1], x[2]); | |
434 | fRhoZManager->ImportElements(top, fRhoZEventScene); | |
435 | } | |
436 | ||
437 | ||
438 | //Redraw the display | |
439 | GetEveManager()->Redraw3D(0,1); // (0, 1) | |
440 | GetEveManager()->EnableRedraw(); | |
441 | ||
442 | } | |
443 | ||
444 | void AliEveHLTEventManager::SaveEveryThing() { | |
445 | ||
cc87822c | 446 | PrintScreens(); |
447 | ||
448 | GetEventBuffer()->WriteToFile(GetRunNumber()); | |
30e7579c | 449 | //Save everything to file |
450 | //fEventBuffer->SaveBlockList(); | |
451 | //fEventBuffer->SaveAsyncBlockList(); | |
452 | ||
453 | ||
454 | } | |
455 | ||
456 | ||
457 | ||
458 | void AliEveHLTEventManager::CreatePhosElement() { | |
459 | fPhosElement = new AliHLTEvePhos(); | |
460 | fPhosElement->SetEventManager(this); | |
461 | gEve->AddElement(fPhosElement); | |
462 | } | |
463 | ||
464 | void AliEveHLTEventManager::CreateEmcalElement() { | |
465 | fEmcalElement = new AliHLTEveEmcal(); | |
466 | fEmcalElement->SetEventManager(this); | |
467 | gEve->AddElement(fEmcalElement); | |
468 | } | |
469 | void AliEveHLTEventManager::CreateTPCElement() { | |
470 | fTPCElement = new AliHLTEveTPC(); | |
471 | fTPCElement->SetEventManager(this); | |
472 | gEve->AddElement(fTPCElement); | |
473 | } | |
474 | void AliEveHLTEventManager::CreateITSElement() { | |
475 | fITSElement = new AliHLTEveITS(); | |
476 | fITSElement->SetEventManager(this); | |
477 | gEve->AddElement(fITSElement); | |
478 | } | |
479 | void AliEveHLTEventManager::CreateISPDElement() { | |
480 | fISPDElement = new AliHLTEveISPD(); | |
481 | fISPDElement->SetEventManager(this); | |
482 | gEve->AddElement(fISPDElement); | |
483 | } | |
484 | void AliEveHLTEventManager::CreateISDDElement() { | |
485 | fISDDElement = new AliHLTEveISDD(); | |
486 | fISDDElement->SetEventManager(this); | |
487 | gEve->AddElement(fISSDElement); | |
488 | } | |
489 | void AliEveHLTEventManager::CreateISSDElement() { | |
490 | fISSDElement = new AliHLTEveISSD(); | |
491 | fISSDElement->SetEventManager(this); | |
492 | gEve->AddElement(fISSDElement); | |
493 | } | |
494 | void AliEveHLTEventManager::CreateTRDElement() { | |
495 | fTRDElement = new AliHLTEveTRD(); | |
496 | fTRDElement->SetEventManager(this); | |
497 | gEve->AddElement(fTRDElement); | |
498 | } | |
499 | void AliEveHLTEventManager::CreateHLTElement() { | |
500 | fHLTElement = new AliHLTEveHLT(); | |
501 | fHLTElement->SetEventManager(this); | |
502 | gEve->AddElement(fHLTElement); | |
503 | } | |
504 | ||
505 |