From 34b3d958d10e39da3d19d1f93b9f4330776253e1 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Mon, 23 Sep 2019 09:16:46 -0500 Subject: add sub_run variable to the events array in the HDF5 file This commit adds the sub_run variable to the ev array in the HDF5 output file and updates plot-energy to order the events using the run and sub_run variables. This fixes a potential issue where I was sorting by GTID before, but the GTID can wrap around and so isn't guaranteed to put the events in the right order. --- src/event.h | 1 + src/fit.c | 1 + src/hdf5_utils.c | 1 + src/hdf5_utils.h | 1 + src/zdab-cat.c | 2 ++ src/zdab_utils.c | 1 + src/zdab_utils.h | 2 +- 7 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/event.h b/src/event.h index 88fcbe1..fbb1658 100644 --- a/src/event.h +++ b/src/event.h @@ -73,6 +73,7 @@ typedef struct pmt_hit { typedef struct event { int run; + int sub_run; /* Global trigger time in ns. */ double trigger_time; /* Number of normal hit PMTs. */ diff --git a/src/fit.c b/src/fit.c index 056f6b0..7fdf994 100644 --- a/src/fit.c +++ b/src/fit.c @@ -6299,6 +6299,7 @@ skip_mc: if (output) { hdf5_events[nevents].run = ev.run; + hdf5_events[nevents].sub_run = ev.sub_run; hdf5_events[nevents].evn = bmc.evn; hdf5_events[nevents].gtr = ev.trigger_time; hdf5_events[nevents].nhit = ev.nhit; diff --git a/src/hdf5_utils.c b/src/hdf5_utils.c index 05d1002..2a8f396 100644 --- a/src/hdf5_utils.c +++ b/src/hdf5_utils.c @@ -102,6 +102,7 @@ int save_output(const char *output, HDF5Event *hdf5_events, size_t nevents, HDF5 */ hdf5_events_tid = H5Tcreate(H5T_COMPOUND, sizeof(HDF5Event)); H5Tinsert(hdf5_events_tid, "run", HOFFSET(HDF5Event, run), H5T_NATIVE_INT); + H5Tinsert(hdf5_events_tid, "sub_run", HOFFSET(HDF5Event, sub_run), H5T_NATIVE_INT); H5Tinsert(hdf5_events_tid, "evn", HOFFSET(HDF5Event, evn), H5T_NATIVE_INT); H5Tinsert(hdf5_events_tid, "gtr", HOFFSET(HDF5Event, gtr), H5T_NATIVE_DOUBLE); H5Tinsert(hdf5_events_tid, "nhit", HOFFSET(HDF5Event, nhit), H5T_NATIVE_INT); diff --git a/src/hdf5_utils.h b/src/hdf5_utils.h index 4f6ad32..850355f 100644 --- a/src/hdf5_utils.h +++ b/src/hdf5_utils.h @@ -13,6 +13,7 @@ * will be set to nan. */ typedef struct HDF5Event { int run; + int sub_run; int evn; double gtr; int nhit; diff --git a/src/zdab-cat.c b/src/zdab-cat.c index dfb295a..7b0b714 100644 --- a/src/zdab-cat.c +++ b/src/zdab-cat.c @@ -170,6 +170,7 @@ int main(int argc, char **argv) * instead of a MAST record. */ continue; } else { + continue; fprintf(stderr, "logical record starts with unknown bank '%s'\n", bmast.name); goto err; } @@ -323,6 +324,7 @@ skip_mc: if (output) { hdf5_events[nevents].run = ev.run; + hdf5_events[nevents].sub_run = ev.sub_run; hdf5_events[nevents].evn = bmc.evn; hdf5_events[nevents].gtr = ev.trigger_time; hdf5_events[nevents].nhit = ev.nhit; diff --git a/src/zdab_utils.c b/src/zdab_utils.c index cf1a01c..8b6cbc8 100644 --- a/src/zdab_utils.c +++ b/src/zdab_utils.c @@ -103,6 +103,7 @@ int get_event(zebraFile *f, event *ev, zebraBank *bev) unpack_ev(bev->data, &ev_bank); ev->run = ev_bank.run; + ev->sub_run = ev_bank.sub_run; ev->gtid = ev_bank.gtr_id; ev->trigger_type = ev_bank.trg_type; ev->trigger_time = ev_bank.gtr; diff --git a/src/zdab_utils.h b/src/zdab_utils.h index ce3661c..91f8898 100644 --- a/src/zdab_utils.h +++ b/src/zdab_utils.h @@ -526,7 +526,7 @@ typedef struct EVBank { /* Integrated charge in the event. */ float nph; /* Sub-run number, or -1 if unknown. Only defined for run number >= 10614. */ - uint32_t sub_run; + int32_t sub_run; /* Packed word. */ uint32_t mc_pck; /* ZDAB input/output record type, e.g. PMT, NCD, CMA, RUN, etc. */ -- cgit