aboutsummaryrefslogtreecommitdiff
path: root/src/fit.c
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2019-05-23 11:22:15 -0400
committertlatorre <tlatorre@uchicago.edu>2019-05-23 11:22:15 -0400
commitf332b293430d5641575917686d7dc128c309acf5 (patch)
treec775fc4b94d7c2ad5812bc1c125d92c2fc7c8772 /src/fit.c
parent3ecd79253ca96645cc670b3e0ad7ee03d1bb9161 (diff)
downloadsddm-f332b293430d5641575917686d7dc128c309acf5.tar.gz
sddm-f332b293430d5641575917686d7dc128c309acf5.tar.bz2
sddm-f332b293430d5641575917686d7dc128c309acf5.zip
add zdab-cat
This commit adds a new program called zdab-cat which is kind of like fit, but just produces the YAML output without actually fitting anything.
Diffstat (limited to 'src/fit.c')
-rw-r--r--src/fit.c85
1 files changed, 3 insertions, 82 deletions
diff --git a/src/fit.c b/src/fit.c
index 2c8c544..2e2fee3 100644
--- a/src/fit.c
+++ b/src/fit.c
@@ -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.