{ *************************************************************************** } MODULE mod_handle_thresholds ; { Created 8-MAY-1992 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE } { *************************************************************************** } INCLUDE mod_common_global_flags, mod_def_hardware_tables, mod_def_physics_tables, mod_handle_tracing, mod_handle_cat_cards, mod_handle_fmln, mod_common_hard_io ; {from the TRICS hardware IO library } { *************************************************************************** } EXPORT set_energy_threshold, {PROCEDURE set an energy threshold } set_count_threshold ; {PROCEDURE set a count } { *************************************************************************** } IMPORT status_type, ok,{already_done,}io_failure, {from module MOD_COMMON_GLOBAL_FLAGS } trace_info,{trace_warn,}trace_error,{from module MOD_HANDLE_TRACING } inline_tracing, {from module MOD_HANDLE_TRACING } handle_trc_inf, {from module MOD_HANDLE_TRACING } {handle_trc_wrn,} {from module MOD_HANDLE_TRACING } handle_trc_err, {from module MOD_HANDLE_TRACING } threshold_reference_set_number, {from module MOD_DEF_HARDWARE_TABLES } threshold_comparison_type, EMEt_cmp, TOTEt_cmp, Global_EMEt, Global_EML2, Global_HDEt, Global_HDL2, Global_TotEt, Global_TotL2, Global_Px, global_energy_thresholds, {from module MOD_DEF_HARDWARE_TABLES } Thresh_EMEt, Thresh_HDEt, Thresh_TotEt, Thresh_EML2, Thresh_HDL2, Thresh_TotL2, Thresh_MisPt, {from module MOD_DEF_HARDWARE_TABLES } cat3_EM_Et_t3, cat3_EM_L2_t3, cat3_HD_Et_t3, cat3_HD_L2_t3, cat2_EM_cnt_t3, cat2_TOT_cnt_t3, {from module MOD_DEF_HARDWARE_TABLES } cat3_TOT_Et_t4, cat3_TOT_L2_t4, {from module MOD_DEF_HARDWARE_TABLES } fmln_compare, {from module MOD_DEF_HARDWARE_TABLES } energy_threshold, {from module MOD_DEF_PHYSICS_TABLES } count_threshold, {from module MOD_DEF_PHYSICS_TABLES } tree_offset, {from module MOD_DEF_PHYSICS_TABLES } Energy_MeV_per_count, {from module MOD_DEF_PHYSICS_TABLES } update_cat2_threshold, {from module MOD_HANDLE_CAT_CARDS } update_cat3_threshold, {from module MOD_HANDLE_CAT_CARDS } update_fmln_threshold, {from module MOD_HANDLE_FMLN } cbus_param_list ; {from module MOD_COMMON_HARD_IO } { *************************************************************************** } VAR tag : VARYING_STRING(8) := 'HTH/ODB%' ; { *************************************************************************** } { *************************************************************************** } PROCEDURE set_energy_threshold ( tagext : VARYING_STRING(8) := '' ; thrshtyp : global_energy_thresholds ; thrshnum : INTEGER ; thrsheng : INTEGER ; iopar :^cbus_param_list ; VAR status : [OPTIONAL] status_type ) ; VAR io_status : status_type ; thrshcnt : INTEGER ; BEGIN IF PRESENT(status) THEN status := ok ; energy_threshold[thrshtyp,thrshnum].status.initialized := FALSE ; {translate thrshold value from MeV to counts} CASE thrshtyp OF Thresh_EMEt : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_EMEt] ; Thresh_HDEt : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_HDEt] ; Thresh_TotEt : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_TOTEt] ; Thresh_EML2 : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_EML2] ; Thresh_HDL2 : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_HDL2] ; Thresh_TotL2 : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_TOTL2] ; Thresh_MisPt : thrshcnt := thrsheng DIV Energy_MeV_per_count[Global_Px] ; END ; IF ( inline_tracing(trace_info) <> 0 ) THEN handle_trc_inf ( TAG := tag + tagext, MESSAGE := ' Setting ' + CONVERT(STRING,thrshtyp) + ' #' + CONVERT(STRING,thrshnum) + ' to ' + CONVERT(STRING,thrshcnt) + ' counts' ); {correct for tree ofsset} CASE thrshtyp OF Thresh_EMEt : thrshcnt := thrshcnt + tree_offset[Global_EMEt] ; Thresh_HDEt : thrshcnt := thrshcnt + tree_offset[Global_HDEt] ; Thresh_TotEt : thrshcnt := thrshcnt + tree_offset[Global_TOTEt] ; Thresh_EML2 : thrshcnt := thrshcnt + tree_offset[Global_EML2] ; Thresh_HDL2 : thrshcnt := thrshcnt + tree_offset[Global_HDL2] ; Thresh_TotL2 : thrshcnt := thrshcnt + tree_offset[Global_TOTL2] ; Thresh_MisPt : thrshcnt := thrshcnt + 0 ; END ; {use proper routine and proper card} CASE thrshtyp OF Thresh_EMEt : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_EM_Et_t3[0]), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_HDEt : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_HD_Et_t3[0]), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_TotEt : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_TOT_Et_t4[0]), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_EML2 : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_EM_L2_t3), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_HDL2 : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_HD_L2_t3), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_TotL2 : update_cat3_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat3_TOT_L2_t4), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; Thresh_MisPt : update_fmln_threshold ( TAGEXT := tagext, CARD := ADDRESS(fmln_compare), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; END ; {return to MeV for round off} CASE thrshtyp OF Thresh_EMEt : thrsheng := Energy_MeV_per_count[Global_EMEt] * ( thrshcnt - tree_offset[Global_EMEt] ) ; Thresh_HDEt : thrsheng := Energy_MeV_per_count[Global_HDEt] * ( thrshcnt - tree_offset[Global_HDEt] ) ; Thresh_TotEt : thrsheng := Energy_MeV_per_count[Global_TOTEt] * ( thrshcnt - tree_offset[Global_TOTEt] ) ; Thresh_EML2 : thrsheng := Energy_MeV_per_count[Global_EML2] * ( thrshcnt - tree_offset[Global_EML2] ) ; Thresh_HDL2 : thrsheng := Energy_MeV_per_count[Global_HDL2] * ( thrshcnt - tree_offset[Global_HDL2] ) ; Thresh_TotL2 : thrsheng := Energy_MeV_per_count[Global_TOTL2] * ( thrshcnt - tree_offset[Global_TOTL2] ) ; Thresh_MisPt : thrsheng := Energy_MeV_per_count[Global_Px] * thrshcnt ; END ; energy_threshold[thrshtyp,thrshnum].value := thrsheng ; IF ( io_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Programming ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) ) ; IF PRESENT(status) THEN status := io_status ; END ; END ; { *************************************************************************** } { *************************************************************************** } PROCEDURE set_count_threshold ( tagext : VARYING_STRING(8) := '' ; thrshtyp : threshold_comparison_type ; ref_num : threshold_reference_set_number ; thrshnum : INTEGER ; thrshcnt : INTEGER ; iopar :^cbus_param_list ; VAR status : [OPTIONAL] status_type ) ; VAR io_status : status_type ; BEGIN IF PRESENT(status) THEN status := ok ; count_threshold[thrshtyp,ref_num,thrshnum].status.initialized := FALSE ; IF ( inline_tracing(trace_info) <> 0 ) THEN handle_trc_inf ( TAG := tag + tagext, MESSAGE := ' Setting ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) + ' to ' + CONVERT(STRING,thrshcnt) + ' Twr(s)' ) ; {use proper routine adn proer card} CASE thrshtyp OF EMEt_cmp : update_cat2_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat2_EM_cnt_t3[ref_num]), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; TotEt_cmp : update_cat2_threshold ( TAGEXT := tagext, CARD := ADDRESS(cat2_TOT_cnt_t3[ref_num]), COMP_NUM := thrshnum, COUNT_THRESHOLD := thrshcnt, IOPAR := iopar, STATUS := status) ; END ; count_threshold[thrshtyp,ref_num,thrshnum].value := thrshcnt ; IF ( io_status = io_failure ) THEN BEGIN IF ( inline_tracing(trace_error) <> 0 ) THEN handle_trc_err ( TAG := tag + tagext, MESSAGE := ' Failure Programming ' + CONVERT(STRING,ref_num) + ' ' + CONVERT(STRING,Thrshtyp) + ' #' + CONVERT(STRING,thrshnum) + ' to ' + CONVERT(STRING,thrshcnt) + ' Twr(s)' ) ; IF PRESENT(status) THEN status := io_status ; END ; END ; { *************************************************************************** } { *************************************************************************** } END.