StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tpxCore.h
1 #ifndef _TPX_CORE_H_
2 #define _TPX_CORE_H_
3 
4 #include <sys/types.h>
5 #include <rtsLog.h>
6 
7 #define TPX_GAIN_MASTER_FILE "/RTS/conf/tpx/tpx_gains.txt" // global -- read only AFAIK this code is concerned!
8 #define TPX_CONFIG_FILE "/RTS/conf/tpx/tpx_config_%03d"
9 #define TPX_REMAP_FILE "/RTS/conf/tpx/tpx_remap.txt"
10 
11 #define TPX_ALTRO_DO_CHECK (1<<0) // check altro data
12 #define TPX_ALTRO_DO_ADC (1<<1) // dump the ADCs into the altro_struct
13 #define TPX_ALTRO_DO_FCF (1<<2) // run the CLUSTERfinder as well...
14 
15 #define TPX_MAX_PAD 182
16 
17 /*
18  In pedestal mode I always include the 15 pre-triggers.
19  Due to FIFO sizes in the RDO & FEE I can't have more
20  than 502 entries thus pedestal runs will have 502 timebins,
21  from 0 to 511 where timebins 0..14 are before the trigger.
22 */
23 
24 
25 
26 #define TPX_MAX_TB 420
27 #define TPX_DEF_TB 400
28 
29 //#define TPX_MAX_TB 480
30 //#define TPX_DEF_TB 460
31 
32 #include <TPX/tpx_rdo.h>
33 
34 struct tpx_odd_fee_t {
35  u_char tpc_fee_padplane ; // fee id from padplane
36  u_char status ; // 1=overriden; 2=marked bad
37  u_char sector ; // from 1
38  u_char rdo ; // from 1
39 
40  u_char altro_id_padplane ;
41 } ;
42 
43 struct tpx_rdo_event {
44  u_int *data_start ;
45  u_int *data_end ;
46  u_int trg_cou ;
47  struct trg_data *trg ;
48 
49  short token ; // can be negative!
50  short sector ; // can be negative, if uknown...
51  short rdo ; // can be negative, if unknown; starts from 1!
52 
53  u_char l2_cmd ; // abort,accept,unknown yet...
54  u_char type ;
55  u_char subtype ;
56  u_char data_err ;
57 } ;
58 
59 
61  u_char id ; // original altro id; even if overriden
62  u_char ch ; // original altro channel
63  u_char rdo ; // from 0; this is an _incoming_ datum to the scanner!
64  u_char what ; // bitfield: do what, see defines above...
65 
66  u_char sector ; // input: from 1
67  u_char fee ; // TPC physical absolute FEE; will be correct even for overriden ALTROs!
68  u_char row ;
69  u_char pad ;
70 
71  u_short wc_dummy ; // full altro word count, used in FCF
72  u_char log_err ; // input!
73  u_char err ; // output
74 
75 // u_int *where ; // pointer to this altro's data...
76 
77  u_short t ; // token; incoming, for debugging
78  u_short count ; // length of data
79 
80  u_short adc[512] ;
81  u_short tb[512] ;
82 
83 } ;
84 
85 
87 {
88  u_int delta ;
89  u_int old_rhic ;
90 } ;
91 
93  u_char pll ;
94  u_char status ;
95  u_short retries ;
96 
97  u_int trgs ;
98  u_int trg_csr ; // shows i.e. BUSY
99  u_int a_ticks ;
100  u_int sta_reg ; // status
101  u_int rhic_ticks ; // rhic clocks..
102 } ;
103 
104 inline int tpx36_from_real(int s36, int s_real, int r_real)
105 {
106  int r0_logical ;
107 
108  if(s36 <= 24) return r_real ;
109 
110  if((s_real % 2)==0) { // i.e. 24
111  r0_logical = (r_real-4)+2 ; // 5->3, 6->4
112  }
113  else {
114  r0_logical = (r_real - 4) ; // 5->1, 6->2 ;
115  }
116 
117  if((r0_logical < 1) || (r0_logical > 4)) {
118  LOG(ERR,"Mismap: s36 %d, Shw %02d:%d = %d",s36,s_real,r_real,r0_logical) ;
119  r0_logical = 1 ;
120  }
121 
122  return r0_logical ;
123 }
124 
125 
126 inline void tpx36_to_real(int s36, int r1, int &s_real, int &r_real)
127 {
128  s_real = r_real = 1 ;
129 
130  // this handles both the S35 case when RDOs are 1..4
131  // but _also_ the old, pre-36 case for all 6 RDOs
132  if(s36 <= 24) {
133  s_real = s36 ;
134  r_real = r1 ;
135 
136  return ;
137  }
138 
139 
140  switch(r1) {
141  case 1 :
142  r_real = 5 ;
143  s_real = (s36-24)*2 - 1 ;
144  break ;
145  case 2 :
146  r_real = 6 ;
147  s_real = (s36-24)*2 - 1 ;
148  break ;
149  case 3 :
150  r_real = 5 ;
151  s_real = (s36-24)*2 ;
152  break ;
153  case 4 :
154  r_real = 6 ;
155  s_real = (s36-24)*2 ;
156  break ;
157  default:
158  LOG(ERR,"Mismap: S%02d:%d",s36,r1) ;
159 
160  r_real = 1 ;
161  s_real = 1 ;
162  break ;
163  }
164 
165  return ;
166 }
167 
168 
169 
170 
171 extern int tpx_get_start(char *buff, u_int words, struct tpx_rdo_event *rdo, int do_log) ;
172 extern u_int *tpx_scan_to_next(u_int *now, u_int *data_start, struct tpx_altro_struct *a) ;
173 
174 extern void tpx_from_altro(int rdo, int a, int ch, int &row, int &pad) ;
175 extern void tpx_to_altro(int row, int pad, int &rdo, int &a, int &ch) ;
176 extern int tpx_altro_to_fee(int rdo, int a) ;
177 extern u_char tpx_rdo_fees(int rdo, int cou) ;
178 //extern u_char tpx_altro_ch_to_fee(int a, int ch) ;
179 
180 extern void tpx_analyze_log(int sector, int rdo, char *buff) ;
181 extern int tpx_analyze_msc(int sector, int rdo, char *buff, int *altro_list=0) ;
182 extern int tpx_show_status(int sector, int rb_mask, int *altro_list=0) ;
183 
184 extern struct tpx_rdo tpx_rdo[24][6] ;
185 extern struct tpx_rdo_dbg tpx_rdo_dbg[24][6] ;
186 extern int tpx_fee_check ;
187 
188 extern struct tpx_odd_fee_t tpx_odd_fee[256] ;
189 extern int tpx_odd_fee_count ;
190 
191 extern int *tpx_altro_to_row_override ;
192 extern int tpx_fy16_map ;
193 extern int tpx_is_stgc ;
194 extern int tpx_rdo_override ;
195 
196 #endif
Definition: tpx_rdo.h:4