# File: frontend.mac
# Brief: Macro for simulating the frontend electronics in RAT
#
# Date: 2014-12-19
# Contact: I Coulter, <icoulter@hep.upenn.edu>
# Revisions:
#
# This macro shows options that can be used to control the simulation of
# the frontend processor.
# This includes the ability to choose to simulate either square PMT pulses or
# with a realistic pulse shape.


# By default, this simulation uses square PMT pulse shapes.
# For realistic pulse shapes, uncomment the lines:
#/rat/db/set DAQ pulse_type 1
#/rat/db/set DAQ pulse_width 0.22

# The realistic pulses bring an approx 9ns delay compared to square pulses
# so this would need to be allowed for on the ExtAsync trigger delay if needed
# This will also add a time-walk due to the fixed discriminator threshold.

/run/initialize

# BEGIN EVENT LOOP
/rat/proc frontend
/rat/proc trigger
/rat/proc eventbuilder
/rat/proc calibratePMT

/rat/proc count
/rat/procset update 10
/rat/proclast outroot
/rat/procset file "frontend.root"
# END EVENTLOOP

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

/rat/run/start 10
exit