# File: BiPoTimeResidual.mac
# Brief: Short macro showing how to run the BiPoCumulTimeResid Classifier
#
# Date: 19-05-2014
# Contact: K Majumdar, <Krishanu.Majumdar@physics.ox.ac.uk>
# Revisions:
#       19-05-2014 I. Coulter <icoulter@hep.upenn.edu> Initial commit.
#       11-05-2015 M. Mottram <m.mottram@qmul.ac.uk> Modified syntax to invoke classifier.
#
# This is macro showing the commands need to run the cumulative time
# residuals based BiPo classifier. It uses the normalised cumulative
# time residuals distribution to classify events as either pileip BiPo
# coincidence events or 130Te 0vBB events The classifier returns the
# gamma value resulting from a KS test between the 130Te and BiPo
# events distributions.
#

# The range of the time residual distribution is defined in the
# CLASSIFIER_BIPO_CUMULTIMERESID_xxx.ratdb files.
# It can be overwritten by the user using the commands:
/rat/db/set CLASSIFIER_BIPO_CUMULTIMERESID[te_0p3_labppo_scintillator_bisMSB_Dec2013] min_time_residual -250.0
/rat/db/set CLASSIFIER_BIPO_CUMULTIMERESID[te_0p3_labppo_scintillator_bisMSB_Dec2013] max_time_residual 250.0

/run/initialize

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

# BiPoClassifierTimeResid requires a position+time seed.
/rat/proc fitter
/rat/procset method "quad"

# Now run the classifier.
# Requires a PDF as found in one of the CLASSIFIER_BIPO_CUMULTIMERESID_xxx.ratdb files

# Run the classifier in default mode
# This will run the classifier using PDFs for the inner AV material
/rat/proc classifier
/rat/procset classifier "BiPoCumulTimeResid"
/rat/procset seed "quad"

# Run the classifier again, using a specified material
# Also set a name (otherwise, both classifiers have the same name and only one is stored)
/rat/proc classifier
/rat/procset classifier "BiPoCumulTimeResid-te_0p3_labppo_scintillator_bisMSB_Dec2013"
/rat/procset seed "quad"
/rat/procset name "BiPoCumulTimeResidTe"

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