forked from madgraph5/madgraph4gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fvsc] add dummyColor.sh to replace colors by dummy color 0 in events…
….lhe madgraph5#402
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |