Skip to content

Commit

Permalink
[fvsc] add dummyColor.sh to replace colors by dummy color 0 in events…
Browse files Browse the repository at this point in the history
  • Loading branch information
valassi committed Jun 19, 2022
1 parent b16fec8 commit 6225f0b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions epochX/cudacpp/tmad/dummyColor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Temmporary workaround for #402
# Replace event-by-event color information in <events.lhe.in> by a dummy color 0 in <events.lhe.out>
if [ "$1" == "$2" ] || [ "$2" == "" ] || [ "$3" != "" ]; then
echo "Usage: $0 <events.lhe.in> <events.lhe.out>"
exit 1
fi
infile=$1
outfile=$2

if [ ! -f ${infile} ]; then
echo "ERROR! File not found: ${infile}"
exit 1
fi

cat ${infile} | awk \
'BEGIN{line=1000; npar=0}
{if ($1=="<event>"){line=0; print $0}
else {line=line+1;
if (line==1){npar=$1; print $0}
else if (line<=1+npar){split("AAA"$0,a,FS,seps); # see https://stackoverflow.com/a/40456663 (add AAA to keep leading whitespaces)
a[6]=sprintf("%"length($5)"d",0); # 1st color is field 5 (but a[6] because of AAA)
a[7]=sprintf("%"length($6)"d",0); # 2nd color is field 6 (but a[7] because of AAA)
printf("%s",seps[1]); # print only leading whitespaces (not AAA)
for(i=2;i<=NF+1;i++) printf("%s%s",a[i],seps[i]); # NF+1 because of AAA
print ""} # print newline
else print $0}}' > ${outfile}

0 comments on commit 6225f0b

Please sign in to comment.