StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fcfClass.hh
1 /*
2  Version 3.0 C++ Class-based version
3  Version 3.11 Overhaul of internal structures
4 
5 */
6 
7 #ifndef _FCF_CLASS_HH_
8 #define _FCF_CLASS_HH_
9 
10 #include <sys/types.h>
11 
12 
13 // steering - watch it!
14 //#define FCF_ANNOTATE_CLUSTERS
15 
16 
17 
18 // flag definitions - NEVER CHANGE
19 #define FCF_ONEPAD 1
20 #define FCF_DOUBLE_PAD 2
21 #define FCF_DOUBLE_T 4
22 #define FCF_FALLING 8
23 #define FCF_ROW_EDGE 16 // touched end of row
24 #define FCF_BROKEN_EDGE 32 // touches one of the mezzanine edges
25 #define FCF_DEAD_EDGE 64 // touches a dead pad
26 #define FCF_IGNORE 128
27 
28 // FCF paramters defaults - DON'T MUCK AROUND!
29 #define FCF_PARAM1 2 // was 2
30 #define FCF_MIN_ADC_T 3 // was 3
31 #define FCF_MIN_ADC_PAD 12 // was 12
32 
33 
34 #define FCF_GAIN_SHIFT 6 // shift left/righ
35 #define FCF_GAIN_FACTOR (1<<FCF_GAIN_SHIFT) // 64!!!
36 
37 
38 #define FCF_WORDS_PER_CLUSTER 2
39 
40 
41 #if defined(__unix) || defined(__ROOT__) || defined(__CINT__)
42 
43 typedef unsigned int u_int;
44 typedef unsigned short u_short;
45 typedef unsigned char u_char;
46 
47 #define FCF_SIM_ON
48 
49 #else
50 
51 #ifdef FCF_ANNOTATE_CLUSTERS
52 #undef FCF_ANNOTATE_CLUSTERS
53 #endif
54 
55 #ifdef FCF_DEBUG_OUTPUT
56 #undef FCF_DEBUG_OUTPUT
57 #endif
58 
59 #ifdef FCF_SIM_ON
60 #undef FCF_SIM_ON
61 #endif
62 
63 #endif
64 
65 
66 // used if the FCF_ANNOTATE_CLUSTERS is set...
68  u_short adc ; // the 10 bit ADC value of the charge
69  u_short cl_id ; // the FCF cluster ID (local to the row)
70  u_short id_simtrk ; // the Simulated track ID (local to the event)
71  u_short res ; // reserved...
72 } ;
73 
74 
75 // used for simulated tracks...
76 struct FcfSimOutput { // this is just the payload definition.
77  short id_simtrk;
78  short id_quality;
79  short cl_id ; // local cluster id
80  short reserved; // reserved
81 };
82 
83 
84 #ifdef FCF_ANNOTATE_CLUSTERS
85 #ifndef FCF_SIM_ON
86 #define FCF_SIM_ON
87 #endif
88 
89 #ifndef __ROOT__
90 
91 extern struct fcfPixAnnotate fcfPixA[45][182][512] ; // a biiiig one!
92 
93 #else
94 extern struct fcfPixAnnotate pixStruct[183][512] ;
95 
96 #endif
97 
98 #endif
99 
100 
101 class fcfClass {
102 public:
103 
104  fcfClass(int det, u_short *table = NULL) ; // constructor
105 
106  // the following are set by the constructor depending on the detector parameter
107  // They may be changed explicitly for tests & debug thus they are "public"
108 
109  // Tonko added this for TPCMZCLD tracking
110  u_int cvs_revision ;
111 
112  int detector ; // i.e. TPC_ID, SVT_ID; set in constructor
113  u_int maxTimebin ; // 511 TPC, 127 SVT
114  u_int maxCPP ; // 8 SVT, 31 TPC
115 
116  // the following MUST BE SET once!
117  u_int svtPedestal ; // when using SVT pedestal offet...
118  u_int timebinLo ;
119  u_int timebinHi ;
120  u_int chargeMin ;
121 
122 
123  u_int deconTime ; // unused...
124  u_int deconPad ; // unused...
125 
126  u_int doCuts ;
127 
128  int param1 ;
129  int minAdcT ;
130  int minAdcPad ;
131 
132  // the following changes from call to call (row to row...)
133  int row ; // from 1..45
134  int padStart ; // Absolute starting pad i.e. 1..182
135  int padStop ; // Absolute last pad
136  int padMax ; // maximum pad for this row
137 
138  u_int *adcOff ; // offsets for the current row only!
139  u_short *cppOff ;
140  u_int maxClusters ; // maximum allowed # clusters in this row
141 
142  short *simIn; // simulation track id
143  u_int *simOut;
144 
145  // offset to the pad-to-pad t0 correction (multipled by gain and 64!), V4.10
146  int *t0Corr ;
147 
148  // offset to the pad gain table (multipled by 64!),
149  u_int *gainCorr ;
150 
151  u_short *startFlags ;
152 
153  // used perhaps...
154  int sb ; // i.e. sector number, 1..24
155  int rb ; // receiver board, 1..12 or 1..6 for Offline
156  int mz ; // mezzanine, 1..3 (0 for Offline)
157 
158 
159  // THA function!
160  int finder(u_char *adcin, u_short *cppin, u_int *outres) ;
161 
162  // support
163  inline int saveRes(struct fcfResx *res_p[], int cou, u_int *output) ;
164  void set8to10(u_short *extTable) ;
165 
166 private:
167  struct fcfResx *resx[2][512] ;
168 
169  u_short *a8to10 ; // internal copy
170  int noADCconversion ;
171 
172  // used in UNIX versions only...
173  u_short adc8to10_storage[256] ;
174 
175  u_int chargeMinCorrect ;
176 } ;
177 
178 
179 // Tonko: merged fcfAfterburner.hh into here
180 
181 struct fcfHit {
182  u_short pad ;
183  u_short tm ;
184  u_short f ;
185  u_short c ;
186  u_short p1,p2,t1,t2 ;
187  short id_simtrk;
188  short id_quality;
189  short cl_id ;
190 } ;
191 
192 
194  enum {kMax_fcfHit = 200};
195 public:
196  fcfAfterburner();
197  ~fcfAfterburner() { ; } ;
198 
199  int burn(u_int *ptr_res[3], u_int *ptr_simu_res[3] = NULL) ;
200  int next(fcfHit *out) ;
201  int compare(u_int *p1[3], u_int *p2[3]) ;
202 
203  void decode(u_int *data, fcfHit *h, u_int *sim = 0) ; // utility: from FCF to local
204  void print_hit(const char *, fcfHit *hit) ; // utility
205 
206  u_int do_swap ; // 0=no, 1=yes => set by "burn"
207  u_int do_merge ; // merge broken rows
208  u_int do_cuts ; // apply additional cuts
209  u_int row ; // picked up from the data...
210 
211  void setVerbose(bool v) { verbose = v; };
212 private :
213  bool verbose;
214 
215  u_int last_n, last_i, last_count, last_stage ;
216  u_int **ptr ; // storage for the burn arg...
217  u_int **ptr_simu ; // storage for the simulation ptr. 2nd burn argument
218 
219  u_int edge[4] ;
220  struct fcfHit broken[4][kMax_fcfHit] ;
221  u_int cou_broken[4] ;
222 
223  int output(fcfHit *l) ; // the cut function; return TRUE if accepted
224  int check_merge(fcfHit *l, fcfHit *r) ; // merges r into l and returns TRUE
225 } ;
226 
227 
228 
229 #endif
Definition: rb.hh:21