StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stage_2_tonko_202104.cxx
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <string.h>
4 
5 #include "fcs_trg_base.h"
6 #include "fcs_ecal_epd_mask.h"
7 
8 /*
9  Tonko's test code used in Apr+ 2021
10 
11 
12  Will be stage_version 0xFF210204
13 */
14 
15 // 20 ECAL links
16 // 8 HCAL link
17 // 6 FPRE links
18 // 2 output links
19 void fcs_trg_base::stage_2_tonko_202104(link_t ecal[], link_t hcal[], link_t pres[], geom_t geo, link_t output[])
20 {
21 
22  int ecal_or = 0 ;
23  int hcal_or = 0 ;
24  int fpre_or = 0 ;
25 
26  for(int i=0;i<20;i++) { // 0..19
27  for(int j=0;j<8;j++) {
28 
29  if(s2_ch_mask[geo.ns] & (1ll<<i)) {
30  ecal[i].d[j] = 0 ;
31  continue ;
32  }
33 
34  if(ecal[i].d[j]) ecal_or |= 1 ;
35  }
36  }
37 
38  for(int i=0;i<8;i++) { // 20..27
39  for(int j=0;j<8;j++) {
40 
41  if(s2_ch_mask[geo.ns] & (1ll<<(20+i))) {
42  hcal[i].d[j] = 0 ;
43  continue ;
44  }
45 
46  if(hcal[i].d[j]) hcal_or |= 1 ;
47  }
48  }
49 
50  for(int i=0;i<6;i++) { // 28..33
51  for(int j=0;j<8;j++) {
52 
53  if(s2_ch_mask[geo.ns] & (1ll<<(28+i))) {
54  pres[i].d[j] = 0 ;
55  continue ;
56  }
57 
58  if(pres[i].d[j]) fpre_or |= 1 ;
59  }
60  }
61 
62  // lower 8 bits
63  output[0].d[0] = ecal_or?0xEE:0 ;
64  output[0].d[1] = hcal_or?0xAA:0 ;
65  output[0].d[2] = fpre_or?0xFF:0 ;
66  output[0].d[3] = 0 ;
67  output[0].d[4] = 0 ;
68  output[0].d[5] = 0 ;
69  output[0].d[6] = (fpre_or<<2)|(hcal_or<<1)|ecal_or ;
70  output[0].d[7] = 0xCD ;
71 
72  // upper 8 bits
73  output[1].d[0] = 0 ;
74  output[1].d[1] = 0 ;
75  output[1].d[2] = 0 ;
76  output[1].d[3] = 0 ;
77  output[1].d[4] = 0 ;
78  output[1].d[5] = 0 ;
79  output[1].d[6] = 0 ;
80  output[1].d[7] = 0xAB ;
81 
82 
83 
84  return ;
85 }
86