Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisplayOn.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DisplayOn.C
1 #ifndef MACRO_DISPLAYON_C
2 #define MACRO_DISPLAYON_C
3 
4 #include <g4main/PHG4Reco.h>
5 
7 
8 R__LOAD_LIBRARY(libfun4all.so)
9 R__LOAD_LIBRARY(libg4testbench.so)
10 
11 namespace Enable
12 {
13  bool DISPLAY = false;
14 }
15 
16 // This starts the QT based G4 gui which takes control
17 // when x'ed out it will return a pointer to PHG4Reco so
18 // the gui can be startrd again
20 {
22  PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
23  g4->InitRun(se->topNode());
24  g4->ApplyDisplayAction();
25  g4->StartGui();
26  return g4;
27 }
28 
29 // stupid macro to turn on the geant4 display
30 // we ask Fun4All for a pointer to PHG4Reco
31 // using the ApplyCommand will start up the
32 // G4 cmd interpreter and graphics system
33 // the vis.mac contains the necessary commands to
34 // start up the visualization, the next event will
35 // be displayed. Do not execute this macro
36 // before PHG4Reco was registered with Fun4All
37 PHG4Reco *DisplayOn(const char *mac = "vis.mac")
38 {
39  char cmd[100];
41  PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
42  g4->InitRun(se->topNode());
43  g4->ApplyDisplayAction();
44  sprintf(cmd, "/control/execute %s", mac);
45  g4->ApplyCommand(cmd);
46  return g4;
47 }
48 // print out the commands I always forget
49 void displaycmd()
50 {
51  cout << "draw axis: " << endl;
52  cout << " g4->ApplyCommand(\"/vis/scene/add/axes 0 0 0 50 cm\")" << endl;
53  cout << "zoom" << endl;
54  cout << " g4->ApplyCommand(\"/vis/viewer/zoom 1\")" << endl;
55  cout << "viewpoint:" << endl;
56  cout << " g4->ApplyCommand(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << endl;
57  cout << "panTo:" << endl;
58  cout << " g4->ApplyCommand(\"/vis/viewer/panTo 0 0 cm\")" << endl;
59  cout << "print to eps:" << endl;
60  cout << " g4->ApplyCommand(\"/vis/ogl/printEPS\")" << endl;
61  cout << "set background color:" << endl;
62  cout << " g4->ApplyCommand(\"/vis/viewer/set/background white\")" << endl;
63 }
64 #endif