14 #include <TApplication.h>
17 #include <TRootBrowser.h>
22 #include <TGFileDialog.h>
25 #include <TGListBox.h>
28 #include <TGTextEntry.h>
32 #include <TEveBrowser.h>
33 #include <TEveEventManager.h>
34 #include <TEveScene.h>
40 #include "IMPL/LCEventImpl.h"
41 #include "IMPL/LCCollectionVec.h"
42 #include "Exceptions.h"
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>
76 TEveManager(w, h, map_window, opt),
80 fTracksCollections(0),
85 TGLayoutHints* fillx =
new TGLayoutHints(kLHintsExpandX);
91 TGMenuBar *menuBar = GetBrowser()->GetMenuBar();
92 TGHorizontalFrame *menuFrame = GetBrowser()->GetTopMenuFrame();
93 TGPopupMenu *bbqMenu =
new TGPopupMenu(gClient->GetRoot());
97 bbqMenu->AddSeparator();
99 bbqMenu->AddSeparator();
102 bbqMenu->AddSeparator();
107 bbqMenu->Connect(
"Activated(Int_t)",
"TBBQManager",
this,
"slotMenu(Int_t)");
109 menuBar->AddPopup(
"BBQ", bbqMenu,
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
110 menuFrame->MapSubwindows();
119 TEveBrowser* browser = gEve->GetBrowser();
120 browser->StartEmbedding(TRootBrowser::kLeft);
122 TGMainFrame* frmMain =
new TGMainFrame(gClient->GetRoot(), 1000, 600);
123 frmMain->SetWindowName(
"XX GUI");
124 frmMain->SetCleanup(kDeepCleanup);
126 TGGroupFrame *group = NULL;
127 TGHorizontalFrame *hf = NULL;
134 group =
new TGGroupFrame(frmMain,
"Event navigation");
138 hf =
new TGHorizontalFrame(group);
140 TGLabel* runLabel =
new TGLabel(hf,
"Run #");
141 TGTextEntry* runEntry =
new TGTextEntry(hf);
143 hf->AddFrame(runLabel);
144 hf->AddFrame(runEntry,
new TGLayoutHints(kLHintsRight));
145 fGUI[
"RunEntry"] = runEntry;
147 runEntry->SetWidth(100);
157 group->AddFrame(hf,
new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
159 hf =
new TGHorizontalFrame(group);
161 TGLabel* eventLabel =
new TGLabel(hf,
"Event #");
162 TGTextEntry* eventEntry =
new TGTextEntry(hf);
164 eventEntry->SetWidth(100);
165 hf->AddFrame(eventLabel);
166 hf->AddFrame(eventEntry,
new TGLayoutHints(kLHintsRight));
167 fGUI[
"EventEntry"] = eventEntry;
178 group->AddFrame(hf, fillx);
182 hf =
new TGHorizontalFrame(group);
184 TString icondir(TString::Format(
"%s/icons/", gSystem->Getenv(
"ROOTSYS")) );
185 TGPictureButton* b = 0;
187 b =
new TGPictureButton(hf, gClient->GetPicture(icondir +
"GoBack.gif"));
189 fGUI[
"PrevEventButton"] = b;
197 b =
new TGPictureButton(hf, gClient->GetPicture(icondir +
"ReloadPage.gif"));
199 fGUI[
"ReloadEventButton"] = b;
207 b =
new TGPictureButton(hf, gClient->GetPicture(icondir +
"GoForward.gif"));
209 fGUI[
"NextEventButton"] = b;
217 group->AddFrame(hf,
new TGLayoutHints(kLHintsCenterX, 0, 0, 5, 0));
219 frmMain->AddFrame(group);
224 group =
new TGGroupFrame(frmMain,
"Pulses");
225 hf =
new TGHorizontalFrame(group);
233 frmMain->AddFrame(group, fillx);
235 group =
new TGGroupFrame(frmMain,
"Hits");
236 hf =
new TGHorizontalFrame(group);
244 frmMain->AddFrame(group, fillx);
246 group =
new TGGroupFrame(frmMain,
"Tracks");
247 hf =
new TGHorizontalFrame(group);
255 frmMain->AddFrame(group, fillx);
260 frmMain->MapSubwindows();
262 frmMain->MapWindow();
264 browser->StopEmbedding(
"Event");
270 browser->StartEmbedding(TRootBrowser::kLeft);
272 frmMain =
new TGMainFrame(gClient->GetRoot(), 1000, 600);
273 frmMain->SetWindowName(
"XX GUI");
274 frmMain->SetCleanup(kDeepCleanup);
276 group =
new TGGroupFrame(frmMain,
"TPC properties");
280 hf =
new TGHorizontalFrame(group);
282 TGLabel* driftLabel =
new TGLabel(hf,
"Max drift length");
283 TGTextEntry* driftEntry =
new TGTextEntry(hf);
285 hf->AddFrame(driftLabel);
286 hf->AddFrame(driftEntry,
new TGLayoutHints(kLHintsRight));
287 fGUI[
"TPC_MaxDriftLengthEntry"] = driftEntry;
289 driftEntry->SetWidth(100);
291 "TextChanged(const char*)",
294 "handleMaxDriftLengthEntry(const char*)"
297 group->AddFrame(hf, fillx);
301 hf =
new TGHorizontalFrame(group);
303 TGLabel* frequencyLabel =
new TGLabel(hf,
"Readout frequency");
304 TGTextEntry* frequencyEntry =
new TGTextEntry(hf);
306 hf->AddFrame(frequencyLabel);
307 hf->AddFrame(frequencyEntry,
new TGLayoutHints(kLHintsRight));
308 fGUI[
"TPC_ReadoutFrequencyEntry"] = frequencyEntry;
310 frequencyEntry->SetWidth(100);
311 frequencyEntry->Connect(
312 "TextChanged(const char*)",
315 "handleReadoutFrequencyEntry(const char*)"
318 group->AddFrame(hf, fillx);
322 hf =
new TGHorizontalFrame(group);
324 TGLabel* driftVelocityLabel =
new TGLabel(hf,
"Drift velocity");
325 TGTextEntry* driftVelocityEntry =
new TGTextEntry(hf);
327 hf->AddFrame(driftVelocityLabel);
328 hf->AddFrame(driftVelocityEntry,
new TGLayoutHints(kLHintsRight));
329 fGUI[
"TPC_DriftVelocityEntry"] = driftVelocityEntry;
331 driftVelocityEntry->SetWidth(100);
332 driftVelocityEntry->Connect(
333 "TextChanged(const char*)",
336 "handleDriftVelocityEntry(const char*)"
339 group->AddFrame(hf, fillx);
341 frmMain->AddFrame(group, fillx);
346 TGCheckButton *checkbutton = NULL;
348 group =
new TGGroupFrame(frmMain,
"Module visualisation");
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);
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);
366 frmMain->AddFrame(group, fillx);
370 frmMain->MapSubwindows();
372 frmMain->MapWindow();
374 browser->StopEmbedding(
"Options");
424 std::cout <<
"Clearing current event scene: ";
426 gEve->GetCurrentEvent()->DestroyElements();
429 std::cout <<
"done." << std::endl;
433 std::cout <<
"Clearing current global scene: ";
435 gEve->GetGlobalScene()->DestroyElements();
438 std::cout <<
"done." << std::endl;
445 static const TEveException eh(
"TEveManager::Create ");
450 if (gROOT->IsBatch())
452 throw eh +
"ROOT is running in batch mode.";
454 TApplication::NeedGraphicsLibs();
455 gApplication->InitializeGraphics();
456 if (gROOT->IsBatch() || gClient == 0 || gClient->IsZombie())
458 throw eh +
"window system not initialized.";
464 TEveUtil::SetupEnvironment();
465 TEveUtil::SetupGUI();
476 TGFileInfo selectedFile;
478 static TString dir(
".");
480 selectedFile.fFileTypes = fileTypes;
481 selectedFile.fIniDir = StrDup(dir);
482 selectedFile.fMultipleSelection = kFALSE;
487 gClient->GetDefaultRoot(),
488 this->GetMainWindow(),
495 std::string returnStr(gSystem->UnixPathName(selectedFile.fFilename));
501 const char* fileTypes[] = {
502 "GEAR file",
"*.xml",
503 "GEAR file",
"*.gear",
512 if (selectedFile.empty())
517 }
catch (gear::Exception e) {
519 std::cout << e.what() << std::endl;
528 const char* fileTypes[] = {
529 "LCIO file",
"*.slcio",
538 if (selectedFile.empty())
557 const std::vector<std::string> * names =
event->getCollectionNames();
561 std::vector<std::string>::const_iterator it = names->begin();
585 std::string option(button);
587 std::map<std::string, TGObject*>::iterator it =
fGUI.find(option);
589 if (it ==
fGUI.end())
596 std::stringstream sstr(text);
598 if (sstr.str().empty())
603 if (sstr >> driftVelocity)
606 std::cout <<
"\"" << text <<
"\""
607 <<
"is not a number." << std::endl;
611 std::stringstream sstr(text);
613 if (sstr.str().empty())
616 float maxDriftLength;
618 if (sstr >> maxDriftLength)
621 std::cout <<
"\"" << text <<
"\""
622 <<
"is not a number." << std::endl;
626 std::stringstream sstr(text);
628 if (sstr.str().empty())
631 float readoutFrequency;
633 if (sstr >> readoutFrequency)
636 std::cout <<
"\"" << text <<
"\""
637 <<
"is not a number." << std::endl;
641 if (filePath.empty())
644 std::cout <<
"importing GEAR: " << filePath << std::endl;
660 gear::GearXML gearXML(filePath);
668 std::stringstream text;
671 text <<
fGearMgr->getTPCParameters().getMaxDriftLength();
673 (
dynamic_cast<TGTextEntry *
> (
fGUI[
"TPC_MaxDriftLengthEntry"]))
674 ->SetText(text.str().c_str());
681 (
dynamic_cast<TGTextEntry *
> (
fGUI[
"TPC_ReadoutFrequencyEntry"]))
682 ->SetText(text.str().c_str(), kFALSE);
687 (
dynamic_cast<TGTextEntry *
> (
fGUI[
"TPC_DriftVelocityEntry"]))
688 ->SetText(text.str().c_str(), kFALSE);
696 if (filePath.empty())
699 std::cout <<
"importing LCIO: " << filePath << std::endl;
708 const std::vector<gear::TPCModule *> * modules = 0;
713 this->Redraw3D(kTRUE);
718 std::cout <<
" error -> first load GEAR." << std::endl;
742 modules = &
fGearMgr->getTPCParameters().getModules();
751 modules = &
fGearMgr->getTPCParameters().getModules();
763 std::cout <<
"slotTreeItemChecked: " << item->GetText() << (check ?
" Checked!" :
" not Checked!") << std::endl;
765 if (strcmp(item->GetText(),
"All hits") == 0) {
766 std::cout <<
"item is All hits" << std::endl;
768 TEveElementList* list =
static_cast<TEveElementList*
>(item->GetUserData());
772 std::cout <<
"ElementTitle: " << list->GetElementName() << std::endl;
798 TEveManager::Terminate();
804 TGPopupMenu* bbqMenu = GetBrowser()->GetMenuBar()->GetPopup(
"BBQ");
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);
823 ((TGTextEntry*)
fGUI[
"TPC_MaxDriftLengthEntry"] )->SetEnabled(kFALSE);
824 ((TGTextEntry*)
fGUI[
"TPC_DriftVelocityEntry"] )->SetEnabled(kFALSE);
825 ((TGTextEntry*)
fGUI[
"TPC_ReadoutFrequencyEntry"])->SetEnabled(kFALSE);
839 ((TGTextEntry*)
fGUI[
"TPC_MaxDriftLengthEntry"] )->SetEnabled(kTRUE);
840 ((TGTextEntry*)
fGUI[
"TPC_DriftVelocityEntry"] )->SetEnabled(kTRUE);
841 ((TGTextEntry*)
fGUI[
"TPC_ReadoutFrequencyEntry"])->SetEnabled(kTRUE);
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);
void importGEARFile(const std::string &filePath)
void testNearestPadGlobal()
void readFile(const std::string &filePath, bool clearEventCollections=true)
Read LCIO data file.
void handleDriftVelocityEntry(const char *text)
TGTextEntry * fRunNumberEntry
std::string fCurrentGEARFile
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.
A derived class of TEveEventManager that governs the navigation through events.
void displayEventCollections(const EVENT::LCEvent *event)
void importLCIOFile(const std::string &filePath)
void testLeftRightNeighbour(int moduleID=0)
std::string dialogOpenFile(const char **fileTypes)
virtual TBBQEventManager * GetCurrentEvent()
void setMaxDriftLength(float length)
TBBQManager(UInt_t w, UInt_t h, Bool_t map_window=kTRUE, Option_t *opt="FI")
void testNearestPad(int moduleID=0)
void setDriftVelocity(float velocity)
std::map< std::string, TGObject * > fGUI
void dialogOpenGEARFile()
void slotMenu(Int_t menuId)
static TBBQManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
TGTextEntry * fEventNumberEntry
TGListBox * fHitsCollections
void dialogOpenLCIOFile()
void updateGearMgr(gear::GearMgr *aGearMgr)
A function to update the vistpc with information from a new gear file.
void slotTreeItemChecked(TEveListTreeItem *item, Bool_t check)
TGListBox * fPulsesCollections
TGListBox * fTracksCollections
const LCCollectionType_enum getCollectionType(const std::string &)
void handleMaxDriftLengthEntry(const char *text)
float getReadoutFrequency()
void handleCheckbutton(const char *)
void GotoEvent(int eventNumber)
void setOption(std::string option, int value)
void handleReadoutFrequencyEntry(const char *text)
void setReadoutFrequency(float frequency)
A derived class of TEveManager tailored to the needs of BBQ.
EVENT::LCEvent * getCurrentEvent()
void clearEventCollections()