~maddevelopers/mg5amcnlo/2.9.4

« back to all changes in this revision

Viewing changes to Template/NLO/bin/internal/gen_jpeg-pl

pass to v2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
#---------------------------------------------------------------------
 
4
# Run GS to create jpeg files defined as $gs
 
5
#---------------------------------------------------------------------
 
6
system("/bin/bash -c \"rm -f matrix*.jpg born.jpg V*/loop_matrix.jpg\" ");
 
7
 
 
8
$imatrix = "";
 
9
if (! -e "matrix.ps") {$imatrix = 1;}
 
10
$max_jpg = 2;
 
11
if ($imatrix eq "") {$max_jpg = 5;}
 
12
# add 1 to max_jpg, to get max_jpg pages
 
13
$max_jpg += 1;
 
14
open(PAGE,"> diagrams.html") || die "Error creating diagrams.html";
 
15
print PAGE "\<HTML\> \n";
 
16
print PAGE "\<HEAD\> \n";
 
17
print PAGE "\<TITLE\>Feynman Diagrams \<\/TITLE\> \n";
 
18
print PAGE "\<\/HEAD\> \n";
 
19
print PAGE "\<BODY\> \n";
 
20
while ( -e "matrix_$imatrix.ps"){
 
21
  open(IN, "< matrix_$imatrix.ps") || die "No file matrix_$imatrix.ps";
 
22
  open(OUT, "> matrix-1.ps") || die "Could not open file matrix-1.ps";
 
23
  while (<IN>) {
 
24
    if ($_ =~ m/^%%Page: $max_jpg $max_jpg/) {last;}
 
25
    else {print OUT $_, "\n";}
 
26
  }
 
27
  close(OUT);
 
28
  close(IN);
 
29
  system "/bin/bash -c \"nice gs  \-sDEVICE\=jpeg \-sOutputFile\=matrix_$imatrix\%00d.jpg \-q \-dNOPAUSE \-dBATCH matrix-1.ps\"";
 
30
  system "rm -f matrix-1.ps";
 
31
 
 
32
# Determine how many jpg files we have
 
33
  $pages=1;
 
34
 
 
35
  while(-e "matrix_$imatrix$pages.jpg"){
 
36
    $pages++;
 
37
  }#end of while
 
38
  #reduce it by one
 
39
  if ($pages > $max_jpg){
 
40
    $pages -= 1;
 
41
  }
 
42
# Find name of process
 
43
  open PROCESS, "grep Process matrix_$imatrix.f |" or print "Error: can't do grep\n";
 
44
  $proc = <PROCESS>;
 
45
  if ($proc =~ /Process: (.+?)(\s\w+=\d+)*$/) { $proc = $1; }
 
46
  print PAGE "<P>\<A HREF\=\"matrix_$imatrix.ps\" id\=\"$imatrix\"\> Postscript Diagrams for $proc\<\/A\> \<BR\> \n";
 
47
  for($j=1;$j<$pages;$j++){
 
48
    print PAGE "\<IMG SRC=\"matrix_$imatrix$j.jpg\" ALT=\"Page $j of $pages \" \> \<BR\> \n";
 
49
  }#end of for
 
50
#
 
51
#   In case I didn't include all of the diagrams as jpeg, warn user
 
52
#
 
53
  if (-e "matrix_$imatrix$max_jpg.jpg" ) {
 
54
    print PAGE "<P>To save bandwidth not all diagrams were converted to jpeg.";
 
55
    print PAGE "<P> To view all diagrams click on ";
 
56
    print PAGE "\<A HREF\=\"matrix_$imatrix.ps\"\> postscript. \<\/A\> \<BR\> \n";
 
57
#
 
58
#    Delete files which aren't included in diagrams.html
 
59
#
 
60
    system ("/bin/bash -c \"rm -f matrix_$max_jpg.jpg\" ");
 
61
  }
 
62
#
 
63
#  Now create jpeg file for card
 
64
#
 
65
    system ("/bin/bash -c \"head -352 matrix_$imatrix.ps >& junk.ps\" ");
 
66
    open(JUNK,">> junk.ps") || die "Error opening junk.ps";  
 
67
 
 
68
    print JUNK "-30 -380 translate \n";
 
69
    print JUNK "0.7 0.7 scale \n";
 
70
    close(JUNK);
 
71
 
 
72
    system ("/bin/bash -c \"cat matrix_$imatrix.ps | sed 1,352d >> junk.ps\" ");
 
73
 
 
74
    system "/bin/bash -c \"nice gs  \-sDEVICE\=jpeg \-sOutputFile\=card.jpg \-q \-dNOPAUSE \-dBATCH \-g180x150 ./junk.ps; rm -f junk.ps; cp -p card.jpg ../../HTML/card.jpg\" ";
 
75
  if ($imatrix eq "") {$imatrix = 0;}
 
76
  $imatrix = $imatrix + 1;
 
77
}
 
78
 
 
79
print PAGE "\n";
 
80
print PAGE "\<\/BODY\> \n";
 
81
print PAGE "\<\/HTML\> \n";
 
82
close(PAGE);