00001 #include <stdio.h>
00002 #include <unistd.h>
00003 #include <getopt.h>
00004 #include <sys/types.h>
00005 #include <stdlib.h>
00006
00007 #include <rtsLog.h>
00008 #include <rtsSystems.h>
00009
00010
00011 #include <DAQ_READER/daqReader.h>
00012 #include <DAQ_READER/daq_dta.h>
00013
00014 #include <trgDataDefs.h>
00015
00016
00017
00018 #include <DAQ_BSMD/daq_bsmd.h>
00019 #include <DAQ_BTOW/daq_btow.h>
00020 #include <DAQ_EMC/daq_emc.h>
00021 #include <DAQ_ESMD/daq_esmd.h>
00022 #include <DAQ_ETOW/daq_etow.h>
00023 #include <DAQ_FPD/daq_fpd.h>
00024 #include <DAQ_FTP/daq_ftp.h>
00025 #include <DAQ_L3/daq_l3.h>
00026 #include <DAQ_PMD/daq_pmd.h>
00027 #include <DAQ_PP2PP/daq_pp2pp.h>
00028 #include <DAQ_RIC/daq_ric.h>
00029 #include <DAQ_SC/daq_sc.h>
00030 #include <DAQ_SSD/daq_ssd.h>
00031 #include <DAQ_SVT/daq_svt.h>
00032 #include <DAQ_TOF/daq_tof.h>
00033 #include <DAQ_TPC/daq_tpc.h>
00034 #include <DAQ_TPX/daq_tpx.h>
00035 #include <DAQ_TRG/daq_trg.h>
00036 #include <DAQ_HLT/daq_hlt.h>
00037 #include <DAQ_FGT/daq_fgt.h>
00038 #include <DAQ_MTD/daq_mtd.h>
00039
00040
00041
00042
00043 static int bsmd_doer(daqReader *rdr, const char *do_print) ;
00044 static int esmd_doer(daqReader *rdr, const char *do_print) ;
00045 static int btow_doer(daqReader *rdr, const char *do_print) ;
00046 static int etow_doer(daqReader *rdr, const char *do_print) ;
00047 static int tpc_doer(daqReader *rdr, const char *do_print) ;
00048 static int tpx_doer(daqReader *rdr, const char *do_print) ;
00049 static int trg_doer(daqReader *rdr, const char *do_print) ;
00050 static int ftp_doer(daqReader *rdr, const char *do_print) ;
00051 static int pmd_doer(daqReader *rdr, const char *do_print) ;
00052 static int hlt_doer(daqReader *rdr, const char *do_print) ;
00053 static int emc_pseudo_doer(daqReader *rdr, const char *do_print) ;
00054 static int pp2pp_doer(daqReader *rdr, const char *do_print) ;
00055 static int l3_doer(daqReader *rdr, const char *do_print) ;
00056 static int fgt_doer(daqReader *rdr, const char *do_print) ;
00057 static int mtd_doer(daqReader *rdr, const char *do_print) ;
00058 static int tinfo_doer(daqReader *rdr, const char *do_print);
00059
00060
00061 static int good ;
00062
00063 int main(int argc, char *argv[])
00064 {
00065 extern char *optarg ;
00066 extern int optind ;
00067 int c ;
00068 const char *print_det = "" ;
00069 char _mountpoint[256];
00070 char *mountpoint = NULL;
00071
00072 rtsLogOutput(RTS_LOG_STDERR) ;
00073 rtsLogLevel((char *)WARN) ;
00074
00075
00076 while((c = getopt(argc, argv, "D:d:m:h")) != EOF) {
00077 switch(c) {
00078 case 'd' :
00079 rtsLogLevel(optarg) ;
00080 break ;
00081 case 'D' :
00082 print_det = optarg ;
00083 break ;
00084 case 'm' :
00085 mountpoint = _mountpoint;
00086 strcpy(mountpoint, optarg);
00087 break;
00088
00089 default :
00090 break ;
00091 }
00092 }
00093
00094 class daqReader *evp ;
00095 evp = new daqReader(argv[optind]) ;
00096 if(mountpoint) {
00097 evp->setEvpDisk(mountpoint);
00098 }
00099
00100 good=0;
00101 int bad=0;
00102
00103 for(;;) {
00104 char *ret = evp->get(0,EVP_TYPE_ANY);
00105
00106 if(ret) {
00107 if(evp->status) {
00108 LOG(ERR,"evp status is non-null [0x08X, %d dec]",evp->status,evp->status) ;
00109 continue ;
00110 }
00111 good++;
00112 }
00113 else {
00114 switch(evp->status) {
00115 case EVP_STAT_OK:
00116 continue;
00117 case EVP_STAT_EOR:
00118 LOG(DBG, "End of Run/File");
00119 if(evp->IsEvp()) {
00120 LOG(DBG, "Wait a second...");
00121 sleep(1);
00122 continue;
00123 }
00124 break;
00125 case EVP_STAT_EVT:
00126 bad++;
00127 LOG(WARN, "Problem getting event - skipping [good %d, bad %d]",good,bad);
00128 sleep(1);
00129 continue;
00130 case EVP_STAT_CRIT:
00131 LOG(CRIT,"evp->status CRITICAL (?)") ;
00132 return -1;
00133 }
00134 }
00135
00136
00137 if(evp->status == EVP_STAT_EOR) {
00138 LOG(INFO,"End of File reached...") ;
00139 break ;
00140 }
00141
00142 daq_dta *dd ;
00143
00144
00145 LOG(INFO,"evt %d: sequence %d: token %4d, trgcmd %d, daqcmd %d, time %u, detectors 0x%08X (status 0x%X)",good,evp->seq, evp->token, evp->trgcmd, evp->daqcmd,
00146 evp->evt_time, evp->detectors, evp->status) ;
00147
00148
00149
00150
00151
00152 if(print_det[0]) {
00153 if(strcmp(print_det, "tinfo") == 0) {
00154 printf("trginfo: seq = #%d token = %d detectors = 0x%x triggers = 0x%llx/0x%llx/0x%llx evptriggers=0x%x\n",
00155 evp->seq,
00156 evp->token,
00157 evp->detectors,
00158 evp->daqbits64_l1,
00159 evp->daqbits64_l2,
00160 evp->daqbits64,
00161 evp->evpgroups);
00162
00163 tinfo_doer(evp, "tinfo");
00164 }
00165 }
00166
00167 if(print_det[0]) {
00168 if(strcmp(print_det, "readahead") == 0) {
00169 SummaryInfo nsummary;
00170 int ret = evp->readNextFutureSummaryInfo(&nsummary);
00171
00172
00173 if(ret <= 0) {
00174 printf("Event #%d, token %d triggers 0x%llx ----> No Next Event...",
00175 evp->seq,evp->token,evp->daqbits64);
00176 }
00177 else {
00178 printf("Event #%d, token %d triggers 0x%llx ----> Next Event: #%d, token %d triggers 0x%llx\n",
00179 evp->seq,evp->token,evp->daqbits64,
00180 nsummary.seq, nsummary.token,
00181 make64(nsummary.L3summary[0],nsummary.L3summary[1]));
00182 }
00183 }
00184 }
00185
00186 dd = evp->det("sc")->get() ;
00187 if(dd && dd->iterate()) {
00188 LOG(INFO,"SC found") ;
00189 if(strcasecmp(print_det,"sc")==0) {
00190 sc_t *sc_p = (sc_t *) dd->Void ;
00191
00192
00193
00194 int alag ;
00195
00196 sc_p->timelag = evp->evt_time - sc_p->time ;
00197 if(sc_p->timelag > 0) alag = sc_p->timelag ;
00198 else alag = -sc_p->timelag ;
00199
00200 if(alag > 5) sc_p->valid = 0 ;
00201 else sc_p->valid = 1 ;
00202
00203 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) ;
00204 for(int i=0;i<16;i++) {
00205 printf("\tRICH scaler %2d: %u\n",i,sc_p->rich_scalers[i]) ;
00206 }
00207 }
00208 }
00209
00210 dd = evp->det("fpd")->get("legacy") ;
00211 if(dd) LOG(INFO,"FPD found") ;
00212
00213 if(ftp_doer(evp,print_det)) LOG(INFO,"FTP found") ;
00214
00215
00216 dd = evp->det("rich")->get("legacy") ;
00217 if(dd) LOG(INFO,"RIC found") ;
00218
00219 dd = evp->det("ssd")->get("legacy") ;
00220 if(dd) LOG(INFO,"SSD found") ;
00221
00222 dd = evp->det("svt")->get("legacy") ;
00223 if(dd) LOG(INFO,"SVT found") ;
00224
00225
00226 if(pmd_doer(evp, print_det)) LOG(INFO,"PMD found") ;
00227
00228 dd = evp->det("tof")->get("legacy") ;
00229 if(dd) {
00230 LOG(INFO,"TOF found") ;
00231 if(strcasecmp(print_det,"tof")==0) {
00232 while(dd->iterate()) {
00233 tof_t *tof = (tof_t *)dd->Void ;
00234 for(int r=0;r<4;r++) {
00235 printf("TOF RDO %d: words %d:\n",r+1,tof->ddl_words[r]) ;
00236 for(u_int i=0;i<tof->ddl_words[r];i++) {
00237 printf("\t%d: 0x%08X [%u dec]\n",i,tof->ddl[r][i],tof->ddl[r][i]) ;
00238 }
00239 }
00240 }
00241 }
00242 }
00243
00244 if(trg_doer(evp, print_det)) LOG(INFO,"TRG found") ;
00245
00246
00247
00248 if(btow_doer(evp, print_det)) LOG(INFO,"BTOW found") ;
00249
00250
00251 bsmd_doer(evp,print_det) ;
00252
00253 if(etow_doer(evp, print_det)) LOG(INFO,"ETOW found") ;
00254
00255 if(esmd_doer(evp, print_det)) LOG(INFO,"ESMD found") ;
00256
00257
00258
00259 if(tpc_doer(evp,print_det)) LOG(INFO,"TPC found (legacy)") ;
00260
00261
00262
00263 tpx_doer(evp,print_det) ;
00264
00265
00266
00267
00268 if(pp2pp_doer(evp,print_det)) LOG(INFO,"PP2PP found") ;
00269
00270
00271
00272 if(l3_doer(evp,print_det)) LOG(INFO,"L3/HLT_FY09 found") ;
00273
00274
00275 if(hlt_doer(evp,print_det)) LOG(INFO,"HLT_FY10 found") ;
00276
00277
00278 if(fgt_doer(evp,print_det)) LOG(INFO,"FGT found") ;
00279
00280
00281 if(mtd_doer(evp,print_det)) LOG(INFO,"MTD found") ;
00282
00283
00284
00285
00286
00287
00288
00289
00290 #ifdef INSIST_ON_EMC_PSEUDO
00291 if(emc_pseudo_doer(evp,print_det)) LOG(INFO,"EMC found (any detector)") ;
00292 #endif
00293
00294 }
00295
00296 delete evp ;
00297
00298 return 0 ;
00299 }
00300
00301 static int trg_doer(daqReader *rdr, const char *do_print)
00302 {
00303 int found = 0 ;
00304 daq_dta *dd ;
00305
00306 if(strcasestr(do_print,"trg")) ;
00307 else do_print = 0 ;
00308
00309
00310
00311 dd = rdr->det("trg")->get("legacy") ;
00312 if(dd) {
00313 if(dd->iterate()) {
00314 trg_t *trg_p = (trg_t *) dd->Void ;
00315
00316 if(do_print) {
00317 printf("Trigger: tcubits 0x%08X, trg_word 0x%04X\n",trg_p->tcubits,trg_p->trg_word) ;
00318 }
00319
00320 }
00321 }
00322
00323
00324
00325 dd = rdr->det("trg")->get("raw") ;
00326 if(dd) {
00327 if(dd->iterate()) {
00328 found = 1 ;
00329
00330
00331 u_char *trg_raw = dd->Byte;
00332
00333 if(do_print) {
00334
00335
00336
00337 struct simple_desc {
00338 short len ;
00339 char evt_desc ;
00340 char ver ;
00341 } *desc ;
00342
00343 desc = (simple_desc *) trg_raw ;
00344
00345
00346 printf("Trigger: raw bank has %d bytes: ver 0x%02X, desc %d, len %d\n",dd->ncontent,desc->ver, desc->evt_desc, desc->len) ;
00347
00348
00349 u_int *i32 = (u_int *) trg_raw ;
00350 for(int i=0;i<10;i++) {
00351 printf("Trigger: word %d: 0x%08X\n",i,i32[i]) ;
00352 }
00353 }
00354 }
00355 }
00356
00357 return found ;
00358 }
00359
00360
00361 static int hlt_doer(daqReader *rdr, const char *do_print)
00362 {
00363 int found = 0 ;
00364 daq_dta *dd ;
00365
00366 if(strcasestr(do_print,"hlt")) ;
00367 else do_print = 0 ;
00368
00369 for(int s=1;s<=24;s++) {
00370 dd = rdr->det("hlt")->get("tpx",s) ;
00371 while(dd && dd->iterate()) {
00372 found = 1 ;
00373 if(do_print) {
00374 printf("HLT TPX sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
00375 }
00376 }
00377 }
00378
00379 dd = rdr->det("hlt")->get("trg") ;
00380 while(dd && dd->iterate()) {
00381 found = 1 ;
00382 if(do_print) {
00383 printf("HLT TRG sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
00384 }
00385 }
00386
00387 dd = rdr->det("hlt")->get("tof") ;
00388 while(dd && dd->iterate()) {
00389 found = 1 ;
00390 if(do_print) {
00391 printf("HLT TOF sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
00392 }
00393 }
00394
00395 dd = rdr->det("hlt")->get("gl3") ;
00396 while(dd && dd->iterate()) {
00397 found = 1 ;
00398 if(do_print) {
00399 hlt_gl3_t *h = (hlt_gl3_t *) dd->Void ;
00400 printf("HLT GL3 sec %02d: bytes %d: %d %s\n",dd->sec,dd->ncontent,h->bytes,h->name) ;
00401 }
00402 }
00403
00404
00405
00406 return found ;
00407 }
00408
00409 static int tpx_doer(daqReader *rdr, const char *do_print)
00410 {
00411 int found = 0 ;
00412 int adc_found = 0 ;
00413 int cld_found = 0 ;
00414 int ped_found = 0 ;
00415 char s_mask[24] ;
00416
00417 daq_dta *dd ;
00418
00419 if(strcasestr(do_print,"tpx")) ;
00420 else do_print = 0 ;
00421
00422
00423
00424
00425 memset(s_mask,0,sizeof(s_mask)) ;
00426
00427 for(int s=1;s<=24;s++) {
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 int pixel_count[46] ;
00448 memset(pixel_count,0,sizeof(pixel_count)) ;
00449 int sec_found = 0 ;
00450
00451 dd = rdr->det("tpx")->get("adc",s) ;
00452 if(dd) {
00453
00454 while(dd->iterate()) {
00455 found = 1 ;
00456 sec_found = 1 ;
00457 adc_found = 1 ;
00458 if(do_print) {
00459 printf("TPX: sec %02d, row %2d, pad %3d: %3d pixels\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
00460 }
00461
00462 pixel_count[dd->row] += dd->ncontent ;
00463
00464 for(u_int i=0;i<dd->ncontent;i++) {
00465 if(do_print) {
00466 printf("\ttb %3d = %4d ADC\n",dd->adc[i].tb, dd->adc[i].adc) ;
00467 }
00468 }
00469 }
00470
00471
00472 if(sec_found && do_print) {
00473 for(int row=0;row<=45;row++) {
00474 printf("+sector %2d, row %2d: pixels %d\n",s,row,pixel_count[row]) ;
00475 }
00476 }
00477 }
00478
00479
00480 dd = rdr->det("tpx")->get("cld",s) ;
00481 while(dd && dd->iterate()) {
00482
00483 found = 1 ;
00484 cld_found = 1 ;
00485
00486 s_mask[dd->sec-1]=1 ;
00487
00488
00489 if(do_print) {
00490 printf("TPX: sec %02d, row %2d: %3d clusters (evt %d)\n",dd->sec,dd->row,dd->ncontent,good) ;
00491 }
00492
00493 for(u_int i=0;i<dd->ncontent;i++) {
00494 if(do_print) {
00495 int p1,p2,t1,t2 ;
00496 int bad = 0 ;
00497 p1 = dd->cld[i].p1 ;
00498 p2 = dd->cld[i].p2 ;
00499 t1 = dd->cld[i].t1 ;
00500 t2 = dd->cld[i].t2 ;
00501
00502 if(p1 > 200) bad = 1 ;
00503 if(p2 > 200) bad = 1 ;
00504 if(p2<p1) bad = 1 ;
00505 if((p2-p1)>14) bad = 1 ;
00506
00507 if(t1 > 1200) bad = 1 ;
00508 if(t2 > 1200) bad = 1 ;
00509 if(t2<t1) bad = 1 ;
00510 if((t2-t1)>30) bad = 1 ;
00511
00512 if(bad) printf("BAD: ") ;
00513 printf("\tpad %7.3f[%d,%d], time %7.3f[%d,%d], charge %5d, flags 0x%02X\n",
00514 dd->cld[i].pad,dd->cld[i].p1,dd->cld[i].p2,
00515 dd->cld[i].tb,dd->cld[i].t1,dd->cld[i].t2,
00516 dd->cld[i].charge,dd->cld[i].flags) ;
00517
00518 }
00519 }
00520 }
00521
00522
00523
00524 dd = rdr->det("tpx")->get("pedrms",s) ;
00525 while(dd && dd->iterate()) {
00526 found = 1 ;
00527 ped_found = 1 ;
00528 if(do_print) {
00529 printf("TPX: sec %02d, row %2d, pad %3d (%d pix)\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
00530 daq_det_pedrms *ped = (daq_det_pedrms *)dd->Void ;
00531 for(u_int tb=0;tb<dd->ncontent;tb++) {
00532 printf(" tb %3d: ped %3d, rms %.2f\n",tb,ped[tb].ped,ped[tb].rms) ;
00533 }
00534 }
00535 }
00536
00537 }
00538
00539 char fstr[64] ;
00540 fstr[0] = 0 ;
00541
00542 if(cld_found) {
00543 strcat(fstr,"CLD ") ;
00544 }
00545 if(adc_found) {
00546 strcat(fstr,"ADC " ) ;
00547 }
00548 if(ped_found) {
00549 strcat(fstr,"PEDRMS ") ;
00550 }
00551
00552
00553 int s_cou = 0 ;
00554 for(int s=0;s<24;s++) {
00555 if(s_mask[s]) s_cou++ ;
00556 }
00557
00558 if(found) {
00559 LOG(INFO,"TPX found [%s;%d]",fstr,s_cou) ;
00560 }
00561
00562 return found ;
00563
00564 }
00565
00566 static int ftp_doer(daqReader *rdr, const char *do_print)
00567 {
00568 int found = 0;
00569 daq_dta *dd;
00570
00571 if(strcasestr(do_print,"ftp")) ;
00572 else do_print = 0 ;
00573
00574 dd = rdr->det("ftp")->get("legacy") ;
00575
00576 while(dd && dd->iterate()) {
00577 found++ ;
00578 ftp_t *ftp = (ftp_t *) dd->Void ;
00579
00580 if(do_print) {
00581 printf("FTP sector %d: pixels %d\n",dd->sec,ftp->channels) ;
00582
00583
00584 for(int ss=0;ss<2;ss++) {
00585 for(int rb=0;rb<10;rb++) {
00586 for(int pad=0;pad<960;pad++) {
00587 for(int tbi=0;tbi<ftp->counts[ss][rb][pad];tbi++) {
00588 printf("%d %d %d %d %d\n",
00589 ss,rb,pad,
00590 ftp->timebin[ss][rb][pad][tbi],
00591 ftp->adc[ss][rb][pad][tbi]);
00592 }
00593 }
00594 }
00595 }
00596 }
00597 }
00598
00599
00600 return found ;
00601 }
00602
00603
00604 static int tpc_doer(daqReader *rdr, const char *do_print)
00605 {
00606 int found = 0 ;
00607 daq_dta *dd ;
00608
00609 if(strcasestr(do_print,"tpc")) ;
00610 else do_print = 0 ;
00611
00612
00613
00614
00615 for(int s=1;s<=24;s++) {
00616 dd = rdr->det("tpc")->get("legacy",s) ;
00617
00618 while(dd && dd->iterate()) {
00619 found++ ;
00620 tpc_t *tpc = (tpc_t *) dd->Void ;
00621
00622 if(do_print) {
00623 printf("TPC sector %d: pixels %d\n",dd->sec,tpc->channels_sector) ;
00624 for(int r=0;r<45;r++) {
00625 for(int c=0;c<tpc->cl_counts[r];c++) {
00626 printf("row %2d: pad %1.f, tb %.1f, charge %d\n",r+1,
00627 tpc->cl[r][c].p,tpc->cl[r][c].t,tpc->cl[r][c].charge) ;
00628 }
00629 }
00630 }
00631
00632
00633
00634
00635
00636
00637 }
00638 }
00639
00640 return found ;
00641
00642
00643 }
00644
00645
00646 static int pmd_doer(daqReader *rdr, const char *do_print)
00647 {
00648 int found = 0 ;
00649 daq_dta *dd ;
00650
00651 if(strcasestr(do_print,"pmd")) ;
00652 else do_print = 0 ;
00653
00654 dd = rdr->det("pmd")->get("legacy") ;
00655
00656 if(dd && dd->iterate()) {
00657 struct pmd_t *pmd_p = (pmd_t *) dd->Void ;
00658
00659 if(do_print) {
00660 for(int crate=0;crate<2;crate++) {
00661 printf("Crate %s: status %d, mode %d\n",crate==0?"Up":"Dn",pmd_p->status[crate],pmd_p->mode) ;
00662
00663 for(int c=0;c<PMD_CRAMS_MAX;c++) {
00664 for(int s=0;s<2;s++) {
00665 for(int ch=0;ch<PMD_CRAMS_CH_MAX;ch++) {
00666 printf(" CRAM %2d: side %d: ch %4d: adc %4d [ped %4.1f, rms %4.2f, thr %4.1f]\n",
00667 c,s,ch,
00668 pmd_p->adc[crate][c][s][ch],
00669 (double)pmd_p->ped[crate][c][s][ch]/16.0,
00670 (double)pmd_p->rms[crate][c][s][ch]/16.0,
00671 (double)pmd_p->thr[crate][c][s][ch]/16.0) ;
00672
00673 }}}
00674 }
00675
00676 }
00677
00678 found = 1 ;
00679 }
00680
00681 if(found) LOG(NOTE,"PMD legacy found") ;
00682
00683 return found ;
00684
00685
00686 }
00687
00688 static int bsmd_doer(daqReader *rdr, const char *do_print)
00689 {
00690 int found = 0 ;
00691 daq_dta *dd ;
00692
00693 int raw_found = 0 ;
00694 int adc_non_zs_found = 0 ;
00695 int adc_found = 0 ;
00696 int ped_found = 0 ;
00697
00698 if(strcasestr(do_print,"bsmd")) ;
00699 else do_print = 0 ;
00700
00701
00702
00703 for(int f=1;f<=12;f++) {
00704 dd = rdr->det("bsmd")->get("raw",0,f) ;
00705 if(dd) {
00706 while(dd->iterate()) {
00707 found = 1 ;
00708 raw_found = 1 ;
00709
00710 if(do_print) printf("BSMD RAW: fiber %2d [==%d], sector %d:\n",dd->rdo,f,dd->sec) ;
00711
00712
00713 for(int i=0;i<10;i++) {
00714 if(do_print) printf(" Head %2d = %08X\n",i,dd->Int32[i]) ;
00715 }
00716 }
00717 }
00718 }
00719
00720
00721
00722 for(int f=1;f<=12;f++) {
00723 dd = rdr->det("bsmd")->get("adc_non_zs",0,f) ;
00724 if(dd) {
00725 while(dd->iterate()) {
00726 found = 1 ;
00727 adc_non_zs_found = 1 ;
00728
00729 bsmd_t *d = (bsmd_t *) dd->Void ;
00730
00731 if(do_print) printf("BSMD non-ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
00732
00733
00734 for(int i=0;i<BSMD_DATSIZE;i++) {
00735 if(do_print) printf(" %4d = %4d\n",i,d->adc[i]) ;
00736 }
00737 }
00738 }
00739 }
00740
00741
00742 for(int f=1;f<=12;f++) {
00743 dd = rdr->det("bsmd")->get("adc",0,f) ;
00744 if(dd) {
00745 while(dd->iterate()) {
00746 found = 1 ;
00747 adc_found = 1 ;
00748
00749 bsmd_t *d = (bsmd_t *) dd->Void ;
00750
00751 if(do_print) printf("BSMD ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
00752
00753 for(int i=0;i<BSMD_DATSIZE;i++) {
00754
00755 if(do_print) if(d->adc[i]) printf(" %4d = %4d\n",i,d->adc[i]) ;
00756 }
00757 }
00758 }
00759 }
00760
00761
00762 for(int f=1;f<=12;f++) {
00763 dd = rdr->det("bsmd")->get("ped",0,f) ;
00764 if(dd) {
00765 while(dd->iterate()) {
00766 found = 1 ;
00767 ped_found = 1 ;
00768
00769 bsmd_t *d = (bsmd_t *) dd->Void ;
00770
00771 if(do_print) printf("BSMD PED: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
00772
00773 for(int i=0;i<BSMD_DATSIZE;i++) {
00774 if(do_print) printf(" %4d = %4d\n",i,d->adc[i]) ;
00775 }
00776 }
00777 }
00778 }
00779
00780
00781 for(int f=1;f<=12;f++) {
00782 dd = rdr->det("bsmd")->get("rms",0,f) ;
00783 if(dd) {
00784 while(dd->iterate()) {
00785 found = 1 ;
00786 ped_found = 1 ;
00787
00788 bsmd_t *d = (bsmd_t *) dd->Void ;
00789
00790 if(do_print) printf("BSMD RMS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
00791
00792 for(int i=0;i<BSMD_DATSIZE;i++) {
00793 if(do_print) printf(" %4d = %.2f\n",i,(double)d->adc[i]/8.0) ;
00794 }
00795 }
00796 }
00797 }
00798
00799
00800 char fstr[64] ;
00801 fstr[0] = 0 ;
00802
00803 if(raw_found) {
00804 strcat(fstr,"RAW ") ;
00805 }
00806
00807 if(adc_found) {
00808 strcat(fstr,"ADC-ZS ") ;
00809 }
00810 if(adc_non_zs_found) {
00811 strcat(fstr,"ADC-non-ZS " ) ;
00812 }
00813 if(ped_found) {
00814 strcat(fstr,"PEDRMS ") ;
00815 }
00816
00817 if(found) {
00818 LOG(INFO,"BSMD found [%s]",fstr) ;
00819 }
00820
00821
00822 return found ;
00823 }
00824
00825 static int esmd_doer(daqReader *rdr, const char *do_print)
00826 {
00827 int found = 0 ;
00828 daq_dta *dd ;
00829
00830 if(strcasestr(do_print,"esmd")) ;
00831 else do_print = 0 ;
00832
00833
00834 dd = rdr->det("esmd")->get("adc") ;
00835 if(dd) {
00836 while(dd->iterate()) {
00837 found = 1 ;
00838
00839 esmd_t *d = (esmd_t *) dd->Void ;
00840
00841 for(int i=0;i<ESMD_MAXFEE;i++) {
00842 for(int j=0;j<ESMD_PRESIZE;j++) {
00843 if(do_print) printf("ESMD: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
00844 }
00845 for(int j=0;j<ESMD_DATSIZE;j++) {
00846 if(do_print) printf("ESMD: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
00847 }
00848
00849 }
00850 }
00851 }
00852
00853 return found ;
00854 }
00855
00856 static int etow_doer(daqReader *rdr, const char *do_print)
00857 {
00858 int found = 0 ;
00859 daq_dta *dd ;
00860
00861 if(strcasestr(do_print,"etow")) ;
00862 else do_print = 0 ;
00863
00864
00865 dd = rdr->det("etow")->get("adc") ;
00866 if(dd) {
00867 while(dd->iterate()) {
00868 found = 1 ;
00869
00870 etow_t *d = (etow_t *) dd->Void ;
00871
00872 for(int i=0;i<ETOW_MAXFEE;i++) {
00873 for(int j=0;j<ETOW_PRESIZE;j++) {
00874 if(do_print) printf("ETOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
00875 }
00876 for(int j=0;j<ETOW_DATSIZE;j++) {
00877 if(do_print) printf("ETOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
00878 }
00879
00880 }
00881 }
00882 }
00883
00884 return found ;
00885 }
00886
00887 static int btow_doer(daqReader *rdr, const char *do_print)
00888 {
00889 int found = 0 ;
00890 daq_dta *dd ;
00891
00892 if(strcasestr(do_print,"btow")) ;
00893 else do_print = 0 ;
00894
00895
00896 #if 0
00897 dd = rdr->det("btow")->get("raw") ;
00898 if(dd) {
00899 while(dd->iterate()) {
00900 u_short *s16 = (u_short *) dd->Void ;
00901
00902 if(do_print) {
00903 printf("BTOW: bytes %d\n",dd->ncontent) ;
00904 }
00905
00906 for(u_int i=0;i<dd->ncontent/2;i++) {
00907 if(do_print) {
00908 printf("%d: 0x%04X [%d dec]\n",i,s16[i],s16[i]) ;
00909 }
00910 }
00911 }
00912 }
00913 #endif
00914
00915 dd = rdr->det("btow")->get("adc") ;
00916 if(dd) {
00917 while(dd->iterate()) {
00918 found = 1 ;
00919
00920 btow_t *d = (btow_t *) dd->Void ;
00921
00922 for(int i=0;i<BTOW_MAXFEE;i++) {
00923 for(int j=0;j<BTOW_PRESIZE;j++) {
00924 if(do_print) printf("BTOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
00925 }
00926 for(int j=0;j<BTOW_DATSIZE;j++) {
00927 if(do_print) printf("BTOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
00928 }
00929
00930 }
00931 }
00932 }
00933
00934 return found ;
00935 }
00936
00937 static int emc_pseudo_doer(daqReader *rdr, const char *do_print)
00938 {
00939 int found = 0 ;
00940 daq_dta *dd ;
00941
00942 if(strcasestr(do_print,"emc_pseudo")) ;
00943 else do_print = 0 ;
00944
00945
00946 dd = rdr->det("emc_pseudo")->get("legacy") ;
00947 if(dd) {
00948 while(dd->iterate()) {
00949 found = 1 ;
00950
00951 emc_t *d = (emc_t *) dd->Void ;
00952
00953 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",
00954 d->btow_in, d->btow_ch, d->bsmd_in, d->bsmd_ch, d->etow_in, d->etow_ch, d->esmd_in, d->esmd_ch) ;
00955 }
00956 }
00957
00958 return found ;
00959
00960 }
00961
00962
00963 static int pp2pp_doer(daqReader *rdr, const char *do_print)
00964 {
00965 int found = 0 ;
00966 daq_dta *dd ;
00967
00968 if(strcasestr(do_print,"pp2pp")) ;
00969 else do_print = 0 ;
00970
00971
00972 dd = rdr->det("pp2pp")->get("adc") ;
00973 if(dd) {
00974 while(dd->iterate()) {
00975 found = 1 ;
00976
00977 pp2pp_t *d = (pp2pp_t *) dd->Void ;
00978
00979 if(do_print) {
00980 printf("PP2PP: sector %d, seq %d, chain %d, SVX %d:\n",dd->sec,d->seq_id,d->chain_id,d->svx_id) ;
00981 for(int c=0;c<PP2PP_SVX_CH;c++) {
00982
00983 if(d->trace[c]) printf(" %3d: %3d [0x%02X], trace %d\n",c,d->adc[c],d->adc[c],d->trace[c]) ;
00984 }
00985 }
00986
00987 }
00988 }
00989
00990 return found ;
00991 }
00992
00993 static int l3_doer(daqReader *rdr, const char *do_print)
00994 {
00995 int found = 0 ;
00996 daq_dta *dd ;
00997
00998 if(strcasestr(do_print,"l3")) ;
00999 else do_print = 0 ;
01000
01001
01002 dd = rdr->det("l3")->get("legacy") ;
01003 if(dd) {
01004 while(dd->iterate()) {
01005 found = 1 ;
01006
01007 l3_t *l3_p = (l3_t *) dd->Void ;
01008
01009 if(do_print) {
01010 printf("L3/HLT: sequence %u, decision 0x%X: tracks %d, clusters %d, vertex %f:%f:%f\n",
01011 l3_p->channels, l3_p->mode,
01012 l3_p->tracks_num, l3_p->cluster_num,
01013 l3_p->xVertex, l3_p->yVertex, l3_p->xVertex) ;
01014
01015
01016 for(u_int i=0;i<l3_p->tracks_num;i++) {
01017
01018 printf(" track %d: Pt %f, charge %d, nHits %d\n",i+1,
01019 l3_p->track[i].pt, l3_p->track[i].q, l3_p->track[i].nHits) ;
01020
01021 }
01022 }
01023
01024 }
01025 }
01026
01027 return found ;
01028 }
01029
01030 static int fgt_doer(daqReader *rdr, const char *do_print)
01031 {
01032 int found = 0 ;
01033
01034 daq_dta *dd ;
01035
01036 if(strcasestr(do_print,"fgt")) ;
01037 else do_print = 0 ;
01038
01039
01040
01041 dd = rdr->det("fgt")->get("raw") ;
01042 if(dd) {
01043 while(dd->iterate()) {
01044 found = 1 ;
01045
01046
01047 u_int *d = (u_int *) dd->Void ;
01048
01049
01050 if(do_print) {
01051 printf("FGT RAW: RDO %d: %d bytes, %d words\n",dd->rdo,dd->ncontent,dd->ncontent/4) ;
01052
01053 for(int i=0;i<10;i++) {
01054 printf(" %3d: 0x%08X\n",i,d[i]) ;
01055 }
01056 }
01057
01058 }
01059 }
01060
01061
01062
01063 dd = rdr->det("fgt")->get("adc") ;
01064 while(dd && dd->iterate()) {
01065 found = 1 ;
01066
01067 fgt_adc_t *f = (fgt_adc_t *) dd->Void ;
01068
01069 if(do_print) {
01070 printf("FGT ADC: RDO %d, ARM %d, APV %d: %d values\n",dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
01071
01072 for(u_int i=0;i<dd->ncontent;i++) {
01073 printf(" %5d: ch %3d, tb %d = %3d\n",i,f[i].ch,f[i].tb,f[i].adc) ;
01074 }
01075 }
01076 }
01077
01078
01079
01080 dd = rdr->det("fgt")->get("phys") ;
01081 while(dd && dd->iterate()) {
01082 found = 1 ;
01083
01084 fgt_adc_t *f = (fgt_adc_t *) dd->Void ;
01085
01086 if(do_print) {
01087 printf("FGT phys: disk %d, quadrant %d, type %s: %d values\n",dd->sec,dd->rdo,
01088 (dd->pad==FGT_STRIP_TYPE_R)?"r-strip":"phi_strip",
01089 dd->ncontent) ;
01090
01091 for(u_int i=0;i<dd->ncontent;i++) {
01092 printf(" strip %3d, tb %d = %3d\n",f[i].ch,f[i].tb,f[i].adc) ;
01093 }
01094 }
01095 }
01096
01097
01098
01099 dd = rdr->det("fgt")->get("pedrms") ;
01100 while(dd && dd->iterate()) {
01101 found = 1 ;
01102
01103 fgt_pedrms_t *f = (fgt_pedrms_t *) dd->Void ;
01104
01105 if(do_print) {
01106 printf("FGT pedrms: RDO %d, ARM %d, APV %d: %d values\n",dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
01107
01108 for(u_int i=0;i<dd->ncontent;i++) {
01109 printf(" ch %3d, tb %d = %.3f +-%.3f\n",f[i].ch,f[i].tb,f[i].ped,f[i].rms) ;
01110 }
01111 }
01112 }
01113
01114
01115 return found ;
01116 }
01117
01118 static int mtd_doer(daqReader *rdr, const char *do_print)
01119 {
01120 int found = 0 ;
01121 daq_dta *dd ;
01122
01123 if(strcasestr(do_print,"mtd")) ;
01124 else do_print = 0 ;
01125
01126
01127
01128 dd = rdr->det("mtd")->get("raw") ;
01129 if(dd) {
01130 while(dd->iterate()) {
01131 found = 1 ;
01132
01133
01134 u_int *d = (u_int *) dd->Void ;
01135
01136
01137 if(do_print) {
01138 printf("MTD: RDO %d: %d bytes\n",dd->rdo,dd->ncontent) ;
01139
01140 for(int i=0;i<10;i++) {
01141 printf(" %2d: 0x%08X\n",i,d[i]) ;
01142 }
01143 }
01144
01145 }
01146 }
01147
01148 return found ;
01149 }
01150
01151 #if 0
01152 static int gmt_doer(daqReader *rdr, const char *do_print)
01153 {
01154 int found = 0 ;
01155 daq_dta *dd ;
01156
01157 if(strcasestr(do_print,"gmt")) ;
01158 else do_print = 0 ;
01159
01160
01161
01162 dd = rdr->det("gmt")->get("raw") ;
01163 if(dd) {
01164 while(dd->iterate()) {
01165 found = 1 ;
01166
01167
01168 u_int *d = (u_int *) dd->Void ;
01169
01170
01171 if(do_print) {
01172 printf("GMT: RDO %d: %d bytes\n",dd->rdo,dd->ncontent) ;
01173
01174 for(int i=0;i<10;i++) {
01175 printf(" %2d: 0x%08X\n",i,d[i]) ;
01176 }
01177 }
01178
01179 }
01180 }
01181
01182 return found ;
01183 }
01184
01185 #endif
01186
01187
01188
01189
01190
01191 static int tinfo_doer(daqReader *rdr, const char *do_print)
01192 {
01193 int found = 0;
01194
01195 daq_dta *dd = rdr->det("trg")->get("raw") ;
01196 if(dd) {
01197 if(dd->iterate()) {
01198 found = 1;
01199
01200 int sz = dd->get_size_t();
01201 TriggerDataBlk *trg = (TriggerDataBlk *)dd->Byte;
01202
01203 EvtDescData *evtDesc = (EvtDescData *)(((char *)trg) + swap32(trg->EventDesc_ofl.offset));
01204 TrgSumData *trgSum = (TrgSumData *)(((char *)trg) + swap32(trg->Summary_ofl.offset));
01205 L1_DSM_Data *l1Dsm = (L1_DSM_Data *)(((char *)trg) + swap32(trg->L1_DSM_ofl.offset));
01206
01207 printf("L1 trg = 0x%x-%x\n",swap32(trgSum->L1Sum[1]),swap32(trgSum->L1Sum[0]));
01208 printf("L2 trg = 0x%x-%x\n",swap32(trgSum->L2Sum[1]),swap32(trgSum->L2Sum[0]));
01209 for(int i=0;i<64;i++) {
01210 printf("L2Result[%d]=0x%x\n",i,swap32(trgSum->L2Result[i]));
01211 }
01212 for(int i=0;i<8;i++) {
01213 printf("lastDsm[%d] = 0x%x\n",i,swap16(l1Dsm->lastDSM[i]));
01214 }
01215 }
01216 }
01217
01218 return found;
01219 }