/*******************************************************************************
* Instrument: Unittest_JUMP_ITERATE
*
* %I
* Written by: Peter Willendrup
* Date: Oct 28th, 2021
* Origin: DTU
* %INSTRUMENT_SITE: Tests_grammar
*
* JUMP ITERATE unittest
*
* %D
* JUMP ITERATE unittest
*
* The instrument uses JUMP ITERATE to let each particle make n='jumps' returns
* to the monitor. The particles have unit weight and hence the intensity scales
* with the simulated statistics. (Use input parameter Ncount for setting the stats).
* 
* %Example: Ncount=1000 jumps=10 Detector: PSD_I=10000
* %Example: Ncount=1000 jumps=20 Detector: PSD_I=20000
* %Example: Ncount=100000 jumps=10 Detector: PSD_I=1e6
*
* %P
* Ncount: [1] Specify statistics
* jumps:  [1] Number of jumps
*
* %L
* <reference/HTML link>
*
* %E
*******************************************************************************/
DEFINE INSTRUMENT Unittest_JUMP_ITERATE(Ncount=1000, int jumps=10)

DECLARE
%{
%}

INITIALIZE
%{
  mcset_ncount(Ncount);
%}

TRACE

COMPONENT Arm = Arm()
  AT (0,0,0) ABSOLUTE
EXTEND %{
  // position x in one of 100 bins
  x = rand01()-0.5;
  y = rand01()-0.5;
  p = 1;
  vz=1000;
%}

COMPONENT Return = Arm()
  AT (0,0,0) ABSOLUTE  

COMPONENT PSD = PSD_monitor(xwidth=2.0, yheight=2.0, filename="rngout", nx=100, ny=100)
  AT (0,0,0.1) ABSOLUTE

COMPONENT Jmp = Arm()
  AT (0,0,0.1) ABSOLUTE
JUMP Return ITERATE jumps
  
FINALLY
%{
%}

END
