6 #include <DAQ_FCS/fcs_data_c.h>
8 #include "fcs_trg_base.h"
11 fcs_trg_base::marker_t fcs_trg_base::marker ;
13 u_int fcs_trg_base::stage_version[4] ;
15 u_short fcs_trg_base::stage_params[4][32] ;
17 ped_gain_t fcs_trg_base::p_g[NS_COU][ADC_DET_COU][DEP_COU][32] ;
18 u_short fcs_trg_base::ht_threshold[ADC_DET_COU] ;
21 unsigned long long fcs_trg_base::s2_ch_mask[NS_COU] ;
22 u_char fcs_trg_base::s2_ch_phase[NS_COU][34] ;
24 u_char fcs_trg_base::s3_ch_mask ;
25 u_char fcs_trg_base::s3_ch_phase[4] ;
26 u_char fcs_trg_base::s3_out_phase ;
28 int fcs_trg_base::fcs_trgDebug ;
29 int fcs_trg_base::fcs_readPresMaskFromText;
30 u_int fcs_trg_base::PRES_MASK[15][9][6];
32 u_short fcs_trg_base::EM_HERATIO_THR ;
33 u_short fcs_trg_base::HAD_HERATIO_THR ;
34 u_short fcs_trg_base::EMTHR0 ;
35 u_short fcs_trg_base::EMTHR1 ;
36 u_short fcs_trg_base::EMTHR2 ;
37 u_short fcs_trg_base::EMTHR3 ;
38 u_short fcs_trg_base::ELETHR0 ;
39 u_short fcs_trg_base::ELETHR1 ;
40 u_short fcs_trg_base::ELETHR2 ;
41 u_short fcs_trg_base::HADTHR0 ;
42 u_short fcs_trg_base::HADTHR1 ;
43 u_short fcs_trg_base::HADTHR2 ;
44 u_short fcs_trg_base::HADTHR3 ;
45 u_short fcs_trg_base::JETTHR1 ;
46 u_short fcs_trg_base::JETTHR2 ;
47 u_short fcs_trg_base::JPATHR2 ;
48 u_short fcs_trg_base::JPATHR1 ;
49 u_short fcs_trg_base::JPATHR0 ;
50 u_short fcs_trg_base::JPBCTHR2 ;
51 u_short fcs_trg_base::JPBCTHR1 ;
52 u_short fcs_trg_base::JPBCTHR0 ;
53 u_short fcs_trg_base::JPBCTHRD ;
54 u_short fcs_trg_base::JPDETHR2 ;
55 u_short fcs_trg_base::JPDETHR1 ;
56 u_short fcs_trg_base::JPDETHR0 ;
57 u_short fcs_trg_base::JPDETHRD ;
58 u_short fcs_trg_base::ETOTTHR ;
59 u_short fcs_trg_base::HTOTTHR ;
60 u_short fcs_trg_base::EHTTHR ;
61 u_short fcs_trg_base::HHTTHR ;
62 u_short fcs_trg_base::PHTTHR ;
64 u_int fcs_trg_base::data_format ;
66 int fcs_trg_base::run_type ;
69 fcs_trg_base::fcs_trg_base()
85 want_stage_1_sim = 1 ;
89 fcs_trg_base::~fcs_trg_base()
94 u_int fcs_trg_base::get_version()
100 void fcs_trg_base::init(
const char* fname)
107 memset(stage_params,0,
sizeof(stage_params)) ;
108 memset(p_g,0,
sizeof(p_g)) ;
110 memset(s2_ch_phase,0,
sizeof(s2_ch_phase)) ;
111 memset(s2_ch_mask,0,
sizeof(s2_ch_mask)) ;
113 memset(s3_ch_phase,0,
sizeof(s3_ch_phase)) ;
118 for(
int i=0;i<NS_COU;i++) {
119 for(
int j=0;j<ADC_DET_COU;j++) {
120 for(
int k=0;k<DEP_COU;k++) {
121 for(
int c=0;c<32;c++) {
122 p_g[i][j][k][c].gain = (1<<8) ;
128 ht_threshold[0] = 90 ;
129 ht_threshold[1] = 90 ;
130 ht_threshold[2] = 45 ;
135 LOG(INFO,
"init: not realtime -- loading stuff from files") ;
137 memset(fcs_data_c::ped,0,
sizeof(fcs_data_c::ped)) ;
140 sprintf(rdomap,
"%s/fcs_daq_map.txt",fname);
141 fcs_data_c::load_rdo_map(rdomap) ;
142 fcs_data_c::gain_from_cache(fname) ;
145 for(
int s=1;s<=1;s++) {
146 for(
int r=1;r<=6;r++) {
148 sprintf(fname,
"/net/fcs%02d/RTScache/fcs_pedestals_s%02d_r%d.txt",s,s,r) ;
149 fcs_data_c::ped_from_cache(fname) ;
159 for(
int i=0;i<3;i++) {
160 ht_threshold[i] = fcs_data_c::ht_threshold ;
164 for(
int i=0;i<NS_COU;i++) {
165 for(
int j=0;j<ADC_DET_COU;j++) {
166 for(
int k=0;k<DEP_COU;k++) {
168 int sec = fcs_data_c::det_map[j][i][k].sector - 1 ;
169 int rdo = fcs_data_c::det_map[j][i][k].rdo - 1 ;
171 if(sec<0 || rdo<0) continue ;
173 for(
int c=0;c<32;c++) {
174 u_short p = fcs_data_c::ped[sec][rdo].i_ped[c] ;
175 u_short g = fcs_data_c::ped[sec][rdo].i_gain[c] ;
177 if(p && log_level>5 && c==0) {
178 LOG(TERR,
"S%d:%d: %d:%d:%d: ch %d = i_ped %d, i_gain %d",sec+1,rdo+1,j,i,k,c,p,g) ;
184 p_g[i][j][k][c].gain = fcs_data_c::ped[sec][rdo].i_gain[c] ;
185 p_g[i][j][k][c].ped = fcs_data_c::ped[sec][rdo].i_ped[c] ;
194 marker.last_xing = 7 ;
196 marker.adc_start = 7 ;
197 marker.s1_out_start = marker.adc_start + 11 ;
199 marker.s2_in_start = marker.s1_out_start + 2 ;
200 marker.s2_to_s3_start = marker.s2_in_start + 15 ;
203 marker.s3_in_start = marker.s2_to_s3_start + 8 ;
204 marker.dsm_out_start = marker.s3_in_start + 14 ;
207 if(log_level>0) LOG(INFO,
"init markers: last xing %d, ADC %d, s1_out %d, s2_in %d, s2_to_s3 %d, s3_in %d, dsm_out %d",
212 marker.s2_to_s3_start,
214 marker.dsm_out_start) ;
219 fcs_readPresMaskFromText=0;
222 EM_HERATIO_THR = 32 ;
223 HAD_HERATIO_THR = 32 ;
262 ht_threshold[0]=EHTTHR;
263 ht_threshold[1]=HHTTHR;
264 ht_threshold[2]=PHTTHR;
269 stage_version[0] = 2 ;
270 stage_version[1] = 1 ;
271 stage_version[2] = 7 ;
272 stage_version[3] = 7 ;
281 void fcs_trg_base::run_start(u_int run)
286 memset(&errs,0,
sizeof(errs)) ;
287 memset(&good,0,
sizeof(good)) ;
288 memset(&statistics,0,
sizeof(statistics)) ;
291 memset(d_in,0,
sizeof(d_in));
292 memset(&d_out,0,
sizeof(d_out));
297 marker.adc_start = 0 ;
298 marker.last_xing = 1 ;
301 LOG(INFO,
"%d: starting run %08u, realtime %d, sim_mode %d",
id,run_number,realtime,sim_mode) ;
307 void fcs_trg_base::start_event()
311 memset(tb_cou,0,
sizeof(tb_cou)) ;
314 memset(d_in,0,
sizeof(d_in));
319 void fcs_trg_base::fill_event(
int det,
int ns,
int dep,
int c, u_short *d16,
int t_cou)
332 tb_cou[ns][det][dep] = t_cou ;
338 for(
int t=0;t<t_cou;t++) {
339 int dta = d16[t] & 0xFFF ;
340 int fla = d16[t] >> 12 ;
346 if(log_level>100) printf(
"%d:%d:%d ch %d: tb %d: ADC %d, fla %d\n",
347 ns,det,dep,c,t,dta,fla) ;
351 tix = t - marker.s1_out_start ;
355 if(dta && log_level>10) {
356 printf(
"s1 out: %d:%d:%d -- at xing %d:%d(%d) = %d\n",ns,det,dep,xing,xou,t,dta) ;
359 if(tix>=0 && xing<XING_COU) {
361 d_in[xing].s1[ns][det][dep].s1_to_s2.d[xou] = dta ;
365 tix = t - marker.adc_start ;
369 if(tix>=0 && xing<XING_COU) {
371 d_in[xing].s1[ns][det][dep].adc[c].d[xou] = dta ;
374 switch(data_format) {
376 if(c==0 && (fla & 0x1)) {
379 if(is_tcd < 0) is_tcd = t ;
381 if(log_level > 101) {
382 printf(
"ADC tcd_marker -- at xing %d:%d(%d)\n",xing,xou,t) ;
387 if(c==0 && (fla & 0x2)) {
389 if(is_self < 0) is_self = t ;
392 printf(
"ADC self_trg -- at xing %d:%d(%d)\n",xing,xou,t) ;
399 if(c==3 && (fla&4)) {
401 if(is_tcd < 0) is_tcd = t ;
403 if(log_level > 101) {
404 printf(
"ADC tcd_marker -- at xing %d:%d(%d)\n",xing,xou,t) ;
409 if(c==1 && (fla&4)) {
410 if(is_self < 0) is_self = t ;
413 printf(
"ADC self_trg -- at xing %d:%d(%d)\n",xing,xou,t) ;
426 tix = t - marker.dsm_out_start ;
431 if(tix>=0 && xing<XING_COU) {
432 d_in[xing].s3.dsm_out.d[xou] = dta & 0xFF ;
436 tix = t - marker.dsm_out_start ;
442 if(tix>=0 && xing<XING_COU) {
443 d_in[xing].s3.dsm_out.d[xou] |= (dta & 0xFF)<<8 ;
447 tix = t - marker.s3_in_start ;
452 if(tix>=0 && xing<XING_COU) {
453 d_in[xing].s3.s3_from_s2[c].d[xou] = dta & 0xFF ;
464 tix = t - marker.s2_to_s3_start ;
469 if(tix>=0 && xing<XING_COU) {
478 d_in[xing].s2[ns].s2_to_s3[c-34].d[xou] = dta & 0xFF ;
483 tix = t - marker.dsm_out_start ;
488 if(tix>=0 && xing<XING_COU) {
489 d_in[xing].s2[ns].s2_to_dsm.d[xou] = dta & 0xFF ;
495 tix = t - marker.s2_in_start ;
500 if(tix>=0 && xing<XING_COU) {
501 d_in[xing].s2[ns].s2_from_s1[c].d[xou] = dta & 0xFF ;
511 statistics.self_trgs++ ;
512 statistics.self_trg_marker = is_self ;
516 statistics.tcd_marker = is_tcd ;
521 int fcs_trg_base::end_event()
537 s3_to_dsm = s2_to_dsm[0] = s2_to_dsm[1] = 0 ;
539 if(!got_one)
return 0 ;
545 s3_to_dsm = d_in[trg_xing].s3.dsm_out.d[0] ;
546 s2_to_dsm[0] = d_in[trg_xing].s2[0].s2_to_dsm.d[0] ;
547 s2_to_dsm[1] = d_in[trg_xing].s2[1].s2_to_dsm.d[0] ;
549 for(
int xing=0;xing<marker.last_xing;xing++) {
551 LOG(NOTE,
"run_event_sim: xing %d",xing) ;
554 dsmout = run_event_sim(xing,sim_mode) ;
557 dump_event_sim(xing) ;
560 verify_event_sim(xing) ;
567 int fcs_trg_base::run_stop()
571 for(
int i=0;i<4;i++) {
572 if(errs.io_s1_to_s2[i]) err |= 1 ;
575 if(errs.io_s2_to_s3) err |= 1 ;
577 if(errs.sim_s1 || errs.sim_s2 || errs.sim_s3) {
581 LOG(INFO,
"thread %d: self_trg_marker %d, tcd_marker %d",
id,statistics.self_trg_marker,statistics.tcd_marker) ;
584 if(run_type==3 || (err&1)) {
585 LOG(ERR,
"thread %d: %d/%d events in run %d: errs sim %u %u %u; io [%u %u %u %u] %u",
id,
586 statistics.self_trgs,
591 errs.io_s1_to_s2[0],errs.io_s1_to_s2[1],errs.io_s1_to_s2[2],errs.io_s1_to_s2[3],
595 LOG(WARN,
"thread %d: %d/%d events in run %d: errs sim %u %u %u; io [%u %u %u %u] %u",
id,
596 statistics.self_trgs,
601 errs.io_s1_to_s2[0],errs.io_s1_to_s2[1],errs.io_s1_to_s2[2],errs.io_s1_to_s2[3],
608 LOG(INFO,
"thread %d: %d/%d events in run %d: good sim %u %u %u; io [%u %u %u %u] %u",
id,
609 statistics.self_trgs,
614 good.io_s1_to_s2[0],good.io_s1_to_s2[1],good.io_s1_to_s2[2],good.io_s1_to_s2[3],
622 int fcs_trg_base::verify_event_io()
628 if(!want_stage_2_io)
goto stage_3 ;
631 for(
int x=0;x<marker.last_xing;x++) {
632 for(
int t=0;t<8;t++) {
633 for(
int ns=0;ns<2;ns++) {
650 for(
int i=0;i<34;i++) {
651 s2_from_s1[i] = d_in[x].s2[ns].s2_from_s1[i].d[t] ;
662 for(
int d=0;d<20;d++) {
663 if(tb_cou[ns][0][d]) mask |= (1ll<<ix) ;
664 s1_to_s2[ix] = d_in[x].s1[ns][0][d].s1_to_s2.d[t] ;
669 for(
int d=0;d<8;d++) {
670 if(tb_cou[ns][1][d]) mask |= (1ll<<ix) ;
671 s1_to_s2[ix] = d_in[x].s1[ns][1][d].s1_to_s2.d[t] ;
676 for(
int d=0;d<6;d++) {
677 if(tb_cou[ns][2][d]) mask |= (1ll<<ix) ;
678 s1_to_s2[ix] = d_in[x].s1[ns][2][d].s1_to_s2.d[t] ;
685 if(mask != 0 && log_level>1) LOG(WARN,
"xing %d:%d, ns %d: mask 0x%llX, ix %d",x,t,ns,mask,ix) ;
687 for(
int i=0;i<34;i++) {
693 if(s2_ch_mask[ns] & (1ll<<i)) continue ;
695 if(s2_from_s1[i] || s1_to_s2[i]) {
699 if(s2_from_s1[i] != s1_to_s2[i]) {
705 if(log_level>0) LOG(ERR,
"evt %d: S1_to_S2 IO: NS %c: ch %d: xing %d:%d: out 0x%02X, in 0x%02X",
706 evts,cns,i,x,t,s1_to_s2[i],s2_from_s1[i]) ;
708 if(ns==0 && i<17) errs.io_s1_to_s2[0]++ ;
709 else if(ns==0) errs.io_s1_to_s2[1]++ ;
710 else if(ns==1 && i<17) errs.io_s1_to_s2[2]++ ;
711 else errs.io_s1_to_s2[3]++ ;
715 if(ns==0 && i<17) good.io_s1_to_s2[0]++ ;
716 else if(ns==0) good.io_s1_to_s2[1]++ ;
717 else if(ns==1 && i<17) good.io_s1_to_s2[2]++ ;
718 else good.io_s1_to_s2[3]++ ;
729 if(!want_stage_3_io)
goto end ;
732 for(
int x=0;x<marker.last_xing;x++) {
734 if(tb_cou[0][3][0]==0) continue ;
736 for(
int c=0;c<4;c++) {
739 if(tb_cou[c/2][3][1]==0) continue ;
742 #if 0 // need to remap
754 for(
int t=0;t<8;t++) {
755 int s3_from_s2 = d_in[x].s3.s3_from_s2[c].d[t] ;
756 int s2_to_s3 = d_in[x].s2[c/2].s2_to_s3[cc].d[t] ;
758 if(s2_to_s3 != s3_from_s2) {
771 if(err==1 && log_level>0) {
772 for(
int t=0;t<8;t++) {
775 int s3_from_s2 = d_in[x].s3.s3_from_s2[c].d[t] ;
776 int s2_to_s3 = d_in[x].s2[c/2].s2_to_s3[cc].d[t] ;
778 if(s2_to_s3 != s3_from_s2) ctmp =
'*' ;
781 LOG(ERR,
"evt %d: S3 IO: ch %d: xing %d:%d: in S3 0x%02X, out of S2 0x%02X%c",
783 s3_from_s2,s2_to_s3,ctmp) ;
793 if(printed) fflush(stdout) ;
800 int fcs_trg_base::dump_event_sim(
int xing)
804 for(
int i=0;i<NS_COU;i++) {
805 for(
int j=0;j<ADC_DET_COU;j++) {
806 for(
int k=0;k<DEP_COU;k++) {
810 for(
int t=0;t<8;t++) {
811 int d_sim = d_out.s1[i][j][k].s1_to_s2.d[t] ;
813 if(d_sim && fcs_trgDebug>0)
814 printf(
"S1 sim: %d:%d:%d - xing %d:%d, dta %d\n",
815 i,j,k,xing,t,d_sim) ;
823 for(
int i=0;i<NS_COU;i++) {
824 for(
int j=0;j<2;j++) {
827 for(
int t=0;t<8;t++) {
828 int d_sim = d_out.s2[i].s2_to_s3[j].d[t] ;
831 printf(
"S2 sim: %d:%d - xing %d:%d, dta 0x%03X\n",
843 int fcs_trg_base::verify_event_sim(
int xing)
855 if(!want_stage_1_sim)
goto skip_stage1 ;
857 for(
int i=0;i<NS_COU;i++) {
863 for(
int j=0;j<ADC_DET_COU;j++) {
878 for(
int k=0;k<DEP_COU;k++) {
882 if(tb_cou[i][j][k]==0) continue ;
885 for(
int t=0;t<8;t++) {
886 int d_sim = d_out.s1[i][j][k].s1_to_s2.d[t] ;
887 int d_i = d_in[xing].s1[i][j][k].s1_to_s2.d[t] ;
911 for(
int t=0;t<8;t++) {
912 int d_sim = d_out.s1[i][j][k].s1_to_s2.d[t] ;
913 int d_i = d_in[xing].s1[i][j][k].s1_to_s2.d[t] ;
915 if(want_log && log_level>0) {
916 LOG(ERR,
"evt %d: S1 sim: %c:%c:%d - xing %d:%d: sim 0x%02X, dta 0x%02X %c",evts,cns,cdet,k,
919 d_i,d_sim!=d_i?
'*':
' ') ;
922 if(want_print && log_level>3) {
923 printf(
"S1: %d:%d:%d - xing %d:%d: s1 sim %d, dta %d %s\n",i,j,k,
926 d_i,want_log?
"ERROR":
"") ;
930 if(want_log && log_level>4) {
932 for(
int c=0;c<32;c++) {
934 for(
int t=0;t<8;t++) {
935 sum += d_in[xing].s1[i][j][k].adc[c].d[t] ;
936 LOG(ERR,
"ch %2d: t %d: dta %d",c,t,d_in[xing].s1[i][j][k].adc[c].d[t]) ;
940 sum -= p_g[i][j][k][c].ped ;
941 if(sum > ht_threshold[j]) s1_bits |= (1<<c) ;
943 LOG(ERR,
" s1_bits 0x%08X",s1_bits) ;
955 for(
int i=0;i<NS_COU;i++) {
964 for(
int j=0;j<1;j++) {
968 if(tb_cou[i][3][1]==0) continue ;
970 for(
int t=0;t<4;t++) {
971 int d_sim = d_out.s2[i].s2_to_dsm ;
972 int d_i = d_in[xing].s2[i].s2_to_dsm.d[t] ;
994 for(
int t=0;t<4;t++) {
997 int d_sim = d_out.s2[i].s2_to_dsm ;
998 int d_i = d_in[xing].s2[i].s2_to_dsm.d[t] ;
1000 if(d_sim != d_i) ctmp =
'*' ;
1002 if(want_log && log_level>0) {
1003 LOG(ERR,
"evt %d: S2_to_DSM sim: %c - xing %d:%d: sim 0x%02X, dta 0x%02X%c",evts,cns,
1009 if(want_print && log_level>3) {
1010 printf(
"evt %d: S2_to_DSM sim: %c: - xing %d:%d: sim %d, dta %d %s\n",evts,cns,
1013 d_i,want_log?
"ERROR":
"") ;
1021 for(
int j=0;j<2;j++) {
1022 int want_print = 0 ;
1025 if(tb_cou[i][3][1]==0) continue ;
1027 for(
int t=0;t<7;t++) {
1028 int d_sim = d_out.s2[i].s2_to_s3[j].d[t] ;
1029 int d_i = d_in[xing].s2[i].s2_to_s3[j].d[t] ;
1051 for(
int t=0;t<8;t++) {
1054 int d_sim = d_out.s2[i].s2_to_s3[j].d[t] ;
1055 int d_i = d_in[xing].s2[i].s2_to_s3[j].d[t] ;
1057 if(d_sim != d_i) ctmp =
'*' ;
1059 if(want_log && log_level>0) {
1060 LOG(ERR,
"evt %d: S2 sim: %c:%d - xing %d:%d: sim 0x%02X, dta 0x%02X%c",evts,cns,j,
1066 if(want_print && log_level>3) {
1067 printf(
"evt %d: S2 sim: %c:%d: - xing %d:%d: sim %d, dta %d %s\n",evts,cns,j,
1070 d_i,want_log?
"ERROR":
"") ;
1083 if(tb_cou[0][3][0]==0)
return bad ;
1088 int want_print = 0 ;
1090 for(
int t=0;t<4;t++) {
1091 int d_sim = d_out.s3.dsm_out ;
1092 int d_i = d_in[xing].s3.dsm_out.d[t] ;
1095 if(d_sim || d_i) want_print = 1 ;
1112 for(
int t=0;t<4;t++) {
1113 int d_sim = d_out.s3.dsm_out ;
1114 int d_i = d_in[xing].s3.dsm_out.d[t] ;
1116 if(want_log && log_level>0) {
1117 LOG(ERR,
"evt %d: S3 sim: xing %d:%d: sim 0x%04X, dta 0x%04X %s",evts,xing,t,
1118 d_sim,d_i,want_log?
"ERROR":
"") ;
1121 if(want_print && log_level > 3) {
1122 printf(
"evt %d: S3 sim: xing %d:%d: sim 0x%04X, dta 0x%04X %s\n",evts,xing,t,
1123 d_sim,d_i,want_log?
"ERROR":
"") ;
1140 u_int fcs_trg_base::run_event_sim(
int xing,
int type)
1145 memset(&d_out,0,
sizeof(d_out)) ;
1150 for(
int i=0;i<NS_COU;i++) {
1154 link_t ecal_in[DEP_ECAL_COU] ;
1155 link_t hcal_in[DEP_HCAL_COU] ;
1156 link_t fpre_in[DEP_PRE_COU] ;
1158 for(
int j=0;j<ADC_DET_COU;j++) {
1161 for(
int k=0;k<DEP_COU;k++) {
1162 u_int s0_to_s1[32] ;
1164 if(tb_cou[i][j][k]==0) continue ;
1170 for(
int c=0;c<32;c++) {
1175 stage_0(d_in[xing].s1[i][j][k].adc[c],geo,&(p_g[i][j][k][c]),&res) ;
1179 if(log_level>100) printf(
"... S0: xing %d: %d:%d:%d: ch %d = %d (ADC %d) (ped %d, gain %d) %s\n",xing,i,j,k,c,res,
1180 d_in[xing].s1[i][j][k].adc[c].d[0],
1181 p_g[i][j][k][c].ped,p_g[i][j][k][c].gain,
1186 for(
int t=0;t<8;t++) {
1187 sum += d_in[xing].s1[i][j][k].adc[c].d[t] ;
1188 printf(
" ADC %d = %d [sum %d, delta %d]\n",t,d_in[xing].s1[i][j][k].adc[c].d[t],sum,sum-p_g[i][j][k][c].ped) ;
1191 printf(
"SSS0: %d %d %d %d %d\n",j,i,k,c,sum-p_g[i][j][k][c].ped) ;
1196 stage_1(s0_to_s1, geo, &d_out.s1[i][j][k].s1_to_s2) ;
1206 if(tb_cou[i][3][1]==0) continue ;
1208 memset(ecal_in,0,
sizeof(ecal_in)) ;
1209 memset(hcal_in,0,
sizeof(hcal_in)) ;
1210 memset(fpre_in,0,
sizeof(fpre_in)) ;
1212 for(
int j=0;j<20;j++) {
1213 ecal_in[j] = d_in[xing].s2[i].s2_from_s1[j] ;
1215 for(
int j=0;j<8;j++) {
1216 hcal_in[j] = d_in[xing].s2[i].s2_from_s1[20+j] ;
1218 for(
int j=0;j<6;j++) {
1219 fpre_in[j] = d_in[xing].s2[i].s2_from_s1[28+j] ;
1222 stage_2(ecal_in, hcal_in, fpre_in, geo, d_out.s2[i].s2_to_s3, &d_out.s2[i].s2_to_dsm) ;
1226 for(
int c=0;c<DEP_ECAL_COU;c++) {
1227 ecal_in[c] = d_out.s1[i][0][c].s1_to_s2 ;
1229 for(
int c=0;c<DEP_HCAL_COU;c++) {
1230 hcal_in[c] = d_out.s1[i][1][c].s1_to_s2 ;
1232 for(
int c=0;c<DEP_PRE_COU;c++) {
1233 fpre_in[c] = d_out.s1[i][2][c].s1_to_s2 ;
1236 stage_2(ecal_in, hcal_in, fpre_in, geo, d_out.s2[i].s2_to_s3, &d_out.s2[i].s2_to_dsm) ;
1250 if(tb_cou[0][3][0]==0)
return 0 ;
1252 l_in[0] = d_in[xing].s3.s3_from_s2[0] ;
1253 l_in[1] = d_in[xing].s3.s3_from_s2[1] ;
1254 l_in[2] = d_in[xing].s3.s3_from_s2[2] ;
1255 l_in[3] = d_in[xing].s3.s3_from_s2[3] ;
1257 stage_3(l_in,&d_out.s3.dsm_out) ;
1263 l_in[0] = d_out.s2[0].s2_to_s3[0] ;
1264 l_in[1] = d_out.s2[0].s2_to_s3[1] ;
1265 l_in[2] = d_out.s2[1].s2_to_s3[0] ;
1266 l_in[3] = d_out.s2[1].s2_to_s3[1] ;
1268 stage_3(l_in,&d_out.s3.dsm_out) ;
1272 return d_out.s3.dsm_out
1273 + ((int)(d_out.s2[0].s2_to_dsm & 0xFF) << 16)
1274 + ((
int)(d_out.s2[1].s2_to_dsm & 0xFF) << 24);
1283 switch(stage_version[0]) {
1285 stage_0_201900(adc, geo, pg, dta_out) ;
1288 stage_0_202101(adc, geo, pg, dta_out) ;
1291 stage_0_202103(adc, geo, pg, dta_out) ;
1294 stage_0_202109(adc, geo, pg, dta_out) ;
1298 LOG(ERR,
"stage_0: unknown version %d",stage_version[0]) ;
1305 void fcs_trg_base::stage_1(u_int s0[],
geom_t geo,
link_t *output)
1308 switch(stage_version[1]) {
1310 stage_1_201900(s0,geo,output) ;
1313 stage_1_202201(s0,geo,output) ;
1316 LOG(ERR,
"Unknown stage_1 version %d",stage_version[1]) ;
1325 switch(stage_version[2]) {
1327 stage_2_201900(ecal,hcal,pres,geo,output) ;
1330 stage_2_202201(ecal,hcal,pres,geo,output) ;
1333 stage_2_TAMU_202202(ecal,hcal,pres,geo,output) ;
1336 stage_2_202203(ecal,hcal,pres,geo,output) ;
1339 stage_2_JP6_202204(ecal,hcal,pres,geo,output) ;
1342 stage_2_JP6Carl_202205(ecal,hcal,pres,geo,output) ;
1345 stage_2_JP5_202206(ecal,hcal,pres,geo,output) ;
1348 stage_2_202207(ecal,hcal,pres,geo,output,s2_to_dsm) ;
1353 stage_2_tonko_202101(ecal,hcal,pres,geo,output) ;
1356 stage_2_tonko_202104(ecal,hcal,pres,geo,output) ;
1359 LOG(ERR,
"Unknown stage_2 version %d",stage_version[2]) ;
1367 void fcs_trg_base::stage_3(
link_t link[4], u_short *dsm_out)
1370 switch(stage_version[3]) {
1372 stage_3_201900(link,dsm_out) ;
1375 stage_3_202201(link,dsm_out) ;
1378 stage_3_202203(link,dsm_out) ;
1381 stage_3_202207(link,dsm_out) ;
1385 stage_3_tonko_202101(link, dsm_out) ;
1389 LOG(ERR,
"Unknown stage_3 version %d",stage_version[3]) ;