#!/usr/bin/perl

use lib ("$ENV{GLUEX_PERL}");
use evgen;

$px = 0;
$py = 0;
$pz = 100;
$z0 = 170;
$type = "pi+";

$xmin = -50.; #cm
$xmax = 50.1; #cm
$ymin = -50.; #cm
$ymax = 50.1; #cm
$nstep = 10;
$xstep = ($xmax - $xmin)/($nstep - 1);
$ystep = ($ymax - $ymin)/($nstep - 1);

output_header();
for ($iy = 0; $iy < $nstep; $iy++) {
    $y0 = $ymin + $iy*$ystep;
    for ($ix = 0; $ix < $nstep; $ix++) {
	$x0 = $xmin + $ix*$xstep;
	generate_point();
    }
}
output_footer();

exit;

sub generate_point {
    $evno_max = 10;
    for ($evno = 1; $evno <= $evno_max; $evno++) {
	output_event_header();
	output_event($px, $py, $pz, $x0, $y0, $z0, $type);
	output_event_footer();
    }
}
