120 likes | 241 Views
Basic Visualization Tutorial. Using Geant4. Why visualize?. Debugging geometry Demonstration purpose Interactive picking of visualized objects For fun………. What can you visualize?. Detector components Physical volumes Particle trajectories Hits of particles in detector components.
E N D
Basic Visualization Tutorial Using Geant4 Wah-kai Ngai
Why visualize? • Debugging geometry • Demonstration purpose • Interactive picking of visualized objects • For fun……… Wah-kai Ngai
What can you visualize? • Detector components • Physical volumes • Particle trajectories • Hits of particles in detector components Wah-kai Ngai
Things you need to do • Choose a visualization driver • OpenGL, HepRepFile, DAWN • They have different limitations and advantages. I use OpenGL personally because of its speed • No matter which one you use, the following procedures are the same Wah-kai Ngai
Things you need to do • Register the drivers, see novice examples N02, • ../examples/novice/N02/include/ExN02VisManager.hh • ../examples/novice/N02/src/ExN02VisManager.cc • Basically, just copy the code and change some words to make it run Wah-kai Ngai
Things you need to do • Add attributes to the detector components you want to visualize • Visualization attributes are a set of information associated with objects which can be visualized Wah-kai Ngai
Color • G4VisAttributes holds its color entry as an object of the class G4Colour • A G4Colour object is created by giving the red, blue and green components of the color G4Color( G4double red=1.0,G4double green=1.0,G4double blue=1.0, G4double a=1.0); • The default value of each component is 1, which means white Wah-kai Ngai
Color G4Colour white () ; // white G4Colour white (1.,1.,1.) ; // white G4Colour gray (.5,.5,.5) ; // gray G4Colour black (0.,0.,0.) ; // black G4Colour red (1.,0.,0.) ; // red G4Colour green (0.,1.,0.) ; // green G4Colour blue (0.,0.,1.) ; // blue G4Colour cyan (0.,1.,1.) ; // cyan G4Colour magenta (1.,0.,1.) ; // magenta G4Colour yellow (1.,1.,0.) ; // yellow Wah-kai Ngai
Color • One can set the RGBA components directly into G4VisAttributes void G4VisAttributes::SetColour (G4double red, G4double green, G4double blue, G4double alpha=1.0); • The following G4VisAttributes constructor is also supported G4VisAttributes::G4VisAttributes(const G4Colour& color); Wah-kai Ngai
Forced wireframe and forced solid styles • one can select to visualize detector components in “wireframe” or with “surfaces”. • The forced wireframe and forced solid styles make it possible to mix wireframe and solid visualization. For instance, one can make the mother volume transparent and still look inside when in “solid” mode • Forced wireframe and forced solid are available via: void G4VisAttributes::SetForceWireframe(G4bool force); void G4VisAttributes::SetForceSolid(G4bool force); Wah-kai Ngai
How to assign G4VisAttributes to a volume? • In constructing the detector components, one may assign a set of visualization attributes to each LOGICAL VOLUME in order to visualize it later • G4LogicalVolume holds a pointer to a G4VisAttributes. • void G4LogicalVolume::SetVisAttributes(const G4VisAttributes* pVa); • ExpHall_log=new G4LogicalVolume(ExpHall_box,Air,”exp_hall”); • G4VisAttributes *expHallVisAtt=new G4VisAttributes(G4Colour(0.,1.,1.)); • expHallVisAtt->SetForceWireframe(true); • ExpHall_log->SetVisAttributes(expHallVisAtt); Wah-kai Ngai
Things you need to do • Recompile the program! • Need some built-in command to order geant4 for visualization • Check out ../examples/novice/N02/vis.mac Wah-kai Ngai