#! /bin/sh # This is the LHEA perl script: /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/pcpicor # The purpose of this special block is to make this script work with # the user's local perl, regardless of where that perl is installed. # The variable LHEAPERL is set by the initialization script to # point to the local perl installation. #------------------------------------------------------------------------------- eval ' if [ "x$LHEAPERL" = x ]; then echo "Please run standard LHEA initialization before attempting to run /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/pcpicor." exit 3 elif [ "$LHEAPERL" = noperl ]; then echo "During LHEA initialization, no acceptable version of Perl was found." echo "Cannot execute script /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/pcpicor." exit 3 elif [ `$LHEAPERL -v < /dev/null 2> /dev/null | grep -ic "perl"` -eq 0 ]; then echo "LHEAPERL variable does not point to a usable perl." exit 3 else # Force Perl into 32-bit mode (to match the binaries) if necessary: if [ "x$HD_BUILD_ARCH_32_BIT" = xyes ]; then if [ `$LHEAPERL -V 2> /dev/null | grep -ic "USE_64_BIT"` -ne 0 ]; then VERSIONER_PERL_PREFER_32_BIT=yes export VERSIONER_PERL_PREFER_32_BIT fi fi exec $LHEAPERL -x $0 ${1+"$@"} fi ' if(0); # Do not delete anything above this comment from an installed LHEA script! #------------------------------------------------------------------------------- #! /usr/local/bin/perl5 # # script to run pcsasscor, pctcor and pcecor # # Rehana Yusaf Feb 26 1996 # HEASARC NASA/GSFC/HSTX # # Banashree M. Seifert Sept 1996 2.0.0 # This task is rewritten # . runcom introduced # . option for caldb or not introduced # . ^C catch # . online help when pcpicor -h is typed # # Banashree M. Seifert Aug 1997 2.1.0 # . pctcor uses 13 caldb files instead of 8 which was before. # # Banashree M. Seifert Sep 1997 2.2.0 # . pcecor uses a new parameter calflag for user option to use # ground or inflight callibration. # Ning Gan Dec 1999 2.2.1 # . copy the event file to pcsass.out before run pcsasscor. # use Getopt::Std; require "utils.pl"; use Config; use File::Copy; #print "$Config{'sig_name'}"; $task='PCPICOR'; $version_number='2.2.1'; # ---------- start up ----------------------------------- print " \n"; print " *** ".$task." Ver ".$version_number." ***\n\n"; # ---------------------------------------------------------- # # Output the help if -h is specified # getopts('hv:'); if (defined $opt_h) { print <); if($evt_fil =~ /^$/){ print ".... file not entered. Try again......\n"; print "Please enter events filename[ext#] : "; chop($evt_fil = ); if($evt_fil =~ /^$/){ die ".... Input file name must be entered. Exiting ...\n"; } } die "file \"$evt_fil\" doesn't exist. Exiting \n" if(!-e $evt_fil); #----------------------- CALDB enquiry ------------------------ print "Do you want to use default CALDB calibration files?[y/n] :"; chop($qdefault=); #-------------------- output filename ------------------ print "Please enter output filename:"; chop($out_fil = ); unlink $out_fil if(-e $out_fil); # ------------------- running the trio #if PCSASSCOR to run if ($pcsass) { if($qdefault=~ /^n/i){ print "Energy dependent correction filename:"; chop($end_ep = ); die "... file name should be entered! ..Exiting \n" if($end_ep =~ /^$/); die "file $end_ep doesn't exist. Exiting \n" if(!-e $end_ep); print "Golden disk filename:"; chop($y_map = ); die "... file name should be entered! ..Exiting \n" if($y_map =~ /^$/); die "file $y_map doesn't exist. Exiting \n" if(!-e $y_map); print "ADC binfile name:"; chop($adc = ); die "... file name should be entered! ..Exiting \n" if($adc =~ /^$/); die "file $adc doesn't exist. Exiting \n" if(!-e $adc); print "E-dep spatial gain correction filename:"; chop($spg = ); die "... file name should be entered! ..Exiting \n" if($spg =~ /^$/); die "file $spg doesn't exist. Exiting \n" if(!-e $spg); print "Pos-dep spatial gain correction file:"; chop($spgk = ); die "... file name should be entered! ..Exiting \n" if($spgk =~ /^$/); die "file $spgk doesn't exist. Exiting \n" if(!-e $spgk); print "Alk history file:"; chop($alk = ); die "... file name should be entered! ..Exiting \n" if($alk =~ /^$/); die "file $alk doesn't exist. Exiting \n" if(!-e $alk); if($verbose >= 10) { $string = " ----------------------------------------------------- Running PCSASSCOR Input event file : $evt_fil Energy dep. correction file : $end_ep Golden disk file : $y_map ADC binfile : $adc E-dep spatial gain correction file : $spg Pos-dep spatial gain correction file: $spgk Alk history file : $alk -----------------------------------------------------\n"; print "\n $string\n"; } }else{ $end_ep = 'caldb'; $y_map = 'caldb'; $adc = 'caldb'; $spg = 'caldb'; $spgk = 'caldb'; $alk = 'caldb'; } if ((!($pct)) && (!($pce))) { $command_string='pcsasscor infile='.$evt_fil.' outfile='.$out_fil.' endepfile='.$end_ep.' ymapfile='.$y_map.' adcfile='.$adc.' spgfile='.$spg.' spgkfile='.$spgk.' alkfile='.$alk.' chatter='.$verbose; }else{ copy ( $evt_fil, "pcsass.out" ); $command_string='pcsasscor infile='.$evt_fil.' outfile=!pcsass.out endepfile='.$end_ep.' ymapfile='.$y_map.' adcfile='.$adc.' spgfile='.$spg.' spgkfile='.$spgk.' alkfile='.$alk.' chatter='.$verbose; } $prog_name='PCSASSCOR'; print "\n ...running $prog_name \n"; @tmp_array=&runcom($command_string,"error","runtime error"); print " ...... done \n\n"; } #if PCTCOR to run if ($pct) { print " ......... going for PCTCOR\n"; if($qdefault=~ /^n/i){ print "1st Al K alpha calibration file (for pctcor):"; chop($alkmap1 = ); die "file $alkmap1 doesn't exist. Exiting \n" if(!-e $alkmap1); print "2nd Al K alpha calibration file:"; chop($alkmap2 = ); die "file $alkmap2 doesn't exist. Exiting \n" if(!-e $alkmap2); print "3rd Al K alpha calibration file:"; chop($alkmap3 = ); die "file $alkmap3 doesn't exist. Exiting \n" if(!-e $alkmap3); print "4th Al K alpha calibration file:"; chop($alkmap4 = ); die "file $alkmap4 doesn't exist. Exiting \n" if(!-e $alkmap4); print "5th Al K alpha calibration file:"; chop($alkmap5 = ); die "file $alkmap5 doesn't exist. Exiting \n" if(!-e $alkmap5); print "6th Al K alpha calibration file:"; chop($alkmap6 = ); die "file $alkmap6 doesn't exist. Exiting \n" if(!-e $alkmap6); print "7th Al K alpha calibration file:"; chop($alkmap7 = ); die "file $alkmap7 doesn't exist. Exiting \n" if(!-e $alkmap7); print "8th Al K alpha calibration file:"; chop($alkmap8 = ); die "file $alkmap8 doesn't exist. Exiting \n" if(!-e $alkmap8); print "9th Al K alpha calibration file:"; chop($alkmap9 = ); die "file $alkmap9 doesn't exist. Exiting \n" if(!-e $alkmap9); print "10th Al K alpha calibration file:"; chop($alkmap10 = ); die "file $alkmap10 doesn't exist. Exiting \n" if(!-e $alkmap10); print "11th Al K alpha calibration file:"; chop($alkmap11 = ); die "file $alkmap11 doesn't exist. Exiting \n" if(!-e $alkmap11); print "12th Al K alpha calibration file:"; chop($alkmap12 = ); die "file $alkmap12 doesn't exist. Exiting \n" if(!-e $alkmap12); print "13th Al K alpha calibration file:"; chop($alkmap13 = ); die "file $alkmap8 doesn't exist. Exiting \n" if(!-e $alkmap13); if($verbose >= 10) { $string = " ----------------------------------------------------- Running PCTCOR Al K calibration files are : 1) $alkmap1 2) $alkmap2 3) $alkmap3 4) $alkmap4 5) $alkmap5 6) $alkmap6 7) $alkmap7 8) $alkmap8 9) $alkmap9 10) $alkmap10 11) $alkmap11 12) $alkmap12 13) $alkmap13 -----------------------------------------------------\n"; print "\n $string\n"; } }else{ $alkmap1 = 'caldb'; $alkmap2 = 'caldb'; $alkmap3 = 'caldb'; $alkmap4 = 'caldb'; $alkmap5 = 'caldb'; $alkmap6 = 'caldb'; $alkmap7 = 'caldb'; $alkmap8 = 'caldb'; $alkmap9 = 'caldb'; $alkmap10 = 'caldb'; $alkmap11 = 'caldb'; $alkmap12 = 'caldb'; $alkmap13 = 'caldb'; } if (!($pce)) { if ($pcsass) { $command_string='pctcor infile=pcsass.out alkfile1='.$alkmap1.' alkfile2='.$alkmap2.' alkfile3='.$alkmap3.' alkfile4='.$alkmap4.' alkfile5='.$alkmap5.' alkfile6='.$alkmap6.' alkfile7='.$alkmap7.' alkfile8='.$alkmap8.' alkfile9='.$alkmap9.' alkfile10='.$alkmap10.' alkfile11='.$alkmap11.' alkfile12='.$alkmap12.' alkfile13='.$alkmap13.' chatter='.$verbose.' outfile='.$out_fil; }else{ $command_string='pctcor infile='.$evt_fil.' alkfile1='.$alkmap1.' alkfile2='.$alkmap2.' alkfile3='.$alkmap3.' alkfile4='.$alkmap4.' alkfile5='.$alkmap5.' alkfile6='.$alkmap6.' alkfile7='.$alkmap7.' alkfile8='.$alkmap8.' alkfile9='.$alkmap9.' alkfile10='.$alkmap10.' alkfile11='.$alkmap11.' alkfile12='.$alkmap12.' alkfile13='.$alkmap13.' chatter='.$verbose.' outfile='.$out_fil; } }else{ if ($pcsass) { $command_string='pctcor infile=pcsass.out alkfile1='.$alkmap1.' alkfile2='.$alkmap2.' alkfile3='.$alkmap3.' alkfile4='.$alkmap4.' alkfile5='.$alkmap5.' alkfile6='.$alkmap6.' alkfile7='.$alkmap7.' alkfile8='.$alkmap8.' alkfile9='.$alkmap9.' alkfile10='.$alkmap10.' alkfile11='.$alkmap11.' alkfile12='.$alkmap12.' alkfile13='.$alkmap13.' chatter='.$verbose.' outfile=!pctcor.out'; }else{ $command_string='pctcor infile='.$evt_fil.' alkfile1='.$alkmap1.' alkfile2='.$alkmap2.' alkfile3='.$alkmap3.' alkfile4='.$alkmap4.' alkfile5='.$alkmap5.' alkfile6='.$alkmap6.' alkfile7='.$alkmap7.' alkfile8='.$alkmap8.' alkfile9='.$alkmap9.' alkfile10='.$alkmap10.' alkfile11='.$alkmap11.' alkfile12='.$alkmap12.' alkfile13='.$alkmap13.' chatter='.$verbose.' outfile=!pctcor.out'; } } $prog_name='PCTCOR'; print "\n ...running $prog_name \n"; @tmp_array=&runcom($command_string,"error","runtime error"); print " ...... done \n\n"; } #if PCECOR to run if ($pce) { print " ......... going for PCECOR\n"; #-------------------- calflag to use ------------------ # calflag = 1 --> ground callibration # calflag = 2 --> inflight callibration print "Which correction algorithm to be used [grnd=1/inflight=2]?:"; chop($calflg = ); if ($pct) { if(! ($pcsass)){ if($qdefault=~ /^n/i){ print "Alk history filename:"; chop($alk = ); die "file $alk doesn't exist. Exiting \n" if(!-e $alk); }else{ $alk = 'caldb'; } } $command_string='pcecor infile=pctcor.out outfile='.$out_fil.' alkfile='.$alk.' calflag='.$calflg.' chatter='.$verbose; }else{ if($pcsass){ $command_string='pcecor infile=pcsass.out outfile='.$out_fil.' alkfile='.$alk.' calflag='.$calflg.' chatter='.$verbose; }else{ if($qdefault=~ /^n/i){ print "Alk history filename:"; chop($alk = ); die "file $alk doesn't exist. Exiting \n" if(!-e $alk); if($verbose >= 10) { $string = " ----------------------------------------------------- Running PCECOR Event file : $evt_fil Al K history file : $alk -----------------------------------------------------\n"; print "\n $string\n"; } }else{ $alk = 'caldb'; } $command_string='pcecor infile='.$evt_fil.' outfile='.$out_fil.' alkfile='.$alk.' calflag='.$calflg.' chatter='.$verbose; } } $prog_name='PCECOR'; print "\n ...running $prog_name \n"; @tmp_array=&runcom($command_string,"error","runtime error"); print " ...... done \n\n"; } print "*** Successfully done PCPICOR \n"; #cleanup intermediate files created if(-e 'pcsass.out'){ $string = " Following files are created by this task:\n"; print "$string"; $string = "-----------------------------------------------------\n"; print "$string"; $string = " from running pcsasscor = pcsass.out\n"; print "$string"; if(-e 'pctcor.out'){ $string = " from running pctcor = pctcor.out\n"; print "$string"; $string= "-----------------------------------------------------\n"; print "$string\n"; print "Do you want to delete all intermediate files created?[yes]:"; chop ($qdelete=); if ($qdelete=~ /n/i){ print "Files are not deleted. ...Exiting\n"; }else{ unlink 'pcsass.out'; unlink 'pctcor.out'; print "Files deleted. ...Exiting\n"; } }else{ $string= "-----------------------------------------------------\n"; print "$string\n"; print "Do you want to delete all intermediate files created?[yes]:"; chop ($qdelete=); if ($qdelete=~ /n/i){ print "Files are not deleted. ...Exiting\n"; }else{ unlink 'pcsass.out'; print "Files deleted. ...Exiting\n"; } } }else{ if(-e 'pctcor.out'){ $string = " Following files are created by this task:\n"; print "$string"; $string = "-----------------------------------------------------\n"; print "$string"; $string = " from running pctcor = pctcor.out\n"; print "$string"; $string= "-----------------------------------------------------\n"; print "$string"; print "Do you want to delete all intermediate files created?[yes]:"; chop ($qdelete=); if ($qdelete=~ /n/i){ print "Files are not deleted. ...Exiting\n"; }else{ unlink 'pctcor.out'; print "Files deleted. ...Exiting\n"; } } } $SIG{'INT'}='DEFAULT'; #-------------------------------------------------------------------- # subroutine for erroring out while running runcom #-------------------------------------------------------------------- sub error { # This routine is called when an error occurs in RUNCOM. local ($err_str) = $_[0]; print "@tmp_array\n"; die ("\n$prog_name: $err_str\nExiting $task Ver $version_number\n"); } #-------------------------------------------------------------------- # subroutine for terminating when ^C is pressed #-------------------------------------------------------------------- sub handler{ local($sig)=@_; while(glob("/tmp/er*")) { unlink $_; # print "Temporary File= $_ deleted \n"; } while(glob("/tmp/E*")) { unlink $_; # print "Temporary File= $_ deleted \n"; } while(glob("/tmp/R*")) { unlink $_; # print "Temporary File= $_ deleted \n"; } print "\n\n..... Terminating $task V$version_number ......\n\n "; exit(1); }