diff options
Diffstat (limited to 'src/fit.c')
-rw-r--r-- | src/fit.c | 85 |
1 files changed, 3 insertions, 82 deletions
@@ -57,9 +57,9 @@ char *GitDirty(void); static int stop = 0; static nlopt_opt opt; -#define EV_RECORD 0x45562020 -#define MCTK_RECORD 0x4d43544b -#define MCVX_RECORD 0x4d435658 +#define EV_RECORD 0x45562020 // 'EV ' +#define MCTK_RECORD 0x4d43544b // 'MCTK' +#define MCVX_RECORD 0x4d435658 // 'MCVX' char *flikelihood; @@ -5812,85 +5812,6 @@ void sigint_handler(int dummy) stop = 1; } -size_t get_nhit(event *ev) -{ - /* Returns the number of PMT hits in event `ev`. - * - * Note: Only hits on normal PMTs which aren't flagged are counted. */ - size_t i, nhit; - - nhit = 0; - for (i = 0; i < MAX_PMTS; i++) { - if (ev->pmt_hits[i].flags || pmts[i].pmt_type != PMT_NORMAL) continue; - - if (!ev->pmt_hits[i].hit) continue; - - nhit++; - } - - return nhit; -} - -int get_event(zebraFile *f, event *ev, zebraBank *bev) -{ - /* Read all the PMT banks from the zebra file and update `ev`. - * - * Returns 0 on success, -1 on error. */ - int i, rv; - PMTBank bpmt; - zebraBank b; - int id, crate, card, channel; - - 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]); - - 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); - - if (rv) { - fprintf(stderr, "error getting PMT bank: %s\n", zebra_err); - return -1; - } - } - - ev->nhit = get_nhit(ev); - - return 0; -} - void sprintf_particle_string(int *id, size_t n, char *str) { /* Convert a list of particle id codes to a string. |