File indexing completed on 2025-08-03 08:22:09
0001
0002
0003 use strict;
0004 use warnings;
0005 use Getopt::Long;
0006
0007 if ($#ARGV < 0)
0008 {
0009 print "extracts theta/phi/x0/lambda0 output from G4 matscan cmd from logfile\n";
0010 print "usage matscan_digest.pl <logfile>\n";
0011 print "--outputfile data file name ";
0012 exit(-1);
0013 }
0014 if (! -f $ARGV[0])
0015 {
0016 die "could not locate $ARGV[0]\n";
0017 }
0018 my $outputfile='matscan.dat';
0019 GetOptions('outputfile=s' => \$outputfile);
0020
0021 open(F,"$ARGV[0]");
0022 open(F1,">$outputfile");
0023 my $foundthetaphi = 0;
0024 my $skip =0;
0025 while(my $line = <F>)
0026 {
0027 chomp $line;
0028
0029 if ($line =~ /Theta/ && $line =~ /Phi/ && $line =~ /lambda0/)
0030 {
0031 $foundthetaphi = 1;
0032 $skip = 0;
0033 next;
0034 }
0035 if ($line =~ /ave/)
0036 {
0037 $foundthetaphi = 0;
0038 next;
0039 }
0040 if ($line =~ /All done/)
0041 {
0042 last;
0043 }
0044 if ($foundthetaphi == 1)
0045 {
0046 if ($skip == 0)
0047 {
0048 my @sp1 = split(/ /,$line);
0049
0050
0051 if ($#sp1 < 3)
0052 {
0053 next;
0054 }
0055 }
0056 $line =~ s/\s+/ /g;
0057 print F1 "$line\n";
0058
0059 $skip = 0;
0060 }
0061 }
0062
0063 close(F);
0064 close(F1);