I am trying to develop a standalone application using the TGeom library to display the geometry of a detector to illustrate the hits and tracking of the particles traveling through it. The geometry and tracking isn’t proving to be too difficult but I was trying to make a TControlBar that would control the program and allow for the selection of different entries in the TTree I am reading data from.
When I attempt to call a function from a button I get the following code returned in the terminal:
Error: Function box() is not defined in current scope (tmpfile):1:
*** Interpreter error recovered ***
I have attempted numerous methods to define the function box() which is just a test program for now. I have tried to find previous suggestions I have found online but so far have been unable to correct it. My code is attached below. One interesting thing I noticed is that to exit the control bar I had to use the command “.q”. To me this means the program is dependent on ROOT CINT and isn’t looking for the compiled function but I have no idea how to fix it, but this is just my current thought about it.
int main(int argc, char **argv){
TApplication * theApp = new TApplication(“RichEvent”, 0, 0);
TControlBar *bar = new TControlBar(“vertical”, “Pienu Visualization GUI”,200,10);
bar->AddButton(“Box Geom”,“box()”,“This will make a random Geometry”);
bar->AddButton(“exit”,".q",“This will close the program”);
bar->SetButtonWidth(400);
bar->Show();
theApp->Run();
return 0;
}
In LinkDef.h, replace: #pragma link C++ function box;
by: #pragma link C++ class box+;
And in box.cxx (showing only the relevant part):
box *mybox = new box();
TApplication *theApp = new TApplication("RichEvent", 0, 0);
TControlBar *bar = new TControlBar("vertical", "Pienu Visualization GUI",200,10);
bar->AddButton("Box Geom", Form("((box *)0x%ld)->setupBox()", mybox), "This will make a random Geometry");