]>
Commit | Line | Data |
---|---|---|
f67e2651 | 1 | |
2 | /* implement functions special for the f2k 1.2 format */ | |
3 | #include <stdlib.h> | |
4 | ||
5 | #include "rdmc.h" | |
6 | #include "amanda.h" | |
7 | #include "f2k.h" | |
8 | ||
9 | const f2000_line_t HT_line_1x2 = | |
10 | {"HT ", HT_LINE, COMP_STRINGWISE, rdmc_amanda_HT_1x2 }; | |
11 | const f2000_line_t WF_line_1x2 = | |
12 | {"WF ", WF_LINE, COMP_STRINGWISE, rdmc_amanda_WF_1x2 }; // pd | |
13 | ||
14 | ||
15 | const f2000_event_t f2000_mevt_1x2 = | |
16 | { RDMC_EVENT_MUON, | |
17 | { &(EM_line_1x1), | |
18 | NULL | |
19 | }, | |
20 | { | |
21 | &(TR_line_1x1), | |
22 | &(HT_line_1x2), &(CH_line_1x1), | |
23 | &(WF_line_1x2), | |
24 | &(STATUS_line_1x1), &(US_line_1x1), | |
25 | &(FIT_block_1x1), &(FRESULT_line_1x1), | |
26 | &(TRIG_block_1x1), &(USES_line_1x1), | |
27 | &(COMMENT_line_1x1) | |
28 | , NULL | |
29 | }, | |
30 | { &(EE_line_1x1) | |
31 | , NULL}, | |
32 | rdmc_mevt_f2k_1x1, | |
33 | rdmc_wevt_f2k_1x1_2 | |
34 | }; | |
35 | ||
36 | ||
37 | const f2000_event_t * f2000_events_1x2[] | |
38 | = { | |
39 | &f2000_mevt_1x2, | |
40 | NULL | |
41 | }; | |
42 | ||
43 | ||
44 | int rdmc_amanda_HT_1x2( mcfile *fp , array *a, | |
45 | mevt *e, void *tmp){ | |
46 | rdmc_f2k_buffer_t *f2k_buff = fp->info.f2000.f2k_buffer; | |
47 | char *s=f2k_buff->line_pt[f2k_buff->iline]; | |
48 | char **args=NULL; | |
49 | int nargs=0; | |
50 | mhit h; | |
51 | char *c_stat=""; | |
52 | ||
53 | /* start parsing*/ | |
54 | args = rdmc_f2k_tokenize(s,&nargs); | |
55 | ||
56 | switch (nargs){ | |
57 | case 7: | |
58 | break; | |
59 | case 8: | |
60 | c_stat=args[7]; | |
61 | break; | |
62 | default: | |
63 | return RDMC_ILF; | |
64 | } | |
65 | ||
66 | rdmc_init_mhit(&h); | |
67 | h.str = 0; /* this is filled later at the end of the event read */ | |
68 | h.ch = atoi(args[1])-1; | |
69 | h.amp = rdmc_amanda_strtof(args[2] , RDMC_NA); | |
70 | h.id = rdmc_amanda_strtoi(args[3] ,RDMC_NA); | |
71 | h.ma = h.mt = rdmc_amanda_strtoi(args[4] ,RDMC_PARENT_NA); | |
72 | h.t = rdmc_amanda_strtof(args[5] , RDMC_TDC_NA); | |
73 | h.tot = rdmc_amanda_strtof(args[6], RDMC_NA); | |
74 | ||
75 | if (rdmc_amanda_mhit_stat(&(h.hstat),c_stat) != RDMC_IO_OK) | |
76 | return RDMC_ILF; | |
77 | ||
78 | rdmc_add_mhit(e,&h,e->nhits); | |
79 | #if 1 /* no dynamic allocated stuff */ | |
80 | rdmc_clear_mhit(&h); | |
81 | #endif | |
82 | ||
83 | ||
84 | return RDMC_IO_OK; | |
85 | } /* rdmc_amanda_HT() */ | |
86 | ||
87 | int rdmc_amanda_WF_1x2( mcfile *fp , array *a, mevt *e, void *tmp) | |
88 | { | |
89 | rdmc_f2k_buffer_t *f2k_buff = fp->info.f2000.f2k_buffer; | |
90 | char *s=f2k_buff->line_pt[f2k_buff->iline]; | |
91 | char **args=NULL; | |
92 | int nargs=0; | |
93 | int i; | |
94 | waveform wf; | |
95 | float channel; | |
96 | ||
97 | ||
98 | /* start parsing*/ | |
99 | args = rdmc_f2k_tokenize(s,&nargs); //check the parsing string | |
100 | ||
101 | if ( nargs < 7) return RDMC_ILF; // check # | |
102 | ||
103 | rdmc_init_WF(&wf); | |
104 | channel = rdmc_amanda_strtof(args[1], RDMC_NA); // fill waveform struct | |
105 | wf.om = rdmc_nint(channel); | |
106 | wf.ch = (channel - wf.om) * 100.; | |
107 | wf.id = rdmc_amanda_strtoi(args[2] ,RDMC_NA); | |
108 | wf.pa = rdmc_amanda_strtoi(args[3] ,RDMC_PARENT_NA); | |
109 | wf.ndigi = atoi(args[4]); | |
110 | wf.t_start = rdmc_amanda_strtof(args[5], RDMC_NA); | |
111 | wf.t_bin = rdmc_amanda_strtof(args[6], RDMC_NA); | |
112 | if ( nargs < 7 + wf.ndigi) return RDMC_ILF; // check # | |
113 | ||
114 | if( wf.ndigi <= 0 || wf.ndigi > RDMC_MAXDIGI ) | |
115 | return RDMC_ILF; | |
116 | ||
117 | wf.digi = malloc(wf.ndigi*sizeof(float)); // fill digit. of waveform | |
118 | for (i = 0; i < wf.ndigi; i++) | |
119 | wf.digi[i] = rdmc_amanda_strtof(args[7+i], RDMC_TDC_NA); | |
120 | ||
121 | ||
122 | rdmc_add_WF(e,&wf,e->nwf); // add waveform to event | |
123 | rdmc_clear_WF(&wf); | |
124 | ||
125 | return RDMC_IO_OK; | |
126 | } /* rdmc_amanda_WF() */ | |
127 | ||
128 | // pd - end | |
129 | ||
130 | ||
131 | /**************************************************************************** | |
132 | ********************************** E O F *********************************** | |
133 | ****************************************************************************/ | |
134 | ||
135 | ||
136 |