Пример #1
0
def init_chip(TDC, conn, chip, pktime, gain, thresh):

    if (pktime == 10):
        os.system("cd pasttrec_ctrl; TDC=" + TDC +
                  " CONN={:d} CHIP={:d} ./spi blue_settings_pt10_g1_thr127".
                  format(conn, chip))
    if (pktime == 15):
        os.system("cd pasttrec_ctrl; TDC=" + TDC +
                  " CONN={:d} CHIP={:d} ./spi black_settings_pt15_g1_thr127".
                  format(conn, chip))
    if (pktime == 20):
        os.system("cd pasttrec_ctrl; TDC=" + TDC +
                  " CONN={:d} CHIP={:d} ./spi black_settings_pt20_g1_thr127".
                  format(conn, chip))

    os.system("cd pasttrec_ctrl; TDC=" + TDC +
              " CONN={:d} CHIP={:d} pktime={:d} gain={:d} ./set_gain_pktime".
              format(conn, chip, pktime, gain))
    os.system(
        "cd pasttrec_ctrl; TDC=" + TDC +
        " CONN={:d} CHIP={:d} ./threshold {:d}".format(conn, chip, thresh))
    board_info = db.find_board_by_tdc_connector(TDC, conn)
    board_name = board_info["name"]
    board_channels = board_info["channels"]
    calib = db.get_calib_json_by_name(board_name)
    if ("baselines" in calib):
        board_baselines = calib["baselines"]
        channels = board_channels[0:9]
        values = board_baselines[0:9]
        if chip == 1:
            channels = board_channels[8:17]
            values = board_baselines[8:17]
        set_all_baselines(TDC, channels, values)
    return
Пример #2
0
def gen_baseline_report(board_name,**kwargs):

  import pandas as pd
  import numpy as np
  calib_json = db.get_calib_json_by_name(board_name,**kwargs)
  if "baselines" in calib_json:
    baselines = calib_json["baselines"]
    baseline_mean = baselines
    if "baseline_mean" in calib_json:
      baseline_mean = calib_json["baseline_mean"]
    baseline_stddev = calib_json["baseline_stddev"]
    ch_error = calib_json["ch_error"]
    bl_range = calib_json["bl_range"]
    board_info = db.find_board_by_name(board_name)
    channels = board_info["channels"]
    noise_scan_raw = calib_json["noise_scan_raw"]
    noise_scan_x = calib_json["bl_range"]

    df = pd.DataFrame(
       np.transpose(np.array([board_info["board_chan"],baselines,baseline_mean,baseline_stddev,ch_error])),
      index= channels, columns=["board_chan","baseline","bl_mean","bl_stddev","error"]
    )
    report = df.to_string()
    report += "\n\n\n"
    report += df.describe().to_string()
    report += "\n\n\n"
    report += "\n\n\n"
    board_chan = 0
    for scan in noise_scan_raw:
      report += misc.ascii_hist(scan,xdata=noise_scan_x,title="PT "+board_name+" ch "+str(board_chan).rjust(2))
      report += "\n"*10
      board_chan += 1
    return report
  else:
    return 0
Пример #3
0
def dialog_slow_control_test(board_list):

  d = Dialog(dialog="dialog")
  d.set_background_title("view boards")

  choices = []
  info_format = "{:>6s}  {:>4s}  {:>6s}  {:>6s}  {:>6s}  {:>6s}"
  info = info_format.format("TDC", "CONN", "BL cal", "t1 cal", "active", "SloCon")
  choices += [("board",info)]


  test_results = ptc.slow_control_test_boards(board_list)
  
  for board_name in board_list:
    board_info = db.find_board_by_name(board_name)
    board_calib = db.get_calib_json_by_name(board_name)
    
    bl_calib = " - "
    if board_info["baseline_is_calibrated"] == 1:
      bl_calib = "yes"
    elif board_info["baseline_is_calibrated"] == -1:
      bl_calib = "err"


    t1_calib = " - "
    if board_info["t1_is_calibrated"]:
      t1_calib = "yes"

    active = " - "
    if board_info["active"]:
      active = "yes"

    sctest = "err"
    if test_results[board_name] == 1:
      sctest = " ok"
  
    info = info_format.format(board_info["tdc_addr"], str(board_info["tdc_connector"]),  bl_calib, t1_calib, active, sctest       )
    choices += [(board_name,info)]
  
  

  code, tag = d.menu("slow control test - active boards",
                     choices= choices, height="30", menu_height="28", width="70")
Пример #4
0
        ## calib t1 offsets ##
        if tag == "12":
            code_9, choice_9 = dbd.dialog_board_list()
            if code_9 == d.DIALOG_OK:
                board_name = choice_9
                board_info = db.find_board_by_name(board_name)
                #if board_info["baseline_is_calibrated"]:
                d.msgbox(
                    "1. Make sure DABC is running. 2. Supply the same pulse to all inputs of board {:s} simultaneously to calibrate t1 offsets"
                    .format(board_name))
                td.calib_t1_offsets_of_board(board_name)
                #else:
                #  d.msgbox("t1 calibration not possible. Please calibrate baselines first, or the walk effect might skew your t1 calibration.")

                calib = db.get_calib_json_by_name(board_name)
                board_t1_offsets = db.get_t1_offsets_of_board(board_name)
                t1_calib_efficiency = calib["t1_calib_efficiency"]
                code_17, text = dbd.dialog_editbox(
                    "## board t1 offsets:\n\n" +
                    json.dumps(board_t1_offsets, indent=2, sort_keys=True) +
                    "\n\n## board t1 calib efficiency:\n\n" +
                    json.dumps(t1_calib_efficiency, indent=2, sort_keys=True))

        ## clear t1 offsets ##
        if tag == "18":
            code_9, choice_9 = dbd.dialog_board_list()
            if code_9 == d.DIALOG_OK:
                board_name = choice_9
                db.clear_t1_offsets_of_board(board_name)
                d.msgbox("cleared")
Пример #5
0
def dialog_board_list(**kwargs):

  width = str(100)
  height = str(30)
  menu_height = str(28)
  list_height = menu_height
  
  checklist = kwargs.get("checklist","")
  selection = kwargs.get("selection","")

  check_enable  = False
  check_standby = False
  check_select = False
  if checklist == "enable":
    check_enable = True
  if checklist == "standby":
    check_standby = True
  if checklist == "select":
    check_select = True

  empty_selection = False
  if selection == "none":
    empty_selection = True
  


  d = Dialog(dialog="dialog")
  d.set_background_title("view boards")
  if check_enable:
    d.set_background_title("enable/disable boards")
  if check_standby:
    d.set_background_title("set boards to standby")
  if check_select:
    d.set_background_title("select one or more boards")

  choices = []
  info_format = "{:>6s}  {:>4s}  {:>7s}  {:>5}  {:>12s}  {:>6s}  {:>6s}  {:>6s}  {:>7s}"
  info = info_format.format("TDC", "CONN","chamber","layer","FPC ABCD", "BL cal", "t1 cal", "active","standby")

  if check_enable or check_standby or check_select:
    choices += [("board",info, False)]
  else:
    choices += [("board",info)]

  board_list = db.board_list()
  
  for board_name in board_list:
    board_info = db.find_board_by_name(board_name)
    board_calib = db.get_calib_json_by_name(board_name)
    
    bl_calib = " - "
    if board_info["baseline_is_calibrated"] == 1:
      bl_calib = "yes"
    elif board_info["baseline_is_calibrated"] == -1:
      bl_calib = "err"


    t1_calib = " - "
    if board_info["t1_is_calibrated"]:
      t1_calib = "yes"

    active = " - "
    active_bool = False
    if board_info["active"]:
      active = "yes"
      active_bool = True

    standby = " - "
    standby_bool = False
    if "standby" in board_info:
      if board_info["standby"]:
        standby = "yes"
        standby_bool = True
  
    info = info_format.format(
      board_info["tdc_addr"],
      str(board_info["tdc_connector"]),
      str(board_info["chamber"]),
      str(board_info["layer"]),
      str(board_info["fpc_a"]).rjust(2)+","+
      str(board_info["fpc_b"]).rjust(2)+","+
      str(board_info["fpc_c"]).rjust(2)+","+
      str(board_info["fpc_d"]).rjust(2),
      bl_calib, t1_calib, active, standby )
    if check_enable:
      if empty_selection:
        choices += [(board_name,info, False)]
      else:
        choices += [(board_name,info, active_bool)]
    elif check_standby:
      choices += [(board_name,info, standby_bool)]
    elif check_select:
      choices += [(board_name,info, False)]
    else:
      choices += [(board_name,info)]
  
  

  if check_enable:
    code, active_boards = d.checklist("enable/disable boards", choices=choices, width=width, height=height, list_height=list_height)
    if code == d.DIALOG_OK:
      for board_name in board_list:
        db.disable_board(board_name)
      for board_name in active_boards:
        if not(board_name == "board"):
          db.enable_board(board_name)

  elif check_standby:
    code, standby_boards = d.checklist("set board standby", choices= choices, width=width,height=height,list_height=list_height)
    if code == d.DIALOG_OK:
      for board_name in board_list:
        db.unset_standby_board(board_name)
      for board_name in standby_boards:
        if not(board_name == "board"):
          db.set_standby_board(board_name)
  elif check_select:
    code, selected_boards = d.checklist("select one or more boards", choices= choices, width=width,height=height,list_height=list_height)
    return code, selected_boards

  else:
    code, tag = d.menu("select a board:",
                     choices= choices ,width=width,height=height,menu_height=menu_height)
    return code, tag