# File: simpleEnergy.mac
# Brief: Short macro showing how to run the simpleEnergy fitter
#
# Date: 19-05-2014
# Contact: P G Jones, <p.g.jones@qmul.ac.uk>
# Revisions:
#       19-05-2014 I. Coulter <icoulter@hep.upenn.edu> Initial commit.
#
# This is a macro which shows how to run the simpleEnergy fitter.
# This is very simple fitter, converting from nhits to energy using a
# single value constant found in FIT_SIMPLE_ENERGY.ratdb
#

# Can overwrite ratdb to set conversion factor at 500 nhits per MeV
/rat/db/set FIT_SIMPLE_ENERGY nhit_per_mev 500.0d

# Note: ratdb file also contains intercept and gradient.
# Don't seem to be used?
# Warning: Values don't look up to date. Don't trust.

/run/initialize

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

# Run the simpleEnergy fitter
/rat/proc fitter
/rat/procset method "simpleEnergy"

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

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

/rat/run/start 10
exit