aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pmt.c34
-rw-r--r--src/pmt.h3
-rw-r--r--src/zdab_utils.c77
3 files changed, 79 insertions, 35 deletions
diff --git a/src/pmt.c b/src/pmt.c
index 9d284b0..f3253e0 100644
--- a/src/pmt.c
+++ b/src/pmt.c
@@ -26,6 +26,40 @@ static int initialized = 0;
pmt pmts[MAX_PMTS];
+void get_pmt_type_string(int pmt_type, char *s)
+{
+ switch (pmt_type) {
+ case 1:
+ sprintf(s,"Normal");
+ break;
+ case 2:
+ sprintf(s,"OWL");
+ break;
+ case 3:
+ sprintf(s,"LG");
+ break;
+ case 4:
+ sprintf(s,"BUTT");
+ break;
+ case 5:
+ sprintf(s,"NECK");
+ break;
+ case 6:
+ sprintf(s,"CALIBRATION");
+ break;
+ case 10:
+ sprintf(s,"SPARE");
+ break;
+ case 11:
+ sprintf(s,"INVALID");
+ break;
+ default:
+ sprintf(s,"???");
+ }
+
+ return;
+}
+
int load_pmt_info()
{
int i, j;
diff --git a/src/pmt.h b/src/pmt.h
index 6f5cb10..3bccedb 100644
--- a/src/pmt.h
+++ b/src/pmt.h
@@ -32,7 +32,7 @@
#define PMT_LG 3
#define PMT_BUTT 4
#define PMT_NECK 5
-#define PMT_CALIBRATION 5
+#define PMT_CALIBRATION 6
#define PMT_SPARE 10
#define PMT_INVALID 11
@@ -47,6 +47,7 @@ typedef struct pmt {
extern pmt pmts[MAX_PMTS];
+void get_pmt_type_string(int pmt_type, char *s);
int load_pmt_info();
#endif
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);