8 #include "DSMAlgo_EM201_2009.hh"
10 int DSMAlgo_EM201_2009::ajpBarrel(
const DSM& dsm,
int offset)
const
16 for (
int ch = 0; ch < 6; ++ch)
18 jpBits[ch] = dsm.channels[ch] >> offset & 0x3;
21 const int R3 = dsm.registers[3];
24 return (((jpBits[0] > R3) && (jpBits[1] > R3)) ||
25 ((jpBits[1] > R3) && (jpBits[2] > R3)) ||
26 ((jpBits[2] > R3) && (jpBits[3] > R3)) ||
27 ((jpBits[3] > R3) && (jpBits[4] > R3)) ||
28 ((jpBits[4] > R3) && (jpBits[5] > R3)) ||
29 ((jpBits[5] > R3) && (jpBits[0] > R3)));
32 int DSMAlgo_EM201_2009::ajpEndcap(
const DSM& dsm)
const
35 const int R3 = dsm.registers[3];
39 jpBits[0] = dsm.channels[6] & 0x3;
40 jpBits[1] = dsm.channels[6] >> 2 & 0x3;
41 jpBits[2] = dsm.channels[6] >> 4 & 0x3;
45 jpBits[3] = dsm.channels[7] & 0x3;
46 jpBits[4] = dsm.channels[7] >> 2 & 0x3;
47 jpBits[5] = dsm.channels[7] >> 4 & 0x3;
49 return (((jpBits[0] > R3) && (jpBits[1] > R3)) ||
50 ((jpBits[1] > R3) && (jpBits[2] > R3)) ||
51 ((jpBits[2] > R3) && (jpBits[3] > R3)) ||
52 ((jpBits[3] > R3) && (jpBits[4] > R3)) ||
53 ((jpBits[4] > R3) && (jpBits[5] > R3)) ||
54 ((jpBits[5] > R3) && (jpBits[0] > R3)));
57 void DSMAlgo_EM201_2009::operator()(
DSM& dsm)
106 int jpSum1 = dsm.channels[6] >> 6 & 0x3f;
107 int jpSum2 = dsm.channels[7] >> 6 & 0x3f;
109 int jpId1 = dsm.channels[6] >> 12 & 0x3;
110 int jpId2 = dsm.channels[7] >> 12 & 0x3;
113 case 1: jpSum1 += dsm.channels[3] >> 6 & 0x3f;
break;
114 case 2: jpSum1 += dsm.channels[4] >> 6 & 0x3f;
break;
115 case 3: jpSum1 += dsm.channels[5] >> 6 & 0x3f;
break;
119 case 1: jpSum2 += dsm.channels[0] >> 6 & 0x3f;
break;
120 case 2: jpSum2 += dsm.channels[1] >> 6 & 0x3f;
break;
121 case 3: jpSum2 += dsm.channels[2] >> 6 & 0x3f;
break;
127 int htBitsBarrel = 0;
129 for (
int ch = 0; ch < 6; ++ch)
130 htBitsBarrel |= dsm.channels[ch] >> 12 & 0xf;
134 int htBitsEndcap = 0;
136 for (
int ch = 6; ch < 8; ++ch)
137 htBitsEndcap |= dsm.channels[ch] >> 14 & 0x3;
141 int jpBitsBarrel = 0;
143 for (
int ch = 0; ch < 6; ++ch) {
144 int jpx = dsm.channels[ch] & 0x3;
145 int jpy = dsm.channels[ch] >> 2 & 0x3;
146 int jpz = dsm.channels[ch] >> 4 & 0x3;
148 if (jpx > jpBitsBarrel) jpBitsBarrel = jpx;
149 if (jpy > jpBitsBarrel) jpBitsBarrel = jpy;
150 if (jpz > jpBitsBarrel) jpBitsBarrel = jpz;
153 int bjp1 = jpBitsBarrel > 1;
154 int bjp2 = jpBitsBarrel > 2;
156 int jpBitsEndcap = 0;
158 for (
int ch = 6; ch < 8; ++ch) {
159 int jpa = dsm.channels[ch] & 0x3;
160 int jpb = dsm.channels[ch] >> 2 & 0x3;
161 int jpc = dsm.channels[ch] >> 4 & 0x3;
163 if (jpa > jpBitsEndcap) jpBitsEndcap = jpa;
164 if (jpb > jpBitsEndcap) jpBitsEndcap = jpb;
165 if (jpc > jpBitsEndcap) jpBitsEndcap = jpc;
168 int ejp1 = jpBitsEndcap > 1;
169 int ejp2 = jpBitsEndcap > 2;
176 for (
int reg = 0; reg < 3; ++reg)
177 if (jpSum1 > dsm.registers[reg] || jpSum2 > dsm.registers[reg]) ++jpBits;
180 if (jpBitsBarrel > jpBits) jpBits = jpBitsBarrel;
181 if (jpBitsEndcap > jpBits) jpBits = jpBitsEndcap;
183 int jp0 = jpBits > 0;
184 int jp1 = jpBits > 1;
185 int jp2 = jpBits > 2;
189 int ajpx = ajpBarrel(dsm, 0);
190 int ajpy = ajpBarrel(dsm, 2);
191 int ajpz = ajpBarrel(dsm, 4);
192 int bajp = ajpx || ajpy || ajpz;
193 int eajp = ajpEndcap(dsm);
194 int ajp = bajp || eajp;
214 out |= htBitsEndcap << 4;
230 dsm.info[0] = jpSum1;
231 dsm.info[1] = jpSum2;