StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tpx_read_gains.C
1 #include <stdio.h>
2 
3 #include <DAQ_TPX/tpxGain.h>
4 
5 
6 int main(int argc, char *argv[])
7 {
8  const char *fname = "/RTS/conf/tpx/tpx_gains.txt" ; // default
9  int ret ;
10 
11  if(argc==2) { // override default if provided
12  fname = argv[1] ;
13  }
14 
15  tpxGain tpx_gain ; // constructor
16 
17  tpx_gain.init(0) ; // create and zap storage for the whole TPX
18 
19  ret = tpx_gain.from_file(fname) ; // read from file...
20  if(ret < 0) {
21  fprintf(stderr,"********* some failure on file %s!\n",fname) ;
22  return -1 ;
23  }
24 
25  printf("File opened: %s\n",fname) ;
26  printf("Run used [if available]: %08u\n",tpx_gain.c_run) ;
27  printf("Date changed [if available]: date %08u, time %06u\n",tpx_gain.c_date,tpx_gain.c_time) ;
28 
29  // show how the gains & t0 is obtained and used...
30 
31  for(int s=1;s<=24;s++) { // NOTE: sector counts from 1
32  for(int r=1;r<=45;r++) { // NOTE: row counts from 1
33  for(int p=1;p<=182;p++) { // NOTE: pads count from 1
34  float g, t0 ; // gains and t0 are actually stored as "float"...
35 
36  g = tpx_gain.get_gains(s,r,p)->g ;
37  t0 = tpx_gain.get_gains(s,r,p)->t0 ;
38 
39  printf("%d %d %d %.3f %.3f\n",s,r,p,g,t0) ;
40  }
41  }
42  }
43 
44  return 0 ;
45 }