#
#	Example Macro for visualising the simulated geometry
#   various viewers are available (may require installation of other software on your machine)
#   However, all have different problems. This macro is designed to output .heprep files that 
#   can be viewed with the HepRApp software that can be downloaded here: 
#   http://geant4.slac.stanford.edu/Presentations/vis/G4HepRAppTutorial/G4HepRAppTutorial.html 
#   
#
#				visualize.mac
#	Date:		26/8/2015
#	contact:	T. Kaptanoglu, Penn
#

/rat/physics_list/OmitMuonicProcesses true
/rat/physics_list/OmitHadronicProcesses true

# Use the simple geo for speed up viewing 
/rat/db/set DETECTOR geo_file "geo/snoplus_simple.geo"
# Adjust geometry settings here before initialisation
# disable the PMT geometry for speed of viewing
/rat/db/set GEO[innerPMT] enable 0
# make the PSUP invisible
/rat/db/set GEO[psup] invisible 1
# there are so many scintillator photons its very slow to view so use water instead
/rat/db/set GEO[inner_av] material "internalwater_snoplus"

/rat/tracking/store full 

/run/initialize

# Use the HepRApp viewer 
/vis/open HepRepFile
#/vis/open DAWNFILE
#/vis/open VRML2FILE
#/vis/open OGLIX
/vis/heprep/setFileName example_vis 
/vis/scene/create
/vis/scene/add/volume
/vis/sceneHandler/attach
/vis/viewer/set/upVector 0.0 0.0 1.0
/vis/viewer/set/viewpointThetaPhi -90 90
/vis/viewer/set/lightsThetaPhi 90 0
/vis/viewer/set/style s
/vis/scene/add/trajectories
/vis/scene/add/hits
/vis/modeling/trajectories/create/drawByParticleID
/vis/modeling/trajectories/drawByParticleID-0/set opticalphoton blue
/vis/modeling/trajectories/drawByParticleID-0/set e- red 
# view before simulating any events
/vis/viewer/flush

# BEGIN EVENT LOOP
# turn off processors -- not needed for visualization 
# /rat/proc simpledaq
/rat/proc count
/rat/procset update 1
# /rat/proc calibratePMT
# /rat/proc fitter
# /rat/procset method "centroid"
# /rat/proclast outroot
# /rat/procset file "visualize.root"
# END EVENT LOOP

/generator/add combo gun:point
/generator/vtx/set e- 0 0 0 1
/generator/pos/set 0 0 0
/generator/rate/set 1

/rat/run/start 1
exit