Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:24:04

0001 #ifndef MACRO_DISPLAYON_C
0002 #define MACRO_DISPLAYON_C
0003 
0004 #include <g4main/PHG4Reco.h>
0005 
0006 #include <fun4all/Fun4AllServer.h>
0007 
0008 R__LOAD_LIBRARY(libfun4all.so)
0009 R__LOAD_LIBRARY(libg4testbench.so)
0010 
0011 namespace Enable
0012 {
0013   bool DISPLAY = false;
0014 }
0015 
0016 // This starts the QT based G4 gui which takes control
0017 // when x'ed out it will return a pointer to PHG4Reco so
0018 // the gui can be startrd again
0019 PHG4Reco *QTGui()
0020 {
0021   Fun4AllServer *se = Fun4AllServer::instance();
0022   PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
0023   g4->InitRun(se->topNode());
0024   g4->ApplyDisplayAction();
0025   g4->StartGui();
0026   return g4;
0027 }
0028 
0029 // stupid macro to turn on the geant4 display
0030 // we ask Fun4All for a pointer to PHG4Reco
0031 // using the ApplyCommand will start up the
0032 // G4 cmd interpreter and graphics system
0033 // the vis.mac contains the necessary commands to
0034 // start up the visualization, the next event will
0035 // be displayed. Do not execute this macro
0036 // before PHG4Reco was registered with Fun4All
0037 PHG4Reco *DisplayOn(const std::string &mac = "vis.mac")
0038 {
0039   Fun4AllServer *se = Fun4AllServer::instance();
0040   PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco("PHG4RECO");
0041   g4->InitRun(se->topNode());
0042   g4->ApplyDisplayAction();
0043   std::string cmd =  "/control/execute " + mac;
0044   g4->ApplyCommand(cmd);
0045   return g4;
0046 }
0047 // print out the commands I always forget
0048 void displaycmd()
0049 {
0050   std::cout << "draw axis: " << std::endl;
0051   std::cout << " g4->ApplyCommand(\"/vis/scene/add/axes 0 0 0 50 cm\")" << std::endl;
0052   std::cout << "zoom" << std::endl;
0053   std::cout << " g4->ApplyCommand(\"/vis/viewer/zoom 1\")" << std::endl;
0054   std::cout << "viewpoint:" << std::endl;
0055   std::cout << " g4->ApplyCommand(\"/vis/viewer/set/viewpointThetaPhi 0 0\")" << std::endl;
0056   std::cout << "panTo:" << std::endl;
0057   std::cout << " g4->ApplyCommand(\"/vis/viewer/panTo 0 0 cm\")" << std::endl;
0058   std::cout << "print to eps:" << std::endl;
0059   std::cout << " g4->ApplyCommand(\"/vis/ogl/printEPS\")" << std::endl;
0060   std::cout << "set background color:" << std::endl;
0061   std::cout << " g4->ApplyCommand(\"/vis/viewer/set/background white\")" << std::endl;
0062   std::cout << "Overlap check:" << std::endl;
0063   std::cout << " g4->ApplyCommand(\"/geometry/test/run\")" << std::endl;
0064 }
0065 
0066 #endif