StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rts_example.trg.C
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <getopt.h>
4 #include <sys/types.h>
5 #include <stdlib.h>
6 
7 #include <rtsLog.h> // for my LOG() call
8 #include <rtsSystems.h>
9 
10 // this needs to be always included
11 #include <DAQ_READER/daqReader.h>
12 #include <DAQ_READER/daq_dta.h>
13 
14 //#include <trgDataDefs.h>
15 
16 // only the detectors we will use need to be included
17 // for their structure definitions...
18 #include <DAQ_BSMD/daq_bsmd.h>
19 #include <DAQ_BTOW/daq_btow.h>
20 #include <DAQ_EMC/daq_emc.h>
21 #include <DAQ_ESMD/daq_esmd.h>
22 #include <DAQ_ETOW/daq_etow.h>
23 #include <DAQ_FPD/daq_fpd.h>
24 #include <DAQ_FTP/daq_ftp.h>
25 #include <DAQ_L3/daq_l3.h>
26 #include <DAQ_PMD/daq_pmd.h>
27 #include <DAQ_PP2PP/daq_pp2pp.h>
28 #include <DAQ_RIC/daq_ric.h>
29 #include <DAQ_SC/daq_sc.h>
30 #include <DAQ_SSD/daq_ssd.h>
31 #include <DAQ_SVT/daq_svt.h>
32 #include <DAQ_TOF/daq_tof.h>
33 #include <DAQ_TPC/daq_tpc.h>
34 #include <DAQ_TPX/daq_tpx.h>
35 #include <DAQ_TRG/daq_trg.h>
36 #include <DAQ_HLT/daq_hlt.h>
37 #include <DAQ_L4/daq_l4.h>
38 #include <DAQ_FGT/daq_fgt.h> //includes GMT & IST
39 #include <DAQ_MTD/daq_mtd.h>
40 #include <DAQ_PXL/daq_pxl.h>
41 
42 // I wrapped more complicated detectors inside their own functions
43 // for this example
44 #ifdef INSIST_ON_EMC_PSEUDO
45 static int emc_pseudo_doer(daqReader *rdr, const char *do_print) ;
46 #endif
47 
48 static int bsmd_doer(daqReader *rdr, const char *do_print) ;
49 static int esmd_doer(daqReader *rdr, const char *do_print) ;
50 static int btow_doer(daqReader *rdr, const char *do_print) ;
51 static int etow_doer(daqReader *rdr, const char *do_print) ;
52 static int tpc_doer(daqReader *rdr, const char *do_print) ;
53 static int tpx_doer(daqReader *rdr, const char *do_print) ;
54 static int trg_doer(daqReader *rdr, const char *do_print) ;
55 static int ftp_doer(daqReader *rdr, const char *do_print) ;
56 static int pmd_doer(daqReader *rdr, const char *do_print) ;
57 static int hlt_doer(daqReader *rdr, const char *do_print) ;
58 static int l4_doer(daqReader *rdr, const char *do_print) ;
59 
60 static int pp2pp_doer(daqReader *rdr, const char *do_print) ;
61 static int l3_doer(daqReader *rdr, const char *do_print) ;
62 static int fgt_doer(daqReader *rdr, const char *do_print, int which) ;
63 static int mtd_doer(daqReader *rdr, const char *do_print) ;
64 static int tinfo_doer(daqReader *rdr, const char *do_print);
65 static int pxl_doer(daqReader *rdr, const char *do_print) ;
66 
67 static int good ;
68 
69 int main(int argc, char *argv[])
70 {
71  extern char *optarg ;
72  extern int optind ;
73  int c ;
74  const char *print_det = "" ;
75  char _mountpoint[256];
76  char *mountpoint = NULL;
77 
78  rtsLogOutput(RTS_LOG_STDERR) ;
79  rtsLogLevel((char *)WARN) ;
80 
81 
82  while((c = getopt(argc, argv, "D:d:m:h")) != EOF) {
83  switch(c) {
84  case 'd' :
85  rtsLogLevel(optarg) ;
86  break ;
87  case 'D' :
88  print_det = optarg ;
89  break ;
90  case 'm' :
91  mountpoint = _mountpoint;
92  strcpy(mountpoint, optarg);
93  break;
94 
95  default :
96  break ;
97  }
98  }
99 
100  class daqReader *evp ; // tha main guy
101  evp = new daqReader(argv[optind]) ; // create it with the filename argument..
102  if(mountpoint) {
103  evp->setEvpDisk(mountpoint);
104  }
105 
106  good=0;
107  int bad=0;
108 
109  for(;;) {
110  char *ret = evp->get(0,EVP_TYPE_ANY);
111 
112  if(ret) {
113  if(evp->status) {
114  LOG(ERR,"evp status is non-null [0x08X, %d dec]",evp->status,evp->status) ;
115  continue ;
116  }
117  good++;
118  }
119  else { // something other than an event, check what.
120  switch(evp->status) {
121  case EVP_STAT_OK: // just a burp!
122  continue;
123  case EVP_STAT_EOR:
124  LOG(DBG, "End of Run/File");
125  if(evp->IsEvp()) { // but event pool, keep trying...
126  LOG(DBG, "Wait a second...");
127  sleep(1);
128  continue;
129  }
130  break; // file, we're done...
131  case EVP_STAT_EVT:
132  bad++;
133  LOG(WARN, "Problem getting event - skipping [good %d, bad %d]",good,bad);
134  sleep(1);
135  continue;
136  case EVP_STAT_CRIT:
137  LOG(CRIT,"evp->status CRITICAL (?)") ;
138  return -1;
139  }
140  }
141 
142 
143  if(evp->status == EVP_STAT_EOR) {
144  LOG(INFO,"End of File reached...") ;
145  break ; // of the for() loop...
146  }
147 
148  daq_dta *dd ; // generic data pointer; reused all the time
149 
150 
151  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,
152  evp->evt_time, evp->detectors, evp->status) ;
153 
154 
155  //if(print_det[0]) printf("***** Seq #%d, token %d\n",evp->seq,evp->token) ;
156  /***************** let's do simple detectors; the ones which only have legacy *****/
157 
158  if(print_det[0]) {
159  if(strcmp(print_det, "tinfo") == 0) {
160  printf("trginfo: seq = #%d token = %d detectors = 0x%x triggers = 0x%llx/0x%llx/0x%llx evptriggers=0x%x\n",
161  evp->seq,
162  evp->token,
163  evp->detectors,
164  evp->daqbits64_l1,
165  evp->daqbits64_l2,
166  evp->daqbits64,
167  evp->evpgroups);
168 
169  tinfo_doer(evp, "tinfo");
170  }
171  }
172 
173  if(print_det[0]) {
174  if(strcmp(print_det, "readahead") == 0) {
175  SummaryInfo nsummary;
176  int ret = evp->readNextFutureSummaryInfo(&nsummary);
177 
178 
179  if(ret <= 0) {
180  printf("Event #%d, token %d triggers 0x%llx ----> No Next Event...",
181  evp->seq,evp->token,evp->daqbits64);
182  }
183  else {
184  printf("Event #%d, token %d triggers 0x%llx ----> Next Event: #%d, token %d triggers 0x%llx\n",
185  evp->seq,evp->token,evp->daqbits64,
186  nsummary.seq, nsummary.token,
187  make64(nsummary.L3summary[0],nsummary.L3summary[1]));
188  }
189  }
190  }
191 
192  dd = evp->det("sc")->get() ;
193  if(dd && dd->iterate()) {
194  // LOG(INFO,"SC found") ;
195  if(strcasecmp(print_det,"sc")==0) {
196  sc_t *sc_p = (sc_t *) dd->Void ;
197 
198  // oh well, one needs to to these calculations here
199  // since the SFS daq_sc.cxx doesn't know the absolute time
200  int alag ;
201 
202  sc_p->timelag = evp->evt_time - sc_p->time ;
203  if(sc_p->timelag > 0) alag = sc_p->timelag ;
204  else alag = -sc_p->timelag ;
205 
206  if(alag > 5) sc_p->valid = 0 ;
207  else sc_p->valid = 1 ;
208 
209  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) ;
210  for(int i=0;i<16;i++) {
211  printf("\tRICH scaler %2d: %u\n",i,sc_p->rich_scalers[i]) ;
212  }
213  }
214  }
215 
216  dd = evp->det("fpd")->get("legacy") ;
217  //if(dd) LOG(INFO,"FPD found") ;
218 
219  if(ftp_doer(evp,print_det)) LOG(INFO,"FTP found") ;
220 
221 
222  dd = evp->det("rich")->get("legacy") ;
223  //if(dd) LOG(INFO,"RIC found") ;
224 
225  dd = evp->det("ssd")->get("legacy") ;
226  //if(dd) LOG(INFO,"SSD found") ;
227 
228  dd = evp->det("svt")->get("legacy") ;
229  //if(dd) LOG(INFO,"SVT found") ;
230 
231 
232  if(pmd_doer(evp, print_det)) LOG(INFO,"PMD found") ;
233 
234  dd = evp->det("tof")->get("legacy") ;
235  if(dd) {
236  //LOG(INFO,"TOF found") ;
237  if(strcasecmp(print_det,"tof")==0) {
238  while(dd->iterate()) {
239  tof_t *tof = (tof_t *)dd->Void ;
240  for(int r=0;r<4;r++) {
241  printf("TOF RDO %d: words %d:\n",r+1,tof->ddl_words[r]) ;
242  for(u_int i=0;i<tof->ddl_words[r];i++) {
243  printf("\t%d: 0x%08X [%u dec]\n",i,tof->ddl[r][i],tof->ddl[r][i]) ;
244  }
245  }
246  }
247  }
248  }
249 
250  if(trg_doer(evp, print_det)) //LOG(INFO,"TRG found") ;
251 
252  /***************** EMCs ************************/
253 
254  if(btow_doer(evp, print_det)) //LOG(INFO,"BTOW found") ;
255 
256  // logging done in the doer...
257  bsmd_doer(evp,print_det) ;
258 
259  if(etow_doer(evp, print_det)) //LOG(INFO,"ETOW found") ;
260 
261  if(esmd_doer(evp, print_det))// LOG(INFO,"ESMD found") ;
262 
263  /******************** TPC (old electronics) ***********************/
264 
265  if(tpc_doer(evp,print_det)) //LOG(INFO,"TPC found (legacy)") ;
266 
267  /********************** TPX ***************************/
268  // logging is done in the tpx_doer...
269  tpx_doer(evp,print_det) ;
270 
271 
272 
273  /*************************** PP2PP **********************/
274  if(pp2pp_doer(evp,print_det)) LOG(INFO,"PP2PP found") ;
275 
276 
277  /*************************** L3/HLT09 **************************/
278  if(l3_doer(evp,print_det)) LOG(INFO,"L3/HLT_FY09 found") ;
279 
280  /*************************** HLT10 **************************/
281  if(hlt_doer(evp,print_det)) LOG(INFO,"HLT_FY10 found") ;
282 
283  /*************************** L4 (HLT 12) *******************/
284  if(l4_doer(evp,print_det)) {
285  LOG(INFO, "HLT FY12 found");
286  }
287 
288  /*************************** FGT **************************/
289  fgt_doer(evp,print_det,0) ;
290 
291  /*************************** MTD **************************/
292  if(mtd_doer(evp,print_det)) LOG(INFO,"MTD found") ;
293 
294 
295  /*************************** GMT **************************/
296  fgt_doer(evp,print_det,1) ;
297 
298  /*************************** IST **************************/
299  fgt_doer(evp,print_det,2) ;
300 
301 
302  /*************************** PXL **************************/
303  if(pxl_doer(evp,print_det)) LOG(INFO,"PXL found") ;
304 
305 
306 
307 
308  /************ PSEUDO: SHOULD ONLY BE USED FOR BACKWARD COMPATIBILITY! ************/
309 #ifdef INSIST_ON_EMC_PSEUDO
310  if(emc_pseudo_doer(evp,print_det)) LOG(INFO,"EMC found (any detector)") ;
311 #endif
312 
313  }
314 
315 // delete evp ; // cleanup i.e. if running through a set of files.
316 
317  return 0 ;
318 }
319 
320 static int trg_doer(daqReader *rdr, const char *do_print)
321 {
322  int found = 0 ;
323  daq_dta *dd ;
324 
325  if(strcasestr(do_print,"trg")) ;
326  else do_print = 0 ;
327 
328  // If i want decoded data ala old evpReader I call "legacy" ;
329 
330  dd = rdr->det("trg")->get("legacy") ;
331  if(dd) {
332  if(dd->iterate()) {
333  trg_t *trg_p = (trg_t *) dd->Void ;
334 
335  if(do_print) { // print something...
336  printf("Trigger: tcubits 0x%08X, trg_word 0x%04X\n",trg_p->tcubits,trg_p->trg_word) ;
337  }
338 
339  }
340  }
341 
342 
343  // if you need the void black box of untouched trigger data:
344  dd = rdr->det("trg")->get("raw") ;
345  if(dd) {
346  if(dd->iterate()) {
347  found = 1 ;
348 
349 
350  u_char *trg_raw = dd->Byte;
351 
352  if(do_print) { // I have no clue but let me print first few words...
353 
354 
355  // simple start of trig desc; the way it should be...
356  struct simple_desc {
357  short len ;
358  char evt_desc ;
359  char ver ;
360  } *desc ;
361 
362  desc = (simple_desc *) trg_raw ;
363 
364 
365  printf("Trigger: raw bank has %d bytes: ver 0x%02X, desc %d, len %d\n",dd->ncontent,desc->ver, desc->evt_desc, desc->len) ;
366 
367  // dump first 10 ints...
368  u_int *i32 = (u_int *) trg_raw ;
369  for(int i=0;i<10;i++) {
370  printf("Trigger: word %d: 0x%08X\n",i,i32[i]) ;
371  }
372  }
373  }
374  }
375 
376  return found ;
377 }
378 
379 
380 static int hlt_doer(daqReader *rdr, const char *do_print)
381 {
382  int found = 0 ;
383  daq_dta *dd ;
384 
385  if(strcasestr(do_print,"hlt")) ; // leave as is...
386  else do_print = 0 ;
387 
388  for(int s=1;s<=24;s++) {
389  dd = rdr->det("hlt")->get("tpx",s) ;
390  while(dd && dd->iterate()) {
391  found = 1 ;
392  if(do_print) {
393  printf("HLT TPX sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
394  }
395  }
396  }
397 
398  dd = rdr->det("hlt")->get("trg") ;
399  while(dd && dd->iterate()) {
400  found = 1 ;
401  if(do_print) {
402  printf("HLT TRG sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
403  }
404  }
405 
406  dd = rdr->det("hlt")->get("tof") ;
407  while(dd && dd->iterate()) {
408  found = 1 ;
409  if(do_print) {
410  printf("HLT TOF sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
411  }
412  }
413 
414  dd = rdr->det("hlt")->get("gl3") ;
415  while(dd && dd->iterate()) {
416  found = 1 ;
417  if(do_print) {
418  hlt_gl3_t *h = (hlt_gl3_t *) dd->Void ;
419  printf("HLT GL3 sec %02d: bytes %d: %d %s\n",dd->sec,dd->ncontent,h->bytes,h->name) ;
420  }
421  }
422 
423 
424 
425  return found ;
426 }
427 
428 static int l4_doer(daqReader *rdr, const char *do_print)
429 {
430  int found = 0 ;
431  daq_dta *dd ;
432 
433  if(strcasestr(do_print,"l4")) ; // leave as is...
434  else do_print = 0 ;
435 
436  for(int s=1;s<=24;s++) {
437  dd = rdr->det("l4")->get("tpx",s) ;
438  while(dd && dd->iterate()) {
439  found = 1 ;
440  if(do_print) {
441  printf("L4 TPX sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
442  }
443  }
444  }
445 
446  dd = rdr->det("l4")->get("trg") ;
447  while(dd && dd->iterate()) {
448  found = 1 ;
449  if(do_print) {
450  printf("l4 TRG sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
451  }
452  }
453 
454  dd = rdr->det("l4")->get("tof") ;
455  while(dd && dd->iterate()) {
456  found = 1 ;
457  if(do_print) {
458  printf("l4 TOF sec %02d: bytes %d\n",dd->sec,dd->ncontent) ;
459  }
460  }
461 
462  dd = rdr->det("l4")->get("gl3") ;
463  while(dd && dd->iterate()) {
464  found = 1 ;
465  if(do_print) {
466  l4_gl3_t *h = (l4_gl3_t *) dd->Void ;
467  printf("L4 GL3 sec %02d: bytes %d: %d %s\n",dd->sec,dd->ncontent,h->bytes,h->name) ;
468  }
469  }
470 
471 
472 
473  return found ;
474 }
475 
476 static int tpx_doer(daqReader *rdr, const char *do_print)
477 {
478  int found = 0 ;
479  int adc_found = 0 ;
480  int cld_found = 0 ;
481  int ped_found = 0 ;
482  char s_mask[24] ;
483 
484  daq_dta *dd ;
485 
486  if(strcasestr(do_print,"tpx")) ; // leave as is...
487  else do_print = 0 ;
488 
489  // TPX
490  // it is better, more memory efficient, to call stuff sector by sector (if possible)
491 
492  memset(s_mask,0,sizeof(s_mask)) ;
493 
494  for(int s=1;s<=24;s++) {
495 
496 /* stop using legacy, even in the example...
497  dd = rdr->det("tpx")->get("legacy",s) ; // uses tpc_t
498  while(dd && dd->iterate()) {
499  found = 1 ;
500 
501  struct tpc_t *tpc = (tpc_t *) dd->Void ;
502  if(do_print) {
503  int cls = 0 ;
504  for(int r=0;r<45;r++) {
505  cls += tpc->cl_counts[r] ;
506  }
507 
508  printf("TPX: sec %02d (as legacy): %d pixels, %d clusters\n",dd->sec,tpc->channels_sector,cls) ;
509  }
510 
511  }
512 */
513 
514  int pixel_count[46] ; // as an example we'll count pixels per row
515  memset(pixel_count,0,sizeof(pixel_count)) ;
516  int sec_found = 0 ;
517 
518  dd = rdr->det("tpx")->get("adc",s) ;
519  if(dd) {
520 
521  s_mask[dd->sec-1]=1 ;
522 
523  while(dd->iterate()) {
524  found = 1 ; // any sector...
525  sec_found = 1 ;
526  adc_found = 1 ; // any sector...
527 
528 
529 
530  if(do_print) {
531  printf("TPX: sec %02d, row %2d, pad %3d: %3d pixels\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
532  }
533 
534  pixel_count[dd->row] += dd->ncontent ;
535 
536  for(u_int i=0;i<dd->ncontent;i++) {
537  if(do_print) {
538  printf("\ttb %3d = %4d ADC\n",dd->adc[i].tb, dd->adc[i].adc) ;
539  }
540  }
541  }
542 
543 
544  if(sec_found && do_print) {
545  for(int row=0;row<=45;row++) {
546  printf("+sector %2d, row %2d: pixels %d\n",s,row,pixel_count[row]) ;
547  }
548  }
549  }
550 
551 
552  dd = rdr->det("tpx")->get("cld",s) ;
553  while(dd && dd->iterate()) {
554 
555  found = 1 ;
556  cld_found = 1 ;
557 
558  s_mask[dd->sec-1]=1 ;
559 
560 
561  if(do_print) {
562  printf("TPX: sec %02d, row %2d: %3d clusters (evt %d)\n",dd->sec,dd->row,dd->ncontent,good) ;
563  }
564 
565  for(u_int i=0;i<dd->ncontent;i++) {
566  if(do_print) {
567  int p1,p2,t1,t2 ;
568  int bad = 0 ;
569  p1 = dd->cld[i].p1 ;
570  p2 = dd->cld[i].p2 ;
571  t1 = dd->cld[i].t1 ;
572  t2 = dd->cld[i].t2 ;
573 
574  if(p1 > 200) bad = 1 ;
575  if(p2 > 200) bad = 1 ;
576  if(p2<p1) bad = 1 ;
577  if((p2-p1)>14) bad = 1 ;
578 
579  if(t1 > 1200) bad = 1 ;
580  if(t2 > 1200) bad = 1 ;
581  if(t2<t1) bad = 1 ;
582  if((t2-t1)>30) bad = 1 ;
583 
584  if(bad) printf("BAD: ") ;
585  printf("\tpad %7.3f[%d,%d], time %7.3f[%d,%d], charge %5d, flags 0x%02X\n",
586  dd->cld[i].pad,dd->cld[i].p1,dd->cld[i].p2,
587  dd->cld[i].tb,dd->cld[i].t1,dd->cld[i].t2,
588  dd->cld[i].charge,dd->cld[i].flags) ;
589 
590  }
591  }
592  }
593 
594 
595  // will only exist in token 0 of a pedestal run!
596  dd = rdr->det("tpx")->get("pedrms",s) ;
597  while(dd && dd->iterate()) {
598  found = 1 ;
599  ped_found = 1 ;
600 
601  s_mask[dd->sec-1]=1 ;
602 
603  if(do_print) {
604  printf("TPX: sec %02d, row %2d, pad %3d (%d pix)\n",dd->sec,dd->row,dd->pad,dd->ncontent) ;
605  daq_det_pedrms *ped = (daq_det_pedrms *)dd->Void ;
606  for(u_int tb=0;tb<dd->ncontent;tb++) {
607  printf(" tb %3d: ped %3d, rms %.2f\n",tb,ped[tb].ped,ped[tb].rms) ;
608  }
609  }
610  }
611 
612  }
613 
614  char fstr[128] ;
615  fstr[0] = 0 ; // EOS marker...
616 
617  if(cld_found) {
618  strcat(fstr,"CLD ") ;
619  }
620  if(adc_found) {
621  strcat(fstr,"ADC " ) ;
622  }
623  if(ped_found) {
624  strcat(fstr,"PEDRMS ") ;
625  }
626 
627 
628  int s_cou = 0 ;
629  for(int s=0;s<24;s++) {
630  if(s_mask[s]) {
631  char stmp[8] ;
632  sprintf(stmp,"%d ",s+1) ;
633  strcat(fstr,stmp) ;
634  s_cou++ ;
635  }
636  }
637 
638  if(found) {
639  LOG(INFO,"TPX found [%s;%d]",fstr,s_cou) ;
640  }
641 
642  return found ;
643 
644 }
645 
646 static int ftp_doer(daqReader *rdr, const char *do_print)
647 {
648  int found = 0;
649  daq_dta *dd;
650 
651  if(strcasestr(do_print,"ftp")) ; // leave as is...
652  else do_print = 0 ;
653 
654  dd = rdr->det("ftp")->get("legacy") ;
655 
656  while(dd && dd->iterate()) {
657  found++ ; // mark as found..
658  ftp_t *ftp = (ftp_t *) dd->Void ;
659 
660  if(do_print) {
661  printf("FTP sector %d: pixels %d\n",dd->sec,ftp->channels) ;
662 
663 
664  for(int ss=0;ss<2;ss++) {
665  for(int rb=0;rb<10;rb++) {
666  for(int pad=0;pad<960;pad++) {
667  for(int tbi=0;tbi<ftp->counts[ss][rb][pad];tbi++) {
668  printf("%d %d %d %d %d\n",
669  ss,rb,pad,
670  ftp->timebin[ss][rb][pad][tbi],
671  ftp->adc[ss][rb][pad][tbi]);
672  }
673  }
674  }
675  }
676  }
677  }
678 
679 
680  return found ;
681 }
682 
683 
684 static int tpc_doer(daqReader *rdr, const char *do_print)
685 {
686  int found = 0 ;
687  daq_dta *dd ;
688 
689  if(strcasestr(do_print,"tpc")) ; // leave as is...
690  else do_print = 0 ;
691 
692  // although it is possible to have all sectors of the TPC
693  // present in memory, it is better to do this sector-by-sector
694  // ala the old evpReader, due to the memory footprint
695  for(int s=1;s<=24;s++) {
696  dd = rdr->det("tpc")->get("legacy",s) ;
697 
698  while(dd && dd->iterate()) {
699  found++ ; // mark as found..
700  tpc_t *tpc = (tpc_t *) dd->Void ;
701 
702  if(do_print) {
703  printf("TPC sector %d: pixels %d\n",dd->sec,tpc->channels_sector) ;
704  for(int r=0;r<45;r++) {
705  for(int c=0;c<tpc->cl_counts[r];c++) {
706  printf("row %2d: pad %1.f, tb %.1f, charge %d\n",r+1,
707  tpc->cl[r][c].p,tpc->cl[r][c].t,tpc->cl[r][c].charge) ;
708  }
709  }
710  }
711 
712  // one can rerun the afterburner as well with:
713 
714  //daq_tpc *tpc_class = (daq_tpc *)rdr->det("tpc") ;
715  //int cl_found = tpc_class->fcfReader(dd->sec,0,0,tpc) ;
716  //LOG(NOTE,"TPC: rerun cluster finder: sector %d: found %d clusters",dd->sec,cl_found) ;
717  }
718  }
719 
720  return found ;
721 
722 
723 }
724 
725 
726 static int pmd_doer(daqReader *rdr, const char *do_print)
727 {
728  int found = 0 ;
729  daq_dta *dd ;
730 
731  if(strcasestr(do_print,"pmd")) ; // leave as is...
732  else do_print = 0 ;
733 
734  dd = rdr->det("pmd")->get("legacy") ;
735 
736  if(dd && dd->iterate()) {
737  struct pmd_t *pmd_p = (pmd_t *) dd->Void ;
738 
739  if(do_print) {
740  for(int crate=0;crate<2;crate++) {
741  printf("Crate %s: status %d, mode %d\n",crate==0?"Up":"Dn",pmd_p->status[crate],pmd_p->mode) ;
742 
743  for(int c=0;c<PMD_CRAMS_MAX;c++) {
744  for(int s=0;s<2;s++) {
745  for(int ch=0;ch<PMD_CRAMS_CH_MAX;ch++) {
746  printf(" CRAM %2d: side %d: ch %4d: adc %4d [ped %4.1f, rms %4.2f, thr %4.1f]\n",
747  c,s,ch,
748  pmd_p->adc[crate][c][s][ch],
749  (double)pmd_p->ped[crate][c][s][ch]/16.0,
750  (double)pmd_p->rms[crate][c][s][ch]/16.0,
751  (double)pmd_p->thr[crate][c][s][ch]/16.0) ;
752 
753  }}}
754  }
755 
756  }
757 
758  found = 1 ; // mark as found..
759  }
760 
761  if(found) LOG(NOTE,"PMD legacy found") ;
762 
763  return found ;
764 
765 
766 }
767 
768 static int bsmd_doer(daqReader *rdr, const char *do_print)
769 {
770  int found = 0 ;
771  daq_dta *dd ;
772 
773  int raw_found = 0 ;
774  int adc_non_zs_found = 0 ;
775  int adc_found = 0 ;
776  int ped_found = 0 ;
777 
778  if(strcasestr(do_print,"bsmd")) ; // leave as is...
779  else do_print = 0 ;
780 
781 
782  // do I see the non-zero-suppressed bank? let's do this by fiber...
783  for(int f=1;f<=12;f++) {
784  dd = rdr->det("bsmd")->get("raw",0,f) ; // sector is ignored (=0)
785  if(dd) {
786  while(dd->iterate()) {
787  found = 1 ;
788  raw_found = 1 ;
789 
790  if(do_print) printf("BSMD RAW: fiber %2d [==%d], sector %d:\n",dd->rdo,f,dd->sec) ;
791 
792  // just the header
793  for(int i=0;i<10;i++) {
794  if(do_print) printf(" Head %2d = %08X\n",i,dd->Int32[i]) ;
795  }
796  }
797  }
798  }
799 
800 
801  // do I see the non-zero-suppressed bank? let's do this by fiber...
802  for(int f=1;f<=12;f++) {
803  dd = rdr->det("bsmd")->get("adc_non_zs",0,f) ; // sector is ignored (=0)
804  if(dd) {
805  while(dd->iterate()) {
806  found = 1 ;
807  adc_non_zs_found = 1 ;
808 
809  bsmd_t *d = (bsmd_t *) dd->Void ;
810 
811  if(do_print) printf("BSMD non-ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
812 
813 
814  for(int i=0;i<BSMD_DATSIZE;i++) {
815  if(do_print) printf(" %4d = %4d\n",i,d->adc[i]) ;
816  }
817  }
818  }
819  }
820 
821  // do I see the zero suppressed bank?
822  for(int f=1;f<=12;f++) {
823  dd = rdr->det("bsmd")->get("adc",0,f) ;
824  if(dd) {
825  while(dd->iterate()) {
826  found = 1 ;
827  adc_found = 1 ;
828 
829  bsmd_t *d = (bsmd_t *) dd->Void ;
830 
831  if(do_print) printf("BSMD ZS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
832 
833  for(int i=0;i<BSMD_DATSIZE;i++) {
834  // since this is zero-suppressed, I'll skip zeros...
835  if(do_print) if(d->adc[i]) printf(" %4d = %4d\n",i,d->adc[i]) ;
836  }
837  }
838  }
839  }
840 
841  // do I see the pedestal bank?
842  for(int f=1;f<=12;f++) {
843  dd = rdr->det("bsmd")->get("ped",0,f) ;
844  if(dd) {
845  while(dd->iterate()) {
846  found = 1 ;
847  ped_found = 1 ;
848 
849  bsmd_t *d = (bsmd_t *) dd->Void ;
850 
851  if(do_print) printf("BSMD PED: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
852 
853  for(int i=0;i<BSMD_DATSIZE;i++) {
854  if(do_print) printf(" %4d = %4d\n",i,d->adc[i]) ;
855  }
856  }
857  }
858  }
859 
860  // do I see the rms bank?
861  for(int f=1;f<=12;f++) {
862  dd = rdr->det("bsmd")->get("rms",0,f) ;
863  if(dd) {
864  while(dd->iterate()) {
865  found = 1 ;
866  ped_found = 1 ;
867 
868  bsmd_t *d = (bsmd_t *) dd->Void ;
869 
870  if(do_print) printf("BSMD RMS: fiber %2d, capacitor %d:\n",dd->rdo,d->cap) ;
871 
872  for(int i=0;i<BSMD_DATSIZE;i++) {
873  if(do_print) printf(" %4d = %.2f\n",i,(double)d->adc[i]/8.0) ;
874  }
875  }
876  }
877  }
878 
879 
880  char fstr[64] ;
881  fstr[0] = 0 ; // EOS marker...
882 
883  if(raw_found) {
884  strcat(fstr,"RAW ") ;
885  }
886 
887  if(adc_found) {
888  strcat(fstr,"ADC-ZS ") ;
889  }
890  if(adc_non_zs_found) {
891  strcat(fstr,"ADC-non-ZS " ) ;
892  }
893  if(ped_found) {
894  strcat(fstr,"PEDRMS ") ;
895  }
896 
897  if(found) {
898  LOG(INFO,"BSMD found [%s]",fstr) ;
899  }
900 
901 
902  return found ;
903 }
904 
905 static int esmd_doer(daqReader *rdr, const char *do_print)
906 {
907  int found = 0 ;
908  daq_dta *dd ;
909 
910  if(strcasestr(do_print,"esmd")) ; // leave as is...
911  else do_print = 0 ;
912 
913 
914  dd = rdr->det("esmd")->get("adc") ;
915  if(dd) {
916  while(dd->iterate()) {
917  found = 1 ;
918 
919  esmd_t *d = (esmd_t *) dd->Void ;
920 
921  for(int i=0;i<ESMD_MAXFEE;i++) {
922  for(int j=0;j<ESMD_PRESIZE;j++) {
923  if(do_print) printf("ESMD: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
924  }
925  for(int j=0;j<ESMD_DATSIZE;j++) {
926  if(do_print) printf("ESMD: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
927  }
928 
929  }
930  }
931  }
932 
933  return found ;
934 }
935 
936 static int etow_doer(daqReader *rdr, const char *do_print)
937 {
938  int found = 0 ;
939  daq_dta *dd ;
940 
941  if(strcasestr(do_print,"etow")) ; // leave as is...
942  else do_print = 0 ;
943 
944 
945  dd = rdr->det("etow")->get("adc") ;
946  if(dd) {
947  while(dd->iterate()) {
948  found = 1 ;
949 
950  etow_t *d = (etow_t *) dd->Void ;
951 
952  for(int i=0;i<ETOW_MAXFEE;i++) {
953  for(int j=0;j<ETOW_PRESIZE;j++) {
954  if(do_print) printf("ETOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
955  }
956  for(int j=0;j<ETOW_DATSIZE;j++) {
957  if(do_print) printf("ETOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
958  }
959 
960  }
961  }
962  }
963 
964  return found ;
965 }
966 
967 static int btow_doer(daqReader *rdr, const char *do_print)
968 {
969  int found = 0 ;
970  daq_dta *dd ;
971 
972  if(strcasestr(do_print,"btow")) ; // leave as is...
973  else do_print = 0 ;
974 
975 /* generally commented out... */
976 #if 0
977  dd = rdr->det("btow")->get("raw") ;
978  if(dd) {
979  while(dd->iterate()) {
980  u_short *s16 = (u_short *) dd->Void ;
981 
982  if(do_print) {
983  printf("BTOW: bytes %d\n",dd->ncontent) ;
984  }
985 
986  for(u_int i=0;i<dd->ncontent/2;i++) {
987  if(do_print) {
988  printf("%d: 0x%04X [%d dec]\n",i,s16[i],s16[i]) ;
989  }
990  }
991  }
992  }
993 #endif
994 
995  dd = rdr->det("btow")->get("adc") ;
996  if(dd) {
997  while(dd->iterate()) {
998  found = 1 ;
999 
1000  btow_t *d = (btow_t *) dd->Void ;
1001 
1002  for(int i=0;i<BTOW_MAXFEE;i++) {
1003  for(int j=0;j<BTOW_PRESIZE;j++) {
1004  if(do_print) printf("BTOW: fee %2d: preamble %d: 0x%04X [%d dec]\n",i,j,d->preamble[i][j], d->preamble[i][j]) ;
1005  }
1006  for(int j=0;j<BTOW_DATSIZE;j++) {
1007  if(do_print) printf("BTOW: fee %2d: data %d: 0x%04X [%d dec]\n",i,j,d->adc[i][j], d->adc[i][j]) ;
1008  }
1009 
1010  }
1011  }
1012  }
1013 
1014  return found ;
1015 }
1016 
1017 #ifdef INSIST_ON_EMC_PSEUDO
1018 static int emc_pseudo_doer(daqReader *rdr, const char *do_print)
1019 {
1020  int found = 0 ;
1021  daq_dta *dd ;
1022 
1023  if(strcasestr(do_print,"emc_pseudo")) ; // leave as is...
1024  else do_print = 0 ;
1025 
1026 
1027  dd = rdr->det("emc_pseudo")->get("legacy") ;
1028  if(dd) {
1029  while(dd->iterate()) {
1030  found = 1 ;
1031 
1032  emc_t *d = (emc_t *) dd->Void ;
1033 
1034  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",
1035  d->btow_in, d->btow_ch, d->bsmd_in, d->bsmd_ch, d->etow_in, d->etow_ch, d->esmd_in, d->esmd_ch) ;
1036  }
1037  }
1038 
1039  return found ;
1040 
1041 }
1042 #endif
1043 
1044 
1045 static int pp2pp_doer(daqReader *rdr, const char *do_print)
1046 {
1047  int found = 0 ;
1048  daq_dta *dd ;
1049 
1050  if(strcasestr(do_print,"pp2pp")) ; // leave as is...
1051  else do_print = 0 ;
1052 
1053 
1054  dd = rdr->det("pp2pp")->get("adc") ;
1055  if(dd) {
1056  while(dd->iterate()) {
1057  found = 1 ;
1058 
1059  pp2pp_t *d = (pp2pp_t *) dd->Void ;
1060 
1061  if(do_print) {
1062  printf("PP2PP: sector %d, seq %d, chain %d, SVX %d:\n",dd->sec,d->seq_id,d->chain_id,d->svx_id) ;
1063  for(int c=0;c<PP2PP_SVX_CH;c++) {
1064  // print only found channels via the "trace" array
1065  if(d->trace[c]) printf(" %3d: %3d [0x%02X], trace %d\n",c,d->adc[c],d->adc[c],d->trace[c]) ;
1066  }
1067  }
1068 
1069  }
1070  }
1071 
1072  return found ;
1073 }
1074 
1075 static int l3_doer(daqReader *rdr, const char *do_print)
1076 {
1077  int found = 0 ;
1078  daq_dta *dd ;
1079 
1080  if(strcasestr(do_print,"l3")) ; // leave as is...
1081  else do_print = 0 ;
1082 
1083 
1084  dd = rdr->det("l3")->get("legacy") ;
1085  if(dd) {
1086  while(dd->iterate()) {
1087  found = 1 ;
1088 
1089  l3_t *l3_p = (l3_t *) dd->Void ;
1090 
1091  if(do_print) {
1092  printf("L3/HLT: sequence %u, decision 0x%X: tracks %d, clusters %d, vertex %f:%f:%f\n",
1093  l3_p->channels, l3_p->mode, // note comment in daq_l3.h!
1094  l3_p->tracks_num, l3_p->cluster_num,
1095  l3_p->xVertex, l3_p->yVertex, l3_p->xVertex) ;
1096 
1097 
1098  for(u_int i=0;i<l3_p->tracks_num;i++) {
1099  // just an example of what one would print out...
1100  printf(" track %d: Pt %f, charge %d, nHits %d\n",i+1,
1101  l3_p->track[i].pt, l3_p->track[i].q, l3_p->track[i].nHits) ;
1102 
1103  }
1104  }
1105 
1106  }
1107  }
1108 
1109  return found ;
1110 }
1111 
1112 static int fgt_doer(daqReader *rdr, const char *do_print, int which)
1113 {
1114  int found = 0 ;
1115  char s_found[128] ;
1116  daq_dta *dd ;
1117 
1118  char *d_name = 0 ;
1119 
1120 
1121  switch(which) {
1122  case 1 :
1123  d_name = "GMT" ;
1124  break ;
1125  case 2 :
1126  d_name = "IST" ;
1127  break ;
1128  case 0 :
1129  default :
1130  d_name = "FGT" ;
1131  }
1132 
1133 
1134  if(strcasestr(do_print,d_name)) ; // leave as is...
1135  else do_print = 0 ;
1136 
1137  s_found[0] = 0 ;
1138 
1139  short adc_data[2][FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU][15] ;
1140  short zs_data[2][FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU][15] ;
1141  memset(adc_data,0,sizeof(adc_data)) ;
1142  memset(zs_data,0,sizeof(zs_data)) ;
1143 
1144  dd = rdr->det(d_name)->get("raw") ;
1145  if(dd) {
1146  while(dd->iterate()) {
1147  found |= 1 ;
1148 
1149  // point to the start of the DDL raw data
1150  u_int *d = (u_int *) dd->Void ;
1151 
1152 
1153  if(do_print) {
1154  printf("%s RAW: RDO %d: %d bytes, %d words\n",d_name,dd->rdo,dd->ncontent,dd->ncontent/4) ;
1155  // dump a few ints
1156  for(int i=0;i<10;i++) {
1157  printf(" %3d: 0x%08X\n",i,d[i]) ;
1158  }
1159  }
1160 
1161  }
1162  }
1163 
1164 
1165  // one can get the data in the electronics/logical layout
1166  dd = rdr->det(d_name)->get("adc") ;
1167 
1168  // let's dump the meta-data first
1169  if(dd && dd->meta && do_print) {
1170  apv_meta_t *meta = (apv_meta_t *)dd->meta ;
1171 
1172  printf("%s meta data:\n",d_name) ;
1173  for(int r=1;r<=FGT_RDO_COU;r++) {
1174  if(meta->arc[r].present == 0) continue ;
1175 
1176  printf(" ARC %d: error %c; format %d, ARM mask 0x%X\n",r,meta->arc[r].error?'Y':'N',
1177  meta->arc[r].format_code,
1178  meta->arc[r].arm_mask) ;
1179 
1180  for(int arm=0;arm<FGT_ARM_COU;arm++) {
1181  if(meta->arc[r].arm[arm].present == 0) continue ;
1182 
1183  printf(" ARM %d: error %c\n",arm,meta->arc[r].arm[arm].error?'Y':'N') ;
1184  printf(" : arm_id %d, arm_seq %d, arm_err %d, apv_mask 0x%X\n",
1185  meta->arc[r].arm[arm].arm_id,
1186  meta->arc[r].arm[arm].arm_seq,
1187  meta->arc[r].arm[arm].arm_err,
1188  meta->arc[r].arm[arm].apv_mask) ;
1189 
1190  for(int apv=0;apv<FGT_APV_COU;apv++) {
1191  if(meta->arc[r].arm[arm].apv[apv].present == 0) continue ;
1192 
1193  printf(" APV %2d: error %c\n",apv,meta->arc[r].arm[arm].apv[apv].error?'Y':'N') ;
1194  printf(" : apv_id %d, fmt %d, length %d, seq %d, capid %d, nhits %d, is_error %d, refadc %d, ntim %d\n",
1195  meta->arc[r].arm[arm].apv[apv].apv_id,
1196  meta->arc[r].arm[arm].apv[apv].fmt,
1197  meta->arc[r].arm[arm].apv[apv].length,
1198  meta->arc[r].arm[arm].apv[apv].seq,
1199  meta->arc[r].arm[arm].apv[apv].capid,
1200  meta->arc[r].arm[arm].apv[apv].nhits,
1201  meta->arc[r].arm[arm].apv[apv].is_error,
1202  meta->arc[r].arm[arm].apv[apv].refadc,
1203  meta->arc[r].arm[arm].apv[apv].ntim) ;
1204  }
1205  }
1206  }
1207 
1208  }
1209 
1210  while(dd && dd->iterate()) {
1211  found |= 2 ;
1212 
1213  fgt_adc_t *f = (fgt_adc_t *) dd->Void ;
1214 
1215  if(do_print) {
1216  printf("%s ADC: RDO %d, ARM %d, APV %d: %d values\n",d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1217 
1218  for(u_int i=0;i<dd->ncontent;i++) {
1219  adc_data[dd->rdo-1][dd->sec][dd->pad][f[i].ch][f[i].tb] = f[i].adc ;
1220  printf(" %5d: ch %3d, tb %d = %3d\n",i,f[i].ch,f[i].tb,f[i].adc) ;
1221  }
1222  }
1223  }
1224 
1225 
1226 
1227 
1228 
1229 
1230  // one can get the data in the electronics/logical layout
1231  dd = rdr->det(d_name)->get("zs") ;
1232  if(dd) found |= 4 ;
1233 
1234  // let's dump the meta-data first
1235  if(dd && dd->meta && do_print) {
1236  apv_meta_t *meta = (apv_meta_t *)dd->meta ;
1237 
1238  printf("%s ZS meta data:\n",d_name) ;
1239  for(int r=1;r<=FGT_RDO_COU;r++) {
1240  if(meta->arc[r].present == 0) continue ;
1241 
1242  printf(" ARC %d: error %c; format %d, ARM mask 0x%X\n",r,meta->arc[r].error?'Y':'N',
1243  meta->arc[r].format_code,
1244  meta->arc[r].arm_mask) ;
1245 
1246  for(int arm=0;arm<FGT_ARM_COU;arm++) {
1247  if(meta->arc[r].arm[arm].present == 0) continue ;
1248 
1249  printf(" ARM %d: error %c\n",arm,meta->arc[r].arm[arm].error?'Y':'N') ;
1250  printf(" : arm_id %d, arm_seq %d, arm_err %d, apv_mask 0x%X\n",
1251  meta->arc[r].arm[arm].arm_id,
1252  meta->arc[r].arm[arm].arm_seq,
1253  meta->arc[r].arm[arm].arm_err,
1254  meta->arc[r].arm[arm].apv_mask) ;
1255 
1256  for(int apv=0;apv<FGT_APV_COU;apv++) {
1257  if(meta->arc[r].arm[arm].apv[apv].present == 0) continue ;
1258 
1259  printf(" APV %2d: error %c\n",apv,meta->arc[r].arm[arm].apv[apv].error?'Y':'N') ;
1260  printf(" : apv_id %d, fmt %d, length %d, seq %d, capid %d, nhits %d, is_error %d, refadc %d, ntim %d\n",
1261  meta->arc[r].arm[arm].apv[apv].apv_id,
1262  meta->arc[r].arm[arm].apv[apv].fmt,
1263  meta->arc[r].arm[arm].apv[apv].length,
1264  meta->arc[r].arm[arm].apv[apv].seq,
1265  meta->arc[r].arm[arm].apv[apv].capid,
1266  meta->arc[r].arm[arm].apv[apv].nhits,
1267  meta->arc[r].arm[arm].apv[apv].is_error,
1268  meta->arc[r].arm[arm].apv[apv].refadc,
1269  meta->arc[r].arm[arm].apv[apv].ntim) ;
1270  }
1271  }
1272  }
1273 
1274  }
1275 
1276  while(dd && dd->iterate()) {
1277  found |= 4 ;
1278 
1279  fgt_adc_t *f = (fgt_adc_t *) dd->Void ;
1280 
1281  if(do_print) {
1282  printf("%s ZS: RDO %d, ARM %d, APV %d: %d values\n",d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1283 
1284  for(u_int i=0;i<dd->ncontent;i++) {
1285  zs_data[dd->rdo-1][dd->sec][dd->pad][f[i].ch][f[i].tb] = f[i].adc ;
1286  printf(" %5d: ch %3d, tb %d = %3d\n",i,f[i].ch,f[i].tb,f[i].adc) ;
1287  }
1288  }
1289  }
1290 
1291 #if 0
1292  if(do_print) { // only then...
1293 
1294  for(int r=0;r<2;r++) {
1295  for(int arm=0;arm<FGT_ARM_COU;arm++) {
1296  for(int apv=0;apv<FGT_APV_COU;apv++) {
1297  for(int ch=0;ch<FGT_CH_COU;ch++) {
1298  for(int tb=0;tb<15;tb++) {
1299  int zs = zs_data[r][arm][apv][ch][tb] ;
1300  int adc = adc_data[r][arm][apv][ch][tb] ;
1301 
1302  if(zs && (zs != adc)) {
1303  printf("ZS ERROR: %d %d %d %d %d = zs %d, adc %d\n",r+1,arm,apv,ch,tb,zs,adc) ;
1304  }
1305 
1306  }}}}}
1307  }
1308 #endif
1309 
1310  dd = rdr->det(d_name)->get("pedrms") ;
1311  while(dd && dd->iterate()) {
1312  found |= 8 ;
1313 
1314  fgt_pedrms_t *f = (fgt_pedrms_t *) dd->Void ;
1315 
1316  if(do_print) {
1317  int arc = dd->rdo ;
1318  int arm = dd->sec ;
1319  int apv = dd->pad ;
1320 
1321  //printf("%s PEDRMS: RDO %d, ARM %d, APV %d: %d values\n",d_name,dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1322 
1323  for(u_int i=0;i<dd->ncontent;i++) {
1324  printf("%d %d %2d %3d %2d: %.3f +- %.3f\n",arc,arm,apv,f[i].ch,f[i].tb,f[i].ped,f[i].rms) ;
1325  //printf(" %5d: ch %3d, tb %d = %.3f +- %.3f\n",i,f[i].ch,f[i].tb,f[i].ped,f[i].rms) ;
1326  }
1327  }
1328 
1329 
1330 
1331  }
1332 
1333  if(found & 1) {
1334  strcat(s_found,"RAW ") ;
1335  }
1336  if(found & 2) {
1337  strcat(s_found,"ADC ") ;
1338  }
1339  if(found & 4) {
1340  strcat(s_found,"ZS ") ;
1341  }
1342  if(found & 8) {
1343  strcat(s_found,"PEDRMS ") ;
1344  }
1345 
1346  if(found) LOG(INFO,"%s found: %s",d_name,s_found) ;
1347 
1348  return found ;
1349 }
1350 
1351 static int mtd_doer(daqReader *rdr, const char *do_print)
1352 {
1353  int found = 0 ;
1354  daq_dta *dd ;
1355 
1356  if(strcasestr(do_print,"mtd")) ; // leave as is...
1357  else do_print = 0 ;
1358 
1359 
1360  // right now only the "raw" pointer is available/known
1361  dd = rdr->det("mtd")->get("raw") ;
1362  if(dd) {
1363  while(dd->iterate()) {
1364  found = 1 ;
1365 
1366  // point to the start of the DDL raw data
1367  u_int *d = (u_int *) dd->Void ;
1368 
1369 
1370  if(do_print) {
1371  printf("MTD: RDO %d: %d bytes\n",dd->rdo,dd->ncontent) ;
1372 
1373  for(u_int i=0;i<dd->ncontent/4;i++) {
1374  printf(" %2d: 0x%08X\n",i,d[i]) ;
1375  }
1376  }
1377 
1378  }
1379  }
1380 
1381  return found ;
1382 }
1383 
1384 #if 0
1385 static int gmt_doer(daqReader *rdr, const char *do_print)
1386 {
1387  int found = 0 ;
1388  daq_dta *dd ;
1389 
1390  if(strcasestr(do_print,"gmt")) ; // leave as is...
1391  else do_print = 0 ;
1392 
1393 
1394  // right now only the "raw" pointer is available/known
1395  dd = rdr->det("gmt")->get("raw") ;
1396  if(dd) {
1397  while(dd->iterate()) {
1398  found = 1 ;
1399 
1400  // point to the start of the DDL raw data
1401  u_int *d = (u_int *) dd->Void ;
1402 
1403 
1404  if(do_print) {
1405  printf("GMT RAW: ARC %d: %d bytes (%d words)\n",dd->rdo,dd->ncontent,dd->ncontent/4) ;
1406  // dump a few
1407  for(int i=0;i<10;i++) {
1408  printf(" %2d: 0x%08X\n",i,d[i]) ;
1409  }
1410  }
1411 
1412  }
1413  }
1414 
1415 
1416  // one can get the data in the electronics/logical layout
1417  dd = rdr->det("gmt")->get("adc") ;
1418 
1419 
1420  // let's dump the meta-data first
1421  if(dd && dd->meta && do_print) {
1422  apv_meta_t *meta = (apv_meta_t *)dd->meta ;
1423 
1424  printf("GMT meta data:\n") ;
1425  for(int r=1;r<=FGT_RDO_COU;r++) {
1426  if(meta->arc[r].present == 0) continue ;
1427 
1428  printf(" ARC %d: error %c; format %d, ARM mask 0x%X\n",r,meta->arc[r].error?'Y':'N',
1429  meta->arc[r].format_code,
1430  meta->arc[r].arm_mask) ;
1431 
1432  for(int arm=0;arm<FGT_ARM_COU;arm++) {
1433  if(meta->arc[r].arm[arm].present == 0) continue ;
1434 
1435  printf(" ARM %d: error %c\n",arm,meta->arc[r].arm[arm].error?'Y':'N') ;
1436  printf(" : arm_id %d, arm_seq %d, arm_err %d, apv_mask 0x%X\n",
1437  meta->arc[r].arm[arm].arm_id,
1438  meta->arc[r].arm[arm].arm_seq,
1439  meta->arc[r].arm[arm].arm_err,
1440  meta->arc[r].arm[arm].apv_mask) ;
1441 
1442  for(int apv=0;apv<FGT_APV_COU;apv++) {
1443  if(meta->arc[r].arm[arm].apv[apv].present == 0) continue ;
1444 
1445  printf(" APV %2d: error %c\n",apv,meta->arc[r].arm[arm].apv[apv].error?'Y':'N') ;
1446  printf(" : apv_id %d, fmt %d, length %d, seq %d, capid %d, nhits %d, is_error %d, refadc %d, ntim %d\n",
1447  meta->arc[r].arm[arm].apv[apv].apv_id,
1448  meta->arc[r].arm[arm].apv[apv].fmt,
1449  meta->arc[r].arm[arm].apv[apv].length,
1450  meta->arc[r].arm[arm].apv[apv].seq,
1451  meta->arc[r].arm[arm].apv[apv].capid,
1452  meta->arc[r].arm[arm].apv[apv].nhits,
1453  meta->arc[r].arm[arm].apv[apv].is_error,
1454  meta->arc[r].arm[arm].apv[apv].refadc,
1455  meta->arc[r].arm[arm].apv[apv].ntim) ;
1456  }
1457  }
1458  }
1459 
1460  }
1461 
1462 
1463  while(dd && dd->iterate()) {
1464  found = 1 ;
1465 
1466  fgt_adc_t *f = (fgt_adc_t *) dd->Void ;
1467 
1468  if(do_print) {
1469  printf("GMT ADC: ARC %d, ARM %d, APV %d: %d values\n",dd->rdo,dd->sec,dd->pad,dd->ncontent) ;
1470 
1471  for(u_int i=0;i<dd->ncontent;i++) {
1472  printf(" %5d: ch %3d, tb %d = %3d\n",i,f[i].ch,f[i].tb,f[i].adc) ;
1473  }
1474  }
1475  }
1476 
1477 
1478 
1479  return found ;
1480 }
1481 #endif
1482 
1483 
1484 
1485 // This is called by tinfo flag:
1486 
1487 static int tinfo_doer(daqReader *rdr, const char *do_print)
1488 {
1489  int found = 0;
1490 
1491  daq_dta *dd = rdr->det("trg")->get("raw") ;
1492  if(dd) {
1493  if(dd->iterate()) {
1494  found = 1;
1495 
1496 // int sz = dd->get_size_t();
1497  TriggerDataBlk *trg = (TriggerDataBlk *)dd->Byte;
1498 
1499 // EvtDescData *evtDesc = (EvtDescData *)(((char *)trg) + swap32(trg->EventDesc_ofl.offset));
1500  TrgSumData *trgSum = (TrgSumData *)(((char *)trg) + swap32(trg->Summary_ofl.offset));
1501  L1_DSM_Data *l1Dsm = (L1_DSM_Data *)(((char *)trg) + swap32(trg->L1_DSM_ofl.offset));
1502 
1503  //printf("trginfo: L1 trg = 0x%08x - %08x\n",swap32(trgSum->L1Sum[1]),swap32(trgSum->L1Sum[0]));
1504  //printf("trginfo: L2 trg = 0x%08x - %08x\n",swap32(trgSum->L2Sum[1]),swap32(trgSum->L2Sum[0]));
1505  // for(int i=0;i<64;i++) {
1506  //printf("L2Result[%d]=0x%x\n",i,swap32(trgSum->L2Result[i]));
1507  //}
1508  printf("trginfo: lastDSM: \n");
1509  for(int i=0;i<8;i++) {
1510  printf("[%d] ",i);
1511 
1512  for(int ii=0;ii<16;ii++) {
1513  printf("%c", (swap16(l1Dsm->lastDSM[i]) & (1<<ii)) ? '1' : '0');
1514 
1515  if((ii==3)||(ii==7)||(ii==11)) {
1516  printf(" ");
1517  }
1518  }
1519 
1520  int vpdtac = swap16(l1Dsm->lastDSM[1]) & (1<<13);
1521  int vpde = swap16(l1Dsm->lastDSM[1]) & (1<<14);
1522  int vpdw = swap16(l1Dsm->lastDSM[1]) & (1<<15);
1523 
1524 
1525 
1526  printf(" tac=%d e=%d w=%d \n",vpdtac>0,vpde>0,vpdw>0);
1527  }
1528  }
1529  }
1530 
1531  return found;
1532 }
1533 
1534 
1535 
1536 static int pxl_doer(daqReader *rdr, const char *do_print)
1537 {
1538  int found = 0 ;
1539  daq_dta *dd ;
1540 
1541  if(strcasestr(do_print,"pxl")) ; // leave as is...
1542  else do_print = 0 ;
1543 
1544 
1545  // right now only the "raw" pointer is available/known
1546  dd = rdr->det("pxl")->get("raw") ;
1547  if(dd) {
1548  while(dd->iterate()) {
1549  found = 1 ;
1550 
1551  // point to the start of the DDL raw data
1552  u_int *d = (u_int *) dd->Void ;
1553 
1554 
1555  if(do_print) {
1556  printf("PXL RAW: Sector %d, RDO %d: %d bytes (%d words)\n",dd->sec,dd->rdo,dd->ncontent,dd->ncontent/4) ;
1557  // dump a few
1558  for(int i=0;i<10;i++) {
1559  printf(" %2d: 0x%08X\n",i,d[i]) ;
1560  }
1561  }
1562 
1563  }
1564  }
1565 
1566 
1567 
1568  return found ;
1569 }
Definition: daq_l3.h:10
Definition: daq_l4.h:5
Definition: daq_tof.h:7
Definition: tof.h:15
Definition: rb.hh:21
Definition: daq_emc.h:52
Definition: daq_etow.h:9
Definition: daq_sc.h:6
Definition: daq_tpc.h:22
Definition: daq_btow.h:9
Definition: daq_trg.h:9
Definition: daq_pmd.h:7
Definition: daq_ftp.h:4