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.

VisualizationThe pointer to the concrete instance of the real Visualization Manager can be obtained as follows://----- Getting a pointer to the concrete Visualization Manager instanceG4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();The method G4VVisManager::GetConcreteInstance() returns NULL if <strong>Geant4</strong> is not ready <strong>for</strong> visualization.Thus your C++ source code should be protected as follows://----- How to protect your C++ source codes in visualizationif (pVVisManager) {....pVVisManager ->Draw (...);....}8.5.2. Visualization of detector componentsIf you have already constructed detector components with logical volumes to which visualization attributes areproperly assigned, you are almost ready <strong>for</strong> visualizing detector components. All you have to do is to describeproper visualization commands within your C++ codes, using the ApplyCommand() method.For example, the following is sample C++ source codes to visualize the detector components://----- C++ source code: How to visualize detector components (2)// ... using visualization commands in source codesG4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance() ;if(pVVisManager){... (camera setting etc) ...G4UImanager::GetUIpointer()->ApplyCommand("/vis/drawVolume");G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/flush");}//----- end of C++ source codeIn the above, you should also describe /vis/open command somewhere in your C++ codes or execute thecommand from (G)UI at the executing stage.8.5.3. Visualization of trajectoriesIn order to visualize trajectories, you can use the method void G4Trajectory::DrawTrajectory()defined in the tracking category. In the implementation of this method, the following drawing method ofG4VVisManager is used://----- A drawing method of G4Polylinevirtual void G4VVisManager::Draw (const G4Polyline&, ...) ;The real implementation of this method is described in the class G4VisManager.At the end of one event, a set of trajectories can be stored as a list of G4Trajectory objects. There<strong>for</strong>eyou can visualize trajectories, <strong>for</strong> example, at the end of each event, by implementing the methodMyEventAction::EndOfEventAction() as follows://----- C++ source codesvoid ExN03EventAction::EndOfEventAction(const G4Event* evt){.....// extract the trajectories and draw themif (G4VVisManager::GetConcreteInstance())245

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

Saved successfully!

Ooh no, something went wrong!