StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tpc23_base.h
1 #ifndef _TPC23_BASE_H_
2 #define _TPC23_BASE_H_
3 
4 struct daq_sim_cld_x ;
5 
6 class itpcData ;
7 struct daq_dta ;
8 
9 class tpc23_base {
10 public:
11  tpc23_base() ;
12  virtual ~tpc23_base() ;
13 
14  static const int ROW_MAX = 45 ;
15  static const int PAD_MAX = 182 ;
16  static const int SEQ_MAX = 64 ;
17  static const int SIM_FIFOS = 64 ;
18 
19  int run_start() ;
20  int run_stop() ;
21 
22  int evt_start() ;
23  int evt_stop() ;
24 
25  virtual int rdo_scan(char *mem, int words) ;
26  virtual int from22to23(char *dta, int words) ; // rewrite the old FY22 raw data foramt to FY23
27 
28 // int fee_errs ;
29 
30  u_char rts_id ; // tpx, itpc
31  u_char fmt ; // 22: old data format, 23: FY23 data format
32  u_char online ; // 1:running online, 0:offline with quality and track_id stuff
33 
34  u_char subdet_id ; // e.g. from 1..36
35 
36  u_char sector1 ; // from 1
37  u_char rdo1 ; // from 1
38  u_char rb_mask ; // for iTPC really...
39 
40  u_char id ; // of the instance e.g. number of threads
41 
42  u_char run_type ; //1:pedestal,5:pulser,other:physcs
43 
44  u_char log_level ;
45 
46  u_char trg_cmd ;
47  u_char daq_cmd ;
48  u_short token ;
49 
50  u_char no_cld ;
51 
52 
53  u_char mode ; // for various debugging steering
54 
55  u_int last_ix ;
56  int sequence_cou ;
57 
58  // statistics
59  u_int evt ; // processed
60  u_int evt_trgd ; // triggered event
61 
62  u_int err ; // cleared at rdo_scan?
63 
64  u_int run_errors ;
65 
66  static itpcData *data_c ;
67 
68  // loads once, for ALL sectors...
69  int gains_from_cache(const char *fname=0) ;
70  virtual u_int get_token_s(char *c_addr, int words) { return 0xFFFFF ;} ;
71 
72  struct row_pad_t {
73  float gain ;
74  float t0 ;
75  u_char flags ;
76  } ;
77 
78 
79  static short bad_fee_cou[24][46] ;
80  static short bad_fee[24][46][36] ;
81 
82  struct row_pad_t (*rp_gain)[ROW_MAX+1][PAD_MAX+1] ; // max for both dets; all sectors
83 
84 // static struct row_pad_t (*rp_gain_tpx)[ROW_MAX+1][PAD_MAX+1] ;
85 // static struct row_pad_t (*rp_gain_itpc)[ROW_MAX+1][PAD_MAX+1] ;
86 
87 // static int rowlen[ROW_MAX+1] ;
88 // static int row_min ;
89 // static int row_max ;
90  int rowlen[ROW_MAX+1] ;
91  int row_min ;
92  int row_max ;
93 
94  static struct sim_dta_t {
95  struct {
96  char *mem ;
97  int bytes ;
98  } rb[6] ;
99  } sim_dta[SIM_FIFOS] ;
100 
101  int load_replay(const char *fname, int sec_soft) ;
102  virtual u_int set_rdo(int sec, int rdo) { return 0 ; } ;
103 
104 
105  // simulation
106  void sim_evt_start(int sector) ;
107  //void sim_do_pad(int row, int pad, short *adc, int *track_id) ;
108  int do_ch_sim(int row, int pad, u_short *adc, int *track_id) ;
109  static int fcf_decode(u_int *p_buff, daq_sim_cld_x *dc, u_int version) ;
110 
111 
112  // called from daq_itpc
113  int init(daq_dta *gain) ;
114 
115 //private:
116 
117 
118  // Stage 1 -- first copy of the data
119  // intermediate, unpacking, storage -- allocated at start
120  u_short *s1_dta ;
121  int s1_bytes ;
122 
123 
124 
125  struct seq_t { // just the declaration...
126  short t_hi ;
127  u_short t_lo ;
128  u_short blob_id ;
129  u_short dta_p ; // pointer to data
130  } ;
131 
132  // Stage 1 -- working storage for sequences
133  struct s1_t {
134  u_int ix ; // pointer/index to data in s1_dta
135  struct seq_t seq[SEQ_MAX+1] ; // sequences
136  } s1[ROW_MAX+1][PAD_MAX+1] ;
137 
138  // blob stuff: per row!
139  struct blob_t {
140  u_short t1, t2 ;
141  u_short p1, p2 ;
142  u_short flags ;
143  u_short area ; // here because it is useful for cuts!
144  } blob[PAD_MAX*SEQ_MAX] ; // really a lot...
145 
146  int blob_cou ;
147 
148  int blob_ix[PAD_MAX*SEQ_MAX] ;
149 
150  struct peaks_t {
151  u_short t ;
152  u_short p ;
153  } peaks[512] ;
154 
155  int peaks_cou ;
156 
157  u_short store[PAD_MAX+1][512] ;
158  short smooth[PAD_MAX+1][512] ; // note that it can be negative!
159 
160 
161  u_int *s2_start ; // allocated space for FCF data
162  u_int *s2_dta ; // working pointer
163  int s2_max_words ; // allocated size
164  int s2_words ; // used
165 
166  int *s1_track_id ; // simulated data
167  int *store_track_id ;
168  int sim_track_id ;
169  int sim_quality ;
170  int sim_max_adc ;
171 
172  int row_stage1(int row) ;
173  int row_stage2(int row) ;
174 
175 // static pthread_mutex_t peds_mutex ;
176 } ;
177 
178 
179 #endif
180 
Definition: rb.hh:21