12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Getting Started with <strong>Geant4</strong>- Running a Simple ExampleIn order to use the DAWNFILE driver, you need Fukui Renderer DAWN, which is obtainable from the followingWeb site: http://geant4.kek.jp/GEANT4/vis.In order to use the the OpenGL drivers, you need the OpenGL library, which is installed in many plat<strong>for</strong>ms bydefault. You also need to set an environmental variable G4VIS_BUILD_OPENGLX_DRIVER to 1 in building(installing) Genat4 libraries, and also set another environmental variable G4VIS_USE_OPENGLX to 1 in compilingyour <strong>Geant4</strong> executable. You may also have to set an environmental variable OGLHOME to the OpenGLroot directory. For example,setenv G4VIS_BUILD_OPENGLX_DRIVER 1setenv G4VIS_USE_OPENGLX 1setenv OGLHOME /usr/X11R6Some other visualization drivers depending on external libraries are also required to set the similar environmentalvariables, G4VIS_BUILD_DRIVERNAME_DRIVER and G4VIS_USE_DRIVERNAME, to 1. All visualizationdrivers independent of external libraries, e.g. DAWNFILE and VRMLFILE drivers, need not such setting. (Butyou must prepare a proper visualization manager class and a proper main() function, anyway. See below.)For all visualization drivers available in your <strong>Geant4</strong> executable, the C-pre-processor flagsG4VIS_USE_DRIVERNAME are automatically set by config/G4VIS_USE.gmk in compilation. Similarly,<strong>for</strong> all visualization drivers incorporated into the <strong>Geant4</strong> libraries, the C-pre-processor flagsG4VIS_BUILD_DRIVERNAME_DRIVER are automatically set by config/G4VIS_BUILD.gmk in installation.2.10.3. How to Incorporate Visualization Drivers into anExecutableYou can realize (use) visualization driver(s) you want in your <strong>Geant4</strong> executable. These can only be from the setinstalled in the <strong>Geant4</strong> libraries. You will be warned if the one you request is not available.In order to realize visualization drivers, you must instantiate and initialize a subclass of G4VisManager thatimplements the pure virtual function RegisterGraphicsSystems(). This subclass must be compiled inthe user's domain to <strong>for</strong>ce the loading of appropriate libraries in the right order. The easiest way to do this is touse G4VisExecutive, a provided class with included implementation. G4VisExecutive is sensitive to theG4VIS_USE... variables mentioned above.If you do wish to write your own subclass, you may do so. You will see how to do this by looking atG4VisExecutive.icc. A typical extract is:...RegisterGraphicsSystem (new G4DAWNFILE);...#ifdef G4VIS_USE_OPENGLXRegisterGraphicsSystem (new G4OpenGLImmediateX);RegisterGraphicsSystem (new G4OpenGLStoredX);#endif...If you wish to use G4VisExecutive but register an additional graphics system, XXX say, you may do so eitherbe<strong>for</strong>e or after initializing:visManager->RegisterGraphicsSytem(new XXX);visManager->Initialize();An example of a typical main() function is given below.2.10.4. Writing the main() Method to Include VisualizationNow we explain how to write a visualization manager and the main() function <strong>for</strong> <strong>Geant4</strong> visualization. In orderthat your <strong>Geant4</strong> executable is able to per<strong>for</strong>m visualization, you must instantiate and initialize your Visualiza-29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!