456 if Run.writehtml:
457
458 ofllumiFlag = False
459 s = '<tr>\n'
460 if Run.showrunnr:
461 s += ' <th>Run</th><th>Links</th><th>#LB</th>\n'
462 if Run.showtime:
463 s += ' <th>Start and endtime (%s)</th>\n' % QC.localStr()
464 if Run.showduration:
465 s += ' <th>Duration</th>\n'
466 for ik, data_key in enumerate(Run.SortedShowOrder()):
467 k = data_key.ResultKey
468 if k[0:4] == 'STR:':
469 s +=
' <th><font size="-2">%s_<BR>%s</font></th>' % tuple(k[4:].
split(
'_',1))
470 elif k[0:8] == "Detector":
471 s += ' <th>%s</th>' % k
472 elif "SolCurrent" in k:
473 s += ' <th>Solenoid<br>current (A)</th>'
474 elif "TorCurrent" in k:
475 s += ' <th>Toroid<br>current (A)</th>'
476 elif 'DQ' == k:
477 s += ' '
478 matching_names = dict(Run.Fieldinfo['DQ']['DefMatch'])
479 first = True
480 for channelname in Run.Fieldinfo['DQ']['DefChannels']:
481 tip = "defect_match_%s" % channelname
482 info = "%s # %s" % (channelname if channelname!="" else "*",data_key._second_internal_key if data_key._second_internal_key!="" else "HEAD")
483 s += '<th style="align:center; white-space:nowrap; padding-right: 10px; padding-left: 10px; ">'
484 s += 'Data Quality<br><span class="showTip %s tooltip" style="font-weight:normal; font-size:80%%">(%s)</span>' % (tip, info)
485 if first:
486 s += '<div style="font-size: xx-small; cursor: pointer;" onclick="toggle_dq(this)">[show tolerable]</div>'
487 first = False
488 s += '</th>'
489
490 allDefects = sorted(matching_names[channelname])
491 n = 4*[len(allDefects)//4]
492 for x in range(len(allDefects) % 4):
493 n[x]+=1
494
495
496 cx = 0
497 columns = []
498 for x in n:
499 columns.append( allDefects[slice(cx,cx+x)] )
500 cx+=x
501
502 for x in columns[1:]:
503 x += ['']
504
505 columnsTransposed = zip(*columns)
506
507 tts = ''
508 for z in columnsTransposed:
509 tts += '<tr>%s</tr>' % ''.join(["<td>%s</td>"% x for x in z])
510 content = '<table style="width:500px; font-size:80%%;">%s</table>' % tts
511 Run.addGlobalToolTip(tip,content)
512
513 elif isDQ(k):
514 foldertag,flag = k.split(':')
515
516 if flag in Run.Fieldinfo:
517 tipname = 'dqvfdesc_%s' % flag
518 commentbox = '%s' % (Run.Fieldinfo[flag])
519 Run.addGlobalToolTip(tipname, commentbox)
520 s += '<th class="showTip %s tooltip" style="cursor:pointer">' % tipname
521 else:
522 s += ' <th>'
523
524 s += '<font size="-1">%s</font><BR><font style="font-weight:normal;font-size:70%%">' % flag
525 if '#' in foldertag:
526 s += '(%s #<br>%s)' % tuple(foldertag.split('#',1))
527 else:
528 s += '(%s)' % (foldertag)
529 s += '</font></th>'
530
531 elif k == "L1 PSK":
532 continue
533 elif k == "HLT PSK":
534 s += ' <th>Prescale keys</th>'
535 elif k == "Release":
536 s += ' <th>HLT Release</th>'
537 elif k == "Datasets":
538 s += ' <th>Tier-0 Datasets</th>'
539 elif k == '#Events (incl. calib.)':
540 s += ' <th>#Events<br><font size="-2">(incl. calib.)</font></th>'
541 elif k == '#Events (streamed)' :
542 s += ' <th>#Events<br><font size="-2">(streamed)</font></th>'
543 elif 'lar:' in k:
544 if 'runtype' in k:
545 s += ' <th><font size="-2">Run type</font></th>'
546 elif 'nsamples' in k:
547 s += ' <th><font size="-2">#Samples</font></th>'
548 elif 'firstsample' in k:
549 s += ' <th><font size="-2">1st sample</font></th>'
550 elif 'format' in k:
551 s += ' <th><font size="-2">Format</font></th>'
552 else:
553 print ('ERROR: unknown LAr option "%s"' % k)
554 sys.exit(1)
555 elif 'lhc:' in k:
556 if 'fillnumber' in k:
557 s += ' <th> LHC Fill</th>'
558 elif 'stablebeams' in k:
559 s += ' <th>Stable beams</th>'
560 if 'lhc:beammode' in Run.ShowOrder:
561 s += ' <th>Beam mode</th>'
562 if 'lhc:beamenergy' in Run.ShowOrder:
563 s += ' <th>Beam energy and intensities</th>'
564
565 elif 'beamenergy' in k:
566 continue
567 elif 'nbunch1' in k:
568 s += ' <th>#Bunches B1 <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
569 elif 'nbunch2' in k:
570 s += ' <th>#Bunches B2 <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
571 elif 'nbunchcoll' in k:
572 s += ' <th>#Bunches<br>colliding <br><font size="-2"><b>(NOT YET RELIABLE)</b></font></th>'
573 elif 'beamtype1' in k:
574 s += ' <th>Beam type B1</th>'
575 elif 'beamtype2' in k:
576 s += ' <th>Beam type B2</th>'
577 elif 'machinemode' in k:
578 s += ' <th>LHC mode</th>'
579 elif 'beammode' in k:
580 continue
581 else:
582 print ('ERROR: unknown LHC option "%s"' % k)
583 sys.exit(1)
584 elif 'ofllumi:' in k:
585 if not ofllumiFlag:
586 s += ' <th>Offline Luminosity<br><font style="font-weight:normal">(%s)</font></font></th>' % k.split(':')[-1]
587 ofllumiFlag = True
588 elif 'bs:' in k:
589 kt = k.replace('bs:','')
590 if 'bs:Pos' in k or 'bs:Sig' in k:
591 s += ' <th><font size="-2">%s<br><font style="font-weight:normal">(mm)</font></font></th>' % kt
592 elif 'bs:Tilt' in k:
593 s += ' <th><font size="-2">%s<br><font style="font-weight:normal">(rad)</font></font></th>' % kt
594 else:
595 s += ' <th><font size="-2">%s</font></th>' % kt
596 elif 'BPM' in k:
597 s += ' <th>Beam Position Monitors (BPM)</th>'
598 elif 'olc:' in k:
599 if 'olc:lumi' in k:
600 tp1, tp2, chan = k.split(':')
601 try:
602 chan = float(chan)
603 except ValueError:
604 chan = -1
605 if chan in OLCAlgorithms:
606 chanstr = OLCAlgorithms[chan]
607 else:
608 chanstr = 'UNKNOWN'
609 s += ' <th>Online del. Luminosity <font size="-2"><br><font style="font-weight:normal">[%s]</font></font></th>' % chanstr
610 elif 'beam1bunches' in k:
611 continue
612 elif 'beam2bunches' in k:
613 continue
614 elif 'collbunches' in k:
615 continue
616 elif 'bcidmask' in k:
617 s += ' <th>Bunch structure</th>'
618 elif 'beam1intensity' in k:
619 continue
620 elif 'beam2intensity' in k:
621 continue
622 else:
623 s += ' <th>%s</th>' % k
624
625 elif 'BGS Key' in k:
626 s += ' <th>Bunch group key</th>'
627
628 else:
629 s += ' <th>%s</th>' % k
630 s += '\n'
631 s += '</tr>'
632
633
634 secondheader = ''
635 patterns = [ ('lar:', 'LAr configuration'),
636 ('lhc:|olc:', 'LHC and online luminosity information' if any(['olc:' in x for x in Run.headerkeys()]) else 'LHC information' ),
637 ('bs:', 'Beam spot parameters (%s)' % Run.BeamspotSource),
638 ('STR:', 'Data stream statistics'),
639 ('TriggerMenu|SMK|Release|L1 PSK|HLT PSK|BGS|TriggerRates', 'Trigger information'),
640 ('SHIFTOFL:', 'Data quality (SHIFTOFL)'),
641 ('LBSUMM:', 'Data quality (LBSUMM)')
642 ]
643
644 order = []
645 for (p,hdesc) in patterns:
646 matchedpositions = [idx for (idx,head) in enumerate(Run.headerkeys()) if re.match(p,head)]
647
648 if matchedpositions:
649 order += [(
min(matchedpositions),
max(matchedpositions),hdesc)]
650 order.sort()
651
652 mergeempty = True
653 if len(order)>0:
654 current=0
655 for th in order:
656 if mergeempty:
657 if th[0]>current:
658 secondheader += '<th colspan="%s"></th>' % (th[0]-current)
659 else:
660 for x in range(th[0]-current):
661 secondheader += '<th></th>'
662 secondheader += '<th colspan="%s">%s</th>' % (th[1]-th[0]+1,th[2])
663 current=th[1]+1
664 if len(Run.headerkeys())>current:
665 if mergeempty:
666 secondheader += '<th colspan="%s"></th>' % (len(Run.headerkeys())-current)
667 else:
668 for x in range(len(Run.headerkeys())-current):
669 secondheader += '<th></th>'
670 secondheader = "<tr>%s</tr>" % secondheader
671
672
673 s = '<thead>' + secondheader + s + '</thead>\n'
674
675
676
677
678 if any([k for k in Run.ShowOrder if "olc:lumi" in k.ResultKey]):
679 boxcontent = '<font color="#AA0000">Click to enlarge figure and to obtain online integrated luminosity versus LB</font>'
680 Run.addGlobalToolTip("OLCLumi", boxcontent)
681
682
683 if any([k for k in Run.ShowOrder if "ofllumi" in k.ResultKey]):
684 boxcontent = '<font color="#AA0000">Click to obtain offline integrated luminosity versus LB</font>'
685 Run.addGlobalToolTip("OFLLumi", boxcontent)
686
687
688 if any([k for k in Run.ShowOrder if "bs:" in k.ResultKey]):
689 boxcontent = '<font color="#AA0000">Click to obtain %s beamspot versus LB</font>' % (Run.BeamspotSource.split()[0])
690 Run.addGlobalToolTip("OFLBS", boxcontent)
691
692
693 if any([k for k in Run.ShowOrder if "BPM" == k.ResultKey]):
694 boxcontent = '<font color="#AA0000">Click to enlarge figure</font>'
695 Run.addGlobalToolTip("BPM", boxcontent)
696
697
698 if any([k for k in Run.ShowOrder if "lhc:fillnumber" in k.ResultKey]):
699 boxcontent = '<font color="#AA0000">Click to enlarge figure</font>'
700 Run.addGlobalToolTip("LHCSummary", boxcontent)
701
702 else:
703 s = ''
704 for lll in [1,2]:
705 if Run.showrunnr:
706 if lll==0:
707 s += '%-*s %*s ' % (_fW['Run'],'Run',_fW['NLB'],'#LB')
708 if lll==1:
709 s += '%-*s %*s ' % (_fW['Run'],' ',_fW['NLB'],' ')
710 s+=" "
711 if Run.showtime:
712 hstr = 'Start and endtime (%s)' % QC.localStr()
713 if lll==0:
714 s += '%*s ' %(_fW['Time'],hstr)
715 if lll==1:
716 s += '%*s ' %(_fW['Time'],' ')
717 if Run.showduration:
718 if lll==0:
719 s += '%*s ' % (10,'Duration')
720 if lll==1:
721 s += '%*s ' % (10,' ')
722 for k in Run.SortedShowOrder():
723 if k.Type == DataKey.STREAM:
724 w =
max(len(k.Header)-k.Header.find(
'_'),_fW[
'Stream'])
725 if lll==0:
726 s += '%*s ' % (w,k.Header[4:k.Header.find('_')])
727 if lll==1:
728 s += '%*s ' % (w,k.Header[k.Header.find('_')+1:])
729 else:
730 w = 10
731 if k in _fW:
732 w = _fW[k.ResultKey]
733 if lll==0:
734 s += '%*s ' % (w,k.Header)
735 if lll==1:
736 s += '%*s ' % (w,' ')
737 if lll==0:
738 s+='\n'
739 return s
740
std::vector< std::string > split(const std::string &s, const std::string &t=":")