# File: positionTimeFitH2O.mac
# Brief: Short macro showing how to run the position likelihood fitter
#        in a water geometry
#
# Date: 19-05-2014
# Contact: I Coulter, <icoulter@hep.upenn.edu>
# Revisions:
#       19-05-2014 I. Coulter <icoulter@hep.upenn.edu> Initial commit.
#
# This is a macro which shows how to run a position likelihood fitter in
# H2O. This uses the positionTimeLikelihood method, the gv1d PDF, which
# uses the the time-residuals of the PMT hits using the group velocity of
# the photons, the metaDriveCorrectSeed optimiser, which aims to correct
# for the drive due to Cerenkov light and the modeCut PMTselector, which
# selects only PMTs within 50ns of the mode hit time.
#

# Load a water geometry
/rat/db/set DETECTOR geo_file "geo/snoplus_water.geo"

/run/initialize

# BEGIN EVENT LOOP
/rat/proc frontend
/rat/proc trigger
/rat/proc eventbuilder
/rat/proc count
/rat/procset update 10
/rat/proc calibratePMT

# Requires a position seed
/rat/proc fitter
/rat/procset method "quad"

# Run the position likelihood fitter in H2O
/rat/proc fitter
/rat/procset method "positionTimeLikelihood"
/rat/procset optimiser "metaDriveCorrectSeed-powell"
/rat/procset pdf "gv1d"
/rat/procset seed "quad"
/rat/procset selector "modeCut"

/rat/proclast outroot
/rat/procset file "positionTimeFitH2O.root"
# END EVENTLOOP

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

/rat/run/start 10
exit