# File: pythonproc_hist.mac
# Brief: Macro showing how to use the Python processors (histogram specifically).
#
# Date: 2020-12-01
# Contact: M. Anderson, <anderson.mark@queensu.ca>
#
# This macro demostrates how to draw a histogram while a RAT job is running.
# Can specify the quantity to draw using public methods of the Entry class,
# and public methods of the return values of those.

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

/rat/db/set DETECTOR geo_file "geo/snoplusnative.geo"

/run/initialize

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

# Simple count processor (identical functionality to the C++ count processor).
/rat/proc python
/rat/procset class "ratproc.Count(interval=1)"

# Plot a histogram of the event count per entry.
/rat/proc python
/rat/procset class "ratproc.Hist('GetEVCount()', 3, 0, 3, interval=1)"

# Plot a histogram of the MC particle count, but only update once per five entries.
/rat/proc python
/rat/procset class "ratproc.Hist('GetMC().GetMCParticleCount()', 3, 0, 3, interval=5)"

# Plot a histogram of the MC hit PMT count.
/rat/proc python
/rat/procset class "ratproc.Hist('GetMC().GetMCPMTCount()', 50, 0, 10000, interval=1)"

# Use IO.default_output_filename
/rat/proclast outroot
#END EVENT LOOP

/generator/add combo gun2:fill:poisson
/generator/vtx/set e- 0.0 0.0 0.0 0 2.0 10.0
/generator/pos/set inner_av
/generator/rate/set 1

/rat/run/start 1000