aboutsummaryrefslogtreecommitdiff
path: root/src/zdab_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/zdab_utils.h')
-rw-r--r--src/zdab_utils.h215
1 files changed, 215 insertions, 0 deletions
diff --git a/src/zdab_utils.h b/src/zdab_utils.h
index 5b5fe96..d4411d9 100644
--- a/src/zdab_utils.h
+++ b/src/zdab_utils.h
@@ -23,6 +23,8 @@
#include "event.h"
#include "zebra.h"
+extern char zdab_err[256];
+
// the builder won't put out events with NHIT > 10000
// (note that these are possible due to hardware problems)
// but XSNOED can write an event with up to 10240 channels
@@ -172,6 +174,210 @@
/* Links for the MCTK bank. */
#define KMCTK_MCVX 1
+/* Structural links for the FT bank. */
+#define KFT_FTN 19 /* Not used; FTN (QPDF fitter for the NCD Phase) does not produce a ZEBRA bank. */
+#define KFT_FTA 18 /* Attenuation Fitter */
+#define KFT_FTC 17 /* Stopping Muon */
+#define KFT_FTZ 16 /* Time-only version of FTI */
+#define KFT_FTY 15 /* Charge-only version of FTI */
+#define KFT_FTH 14 /* Hough Fitter (not yet implemented) */
+#define KFT_FTI 13 /* Muon "Impact parameter" fitter */
+#define KFT_FTK 12 /* Energy fitter */
+#define KFT_FTR 11 /* TRack fitter */
+#define KFT_FTU 10 /* QPDF fitter */
+#define KFT_FTP 9 /* Path fitter */
+#define KFT_FTM 8 /* Muon fitter */
+#define KFT_FTG 7 /* Grid fitter */
+#define KFT_FTQ 6 /* Quad fitter */
+#define KFT_FTT 5 /* Time fitter */
+#define KFT_FTE 4 /* Elastic fitter */
+#define KFT_FT3 3 /* User fitter 3 */
+#define KFT_FT2 2 /* User fitter 2 */
+#define KFT_FT1 1 /* User fitter 1 */
+
+/* Structural links for FTX bank. */
+#define KFTX_FTXV 1 /* Link to first fit vertex. */
+#define KFTX_FTXA 2 /* Link to fit analysis bank. */
+
+/* Structural links for FTXA bank. */
+#define KFTXA_FTXC 1 /* Link to Classifier Parameters bank */
+#define KFTXA_FTXR 2 /* Link to FTXR bank */
+#define KFTXA_FTXK 3 /* Link to FTXK bank */
+#define KFTXA_FTXP 4 /* Link to FTXP bank */
+
+/* Structural links for FTXV bank. */
+#define KFTXV_FTXT 1 /* Link to first fit track. */
+
+typedef struct RSPBank {
+ /* Optical response for this event. */
+ float optical_response;
+ float nwin; /* Number of in-time hits. */
+ float nwin2; /* Total number of in-time hits (MC only). */
+ float ndark; /* Average number of noise hits in window. */
+ float neff; /* Effective hits, see note 2. */
+ float ncor; /* Corrected hits, see note 3. */
+ float ncormc; /* Scaled corrected hits, see note 4. */
+ float nonline; /* Number of on-line tubes. */
+ float ncal; /* Number of calibratable tubes, see note 5. */
+ float nefficient; /* Number of tubes with efficiency > 0, see note 5. */
+ float nworking; /* Number of working tubes, see note 5. */
+ float ene; /* Estimated energy in MeV. */
+ float uncertainty; /* Uncertainty on above. */
+ float quality; /* Quality of energy calibration. */
+ float r_d2o; /* D2O contribution to response. */
+ float r_acr; /* Acrylic contribution to response. */
+ float r_h2o; /* H2O contribution to response. */
+ float r_fresnel; /* Fresnel scattering contribution to response, see note 6. */
+ float r_mpe; /* MPE contribution to response. */
+ float r_pmtr; /* PMT response contribution to response. */
+ float r_eff; /* PMT efficiency contribution to response. */
+ float drift; /* Scale drift correction */
+ float nhits; /* Total number of working inward-looking PMTs which have fired in this event. */
+ uint32_t fit_idx; /* Index of vertex fitter used. */
+ float nwin_allq; /* Number of working inward looking tubes in the prompt time window which have fired, without the software charge threshold. See note 3. */
+ float nhits_allq; /* Number of working inward looking tubes which have fired without the software charge threshold. See note 3. */
+ float nhits_dqxx; /* Number of online inword looking tubes which have fired. See note 3. */
+ float nwin_pt; /* In-time hits with walk-correction and charge cut. */
+ float tshift; /* Time shift between walk corrected and non-corrected times. */
+ float pmt_response; /* RSP PMT response. */
+ float alt_energy; /* Alternate RSP energy see note 8. */
+ float nckv; /* Alternate RSP Ncor equivalent. */
+ float resolution; /* RSP resolution estimate, not yet defined. */
+ float fom; /* RSP figure of merit, not yet defined. */
+ float ncd_shad_cor; /* NCD shadow correction, not yet defined. */
+ float rlambda; /* New energy optical response */
+ float omega; /* New energy solid angle response */
+ float ckvprob; /* New energy cerenkov distribution response */
+ float chaneff; /* New energy channel efficiency response */
+ float pmteff; /* New energy relative PMT efficiency response */
+ float mpe; /* New energy MPE response */
+ float spare1;
+ float spare2;
+ float spare3;
+ float spare4;
+ float spare5;
+ float spare6;
+ float spare7;
+ float spare8;
+ float spare9;
+} RSPBank;
+
+typedef struct FTPTBank {
+ /* Fitted X direction cosine. */
+ float u;
+ /* Fitted Y direction cosine. */
+ float v;
+ /* Fitted Z direction cosine. */
+ float w;
+ /* Error on fitted U. */
+ float du;
+ /* Error on fitted V. */
+ float dv;
+ /* Error on fitted W. */
+ float dw;
+} FTPTBank;
+
+typedef struct FTPVBank {
+ /* Fitted X. */
+ float x;
+ /* Fitted Y. */
+ float y;
+ /* Fitted Z. */
+ float z;
+ /* Fitted time. */
+ float t;
+ /* Error on fitted X. */
+ float dx;
+ /* Error on fitted Y. */
+ float dy;
+ /* Error on fitted Z. */
+ float dz;
+ /* Error on fitted time. */
+ float dt;
+} FTPVBank;
+
+typedef struct FTXKBank {
+ /* LH value at the best fit point. */
+ float prob;
+ /* Total energy of the event. */
+ float energy;
+ /* Lower uncertainty on the energy (MeV). */
+ float ene_merr;
+ /* Upper uncertainty on the energy (MeV). */
+ float ene_perr;
+ /* Number of hits inside the FTK time cut. */
+ float neff;
+ /* Probability of a direct photon being detected. */
+ float dir_scale;
+ /* MPE correction term at the mean of the cerenkov photons distribution. */
+ float dir_scale_sq;
+ /* Probability of a scattered photon being detected. */
+ float scat_scale;
+ /* Probability of detecting a PMT reflection photon. */
+ float refl_scale;
+ /* Probability of detecting a AV reflection photon which reflects off the
+ * first AV boundary. */
+ float refl_av1_scale;
+ /* Probability of detecting a AV reflection photon which reflects off the
+ * second AV boundary. */
+ float refl_av2_scale;
+ /* Probability of detecting a NCD reflection photon. */
+ float refl_ncd_scale;
+ float spare1;
+ float spare2;
+ float spare3;
+ float spare4;
+ float spare5;
+} FTXKBank;
+
+typedef struct FTKBank {
+ /* Fitter method. */
+ uint32_t method;
+ /* Return code. */
+ uint32_t retc;
+ /* Number of PMT hits available. */
+ uint32_t pmt_avail;
+ /* Number of PMT hits used. */
+ uint32_t pmt_used;
+ /* Number of early PMT hits rejected. */
+ uint32_t early;
+ /* Number of late PMT hits rejected. */
+ uint32_t late;
+ /* Number of fit iterations. */
+ uint32_t iter;
+ /* Fit probability. */
+ float prob;
+ /* Total energy of the event. */
+ float energy;
+ /* Lower uncertainty on the energy (MeV). */
+ float ene_merr;
+ /* Upper uncertainty on the energy (MeV). */
+ float ene_perr;
+ /* Number of hits inside the FTK time cut. */
+ float neff;
+ /* Probability of a direct photon being detected. */
+ float dir_scale;
+ /* MPE correction term at the mean of the cerenkov photons distribution. */
+ float dir_scale_sq;
+ /* Probability of a scattered photon being detected. */
+ float scat_scale;
+ /* Probability of detecting a PMT reflection photon. */
+ float refl_scale;
+ /* Probability of detecting a AV reflection photon which reflects off the
+ * first AV boundary. */
+ float refl_av1_scale;
+ /* Probability of detecting a AV reflection photon which reflects off the
+ * second AV boundary. */
+ float refl_av2_scale;
+ /* Probability of detecting a NCD reflection photon. */
+ float refl_ncd_scale;
+ float spare1;
+ float spare2;
+ float spare3;
+ float spare4;
+ float spare5;
+} FTKBank;
+
typedef struct MCGNBank {
/* Particle id. */
uint32_t id;
@@ -423,6 +629,15 @@ typedef struct PMTBank {
float qrc;
} PMTBank;
+int get_ftpv(zebraFile *f, zebraBank *ev, FTPVBank *bftpv);
+int get_ftxk(zebraFile *f, zebraBank *ev, FTXKBank *bftxk);
+int get_rsp(zebraFile *f, zebraBank *ev, RSPBank *brsp);
+
+void unpack_rsp(uint32_t *data, RSPBank *b);
+void unpack_ftpt(uint32_t *data, FTPTBank *b);
+void unpack_ftpv(uint32_t *data, FTPVBank *b);
+void unpack_ftxk(uint32_t *data, FTXKBank *b);
+void unpack_ftk(uint32_t *data, FTKBank *b);
void unpack_mcgn(uint32_t *data, MCGNBank *b);
void unpack_mcvx(uint32_t *data, MCVXBank *b);
void unpack_mctk(uint32_t *data, MCTKBank *b);