EIC 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  // draw by particle type and set nice color
47 // g4->ApplyCommand("/vis/modeling/trajectories/create/drawByParticleID");
48 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set e+ steelblue");
49 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set e- steelblue");
50 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set pi+ red");
51 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set pi- red");
52 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set kaon- mediumvioletred");
53 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set kaon+ mediumvioletred");
54 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set kaon0 mediumvioletred");
55 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set proton+ orange");
56 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set proton- orange");
57 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set neutron lightgrey");
58 // g4->ApplyCommand("/vis/modeling/trajectories/drawByParticleID-0/set gamma wheat");
59 // g4->ApplyCommand("/vis/scene/add/trajectories smooth rich");
60  // remove neutrons and neutrinos
61 // g4->ApplyCommand("/vis/filtering/trajectories/create/particleFilter");
62 // g4->ApplyCommand("/vis/filtering/trajectories/particleFilter-0/add neutron");
63 // g4->ApplyCommand("/vis/filtering/trajectories/particleFilter-0/add neutrino");
64 // g4->ApplyCommand("/vis/filtering/trajectories/particleFilter-0/invert true");
65 
66  // set background white for presentations
67  g4->ApplyCommand("/vis/viewer/set/background white");
68 
69 
70  return g4;
71 }
72 // print out the commands I always forget
73 void displaycmd()
74 {
75  cout << "draw axis: " << endl;
76  cout << " g4->ApplyCommand(\"/vis/scene/add/axes 0 0 0 50 cm\")" << endl;
77  cout << "zoom" << endl;
78  cout << " g4->ApplyCommand(\"/vis/viewer/zoom 1\")" << endl;
79  cout << "viewpoint:" << endl;
80  cout << " g4->ApplyCommand(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << endl;
81  cout << "panTo:" << endl;
82  cout << " g4->ApplyCommand(\"/vis/viewer/panTo 0 0 cm\")" << endl;
83  cout << "print to eps:" << endl;
84  cout << " g4->ApplyCommand(\"/vis/ogl/printEPS\")" << endl;
85  cout << "set background color:" << endl;
86  cout << " g4->ApplyCommand(\"/vis/viewer/set/background white\")" << endl;
87 }
88 
89 
90 
91 #endif
92