]>
Commit | Line | Data |
---|---|---|
a82a31af | 1 | //-*- Mode: C++ -*- |
2 | ||
d810d0de | 3 | // $Id$ |
33791895 | 4 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 * |
fd31e9de | 5 | // Author: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * |
33791895 | 6 | // Author: 2010 Svein Lindal <slindal@fys.uio.no> * |
fd31e9de | 7 | // for The ALICE HLT Project. * |
059c30e4 | 8 | |
a82a31af | 9 | |
7279ee15 | 10 | |
d810d0de | 11 | /** @file AliEveHOMERManager.cxx |
33791895 | 12 | @author Jochen Thaeder, Svein Lindal <slindal@fys.uio.no> |
51346b82 | 13 | @date |
cfa641b1 | 14 | @brief Manager for HOMER online |
059c30e4 | 15 | */ |
16 | ||
17 | #if __GNUC__>= 3 | |
18 | using namespace std; | |
19 | #endif | |
20 | ||
9e78371d | 21 | #include "unistd.h" |
33791895 | 22 | #include "TEveManager.h" |
23 | #include "TTimer.h" | |
24 | #include "TEveScene.h" | |
25 | #include "TEveProjectionManager.h" | |
26 | #include "TEveBrowser.h" | |
27 | ||
d810d0de | 28 | #include "AliEveHOMERManager.h" |
cfa641b1 | 29 | #include "AliHLTHOMERBlockDesc.h" |
cfa641b1 | 30 | #include "AliHLTHOMERManager.h" |
31 | #include "AliHLTTriggerDecision.h" | |
33791895 | 32 | #include "AliHLTEvePhos.h" |
33 | #include "AliHLTEveEmcal.h" | |
34 | #include "AliHLTEveTPC.h" | |
35 | #include "AliHLTEveHLT.h" | |
36 | #include "AliHLTEveITS.h" | |
37 | #include "AliHLTEveISPD.h" | |
38 | #include "AliHLTEveISSD.h" | |
39 | #include "AliHLTEveISDD.h" | |
40 | #include "AliHLTEveTRD.h" | |
41 | #include "AliHLTEveMuon.h" | |
42 | #include "AliHLTEveAny.h" | |
43 | #include "AliEveHOMERSourceList.h" | |
44 | ||
45 | //#include "TTimer.h" | |
a15e6d7d | 46 | |
d810d0de | 47 | ClassImp(AliEveHOMERManager) |
a82a31af | 48 | |
059c30e4 | 49 | /* |
50 | * --------------------------------------------------------------------------------- | |
51346b82 | 51 | * Constructor / Destructor |
52 | * --------------------------------------------------------------------------------- | |
059c30e4 | 53 | */ |
a82a31af | 54 | |
059c30e4 | 55 | //################################################################################## |
a82a31af | 56 | AliEveHOMERManager::AliEveHOMERManager() : |
33791895 | 57 | TEveElementList("Homer Manager"), |
58 | AliHLTHOMERManager(), | |
59 | fSrcList(NULL), | |
60 | fRetryCount(1000), | |
61 | fRetrySleeptime(15), | |
62 | fGeoManager(NULL), | |
63 | fEveManager(NULL), | |
64 | fRPhiManager(NULL), | |
65 | fRhoZManager(NULL), | |
66 | fRPhiEventScene(NULL), | |
67 | fRhoZEventScene(NULL), | |
68 | fTimer(NULL), | |
69 | // fSourceListTimer(NULL), | |
70 | fPhosElement(NULL), | |
71 | fEmcalElement(NULL), | |
72 | fTPCElement(NULL), | |
73 | fHLTElement(NULL), | |
74 | fITSElement(NULL), | |
75 | fISPDElement(NULL), | |
76 | fISSDElement(NULL), | |
77 | fISDDElement(NULL), | |
78 | fTRDElement(NULL), | |
79 | fMuonElement(NULL), | |
80 | fAnyElement(NULL), | |
81 | fEventLoopStarted(kFALSE), | |
82 | fCenterProjectionsAtPrimaryVertex(kFALSE), | |
83 | fShowBarrel(kTRUE), | |
84 | fShowMuon(kFALSE) | |
cfa641b1 | 85 | { |
33791895 | 86 | // see header file for class documentation |
a82a31af | 87 | // or |
88 | // refer to README to build package | |
89 | // or | |
90 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
33791895 | 91 | |
92 | fTimer = new TTimer(); | |
93 | fTimer->Connect("Timeout()", "AliEveHOMERManager", this, "NextHOMEREvent()" ); | |
94 | ||
95 | //fSourceListTimer = new TTimer(); | |
96 | ||
97 | fPhosElement = new AliHLTEvePhos(); | |
98 | fPhosElement->SetEventManager(this); | |
99 | ||
100 | fEmcalElement = new AliHLTEveEmcal(); | |
101 | fEmcalElement->SetEventManager(this); | |
102 | ||
103 | fTPCElement = new AliHLTEveTPC(); | |
104 | fTPCElement->SetEventManager(this); | |
105 | ||
106 | fHLTElement = new AliHLTEveHLT(); | |
107 | fHLTElement->SetEventManager(this); | |
108 | ||
109 | fITSElement = new AliHLTEveITS(); | |
110 | fITSElement->SetEventManager(this); | |
111 | ||
112 | fISPDElement = new AliHLTEveISPD(); | |
113 | fISPDElement->SetEventManager(this); | |
114 | ||
115 | fISDDElement = new AliHLTEveISDD(); | |
116 | fISDDElement->SetEventManager(this); | |
117 | ||
118 | fISSDElement = new AliHLTEveISSD(); | |
119 | fISSDElement->SetEventManager(this); | |
120 | ||
121 | fTRDElement = new AliHLTEveTRD(); | |
122 | fTRDElement->SetEventManager(this); | |
123 | ||
059c30e4 | 124 | } |
125 | ||
059c30e4 | 126 | //################################################################################## |
d810d0de | 127 | AliEveHOMERManager::~AliEveHOMERManager() { |
a82a31af | 128 | // see header file for class documentation |
059c30e4 | 129 | |
33791895 | 130 | DestroyElements(); |
131 | DestroyDetectorElements(); | |
132 | ||
133 | } | |
134 | ||
135 | ||
136 | ||
137 | void AliEveHOMERManager::DestroyDetectorElements(){ | |
138 | //See header file for documentation | |
a82a31af | 139 | if (fSrcList) |
46eadbb4 | 140 | delete fSrcList; |
141 | fSrcList = NULL; | |
33791895 | 142 | |
143 | if (fPhosElement) | |
144 | delete fPhosElement; | |
145 | fPhosElement = NULL; | |
146 | ||
147 | if(fEmcalElement) | |
148 | delete fEmcalElement; | |
149 | fEmcalElement = NULL; | |
150 | ||
151 | if(fTPCElement) | |
152 | delete fTPCElement; | |
153 | fTPCElement = NULL; | |
154 | ||
155 | if(fHLTElement) | |
156 | delete fHLTElement; | |
157 | fHLTElement = NULL; | |
158 | ||
159 | if(fITSElement) | |
160 | delete fITSElement; | |
161 | fITSElement = NULL; | |
162 | ||
163 | if(fISSDElement) | |
164 | delete fISSDElement; | |
165 | fISSDElement = NULL; | |
166 | ||
167 | if(fISDDElement) | |
168 | delete fISDDElement; | |
169 | fISDDElement = NULL; | |
170 | ||
171 | if(fISPDElement) | |
172 | delete fISPDElement; | |
173 | fISPDElement = NULL; | |
174 | ||
175 | if(fTRDElement) | |
176 | delete fTRDElement; | |
177 | fTRDElement = NULL; | |
178 | ||
179 | if(fMuonElement) | |
180 | delete fMuonElement; | |
181 | fMuonElement = NULL; | |
182 | ||
183 | if(fAnyElement) | |
184 | delete fAnyElement; | |
185 | fAnyElement = NULL; | |
186 | ||
187 | ||
059c30e4 | 188 | } |
189 | ||
33791895 | 190 | |
191 | ||
059c30e4 | 192 | /* |
193 | * --------------------------------------------------------------------------------- | |
7279ee15 | 194 | * Source Handling |
51346b82 | 195 | * --------------------------------------------------------------------------------- |
059c30e4 | 196 | */ |
197 | ||
198 | //################################################################################## | |
a82a31af | 199 | Int_t AliEveHOMERManager::CreateEveSourcesList() { |
200 | // see header file for class documentation | |
059c30e4 | 201 | |
059c30e4 | 202 | DestroyElements(); |
059c30e4 | 203 | |
a82a31af | 204 | Int_t iResult = CreateSourcesList(); |
33791895 | 205 | |
206 | // fStateHasChanged = kTRUE; | |
46eadbb4 | 207 | |
dd407e8c | 208 | HLTDebug(Form("iResult XXX %d", iResult)); |
a82a31af | 209 | if ( iResult ) |
059c30e4 | 210 | return iResult; |
51346b82 | 211 | |
33791895 | 212 | |
dd407e8c | 213 | HLTDebug(Form("iResult %d", iResult)); |
33791895 | 214 | if (fSrcList) { |
215 | HLTInfo(Form("delete source list", iResult)); | |
216 | DestroyElements(); | |
217 | //delete fSrcList; | |
218 | fSrcList = NULL; | |
219 | //fSrcList->Clear(); | |
220 | HLTInfo(Form("cleared source list", iResult)); | |
221 | } | |
222 | ||
51346b82 | 223 | |
a82a31af | 224 | // -- Create new AliEVE sources list |
33791895 | 225 | if(!fSrcList){ |
226 | HLTInfo(Form("no source list", iResult)); | |
227 | fSrcList = new AliEveHOMERSourceList("HLT Sources"); | |
228 | fSrcList->SetManager(this); | |
a82a31af | 229 | |
33791895 | 230 | AddElement(fSrcList); |
231 | } | |
dd407e8c | 232 | |
233 | //HLTInfo(Form("createbytype", iResult)); | |
33791895 | 234 | fSrcList->CreateByDet(); |
dd407e8c | 235 | |
236 | HLTDebug(Form("Done createing source list %d", iResult)); | |
237 | ||
238 | ||
33791895 | 239 | |
059c30e4 | 240 | return iResult; |
241 | } | |
242 | ||
059c30e4 | 243 | //################################################################################## |
9e78371d | 244 | Int_t AliEveHOMERManager::CreateEveSourcesListLoop() { |
a82a31af | 245 | // see header file for class documentation |
059c30e4 | 246 | |
247 | Int_t iResult = 0; | |
9e78371d | 248 | |
249 | for ( Int_t retry = 0; retry < fRetryCount ; retry++ ) { | |
33791895 | 250 | |
9e78371d | 251 | iResult = CreateEveSourcesList(); |
33791895 | 252 | |
253 | if (!iResult) { | |
254 | HLTInfo("Source list successfully created."); | |
9e78371d | 255 | break; |
33791895 | 256 | } |
9e78371d | 257 | else if (iResult == 1) { |
cfa641b1 | 258 | HLTWarning( Form("Couldn't find active services, sleeping %d s before making attempt %d out of %d", fRetrySleeptime, retry, fRetryCount) ) ; |
9e78371d | 259 | } |
260 | else if (iResult == 2) { | |
33791895 | 261 | HLTWarning( Form("Services List empty, sleeping %d s before making new attempt.", fRetrySleeptime) ) ; |
9e78371d | 262 | } |
263 | else { | |
264 | HLTError( Form("Other problem ... \n") ); | |
265 | return iResult; | |
266 | } | |
33791895 | 267 | |
268 | //fSourceListTimer->Start(fRetrySleeptime, kFALSE); | |
9e78371d | 269 | sleep(fRetrySleeptime); |
33791895 | 270 | |
9e78371d | 271 | } |
272 | ||
273 | if ( iResult ) { | |
703482d8 | 274 | HLTWarning( Form("Couldn't find active services.") ); |
9e78371d | 275 | return iResult; |
276 | } | |
a82a31af | 277 | |
9e78371d | 278 | return iResult; |
279 | } | |
059c30e4 | 280 | |
9e78371d | 281 | //################################################################################## |
703482d8 | 282 | Int_t AliEveHOMERManager::ConnectEVEtoHOMER( TString detector ) { |
9e78371d | 283 | // see header file for class documentation |
059c30e4 | 284 | |
33791895 | 285 | HLTInfo(""); |
9e78371d | 286 | fStateHasChanged = fSrcList->GetSelectedSources(); |
33791895 | 287 | HLTInfo(Form("has state changed % d", fStateHasChanged)); |
703482d8 | 288 | return ConnectHOMER(detector); |
059c30e4 | 289 | } |
cfa641b1 | 290 | |
33791895 | 291 | |
292 | //################################################################################## | |
293 | Int_t AliEveHOMERManager::ReConnectHOMER( TString detector ){ | |
294 | // see header file for class documentation | |
295 | ||
296 | Int_t iResult = 0; | |
297 | ||
298 | DisconnectHOMER(); | |
299 | iResult = CreateEveSourcesListLoop(); | |
300 | HLTInfo("Created new source list, reconnect to HOMER"); | |
301 | iResult = ConnectEVEtoHOMER(); | |
302 | if ( iResult ) { | |
303 | HLTError(Form("Error reconnecting.")); | |
304 | } | |
305 | ||
306 | return iResult; | |
307 | } | |
308 | ||
309 | ||
310 | //_____________________________________________________________________________________ | |
311 | Int_t AliEveHOMERManager::NextHOMEREvent() { | |
312 | //See header file for documentation | |
313 | Int_t iResult = 0; | |
314 | ||
315 | ||
316 | //Loop over blocks | |
317 | AliHLTHOMERBlockDesc * block = NULL; | |
318 | ||
319 | if ( NextEvent() ) { | |
320 | ||
321 | HLTInfo("Failed getting next event, trying to reconnect"); | |
322 | iResult = ReConnectHOMER(); | |
323 | return NextHOMEREvent(); | |
324 | } | |
325 | ||
326 | ||
327 | //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) | |
328 | ResetDisplay(); | |
329 | ||
330 | //Process the SYNCED block list | |
331 | if ( GetBlockList() == NULL) { | |
332 | printf ("onlineDisplay: No regular BlockList ... \n"); | |
333 | cout << endl; | |
334 | //return -1; | |
335 | ||
336 | } else { | |
337 | ||
338 | if (GetBlockList()->IsEmpty() ) { | |
339 | printf ("onlineDisplay: No Sync Blocks in list ... \n"); | |
340 | cout<<endl; | |
341 | //return; | |
342 | } | |
343 | ||
344 | ||
345 | TIter next(GetBlockList()); | |
346 | ||
347 | while ((block = (AliHLTHOMERBlockDesc*)next())) { | |
348 | ProcessBlock(block); | |
349 | ||
350 | } | |
351 | } | |
352 | ||
353 | ||
354 | //Read out histograms and elements from detectors outside physics 1 partition | |
355 | TIter anext(GetAsyncBlockList()); | |
356 | ||
357 | while ( (block = (AliHLTHOMERBlockDesc*)anext()) ) { | |
33791895 | 358 | ProcessBlock(block); |
33791895 | 359 | } |
360 | ||
361 | UpdateDisplay(); | |
362 | ||
363 | return 0; | |
364 | ||
365 | } | |
366 | ||
367 | void AliEveHOMERManager::UpdateDisplay() { | |
368 | //See header file for documentation | |
369 | fPhosElement->UpdateElements(); | |
370 | fEmcalElement->UpdateElements(); | |
371 | fTPCElement->UpdateElements(); | |
372 | fHLTElement->UpdateElements(); | |
373 | fITSElement->UpdateElements(); | |
374 | fISSDElement->UpdateElements(); | |
375 | fISDDElement->UpdateElements(); | |
376 | fISPDElement->UpdateElements(); | |
377 | fTRDElement->UpdateElements(); | |
378 | if(fAnyElement) fAnyElement->UpdateElements(); | |
379 | if(fMuonElement) fMuonElement->UpdateElements(); | |
380 | ||
381 | ||
382 | // -- Set EventID in Window Title | |
33791895 | 383 | TString winTitle("Eve Main Window -- Event ID : "); |
384 | winTitle += Form("0x%016X ", GetEventID() ); | |
385 | GetEveManager()->GetBrowser()->SetWindowName(winTitle); | |
386 | ||
387 | //============================================================================== | |
388 | // -- Import global scene into projection scenes | |
389 | //============================================================================== | |
390 | ||
391 | // XXX Primary vertex ... to be retrieved from the ESD | |
392 | Double_t x[3] = { 0, 0, 0 }; | |
393 | ||
394 | TEveElement* top = GetEveManager()->GetCurrentEvent(); | |
395 | ||
396 | if (fRPhiManager && top) { | |
397 | fRPhiEventScene->DestroyElements(); | |
398 | if (fCenterProjectionsAtPrimaryVertex) | |
399 | fRPhiManager->SetCenter(x[0], x[1], x[2]); | |
400 | fRPhiManager->ImportElements(top, fRPhiEventScene); | |
401 | } | |
402 | ||
403 | if (fRhoZManager && top) { | |
404 | fRhoZEventScene->DestroyElements(); | |
405 | if (fCenterProjectionsAtPrimaryVertex) | |
406 | fRhoZManager->SetCenter(x[0], x[1], x[2]); | |
407 | fRhoZManager->ImportElements(top, fRhoZEventScene); | |
408 | } | |
409 | ||
410 | ||
411 | //Redraw the display | |
412 | GetEveManager()->Redraw3D(0,1); // (0, 1) | |
413 | GetEveManager()->EnableRedraw(); | |
414 | ||
415 | } | |
416 | ||
417 | void AliEveHOMERManager::ProcessBlock(AliHLTHOMERBlockDesc * block) { | |
418 | //See header file for documentation | |
419 | ||
420 | #if 1//DEBUG | |
421 | printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n"); | |
422 | printf( "Detector : %s\n", block->GetDetector().Data() ); | |
423 | printf( "Datatype : %s\n", block->GetDataType().Data() ); | |
424 | if (block->IsTObject() ) | |
425 | printf( "Is TObject of class: %s\n", block->GetClassName().Data() ); | |
426 | printf( "------------------- xxxxxxxxxxxxxxx ----------------------\n"); | |
427 | #endif | |
428 | ||
429 | ||
430 | if(fShowBarrel) { | |
431 | ||
432 | if ( ! block->GetDetector().CompareTo("PHOS") ) | |
433 | fPhosElement->ProcessBlock(block); | |
434 | ||
435 | else if ( ! block->GetDetector().CompareTo("EMCA") ) | |
436 | fEmcalElement->ProcessBlock(block); | |
437 | ||
438 | else if ( ! block->GetDetector().CompareTo("TPC") ) | |
439 | fTPCElement->ProcessBlock(block); | |
440 | ||
441 | else if ( ! block->GetDetector().CompareTo("HLT") ) | |
442 | fHLTElement->ProcessBlock(block); | |
443 | ||
444 | else if ( ! block->GetDetector().CompareTo("ITS") ) | |
445 | fITSElement->ProcessBlock(block); | |
446 | ||
447 | else if ( ! block->GetDetector().CompareTo("ISDD") ) | |
448 | fISDDElement->ProcessBlock(block); | |
449 | ||
450 | else if ( ! block->GetDetector().CompareTo("ISPD") ) | |
451 | fISPDElement->ProcessBlock(block); | |
452 | ||
453 | else if ( ! block->GetDetector().CompareTo("ISSD") ) | |
454 | fISSDElement->ProcessBlock(block); | |
455 | ||
456 | else if ( ! block->GetDetector().CompareTo("TRD") ) | |
457 | fTRDElement->ProcessBlock(block); | |
458 | ||
459 | else if ( ! block->GetDetector().CompareTo("MUON") ) { | |
460 | //Do Nothing | |
461 | ||
462 | ||
463 | } else { | |
464 | if(!fAnyElement) { | |
465 | fAnyElement = new AliHLTEveAny(); | |
466 | fAnyElement->SetEventManager(this); | |
467 | } | |
468 | fAnyElement->ProcessBlock(block); | |
469 | } | |
470 | ||
471 | } | |
472 | ||
473 | ||
474 | if(fShowMuon) { | |
475 | if ( ! block->GetDetector().CompareTo("MUON") ) { | |
476 | if(!fMuonElement) { | |
477 | fMuonElement = new AliHLTEveMuon(); | |
478 | fMuonElement->SetEventManager(this); | |
479 | } | |
480 | fMuonElement->ProcessBlock(block); | |
481 | } | |
482 | } | |
483 | ||
484 | } | |
485 | ||
486 | void AliEveHOMERManager::ResetDisplay () { | |
487 | //See header file for documentation | |
488 | ||
489 | if(fPhosElement) | |
490 | fPhosElement->ResetElements(); | |
491 | ||
492 | if(fEmcalElement) | |
493 | fEmcalElement->ResetElements(); | |
494 | ||
495 | if(fTPCElement) | |
496 | fTPCElement->ResetElements(); | |
497 | ||
498 | if(fHLTElement) | |
499 | fHLTElement->ResetElements(); | |
500 | ||
501 | if(fITSElement) | |
502 | fITSElement->ResetElements(); | |
503 | ||
504 | if(fISPDElement) | |
505 | fISPDElement->ResetElements(); | |
506 | ||
507 | if(fISDDElement) | |
508 | fISDDElement->ResetElements(); | |
509 | ||
510 | if(fISSDElement) | |
511 | fISSDElement->ResetElements(); | |
512 | ||
513 | if (fTRDElement) | |
514 | fTRDElement->ResetElements(); | |
515 | ||
516 | if(fAnyElement) | |
517 | fAnyElement->ResetElements(); | |
518 | ||
519 | if(fMuonElement) | |
520 | fMuonElement->ResetElements(); | |
521 | ||
522 | } | |
523 | ||
524 | ||
525 | void AliEveHOMERManager::StartLoop() { | |
526 | //See header file for documentation | |
527 | //fTimer->SetCommand("NextEvent()", "AliEveHOMERManager", this); | |
528 | SetEventLoopStarted(kTRUE); | |
529 | fTimer->Start(3000); | |
530 | } | |
531 | ||
532 | void AliEveHOMERManager::StopLoop() { | |
533 | //See header file for documentation | |
534 | fTimer->Stop(); | |
535 | SetEventLoopStarted(kFALSE); | |
536 | } | |
537 | ||
538 | // void AliEveHOMERManager::TimeOut(Int_t sec) { | |
539 | ||
540 | // TTimer t(sec*1000, kFALSE); | |
541 | ||
542 | // cout << "Start timer for " << sec << " seconds" << endl; | |
543 | ||
544 | // while (!t.CheckTimer(gSystem->Now())) | |
545 | // gSystem->Sleep(100); // 100 ms sleep | |
546 | ||
547 | // cout << "Timed out." << endl; | |
548 | ||
549 | // } |