1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import string
18 import os
19 import re
20 import sys
21
22 template_text= string.Template("""
23 <HTML>
24 <HEAD>
25 <TITLE>Detail on the Generation</TITLE>
26 <META $meta ></HEAD>
27
28 <style type="text/css">
29
30 table.processes { border-collapse: collapse;
31 border: solid}
32
33 .processes td {
34 padding: 2 5 2 5;
35 border: solid thin;
36 }
37
38 th{
39 border-top: solid;
40 border-bottom: solid;
41 }
42
43 .first td{
44 border-top: solid;
45 }
46
47
48
49
50 </style>
51
52 <BODY>
53 <P> <H2 ALIGN=CENTER> SubProcesses and Feynman diagrams </H2>
54
55 <TABLE BORDER=2 ALIGN=CENTER class=processes>
56 <TR>
57 <TH>Directory</TH>
58 <TH NOWRAP># Diagrams </TH>
59 <TH NOWRAP># Subprocesses </TH>
60 <TH>FEYNMAN DIAGRAMS</TH>
61 <TH> SUBPROCESS </TH>
62 </TR>
63 $info_lines
64 </TABLE><BR>
65 <CENTER> $nb_diag diagrams ($nb_gen_diag independent).</CENTER>
66 <br><br><br>
67 <TABLE ALIGN=CENTER>
68 $log
69 <TR>
70 <TD ALIGN=CENTER> <A HREF="../Cards/proc_card_mg5.dat">proc_card_mg5.dat</A> </TD>
71 <TD> Input file used for code generation.
72 $model_info
73 </TABLE><br>
74 <center>
75 <H3>Back to <A HREF="../index.html">Process main page</A></H3>
76 </center>
77 </BODY>
78
79 </HTML>""")
80
81
83
94
95
97 """find path for the model"""
98
99 path = os.path.join(self.dir, 'Source','MODEL','particles.dat')
100 if os.path.exists(path):
101 return """<TR>
102 <TD ALIGN=CENTER> <A HREF="../Source/MODEL/particles.dat">particles</A></TD>
103 <TD> Particles file used for code generation.</TD>
104 </TR>
105 <TR>
106 <TD ALIGN=CENTER> <A HREF="../Source/MODEL/interactions.dat">interactions</A></TD>
107 <TD> Interactions file used for code generation.</TD>
108 </TR>"""
109 else:
110 return ''
111
112
120
121
123 """define the information table"""
124
125 line_template = string.Template("""
126 <TR class=$class> $first
127 <TD> $diag </TD>
128 <TD> $subproc </TD>
129 <TD> <A HREF="../SubProcesses/$processdir/diagrams.html#$id" >html</A> $postscript
130 </TD><TD class=$class>
131 <SPAN style="white-space: nowrap;"> $subprocesslist</SPAN>
132 </TD></TR>""")
133
134
135 text = ''
136
137 subproc = [content for content in os.listdir(os.path.join(self.dir,'SubProcesses'))
138 if content.startswith('P') and
139 os.path.isdir(os.path.join(self.dir,'SubProcesses',content))
140 and os.path.exists(os.path.join(self.dir,'SubProcesses',content,'auto_dsig.f'))]
141
142 for proc in subproc:
143
144 idnames = self.get_subprocesses_info(proc)
145
146 for id in range(1,len(idnames)+1):
147
148 if id == 1:
149
150 line_dict = {'processdir': proc,
151 'class': 'first'}
152 line_dict['first']= '<TD class=$class rowspan=%s> %s </TD>' % (len(idnames), proc)
153 else:
154 line_dict = {'processdir': proc,
155 'class': 'second'}
156 line_dict['first'] = ''
157 try:
158 names = idnames[id]
159 except:
160 names = idnames['']
161 id = ''
162 line_dict['id'] = str(id)
163 line_dict['diag'] = self.get_diagram_nb(proc, id)
164 line_dict['subproc'] = sum([len(data) for data in names])
165 self.rep_rule['nb_diag'] += line_dict['diag'] * line_dict['subproc']
166 self.rep_rule['nb_gen_diag'] += line_dict['diag']
167 line_dict['subprocesslist'] = ', <br>'.join([' </SPAN> , <SPAN style="white-space: nowrap;"> '.join(info) for info in names])
168 line_dict['postscript'] = self.check_postcript(proc, id)
169
170
171
172 text += line_template.substitute(line_dict)
173 return text
174
176
177 path = os.path.join(self.dir, 'SubProcesses', proc, 'matrix%s.f' % id)
178 nb_diag = 0
179
180 pat = re.compile(r'''Amplitude\(s\) for diagram number (\d+)''' )
181
182 text = open(path).read()
183 for match in re.finditer(pat, text):
184 pass
185 nb_diag += int(match.groups()[0])
186
187 return nb_diag
188
189
191 """ return the list of processes with their name"""
192
193 path = os.path.join(self.dir, 'SubProcesses', proc)
194 nb_sub = 0
195 names = {}
196 old_main = ''
197
198 if not os.path.exists(os.path.join(path,'processes.dat')):
199 return self.get_subprocess_info_v4(proc)
200
201 for line in open(os.path.join(path,'processes.dat')):
202 main = line[:8].strip()
203 if main == 'mirror':
204 main = old_main
205 if line[8:].strip() == 'none':
206 continue
207 else:
208 main = int(main)
209 old_main = main
210
211 sub_proccess = line[8:]
212 nb_sub += sub_proccess.count(',') + 1
213 if main in names:
214 names[main] += [sub_proccess.split(',')]
215 else:
216 names[main]= [sub_proccess.split(',')]
217
218 return names
219
221 """ return the list of processes with their name in case without grouping """
222
223 nb_sub = 0
224 names = {'':[[]]}
225 path = os.path.join(self.dir, 'SubProcesses', proc,'auto_dsig.f')
226 found = 0
227 for line in open(path):
228 if line.startswith('C Process:'):
229 found += 1
230 names[''][0].append(line[15:])
231 elif found >1:
232 break
233 return names
234
235 - def check_postcript(self, proc, id):
236 """ check if matrix.ps is defined """
237 path = os.path.join(self.dir, 'SubProcesses', proc,'matrix%s.f' % id)
238 if os.path.exists(path):
239 return "<A HREF=\"../SubProcesses/%s/matrix%s.ps\" >postscript </A>" % \
240 (proc, id)
241 else:
242 return ''
243
245 path = os.path.join(self.dir, 'proc_log.txt')
246 if os.path.exists(path):
247 return """<TR>
248 <TD ALIGN=CENTER> <A HREF="../proc_log.txt">proc_log.txt</A> </TD>
249 <TD> Log file from MadGraph code generation. </TD>
250 </TR>"""
251 else:
252 return ''
254 """write the info.html file"""
255
256 fsock = open(os.path.join(self.dir,'HTML','info.html'),'w')
257 text = template_text.substitute(self.rep_rule)
258 fsock.write(text)
259