# File: energyRSP.mac
# Brief: Short macro showing how to run the energyRSP fitter
#
# Date: 28-09-2015
# Contact: J Walker, <john.walker@liverpool.ac.uk>
#
# This is a macro which shows how to run the energyRSP fitter.
# This method calculates the optical response of each PMT (taking 
# into account PMT efficiency, solid angle, Cerenkov angular
# distribution, transmission probability and attenuation) to estimate
# the number of Cerenkov photons from the prompt hits. A lookup table
# is used to map from Cerenkov photons to energy. This fitter is only
# for a detector geometry with light water in the inner av.

# Select the water filled snoplus geometry file
/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, time, direction and initial energy estimate seed.
# Use the water fitter.
/rat/proc waterFitter

/rat/proc fitter
/rat/procset method "energyRSP"
/rat/procset seed "waterFitter"

/rat/proclast outroot
/rat/procset file "energyRSP.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 100
exit