code: def write_loudest_events(page, bins, onsource=False):
  
      
  
      th = ['']+['Mchirp %s - %s' % tuple(bin) for bin in bins]
      td = []
  
      plots = ['BestNR','SNR']
  
      if onsource:
          trial = 'ONSOURCE'
      else:
          trial = 'OFFTRIAL_1'
  
      for pTag in plots:
          row = pTag.lower()
          d = [pTag]
          for bin in bins:
              b = '%s_%s' % tuple(bin)
              plot = markup.page()
              p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
              plot.a(href=p, title="FAP versus %s" % pTag)
              plot.img(src=p)
              plot.a.close()
              d.append(plot())
          td.append(d)
  
      row = 'snruncut'
      d = ['SNR after cuts <br> have been applied']
      for bin in bins:
          b = '%s_%s' % tuple(bin)
          plot = markup.page()
          p = "%s/efficiency/%s_vs_fap_%s.png" % (trial, row, b)
          plot.a(href=p, title="FAP versus %s" % pTag)
          plot.img(src=p)
          plot.a.close()
          d.append(plot())
      td.append(d)
  
      page = write_table(page, th, td)
  
      page.add('For more details on the loudest offsource events see')
      page.a(href='%s/efficiency/loudest_offsource_trigs.html' % (trial))
      page.add('here.')
      page.a.close()
  
  
      return page
docs: Write injection chisq plots to markup.page object page