3 #define JMLEVTMIN 206150
4 #define JMLEVTMAX 206200
12 #include <arpa/inet.h>
15 #include <rtsSystems.h>
18 #include <DAQ_READER/daqReader.h>
19 #include <DAQ_READER/daq_dta.h>
22 #include "trgConfNum.h"
26 #include <DAQ_BSMD/daq_bsmd.h>
27 #include <DAQ_BTOW/daq_btow.h>
28 #include <DAQ_EMC/daq_emc.h>
29 #include <DAQ_ESMD/daq_esmd.h>
30 #include <DAQ_ETOW/daq_etow.h>
31 #include <DAQ_FPD/daq_fpd.h>
32 #include <DAQ_FTP/daq_ftp.h>
33 #include <DAQ_L3/daq_l3.h>
34 #include <DAQ_PMD/daq_pmd.h>
35 #include <DAQ_PP2PP/daq_pp2pp.h>
36 #include <DAQ_RIC/daq_ric.h>
37 #include <DAQ_SC/daq_sc.h>
38 #include <DAQ_SSD/daq_ssd.h>
39 #include <DAQ_SVT/daq_svt.h>
40 #include <DAQ_TOF/daq_tof.h>
41 #include <DAQ_TPC/daq_tpc.h>
42 #include <DAQ_TPX/daq_tpx.h>
43 #include <DAQ_TPX/tpxCore.h>
45 #include <DAQ_TRG/daq_trg.h>
46 #include <DAQ_HLT/daq_hlt.h>
47 #include <DAQ_L4/daq_l4.h>
48 #include <DAQ_FGT/daq_fgt.h>
49 #include <DAQ_MTD/daq_mtd.h>
50 #include <DAQ_PXL/daq_pxl.h>
51 #include <DAQ_SST/daq_sst.h>
52 #include <DAQ_FPS/daq_fps.h>
53 #include <DAQ_RHICF/daq_rhicf.h>
54 #include <DAQ_ETOF/daq_etof.h>
56 #include <DAQ_ITPC/daq_itpc.h>
57 #include <DAQ_ITPC/itpcCore.h>
58 #include <TPC/rowlen.h>
60 #include <DAQ_FCS/daq_fcs.h>
61 #include <DAQ_FCS/fcs_data_c.h>
63 #include <DAQ_STGC/daq_stgc.h>
68 #include <DAQ_FGT/fgtPed.h>
69 static int fgt_test(
daqReader *rdr,
const char *do_print,
int which) ;
70 #include <DAQ_SST/sstPed.h>
71 static int sst_test(
daqReader *rdr,
int mode) ;
75 #ifdef INSIST_ON_EMC_PSEUDO
76 static int emc_pseudo_doer(
daqReader *rdr,
const char *do_print) ;
79 static int bsmd_doer(
daqReader *rdr,
const char *do_print) ;
80 static int esmd_doer(
daqReader *rdr,
const char *do_print) ;
81 static int btow_doer(
daqReader *rdr,
const char *do_print) ;
82 static int etow_doer(
daqReader *rdr,
const char *do_print) ;
83 static int tpc_doer(
daqReader *rdr,
const char *do_print) ;
84 static int tpx_doer(
daqReader *rdr,
const char *do_print) ;
85 static int trg_doer(
daqReader *rdr,
const char *do_print) ;
86 static int ftp_doer(
daqReader *rdr,
const char *do_print) ;
87 static int pmd_doer(
daqReader *rdr,
const char *do_print) ;
88 static int hlt_doer(
daqReader *rdr,
const char *do_print) ;
89 static int l4_doer(
daqReader *rdr,
const char *do_print) ;
91 static int pp2pp_doer(
daqReader *rdr,
const char *do_print) ;
92 static int l3_doer(
daqReader *rdr,
const char *do_print) ;
93 static int fgt_doer(
daqReader *rdr,
const char *do_print,
int which) ;
94 static int mtd_doer(
daqReader *rdr,
const char *do_print) ;
95 static int tinfo_doer(
daqReader *rdr,
const char *do_print);
96 static int pxl_doer(
daqReader *rdr,
const char *do_print) ;
97 static int sst_doer(
daqReader *rdr,
const char *do_print) ;
98 static int fps_doer(
daqReader *rdr,
const char *do_print) ;
99 static int rhicf_doer(
daqReader *rdr,
const char *do_print) ;
100 static int etof_doer(
daqReader *rdr,
const char *do_print) ;
101 static int itpc_doer(
daqReader *rdr,
const char *do_print) ;
102 static int fcs_doer(
daqReader *rdr,
const char *do_print) ;
103 static int stgc_doer(
daqReader *rdr,
const char *do_print) ;
107 static int nfs_loops ;
109 static int run_number ;
110 static int print_mode ;
113 u_int rcc_timestamp ;
117 int altro_override[256] ;
119 extern int *tpx_altro_to_row_override ;
128 int main(
int argc,
char *argv[])
130 extern char *optarg ;
133 const char *print_det =
"" ;
134 char _mountpoint[256];
135 const char *mountpoint =
"/net/evp";
137 rtsLogOutput(RTS_LOG_STDERR) ;
138 rtsLogLevel((
char *)WARN) ;
148 while((c = getopt(argc, argv,
"D:d:m:f:")) != EOF) {
151 rtsLogLevel(optarg) ;
157 mountpoint = _mountpoint;
158 strncpy(_mountpoint, (
char *)optarg,
sizeof(_mountpoint)-1);
161 print_mode = atoi(optarg) ;
175 evp->setEvpDisk((
char *)mountpoint);
177 LOG(INFO,
"Using direct access via NFS directory %s to host %s",mountpoint,evp->EVP_HOSTNAME) ;
184 while(optind < argc) {
187 LOG(INFO,
"Opening file %s",argv[optind]) ;
195 char *ret = evp->get(0,EVP_TYPE_ANY);
200 LOG(ERR,
"evp status is non-null [0x08X, %d dec]",evp->status,evp->status) ;
206 switch(evp->status) {
210 LOG(DBG,
"End of Run/File");
212 LOG(DBG,
"Wait a second...");
215 if((nfs_loops%5)==0) {
216 LOG(WARN,
"Still waiting for Event Pool...") ;
223 LOG(WARN,
"Problem getting event - skipping [good %d, bad %d]",good,bad);
228 LOG(CRIT,
"evp->status CRITICAL (?)") ;
237 run_number = evp->run ;
238 LOG(INFO,
"Opened run number %08u",evp->run) ;
241 if(evp->status == EVP_STAT_EOR) {
242 LOG(INFO,
"End of File reached...") ;
248 time_t e_time = (time_t) evp->evt_time ;
249 char *date = ctime(&e_time) ;
250 date[strlen(date)-1] = 0 ;
252 LOG(INFO,
"evt %d: sequence %d: token %4d, trgcmd %d, daqcmd %d, time \"%s\", detectors 0x%08X (status 0x%X), evpgroups 0x%X",good,evp->seq, evp->token, evp->trgcmd, evp->daqcmd,
253 date, evp->detectors, evp->status,evp->evpgroups) ;
267 if(strcmp(print_det,
"tinfo") == 0) {
268 int ret = tinfo_doer(evp,
"tinfo");
269 if(ret) LOG(INFO,
"Trigger Info FOUND") ;
274 if(strcmp(print_det,
"readahead") == 0) {
276 int ret = evp->readNextFutureSummaryInfo(&nsummary);
280 printf(
"Event #%d, token %d triggers 0x%llx ----> No Next Event...",
281 evp->seq,evp->token,evp->daqbits64);
284 printf(
"Event #%d, token %d triggers 0x%llx ----> Next Event: #%d, token %d triggers 0x%llx\n",
285 evp->seq,evp->token,evp->daqbits64,
286 nsummary.seq, nsummary.token,
287 make64(nsummary.L3summary[0],nsummary.L3summary[1]));
292 dd = evp->det(
"sc")->get() ;
293 if(dd && dd->iterate()) {
294 LOG(INFO,
"SC found") ;
295 if(strcasecmp(print_det,
"sc")==0) {
302 sc_p->timelag = evp->evt_time - sc_p->time ;
303 if(sc_p->timelag > 0) alag = sc_p->timelag ;
304 else alag = -sc_p->timelag ;
306 if(alag > 5) sc_p->valid = 0 ;
307 else sc_p->valid = 1 ;
309 printf(
"SC: valid %d, time %u, timelag %d, B field %.3f\n",sc_p->valid,sc_p->time,sc_p->timelag,sc_p->mag_field) ;
310 for(
int i=0;i<16;i++) {
311 printf(
"\tRICH scaler %2d: %u\n",i,sc_p->rich_scalers[i]) ;
316 dd = evp->det(
"fpd")->get(
"legacy") ;
317 if(dd) LOG(INFO,
"FPD found") ;
319 if(ftp_doer(evp,print_det)) LOG(INFO,
"FTP found") ;
322 dd = evp->det(
"rich")->get(
"legacy") ;
323 if(dd) LOG(INFO,
"RIC found") ;
325 dd = evp->det(
"ssd")->get(
"legacy") ;
326 if(dd) LOG(INFO,
"SSD found") ;
328 dd = evp->det(
"svt")->get(
"legacy") ;
329 if(dd) LOG(INFO,
"SVT found") ;
332 if(pmd_doer(evp, print_det)) LOG(INFO,
"PMD found") ;
334 dd = evp->det(
"tof")->get(
"legacy") ;
336 LOG(INFO,
"TOF found") ;
337 if(strcasecmp(print_det,
"tof")==0) {
338 while(dd->iterate()) {
340 for(
int r=0;r<4;r++) {
341 printf(
"TOF RDO %d: words %d:\n",r+1,tof->ddl_words[r]) ;
342 for(u_int i=0;i<tof->ddl_words[r];i++) {
343 printf(
"\t%d: 0x%08X [%u dec]\n",i,tof->ddl[r][i],tof->ddl[r][i]) ;
350 if(trg_doer(evp, print_det)) LOG(INFO,
"TRG found") ;
354 if(btow_doer(evp, print_det)) LOG(INFO,
"BTOW found") ;
357 bsmd_doer(evp,print_det) ;
359 if(etow_doer(evp, print_det)) LOG(INFO,
"ETOW found") ;
361 if(esmd_doer(evp, print_det)) LOG(INFO,
"ESMD found") ;
365 if(tpc_doer(evp,print_det)) LOG(INFO,
"TPC found (legacy)") ;
368 tpx_doer(evp,print_det) ;
373 pp2pp_doer(evp,print_det) ;
377 if(l3_doer(evp,print_det)) LOG(INFO,
"L3/HLT_FY09 found") ;
380 if(hlt_doer(evp,print_det)) LOG(INFO,
"HLT_FY10 found") ;
383 if(l4_doer(evp,print_det)) {
384 LOG(INFO,
"HLT FY12 found");
388 fgt_doer(evp,print_det,FGT_ID) ;
391 if(mtd_doer(evp,print_det)) LOG(INFO,
"MTD found") ;
395 fgt_doer(evp,print_det,GMT_ID) ;
398 fgt_doer(evp,print_det,IST_ID) ;
399 fgt_test(evp,print_det,IST_ID) ;
402 if(pxl_doer(evp,print_det)) LOG(INFO,
"PXL found") ;
405 sst_doer(evp,print_det) ;
408 fps_doer(evp,print_det) ;
411 rhicf_doer(evp,print_det) ;
414 etof_doer(evp,print_det) ;
417 itpc_doer(evp,print_det) ;
420 fcs_doer(evp,print_det) ;
423 stgc_doer(evp,print_det) ;
426 fgt_doer(evp,print_det,FST_ID) ;
430 #ifdef INSIST_ON_EMC_PSEUDO
431 if(emc_pseudo_doer(evp,print_det)) LOG(INFO,
"EMC found (any detector)") ;
442 LOG(INFO,
"Found %d good, %d bad events",good,bad) ;
448 static int trg_doer(
daqReader *rdr,
const char *do_print)
453 if(strcasestr(do_print,
"trg")) ;
458 dd = rdr->det(
"trg")->get(
"legacy") ;
464 printf(
"Trigger: tcubits 0x%08X, trg_word 0x%04X\n",trg_p->tcubits,trg_p->trg_word) ;
472 dd = rdr->det(
"trg")->get(
"raw") ;
478 u_char *trg_raw = dd->Byte;
484 rcc_timestamp = (ntohs(evtDesc->tcuCtrBunch_hi)<<16) | ntohs(evtDesc->DSMAddress) ;
501 desc = (simple_desc *) trg_raw ;
504 printf(
"Trigger: raw bank has %d bytes: ver 0x%02X, desc %d, len %d\n",dd->ncontent,desc->ver, desc->evt_desc, desc->len) ;
507 u_int *i32 = (u_int *) trg_raw ;
508 for(
int i=0;i<10;i++) {
509 printf(
"Trigger: word %d: 0x%08X\n",i,i32[i]) ;
519 static int hlt_doer(
daqReader *rdr,
const char *do_print)
524 if(strcasestr(do_print,
"hlt")) ;
527 for(
int s=1;s<=24;s++) {
528 dd = rdr->det(
"hlt")->get(
"tpx",s) ;
529 while(dd && dd->iterate()) {
532 printf(
"HLT TPX sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
537 dd = rdr->det(
"hlt")->get(
"trg") ;
538 while(dd && dd->iterate()) {
541 printf(
"HLT TRG sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
545 dd = rdr->det(
"hlt")->get(
"tof") ;
546 while(dd && dd->iterate()) {
549 printf(
"HLT TOF sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
553 dd = rdr->det(
"hlt")->get(
"gl3") ;
554 while(dd && dd->iterate()) {
558 printf(
"HLT GL3 sec %02d: bytes %d: %d %s\n",dd->sec,dd->ncontent,h->bytes,h->name) ;
567 static int l4_doer(
daqReader *rdr,
const char *do_print)
572 if(strcasestr(do_print,
"l4")) ;
575 for(
int s=1;s<=24;s++) {
576 dd = rdr->det(
"l4")->get(
"tpx",s) ;
577 while(dd && dd->iterate()) {
580 printf(
"L4 TPX sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
585 dd = rdr->det(
"l4")->get(
"trg") ;
586 while(dd && dd->iterate()) {
589 printf(
"l4 TRG sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
593 dd = rdr->det(
"l4")->get(
"tof") ;
594 while(dd && dd->iterate()) {
597 printf(
"l4 TOF sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
601 dd = rdr->det(
"l4")->get(
"gl3") ;
602 while(dd && dd->iterate()) {
606 UINT32 *x = (UINT32 *)h->data;
607 printf(
"L4 GL3 sec %02d: bytes %d: %d %s [0x%08x 0x%08x 0x%08x 0x%08x]\n",dd->sec,dd->ncontent,h->bytes,h->name,x[0],x[1],x[2],x[3]) ;
608 printf(
"sizeof %ld offset %ld\n",
sizeof(
l4_gl3_t), (
char *)h->data - (
char *)h);
617 static int tpx_doer(
daqReader *rdr,
const char *do_print)
624 u_int tot_pixels = 0 ;
628 memset(sec_cou,0,
sizeof(sec_cou)) ;
632 if(strcasestr(do_print,
"tpx")) ;
638 memset(s_mask,0,
sizeof(s_mask)) ;
640 for(
int s=1;s<=24;s++) {
643 memset(adctb, 0,
sizeof(adctb));
664 int pixel_count[46] ;
665 memset(pixel_count,0,
sizeof(pixel_count)) ;
668 dd = rdr->det(
"tpx")->get(
"adc",s) ;
670 while(dd->iterate()) {
678 printf(
"TPX: sec %02d, row %2d, pad %3d: %3d pixels\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
681 pixel_count[dd->row] += dd->ncontent ;
682 pcount += dd->ncontent;
688 for(u_int i=0;i<dd->ncontent;i++) {
689 int tb = dd->adc[i].tb ;
690 int adc = dd->adc[i].adc ;
698 if(seq==0) first_i = i ;
700 if(tb==(last_tb-1)) {
707 if(seq>=5 && (dd->adc[first_i].tb<30)) {
708 for(u_int j=first_i;j<i;j++) {
716 if(seq>=5 && (dd->adc[first_i].tb<30)) {
717 for(u_int j=first_i;j<i;j++) {
729 for(u_int i=0;i<dd->ncontent;i++) {
731 printf(
"%d %d %d %d %d\n",dd->sec,dd->row,dd->pad,dd->adc[i].tb,dd->adc[i].adc) ;
741 s_mask[dd->sec-1]=1 ;
745 for(
int row=0;row<=45;row++) {
746 int max_cou = tpc_rowlen[row] * 400 ;
747 if(max_cou==0) max_cou = 1 ;
748 double occ = 100.0*(double)pixel_count[row]/(
double)max_cou ;
749 printf(
"+sector %2d, row %2d: pixels %d, occupancy %.1f%%\n",s,row,pixel_count[row],occ) ;
755 if((rdr->seq > JMLEVTMIN) && (rdr->seq < JMLEVTMAX)) {
756 for(
int i=0;i<100;i++) {
757 printf(
"%d %d %d %d %lf %d\n",
771 LOG(DBG,
"Doing TPX get CLD, s %d",s) ;
773 dd = rdr->det(
"tpx")->get(
"cld",s) ;
774 while(dd && dd->iterate()) {
779 s_mask[dd->sec-1]=1 ;
780 sec_cou[dd->sec-1] += dd->ncontent ;
783 printf(
"CLD: sec %02d, row %2d: %3d clusters (evt %d)\n",dd->sec,dd->row,dd->ncontent,good) ;
786 tot_pixels += dd->ncontent ;
788 for(u_int i=0;i<dd->ncontent;i++) {
797 if(p1 > 200) bad = 1 ;
798 if(p2 > 200) bad = 1 ;
800 if((p2-p1)>14) bad = 1 ;
802 if(t1 > 1200) bad = 1 ;
803 if(t2 > 1200) bad = 1 ;
805 if((t2-t1)>30) bad = 1 ;
808 printf(
"\tpad %7.3f[%d,%d], time %7.3f[%d,%d], charge %5d, flags 0x%02X\n",
809 dd->cld[i].pad,dd->cld[i].p1,dd->cld[i].p2,
810 dd->cld[i].tb,dd->cld[i].t1,dd->cld[i].t2,
811 dd->cld[i].charge,dd->cld[i].flags) ;
821 printf(
"%d %d %d %d %d %d\n",
832 dd = rdr->det(
"tpx")->get(
"pedrms",s) ;
833 while(dd && dd->iterate()) {
837 s_mask[dd->sec-1]=1 ;
840 printf(
"TPX: sec %02d, row %2d, pad %3d (%d pix)\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
842 for(u_int tb=0;tb<dd->ncontent;tb++) {
843 printf(
" tb %3d: ped %3d, rms %.2f\n",tb,ped[tb].ped,ped[tb].rms) ;
850 for(
int r=1;r<=6;r++) {
851 dd = rdr->det(
"tpx")->get(
"altro",s,r) ;
852 while(dd && dd->iterate()) {
855 printf(
"TPX ALTRO: sec %02d, RDO %d: ALTRO %3d, ch %2d: %3d pixels\n",dd->sec,r,dd->row,dd->pad,dd->ncontent) ;
868 strcat(fstr,
"CLD ") ;
875 strcat(fstr,
"ADC " ) ;
878 strcat(fstr,
"PEDRMS ") ;
883 for(
int s=0;s<24;s++) {
886 sprintf(stmp,
"%d ",s+1) ;
893 LOG(INFO,
"TPX found [%s;%d]",fstr,s_cou) ;
903 static int ftp_doer(
daqReader *rdr,
const char *do_print)
908 if(strcasestr(do_print,
"ftp")) ;
911 dd = rdr->det(
"ftp")->get(
"legacy") ;
913 while(dd && dd->iterate()) {
918 printf(
"FTP sector %d: pixels %d\n",dd->sec,ftp->channels) ;
921 for(
int ss=0;ss<2;ss++) {
922 for(
int rb=0;
rb<10;
rb++) {
923 for(
int pad=0;pad<960;pad++) {
924 for(
int tbi=0;tbi<ftp->counts[ss][
rb][pad];tbi++) {
925 printf(
"%d %d %d %d %d\n",
927 ftp->timebin[ss][
rb][pad][tbi],
928 ftp->adc[ss][
rb][pad][tbi]);
941 static int tpc_doer(
daqReader *rdr,
const char *do_print)
946 if(strcasestr(do_print,
"tpc")) ;
952 for(
int s=1;s<=24;s++) {
953 dd = rdr->det(
"tpc")->get(
"legacy",s) ;
955 while(dd && dd->iterate()) {
960 printf(
"TPC sector %d: pixels %d\n",dd->sec,tpc->channels_sector) ;
961 for(
int r=0;r<45;r++) {
962 for(
int c=0;c<tpc->cl_counts[r];c++) {
963 printf(
"row %2d: pad %1.f, tb %.1f, charge %d\n",r+1,
964 tpc->cl[r][c].p,tpc->cl[r][c].t,tpc->cl[r][c].charge) ;
983 static int pmd_doer(
daqReader *rdr,
const char *do_print)
988 if(strcasestr(do_print,
"pmd")) ;
991 dd = rdr->det(
"pmd")->get(
"legacy") ;
993 if(dd && dd->iterate()) {
997 for(
int crate=0;crate<2;crate++) {
998 printf(
"Crate %s: status %d, mode %d\n",crate==0?
"Up":
"Dn",pmd_p->status[crate],pmd_p->mode) ;
1000 for(
int c=0;c<PMD_CRAMS_MAX;c++) {
1001 for(
int s=0;s<2;s++) {
1002 for(
int ch=0;ch<PMD_CRAMS_CH_MAX;ch++) {
1003 printf(
" CRAM %2d: side %d: ch %4d: adc %4d [ped %4.1f, rms %4.2f, thr %4.1f]\n",
1005 pmd_p->adc[crate][c][s][ch],
1006 (
double)pmd_p->ped[crate][c][s][ch]/16.0,
1007 (
double)pmd_p->rms[crate][c][s][ch]/16.0,
1008 (
double)pmd_p->thr[crate][c][s][ch]/16.0) ;
1018 if(found) LOG(NOTE,
"PMD legacy found") ;
1025 static int bsmd_doer(
daqReader *rdr,
const char *do_print)
1031 int adc_non_zs_found = 0 ;
1035 if(strcasestr(do_print,
"bsmd")) ;
1040 for(
int f=1;f<=12;f++) {
1041 dd = rdr->det(
"bsmd")->get(
"raw",0,f) ;
1043 while(dd->iterate()) {
1047 if(do_print) printf(
"BSMD RAW: fiber %2d [==%d], sector %d:\n",dd->rdo,f,dd->sec) ;
1050 for(
int i=0;i<10;i++) {
1051 if(do_print) printf(
" Head %2d = %08X\n",i,dd->Int32[i]) ;
1059 for(
int f=1;f<=12;f++) {
1060 dd = rdr->det(
"bsmd")->get(
"adc_non_zs",0,f) ;
1062 while(dd->iterate()) {
1064 adc_non_zs_found = 1 ;
1068 if(do_print) printf(
"BSMD non-ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
1071 for(
int i=0;i<BSMD_DATSIZE;i++) {
1072 if(do_print) printf(
" %4d = %4d\n",i,d->adc[i]) ;
1079 for(
int f=1;f<=12;f++) {
1080 dd = rdr->det(
"bsmd")->get(
"adc",0,f) ;
1082 while(dd->iterate()) {
1088 if(do_print) printf(
"BSMD ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
1090 for(
int i=0;i<BSMD_DATSIZE;i++) {
1092 if(do_print)
if(d->adc[i]) printf(
" %4d = %4d\n",i,d->adc[i]) ;
1099 for(
int f=1;f<=12;f++) {
1100 dd = rdr->det(
"bsmd")->get(
"ped",0,f) ;
1102 while(dd->iterate()) {
1108 if(do_print) printf(
"BSMD PED: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
1110 for(
int i=0;i<BSMD_DATSIZE;i++) {
1111 if(do_print) printf(
" %4d = %4d\n",i,d->adc[i]) ;
1118 for(
int f=1;f<=12;f++) {
1119 dd = rdr->det(
"bsmd")->get(
"rms",0,f) ;
1121 while(dd->iterate()) {
1127 if(do_print) printf(
"BSMD RMS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
1129 for(
int i=0;i<BSMD_DATSIZE;i++) {
1130 if(do_print) printf(
" %4d = %.2f\n",i,(
double)d->adc[i]/8.0) ;
1141 strcat(fstr,
"RAW ") ;
1145 strcat(fstr,
"ADC-ZS ") ;
1147 if(adc_non_zs_found) {
1148 strcat(fstr,
"ADC-non-ZS " ) ;
1151 strcat(fstr,
"PEDRMS ") ;
1155 LOG(INFO,
"BSMD found [%s]",fstr) ;
1162 static int esmd_doer(
daqReader *rdr,
const char *do_print)
1167 if(strcasestr(do_print,
"esmd")) ;
1171 dd = rdr->det(
"esmd")->get(
"adc") ;
1173 while(dd->iterate()) {
1178 for(
int i=0;i<ESMD_MAXFEE;i++) {
1179 for(
int j=0;j<ESMD_PRESIZE;j++) {
1180 if(do_print) printf(
"ESMD: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
1182 for(
int j=0;j<ESMD_DATSIZE;j++) {
1183 if(do_print) printf(
"ESMD: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
1193 static int etow_doer(
daqReader *rdr,
const char *do_print)
1198 if(strcasestr(do_print,
"etow")) ;
1202 dd = rdr->det(
"etow")->get(
"adc") ;
1204 while(dd->iterate()) {
1209 for(
int i=0;i<ETOW_MAXFEE;i++) {
1210 for(
int j=0;j<ETOW_PRESIZE;j++) {
1211 if(do_print) printf(
"ETOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
1213 for(
int j=0;j<ETOW_DATSIZE;j++) {
1214 if(do_print) printf(
"ETOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
1224 static int btow_doer(
daqReader *rdr,
const char *do_print)
1229 if(strcasestr(do_print,
"btow")) ;
1234 dd = rdr->det(
"btow")->get(
"raw") ;
1236 while(dd->iterate()) {
1237 u_short *s16 = (u_short *) dd->Void ;
1240 printf(
"BTOW: bytes %d\n",dd->ncontent) ;
1243 for(u_int i=0;i<dd->ncontent/2;i++) {
1245 printf(
"%d: 0x%04X [%d dec]\n",i,s16[i],s16[i]) ;
1252 dd = rdr->det(
"btow")->get(
"adc") ;
1254 while(dd->iterate()) {
1259 for(
int i=0;i<BTOW_MAXFEE;i++) {
1260 for(
int j=0;j<BTOW_PRESIZE;j++) {
1261 if(do_print) printf(
"BTOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
1263 for(
int j=0;j<BTOW_DATSIZE;j++) {
1264 if(do_print) printf(
"BTOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
1274 #ifdef INSIST_ON_EMC_PSEUDO
1275 static int emc_pseudo_doer(
daqReader *rdr,
const char *do_print)
1280 if(strcasestr(do_print,
"emc_pseudo")) ;
1284 dd = rdr->det(
"emc_pseudo")->get(
"legacy") ;
1286 while(dd->iterate()) {
1291 if(do_print) printf(
"BTOW found %d (%d ch), BSMD found %d (%d ch), ETOW found %d (%d ch), ESMD found %d (%d ch)\n",
1292 d->btow_in, d->btow_ch, d->bsmd_in, d->bsmd_ch, d->etow_in, d->etow_ch, d->esmd_in, d->esmd_ch) ;
1302 static int pp2pp_doer(
daqReader *rdr,
const char *do_print)
1306 int pedrms_found = 0 ;
1307 int adc_ped_sub_found = 0 ;
1311 if(strcasestr(do_print,
"pp2pp")) ;
1314 dd = rdr->det(
"pp2pp")->get(
"raw") ;
1316 while(dd->iterate()) {
1320 printf(
"PP2PP: RAW: sector %d, RDO %d, bytes %d\n",dd->sec,dd->rdo,dd->ncontent) ;
1322 u_int *d32 = (u_int *)dd->Void ;
1323 for(
int i=0;i<16;i++) {
1324 printf(
" %2d: 0x%08X\n",i,d32[i]) ;
1333 dd = rdr->det(
"pp2pp")->get(
"adc") ;
1335 while(dd->iterate()) {
1342 for(
int c=0;c<PP2PP_SVX_CH;c++) {
1343 if(d->trace[c]) cou++ ;
1346 printf(
"PP2PP: sector %d, sequencer %d, chain %c, SVX %d: %d channels:\n",dd->sec,d->seq_id,
'A'+d->chain_id,d->svx_id,cou) ;
1347 for(
int c=0;c<PP2PP_SVX_CH;c++) {
1349 if(d->trace[c]) printf(
" ch %3d: ADC %3d [0x%02X], trace %d\n",c,d->adc[c],d->adc[c],d->trace[c]) ;
1357 dd = rdr->det(
"pp2pp")->get(
"adc_ped_sub") ;
1359 while(dd->iterate()) {
1360 adc_ped_sub_found++ ;
1366 for(
int c=0;c<PP2PP_SVX_CH;c++) {
1367 if(d->trace[c]) cou++ ;
1370 printf(
"PP2PP PED_SUB: sector %d, sequencer %d, chain %c, SVX %d: %d channels:\n",dd->sec,d->seq_id,
'A'+d->chain_id,d->svx_id,cou) ;
1372 for(
int c=0;c<PP2PP_SVX_CH;c++) {
1374 if(d->trace[c]) printf(
" ch %3d: ADC %3d [0x%02X], trace %d\n",c,d->adc[c],d->adc[c],d->trace[c]) ;
1382 dd = rdr->det(
"pp2pp")->get(
"pedrms") ;
1384 while(dd->iterate()) {
1390 printf(
"PP2PP PEDRMS: sector %d, sequencer %d, chain %c, SVX %d: SVX pedestal %f +- %f\n",dd->sec,d->seq_id,
'A'+d->chain_id,d->svx_id,
1391 d->svx_ped,d->svx_rms) ;
1393 for(
int c=0;c<PP2PP_SVX_CH;c++) {
1394 printf(
" ch %3d: ped %f, rms %f\n",c,d->ped[c],d->rms[c]) ;
1404 if(raw_found) strcat(fstr,
"RAW ") ;
1405 if(adc_found) strcat(fstr,
"ADC ") ;
1406 if(adc_ped_sub_found) strcat(fstr,
"ADC-PED-SUB ") ;
1407 if(pedrms_found) strcat(fstr,
"PEDRMS ") ;
1409 int found = raw_found || adc_found || pedrms_found ;
1412 LOG(INFO,
"PP2PP found [%s]",fstr) ;
1418 static int l3_doer(
daqReader *rdr,
const char *do_print)
1423 if(strcasestr(do_print,
"l3")) ;
1427 dd = rdr->det(
"l3")->get(
"legacy") ;
1429 while(dd->iterate()) {
1435 printf(
"L3/HLT: sequence %u, decision 0x%X: tracks %d, clusters %d, vertex %f:%f:%f\n",
1436 l3_p->channels, l3_p->mode,
1437 l3_p->tracks_num, l3_p->cluster_num,
1438 l3_p->xVertex, l3_p->yVertex, l3_p->xVertex) ;
1441 for(u_int i=0;i<l3_p->tracks_num;i++) {
1443 printf(
" track %d: Pt %f, charge %d, nHits %d\n",i+1,
1444 l3_p->track[i].pt, l3_p->track[i].q, l3_p->track[i].nHits) ;
1455 static int fgt_doer(
daqReader *rdr,
const char *do_print,
int which)
1461 const char *d_name = 0 ;
1480 if(strcasestr(do_print,d_name)) ;
1485 dd = rdr->det(d_name)->get(
"raw") ;
1487 while(dd->iterate()) {
1491 u_int *d = (u_int *) dd->Void ;
1495 printf(
"%s RAW: RDO %d:%d: %d bytes, %d words\n",d_name,dd->sec,dd->rdo,dd->ncontent,dd->ncontent/4) ;
1497 for(
int i=0;i<10;i++) {
1498 printf(
" %3d: 0x%08X\n",i,d[i]) ;
1507 dd = rdr->det(d_name)->get(
"adc") ;
1510 if(dd && dd->meta && do_print) {
1513 printf(
"%s meta data:\n",d_name) ;
1514 for(
int r=1;r<=FGT_RDO_COU;r++) {
1515 if(meta->arc[r].present == 0) continue ;
1517 printf(
" ARC %d: error %c; format %d, ARM mask 0x%X\n",r,meta->arc[r].error?
'Y':
'N',
1518 meta->arc[r].format_code,
1519 meta->arc[r].arm_mask) ;
1521 for(
int arm=0;arm<FGT_ARM_COU;arm++) {
1522 if(meta->arc[r].arm[arm].present == 0) continue ;
1524 printf(
" ARM %d: error %c\n",arm,meta->arc[r].arm[arm].error?
'Y':
'N') ;
1525 printf(
" : arm_id %d, arm_seq %d, arm_err %d, apv_mask 0x%X\n",
1526 meta->arc[r].arm[arm].arm_id,
1527 meta->arc[r].arm[arm].arm_seq,
1528 meta->arc[r].arm[arm].arm_err,
1529 meta->arc[r].arm[arm].apv_mask) ;
1531 for(
int apv=0;apv<FGT_APV_COU;apv++) {
1532 if(meta->arc[r].arm[arm].apv[apv].present == 0) continue ;
1534 printf(
" APV %2d: error %c\n",apv,meta->arc[r].arm[arm].apv[apv].error?
'Y':
'N') ;
1535 printf(
" : apv_id %d, fmt %d, length %d, seq %d, capid %d, nhits %d, is_error %d, refadc %d, ntim %d\n",
1536 meta->arc[r].arm[arm].apv[apv].apv_id,
1537 meta->arc[r].arm[arm].apv[apv].fmt,
1538 meta->arc[r].arm[arm].apv[apv].length,
1539 meta->arc[r].arm[arm].apv[apv].seq,
1540 meta->arc[r].arm[arm].apv[apv].capid,
1541 meta->arc[r].arm[arm].apv[apv].nhits,
1542 meta->arc[r].arm[arm].apv[apv].is_error,
1543 meta->arc[r].arm[arm].apv[apv].refadc,
1544 meta->arc[r].arm[arm].apv[apv].ntim) ;
1552 while(dd && dd->iterate()) {
1559 printf(
"EVT %d: %s ADC: RDO %d, ARM %d, APV %d: %d values\n",good,d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1561 for(u_int i=0;i<dd->ncontent;i++) {
1562 printf(
" %5d: ch %3d, tb %d = %3d\n",i,f[i].ch,f[i].tb,f[i].adc) ;
1573 dd = rdr->det(d_name)->get(
"zs") ;
1577 if(dd && dd->meta && do_print) {
1580 printf(
"%s ZS meta data:\n",d_name) ;
1581 for(
int r=1;r<=FGT_RDO_COU;r++) {
1582 if(meta->arc[r].present == 0) continue ;
1584 printf(
" ARC %d: error %c; format %d, ARM mask 0x%X\n",r,meta->arc[r].error?
'Y':
'N',
1585 meta->arc[r].format_code,
1586 meta->arc[r].arm_mask) ;
1588 for(
int arm=0;arm<FGT_ARM_COU;arm++) {
1589 if(meta->arc[r].arm[arm].present == 0) continue ;
1591 printf(
" ARM %d: error %c\n",arm,meta->arc[r].arm[arm].error?
'Y':
'N') ;
1592 printf(
" : arm_id %d, arm_seq %d, arm_err %d, apv_mask 0x%X\n",
1593 meta->arc[r].arm[arm].arm_id,
1594 meta->arc[r].arm[arm].arm_seq,
1595 meta->arc[r].arm[arm].arm_err,
1596 meta->arc[r].arm[arm].apv_mask) ;
1598 for(
int apv=0;apv<FGT_APV_COU;apv++) {
1599 if(meta->arc[r].arm[arm].apv[apv].present == 0) continue ;
1601 printf(
" APV %2d: error %c\n",apv,meta->arc[r].arm[arm].apv[apv].error?
'Y':
'N') ;
1602 printf(
" : apv_id %d, fmt %d, length %d, seq %d, capid %d, nhits %d, is_error %d, refadc %d, ntim %d\n",
1603 meta->arc[r].arm[arm].apv[apv].apv_id,
1604 meta->arc[r].arm[arm].apv[apv].fmt,
1605 meta->arc[r].arm[arm].apv[apv].length,
1606 meta->arc[r].arm[arm].apv[apv].seq,
1607 meta->arc[r].arm[arm].apv[apv].capid,
1608 meta->arc[r].arm[arm].apv[apv].nhits,
1609 meta->arc[r].arm[arm].apv[apv].is_error,
1610 meta->arc[r].arm[arm].apv[apv].refadc,
1611 meta->arc[r].arm[arm].apv[apv].ntim) ;
1618 int charge_sum = 0 ;
1620 while(dd && dd->iterate()) {
1625 for(u_int i=0;i<dd->ncontent;i++) {
1627 charge_sum += f[i].adc ;
1633 printf(
"%s ZS: RDO %d, ARM %d, APV %d: %d values\n",d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1635 for(u_int i=0;i<dd->ncontent;i++) {
1636 printf(
" %5d: ch %3d, tb %d = %3d (flags %d)\n",i,f[i].ch,f[i].tb,f[i].adc,f[i].flags) ;
1641 if((found & 4) && do_print) {
1642 printf(
"+++ Charge sum %d\n",charge_sum) ;
1645 dd = rdr->det(d_name)->get(
"pedrms") ;
1646 while(dd && dd->iterate()) {
1657 printf(
"%s PEDRMS: RDO %d, ARM %d, APV %d: %d values\n",d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1659 for(u_int i=0;i<dd->ncontent;i++) {
1660 printf(
"%d %d %2d %3d %2d: %.3f +- %.3f\n",arc,arm,apv,f[i].ch,f[i].tb,f[i].ped,f[i].rms) ;
1669 strcat(s_found,
"RAW ") ;
1672 strcat(s_found,
"ADC ") ;
1675 strcat(s_found,
"ZS ") ;
1678 strcat(s_found,
"PEDRMS ") ;
1681 if(found) LOG(INFO,
"%s found: %s",d_name,s_found) ;
1686 static int mtd_doer(
daqReader *rdr,
const char *do_print)
1691 if(strcasestr(do_print,
"mtd")) ;
1696 dd = rdr->det(
"mtd")->get(
"raw") ;
1698 while(dd->iterate()) {
1702 u_int *d = (u_int *) dd->Void ;
1706 printf(
"MTD: RDO %d: %d bytes\n",dd->rdo,dd->ncontent) ;
1708 for(u_int i=0;i<dd->ncontent/4;i++) {
1709 printf(
" %2d: 0x%08X\n",i,d[i]) ;
1724 int QtParse(
int conf_num,
TriggerDataBlk *trg,
int *sz,
int *internal_usecs, UINT64 *bx_time, UINT64 bx64) {
1726 *internal_usecs = 0;
1727 if(trg->MainX[conf_num].offset == 0) {
1728 *sz = -1; *internal_usecs = -1; *bx_time = 0ll;
1732 char *base = (
char *)trg;
1733 QTBlock *qtb = (
QTBlock *)(base + swap32(trg->MainX[conf_num].offset));
1734 int len = swap32(trg->MainX[conf_num].length);
1737 if((len - swap32(qtb->length)) != 12) {
1738 LOG(DBG,
"Conf num %d not a QT board!", conf_num);
1740 *internal_usecs = -1;
1747 if(swap32(qtb->length) > 0 ) {
1748 unsigned int *dword = (
unsigned int *)qtb->data;
1750 unsigned int x = swap32(*dword);
1751 LOG(DBG,
"x=0x%x", x);
1752 if(x == 0xac10)
break;
1754 int addr = (x>>16) & 0xff;
1755 int nlines = x & 0xff;
1756 int usec = x & 0xff00;
1760 LOG(DBG,
"addr=%d nlines=%d usec=%d", addr, nlines, usec);
1762 *internal_usecs += usec;
1773 UINT64 tms = trgSum->LocalClocks[conf_num];
1775 while(tms < bx64) tms += 0xffffffffll;
1784 static const char *confnum2str[] = {
1810 int tinfo_fps(
daqReader *rdr, UINT64 bx64) {
1814 UINT32 fpost_sz = 0;
1816 dd = rdr->det(
"fps")->get(
"adc",1);
1821 dd = rdr->det(
"fps")->get(
"adc",2);
1828 if(fpre_bx && fpost_bx)
1829 printf(
"%d %u %u %u %d %d 0x%llx #FPS seq bx fpre fpost fpresz fpostsz trg\n",
1831 (UINT32)bx64, fpre_bx, fpost_bx, fpre_sz, fpost_sz, rdr->daqbits64_l1);
1838 static int tinfo_doer(
daqReader *rdr,
const char *do_print)
1842 printf(
"tinfo: seq = #%d (%s %d %d) token = %d detectors = 0x%x triggers = 0x%llx/0x%llx/0x%llx evpgroups=0x%x flags=0x%x freq=%f\n",
1844 rdr->streaming_node,
1854 rdr->triggerFrequency);
1857 dd = rdr->det(
"trg")->get(
"raw") ;
1866 int trgDetMask = swap16(evtDesc->trgDetMask);
1867 int pre = swap16(evtDesc->npre) & 0xF ;
1868 int post = swap16(evtDesc->npost) & 0xF;
1869 int res1 = swap16(evtDesc->res1);
1870 int trgCrateMask = (res1 & 0xfff0) << 20 | (swap16(evtDesc->npost) & 0xfff0) << 8 | (swap16(evtDesc->npre) & 0xfff0) >> 4;
1871 UINT32 bx_high = swap32(evtDesc->bunchXing_hi);
1872 UINT32 bx_low = swap32(evtDesc->bunchXing_lo);
1873 UINT64 bx64 = bx_high;
1874 bx64 = (bx64 << 32) + bx_low;
1875 float bx_sec = bx64/9.3e6;
1876 int bx7 = bx64 % 120;
1878 int addBits = swap16(evtDesc->addBits);
1880 int trg_tkn = swap16(evtDesc->TrgToken) ;
1883 printf(
"tinfo: token %d, pre %d, post %d, 0x%016llx 0x%04x\n",trg_tkn,pre,post, rdr->daqbits64, addBits) ;
1886 int crate_sz[MAX_CONF_NUM];
1887 int crate_internal_usec[MAX_CONF_NUM];
1888 UINT64 crate_bx_time[MAX_CONF_NUM];
1890 for(
int i=0;i<MAX_CONF_NUM;i++) {
1891 QtParse(i, trg, &crate_sz[i], &crate_internal_usec[i], &crate_bx_time[i], bx64);
1896 for(
int i=0;i<MAX_CONF_NUM;i++) {
1897 if(crate_bx_time[i] > 0xffffll) {
1900 printf(
"CORRUPT evt %d: %s bxtime %lld %lld\n",
1918 printf(
"l1Dsm offset %d\n",swap32(trg->L1_DSM_ofl.offset)) ;
1920 u_int bc2 = swap16(l1Dsm->BCdata[2]) ;
1921 u_int bc7bit = bc2 & 0x7F ;
1925 for(
int i=0;i<8;i++) {
1927 lastdsm[i] = swap16(l1Dsm->lastDSM[i]) ;
1928 printf(
".... lastdsm[%d]: 0x%04X\n",i,lastdsm[i]) ;
1937 u_int fcs2019 = (lastdsm[4] >> 10) & 1 ;
1938 fcs2019 |= ((lastdsm[4] >> 5) & 1) << 1 ;
1939 fcs2019 |= ((lastdsm[4] >> 7) & 1) << 2 ;
1940 fcs2019 |= ((lastdsm[4] >> 8) & 1) << 3 ;
1941 fcs2019 |= ((lastdsm[4] >> 9) & 1) << 4 ;
1942 fcs2019 |= ((lastdsm[4] >> 12) & 1) << 5 ;
1943 fcs2019 |= ((lastdsm[4] >> 13) & 1) << 6 ;
1944 fcs2019 |= ((lastdsm[4] >> 14) & 1) << 7 ;
1945 fcs2019 |= ((lastdsm[4] >> 15) & 1) << 8 ;
1947 u_int fcs2021 = lastdsm[5] ;
1948 printf(
"fcs2021 0x%04X\n",fcs2021) ;
1950 u_int fcs_main_2022 = lastdsm[2] ;
1951 u_int fcs_north_2022 = lastdsm[5] & 0xFF ;
1952 u_int fcs_south_2022 = lastdsm[5] >> 8 ;
1954 printf(
"fcs_2022: main 0x%04X, north 0x%02X, south 0x%02X\n",fcs_main_2022,fcs_north_2022,fcs_south_2022) ;
1957 printf(
"bc7bit %3d, fcs2019 0x%04X : 0x%04X 0x%04X 0x%04X 0x%04X\n",bc7bit,fcs2019,
1958 lastdsm[0],lastdsm[1],lastdsm[2],lastdsm[3]) ;
1961 for(
int i=0;i<64;i++) {
1962 if(rdr->daqbits64 & (1ll << i)) {
1963 printf(
"{%d=%d}",i,rdr->getOfflineId(i));
1968 printf(
" l1=0x%llx trgDetMask=0%x trgCrateMask=0x%x\n",rdr->daqbits64_l1,trgDetMask,trgCrateMask);
1971 for(
int i=2;i<MAX_OFFLEN-1;i++) {
1972 if(swap32(trg->MainX[i].length)) {
1974 char *nm = (
char *)trg + swap32(trg->MainX[i].offset);
1976 int *datasz = (
int *)nm;
1981 printf(
"ids %2d: crate %s[%s](0x%x):\toffset=%d\tsize=%d\tdsize=%d\n",i,
1984 swap32(trg->MainX[i].offset),
1985 swap32(trg->MainX[i].length),
1999 static int pxl_doer(
daqReader *rdr,
const char *do_print)
2004 if(strcasestr(do_print,
"pxl")) ;
2009 dd = rdr->det(
"pxl")->get(
"raw") ;
2011 while(dd->iterate()) {
2015 u_int *d = (u_int *) dd->Void ;
2019 printf(
"PXL RAW: Sector %d, RDO %d: %d bytes (%d words)\n",dd->sec,dd->rdo,dd->ncontent,dd->ncontent/4) ;
2021 int cou = dd->ncontent/4 ;
2023 if(cou > 30) cou = 30 ;
2025 for(
int i=0;i<cou;i++) {
2026 printf(
" %2d: 0x%08X\n",i,d[i]) ;
2038 static int sst_doer(
daqReader *rdr,
const char *do_print)
2043 if(strcasestr(do_print,
"sst")) ;
2048 dd = rdr->det(
"sst")->get(
"raw") ;
2050 while(dd->iterate()) {
2054 u_int *d = (u_int *) dd->Void ;
2058 printf(
"SST RAW: Sector %d, RDO %d: %d bytes (%d words)\n",dd->sec,dd->rdo,dd->ncontent,dd->ncontent/4) ;
2060 int cou = dd->ncontent/4 ;
2062 if(cou > 30) cou = 30 ;
2064 for(
int i=0;i<cou;i++) {
2065 printf(
" %2d: 0x%08X\n",i,d[i]) ;
2073 dd = rdr->det(
"sst")->get(
"adc") ;
2075 while(dd->iterate()) {
2083 printf(
"SST ADC: Sector %d, RDO %d, fiber %d: %d ADCs\n",dd->sec,dd->rdo,dd->pad,dd->ncontent) ;
2085 for(u_int i=0;i<dd->ncontent;i++) {
2086 printf(
" Strip %3d, hybrid %2d: %4d\n",sst[i].strip,sst[i].hybrid,sst[i].adc) ;
2093 dd = rdr->det(
"sst")->get(
"pedrms") ;
2095 while(dd->iterate()) {
2103 printf(
"SST PEDRMS: Sector %d, RDO %d, fiber %d: %d vals\n",dd->sec,dd->rdo,dd->pad,dd->ncontent) ;
2105 for(u_int i=0;i<dd->ncontent;i++) {
2106 for(
int h=0;h<SST_HYBRID_COU;h++) {
2107 for(
int s=0;s<SST_STRIP_COU;s++) {
2108 printf(
" ped %d, rms %.3f\n",sst->ped[h][s],(
float)sst->rms[h][s]/16.0) ;
2123 strcat(s_found,
"RAW ") ;
2126 strcat(s_found,
"ADC ") ;
2129 strcat(s_found,
"PEDRMS ") ;
2132 if(found) LOG(INFO,
"SST: found %s",s_found) ;
2142 static int fgt_test(
daqReader *rdr,
const char *do_print,
int which)
2148 ped->tb_cou_xpect = 9 ;
2149 ped->init(0x3F, which) ;
2150 ped->from_cache(
"/net/ist01/RTScache/pedestals.txt") ;
2151 ped->bad_from_cache() ;
2152 double perc_bad = ped->do_thresh(5.0,2) ;
2154 LOG(INFO,
"IST: bad channels %.1f%%",perc_bad) ;
2159 static int sst_test(
daqReader *rdr,
int mode)
2165 LOG(TERR,
"sst_test: mode %d",mode) ;
2170 ped[0]->sector = 1 ;
2174 ped[1]->sector = 2 ;
2179 daq_dta *dd = rdr->det(
"sst")->get(
"raw") ;
2183 while(dd && dd->iterate()) {
2185 ((
daq_sst *)(rdr->det(
"sst")))->raw_to_adc_utility(dd->sec,dd->rdo,(
char *)dd->Void,dd->ncontent/4,0,0) ;
2188 ped[dd->sec-1]->accum((
char *)dd->Void, dd->ncontent, dd->rdo) ;
2190 LOG(NOTE,
"Accum done") ;
2198 ped[0]->to_cache(
"/log",run_number) ;
2199 ped[1]->to_cache(
"/log",run_number) ;
2208 static int fps_doer(
daqReader *rdr,
const char *do_print)
2211 int pedrms_found = 0 ;
2213 const double cpu_clock = 2166855000.0 ;
2216 if(strcasestr(do_print,
"fps")) ;
2222 for(
int sec=1;sec<=2;sec++) {
2224 dd = rdr->det(
"fps")->get(
"adc",sec) ;
2226 while(dd && dd->iterate()) {
2227 adc_found |= 1 << (dd->sec - 1) ;
2233 double occ = 100.0 * (double)dd->ncontent / (
double)32 ;
2237 for(u_int i=0;i<dd->ncontent;i++) {
2241 printf(
"FPS sector %d: xing %2d, QT %d, chs %d (occupancy %.2f %%, charge %d)\n",dd->sec,(
char)dd->pad,dd->row,dd->ncontent,occ,sum) ;
2249 double stp = ((
double) hdr->tick) * 1024.0 ;
2255 double readout = ((double) (u_int) hdr->delta) * 1024.0 ;
2257 readout /= cpu_clock ;
2258 readout *= 1000000.0 ;
2260 double just_readout = ((double)(u_int) hdr->reserved[0]) * 1024.0 ;
2261 just_readout /= cpu_clock ;
2262 just_readout *= 1000000.0 ;
2264 u_int rcc_tick = hdr->reserved[1] ;
2266 printf(
"FPS Sector %d META: time of STP-arrival %.1f us, time of End-of-Readout %.1f us (delta %.1f us, just readout %.1f us), RCC tick %u, RCC delta %d\n",
2267 dd->sec,stp, readout, readout-stp, readout-just_readout, rcc_tick, rcc_tick-rcc_timestamp) ;
2269 for(u_int i=0;i<dd->ncontent;i++) {
2270 printf(
" ch %2d: ADC %4d, TDC %2d\n",a[i].ch, a[i].adc, a[i].tdc) ;
2279 dd = rdr->det(
"fps")->get(
"pedrms") ;
2281 while(dd->iterate()) {
2287 printf(
"FPS PEDRMS: Sector %d: QT %d\n",dd->sec,dd->rdo) ;
2289 for(
int i=0;i<ped->ch_cou;i++) {
2290 printf(
" ch %2d: %f +- %f (bad 0x%X)\n",i,
2291 ped->ped[i].ped,ped->ped[i].rms,ped->ped[i].flag) ;
2302 if(adc_found & 1) strcat(fstr,
"FPS-ADC ") ;
2303 if(adc_found & 2) strcat(fstr,
"FPOST-ADC ") ;
2305 if(pedrms_found) strcat(fstr,
"PEDRMS ") ;
2308 if(adc_found || pedrms_found) found = 1 ;
2312 LOG(INFO,
"FPS found: [%s]",fstr) ;
2319 static int rhicf_doer(
daqReader *rdr,
const char *do_print)
2324 if(strcasestr(do_print,
"rhicf")) ;
2327 dd = rdr->det(
"rhicf")->get(
"raw") ;
2331 while(dd->iterate()) {
2335 printf(
"RHICF: %d bytes\n",dd->ncontent) ;
2337 for(
int i=0;i<10;i++) {
2338 printf(
" %d: 0x%08X\n",i,dd->Int32[i]) ;
2348 LOG(INFO,
"RHICF found") ;
2355 static int etof_doer(
daqReader *rdr,
const char *do_print)
2360 if(strcasestr(do_print,
"etof")) ;
2363 dd = rdr->det(
"etof")->get(
"raw") ;
2367 while(dd->iterate()) {
2371 printf(
"ETOF: %d bytes\n",dd->ncontent) ;
2373 u_int words = dd->ncontent/4 ;
2374 if(words > 16) words = 16 ;
2376 for(u_int i=0;i<words;i++) {
2377 printf(
" %d/%d: 0x%08X\n",i,dd->ncontent/4,dd->Int32[i]) ;
2387 LOG(INFO,
"ETOF found") ;
2394 static int itpc_doer(
daqReader *rdr,
const char *do_print)
2409 memset(rdos,0,
sizeof(rdos)) ;
2411 memset(sec,0,
sizeof(sec)) ;
2413 if(strcasestr(do_print,
"itpc")) ;
2416 for(
int s=1;s<=24;s++) {
2419 dd = rdr->det(
"itpc")->get(
"raw",s) ;
2422 while(dd->iterate()) {
2425 rdos[dd->row-1] = 1 ;
2430 printf(
"ITPC RAW: %d: sector %2d, RDO %d: %d rawbytes\n",rdr->seq,dd->sec,dd->row,dd->ncontent) ;
2432 u_int *d32 = (u_int *)dd->Void ;
2434 for(u_int i=0;i<dd->ncontent/4;i++) {
2435 printf(
"%4d = 0x%08X\n",i,d32[i]) ;
2449 dd = rdr->det(
"itpc")->get(
"sampa",s) ;
2451 while(dd->iterate()) {
2457 int rdo = (dd->row >> 4)+1;
2458 int port = (dd->row & 0xF)+1 ;
2459 int ch = (dd->pad) & 0xFF ;
2460 int fee_id = (dd->pad >> 8) ;
2462 if(dd->ncontent) printf(
"ITPC SAMPA: sector %2d, RDO %d, FEE #%02d (padplane %02d), CH %2d: %3d timebins\n",dd->sec,rdo,port,fee_id,ch,dd->ncontent) ;
2464 for(u_int i=0;i<dd->ncontent;i++) {
2465 printf(
"\ttb %3d = %4d ADC\n",dd->adc[i].tb,dd->adc[i].adc) ;
2476 memset(adctb, 0,
sizeof(adctb));
2478 dd = rdr->det(
"itpc")->get(
"adc",s) ;
2480 while(dd->iterate()) {
2483 pixels += dd->ncontent ;
2487 for(u_int i=0;i<dd->ncontent;i++) {
2488 adctb[dd->adc[i].tb] += dd->adc[i].adc;
2492 if(dd->ncontent) printf(
"ITPC ADC %d: sector %2d, row %2d, pad %3d: %3d timebins\n",rdr->seq,dd->sec,dd->row,dd->pad,dd->ncontent) ;
2494 for(u_int i=0;i<dd->ncontent;i++) {
2495 printf(
"\ttb %3d = %4d ADC\n",dd->adc[i].tb,dd->adc[i].adc) ;
2504 if((rdr->seq > JMLEVTMIN) && rdr->seq < JMLEVTMAX) {
2505 for(
int i=0;i<100;i++) {
2506 printf(
"%d %d %d %d %lf %d\n",
2521 dd = rdr->det(
"itpc")->get(
"cld",s) ;
2523 while(dd->iterate()) {
2526 clusters += dd->ncontent ;
2529 sec[dd->sec] += dd->ncontent ;
2532 printf(
"ITPC CLD: %d: sector %2d, row %2d: %3d clusters\n",rdr->seq,dd->sec,dd->row,dd->ncontent) ;
2534 for(u_int i=0;i<dd->ncontent;i++) {
2535 printf(
"\t%f %d %d %f %d %d %d 0x%X\n", dd->cld[i].pad,dd->cld[i].p1,dd->cld[i].p2,
2536 dd->cld[i].tb,dd->cld[i].t1,dd->cld[i].t2,
2537 dd->cld[i].charge,dd->cld[i].flags) ;
2547 dd = rdr->det(
"itpc")->get(
"pedrms",s) ;
2549 while(dd->iterate()) {
2553 printf(
"ITPC PEDRMS: sector %2d, FEE %3d, CH %2d: %d content\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
2564 int adc_fy17_found = 0 ;
2566 dd = rdr->det(
"itpc")->get(
"ifee_fy17_sampa") ;
2569 while(dd->iterate()) {
2570 adc_fy17_found = 1 ;
2573 printf(
"ITPC: sector %2d, FEE %2d, ch %2d: pixels %3d\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
2574 for(u_int i=0;i<dd->ncontent;i++) {
2575 printf(
"\ttb %3d = %4d ADC\n",dd->adc[i].tb, dd->adc[i].adc) ;
2583 if(adc_fy17_found) {
2584 LOG(INFO,
"ITPC-FY17 found") ;
2591 if(adc_found || cld_found || ped_found) found = 1 ;
2604 for(
int i=1;i<=24;i++) {
2606 printf(
"%d %d %d %d %d %d\n",
2617 sprintf(fstr,
"ADC ") ;
2624 strcat(fstr,
"CLD ") ;
2630 if(ped_found) strcat(fstr,
"PEDRMS ") ;
2633 LOG(INFO,
"ITPC found [%s] pixels %d, clusters %d",fstr,pixels,clusters) ;
2644 static int fcs_doer(
daqReader *rdr,
const char *do_print)
2656 if(strcasestr(do_print,
"fcs")) ;
2665 if(print_mode & 1) {
2668 if(print_mode & 2) {
2672 if(print_mode & 3) {
2677 printf(
"FCS evt %d, token %d\n",good,evp->token) ;
2680 dd = rdr->det(
"fcs")->get(
"ped") ;
2681 while(dd && dd->iterate()) {
2688 if(do_print && want_ped) {
2689 printf(
"FCS PED: %d: S%02d:%d: %d:%d:%d (V%d)\n",good,dd->sec,dd->rdo,
2690 p->det,p->ns,p->dep,p->fmt_version) ;
2692 printf(
" s1_delay %d\n",p->s1_delay) ;
2695 for(
int c=0;c<32;c++) {
2696 printf(
" ch %02d: ped %6.3f, gain %6.3f\n",c,
2697 (
double)p->ped[c].ped/8.0,(
double)p->ped[c].gain/256.0) ;
2701 printf(
" ch_mask 0x%llX, dsm_delay %d, dsm_mode %d, dsm_pattern 0x%04X\n",
2702 p->ch_mask,p->dsm_delay,p->dsm_mode,p->dsm_pattern) ;
2712 dd = rdr->det(
"fcs")->get(
"raw") ;
2716 while(dd->iterate()) {
2720 u_short *d = (u_short *)dd->Void ;
2721 for(u_int i=0;i<dd->ncontent/2;i++) {
2722 printf(
"%d = 0x%04X\n",i,d[i]) ;
2731 dd = rdr->det(
"fcs")->get(
"adc") ;
2734 while(dd->iterate()) {
2737 if(do_print && want_adc) {
2738 int sector = ((dd->sec >> 11) & 0x1F)+1 ;
2739 int rdo = ((dd->sec >> 8) & 0x7)+1 ;
2740 int det = (dd->sec >> 6) & 0x3;
2741 int ns = (dd-> sec >> 5) & 1 ;
2746 printf(
"FCS ADC %d: S%d:%d [det %d, ns %d, dep %d] ch %d, %d words\n",good,sector,rdo,det,ns,dep,ch,dd->ncontent) ;
2747 u_short *d16 = (u_short *)dd->Void ;
2749 for(u_int i=0;i<dd->ncontent;i++) {
2750 u_int flags = d16[i] >> 12 ;
2751 u_int
data = d16[i] & 0xFFF ;
2754 printf(
" %5d = 0x%X = %4u\n",i,flags,data) ;
2757 printf(
" %5d = 0x%X = 0x%04X\n",i,flags,data) ;
2766 dd = rdr->det(
"fcs")->get(
"zs") ;
2770 while(dd->iterate()) {
2773 int sector = ((dd->sec >> 11) & 0x1F)+1 ;
2774 int rdo = ((dd->sec >> 8) & 0x7)+1 ;
2775 int det = (dd->sec >> 6) & 0x3;
2776 int ns = (dd-> sec >> 5) & 1 ;
2783 if(do_print && want_zs) {
2785 printf(
"FCS ZS %d: S%d:%d [det %d, ns %d, dep %d] ch %d, %d ADCs\n",good,sector,rdo,det,ns,dep,ch,dd->ncontent) ;
2787 for(u_int i=0;i<dd->ncontent;i++) {
2789 printf(
" TB %5d, flags %d, ADC 0x%02X\n",dd->adc[i].tb,dd->adc[i].adc>>12,dd->adc[i].adc&0xFFF) ;
2792 printf(
" TB %5d, flags %d, ADC %4u\n",dd->adc[i].tb,dd->adc[i].adc>>12,dd->adc[i].adc&0xFFF) ;
2809 if(zs_found) strcat(fstr,
" ") ;
2810 strcat(fstr,
"ADC") ;
2814 strcat(fstr,
" PED") ;
2818 if(raw_found || zs_found || ped_found) {
2819 LOG(INFO,
"FCS found: %s",fstr) ;
2826 static int stgc_doer(
daqReader *rdr,
const char *do_print)
2828 int altro_found = 0 ;
2833 if(strcasestr(do_print,
"stgc")) ;
2839 dd = rdr->det(
"stgc")->get(
"raw") ;
2843 while(dd->iterate()) {
2847 printf(
"STGC RAW: sec %02d, RDO %d: bytes %d\n",dd->sec,dd->rdo,dd->ncontent) ;
2862 dd = rdr->det(
"stgc")->get(
"altro") ;
2864 ((
daq_stgc *)rdr->det(
"stgc"))->xing_min = -65000 ;
2865 ((
daq_stgc *)rdr->det(
"stgc"))->xing_max = 65000 ;
2867 while(dd && dd->iterate()) {
2872 printf(
"STGC ALTRO: evt %d: sec %d, ALTRO %2d(FEE%02d):%02d\n",good,dd->sec,dd->row,dd->row/2,dd->pad) ;
2874 for(u_int i=0;i<dd->ncontent;i++) {
2875 printf(
" %3d %3d\n",dd->adc[i].tb,dd->adc[i].adc) ;
2881 dd = rdr->det(
"stgc")->get(
"vmm") ;
2885 while(dd && dd->iterate()) {
2891 printf(
"STGC VMM: evt %d: sec %d, RDO %d: hits %d\n",good,dd->sec,dd->rdo,dd->ncontent) ;
2894 for(u_int i=0;i<dd->ncontent;i++) {
2895 u_char feb = vmm[i].feb_vmm >> 2 ;
2896 u_char vm = vmm[i].feb_vmm & 3 ;
2898 printf(
" FEB %d:%d [0x%X], ch %02d: ADC %3d, BCID %4d, tb %4d, BCID_delta %4d\n",feb,vm,vmm[i].feb_vmm,vmm[i].ch,
2899 vmm[i].adc,vmm[i].bcid,vmm[i].tb,vmm[i].bcid_delta) ;
2904 if(altro_found || vmm_found) {
2907 strcpy(fstr,
"STGC found: ") ;
2909 if(altro_found) strcat(fstr,
"ALTRO ") ;
2910 if(vmm_found) strcat(fstr,
"VMM ") ;
2912 LOG(INFO,
"%s",fstr) ;
2915 return (altro_found || vmm_found) ;