StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testReader.C
1 //******************************************************
2 //*** Chops events out of .daq file
3 //***
4 //*** usage: daqFileChopper fn.daq arglist
5 //***
6 //*** arglist is passed to the function
7 //*** FilterEvent(), which returns true
8 //*** if the event is to be saved
9 //***
10 //*** output goes to standard out...
11 //*****************************************************
12 
13 #include <stdio.h>
14 #include <unistd.h>
15 #include <getopt.h>
16 #include <sys/types.h>
17 #include <stdlib.h>
18 
19 #include <rtsLog.h> // for my LOG() call
20 #include <rtsSystems.h>
21 
22 // this needs to be always included
23 #include <DAQ_READER/daqReader.h>
24 #include <SUNRT/clock.h>
25 
26 int main(int argc, char *argv[])
27 {
28  rtsLogOutput(RTS_LOG_STDERR) ;
29  rtsLogLevel(WARN) ;
30 
31  RtsTimer timer;
32 
33  char *fn = NULL;
34  if(argc > 1) {
35  fn = argv[1];
36  }
37 
38  daqReader *evp;
39  evp = new daqReader(fn) ; // create it with the filename argument..
40 
41  int good=0;
42  int bad=0;
43 
44  double t;
45 
46  for(;;) {
47  timer.reset();
48  //char *ret = evp->skip_then_get(4700,0,EVP_TYPE_ANY);
49  char *ret = evp->get(0,EVP_TYPE_ANY);
50  t = timer.currtime();
51 
52  if(ret) {
53  if(evp->status) {
54  LOG(ERR,"evp status is non-null [0x08X, %d dec]",evp->status,evp->status) ;
55  continue ;
56  }
57  good++;
58  LOG("JEFF", "Got event in %lf seconds",t);
59  }
60  else { // something other than an event, check what.
61  switch(evp->status) {
62  case EVP_STAT_OK: // just a burp!
63  LOG("JEFF", "Got empty in %lf seconds",t);
64  continue;
65 
66  case EVP_STAT_EOR:
67  LOG("JEFF", "Got EOR in %lf seconds", t);
68  break;
69 
70  case EVP_STAT_EVT:
71  bad++;
72  LOG("JEFF", "Got ERR in %lf seconds", t);
73  continue;
74 
75  case EVP_STAT_CRIT:
76  LOG(CRIT,"evp->status CRITICAL (?)") ;
77  return -1;
78  }
79  break;
80  }
81 
82 
83  printf("evp->seq=%d n=%d\n",evp->seq,evp->event_number);
84  }
85 
86  delete evp ;
87  return 0 ;
88 }
Definition: clock.h:32