#!/usr/bin/perl
#
#
# Multiply exposure in the PHA file by dead time correction
#

@gov = split (/\//,$0); pop @gov; $BINDIR = join ('/',@gov);

# Read common PERL subs
require "$BINDIR/perlutil.pl";

# Check external packages
&check_ftools; &check_zhtools;


foreach $pha ( @ARGV ) {
  $dtcor = `printkey $pha DTCOR`;
  chomp $dtcor;
  if ( $dtcor ne "undefined" ) {
    $exposure = `printkey $pha\"[SPECTRUM]\" EXPOSURE`;
    chomp $exposure;
    if ($exposure eq "undefined") {
      warn "Exposure undefined in $pha\n";
      next;
    }
    print "$pha $exposure $dtcor \n";
    $exposure *= $dtcor;
    system ("fparkey $exposure $pha\"[SPECTRUM\"] EXPOSURE");
  }
}

