#! /usr/bin/perl -w
# crms <.ccfc file>
#calculate rms value of a .ccfc theory file
# using only the non-zero count cells

$ccfc = $ARGV[0];
open (C, "<$ccfc");
$head = <C>;
@parm = split(' ',$head);
$skip = $parm[2] + $parm[3];
while ($skip > 0) {
  $line = <C>;
  $skip--;
}
$sqrs = 0;
$N = 0;
while ($line = <C>) {
  @data = split(' ',$line);
  if ($data[0]) {
    $sqrs += $data[1]*$data[1];
    $N++;
  }
}
$rms = sqrt($sqrs/$N);
print "$N points, rms $rms\n";
