BBQ
TBBQManager.cxx
Go to the documentation of this file.
1 #include "TBBQManager.h"
2 #include "TBBQEventManager.h"
3 #include "vistpc.h"
4 
5 // C++
6 
7 #include <iostream>
8 #include <sstream>
9 #include <string>
10 #include <vector>
11 
12 // ROOT
13 
14 #include <TApplication.h>
15 #include <TClass.h>
16 #include <TROOT.h>
17 #include <TRootBrowser.h>
18 #include <TSystem.h>
19 #include <TString.h>
20 
21 #include <TGButton.h>
22 #include <TGFileDialog.h>
23 #include <TGFrame.h>
24 #include <TGLabel.h>
25 #include <TGListBox.h>
26 #include <TGMenu.h>
27 #include <TGObject.h>
28 #include <TGTextEntry.h>
29 
30 // Eve
31 
32 #include <TEveBrowser.h>
33 #include <TEveEventManager.h>
34 #include <TEveScene.h>
35 
36 // LCIO
37 
38 #include "lcio.h"
39 
40 #include "IMPL/LCEventImpl.h"
41 #include "IMPL/LCCollectionVec.h"
42 #include "Exceptions.h"
43 
44 // GEAR
45 
46 #include <gearimpl/Util.h>
47 #include <gearxml/GearXML.h>
48 #include <gear/GearMgr.h>
49 #include <gear/GEAR.h>
50 #include <gear/TPCParameters.h>
51 
52 TBBQManager* gBBQ = NULL;
53 
55 {
64 };
65 
66 //------------------------------------------------------------------------------
67 // Constructors & Destructor
68 //------------------------------------------------------------------------------
69 
71  UInt_t w,
72  UInt_t h,
73  Bool_t map_window,
74  Option_t *opt
75 ) :
76  TEveManager(w, h, map_window, opt),
77  fGearMgr(0),
78  fVisTPC(new VisTPC()),
79  fHitsCollections(0),
80  fTracksCollections(0),
81  fPulsesCollections(0)
82 {
83  gBBQ = this;
84 
85  TGLayoutHints* fillx = new TGLayoutHints(kLHintsExpandX);
86 
87  //---------------------------------------------------------------------------
88  // Construct the dropdown menu
89  // Ref: http://root.cern.ch/root/html526/src/TEveBrowser.cxx.html
90 
91  TGMenuBar *menuBar = GetBrowser()->GetMenuBar();
92  TGHorizontalFrame *menuFrame = GetBrowser()->GetTopMenuFrame();
93  TGPopupMenu *bbqMenu = new TGPopupMenu(gClient->GetRoot());
94 
95  bbqMenu->AddEntry("Open &GEAR file", kMenuOpenGEARFile);
96  bbqMenu->AddEntry("Open &LCIO file", kMenuOpenLCIOFile);
97  bbqMenu->AddSeparator();
98  bbqMenu->AddEntry("&Reload GEAR file", kMenuReloadGEARFile);
99  bbqMenu->AddSeparator();
100  bbqMenu->AddEntry("Clear global scene", kMenuClearGlobalScene);
101  bbqMenu->AddEntry("Clear event scene", kMenuClearEventScene);
102  bbqMenu->AddSeparator();
103  bbqMenu->AddEntry("Test getNearestPad() (first module)", kMenuTestGetNearestPadModule);
104  bbqMenu->AddEntry("Test getNearestPad() (global)", kMenuTestGetNearestPadGlobal);
105  bbqMenu->AddEntry("Test getLeftRightNeighbour()", kMenuTestGetLeftRightNeighbour);
106 
107  bbqMenu->Connect("Activated(Int_t)", "TBBQManager", this, "slotMenu(Int_t)");
108 
109  menuBar->AddPopup("BBQ", bbqMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
110  menuFrame->MapSubwindows();
111  menuFrame->Layout();
112 
113  //---------------------------------------------------------------------------
114  // Create minimal GUI for event navigation.
115  // Ref: http://root.cern.ch/root/html/tutorials/eve/alice_vsd.C.html
116 
117  AddEvent(new TBBQEventManager(fVisTPC));
118 
119  TEveBrowser* browser = gEve->GetBrowser();
120  browser->StartEmbedding(TRootBrowser::kLeft);
121 
122  TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
123  frmMain->SetWindowName("XX GUI");
124  frmMain->SetCleanup(kDeepCleanup);
125 
126  TGGroupFrame *group = NULL;
127  TGHorizontalFrame *hf = NULL;
128 
130 
131  //-----------------
132  // Event navigation
133 
134  group = new TGGroupFrame(frmMain, "Event navigation");
135 
136  // Text fields indicating current run # and event #.
137 
138  hf = new TGHorizontalFrame(group);
139  {
140  TGLabel* runLabel = new TGLabel(hf, "Run #");
141  TGTextEntry* runEntry = new TGTextEntry(hf);
142 
143  hf->AddFrame(runLabel);
144  hf->AddFrame(runEntry, new TGLayoutHints(kLHintsRight));
145  fGUI["RunEntry"] = runEntry;
146 
147  runEntry->SetWidth(100);
148  runEntry->Connect(
149  "ReturnPressed()",
150  "TBBQEventManager",
151  eventManager,
152  "handleRunEntry()"
153  );
154 
155  eventManager->fRunNumberEntry = runEntry;
156  }
157  group->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
158 
159  hf = new TGHorizontalFrame(group);
160  {
161  TGLabel* eventLabel = new TGLabel(hf, "Event #");
162  TGTextEntry* eventEntry = new TGTextEntry(hf);
163 
164  eventEntry->SetWidth(100);
165  hf->AddFrame(eventLabel);
166  hf->AddFrame(eventEntry, new TGLayoutHints(kLHintsRight));
167  fGUI["EventEntry"] = eventEntry;
168 
169  eventEntry->Connect(
170  "ReturnPressed()",
171  "TBBQEventManager",
172  eventManager,
173  "handleEventEntry()"
174  );
175 
176  eventManager->fEventNumberEntry = eventEntry;
177  }
178  group->AddFrame(hf, fillx);
179 
180  // Buttons to go backward and forward
181 
182  hf = new TGHorizontalFrame(group);
183  {
184  TString icondir(TString::Format("%s/icons/", gSystem->Getenv("ROOTSYS")) );
185  TGPictureButton* b = 0;
186 
187  b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoBack.gif"));
188  hf->AddFrame(b);
189  fGUI["PrevEventButton"] = b;
190  b->Connect(
191  "Clicked()",
192  "TBBQEventManager",
193  eventManager,
194  "PrevEvent()"
195  );
196 
197  b = new TGPictureButton(hf, gClient->GetPicture(icondir + "ReloadPage.gif"));
198  hf->AddFrame(b);
199  fGUI["ReloadEventButton"] = b;
200  b->Connect(
201  "Clicked()",
202  "TBBQEventManager",
203  eventManager,
204  "ReloadEvent()"
205  );
206 
207  b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoForward.gif"));
208  hf->AddFrame(b);
209  fGUI["NextEventButton"] = b;
210  b->Connect(
211  "Clicked()",
212  "TBBQEventManager",
213  eventManager,
214  "NextEvent()"
215  );
216  }
217  group->AddFrame(hf, new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 0));
218 
219  frmMain->AddFrame(group);
220 
221  //---------------------------------------------------------------------------
222  // ListBoxes for the LCIO Collections
223 
224  group = new TGGroupFrame(frmMain, "Pulses");
225  hf = new TGHorizontalFrame(group);
226  {
227  fPulsesCollections = new TGListBox(hf);
228  fPulsesCollections->Resize(200, 100);
229  fPulsesCollections->SetMultipleSelections(kTRUE);
230  hf->AddFrame(fPulsesCollections);
231  }
232  group->AddFrame(hf);
233  frmMain->AddFrame(group, fillx);
234 
235  group = new TGGroupFrame(frmMain, "Hits");
236  hf = new TGHorizontalFrame(group);
237  {
238  fHitsCollections = new TGListBox(hf);
239  fHitsCollections->Resize(200, 100);
240  fHitsCollections->SetMultipleSelections(kTRUE);
241  hf->AddFrame(fHitsCollections);
242  }
243  group->AddFrame(hf);
244  frmMain->AddFrame(group, fillx);
245 
246  group = new TGGroupFrame(frmMain, "Tracks");
247  hf = new TGHorizontalFrame(group);
248  {
249  fTracksCollections = new TGListBox(hf);
250  fTracksCollections->Resize(200, 250);
251  fTracksCollections->SetMultipleSelections(kTRUE);
252  hf->AddFrame(fTracksCollections);
253  }
254  group->AddFrame(hf);
255  frmMain->AddFrame(group, fillx);
256 
257 
258  //
259 
260  frmMain->MapSubwindows();
261  frmMain->Resize();
262  frmMain->MapWindow();
263 
264  browser->StopEmbedding("Event");
265  //browser->SetTabTitle("Event Control", 0);
266 
267  //---------------------------------------------------------------------------
268  // Tab for options
269 
270  browser->StartEmbedding(TRootBrowser::kLeft);
271 
272  frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
273  frmMain->SetWindowName("XX GUI");
274  frmMain->SetCleanup(kDeepCleanup);
275 
276  group = new TGGroupFrame(frmMain, "TPC properties");
277 
278  // Max drift length
279 
280  hf = new TGHorizontalFrame(group);
281  {
282  TGLabel* driftLabel = new TGLabel(hf, "Max drift length");
283  TGTextEntry* driftEntry = new TGTextEntry(hf);
284 
285  hf->AddFrame(driftLabel);
286  hf->AddFrame(driftEntry, new TGLayoutHints(kLHintsRight));
287  fGUI["TPC_MaxDriftLengthEntry"] = driftEntry;
288 
289  driftEntry->SetWidth(100);
290  driftEntry->Connect(
291  "TextChanged(const char*)",
292  "TBBQManager",
293  this,
294  "handleMaxDriftLengthEntry(const char*)"
295  );
296  }
297  group->AddFrame(hf, fillx);
298 
299  // Readout frequency
300 
301  hf = new TGHorizontalFrame(group);
302  {
303  TGLabel* frequencyLabel = new TGLabel(hf, "Readout frequency");
304  TGTextEntry* frequencyEntry = new TGTextEntry(hf);
305 
306  hf->AddFrame(frequencyLabel);
307  hf->AddFrame(frequencyEntry, new TGLayoutHints(kLHintsRight));
308  fGUI["TPC_ReadoutFrequencyEntry"] = frequencyEntry;
309 
310  frequencyEntry->SetWidth(100);
311  frequencyEntry->Connect(
312  "TextChanged(const char*)",
313  "TBBQManager",
314  this,
315  "handleReadoutFrequencyEntry(const char*)"
316  );
317  }
318  group->AddFrame(hf, fillx);
319 
320  // Drift velocity
321 
322  hf = new TGHorizontalFrame(group);
323  {
324  TGLabel* driftVelocityLabel = new TGLabel(hf, "Drift velocity");
325  TGTextEntry* driftVelocityEntry = new TGTextEntry(hf);
326 
327  hf->AddFrame(driftVelocityLabel);
328  hf->AddFrame(driftVelocityEntry, new TGLayoutHints(kLHintsRight));
329  fGUI["TPC_DriftVelocityEntry"] = driftVelocityEntry;
330 
331  driftVelocityEntry->SetWidth(100);
332  driftVelocityEntry->Connect(
333  "TextChanged(const char*)",
334  "TBBQManager",
335  this,
336  "handleDriftVelocityEntry(const char*)"
337  );
338  }
339  group->AddFrame(hf, fillx);
340 
341  frmMain->AddFrame(group, fillx);
342 
343  //--------------------
344  // Module draw options
345 
346  TGCheckButton *checkbutton = NULL;
347 
348  group = new TGGroupFrame(frmMain, "Module visualisation");
349 
350  //checkbutton = new TGCheckButton(group, "Draw parallel borders");
351  //checkbutton->Connect("Clicked()", "TBBQManager", this, "handleCheckbutton(=\"module.parallelBorders\")");
352  //fGUI["module.parallelBorders"] = checkbutton;
353  //group->AddFrame(checkbutton);
354 
355  checkbutton = new TGCheckButton(group, "Draw pads by default");
356  checkbutton->Connect("Clicked()", "TBBQManager", this, "handleCheckbutton(=\"module.drawPadsByDefault\")");
357  fGUI["module.drawPadsByDefault"] = checkbutton;
358  group->AddFrame(checkbutton);
359 
360  checkbutton = new TGCheckButton(group, "Draw outline by default");
361  checkbutton->SetOn();
362  checkbutton->Connect("Clicked()", "TBBQManager", this, "handleCheckbutton(=\"module.drawOutlineByDefault\")");
363  fGUI["module.drawOutlineByDefault"] = checkbutton;
364  group->AddFrame(checkbutton);
365 
366  frmMain->AddFrame(group, fillx);
367 
368  //
369 
370  frmMain->MapSubwindows();
371  frmMain->Resize();
372  frmMain->MapWindow();
373 
374  browser->StopEmbedding("Options");
375 
376 
377  // TODO
378 
379  // Takeover the Checked signal from the tree.
380 
381  //GetListTree()->Disconnect("Checked(TObject*, Bool_t)");
382  //
383  //GetListTree()->Connect(
384  // "Checked(TObject*, Bool_t)",
385  // "TBBQManager",
386  // this,
387  // "slotTreeItemChecked(TEveListTreeItem*, Bool_t)"
388  //);
389 
390  //
391 
392  updateGUIState();
393 }
394 
396 {
397  // TODO
398 
399  //GetListTree()->Disconnect(
400  // "Checked(TObject*, Bool_t)",
401  // this,
402  // "slotTreeItemChecked(TEveListTreeItem*, Bool_t)"
403  //);
404 
405  delete fVisTPC;
406 }
407 
408 //------------------------------------------------------------------------------
409 // Methods (alphabetical order)
410 //------------------------------------------------------------------------------
411 
413  if (fHitsCollections)
414  fHitsCollections->RemoveAll();
415 
416  if (fPulsesCollections)
417  fPulsesCollections->RemoveAll();
418 
419  if (fTracksCollections)
420  fTracksCollections->RemoveAll();
421 }
422 
424  std::cout << "Clearing current event scene: ";
425 
426  gEve->GetCurrentEvent()->DestroyElements();
427  this->Redraw3D();
428 
429  std::cout << "done." << std::endl;
430 }
431 
433  std::cout << "Clearing current global scene: ";
434 
435  gEve->GetGlobalScene()->DestroyElements();
436  this->Redraw3D();
437 
438  std::cout << "done." << std::endl;
439 }
440 
441 TBBQManager* TBBQManager::Create(Bool_t map_window, Option_t* opt) {
442  // If global TEveManager* gEve is not set initialize it.
443  // Returns gEve.
444 
445  static const TEveException eh("TEveManager::Create ");
446 
447  if (gBBQ == 0)
448  {
449  // Make sure that the GUI system is initialized.
450  if (gROOT->IsBatch())
451  {
452  throw eh + "ROOT is running in batch mode.";
453  }
454  TApplication::NeedGraphicsLibs();
455  gApplication->InitializeGraphics();
456  if (gROOT->IsBatch() || gClient == 0 || gClient->IsZombie())
457  {
458  throw eh + "window system not initialized.";
459  }
460 
461  Int_t w = 1024;
462  Int_t h = 768;
463 
464  TEveUtil::SetupEnvironment();
465  TEveUtil::SetupGUI();
466  gBBQ = new TBBQManager(w, h, map_window, opt);
467  }
468 
469  return gBBQ;
470 }
471 
472 std::string TBBQManager::dialogOpenFile(const char** fileTypes) {
473 
474  // Setup necessary stuff
475 
476  TGFileInfo selectedFile;
477 
478  static TString dir(".");
479 
480  selectedFile.fFileTypes = fileTypes;
481  selectedFile.fIniDir = StrDup(dir);
482  selectedFile.fMultipleSelection = kFALSE;
483 
484  // show File dialog
485 
486  new TGFileDialog(
487  gClient->GetDefaultRoot(),
488  this->GetMainWindow(),
489  kFDOpen,
490  &selectedFile
491  );
492 
493  // Retrieve info
494 
495  std::string returnStr(gSystem->UnixPathName(selectedFile.fFilename));
496 
497  return returnStr;
498 }
499 
501  const char* fileTypes[] = {
502  "GEAR file", "*.xml",
503  "GEAR file", "*.gear",
504  "All files", "*.*",
505  0, 0
506  };
507 
508  try {
509 
510  std::string selectedFile = dialogOpenFile(fileTypes);
511 
512  if (selectedFile.empty())
513  return;
514 
515  importGEARFile(selectedFile);
516 
517  } catch (gear::Exception e) {
518 
519  std::cout << e.what() << std::endl;
520 
521  } catch (...) {
522  return;
523  }
524 
525 }
526 
528  const char* fileTypes[] = {
529  "LCIO file", "*.slcio",
530  "All files", "*.*",
531  0, 0
532  };
533 
534  try {
535 
536  std::string selectedFile = dialogOpenFile(fileTypes);
537 
538  if (selectedFile.empty())
539  return;
540 
541  importLCIOFile(selectedFile);
542 
543  } catch (...) {
544  return;
545  }
546 
547 }
548 
549 void TBBQManager::displayEventCollections(const EVENT::LCEvent* event) {
550  if (
551  fHitsCollections->GetNumberOfEntries()
552  + fPulsesCollections->GetNumberOfEntries()
553  + fTracksCollections->GetNumberOfEntries()
554  )
555  return;
556 
557  const std::vector<std::string> * names = event->getCollectionNames();
558 
559  int i = 0;
560  for (
561  std::vector<std::string>::const_iterator it = names->begin();
562  it != names->end();
563  ++it
564  ) {
565 
566  switch (fVisTPC->getCollectionType(event->getCollection(*it)->getTypeName())) {
567  case VisTPC::kHIT:
568  fHitsCollections->AddEntry(it->c_str(), i++);
569  break;
570  case VisTPC::kPULSE:
571  fPulsesCollections->AddEntry(it->c_str(), i++);
572  break;
573  case VisTPC::kTRACK:
574  fTracksCollections->AddEntry(it->c_str(), i++);
575  break;
576  }
577  }
578 
579  fHitsCollections->Layout();
580  fPulsesCollections->Layout();
581  fTracksCollections->Layout();
582 }
583 
584 void TBBQManager::handleCheckbutton(const char * button) {
585  std::string option(button);
586 
587  std::map<std::string, TGObject*>::iterator it = fGUI.find(option);
588 
589  if (it == fGUI.end())
590  return;
591 
592  fVisTPC->setOption(option, (dynamic_cast<TGCheckButton*>(fGUI[option]))->IsOn());
593 }
594 
596  std::stringstream sstr(text);
597 
598  if (sstr.str().empty())
599  return;
600 
601  float driftVelocity;
602 
603  if (sstr >> driftVelocity)
604  fVisTPC->setDriftVelocity(driftVelocity);
605  else
606  std::cout << "\"" << text << "\""
607  << "is not a number." << std::endl;
608 }
609 
611  std::stringstream sstr(text);
612 
613  if (sstr.str().empty())
614  return;
615 
616  float maxDriftLength;
617 
618  if (sstr >> maxDriftLength)
619  fVisTPC->setMaxDriftLength(maxDriftLength);
620  else
621  std::cout << "\"" << text << "\""
622  << "is not a number." << std::endl;
623 }
624 
626  std::stringstream sstr(text);
627 
628  if (sstr.str().empty())
629  return;
630 
631  float readoutFrequency;
632 
633  if (sstr >> readoutFrequency)
634  fVisTPC->setReadoutFrequency(readoutFrequency);
635  else
636  std::cout << "\"" << text << "\""
637  << "is not a number." << std::endl;
638 }
639 
640 void TBBQManager::importGEARFile(const std::string& filePath) {
641  if (filePath.empty())
642  return;
643 
644  std::cout << "importing GEAR: " << filePath << std::endl;
645 
646  fCurrentGEARFile = filePath;
647 
648  //
649 
650  if (fGearMgr) {
651  this->clearGlobalScene();
652  this->clearEventScene();
653 
654  delete fGearMgr;
655  fGearMgr = NULL;
656  }
657 
658  //
659 
660  gear::GearXML gearXML(filePath);
661 
662  fGearMgr = gearXML.createGearMgr();
663 
664  // Update the "TPC" tab & VisTPC with the correct info
665 
667 
668  std::stringstream text;
669 
670  // 1. maxDriftLength
671  text << fGearMgr->getTPCParameters().getMaxDriftLength();
672 
673  (dynamic_cast<TGTextEntry *> (fGUI["TPC_MaxDriftLengthEntry"]))
674  ->SetText(text.str().c_str());
675 
676  //fVisTPC->setMaxDriftLength(fGearMgr->getTPCParameters().getMaxDriftLength());
677 
678  // 2. readoutFrequency
679  text.str("");
680  text << fVisTPC->getReadoutFrequency();
681  (dynamic_cast<TGTextEntry *> (fGUI["TPC_ReadoutFrequencyEntry"]))
682  ->SetText(text.str().c_str(), kFALSE);
683 
684  // 3. driftVelocity
685  text.str("");
686  text << fVisTPC->getDriftVelocity();
687  (dynamic_cast<TGTextEntry *> (fGUI["TPC_DriftVelocityEntry"]))
688  ->SetText(text.str().c_str(), kFALSE);
689 
690  //
691 
692  fVisTPC->drawTPC();
693 }
694 
695 void TBBQManager::importLCIOFile(const std::string& filePath) {
696  if (filePath.empty())
697  return;
698 
699  std::cout << "importing LCIO: " << filePath << std::endl;
700 
702 
703  eventManager->readFile(filePath);
704  eventManager->GotoEvent(eventManager->getCurrentEvent()->getEventNumber());
705 }
706 
707 void TBBQManager::slotMenu(Int_t menuId) {
708  const std::vector<gear::TPCModule *> * modules = 0;
709 
710  switch (menuId) {
711  case kMenuOpenGEARFile:
713  this->Redraw3D(kTRUE);
714  break;
715 
716  case kMenuOpenLCIOFile:
717  if (fGearMgr == NULL) {
718  std::cout << " error -> first load GEAR." << std::endl;
719  return;
720  }
721 
723  break;
724 
725  case kMenuReloadGEARFile:
726  if (fGearMgr == NULL)
727  return;
728 
730  this->Redraw3D();
731  break;
732 
735  break;
736 
738  clearEventScene();
739  break;
740 
742  modules = & fGearMgr->getTPCParameters().getModules();
743  fVisTPC->testNearestPad((*modules)[0]->getModuleID());
744  break;
745 
748  break;
749 
751  modules = & fGearMgr->getTPCParameters().getModules();
752  fVisTPC->testLeftRightNeighbour((*modules)[0]->getModuleID());
753  break;
754 
755  default:
756  break;
757  }
758 
759  updateGUIState();
760 }
761 
762 void TBBQManager::slotTreeItemChecked(TEveListTreeItem* item, Bool_t check) {
763  std::cout << "slotTreeItemChecked: " << item->GetText() << (check ? " Checked!" : " not Checked!") << std::endl;
764 
765  if (strcmp(item->GetText(), "All hits") == 0) {
766  std::cout << "item is All hits" << std::endl;
767 
768  TEveElementList* list = static_cast<TEveElementList*>(item->GetUserData());
769  //TEveElementList* list = static_cast<TEveElementList*>(item->GetUserData());
770 
771  //list->EnableListElements(check, check);
772  std::cout << "ElementTitle: " << list->GetElementName() << std::endl;
773  }
774 
775  //for (
776  // TGListTreeItem* child = item->GetFirstChild();
777  // child != item->GetLastChild();
778  // child = item->GetNextSibling()
779  //) {
780  // std::cout << "Child: " << child->GetText() << std::endl;
781  // child->CheckItem(check);
782  //}
783 
784  //TEveElement* el = ((TEveElement*) item->GetUserData());
785  //
786  //if (el)
787  // el->EnableListElements(check, check);
788 
789  //if ( (obj->InheritsFrom("TGListItem")) )
790  // std::cout << "Inherits from TGListItem" << std::endl;
791 
792  // return;
793  //
794  //std::cout << obj->ClassName() << " Checked!" << std::endl;
795  //((TEveElement*) obj)->EnableListElements(check, check);
796 }
798  TEveManager::Terminate();
799 
800  gBBQ = 0;
801 }
802 
804  TGPopupMenu* bbqMenu = GetBrowser()->GetMenuBar()->GetPopup("BBQ");
805 
806  // Disable everything
807 
808  bbqMenu->DisableEntry(kMenuOpenGEARFile);
809  bbqMenu->DisableEntry(kMenuOpenLCIOFile);
810  bbqMenu->DisableEntry(kMenuReloadGEARFile);
811  bbqMenu->DisableEntry(kMenuClearGlobalScene);
812  bbqMenu->DisableEntry(kMenuClearEventScene);
813  bbqMenu->DisableEntry(kMenuTestGetNearestPadModule);
814  bbqMenu->DisableEntry(kMenuTestGetNearestPadGlobal);
815  bbqMenu->DisableEntry(kMenuTestGetLeftRightNeighbour);
816 
817  ((TGPictureButton*) fGUI["PrevEventButton"] )->SetEnabled(kFALSE);
818  ((TGPictureButton*) fGUI["ReloadEventButton"])->SetEnabled(kFALSE);
819  ((TGPictureButton*) fGUI["NextEventButton"] )->SetEnabled(kFALSE);
820  ((TGTextEntry*) fGUI["EventEntry"] )->SetEnabled(kFALSE);
821  ((TGTextEntry*) fGUI["RunEntry"] )->SetEnabled(kFALSE);
822 
823  ((TGTextEntry*) fGUI["TPC_MaxDriftLengthEntry"] )->SetEnabled(kFALSE);
824  ((TGTextEntry*) fGUI["TPC_DriftVelocityEntry"] )->SetEnabled(kFALSE);
825  ((TGTextEntry*) fGUI["TPC_ReadoutFrequencyEntry"])->SetEnabled(kFALSE);
826 
827  // Enable things bit by bit
828 
829  bbqMenu->EnableEntry(kMenuOpenGEARFile);
830 
831  if (fGearMgr) {
832  bbqMenu->EnableEntry(kMenuOpenLCIOFile);
833  bbqMenu->EnableEntry(kMenuReloadGEARFile);
834  bbqMenu->EnableEntry(kMenuClearGlobalScene);
835  bbqMenu->EnableEntry(kMenuTestGetNearestPadModule);
836  bbqMenu->EnableEntry(kMenuTestGetNearestPadGlobal);
837  bbqMenu->EnableEntry(kMenuTestGetLeftRightNeighbour);
838 
839  ((TGTextEntry*) fGUI["TPC_MaxDriftLengthEntry"] )->SetEnabled(kTRUE);
840  ((TGTextEntry*) fGUI["TPC_DriftVelocityEntry"] )->SetEnabled(kTRUE);
841  ((TGTextEntry*) fGUI["TPC_ReadoutFrequencyEntry"])->SetEnabled(kTRUE);
842  }
843 
844  if (gBBQ->GetCurrentEvent()->getCurrentEvent()) {
845  bbqMenu->EnableEntry(kMenuClearEventScene);
846 
847  ((TGPictureButton*) fGUI["PrevEventButton"] )->SetEnabled(kTRUE);
848  ((TGPictureButton*) fGUI["ReloadEventButton"])->SetEnabled(kTRUE);
849  ((TGPictureButton*) fGUI["NextEventButton"] )->SetEnabled(kTRUE);
850  ((TGTextEntry*) fGUI["EventEntry"] )->SetEnabled(kTRUE);
851  ((TGTextEntry*) fGUI["RunEntry"] )->SetEnabled(kTRUE);
852  }
853 }
void importGEARFile(const std::string &filePath)
BBQMenu_enum
Definition: TBBQManager.cxx:54
void testNearestPadGlobal()
Definition: vistpc.cxx:2057
void readFile(const std::string &filePath, bool clearEventCollections=true)
Read LCIO data file.
void handleDriftVelocityEntry(const char *text)
TGTextEntry * fRunNumberEntry
std::string fCurrentGEARFile
Definition: TBBQManager.h:57
void updateGUIState()
static void Terminate()
TBBQManager * gBBQ
Definition: TBBQManager.cxx:52
Main visualization class. It is used to draw GEAR detector geometries and LCIO data. It is a self-contained class that depends only on ROOT, TEve, GEAR and LCIO. This means you can use this class outside and independent of BBQ.
Definition: vistpc.h:65
A derived class of TEveEventManager that governs the navigation through events.
void displayEventCollections(const EVENT::LCEvent *event)
void importLCIOFile(const std::string &filePath)
float getDriftVelocity()
Definition: vistpc.h:140
void testLeftRightNeighbour(int moduleID=0)
Definition: vistpc.cxx:1773
std::string dialogOpenFile(const char **fileTypes)
virtual TBBQEventManager * GetCurrentEvent()
Definition: TBBQManager.h:75
void setMaxDriftLength(float length)
Definition: vistpc.h:154
TBBQManager(UInt_t w, UInt_t h, Bool_t map_window=kTRUE, Option_t *opt="FI")
Definition: TBBQManager.cxx:70
void drawTPC()
Definition: vistpc.cxx:1220
void testNearestPad(int moduleID=0)
Definition: vistpc.cxx:1929
void setDriftVelocity(float velocity)
Definition: vistpc.h:153
void clearGlobalScene()
std::map< std::string, TGObject * > fGUI
Definition: TBBQManager.h:65
void dialogOpenGEARFile()
void slotMenu(Int_t menuId)
static TBBQManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
TGTextEntry * fEventNumberEntry
TGListBox * fHitsCollections
Definition: TBBQManager.h:61
void dialogOpenLCIOFile()
void updateGearMgr(gear::GearMgr *aGearMgr)
A function to update the vistpc with information from a new gear file.
Definition: vistpc.cxx:2164
void slotTreeItemChecked(TEveListTreeItem *item, Bool_t check)
TGListBox * fPulsesCollections
Definition: TBBQManager.h:62
TGListBox * fTracksCollections
Definition: TBBQManager.h:63
const LCCollectionType_enum getCollectionType(const std::string &)
Definition: vistpc.cxx:1605
gear::GearMgr * fGearMgr
Definition: TBBQManager.h:55
VisTPC * fVisTPC
Definition: TBBQManager.h:59
void handleMaxDriftLengthEntry(const char *text)
float getReadoutFrequency()
Definition: vistpc.h:139
void handleCheckbutton(const char *)
void GotoEvent(int eventNumber)
void setOption(std::string option, int value)
Definition: vistpc.h:156
void handleReadoutFrequencyEntry(const char *text)
void clearEventScene()
void setReadoutFrequency(float frequency)
Definition: vistpc.h:152
A derived class of TEveManager tailored to the needs of BBQ.
Definition: TBBQManager.h:52
EVENT::LCEvent * getCurrentEvent()
void clearEventCollections()