8 #include <rtsSystems.h>
10 #include <daqFormats.h>
12 #include <DAQ_READER/daqReader.h>
13 #include <DAQ_READER/daq_dta.h>
15 #include <trgConfNum.h>
16 #include <DAQ_TRG/daq_trg.h>
18 #include <DAQ_FCS/daq_fcs.h>
19 #include <DAQ_FCS/fcs_data_c.h>
21 #include "fcs_trg_base.h"
24 static int sim_mode = 0 ;
34 daq_dta *dd = rdr->det(
"trg")->get(
"raw") ;
36 while(dd && dd->iterate()) {
39 printf(
"tinfo: seq = #%d token = %d detectors = 0x%x triggers = 0x%llx/0x%llx/0x%llx evpgroups=0x%x flags=0x%x\n",
50 for(
int i=0;i<64;i++) {
51 if(rdr->daqbits64 & (1ll<<i)) {
60 printf(
"Trg offline id %d\n",i) ;
70 for(
int i=0;i<8;i++) {
71 lastdsm[i] = swap16(l1Dsm->lastDSM[i]) ;
75 fcs2019 = (lastdsm[4] >> 10) & 1 ;
82 fcs2019 |= (fcs<<2) | (ok<<1) ;
93 printf(
"==> Running simulation now\n") ;
99 int from_ascii_open(
const char *fn)
104 LOG(INFO,
"Opening %s",fn) ;
106 FILE *f = fopen(fn,
"r") ;
113 memset(dta,0,
sizeof(dta)) ;
118 if(fgets(buff,
sizeof(buff),f)==0) break ;
120 int det,ns,dep,ch,adc ;
121 int ret = sscanf(buff,
"%d %d %d %d %d",&det,&ns,&dep,&ch,&adc) ;
122 if(ret != 5) continue ;
128 LOG(TERR,
"Running evt %d",evts) ;
134 if(adc > 4095) adc = 4095 ;
137 if(det<0 || det>=3) printf(
"*** ERROR: DET %d\n",det) ;
138 if(ns<0 || ns>=2) printf(
"*** ERROR: NS %d\n",ns) ;
139 if(dep<0 || dep>=24) printf(
"*** ERROR: DEP %d\n",dep) ;
141 f_t->fill_event(det,ns,dep,ch,dta,8) ;
151 int main(
int argc,
char *argv[])
153 extern char *optarg ;
157 rtsLogOutput(RTS_LOG_STDERR) ;
162 f_t->log_level = 110 ;
164 while((c=getopt(argc,argv,
"d:al:")) != EOF) {
167 rtsLogLevel(optarg) ;
170 f_t->log_level = atoi(optarg) ;
180 if(sim_mode) f_t->sim_mode = 1 ;
186 f_t->ht_threshold[2] = 90 ;
187 f_t->marker.last_xing = 8 ;
196 from_ascii_open(argv[optind]) ;
206 f_t->run_start(rdr->run) ;
211 rdr->get(0, EVP_TYPE_ANY) ;
213 if(rdr->status) break ;
216 dd = rdr->det(
"fcs")->get(
"adc") ;
229 while(dd && dd->iterate()) {
232 printf(
"=== fcs_evt %d\n",fcs_evt) ;
233 u_int fcs_trg = trg(rdr) ;
234 printf(
"--- fcs_trg %d\n",fcs_trg) ;
239 int det = (dd->sec >> 6) & 0x3 ;
240 int ns = (dd->sec >> 5) & 1 ;
244 LOG(NOTE,
"evt %d: %d %d %d %d : %d",evt,det,ns,dep,c,dd->ncontent) ;
246 f_t->fill_event(det,ns,dep,c,(u_short *)dd->Void,dd->ncontent) ;
255 printf(
"***** Event %d/%d\n",fcs_evt,evt) ;
262 LOG(INFO,
"Done: %d/%d evts",fcs_evt,evt) ;