aboutsummaryrefslogtreecommitdiff
path: root/src/event.h
blob: 4ebb14c6fa24096caafd5ab03f488c0635ad8d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright (c) 2019, Anthony Latorre <tlatorre at uchicago>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.

 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.

 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef EVENT_H
#define EVENT_H

#include <stdint.h>
#include "pmt.h"

/* Bitmasks for the various PMT flags. */
#define PMT_FLAG_DIS    0x1
#define PMT_FLAG_DQXX   0x2
#define PMT_FLAG_CHARGE 0x4 /* PMT charge status word is non-zero, which means both QHS and QLX are either bad or railed. */

/* Struct to hold all data from a single event used for fitting. */

typedef struct pmt_hit {
    /* Set to 1 if the PMT was hit. */
    int hit;
    /* ECA calibrated time (ns). */
    float ept;
    /* Time in nano-secs relative to event T0 (ns). */
    float t;
    /* ECA calibrated QHL (pedestal subtracted). */
    float ehl;
    /* ECA calibrated QHL (pedestal subtracted). */
    float ehs;
    /* ECA calibrated QLX (pedestal subtracted). */
    float elx;
    /* Best charge. */
    float q;
    /* Integrated charge. */
    float qhl;
    /* Short-time integrated charge. */
    float qhs;
    /* Low-gain integrated charge. */
    float qlx;
    /* Uncalibrated high-gain, long integration charge. */
    uint16_t qihl;
    /* Uncalibrated high-gain, short integration charge. */
    uint16_t qihs;
    /* Uncalibrated low-gain, long integration charge. */
    uint16_t qilx;
    /* Bitmask used to disqualify hits from the likelihood calculation. See the
     * PMT_FLAG_* bitmasks above. */
    int flags;
    /* Set of 1-bit PMT flags. See the KPF_* bitmasks in zdab_utils.h. */
    int pf;
    /* Non-walk corrected PMT time. */
    float pt1;
} pmt_hit;

typedef struct event {
    int run;
    /* Global trigger time in ns. */
    double trigger_time;
    /* Number of hit PMTs without flags. */
    int nhit;
    /* Global trigger ID. */
    uint32_t gtid;
    /* Trigger word. See trigger_mask_bits.inc. */
    uint32_t trigger_type;
    /* Date (format: yyyymmdd) */
    uint32_t dte;
    /* Time (format: hhmmsscc - cc is centisec). */
    uint32_t hmsc;
    pmt_hit pmt_hits[MAX_PMTS];
} event;

#endif