1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 """ Create gen_crossxhtml """
16
17
18 import os
19 import math
20 import pickle
21 try:
22 import internal.files as files
23 import internal.save_load_object as save_load_object
24 except:
25 import madgraph.iolibs.files as files
26 import madgraph.iolibs.save_load_object as save_load_object
27
28 pjoin = os.path.join
29 exists = os.path.exists
30
31
32
33 crossxhtml_template = """
34 <HTML>
35 <HEAD>
36 %(refresh)s
37 <META HTTP-EQUIV="EXPIRES" CONTENT="20" >
38 <TITLE>Online Event Generation</TITLE>
39 <link rel=stylesheet href="./HTML/mgstyle.css" type="text/css">
40 </HEAD>
41 <BODY>
42 <script type="text/javascript">
43 function UrlExists(url) {
44 var http = new XMLHttpRequest();
45 http.open('HEAD', url, false);
46 try{
47 http.send()
48 }
49 catch(err){
50 return 1==2;
51 }
52 return http.status!=404;
53 }
54 function check_link(url,alt, id){
55 var obj = document.getElementById(id);
56 if ( ! UrlExists(url)){
57 if ( ! UrlExists(alt)){
58 obj.href = url;
59 return 1==1;
60 }
61 obj.href = alt;
62 return 1 == 2;
63 }
64 obj.href = url;
65 return 1==1;
66 }
67 </script>
68 <H2 align=center> Results in the %(model)s for %(process)s </H2>
69 <HR>
70 %(status)s
71 <br>
72 <br>
73 <H2 align="center"> Available Results </H2>
74 <TABLE BORDER=2 align="center">
75 <TR align="center">
76 <TH>Run</TH>
77 <TH>Collider</TH>
78 <TH> Banner </TH>
79 <TH> %(numerical_title)s </TH>
80 <TH> Events </TH>
81 <TH> Data </TH>
82 <TH>Output</TH>
83 <TH>Action</TH>
84 </TR>
85 %(old_run)s
86 </TABLE>
87 <H3 align=center><A HREF="./index.html"> Main Page </A></H3>
88 </BODY>
89 </HTML>
90 """
91
92 status_template = """
93 <H2 ALIGN=CENTER> Currently Running </H2>
94 <TABLE BORDER=2 ALIGN=CENTER>
95 <TR ALIGN=CENTER>
96 <TH nowrap ROWSPAN=2 font color="#0000FF"> Run Name </TH>
97 <TH nowrap ROWSPAN=2 font color="#0000FF"> Tag Name </TH>
98 <TH nowrap ROWSPAN=2 font color="#0000FF"> Cards </TH>
99 <TH nowrap ROWSPAN=2 font color="#0000FF"> Results </TH>
100 <TH nowrap ROWSPAN=1 COLSPAN=4 font color="#0000FF"> Status/Jobs
101 <TR>
102 <TH> Queued </TH>
103 <TH> Running </TH>
104 <TH> Done </TH>
105 </TR>
106 </TR>
107 <TR ALIGN=CENTER>
108 <TD nowrap ROWSPAN=2> %(run_name)s </TD>
109 <TD nowrap ROWSPAN=2> %(tag_name)s </TD>
110 <TD nowrap ROWSPAN=2> <a href="./Cards/param_card.dat">param_card</a><BR>
111 <a href="./Cards/run_card.dat">run_card</a><BR>
112 %(plot_card)s
113 %(pythia_card)s
114 %(pgs_card)s
115 %(delphes_card)s
116 </TD>
117 <TD nowrap ROWSPAN=2> %(results)s </TD>
118 %(status)s
119 </TR>
120 <tr></tr>
121 </TABLE>
122 """
123
125 """Store the results for all the run of a given directory"""
126
127 web = False
128
129 - def __init__(self, model, process, path):
130
131 dict.__init__(self)
132 self.order = []
133 self.lastrun = None
134 self.process = ', '.join(process)
135 if len(self.process) > 60:
136 pos = self.process[50:].find(',')
137 if pos != -1:
138 self.process = self.process[:50+pos] + ', ...'
139 self.path = path
140 self.model = model
141 self.status = ''
142 self.unit = 'pb'
143 self.current = None
144
146 """define the name of the current run
147 The first argument can be a OneTagResults
148 """
149
150 if isinstance(run, OneTagResults):
151 self.current = run
152 self.lastrun = run['run_name']
153 return
154
155 assert run in self or run == None
156 self.lastrun = run
157 if run:
158 if not tag:
159 self.current = self[run][-1]
160 else:
161 self.current = self[run][tag]
162 else:
163 self.current = None
164
166 """delete a run from the database"""
167
168 assert run_name in self
169
170 if not tag :
171 if self.current['run_name'] == run_name:
172 self.results.def_current(None)
173 del self[run_name]
174 self.order.remove(run_name)
175 if self.lastrun == run_name:
176 self.lastrun = None
177 else:
178 assert tag in [a['tag'] for a in self[run_name]]
179 RUN = self[run_name]
180 if len(RUN) == 1:
181 self.delete_run(run_name)
182 return
183 RUN.remove(tag)
184
185
186 self.output()
187
189 """define if we are in web mode or not """
190 if web is True:
191 try:
192 web = os.environ['SERVER_NAME']
193 except:
194 web = 'my_computer'
195 self['web'] = web
196 self.web = web
197
198 - def add_run(self, name, run_card, current=True):
225
226 - def update(self, status, level, makehtml=True, error=False):
227 """update the current run status"""
228 if self.current:
229 self.current.update_status(level)
230 self.status = status
231 if self.current and self.current.debug and self.status and not error:
232 self.current.debug = None
233
234 if makehtml:
235 self.output()
236
238 """check the output status of all run
239 main_path redefines the path associated to the run (allowing to move
240 the directory)
241 """
242
243 self.path = main_path
244
245 for key,run in self.items():
246 if key == 'web':
247 continue
248 for i,subrun in enumerate(run):
249 self.def_current(subrun)
250 self.clean()
251 self.current.event_path = pjoin(main_path,'Events')
252 if i==0:
253 self.current.update_status()
254 else:
255 self.current.update_status(nolevel='parton')
256 self.output()
257
258 - def clean(self, levels = ['all'], run=None, tag=None):
259 """clean the run for the levels"""
260
261 if not run and not self.current:
262 return
263 to_clean = self.current
264 if run and not tag:
265 for tagrun in self[run]:
266 self.clean(levels, run, tagrun['tag'])
267 return
268
269 if run:
270 to_clean = self[run].return_tag(tag)
271 else:
272 run = to_clean['run_name']
273
274 if 'all' in levels:
275 levels = ['parton', 'pythia', 'pgs', 'delphes', 'channel']
276
277 if 'parton' in levels:
278 to_clean.parton = []
279 if 'pythia' in levels:
280 to_clean.pythia = []
281 if 'pgs' in levels:
282 to_clean.pgs = []
283 if 'delphes' in levels:
284 to_clean.delphes = []
285
286
288 """Save the results of this directory in a pickle file"""
289 filename = pjoin(self.path, 'HTML', 'results.pkl')
290 save_load_object.save_to_file(filename, self)
291
292 - def add_detail(self, name, value, run=None, tag=None):
293 """ add information to current run (cross/error/event)"""
294 assert name in ['cross', 'error', 'nb_event', 'cross_pythia',
295 'nb_event_pythia','error_pythia']
296
297 if not run and not self.current:
298 return
299
300 if not run:
301 run = self.current
302 else:
303 run = self[run].return_tag(tag)
304
305 if name == 'cross_pythia':
306 run['cross_pythia'] = float(value)
307 elif name == 'nb_event':
308 run[name] = int(value)
309 elif name == 'nb_event_pythia':
310 run[name] = int(value)
311 else:
312 run[name] = float(value)
313
315 """ write the output file """
316
317
318 if self.status and self.current:
319 if isinstance(self.status, str):
320 status = '<td ROWSPAN=2 colspan=4>%s</td>' % self.status
321 else:
322 s = self.status
323 status ='''<td> %s </td> <td> %s </td> <td> %s </td>
324 </tr><tr><td colspan=3><center> %s </center></td>''' % (s[0],s[1], s[2], s[3])
325
326
327 status_dict = {'status': status,
328 'cross': self.current['cross'],
329 'error': self.current['error'],
330 'run_name': self.current['run_name'],
331 'tag_name': self.current['tag'],
332 'unit': self[self.current['run_name']].info['unit']}
333
334 if exists(pjoin(self.path, 'HTML',self.current['run_name'],
335 'results.html')):
336 status_dict['results'] = """<A HREF="./HTML/%(run_name)s/results.html">%(cross).4g <font face=symbol>±</font> %(error).4g (%(unit)s)</A>""" % status_dict
337 else:
338 status_dict['results'] = "No results yet"
339 if exists(pjoin(self.path, 'Cards', 'plot_card.dat')):
340 status_dict['plot_card'] = """ <a href="./Cards/plot_card.dat">plot_card</a><BR>"""
341 else:
342 status_dict['plot_card'] = ""
343 if exists(pjoin(self.path, 'Cards', 'pythia_card.dat')):
344 status_dict['pythia_card'] = """ <a href="./Cards/pythia_card.dat">pythia_card</a><BR>"""
345 else:
346 status_dict['pythia_card'] = ""
347 if exists(pjoin(self.path, 'Cards', 'pgs_card.dat')):
348 status_dict['pgs_card'] = """ <a href="./Cards/pgs_card.dat">pgs_card</a><BR>"""
349 else:
350 status_dict['pgs_card'] = ""
351 if exists(pjoin(self.path, 'Cards', 'delphes_card.dat')):
352 status_dict['delphes_card'] = """ <a href="./Cards/delphes_card.dat">delphes_card</a><BR>"""
353 else:
354 status_dict['delphes_card'] = ""
355
356 status = status_template % status_dict
357 refresh = "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"10\">"
358 else:
359 status =''
360 refresh = ''
361
362
363
364 if os.path.exists(pjoin(self.path, 'RunWeb')):
365 running = True
366 else:
367 running = False
368
369
370 old_run = ''
371 for key in self.order:
372 old_run += self[key].get_html(self.path, web=self.web, running=running)
373
374 text_dict = {'process': self.process,
375 'model': self.model,
376 'status': status,
377 'old_run': old_run,
378 'refresh': refresh,
379 'numerical_title': self.unit == 'pb' and 'Cross section (pb)'\
380 or 'Width (GeV)'}
381
382 text = crossxhtml_template % text_dict
383 open(pjoin(self.path,'crossx.html'),'w').write(text)
384
385
386
388 """The list of all OneTagResults"""
389
390 - def __init__(self, run_name, run_card, process, path):
391 """initialize the object"""
392
393 self.info = {'run_name': run_name,'me_dir':path}
394 self.tags = [run_card['run_tag']]
395
396 data = process.split('>',1)[0].split()
397 if len(data) == 2:
398 name1,name2 = data
399 if run_card['lpp1'] == '-1':
400 name1 = ' p~'
401 elif run_card['lpp1'] == '1':
402 name1 = ' p'
403 elif run_card['lpp1'] == '2':
404 name1 = ' a'
405 if run_card['lpp2'] == '-1':
406 name2 = 'p~'
407 elif run_card['lpp1'] == '1':
408 name2 = ' p'
409 elif run_card['lpp2'] == '2':
410 name2 = ' a'
411 self.info['collider'] = '''%s %s <br> %s x %s GeV''' % \
412 (name1, name2, run_card['ebeam1'], run_card['ebeam2'])
413 self.info['unit'] = 'pb'
414 else:
415 self.info['collider'] = 'decay'
416 self.info['unit'] = 'GeV'
417
418 self.append(OneTagResults(run_name, run_card, path))
419
420
421 - def get_html(self, output_path, **opt):
422 """WRITE HTML OUTPUT"""
423
424 try:
425 self.web = opt['web']
426 self.info['web'] = self.web
427 except:
428 self.web = False
429
430
431 parton = [r for r in self if r.parton]
432
433 if len(parton)>1:
434 for p in parton[:-1]:
435 p.parton = []
436
437 dico = self.info
438 dico['run_span'] = sum([tag.get_nb_line() for tag in self], 1) -1
439 dico['tag_data'] = '\n'.join([tag.get_html(self) for tag in self])
440 text = """
441 <tr>
442 <td rowspan=%(run_span)s>%(run_name)s</td>
443 <td rowspan=%(run_span)s><center> %(collider)s </center></td>
444 %(tag_data)s
445 </tr>
446 """ % dico
447
448 if self.web:
449
450 text = text % self.info
451
452
453 return text
454
456
457 for data in self:
458 if data['tag'] == name:
459 return data
460
461 if name is None:
462
463 return self[-1]
464
465 raise Exception, '%s is not a valid tag' % name
466
467 - def add(self, obj):
468 """ """
469
470 assert isinstance(obj, OneTagResults)
471 tag = obj['tag']
472 assert tag not in self.tags
473 self.tags.append(tag)
474 self.append(obj)
475
477 for i in range(1, len(self)+1):
478 if self[-i].pythia:
479 return self[-i]['tag']
480
482
483 output = {}
484 current = self[-1]
485
486 if current.pythia and not current['nb_event'] and len(self) > 1:
487 output['nb_event'] = self[-2]['nb_event']
488 output['cross'] = self[-2]['cross']
489 output['error'] = self[-2]['error']
490 elif (current.pgs or current.delphes) and not current['nb_event'] and len(self) > 1:
491 if self[-2]['cross_pythia'] and self[-2]['nb_event_pythia']:
492 output['cross'] = self[-2]['cross_pythia']
493 output['nb_event'] = self[-2]['nb_event_pythia']
494 output['error'] = self[-2]['error_pythia']
495 else:
496 output['nb_event'] = self[-2]['nb_event']
497 output['cross'] = self[-2]['cross']
498 output['error'] = self[-2]['error']
499 elif current['cross']:
500 return current
501 elif len(self) > 1:
502 output['nb_event'] = self[-2]['nb_event']
503 output['cross'] = self[-2]['cross']
504 output['error'] = self[-2]['error']
505 else:
506 output['nb_event'] = 0
507 output['cross'] = 0
508 output['error'] = 1e-99
509 return output
510
511
513
514 assert tag in self.tags
515
516 obj = [o for o in self if o['tag']==tag][0]
517 self.tags.remove(tag)
518 list.remove(self, obj)
519
520
521
523 """ Store the results of a specific run """
524
525 - def __init__(self, run_name, run_card, path):
526 """initialize the object"""
527
528
529 self['run_name'] = run_name
530 self['tag'] = run_card['run_tag']
531 self.event_path = pjoin(path,'Events')
532 self.me_dir = path
533 self.debug = None
534
535
536 self['nb_event'] = 0
537 self['cross'] = 0
538 self['cross_pythia'] = ''
539 self['nb_event_pythia'] = 0
540 self['error'] = 0
541 self.parton = []
542 self.pythia = []
543 self.pgs = []
544 self.delphes = []
545
546 self.status = ''
547
548
549
550
552 """update the status of the current run """
553
554 exists = os.path.exists
555 run = self['run_name']
556 tag =self['tag']
557
558 path = pjoin(self.event_path, run)
559 html_path = pjoin(self.event_path, os.pardir, 'HTML', run)
560
561
562 if level in ['gridpack','all']:
563 if 'gridpack' not in self.parton and \
564 exists(pjoin(path,os.pardir ,os.pardir,"%s_gridpack.tar.gz" % run)):
565 self.parton.append('gridpack')
566
567 if level in ['parton','all'] and 'parton' not in nolevel:
568
569 if 'lhe' not in self.parton and \
570 (exists(pjoin(path,"unweighted_events.lhe.gz")) or
571 exists(pjoin(path,"unweighted_events.lhe"))):
572 self.parton.append('lhe')
573
574 if 'root' not in self.parton and \
575 exists(pjoin(path,"unweighted_events.root")):
576 self.parton.append('root')
577
578 if 'plot' not in self.parton and \
579 exists(pjoin(html_path,"plots_parton.html")):
580 self.parton.append('plot')
581
582 if 'param_card' not in self.parton and \
583 exists(pjoin(path, "param_card.dat")):
584 self.parton.append('param_card')
585
586 if level in ['pythia', 'all']:
587
588 if 'plot' not in self.pythia and \
589 exists(pjoin(html_path,"plots_pythia_%s.html" % tag)):
590 self.pythia.append('plot')
591
592 if 'lhe' not in self.pythia and \
593 (exists(pjoin(path,"%s_pythia_events.lhe.gz" % tag)) or
594 exists(pjoin(path,"%s_pythia_events.lhe" % tag))):
595 self.pythia.append('lhe')
596
597
598 if 'hep' not in self.pythia and \
599 (exists(pjoin(path,"%s_pythia_events.hep.gz" % tag)) or
600 exists(pjoin(path,"%s_pythia_events.hep" % tag))):
601 self.pythia.append('hep')
602
603 if 'root' not in self.pythia and \
604 exists(pjoin(path,"%s_pythia_events.root" % tag)):
605 self.pythia.append('root')
606
607 if 'lheroot' not in self.pythia and \
608 exists(pjoin(path,"%s_pythia_lhe_events.root" % tag)):
609 self.pythia.append('lheroot')
610
611 if 'log' not in self.pythia and \
612 exists(pjoin(path,"%s_pythia.log" % tag)):
613 self.pythia.append('log')
614
615 if level in ['pgs', 'all']:
616
617 if 'plot' not in self.pgs and \
618 exists(pjoin(html_path,"plots_pgs_%s.html" % tag)):
619 self.pgs.append('plot')
620
621 if 'lhco' not in self.pgs and \
622 (exists(pjoin(path,"%s_pgs_events.lhco.gz" % tag)) or
623 exists(pjoin(path,"%s_pgs_events.lhco." % tag))):
624 self.pgs.append('lhco')
625
626 if 'root' not in self.pgs and \
627 exists(pjoin(path,"%s_pgs_events.root" % tag)):
628 self.pgs.append('root')
629
630 if 'log' not in self.pgs and \
631 exists(pjoin(path,"%s_pgs.log" % tag)):
632 self.pgs.append('log')
633
634 if level in ['delphes', 'all']:
635
636 if 'plot' not in self.delphes and \
637 exists(pjoin(html_path,"plots_delphes_%s.html" % tag)):
638 self.delphes.append('plot')
639
640 if 'lhco' not in self.delphes and \
641 (exists(pjoin(path,"%s_delphes_events.lhco.gz" % tag)) or
642 exists(pjoin(path,"%s_delphes_events.lhco" % tag))):
643 self.delphes.append('lhco')
644
645 if 'root' not in self.delphes and \
646 exists(pjoin(path,"%s_delphes_events.root" % tag)):
647 self.delphes.append('root')
648
649 if 'log' not in self.delphes and \
650 exists(pjoin(path,"%s_delphes.log" % tag)):
651 self.delphes.append('log')
652
654
655 id = '%s_%s_%s_%s' % (self['run_name'],self['tag'], level, name)
656
657 return " <a id='%(id)s' href='%(link)s.gz' onClick=\"check_link('%(link)s.gz','%(link)s','%(id)s')\">%(name)s</a>" \
658 % {'link': link, 'id': id, 'name':name}
659
661
662 return " <a id='%(id)s' href='%(link1)s' onClick=\"check_link('%(link1)s','%(link2)s','%(id)s')\">%(name)s</a>" \
663 % {'link1': link1, 'link2':link2, 'id': id, 'name':name}
664
666 """ Get the links for a given level"""
667
668 out = ''
669 if level == 'parton':
670 if 'gridpack' in self.parton:
671 out += self.special_link("./%(run_name)s_gridpack.tar",
672 'gridpack', 'gridpack')
673
674 if 'lhe' in self.parton:
675 link = './Events/%(run_name)s/unweighted_events.lhe'
676 level = 'parton'
677 name = 'LHE'
678 out += self.special_link(link, level, name)
679 if 'root' in self.parton:
680 out += ' <a href="./Events/%(run_name)s/unweighted_events.root">rootfile</a>'
681 if 'plot' in self.parton:
682 out += ' <a href="./HTML/%(run_name)s/plots_parton.html">plots</a>'
683 if 'param_card' in self.parton:
684 out += ' <a href="./Events/%(run_name)s/param_card.dat">param_card</a>'
685
686 return out % self
687
688 if level == 'pythia':
689 if 'log' in self.pythia:
690 out += """ <a href="./Events/%(run_name)s/%(tag)s_pythia.log">LOG</a>"""
691 if 'hep' in self.pythia:
692 link = './Events/%(run_name)s/%(tag)s_pythia_events.hep'
693 level = 'pythia'
694 name = 'STDHEP'
695 out += self.special_link(link, level, name)
696 if 'lhe' in self.pythia:
697 link = './Events/%(run_name)s/%(tag)s_pythia_events.lhe'
698 level = 'pythia'
699 name = 'LHE'
700 out += self.special_link(link, level, name)
701 if 'root' in self.pythia:
702 out += """ <a href="./Events/%(run_name)s/%(tag)s_pythia_events.root">rootfile (LHE)</a>"""
703 if 'lheroot' in self.pythia:
704 out += """ <a href="./Events/%(run_name)s/%(tag)s_pythia_lhe_events.root">rootfile (LHE)</a>"""
705 if 'plot' in self.pythia:
706 out += ' <a href="./HTML/%(run_name)s/plots_pythia_%(tag)s.html">plots</a>'
707 return out % self
708
709
710 if level == 'pgs':
711 if 'log' in self.pgs:
712 out += """ <a href="./Events/%(run_name)s/%(tag)s_pgs.log">LOG</a>"""
713 if 'lhco' in self.pgs:
714 link = './Events/%(run_name)s/%(tag)s_pgs_events.lhco'
715 level = 'pgs'
716 name = 'LHCO'
717 out += self.special_link(link, level, name)
718 if 'root' in self.pgs:
719 out += """ <a href="./Events/%(run_name)s/%(tag)s_pgs_events.root">rootfile</a>"""
720 if 'plot' in self.pgs:
721 out += """ <a href="./HTML/%(run_name)s/plots_pgs_%(tag)s.html">plots</a>"""
722 return out % self
723
724 if level == 'delphes':
725
726 if 'log' in self.delphes:
727 out += """ <a href="./Events/%(run_name)s/%(tag)s_delphes.log">LOG</a>"""
728 if 'lhco' in self.delphes:
729 link = './Events/%(run_name)s/%(tag)s_delphes_events.lhco'
730 level = 'delphes'
731 name = 'LHCO'
732 out += self.special_link(link, level, name)
733 if 'root' in self.delphes:
734 out += """ <a href="./Events/%(run_name)s/%(tag)s_delphes_events.root">rootfile</a>"""
735 if 'plot' in self.delphes:
736 out += """ <a href="./HTML/%(run_name)s/plots_delphes_%(tag)s.html">plots</a>"""
737 return out % self
738
739
741
742 nb_line = 0
743 for i in [self.parton, self.pythia, self.pgs, self.delphes]:
744 if len(i):
745 nb_line += 1
746 return max([nb_line,1])
747
748
750 """create the html output linked to the this tag
751 RunResults is given in case of cross-section need to be taken
752 from a previous run
753 """
754
755
756 tag_template = """
757 <td rowspan=%(tag_span)s> <a href="./Events/%(run)s/%(run)s_%(tag)s_banner.txt">%(tag)s</a>%(debug)s</td>
758 %(subruns)s"""
759
760
761
762 sub_part_template_parton = """
763 <td rowspan=%(cross_span)s><center><a href="./HTML/%(run)s/results.html"> %(cross).4g <font face=symbol>±</font> %(err).2g </a></center></td>
764 <td rowspan=%(cross_span)s><center> %(nb_event)s<center></td><td> %(type)s </td>
765 <td> %(links)s</td>
766 <td> %(action)s</td>
767 </tr>"""
768
769 sub_part_template_pgs = """
770 <td> %(type)s </td>
771 <td> %(links)s</td>
772 <td> %(action)s</td>
773 </tr>"""
774
775
776 nb_line = self.get_nb_line()
777
778 if self.pythia and not self['nb_event']:
779 try:
780 self['nb_event'] = runresults[-2]['nb_event']
781 self['cross'] = runresults[-2]['cross']
782 self['error'] = runresults[-2]['error']
783 except:
784 pass
785
786 elif (self.pgs or self.delphes) and not self['nb_event']:
787 if runresults[-2]['cross_pythia'] and runresults[-2]['cross']:
788 self['cross'] = runresults[-2]['cross_pythia']
789 self['error'] = runresults[-2]['error_pythia']
790 self['nb_event'] = runresults[-2]['nb_event_pythia']
791 else:
792 self['nb_event'] = runresults[-2]['nb_event']
793 self['cross'] = runresults[-2]['cross']
794 self['error'] = runresults[-2]['error']
795
796
797 first = None
798 subresults_html = ''
799 for type in ['parton', 'pythia', 'pgs', 'delphes']:
800 data = getattr(self, type)
801 if not data:
802 continue
803
804 local_dico = {'type': type, 'run': self['run_name']}
805
806 if not first:
807 template = sub_part_template_parton
808 first = type
809 if type=='parton' and self['cross_pythia']:
810 local_dico['cross_span'] = 1
811 local_dico['cross'] = self['cross']
812 local_dico['err'] = self['error']
813 local_dico['nb_event'] = self['nb_event']
814 elif self['cross_pythia']:
815 if self.parton:
816 local_dico['cross_span'] = nb_line -1
817 else:
818 local_dico['cross_span'] = nb_line
819 if self['nb_event_pythia']:
820 local_dico['nb_event'] = self['nb_event_pythia']
821 else:
822 local_dico['nb_event'] = 0
823 local_dico['cross'] = self['cross_pythia']
824 local_dico['err'] = self['error_pythia']
825 else:
826 local_dico['cross_span'] = nb_line
827 local_dico['cross'] = self['cross']
828 local_dico['err'] = self['error']
829 local_dico['nb_event'] = self['nb_event']
830
831 elif type == 'pythia' and self['cross_pythia']:
832 template = sub_part_template_parton
833 if self.parton:
834 local_dico['cross_span'] = nb_line - 1
835 if self['nb_event_pythia']:
836 local_dico['nb_event'] = self['nb_event_pythia']
837 else:
838 local_dico['nb_event'] = 0
839 else:
840 local_dico['cross_span'] = nb_line
841 local_dico['nb_event'] = self['nb_event']
842 local_dico['cross'] = self['cross_pythia']
843 local_dico['err'] = self['error_pythia']
844 else:
845 template = sub_part_template_pgs
846
847
848 local_dico['links'] = self.get_links(type)
849
850
851 if type == 'parton':
852 if runresults.web:
853 local_dico['action'] = """
854 <FORM ACTION="http://%(web)s/cgi-bin/RunProcess/handle_runs-pl" ENCTYPE="multipart/form-data" METHOD="POST">
855 <INPUT TYPE=HIDDEN NAME=directory VALUE="%(me_dir)s">
856 <INPUT TYPE=HIDDEN NAME=whattodo VALUE="remove_level">
857 <INPUT TYPE=HIDDEN NAME=level VALUE="all">
858 <INPUT TYPE=HIDDEN NAME=tag VALUE=\"""" + self['tag'] + """\">
859 <INPUT TYPE=HIDDEN NAME=run VALUE="%(run_name)s">
860 <INPUT TYPE=SUBMIT VALUE="Remove run">
861 </FORM>
862
863 <FORM ACTION="http://%(web)s/cgi-bin/RunProcess/handle_runs-pl" ENCTYPE="multipart/form-data" METHOD="POST">
864 <INPUT TYPE=HIDDEN NAME=directory VALUE="%(me_dir)s">
865 <INPUT TYPE=HIDDEN NAME=whattodo VALUE="pythia">
866 <INPUT TYPE=HIDDEN NAME=run VALUE="%(run_name)s">
867 <INPUT TYPE=SUBMIT VALUE="Run Pythia">
868 </FORM>"""
869 else:
870 local_dico['action'] = self.command_suggestion_html('remove %s parton --tag=%s' \
871 % (self['run_name'], self['tag']))
872 local_dico['action'] += self.command_suggestion_html('pythia %s ' % self['run_name'])
873 elif type == 'pythia':
874 if self['tag'] == runresults.get_last_pythia():
875 if runresults.web:
876 local_dico['action'] = """
877 <FORM ACTION="http://%(web)s/cgi-bin/RunProcess/handle_runs-pl" ENCTYPE="multipart/form-data" METHOD="POST">
878 <INPUT TYPE=HIDDEN NAME=directory VALUE="%(me_dir)s">
879 <INPUT TYPE=HIDDEN NAME=whattodo VALUE="remove_level">
880 <INPUT TYPE=HIDDEN NAME=level VALUE="pythia">
881 <INPUT TYPE=HIDDEN NAME=run VALUE="%(run_name)s">
882 <INPUT TYPE=HIDDEN NAME=tag VALUE=\"""" + self['tag'] + """\">
883 <INPUT TYPE=SUBMIT VALUE="Remove pythia">
884 </FORM>
885
886 <FORM ACTION="http://%(web)s/cgi-bin/RunProcess/handle_runs-pl" ENCTYPE="multipart/form-data" METHOD="POST">
887 <INPUT TYPE=HIDDEN NAME=directory VALUE="%(me_dir)s">
888 <INPUT TYPE=HIDDEN NAME=whattodo VALUE="pgs">
889 <INPUT TYPE=HIDDEN NAME=run VALUE="%(run_name)s">
890 <INPUT TYPE=SUBMIT VALUE="Run Detector">
891 </FORM>"""
892 else:
893 local_dico['action'] = self.command_suggestion_html(
894 'remove %s pythia --tag=%s' % \
895 (self['run_name'], self['tag']))
896 local_dico['action'] += self.command_suggestion_html(
897 'pgs %(1)s or delphes %(1)s' % {'1': self['run_name']})
898 else:
899 if runresults.web:
900 local_dico['action'] = ''
901 else:
902 local_dico['action'] = self.command_suggestion_html('remove %s pythia --tag=%s'\
903 % (self['run_name'], self['tag']))
904 else:
905 if runresults.web:
906 local_dico['action'] = """
907 <FORM ACTION="http://%(web)s/cgi-bin/RunProcess/handle_runs-pl" ENCTYPE="multipart/form-data" METHOD="POST">
908 <INPUT TYPE=HIDDEN NAME=directory VALUE="%(me_dir)s">
909 <INPUT TYPE=HIDDEN NAME=whattodo VALUE="remove_level">
910 <INPUT TYPE=HIDDEN NAME=level VALUE=\"""" + str(type) + """\">
911 <INPUT TYPE=HIDDEN NAME=tag VALUE=\"""" + self['tag'] + """\">
912 <INPUT TYPE=HIDDEN NAME=run VALUE="%(run_name)s">
913 <INPUT TYPE=SUBMIT VALUE="Remove """ + str(type) + """\">
914 </FORM>"""
915 else:
916 local_dico['action'] = self.command_suggestion_html('remove %s %s --tag=%s' %\
917 (self['run_name'], type, self['tag']))
918
919
920
921
922 subresults_html += template % local_dico
923
924
925
926 if subresults_html == '':
927 subresults_html = sub_part_template_parton % \
928 {'type': '',
929 'run': self['run_name'],
930 'cross_span': 1,
931 'cross': self['cross'],
932 'err': self['error'],
933 'nb_event': self['nb_event'] and self['nb_event'] or 'No events yet',
934 'links': 'banner only',
935 'action': ''
936 }
937
938 if self.debug:
939 debug = '<br> <a href=\'./%s_%s_debug.log\'> <font color=red>ERROR</font></a>' \
940 % (self['run_name'], self['tag'])
941 else:
942 debug = ''
943 text = tag_template % {'tag_span': nb_line,
944 'run': self['run_name'], 'tag': self['tag'],
945 'subruns' : subresults_html,
946 'debug':debug}
947
948 return text
949
950
952 """return html button with code suggestion"""
953
954 if command.startswith('pythia'):
955 button = 'launch pythia'
956 elif command.startswith('remove'):
957 button = 'remove run'
958 else:
959 button = 'launch detector simulation'
960
961 header = 'Launch ./bin/madevent in a shell, and run the following command: '
962 return "<INPUT TYPE=SUBMIT VALUE='%s' onClick=\"alert('%s')\">" % (button, header + command)
963
964
965 return + '<br>'
966