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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
|
/* 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 ZDAB_UTILS
#define ZDAB_UTILS
#include "Record_Info.h"
#include <stdint.h>
#include <stdlib.h> /* for size_t */
#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
#define MAX_NHIT 10240
#ifdef SWAP_BYTES
#define SWAP_INT32(a,b) swap_int32((int32_t *)(a),(b))
#define SWAP_INT16(a,b) swap_int16((int16_t *)(a),(b))
#else
#define SWAP_INT32(a,b)
#define SWAP_INT16(a,b)
#endif
/* Links for the MCVX bank. */
#define KMCVX_MCVXG 4
#define KMCVX_MCPM 3
#define KMCVX_MCTKI 2
#define KMCVX_MCTK 1
/* Links for the MC bank. */
#define KMC_MCNS 6
#define KMC_MCNH 5
#define KMC_MCPM 4
#define KMC_EGS4 3
#define KMC_MCVX 2
#define KMC_MCGN 1
/* Status bits for the EV bank. */
#define KEV_ORPHAN 0 /* Event contains orphan data. */
#define KEV_TSLH 1 /* Event contains TSLH information. */
#define KEV_HCA 2 /* Event contains HCA information. */
#define KEV_MC_GE_ERR 3 /* Event produced from MC that had geometry errors suppressed. */
/* Links for the EV bank. */
#define KEV_NPFA 32
#define KEV_NECL 31
#define KEV_NPA 30
#define KEV_NEMG_PAR 29
#define KEV_NEMG 28
#define KEV_NES 27
#define KEV_NESG 26
#define KEV_RSP 25
#define KEV_NECK 24
#define KEV_BUTT 23
#define KEV_ANAL 22
#define KEV_FECD 21
#define KEV_LG 20
#define KEV_OWL 19
#define KEV_PMT 18
#define KEV_CL 17
#define KEV_PIF 16
#define KEV_PIT0 15
#define KEV_PIT 14
#define KEV_PIHS 13
#define KEV_PIHL 12
#define KEV_PILX 11
#define KEV_PIN 10
#define KEV_PT0 9
#define KEV_PLX 8
#define KEV_PHS 7
#define KEV_ZDAB 6
#define KEV_PF 5
#define KEV_PN 4
#define KEV_PHL 3
#define KEV_PT 2
#define KEV_FT 1
/* Status bits for the MAST bank. */
#define KMAST_PMT 1 /* PMT data. */
#define KMAST_PERM 2 /* Permanent data of any kind e.g. Run Header. */
#define KMAST_NCD 3 /* NCD data. */
#define KMAST_CMA 4 /* CMA data. */
#define KMAST_ECA 5 /* ECA data. */
#define KMAST_SUBRUN 6 /* Sub-run data, i.e. permanent bank data that is duplicated
at the start of the second and subsequent sub runs to
ensure the context is maintained across file boundaries. */
/* Links for the MAST bank. */
#define KMAST_RLOG 25 /* Runlog data. */
#define KMAST_RLAI 24 /* Runlog analysis data. */
#define KMAST_LABL 12 /* Tape label information. */
#define KMAST_CAAC 11 /* AV Status. */
#define KMAST_CAST 10 /* Manipulator status. */
#define KMAST_SOSF 9 /* LED status. */
#define KMAST_SOSX 8 /* Manipulator source status. */
#define KMAST_TRIG 7 /* Trigger information bank. */
#define KMAST_EPED 6 /* Electronics calibration pedestal bank. */
#define KMAST_RHDR 5 /* Top level run header bank. */
#define KMAST_ANAL 4 /* Analysis top level bank. */
#define KMAST_DSML 3 /* Data structure manager log bank. */
#define KMAST_MC 2 /* Monte carlo top level bank. */
#define KMAST_EV 1 /* First event trigger bank. */
/* MAST bank data words. */
#define KMAST_SNOMAN_VER 1
#define KMAST_SNOMAN_VER_ORG 2
/* Status bits for the MC Vertex bank.
*
* See http://www.lip.pt/~barros/SNO/doc/snoman/companion_frames.html. */
#define KMCVX_SRC 0x00000001 /* Source */
#define KMCVX_BOU 0x00000002 /* Boundary */
#define KMCVX_INT 0x00000004 /* Interaction */
#define KMCVX_SNK 0x00000008 /* Sink */
#define KMCVX_PSC 0x00000010 /* Pre-source */
#define KMCVX_CRE 0x00000100 /* Creation i.e. vertex creates new particle (ignoring Cerenkov photon). */
#define KMCVX_IPM 0x00000200 /* Indirect MCPM. The MCPM hit comes indirectly from the vertex. */
/* Status bits for the MC Track bank.
*
* Bits 4-17 are used to store the "history" of Cerenkov photons. The bit
* structure is the same as in the MCPM bank status word. More details are
* available on the MCPM bank page.
*
* See http://www.lip.pt/~barros/SNO/doc/snoman/companion_frames.html. */
#define KMCTK_IVX 0x00000002 /* Indirect vertex. Track does not come directly from its
supporting vertex, see Notes below. */
#define KMCTK_SPARE1 0x00000004 /* Spare (Not part of Cerenkov history) */
#define KMCTK_SPARE2 0x00000008 /* Spare (Not part of Cerenkov history) */
#define KMCTK_INDIRECT 0x00000010 /* Indirect photon. */
#define KMCTK_RSCAT 0x00000020 /* Photon was Raleigh scattered. */
#define KMCTK_PSUP_SREF 0x00000040 /* Photon had a spectral reflection from the PSUP. */
#define KMCTK_PSUP_DREF 0x00000080 /* Photon had a diffuse reflection from the PSUP. */
#define KMCTK_AV_SREF 0x00000100 /* Photon had a spectral reflection from the AV. */
#define KMCTK_AV_DREF 0x00000200 /* Photon had a diffuse reflection from the AV. */
#define KMCTK_NCD_SREF 0x00000400 /* Photon had a spectral reflection from the NCD OVL. */
#define KMCTK_NCD_DREF 0x00000800 /* Photon had a diffuse reflection from the NCD OVL. */
#define KMCTK_PMT_REF 0x00001000 /* Photon entered and then escaped the PMT code (vxpmt). */
#define KMCTK_IN_PMT 0x00002000 /* Photon was produced inside a PMT. */
#define KMCTK_THROUGH_AV 0x00004000 /* Photon passed through the AV at least once. */
/* Bit masks for the PMT flags field in the PMT bank. */
#define KPF_DIS 0x00000001
#define KPF_NOI 0x00000004
#define KPF_PRP 0x00000008
#define KPF_AFP 0x00000010
#define KPF_FECD 0x00000020
#define KPF_FT_MASK1 0x00000040
#define KPF_XT 0x04000000
#define KPF_NO_CAL 0x08000000
#define KPF_BAD_CAL 0x10000000
/* Links for the MCGN bank. */
#define KMCGN_MCTK 1
/* 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 MCBank {
/* Julian date. */
uint32_t jdy;
/* Universal time seconds. */
uint32_t ut1;
/* Universal time nanoseconds. */
uint32_t ut2;
/* Date (format: yyyymmdd). */
uint32_t dte;
/* Time (format: hhmmsscc - cc is centisec). */
uint32_t hmsc;
/* First random number seed. */
uint32_t seed1;
/* Second random number seed. */
uint32_t seed2;
/* Random number number. */
uint32_t seed_num;
/* Data type. */
uint32_t dtp;
/* SNOMAN MC version number. */
float mcver;
/* Monte Carlo event number. */
uint32_t evn;
/* Generation time in nsec (first word). */
double gtr;
/* Number of suppressed Cerenkov photon tracking errors. */
uint32_t num_ge_err;
/* The current PMT collection efficiency. */
float pmt_eff;
} MCBank;
typedef struct MCGNBank {
/* Particle id. */
uint32_t id;
/* Number of outgoing particles generated. */
uint32_t num;
/* Radiative process if any. */
uint32_t radcor_proc;
/* +1 particle brems and produces a gamma.
* -1 particle is a gamma produced by brem. */
uint32_t radcor_made_gamma;
/* Spares. */
uint32_t spare5;
uint32_t spare6;
uint32_t spare7;
uint32_t spare8;
uint32_t spare9;
uint32_t spare10;
/* Correction to total cross sections. */
float radcor_xtot;
/* Correction to differential cross sections. */
float radcor_xdif;
/* Value of exponential parameter used for generating particle start times,
* if time type IDTEX1 was selected. */
float gentim_xpar;
/* More spares. */
float spare14;
float spare15;
float spare16;
float spare17;
float spare18;
float spare19;
float spare20;
} MCGNBank;
typedef struct MCVXBank {
/* Class: = 1 Source, = 2 Boundary, = 3 Interaction, = 4 Sink
= 5 Pre-source. */
uint32_t cls;
/* Interaction code. */
uint32_t inc;
/* Position X. */
float x;
/* Position Y. */
float y;
/* Position Z. */
float z;
/* Time in ns since MC Generation time (in MC bank). */
double tim;
/* First region code. */
uint32_t rgn;
/* First physical media code. */
uint32_t idm;
/* Second region code. */
uint32_t rg2;
/* Second physical media code. */
uint32_t im2;
/* Boundary normal X (only defined if boundary status bit set). */
float bnx;
/* Boundary normal Y (only defined if boundary status bit set). */
float bny;
/* Boundary normal Z (only defined if boundary status bit set). */
float bnz;
/* Number of Cerenkov photons. Only non-zero for CBV vertex. */
uint32_t cer;
} MCVXBank;
typedef struct MCTKBank {
/* Particle id code. */
uint32_t idp;
/* Direction cosine X. */
float drx;
/* Direction cosine Y. */
float dry;
/* Direction cosine Z. */
float drz;
/* Total energy (except for neutrons where it is kinetic). */
float ene;
/* Region code. */
uint32_t rgn;
/* Physical media code. */
uint32_t idm;
/* Polarization X. */
float plx;
/* Polarization Y. */
float ply;
/* Polarization Z. */
float plz;
/* Track step size. */
float stp;
/* Minimum distance to nearest boundary or 0. */
float near;
} MCTKBank;
typedef struct EVBank {
/* Run number. */
uint32_t run;
/* Event number. */
uint32_t evn;
/* Data type. */
uint32_t dtp;
/* Julian date. */
uint32_t jdy;
/* Universal time (seconds). */
uint32_t ut1;
/* Universal time (nanoseconds). */
uint32_t ut2;
/* Date (format: yyyymmdd) */
uint32_t dte;
/* Time (format: hhmmsscc - cc is centisec). */
uint32_t hmsc;
/* Global trigger time in nsec (first word). */
double gtr;
/* Number of PMTs that fired. */
uint32_t npm;
/* Integrated charge in the event. */
float nph;
/* Sub-run number, or -1 if unknown. Only defined for run number >= 10614. */
uint32_t sub_run;
/* Packed word. */
uint32_t mc_pck;
/* ZDAB input/output record type, e.g. PMT, NCD, CMA, RUN, etc. */
uint32_t rec;
/* ZDAB_PMT format number (x10). */
uint32_t vpck;
/* Global trigger ID. */
uint32_t gtr_id;
/* Trigger word. */
uint32_t trg_type;
/* Digitized peak of analog sum. */
uint32_t peak;
/* Analog sum derivative. */
uint32_t diff;
/* Digitized integral of analog sum. */
uint32_t integral;
/* Trigger error bits plus spares. */
uint32_t err;
/* Data splitter blindness word. */
uint32_t data_set;
uint32_t spare1[3];
uint32_t ncd_status;
/* Number of multiplexer global records. */
uint32_t num_muxg;
/* Number of multiplexer records. */
uint32_t num_mux;
/* Number of scope records. */
uint32_t num_scope;
uint32_t spare2[5];
/* Upper 24 bits of flock */
uint32_t ncd_clk_up;
/* Lower clock register (32 bits). */
uint32_t ncd_clk_lw;
/* Latch register id. */
uint32_t ncd_reg;
/* GTID. */
uint32_t ncd_gtid;
/* Sync clear error. */
uint32_t ncd_sync;
uint32_t spare3[10];
} EVBank;
/* PMT Bank struct. This is a struct which mimics the PMT data bank in SNOMAN.
* The fields and comments were taken from the SNOMAN companion. */
typedef struct PMTBank {
/* Tube number. For FECD, which has no associated tube number, this word is
* a copy of PIN. */
uint32_t pn;
/* Set of 1-bit flags. All undefined bits are set to zero. The following
* bits are defined:
*
* 0 KPF_DIS Discard hit for all processing including fitting.
* 2 KPF_NOI Noise.
* 3 KPF_PRP Pre-pulse.
* 4 KPF_AFP After-pulse.
* 5 KPF_FECD Front-End Card Data i.e. non-PMT channel.
* Should only be set on the FECD bank.
* 6 KPF_FT_MASK+i Discarded by fitter method i (i = 1,2,..).
* For description of fitter methods see the FTx bank.
* 26 KPF_XT Crosstalk.
* 27 KPF_NO_CAL No calibration.
* 28 KPF_BAD_CAL Bad calibration. */
uint32_t pf;
/* Time in nano-secs relative to event T0 - see EV. */
float pt;
/* Integrated charge. */
float phl;
/* Short-time integrated charge. */
float phs;
/* Low-gain integrated charge. */
float plx;
/* Time with the PMT jitter removed. */
float pt0;
/* Set of n-bit flags for the ith hit in list. All undefined bits are set
* to zero. The following bits are defined:
*
* Bit Field DAQ Meaning
* 0-3 NCELL (CMOS Cell address 0 to 15)
* 4-5 FLAG1 Bit 4 = CGT ES16.
* Bit 5 = CGT ES24.
* 6-9 FLAG2 Bit 6 = Missed Count
* Bit 7 = NC/CC Flag
* Bit 8 = LGISELECT (1=long sample)
* Bit 9 = CMOS ES16. */
uint32_t pif;
/* Uncalibrated times. */
float pit;
/* Uncalibrated high-gain, long int. charge. */
float pihl;
/* Uncalibrated high-gain, short int. charge. */
float pihs;
/* Uncalibrated log-gain, long int. charge. */
float pilx;
/* Uncalibrated unjittered time. */
float pit0;
/* PMT channel cell number. */
uint32_t cell;
/* CCC DAQ Circuit Number
* = 1024*card + 32*crate + channel.
* Before uncalibration it holds the tube no. */
uint32_t pin;
/* TSLH of PMT. */
float tslh;
/* HCA information. */
float hca;
/* ECA validation status word. */
uint32_t eca_val;
/* PCA validation status word. */
uint32_t pca_val;
/* ANXX validation status word. */
uint32_t anxx;
/* ECA calibrated time (nsec). */
float ept;
/* ECA calibrated QHL (pedestal subtracted). */
float ehl;
/* ECA calibrated QHS (pedestal subtracted). */
float ehs;
/* ECA calibrated QLX (pedestal subtracted). */
float elx;
/* Non-walk corrected PMT time. */
float pt1;
/* Multiphoton PCA time. */
float ptm;
/* Multiphoton PCA PMT transit time RMS. */
float ptms;
/* Best charge (either QHS or QLX). */
float qm;
/* Best charge status word. */
uint32_t qms;
/* Charge correction for rate-dependent shifting. */
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_mc(uint32_t *data, MCBank *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);
void unpack_ev(uint32_t *data, EVBank *b);
void unpack_pmt(uint32_t *data, PMTBank *b);
int get_event(zebraFile *f, event *ev, zebraBank *bev);
int isOrphan(aPmtEventRecord *pmtRecord);
void swap_int32(int32_t *val_pt, int count);
void swap_int16(int16_t *val_pt, int count);
int swap_PmtRecord(aPmtEventRecord *aPmtRecord, size_t size);
void swap_TrigRecord(struct TriggerInfo *aTrigRecord);
void swap_RunRecord(struct RunRecord *aRunRecord);
#endif
|