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 #pragma once
2 
3 #include <g4main/PHG4Reco.h>
4 
6 
7 R__LOAD_LIBRARY(libfun4all.so)
8 R__LOAD_LIBRARY(libg4testbench.so)
9 
10 namespace Enable
11 {
12  bool DISPLAY = false;
13 }
14 
15 // This starts the QT based G4 gui which takes control
16 // when x'ed out it will return a pointer to PHG4Reco so
17 // the gui can be startrd again
19 {
21  PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
22  g4->InitRun(se->topNode());
23  g4->ApplyDisplayAction();
24  g4->StartGui();
25  return g4;
26 }
27 
28 // stupid macro to turn on the geant4 display
29 // we ask Fun4All for a pointer to PHG4Reco
30 // using the ApplyCommand will start up the
31 // G4 cmd interpreter and graphics system
32 // the vis.mac contains the necessary commands to
33 // start up the visualization, the next event will
34 // be displayed. Do not execute this macro
35 // before PHG4Reco was registered with Fun4All
36 PHG4Reco *DisplayOn(const char *mac = "vis.mac")
37 {
38  char cmd[100];
40  PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
41  g4->InitRun(se->topNode());
42  g4->ApplyDisplayAction();
43  sprintf(cmd, "/control/execute %s", mac);
44  g4->ApplyCommand(cmd);
45  return g4;
46 }
47 // print out the commands I always forget
48 void displaycmd()
49 {
50  cout << "draw axis: " << endl;
51  cout << " g4->ApplyCommand(\"/vis/scene/add/axes 0 0 0 50 cm\")" << endl;
52  cout << "zoom" << endl;
53  cout << " g4->ApplyCommand(\"/vis/viewer/zoom 1\")" << endl;
54  cout << "viewpoint:" << endl;
55  cout << " g4->ApplyCommand(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << endl;
56  cout << "panTo:" << endl;
57  cout << " g4->ApplyCommand(\"/vis/viewer/panTo 0 0 cm\")" << endl;
58  cout << "print to eps:" << endl;
59  cout << " g4->ApplyCommand(\"/vis/ogl/printEPS\")" << endl;
60  cout << "set background color:" << endl;
61  cout << " g4->ApplyCommand(\"/vis/viewer/set/background white\")" << endl;
62  cout << "Overlap check:" << endl;
63  cout << " g4->ApplyCommand(\"/geometry/test/run\")" << endl;
64 }