CMS 3D CMS Logo

DTBtiChipSelTrig.cc
Go to the documentation of this file.
1 //-----------------------------------------------------------------
2 //
3 // Class: DTBtiChip
4 //
5 // Description: Implementation of DTBtiChip
6 // trigger algorithm
7 // (Trigger selection implementation)
8 //
9 //
10 // Author List:
11 // C. Grandi
12 // Modifications:
13 // 23/X/02 Sara Vanini : asymmetric acceptance added for H trig
14 // 07/I/03 SV: sort patterns for equivalence with bti manual
15 // 13/I/03 SV: fixed for Keq in manual form
16 // 30/IX/03 SV: redundancies for xA xB xC xD low trigs included
17 // 22/VI/04 SV: last trigger code update
18 //----------------------------------------------------------------
19 
20 //-----------------------
21 // This Class's Header --
22 //-----------------------
24 
25 //-------------------------------
26 // Collaborating Class Headers --
27 //-------------------------------
29 
30 //---------------
31 // C++ Headers --
32 //---------------
33 #include <iostream>
34 #include <cmath>
35 #include <iomanip>
36 
37 using namespace std;
38 
40  if (config()->debug() > 3) {
41  cout << "DTBtiChip::findTrig called" << endl;
42  }
43 
44  //pattern type: 1 = normal
45  // 2 = 1L1
46  // 3 = 11L
47  // 4 = L11
48  // 5 = 1H1
49  // 6 = 11H
50  // 7 = H11
51 
52  // int accpatB = config()->AccPattB(); //default +-1
53  // int accpatA = config()->AccPattA(); //default +-2
54  // int tiKes = config()->XON();
55  int RON = config()->RONflag(); //default 1, redundant patterns enabled
56  int PTMS[32];
57  for (int i = 0; i < 32; i++) {
58  PTMS[i] = config()->PTMSflag(i);
59  }
60 
61  //Triggers (same order as manual):
62  for (int hl = 0; hl < 2; hl++) { //hl=0 high hl=1 low
63  if (RON == 1) {
64  if (keepTrigPatt(PTMS[0], 0, 1, hl))
65  return; // 1324A --> 0 - 1L3L2R4L: nor
66  }
67  if (keepTrigPatt(PTMS[1], 1, 2, hl))
68  return; // 1324B --> 1 - 1L3L2R4R: 1L1
69  if (keepTrigPatt(PTMS[2], 2, 1, hl))
70  return; // 1324C --> 2 - 1R3L2R4L: nor
71  if (keepTrigPatt(PTMS[3], 3, 1, hl))
72  return; // 1324D --> 3 - 1R3L2R4R: nor
73  if (keepTrigPatt(PTMS[4], 4, 3, hl))
74  return; // 1364A --> 4 - 1L3L6L4R: 11L
75  if (keepTrigPatt(PTMS[5], 5, 1, hl))
76  return; // 1364B --> 5 - 1R3L6L4R: nor
77  if (keepTrigPatt(PTMS[6], 6, 1, hl))
78  return; // 1364C --> 6 - 1R3R6L4R: nor
79  if (keepTrigPatt(PTMS[7], 7, 5, hl))
80  return; // 1368A --> 7 - 1R3R6L8L: 1H1
81  if (keepTrigPatt(PTMS[8], 8, 6, hl))
82  return; // 1368B --> 8 - 1R3R6R8L: 11H
83  if (keepTrigPatt(PTMS[9], 9, 7, hl))
84  return; // 1368C --> 9 - 1R3L6L8L: H11
85  if (keepTrigPatt(PTMS[10], 10, 1, hl))
86  return; // 5324A --> 10 - 5L3L2R4L: nor
87  if (keepTrigPatt(PTMS[11], 11, 1, hl))
88  return; // 5324B --> 11 - 5L3R2R4L: nor
89  if (keepTrigPatt(PTMS[12], 12, 6, hl))
90  return; // 5324C --> 12 - 5R3R2R4L: 11H
91  if (keepTrigPatt(PTMS[13], 13, 1, hl))
92  return; // 5364A --> 13 - 5L3R6L4L: nor
93  if (keepTrigPatt(PTMS[14], 14, 1, hl))
94  return; // 5364B --> 14 - 5L3R6L4R: nor
95  if (keepTrigPatt(PTMS[15], 15, 5, hl))
96  return; // 5364C --> 15 - 5R3R6L4L: 1H1
97  if (keepTrigPatt(PTMS[16], 16, 1, hl))
98  return; // 5364D --> 16 - 5R3R6L4R: nor
99  if (keepTrigPatt(PTMS[17], 17, 1, hl))
100  return; // 5368A --> 17 - 5L3R6L8L: nor
101  if (keepTrigPatt(PTMS[18], 18, 1, hl))
102  return; // 5368B --> 18 - 5L3R6R8L: nor
103  if (keepTrigPatt(PTMS[19], 19, 4, hl))
104  return; // 5368C --> 19 - 5L3R6R8R: L11
105  if (keepTrigPatt(PTMS[20], 20, 1, hl))
106  return; // 5764A --> 20 - 5R7L6L4R: nor
107  if (keepTrigPatt(PTMS[21], 21, 1, hl))
108  return; // 5764B --> 21 - 5R7L6R4R: nor
109  if (keepTrigPatt(PTMS[22], 22, 7, hl))
110  return; // 5764C --> 22 - 5R7L6L4L: H11
111  if (keepTrigPatt(PTMS[23], 23, 3, hl))
112  return; // 9764A --> 23 - 9L7L6L4R: 11L
113  if (keepTrigPatt(PTMS[24], 24, 2, hl))
114  return; // 9764B --> 24 - 9L7L6R4R: 1L1
115  if (keepTrigPatt(PTMS[25], 25, 4, hl))
116  return; // 9764C --> 25 - 9L7R6R4R: L11
117  if (keepTrigPatt(PTMS[26], 26, 1, hl))
118  return; // 5768A --> 26 - 5L7L6R8L: nor
119  if (RON == 1) {
120  if (keepTrigPatt(PTMS[27], 27, 2, hl))
121  return; // 5768B --> 27 - 5L7L6R8R: 1L1
122  if (keepTrigPatt(PTMS[28], 28, 1, hl))
123  return; // 5768C --> 28 - 5R7L6R8L: nor
124  if (keepTrigPatt(PTMS[29], 29, 1, hl))
125  return; // 5768D --> 29 - 5R7L6R8R: nor
126  if (keepTrigPatt(PTMS[30], 30, 1, hl))
127  return; // 9768A --> 30 - 9L7L6R8L: nor
128  if (keepTrigPatt(PTMS[31], 31, 1, hl))
129  return; // 9768B --> 31 - 9L7R6R8L: nor
130  }
131 
132  } //end h/l loop
133 
134  /*
135  for(int hl=0;hl<2;hl++){ //hl=0 high hl=1 low
136  if( keepTrigPatt(PTMS[0],0,1,hl) ) return; // 5768A --> 0 - 5L7L6R8L: nor
137  if( RON==1 ){
138  if( keepTrigPatt(PTMS[1],1,2,hl) ) return; // 5768B --> 1 - 5L7L6R8R: 1L1
139  if( keepTrigPatt(PTMS[2],2,1,hl) ) return; // 5768C --> 2 - 5R7L6R8L: nor
140  if( keepTrigPatt(PTMS[3],3,1,hl) ) return; // 5768D --> 3 - 5R7L6R8R: nor
141  }
142  if( keepTrigPatt(PTMS[4],4,3,hl) ) return; // 1364A --> 4 - 1L3L6L4R: 11L
143  if( keepTrigPatt(PTMS[5],5,1,hl) ) return; // 1364B --> 5 - 1R3L6L4R: nor
144  if( keepTrigPatt(PTMS[6],6,1,hl) ) return; // 1364C --> 6 - 1R3R6L4R: nor
145  if( keepTrigPatt(PTMS[7],7,5,hl) ) return; // 1368A --> 7 - 1R3R6L8L: 1H1
146  if( keepTrigPatt(PTMS[8],8,6,hl) ) return; // 1368B --> 8 - 1R3R6R8L: 11H
147  if( keepTrigPatt(PTMS[9],9,7,hl) ) return; // 1368C --> 9 - 1R3L6L8L: H11
148  if( keepTrigPatt(PTMS[10],10,1,hl) ) return; // 5324A --> 10 - 5L3L2R4L: nor
149  if( keepTrigPatt(PTMS[11],11,1,hl) ) return; // 5324B --> 11 - 5L3R2R4L: nor
150  if( keepTrigPatt(PTMS[12],12,6,hl) ) return; // 5324C --> 12 - 5R3R2R4L: 11H
151  if( keepTrigPatt(PTMS[13],13,1,hl) ) return; // 5364A --> 13 - 5L3R6L4L: nor
152  if( keepTrigPatt(PTMS[14],14,1,hl) ) return; // 5364B --> 14 - 5L3R6L4R: nor
153  if( keepTrigPatt(PTMS[15],15,5,hl) ) return; // 5364C --> 15 - 5R3R6L4L: 1H1
154  if( keepTrigPatt(PTMS[16],16,1,hl) ) return; // 5364D --> 16 - 5R3R6L4R: nor
155  if( keepTrigPatt(PTMS[17],17,1,hl) ) return; // 5368A --> 17 - 5L3R6L8L: nor
156  if( keepTrigPatt(PTMS[18],18,1,hl) ) return; // 5368B --> 18 - 5L3R6R8L: nor
157  if( keepTrigPatt(PTMS[19],19,4,hl) ) return; // 5368C --> 19 - 5L3R6R8R: L11
158  if( keepTrigPatt(PTMS[20],20,1,hl) ) return; // 5764A --> 20 - 5R7L6L4R: nor
159  if( keepTrigPatt(PTMS[21],21,1,hl) ) return; // 5764B --> 21 - 5R7L6R4R: nor
160  if( keepTrigPatt(PTMS[22],22,7,hl) ) return; // 5764C --> 22 - 5R7L6L4L: H11
161  if( keepTrigPatt(PTMS[23],23,3,hl) ) return; // 9764A --> 23 - 9L7L6L4R: 11L
162  if( keepTrigPatt(PTMS[24],24,2,hl) ) return; // 9764B --> 24 - 9L7L6R4R: 1L1
163  if( keepTrigPatt(PTMS[25],25,4,hl) ) return; // 9764C --> 25 - 9L7R6R4R: L11
164  if( RON==1 ){
165  if( keepTrigPatt(PTMS[26],26,1,hl) ) return; // 1324A --> 26 - 1L3L2R4L: nor
166  }
167  if( keepTrigPatt(PTMS[27],27,2,hl) ) return; // 1324B --> 27 - 1L3L2R4R: 1L1
168  if( keepTrigPatt(PTMS[28],28,1,hl) ) return; // 1324C --> 28 - 1R3L2R4L: nor
169  if( keepTrigPatt(PTMS[29],29,1,hl) ) return; // 1324D --> 29 - 1R3L2R4R: nor
170  if( RON==1 ){
171  if( keepTrigPatt(PTMS[30],30,1,hl) ) return; // 9768A --> 30 - 9L7L6R8L: nor
172  }
173  if( keepTrigPatt(PTMS[31],31,1,hl) ) return; // 9768B --> 31 - 9L7R6R8L: nor
174 
175  }//end h/l loop
176 
177 */
178 
179  /*
180  // High level triggers:
181  if( keepTrig( 1,accpatB,8) ) return; // 5768B --> 1 - acc. patt. B
182  if( keepTrig( 2,accpatA,8) ) return; // 5768C --> 2 - acc. patt. A
183  if( keepTrig( 3,accpatA,8) ) return; // 5768D --> 3 - acc. patt. A
184  if( keepTrig( 4,accpatB,8) ) return; // 1364A --> 4 - acc. patt. B
185  if( keepTrig( 5,accpatA,8) ) return; // 1364B --> 5 - acc. patt. A
186  if( keepTrig( 6,accpatA,8) ) return; // 1364C --> 6 - acc. patt. A
187  if( keepTrig( 7,accpatB,8) ) return; // 1368A --> 7 - acc. patt. B
188  if( keepTrig( 8,accpatB,8) ) return; // 1368B --> 8 - acc. patt. B
189  if( keepTrig( 9,accpatB,8) ) return; // 1368C --> 9 - acc. patt. B
190  if( keepTrig(10,accpatA,8) ) return; // 5324A --> 10 - acc. patt. A
191  if( keepTrig(11,accpatA,8) ) return; // 5324B --> 11 - acc. patt. A
192  if( keepTrig(12,accpatB,8) ) return; // 5324C --> 12 - acc. patt. B
193  if( keepTrig(13,accpatA,8) ) return; // 5364A --> 13 - acc. patt. A
194  if( keepTrig(14,accpatA,8) ) return; // 5364B --> 14 - acc. patt. A
195  if( keepTrig(15,accpatB,8) ) return; // 5364C --> 15 - acc. patt. B
196  if( keepTrig(16,accpatA,8) ) return; // 5364D --> 16 - acc. patt. A
197  if( keepTrig(17,accpatA,8) ) return; // 5368A --> 17 - acc. patt. A
198  if( keepTrig(18,accpatA,8) ) return; // 5368B --> 18 - acc. patt. A
199  if( keepTrig(19,accpatB,8) ) return; // 5368C --> 19 - acc. patt. B
200  if( keepTrig(20,accpatA,8) ) return; // 5764A --> 20 - acc. patt. A
201  if( keepTrig(21,accpatA,8) ) return; // 5764B --> 21 - acc. patt. A
202  if( keepTrig(22,accpatB,8) ) return; // 5764C --> 22 - acc. patt. B
203  if( keepTrig(23,accpatB,8) ) return; // 9764A --> 23 - acc. patt. B
204  if( keepTrig(24,accpatB,8) ) return; // 9764B --> 24 - acc. patt. B
205  if( keepTrig(25,accpatB,8) ) return; // 9764C --> 25 - acc. patt. B
206  if( keepTrig( 0,accpatA,8) ) return; // 5768A --> 0 - acc. patt. A
207  */
208  /*
209  // Low level triggers -B
210  if( keepTrig( 1,accpatB,2) ) return; // 5768B --> 1 - acc. patt. B
211  if( keepTrig( 2,accpatA,2) ) return; // 5768C --> 2 - acc. patt. A
212  if(tiKes==1) {
213  if( keepTrig( 3,accpatA,2) ) return; // 5768D --> 3 - acc. patt. A
214  }
215  if( keepTrig( 4,accpatB,2) ) return; // 1364A --> 4 - acc. patt. B
216  if( keepTrig( 5,accpatA,2) ) return; // 1364B --> 5 - acc. patt. A
217  if( keepTrig( 6,accpatA,2) ) return; // 1364C --> 6 - acc. patt. A
218  if( keepTrig( 7,accpatB,2) ) return; // 1368A --> 7 - acc. patt. B
219  if( keepTrig( 8,accpatB,2) ) return; // 1368B --> 8 - acc. patt. B
220  if( keepTrig( 9,accpatB,2) ) return; // 1368C --> 9 - acc. patt. B
221  if( keepTrig(10,accpatA,2) ) return; // 5324A --> 10 - acc. patt. A
222  if( keepTrig(11,accpatA,2) ) return; // 5324B --> 11 - acc. patt. A
223  if( keepTrig(12,accpatB,2) ) return; // 5324C --> 12 - acc. patt. B
224  if(tiKes==1) {
225  if( keepTrig(13,accpatA,2) ) return; // 5364A --> 13 - acc. patt. A
226  }
227  if( keepTrig(14,accpatA,2) ) return; // 5364B --> 14 - acc. patt. A
228  if( keepTrig(15,accpatB,2) ) return; // 5364C --> 15 - acc. patt. B
229  if( keepTrig(16,accpatA,2) ) return; // 5364D --> 16 - acc. patt. A
230  if(tiKes==1) {
231  if( keepTrig(17,accpatA,2) ) return; // 5368A --> 17 - acc. patt. A
232  }
233  if( keepTrig(18,accpatA,2) ) return; // 5368B --> 18 - acc. patt. A
234  if( keepTrig(19,accpatB,2) ) return; // 5368C --> 19 - acc. patt. B
235  if( keepTrig(20,accpatA,2) ) return; // 5764A --> 20 - acc. patt. A
236  if(tiKes==1) {
237  if( keepTrig(21,accpatA,2) ) return; // 5764B --> 21 - acc. patt. A
238  }
239  if( keepTrig(22,accpatB,2) ) return; // 5764C --> 22 - acc. patt. B
240  if( keepTrig(23,accpatB,2) ) return; // 9764A --> 23 - acc. patt. B
241  if( keepTrig(24,accpatB,2) ) return; // 9764B --> 24 - acc. patt. B
242  if( keepTrig(25,accpatB,2) ) return; // 9764C --> 25 - acc. patt. B
243  if( keepTrig( 0,accpatA,2) ) return; // 5768A --> 0 - acc. patt. A
244 
245  // Low level triggers -C
246  if( keepTrig( 1,accpatB,3) ) return; // 5768B --> 1 - acc. patt. B
247  if( keepTrig( 2,accpatA,3) ) return; // 5768C --> 2 - acc. patt. A
248  if( keepTrig( 3,accpatA,3) ) return; // 5768D --> 3 - acc. patt. A
249  if( keepTrig( 4,accpatB,3) ) return; // 1364A --> 4 - acc. patt. B
250  if( keepTrig( 5,accpatA,3) ) return; // 1364B --> 5 - acc. patt. A
251  if(tiKes==1) {
252  if( keepTrig( 6,accpatA,3) ) return; // 1364C --> 6 - acc. patt. A
253  }
254  if( keepTrig( 7,accpatB,3) ) return; // 1368A --> 7 - acc. patt. B
255  if( keepTrig( 8,accpatB,3) ) return; // 1368B --> 8 - acc. patt. B
256  if( keepTrig( 9,accpatB,3) ) return; // 1368C --> 9 - acc. patt. B
257  if(tiKes==1) {
258  if( keepTrig(10,accpatA,3) ) return; // 5324A --> 10 - acc. patt. A
259  }
260  if( keepTrig(11,accpatA,3) ) return; // 5324B --> 11 - acc. patt. A
261  if( keepTrig(12,accpatB,3) ) return; // 5324C --> 12 - acc. patt. B
262  if( keepTrig(13,accpatA,3) ) return; // 5364A --> 13 - acc. patt. A
263  if( keepTrig(14,accpatA,3) ) return; // 5364B --> 14 - acc. patt. A
264  if( keepTrig(15,accpatB,3) ) return; // 5364C --> 15 - acc. patt. B
265  if(tiKes==1) {
266  if( keepTrig(16,accpatA,3) ) return; // 5364D --> 16 - acc. patt. A
267  }
268  if( keepTrig(17,accpatA,3) ) return; // 5368A --> 17 - acc. patt. A
269  if( keepTrig(18,accpatA,3) ) return; // 5368B --> 18 - acc. patt. A
270  if( keepTrig(19,accpatB,3) ) return; // 5368C --> 19 - acc. patt. B
271  if( keepTrig(20,accpatA,3) ) return; // 5764A --> 20 - acc. patt. A
272  if( keepTrig(21,accpatA,3) ) return; // 5764B --> 21 - acc. patt. A
273  if( keepTrig(22,accpatB,3) ) return; // 5764C --> 22 - acc. patt. B
274  if( keepTrig(23,accpatB,3) ) return; // 9764A --> 23 - acc. patt. B
275  if( keepTrig(24,accpatB,3) ) return; // 9764B --> 24 - acc. patt. B
276  if( keepTrig(25,accpatB,3) ) return; // 9764C --> 25 - acc. patt. B
277  if(tiKes==1) {
278  if( keepTrig( 0,accpatA,3) ) return; // 5768A --> 0 - acc. patt. A
279  }
280 
281  // Low level triggers -A
282  if( keepTrig( 1,accpatB,1) ) return; // 5768B --> 1 - acc. patt. B
283  if( keepTrig( 2,accpatA,1) ) return; // 5768C --> 2 - acc. patt. A
284  if( keepTrig( 3,accpatA,1) ) return; // 5768D --> 3 - acc. patt. A
285  if( keepTrig( 4,accpatB,1) ) return; // 1364A --> 4 - acc. patt. B
286  if( keepTrig( 5,accpatA,1) ) return; // 1364B --> 5 - acc. patt. A
287  if( keepTrig( 6,accpatA,1) ) return; // 1364C --> 6 - acc. patt. A
288  if( keepTrig( 7,accpatB,1) ) return; // 1368A --> 7 - acc. patt. B
289  if( keepTrig( 8,accpatB,1) ) return; // 1368B --> 8 - acc. patt. B
290  if(tiKes==1) {
291  if( keepTrig( 9,accpatB,1) ) return; // 1368C --> 9 - acc. patt. B
292  }
293  if( keepTrig(10,accpatA,1) ) return; // 5324A --> 10 - acc. patt. A
294  if( keepTrig(11,accpatA,1) ) return; // 5324B --> 11 - acc. patt. A
295  if( keepTrig(12,accpatB,1) ) return; // 5324C --> 12 - acc. patt. B
296  if( keepTrig(13,accpatA,1) ) return; // 5364A --> 13 - acc. patt. A
297  if( keepTrig(14,accpatA,1) ) return; // 5364B --> 14 - acc. patt. A
298  if( keepTrig(15,accpatB,1) ) return; // 5364C --> 15 - acc. patt. B
299  if( keepTrig(16,accpatA,1) ) return; // 5364D --> 16 - acc. patt. A
300  if( keepTrig(17,accpatA,1) ) return; // 5368A --> 17 - acc. patt. A
301  if( keepTrig(18,accpatA,1) ) return; // 5368B --> 18 - acc. patt. A
302  if(tiKes==1) {
303  if( keepTrig(19,accpatB,1) ) return; // 5368C --> 19 - acc. patt. B
304  }
305  if( keepTrig(20,accpatA,1) ) return; // 5764A --> 20 - acc. patt. A
306  if( keepTrig(21,accpatA,1) ) return; // 5764B --> 21 - acc. patt. A
307  if(tiKes==1) {
308  if( keepTrig(22,accpatB,1) ) return; // 5764C --> 22 - acc. patt. B
309  }
310  if( keepTrig(23,accpatB,1) ) return; // 9764A --> 23 - acc. patt. B
311  if( keepTrig(24,accpatB,1) ) return; // 9764B --> 24 - acc. patt. B
312  if(tiKes==1) {
313  if( keepTrig(25,accpatB,1) ) return; // 9764C --> 25 - acc. patt. B
314  }
315  if( keepTrig( 0,accpatA,1) ) return; // 5768A --> 0 - acc. patt. A
316 
317  // Low level triggers -D
318  if( keepTrig( 0,accpatA,4) ) return; // 5768A --> 0 - acc. patt. A
319  if( keepTrig( 1,accpatB,4) ) return; // 5768B --> 1 - acc. patt. B
320  if( keepTrig( 2,accpatA,4) ) return; // 5768C --> 2 - acc. patt. A
321  if( keepTrig( 3,accpatA,4) ) return; // 5768D --> 3 - acc. patt. A
322  if(tiKes==1) {
323  if( keepTrig( 4,accpatB,4) ) return; // 1364A --> 4 - acc. patt. B
324  }
325  if( keepTrig( 5,accpatA,4) ) return; // 1364B --> 5 - acc. patt. A
326  if( keepTrig( 6,accpatA,4) ) return; // 1364C --> 6 - acc. patt. A
327  if( keepTrig( 7,accpatB,4) ) return; // 1368A --> 7 - acc. patt. B
328  if(tiKes==1) {
329  if( keepTrig( 8,accpatB,4) ) return; // 1368B --> 8 - acc. patt. B
330  }
331  if( keepTrig( 9,accpatB,4) ) return; // 1368C --> 9 - acc. patt. B
332  if( keepTrig(10,accpatA,4) ) return; // 5324A --> 10 - acc. patt. A
333  if( keepTrig(11,accpatA,4) ) return; // 5324B --> 11 - acc. patt. A
334  if(tiKes==1) {
335  if( keepTrig(12,accpatB,4) ) return; // 5324C --> 12 - acc. patt. B
336  }
337  if( keepTrig(13,accpatA,4) ) return; // 5364A --> 13 - acc. patt. A
338  if( keepTrig(14,accpatA,4) ) return; // 5364B --> 14 - acc. patt. A
339  if( keepTrig(15,accpatB,4) ) return; // 5364C --> 15 - acc. patt. B
340  if( keepTrig(16,accpatA,4) ) return; // 5364D --> 16 - acc. patt. A
341  if( keepTrig(17,accpatA,4) ) return; // 5368A --> 17 - acc. patt. A
342  if( keepTrig(18,accpatA,4) ) return; // 5368B --> 18 - acc. patt. A
343  if( keepTrig(19,accpatB,4) ) return; // 5368C --> 19 - acc. patt. B
344  if( keepTrig(20,accpatA,4) ) return; // 5764A --> 20 - acc. patt. A
345  if( keepTrig(21,accpatA,4) ) return; // 5764B --> 21 - acc. patt. A
346  if( keepTrig(22,accpatB,4) ) return; // 5764C --> 22 - acc. patt. B
347  if(tiKes==1) {
348  if( keepTrig(23,accpatB,4) ) return; // 9764A --> 23 - acc. patt. B
349  }
350  if( keepTrig(24,accpatB,4) ) return; // 9764B --> 24 - acc. patt. B
351  if( keepTrig(25,accpatB,4) ) return; // 9764C --> 25 - acc. patt. B
352 */
353 }
354 
355 int DTBtiChip::keepTrigPatt(const int flag, const int eq, const int pattType, int hlflag) {
356  //if pattern is not enabled, return
357  if (flag == 0)
358  return 0;
359 
360  int AC1 = config()->AccPattAC1(); //default 0
361  int AC2 = config()->AccPattAC2(); //default 3
362  int ACH = config()->AccPattACH(); //default 1
363  int ACL = config()->AccPattACL(); //default 2
364  int tiKes = config()->XON();
365 
366  if (config()->debug() > 4) {
367  cout << "DTBtiChip::keepTrigPatt called with arguments: ";
368  cout << eq << ", " << pattType << ", " << hlflag << endl;
369  cout << "AC1,AC2,ACH,ACL=" << AC1 << " " << AC2 << " " << ACH << " " << ACL << endl;
370  }
371 
372  BitArray<80> val0, val1, val2, val3, val4, val5;
373  int mm[6];
374 
375  //NB _Keq = (Kman - K0)/2 where K0=tmax*2 --->OBSOLETE, now Keq=Kman
376  //int K0 = 2 * (config()->ST()/2.);
377  int K0 = int(config()->ST());
378 
379  int i = 0;
380  float Keqfloat[6] = {0, 0, 0, 0, 0, 0};
381  for (i = 0; i < 6; i++) {
382  mm[i] = -1;
383  int mk = (int)(_Keq[eq][i] - K0);
384  //if(abs(mk) > config()->KCut(_id.superlayer()-1))continue;
385  if (abs(mk) > 2 * K0)
386  continue;
387  Keqfloat[i] = _Keq[eq][i];
388  mm[i] = (int)(_Keq[eq][i]);
389  // if(_Keq[eq][i]<0){
390  // mm[i]=_Keq[eq][i]*2-0.5+KCen;
391  // } else {
392  // mm[i]=_Keq[eq][i]*2+KCen;
393  // }
394  }
395 
396  switch (pattType) {
397  case 1: //normal pattern
398  //if(hlflag==1 && (eq!=2 && eq!=14 && eq!=28) ){ //test for L
399  /* if(hlflag==1){ //test for L
400  acceptMask(&val0,mm[0],AC1); //eqAB
401  acceptMask(&val1,mm[1],AC1); //eqBC
402  acceptMask(&val2,mm[2],AC1); //eqCD
403  }
404  else
405 */
406  {
407  acceptMask(&val0, mm[0], AC2); //eqAB
408  acceptMask(&val1, mm[1], AC2); //eqBC
409  acceptMask(&val2, mm[2], AC2); //eqCD
410  }
411  break;
412 
413  case 2: //1L1 pattern
414  acceptMask(&val0, mm[0], AC1); //eqAB
415  acceptMask(&val1, mm[1], ACL); //eqBC
416  acceptMask(&val2, mm[2], AC1); //eqCD
417  break;
418 
419  case 3: //11L pattern
420  acceptMask(&val0, mm[0], AC1); //eqAB
421  acceptMask(&val1, mm[1], AC1); //eqBC
422  acceptMask(&val2, mm[2], ACL); //eqCD
423  break;
424 
425  case 4: //L11 pattern
426  acceptMask(&val0, mm[0], ACL); //eqAB
427  acceptMask(&val1, mm[1], AC1); //eqBC
428  acceptMask(&val2, mm[2], AC1); //eqCD
429  break;
430 
431  case 5: //1H1 pattern
432  acceptMask(&val0, mm[0], AC1); //eqAB
433  acceptMask(&val1, mm[1], ACH); //eqBC
434  acceptMask(&val2, mm[2], AC1); //eqCD
435  break;
436 
437  case 6: //11H pattern
438  acceptMask(&val0, mm[0], AC1); //eqAB
439  acceptMask(&val1, mm[1], AC1); //eqBC
440  acceptMask(&val2, mm[2], ACH); //eqCD
441  break;
442 
443  case 7: //H11 pattern
444  acceptMask(&val0, mm[0], ACH); //eqAB
445  acceptMask(&val1, mm[1], AC1); //eqBC
446  acceptMask(&val2, mm[2], AC1); //eqCD
447  break;
448 
449  default:
450  acceptMask(&val0, mm[0], AC2); //eqAB
451  acceptMask(&val1, mm[1], AC2); //eqBC
452  acceptMask(&val2, mm[2], AC2); //eqCD
453  break;
454  }
455 
456  //eq. AC and BD acceptance are always +-1 ->code 00
457  int acc = 0;
458  acceptMask(&val3, mm[3], acc); //eq.AC
459  acceptMask(&val4, mm[4], acc); //eq.BD
460 
461  //eq. AD is the reference value!
462  if (mm[5] > 0) {
463  val5.set(mm[5]);
464  }
465 
466  // debugging: print() method prints from last to first bit!
467  if (config()->debug() > 4) {
468  cout << " dump of val arrays: " << endl;
469  // cout << val0.to_string() << endl;
470  // cout << val1.to_string() << endl;
471  // cout << val2.to_string() << endl;
472  // cout << val3.to_string() << endl;
473  // cout << val4.to_string() << endl;
474  // cout << val5.to_string() << endl;
475  val0.print();
476  cout << endl;
477  val1.print();
478  cout << endl;
479  val2.print();
480  cout << endl;
481  val3.print();
482  cout << endl;
483  val4.print();
484  cout << endl;
485  val5.print();
486  cout << endl;
487  }
488  // end debugging
489 
490  //search for High trigger:
491  if (hlflag == 0) {
492  int code = 0;
493  int KMax = 0;
494  int LKMax = -1;
495  for (i = 0; i < 80; i++) {
496  int val =
497  val0.element(i) + val1.element(i) + val2.element(i) + val3.element(i) + val4.element(i) + val5.element(i);
498  if (val > KMax) {
499  KMax = val;
500  LKMax = i;
501  }
502  }
503 
504  //SV: K value is stored in 6 bits, so K=64->0, etc
505  if (LKMax > 63)
506  LKMax -= 64;
507 
508  if (KMax == 6) {
509  code = 8;
510  int X;
511  if (eq == 0) //store Xbc only for patt 0, else store Xad
512  X = int(_Xeq[eq][0]);
513  else
514  X = int(_Xeq[eq][1]);
515  store(eq, code, LKMax, X, Keqfloat[0], Keqfloat[1], Keqfloat[2], Keqfloat[3], Keqfloat[4], Keqfloat[5]);
516  return 1;
517  }
518  return 0;
519  } //end H
520 
521  //search for Low triggers:
522  if (hlflag == 1) {
523  int code = 0;
524  int RON = config()->RONflag();
525 
526  //hit in B is missing
527  if (config()->debug() > 4)
528  cout << "SelTrig: searching low-B" << endl;
529  int LKMax = -1;
530  for (i = 0; i < 80; i++) {
531  int val = val2.element(i) + val3.element(i) + val5.element(i);
532  if (val == 3) { //Ref. is eqAD
533  code = 2;
534  LKMax = i;
535  int storefg = 1;
536 
537  //SV - XON time-ind.Keq suppr. XON=0 do not abilitate patterns
538  if (tiKes == 0) {
539  if (eq == 3 || eq == 13 || eq == 17 || eq == 21 || eq == 29) {
540  if (config()->debug() > 3)
541  cout << "SelTrig: doing XON suppression!" << endl;
542  storefg = 0;
543  }
544  }
545 
546  //SV - RON suppression for low triggers
547  if (RON == 0) {
548  if (eq == 19) {
549  if (config()->debug() > 3)
550  cout << "SelTrig: doing RON low triggers suppression!" << endl;
551  storefg = 0;
552  }
553  }
554 
555  if (storefg) {
556  //SV: K value is stored in 6 bits, so K=64->0, etc
557  if (LKMax > 63)
558  LKMax -= 64;
559  int X;
560  if (eq == 0)
561  X = int(_Xeq[eq][0]);
562  else
563  X = int(_Xeq[eq][1]);
564  store(eq, code, LKMax, X, Keqfloat[0], Keqfloat[1], Keqfloat[2], Keqfloat[3], Keqfloat[4], Keqfloat[5]);
565  return 1;
566  }
567  }
568  } //end -B Low
569 
570  //hit in C is missing
571  if (config()->debug() > 3)
572  cout << "SelTrig: searching low-C" << endl;
573  for (i = 0; i < 80; i++) {
574  int val = val0.element(i) + val4.element(i) + val5.element(i);
575  if (val == 3) { //Ref. is eqAD
576  code = 3;
577  LKMax = i;
578  int storefg = 1;
579 
580  //SV - XON time-ind.Keq suppr.
581  if (tiKes == 0) {
582  if (eq == 0 || eq == 6 || eq == 10 || eq == 16 || eq == 26 || eq == 30) {
583  if (config()->debug() > 3)
584  cout << "SelTrig: doing XON suppression!" << endl;
585  storefg = 0;
586  }
587  }
588 
589  if (storefg) {
590  //SV: K value is stored in 6 bits, so K=64->0, etc
591  if (LKMax > 63)
592  LKMax -= 64;
593 
594  int X;
595  if (eq == 0)
596  X = int(_Xeq[eq][0]);
597  else
598  X = int(_Xeq[eq][1]);
599  store(eq, code, LKMax, X, Keqfloat[0], Keqfloat[1], Keqfloat[2], Keqfloat[3], Keqfloat[4], Keqfloat[5]);
600  return 1;
601  }
602  }
603  } // end -C Low
604 
605  //for -A and -D low acceptance is +-1
606  // if(pattType==1){
607  val0.reset();
608  val1.reset();
609  val2.reset();
610  acceptMask(&val0, mm[0], AC1); //eqAB
611  acceptMask(&val1, mm[1], AC1); //eqBC
612  acceptMask(&val2, mm[2], AC1); //eqCD
613  // }
614 
615  //hit in A is missing
616  if (config()->debug() > 4)
617  cout << "SelTrig: searching low-A" << endl;
618  for (i = 0; i < 80; i++) {
619  int val = val1.element(i) + val2.element(i) + val4.element(i);
620  if (val == 3 && i == mm[4]) { //Ref. is eqBD
621  code = 1;
622  LKMax = i;
623  int storefg = 1;
624 
625  //SV - XON time-ind.Keq suppr.
626  if (tiKes == 0) {
627  if (eq == 9 || eq == 19 || eq == 22 || eq == 25) {
628  if (config()->debug() > 3)
629  cout << "SelTrig: doing low-A XON suppression!" << endl;
630  storefg = 0;
631  }
632  }
633 
634  if (RON == 0) { //SV - RON suppression
635  if (eq == 26) {
636  if (config()->debug() > 3)
637  cout << "SelTrig: doing RON low triggers suppression!" << endl;
638  storefg = 0;
639  }
640  }
641 
642  if (storefg) {
643  //SV: K value is stored in 6 bits, so K=64->0, etc
644  if (LKMax > 63)
645  LKMax -= 64;
646 
647  store(eq,
648  code,
649  LKMax,
650  int(_Xeq[eq][0]),
651  Keqfloat[0],
652  Keqfloat[1],
653  Keqfloat[2],
654  Keqfloat[3],
655  Keqfloat[4],
656  Keqfloat[5]);
657  return 1;
658  }
659  }
660  } //end -A Low
661 
662  //hit in D is missing
663  if (config()->debug() > 4)
664  cout << "SelTrig: searching low-D" << endl;
665  for (i = 0; i < 80; i++) {
666  int val = val0.element(i) + val1.element(i) + val3.element(i);
667  if (val == 3 && i == mm[3]) { //Ref. is eqAC
668  code = 4;
669  LKMax = i;
670  int storefg = 1;
671 
672  //SV - XON time-ind.Keq suppr.
673  if (tiKes == 0) {
674  if (eq == 4 || eq == 8 || eq == 12 || eq == 23) {
675  if (config()->debug() > 3)
676  cout << "SelTrig: doing XON suppression!" << endl;
677  storefg = 0;
678  }
679  }
680 
681  //SV - RON suppression for low triggers
682  if (RON == 0) {
683  if (eq == 1 || eq == 2 || eq == 3 || eq == 24 || eq == 25) {
684  if (config()->debug() > 3)
685  cout << "SelTrig: doing RON low triggers suppression!" << endl;
686  storefg = 0;
687  }
688  }
689 
690  if (storefg) { // && _Xeq[eq][1] >=0){
691  //SV: K value is stored in 6 bits, so K=64->0, etc
692  if (LKMax > 63)
693  LKMax -= 64;
694 
695  store(eq,
696  code,
697  LKMax,
698  int(_Xeq[eq][0]),
699  Keqfloat[0],
700  Keqfloat[1],
701  Keqfloat[2],
702  Keqfloat[3],
703  Keqfloat[4],
704  Keqfloat[5]);
705  return 1;
706  }
707  }
708  } //end -D Low
709 
710  return 0;
711  } //end Low
712  return 0;
713 }
714 
715 void DTBtiChip::acceptMask(BitArray<80>* BitArrPtr, int k, int accep) {
716  if (k >= 0 && k < 78) {
717  if (config()->debug() > 4)
718  cout << "DTBtiChip::acceptMask -> Setting acceptance for k=" << k << endl;
719 
720  if (accep == 0) { //code 00
721  if (k >= 1)
722  BitArrPtr->set(k - 1);
723  BitArrPtr->set(k);
724  BitArrPtr->set(k + 1);
725  }
726  if (accep == 1) { //code 01
727  BitArrPtr->set(k);
728  BitArrPtr->set(k + 1);
729  BitArrPtr->set(k + 2);
730  }
731  if (accep == 2) { //code 10
732  if (k > 1)
733  BitArrPtr->set(k - 2);
734  if (k >= 1)
735  BitArrPtr->set(k - 1);
736  BitArrPtr->set(k);
737  }
738  if (accep == 3) { //code 11
739  if (k > 1)
740  BitArrPtr->set(k - 2);
741  if (k >= 1)
742  BitArrPtr->set(k - 1);
743  BitArrPtr->set(k);
744  BitArrPtr->set(k + 1);
745  BitArrPtr->set(k + 2);
746  }
747  }
748 
749  if (config()->debug() > 4)
750  cout << "DTBtiChip::acceptMask -> END " << endl;
751 }
752 
753 int DTBtiChip::keepTrig(const int eq, const int acp, const int code) {
754  if (config()->debug() > 4) {
755  cout << "DTBtiChip::keepTrig called with arguments: ";
756  cout << eq << ", " << acp << ", " << code << endl;
757  }
758 
759  int const KCen = 40; // Arrays will start from 0 --> use 40 instead of 41
760  BitArray<80> val0, val1, val2, val3, val4, val5;
761  int mm[6];
762 
763  int i = 0;
764  for (i = 0; i < 6; i++) {
765  mm[i] = 0;
766  int mk = (int)(2 * _Keq[eq][i]);
767  if (abs(mk) > config()->KCut())
768  continue;
769  mm[i] = (int)(_Keq[eq][i] * 2) + KCen;
770  // if(_Keq[eq][i]<0){
771  // mm[i]=_Keq[eq][i]*2-0.5+KCen;
772  // } else {
773  // mm[i]=_Keq[eq][i]*2+KCen;
774  // }
775  }
776 
777  if (mm[0] > 0 && (code == 8 || code == 3 || code == 4)) {
778  val0.set(mm[0] - 1);
779  val0.set(mm[0]);
780  val0.set(mm[0] + 1);
781  if (acp == 2 && (code == 8 || code == 3)) {
782  val0.set(mm[0] - 2);
783  val0.set(mm[0] + 2);
784  }
785  }
786 
787  if (mm[1] > 0 && (code == 8 || code == 1 || code == 4)) {
788  val1.set(mm[1] - 1);
789  val1.set(mm[1]);
790  val1.set(mm[1] + 1);
791  if (acp == 2 && code == 8) {
792  val1.set(mm[1] - 2);
793  val1.set(mm[1] + 2);
794  }
795  }
796 
797  if (mm[2] > 0 && (code == 8 || code == 1 || code == 2)) {
798  val2.set(mm[2] - 1);
799  val2.set(mm[2]);
800  val2.set(mm[2] + 1);
801  if (acp == 2 && (code == 8 || code == 2)) {
802  val2.set(mm[2] - 2);
803  val2.set(mm[2] + 2);
804  }
805  }
806 
807  if (mm[3] > 0 && (code == 8 || code == 2 || code == 4)) {
808  val3.set(mm[3] - 1);
809  val3.set(mm[3]);
810  val3.set(mm[3] + 1);
811  }
812 
813  if (mm[4] > 0 && (code == 8 || code == 1 || code == 3)) {
814  val4.set(mm[4] - 1);
815  val4.set(mm[4]);
816  val4.set(mm[4] + 1);
817  }
818 
819  if (mm[5] > 0 && (code == 8 || code == 2 || code == 3)) {
820  val5.set(mm[5]);
821  }
822 
823  // debugging
824  if (config()->debug() > 4) {
825  cout << " dump of val arrays: " << endl;
826  // cout << val0.to_string() << endl;
827  // cout << val1.to_string() << endl;
828  // cout << val2.to_string() << endl;
829  // cout << val3.to_string() << endl;
830  // cout << val4.to_string() << endl;
831  // cout << val5.to_string() << endl;
832  val0.print();
833  cout << endl;
834  val1.print();
835  cout << endl;
836  val2.print();
837  cout << endl;
838  val3.print();
839  cout << endl;
840  val4.print();
841  cout << endl;
842  val5.print();
843  cout << endl;
844  }
845  // end debugging
846 
847  int KMax = 0;
848  int LKMax = -1;
849  for (i = 0; i < 80; i++) {
850  int val = val0.element(i) + val1.element(i) + val2.element(i) + val3.element(i) + val4.element(i) + val5.element(i);
851  // int val = val0.test(i)+val1.test(i)+val2.test(i)+
852  // val3.test(i)+val4.test(i)+val5.test(i);
853  if (val > KMax) {
854  KMax = val;
855  LKMax = i;
856  }
857  }
858 
859  // Note that all bits in val are shifted by one w.r.t. FORTRAN version
860  // The output K will be the same because of the different value of Kcen
861 
862  if (KMax == 6 && code == 8) {
863  store(eq, 8, LKMax - KCen, int(_Xeq[eq][1]));
864  return 1;
865  } else if (KMax == 3 && code != 8) {
866  if (code == 1 || code == 4) {
867  store(eq, code, LKMax - KCen, int(_Xeq[eq][0]));
868  } else {
869  store(eq, code, LKMax - KCen, int(_Xeq[eq][1]));
870  }
871  return 1;
872  }
873  return 0;
874  // return value is ITFL of FORTRAN version
875 }
mps_fire.i
i
Definition: mps_fire.py:428
X
#define X(str)
Definition: MuonsGrabber.cc:38
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1DTConfigBti_cff.RON
RON
Definition: L1DTConfigBti_cff.py:22
BitArray::print
std::ostream & print(std::ostream &o=std::cout) const
Definition: BitArray.h:340
debug
#define debug
Definition: HDRShower.cc:19
DTBtiChip::findTrig
void findTrig()
Definition: DTBtiChipSelTrig.cc:39
BitArray::element
int element(const int pos) const
Definition: BitArray.h:206
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DTBtiChip.h
L1DTConfigBti_cff.AC1
AC1
Definition: L1DTConfigBti_cff.py:76
createfilelist.int
int
Definition: createfilelist.py:10
BitArray::reset
void reset()
Definition: BitArray.h:215
L1DTConfigBti_cff.AC2
AC2
drift velocity parameter 4ST3
Definition: L1DTConfigBti_cff.py:75
DTBtiChip::keepTrigPatt
int keepTrigPatt(int flag, const int eq, const int pattType, int hlflag)
Definition: DTBtiChipSelTrig.cc:355
L1DTConfigBti_cff.ACL
ACL
dead bti parameter
Definition: L1DTConfigBti_cff.py:9
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
L1DTConfigBti_cff.ACH
ACH
Definition: L1DTConfigBti_cff.py:6
DTBtiChip::acceptMask
void acceptMask(BitArray< 80 > *BitArrPtr, int k, int accep)
Definition: DTBtiChipSelTrig.cc:715
DTBtiChip::keepTrig
int keepTrig(const int eq, const int acp, const int code)
Definition: DTBtiChipSelTrig.cc:753
BitArray::set
void set(const int i)
Definition: BitArray.h:224
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
BitArray.h
BitArray
Definition: BitArray.h:28
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117