-
Buddhini Waidyawansa authored
This is a script created by Stephen Wood to convert engine type channel maps into hcana type mapfiles. Right now, this is only used when doing hcana and engine comparision for the raster.
Buddhini Waidyawansa authoredThis is a script created by Stephen Wood to convert engine type channel maps into hcana type mapfiles. Right now, this is only used when doing hcana and engine comparision for the raster.
mapedit_rasterbcm.pl 3.46 KiB
#!/usr/bin/perl
# Rewrite a Hall C style MAP file so that the Raster and BPM
# are separate detector types instead of being part of the
# MISC detector
#
# 08.04.2014 (saw) Modify just raster entries for now
use POSIX qw(strftime);
$RASTERID=18;
$BCMID=19;
$SWAPRASTERXY=1;
$thedate = strftime( '%b %e, %Y', localtime );
$ifile = $ARGV[0];
$ofile = $ARGV[1];
open(IFILE,"<$ifile");
open(OFILE,">$ofile");
print OFILE "! $ofile Automatically generated $thedate\n";
print OFILE "! from $ifile by $0\n";
# Insert comments defining the raster and BCM detector IDS
$ininiddefs=0;
while(<IFILE>) {
chomp;
$line = $_;
if($line=~/_ID/) {
$iniddefs=1;
} elsif ($iniddefs) {
if(not $line=~/_ID/ and not $line=~/:/) {
print OFILE "! RASTER_ID=$RASTERID ADC\n";
print OFILE "! BCM_ID=$RASTERID ADC\n";
print OFILE "$line\n";
last;
}
}
print OFILE "$line\n";
}
# Copy the rest of the file, looking for the specific channels to
# edit
$detector=0;
while(<IFILE>) {
chomp;
$line = $_;
if($line=~/^\s*DETECTOR=\s*(\d*)/i) {
$detector=$1;
print "$detector\n";
print OFILE "$line\n";
} elsif ($line=~/^\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*),\s*(\d*)\s*(.*)/) {
$comment = $5;
$channel = $1;
$plane = $2;
$element = $3;
$signal = $4;
if($comment=~"Fast Raster") {
$signal = -1;
if($comment=~"X-sync") {
$signal = 0;
} elsif ($comment=~"X-signal") {
$signal = 1;
} elsif ($comment=~"Y-sync") {
$signal = 2;
} elsif ($comment=~"Y-signal") {
$signal = 3;