diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-06-10 11:50:17 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-06-10 11:50:17 -0500 |
commit | 625dfc21d9588ec589bd28c009f56ce1d4792984 (patch) | |
tree | 28f72ae15b7cd796da6dc74f07356a84f4c30745 /src/zdab_utils.c | |
parent | 3398cdfd9f096e0f20b09746caeb48e424d85eb3 (diff) | |
download | sddm-625dfc21d9588ec589bd28c009f56ce1d4792984.tar.gz sddm-625dfc21d9588ec589bd28c009f56ce1d4792984.tar.bz2 sddm-625dfc21d9588ec589bd28c009f56ce1d4792984.zip |
update get_event() to include all PMT types
This commit updates get_event() to include OWL, LG, FECD, BUTT, and NECK tubes.
Diffstat (limited to 'src/zdab_utils.c')
-rw-r--r-- | src/zdab_utils.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/src/zdab_utils.c b/src/zdab_utils.c index 37d444c..f0651d5 100644 --- a/src/zdab_utils.c +++ b/src/zdab_utils.c @@ -22,6 +22,7 @@ #include <stdio.h> /* for fprintf() */ #include "event.h" #include "zebra.h" +#include "misc.h" size_t get_nhit(event *ev) { @@ -51,50 +52,58 @@ int get_event(zebraFile *f, event *ev, zebraBank *bev) PMTBank bpmt; zebraBank b; int id, crate, card, channel; + static int pmt_links[] = {KEV_PMT,KEV_OWL,KEV_LG,KEV_FECD,KEV_BUTT,KEV_NECK}; + static int pmt_types[] = {PMT_NORMAL,PMT_OWL,PMT_LG,PMT_CALIBRATION,PMT_BUTT,PMT_NECK}; + static char *pmt_names[] = {"PMT","OWL","LG","FECD","BUTT","NECK"}; + char pmt_type_string[256]; for (i = 0; i < MAX_PMTS; i++) { ev->pmt_hits[i].hit = 0; } - if (bev->links[KEV_PMT-1] == 0) { - /* If the PMT link is zero, we assume it's just a 0 nhit event. */ - return 0; - } - - rv = zebra_get_bank(f,&b,bev->links[KEV_PMT-1]); + for (i = 0; i < LEN(pmt_links); i++) { + if (bev->links[pmt_links[i]-1] == 0) continue; - if (rv) { - fprintf(stderr, "error getting PMT bank: %s\n", zebra_err); - return -1; - } - - while (1) { - unpack_pmt(b.data, &bpmt); - card = bpmt.pin/1024; - crate = (bpmt.pin % 1024)/32; - channel = bpmt.pin % 32; - id = crate*512 + card*32 + channel; - ev->pmt_hits[id].hit = 1; - ev->pmt_hits[id].t = bpmt.pt; - ev->pmt_hits[id].qihl = bpmt.pihl; - ev->pmt_hits[id].qihs = bpmt.pihs; - ev->pmt_hits[id].qilx = bpmt.pilx; - ev->pmt_hits[id].qhl = bpmt.phl; - ev->pmt_hits[id].qhs = bpmt.phs; - ev->pmt_hits[id].qlx = bpmt.plx; - /* Clear the PMT_FLAG_DIS bit. */ - ev->pmt_hits[id].flags &= ~PMT_FLAG_DIS; - if (bpmt.pf & KPF_DIS) - ev->pmt_hits[id].flags |= PMT_FLAG_DIS; - - if (!b.next) break; - - rv = zebra_get_bank(f,&b,b.next); + rv = zebra_get_bank(f,&b,bev->links[pmt_links[i]-1]); if (rv) { - fprintf(stderr, "error getting PMT bank: %s\n", zebra_err); + fprintf(stderr, "error getting %s bank: %s\n", pmt_names[i], zebra_err); return -1; } + + while (1) { + unpack_pmt(b.data, &bpmt); + card = bpmt.pin/1024; + crate = (bpmt.pin % 1024)/32; + channel = bpmt.pin % 32; + id = crate*512 + card*32 + channel; + ev->pmt_hits[id].hit = 1; + ev->pmt_hits[id].t = bpmt.pt; + ev->pmt_hits[id].qihl = bpmt.pihl; + ev->pmt_hits[id].qihs = bpmt.pihs; + ev->pmt_hits[id].qilx = bpmt.pilx; + ev->pmt_hits[id].qhl = bpmt.phl; + ev->pmt_hits[id].qhs = bpmt.phs; + ev->pmt_hits[id].qlx = bpmt.plx; + /* Clear the PMT_FLAG_DIS bit. */ + ev->pmt_hits[id].flags &= ~PMT_FLAG_DIS; + if (bpmt.pf & KPF_DIS) + ev->pmt_hits[id].flags |= PMT_FLAG_DIS; + + if (pmts[id].pmt_type != pmt_types[i]) { + get_pmt_type_string(pmts[id].pmt_type,pmt_type_string); + fprintf(stderr, "%i/%i/%i has PMT type %s but expected %s based on bank\n", crate, card, channel, pmt_type_string, pmt_names[i]); + } + + if (!b.next) break; + + rv = zebra_get_bank(f,&b,b.next); + + if (rv) { + fprintf(stderr, "error getting %s bank: %s\n", pmt_names[i], zebra_err); + return -1; + } + } } ev->nhit = get_nhit(ev); |