G4Vis Advanced

Views:
 
Category: Education
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Slide1: 

HepRep/WIRED DAWN OpenGL How to Control the Drawing Style and Filtering of Detector Geometry and Trajectories Geant4 Advanced Visualization Joseph Perl, SLAC

How this Document Fits withOther Tutorial Materials: 

How this Document Fits with Other Tutorial Materials This presentation can be used on its own, but gives the most comprehensive introduction to Geant4 visualization when used as part of the following full set of documents: Introduction to Geant4 Visualization Geant4 Installation Guides Geant4 Visualization Tutorial using the WIRED3 HepRep Browser Geant4 Visualization Tutorial using the DAWN Event Display Geant4 Visualization Tutorial using the OpenGL Event Display Geant4 Visualization Commands Geant4 Advanced Visualization See the URLS at the end of this presentation This presentation discusses seven visualization drivers: OpenGL OpenInventor HepRep/WIRED DAWN VRML RayTracer ASCIITree

Two Kinds of Visualization Attributes: 

Two Kinds of Visualization Attributes G4VisAttributes - carry standard drawing information: Color Visible/Invisible Wireframe/Solid etc. HepRep-Style Attributes - carry arbitrary, user-defined information: for trajectories: momentum particle type etc. for hits: energy electronics channel number etc. for geometry volumes: logical volume name material etc.

G4VisAttributes: 

G4VisAttributes G4VisAttributes - carry standard drawing information: Color Visible/Invisible Wireframe/Solid etc.

LineStyle: WireFrame or Solid: 

LineStyle: WireFrame or Solid WireFrame Solid

Setting Vis Attributes from C++: 

Setting Vis Attributes from C++ Create a G4VisAttributes object and assign it to a volume: experimentalHall_logical -andgt; SetVisAttributes (G4VisAttributes::Invisible)

Setting Vis Attributes from Commands: 

Setting Vis Attributes from Commands From the command prompt: /vis/viewer/set/style wireframe Watch out for fact that interactive commands do not override C++ commands that have the 'force' prefix, such as: experimentalHallVisAtt-andgt;SetForceWireframe(true)

Hidden Line Removal: 

Hidden Line Removal OpenGL supports hidden line removal. You can control whether this removal is done and whether trajectories and hits are affected by this feature. By default, hidden line removal is disabled To turn on hidden line removal /vis/viewer/set/hiddenEdge 1 This hides edges of geometry, but lets trajectories through. To hide trajectories and hits as well /vis/viewer/set/hiddenMarker 1

HepRep-Style Attributes: 

HepRep-Style Attributes HepRep-Style Attributes - carry arbitrary, user-defined information: Displayed when you click on the relevant object in certain visualiation systems: At present, these are only the HepRep browsers, WIRED and FRED. Eventually, there will be ways to use these attributes in other systems such as OpenInventor. for trajectories: momentum particle type etc. for hits: energy electronics channel number etc. for geometry volumes: logical volume name material etc. In addition to letting you click to view these attributes, WIRED lets you: label objects by any of these attributes cut visibility based on these attributes A basic set of such attributes is pre-defined for geometry and trajectories. You can assign additional attributes of your own through C++ code.

HepRep: 

HepRep /vis/open HepRepFile Features Create a file to view in the WIRED3 HepRep Browser WIRED4 JAS Plugin or FRED Event Display Wireframe or simple area fills (not photorealistic) Many interactive features zoom, rotate, translate click to show attributes (momentum, etc.) special projections (FishEye, etc.) control visibility from hierarchical (tree) view of data Hierarchical view of the geometry WIRED3 and WIRED4 can export to many vector graphic formats (PostScript, PDF, etc.) Supported by Joseph Perl and Mark Donszelmann

HepRep is Not Just for Geant4and Not Just for WIRED: 

HepRep is Not Just for Geant4 and Not Just for WIRED The HepRep interface breaks the dependency between any particular experiment's event display server and any particular event display client. The HepRep format is independent of any one particular language or protocol. It can be used from C++ or Java and can be shipped as Corba, RMI, XML, C++, Java or JNI for consumption by WIRED, FRED or any other HepRep-enabled event display client. HepRep WIRED3 Client (Java) Other HepRep Clients BaBar Server GLAST Gaudi Service Geant4 Server FRED Client (C++/Ruby)

Who’s Using HepRep: 

Who’s Using HepRep

WIRED3: Pick to Show Physics Attributes: 

WIRED3: Pick to Show Physics Attributes Picked on this volume to show Material Density Radlen etc Picked on this trajectory to show Particle ID Charge Momentum etc.

Slide14: 

WIRED3: Labeling by Any Attribute

Slide15: 

WIRED3: Cut by Any Attribute

Defining Your Own HepRep Attributes: 

Defining Your Own HepRep Attributes Define the attributes with lines such as: std::mapandlt;G4String,G4AttDefandgt;* store = G4AttDefStore::GetInstance('G4Trajectory',isNew); G4String PN('PN'); (*store)[PN] = G4AttDef(PN,'Particle Name','Physics','','G4String'); G4String IMom('IMom'); (*store)[IMom] = G4AttDef(IMom, 'Momentum of track at start of trajectory', 'Physics','','G4ThreeVector'); Then fill the attributes with lines such as: std::vectorandlt;G4AttValueandgt;* values = new std::vectorandlt;G4AttValueandgt;; values-andgt;push_back(G4AttValue('PN',ParticleName,'')); s.seekp(std::ios::beg); s andlt;andlt; G4BestUnit(initialMomentum,'Energy') andlt;andlt; std::ends; values-andgt;push_back(G4AttValue('IMom',c,'')); See geant4/source/tracking/src/G4Trajectory.cc for a good example.

Visualizing Trajectories: 

Visualizing Trajectories Trajectory are not visualized by default Possible to manipulate trajectory drawing through: Interactive commands /vis/scene/add/trajectories andlt;drawing-modeandgt; Draws trajectories using enhanced trajectory drawing model functionality Using enhanced trajectory drawing directly in compiled code Adding trajectory drawing in EndOfEventAction method Sub-classing G4VTrajectory and implementing DrawTrajectory method Rest of this talk will focus on enhanced trajectory drawing Intended to superceed other two methods mentioned above Hopefully meets most peoples needs

Obsolete Syntax for Trajectory Points: 

Obsolete Syntax for Trajectory Points An additional argument after /vis/scene/add/trajectories allows you to specify whether the trajectory should be shown as: trajectory line (default) trajectory points or both Specify this via: /vis/scene/add/trajectories /vis/scene/add/trajectories 4000 /vis/scene/add/trajectories -4000 This last parameter, called imode, combined both whether the points should be shown positive for show them negative for show them and omit the line and what size the points should be rendered number of pixels times 1000 (please don’t ask what the 1000 is about) We mention this here because you may see it in some older examples and user code, but we’ve replaced it with something much more flexible…

Trajectory Points: 

Trajectory Points /vis/scene/add/trajectories /vis/scene/add/trajectories 4000 /vis/scene/add/trajectories -4000

Enhanced Trajectory Drawing: 

Enhanced Trajectory Drawing First released in Geant4 v8.0 Goes way beyond just being able to decide whether or not to include step points And eliminates the most common reason users had implemented their own trajectory classes, which was to change the trajectory coloring scheme Introduces concept of a trajectory model: Represents a particular style of drawing trajectories Possible to have a whole range of models, for example Color trajectories according to charge Color trajectories according to particle type Enhanced trajectory drawing supports Use and configuration of models supplied with Geant4 distribution Interactive and compile time model configuration User defined models Flexible and extensible

Models Supplied with Geant4: 

Models Supplied with Geant4 Three models are supplied with Geant4 v8.1 release More are being developed for future releases drawByCharge Default model Colors trajectories according to charge drawByParticleID Colors trajectories according to particle type All trajectories are colored grey by default Configure to highlight chosen particle types with chosen colors No limit on the number of particle types that can be highlighted drawByOriginVolume Colors trajectories according to volume in which they originated Useful, for example, to highlight all particles that backscattered from a particular collimator

Trajectory Modeling Example: 

Trajectory Modeling Example Example macro #Standard setup /vis/scene/create /vis/open OGLIX /vis/scene/add/volume /vis/scene/add/trajectories /vis/scene/add/hits /vis/viewer/set/lightsThetaPhi 90. 0. /vis/viewer/set/viewpointThetaPhi 150. 90. /vis/viewer/set/style surface /vis/viewer/set/hiddenEdge true #Create drawByParticleID model, highlighting photons /vis/modeling/trajectories/create/drawByParticleID /vis/modeling/trajectories/drawByParticleID-0/set gamma red /run/beamOn 1 …

Model Configuration: 

Model Configuration You can create and configure multiple models through either Interactive commands Compiled code Interactive commands Located in /vis/modeling/trajectories directory Possible to have multiple instances of given model type e.g., toggle between two different ways of coloring by charge List and select instantiated models with commands: /vis/modeling/trajectories/list /vis/modeling/trajectories/select andlt;model-instance-nameandgt; Note that detailed help for a given model is not shown in the help system until you have created an instance of that model e.g., only after you do your first: /vis/modeling/trajectories/create/drawByCharge will the help system will include details on drawByCharge

Example: Toggling Between Two Charge Coloring Models: 

Example: Toggling Between Two Charge Coloring Models #Create a drawByCharge model named drawCharge-0 by #default. Subsequent models will be named drawByCharge-1… /vis/modeling/trajectories/create/drawByCharge

Example: Controlling Model from Compiled Code: 

Example: Controlling Model from Compiled Code Instantiate model Configure model Register with visualization manager

User Defined Models: 

User Defined Models You can define your own model if you wish New trajectory models must inherit from G4VTrajectoryModel and implement these pure virtual methods: virtual void Draw(const G4VTrajectoryandamp;, G4int i_mode = 0) const = 0; virtual void Print(std::ostreamandamp; ostr) const = 0; New models can be used directly in compiled code Need to be registered with visualization manager

To Make User Defined Model Available from Interactive Commands: 

To Make User Defined Model Available from Interactive Commands You will need to write Messenger classes Messengers to configure the model should inherit from G4VModelCommand. The concrete trajectory model type should be used for the template parameter and a Factory class A factory class responsible for the model and associated messenger creation must also be written. The factory should inherit from G4VModelFactory. The abstract model type should be used for the template parameter, eg: G4ModelCommandDrawByParticleIDSet.cc class G4ModelCommandDrawByParticleIDSet : public : G4VModelCommandandlt;G4TrajectoryDrawByParticleIDandgt; { ... }; G4TrajectoryDrawByChargeFactory.cc class G4TrajectoryDrawByChargeFactory : public G4VModelFactoryandlt;G4VTrajectoryModelandgt; { ... };

Construct the Model and Associated Messengers: 

Construct the Model and Associated Messengers

So How do You Control Whether to Show Step Points?: 

So How do You Control Whether to Show Step Points? In the discussion of Models up to now, we’ve only shown you how to set the color, but a model can include many more options: 1) setDrawLine * Set draw line command 2) setLineVisible * Set line visibility command 3) setLineColour * Set colour through a string 4) setLineColourRGBA * Set colour through red, green, blue and alpha components 5) setDrawStepPts * Set draw step points command 6) setStepPtsVisible * Set step points colour command 7) setStepPtsColour * Set colour through a string 8) setStepPtsColourRGBA * Set colour through red, green, blue and alpha components 9) setStepPtsSize * Set step points colour command 10) setStepPtsType * Set step points type. 11) setStepPtsFillStyle * Set step fill style type. 12) setDrawAuxPts * Set draw auxiliary points command 13) setAuxPtsVisible * Set auxiliary points visibility command 14) setAuxPtsColour * Set colour through a string 15) setAuxPtsColourRGBA * Set colour through red, green, blue and alpha components 16) setAuxPtsSize * Set auxiliary points size command 17) setAuxPtsType * Set auxiliary points type. 18) setAuxPtsFillStyle * Set auxiliary fill style.

Example using Variety of Modeling Commands: 

Example using Variety of Modeling Commands /vis/modeling/trajectories/create/generic /vis/modeling/trajectories/generic-0/default/setLineColour blue /vis/modeling/trajectories/generic-0/default/setDrawLine false /vis/modeling/trajectories/generic-0/default/setDrawAuxPts true /vis/modeling/trajectories/generic-0/default/setDrawStepPts true /vis/modeling/trajectories/generic-0/default/setStepPtsSize 5 /vis/modeling/trajectories/generic-0/default/setAuxPtsSize 5 /vis/modeling/trajectories/generic-0/default/setAuxPtsColour yellow /vis/modeling/trajectories/generic-0/default/setStepPtsColour red /vis/modeling/trajectories/generic-0/default/setStepPtsColour red /vis/modeling/trajectories/generic-0/default/setStepPtsType circles /vis/modeling/trajectories/create/drawByCharge /vis/modeling/trajectories/drawByCharge-0/verbose true /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 5

Trajectory Filtering: 

Trajectory Filtering In addition to being able to control how trajectories are drawn, you can also control Whether a given trajectory is drawn chargeFilter Filters trajectories according to charge particleFilter Filters trajectories according to particle type originVolumeFilter Filters trajectories according to volume in which they originated For example: /vis/filtering/trajectories/create/particleFilter /vis/filtering/trajectories/particleFilter-0/add e- will cause everything except electrons to be filtered out See the help system for details.

Coming in the December 2006 Release: 

Coming in the December 2006 Release You will be able to model or filter trajectories or hits based on ANY HepRep Attribute Color based on particle momentum Filter hits based on energy etc.

G4SmoothTrajectory: 

G4SmoothTrajectory In the standard trajectory class, G4Trajectory, a point is generated for each position that something physical happens Interaction Decay Boundary Crossing Step This can result in jagged-looking trajectories. An alternate trajectory class, G4SmoothTrajectory, generates additional points just to make the drawing smoother. Warning: G4SmoothTrajectory is not yet reliable (sometimes even crashes). Only use it if you feel you need smooth drawings for special circumstances. Otherwise, just use G4Trajectory.

How to Use G4SmoothTrajectory: 

How to Use G4SmoothTrajectory Make your example include a TrackingAction by modifying your main class so that right after you set the RunAction: runManager-andgt;SetUserAction(new MyExampleRunAction); you Set a TrackingAction: runManager-andgt;SetUserAction(new MyExampleTrackingAction); Then, in the TrackingAction class, set the trajectory class to G4SmoothTrajectory: #include 'G4SmoothTrajectory.hh' #include 'G4TrackingManager.hh' void MyExampleTrackingAction::PreUserTrackingAction(const G4Track* aTrack) { fpTrackingManager-andgt;SetTrajectory(new G4SmoothTrajectory(aTrack)); }

G4RichTrajectory: 

G4RichTrajectory In the standard trajectory class, G4Trajectory, the only HepRep attributes assigned to a point are the point position. If you want to study a few trajectories in more detail, you can replace your G4Trajectory with G4RichTrajectory (see next slide for exactly how to do this). Each point will then have additional HepRep attributes that you can view by clicking on the point in WIRED, telling you: Total energy deposited at this point Position (x,y,z) Why was this point generated Interaction Decay Boundary Crossing Step

G4RichTrajectory: 

G4RichTrajectory

How to Use G4RichTrajectory: 

How to Use G4RichTrajectory Make your example include a TrackingAction by modifying your main class so that right after you set the RunAction: runManager-andgt;SetUserAction(new MyExampleRunAction); you Set a TrackingAction: runManager-andgt;SetUserAction(new MyExampleTrackingAction); Then, in the TrackingAction class, set the trajectory class to G4RichTrajectory: #include 'G4RichTrajectory.hh' #include 'G4TrackingManager.hh' void MyExampleTrackingAction::PreUserTrackingAction(const G4Track* aTrack) { fpTrackingManager-andgt;SetTrajectory(new G4RichTrajectory(aTrack)); }

Geant4 Visualization Resources: 

Geant4 Visualization Resources Geant4 Installation Guides http://geant4.slac.stanford.edu/installation Hands on WIRED3 Tutorial http://geant4.slac.stanford.edu/Presentations/vis/G4WIREDTutorial/G4WIREDTutorial.html Hands on DAWN Tutorial http://geant4.slac.stanford.edu/Presentations/vis/G4DAWNTutorial/G4DAWNTutorial.html Hands on OpenGL Tutorial http://geant4.slac.stanford.edu/Presentations/vis/G4OpenGLTutorial/G4OpenGLTutorial.html Geant4 Visualization Commands http://geant4.slac.stanford.edu/Presentations/vis/G4VisCommands.ppt (and .pdf) Geant4 Advanced Visualization http://geant4.slac.stanford.edu/Presentations/vis/G4VisAdvanced.ppt (and .pdf) On-line Documentation on Geant4 Visualization: http://geant4.web.cern.ch/geant4/G4UsersDocuments/UsersGuides/ForApplicationDeveloper/ html/Visualization List of Visualization Commands: http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/ html/Control/UIcommands/_vis_.html For Questions or Comments: Geant4 Visualization Online Forum: http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/visualization.html