17 if (tmbHeader !=
nullptr)
26 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version) {
32 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version) {
41 for (
int ifeb = 0; ifeb <
ncfebs_; ++ifeb) {
42 for (
int tbin = 0; tbin <
ntbins_; ++tbin) {
43 for (
int layer = 1; layer <= 6; ++layer) {
51 static const bool doStripSwapping =
true;
59 std::vector<CSCComparatorDigi>
result;
60 assert(layer > 0 && layer <= 6);
64 for (
int distrip = 0; distrip < 8; ++distrip) {
65 uint16_t tbinbitsS0HS0 = 0;
66 uint16_t tbinbitsS0HS1 = 0;
67 uint16_t tbinbitsS1HS0 = 0;
68 uint16_t tbinbitsS1HS1 = 0;
69 for (
int tbin = 0; tbin <
ntbins_ - 2; ++tbin) {
70 if (
bitValue(cfeb, tbin, layer, distrip)) {
77 int bit2 =
bitValue(cfeb, tbin + 1, layer, distrip);
78 int bit3 =
bitValue(cfeb, tbin + 2, layer, distrip);
80 int chamberDistrip = distrip + cfeb * 8;
81 int HalfStrip = 4 * chamberDistrip + bit2 * 2 + bit3;
82 int output = 4 + bit2 * 2 + bit3;
95 <<
"fillComparatorOutputs: layer = " << layer <<
" timebin = " << tbin <<
" cfeb = " << cfeb
96 <<
" distrip = " << chamberDistrip <<
" HalfStrip = " << HalfStrip <<
" Output " <<
output << std::endl;
101 tbinbitsS0HS0 = tbinbitsS0HS0 + (1 << tbin);
103 tbinbitsS0HS1 = tbinbitsS0HS1 + (1 << tbin);
105 tbinbitsS1HS0 = tbinbitsS1HS0 + (1 << tbin);
107 tbinbitsS1HS1 = tbinbitsS1HS1 + (1 << tbin);
116 if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1) {
117 unsigned int cfeb_corr = cfeb;
118 unsigned int distrip_corr = distrip;
120 if (doStripSwapping) {
127 distrip_corr = 7 - distrip;
128 cfeb_corr = 10 - cfeb;
130 if (me1b && !
zplus) {
131 distrip_corr = 7 - distrip;
132 cfeb_corr = 3 - cfeb;
137 distrip_corr = 7 - distrip;
139 if (me1b && !
zplus) {
140 distrip_corr = 7 - distrip;
141 cfeb_corr = 3 - cfeb;
146 int strip = 16 * cfeb_corr + 2 * distrip_corr + 1;
149 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"fillComparatorOutputs: cfeb_corr = " << cfeb_corr
150 <<
" distrip_corr = " << distrip_corr <<
" strip = " <<
strip;
152 if (doStripSwapping && ((me1a &&
zplus) || (me1b && !
zplus))) {
180 std::vector<CSCComparatorDigi>
result;
181 assert(layer > 0 && layer <= 6);
183 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb) {
184 std::vector<CSCComparatorDigi> oneCfebDigi =
comparatorDigis(layer, cfeb);
185 result.insert(
result.end(), oneCfebDigi.begin(), oneCfebDigi.end());
195 int cfeb = (
strip - 1) / 16;
196 int distrip = ((
strip - 1) % 16) / 2;
200 assert(distrip < 8 && cfeb < 8 && halfStrip < 225);
203 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin(); tbinItr != timeBinsOn.end(); ++tbinItr) {
205 if (tbin >= 0 && tbin <
ntbins_ - 2) {
210 dataWord(cfeb, tbin + 1, layer).
set(distrip,
true);
214 dataWord(cfeb, tbin + 2, layer).
set(distrip,
true);
223 static const bool doStripSwapping =
true;
224 bool me1a = (cid.
station() == 1) && (cid.
ring() == 4);
226 bool me1b = (cid.
station() == 1) && (cid.
ring() == 1);
229 unsigned layer = cid.
layer();
233 int cfeb = (
strip - 1) / 16;
234 int distrip = ((
strip - 1) % 16) / 2;
235 int bit2 = (
strip - 1) % 2;
241 assert(distrip < 8 && cfeb < 8 && halfstrip < 225);
243 assert(distrip < 8 && cfeb < 6 && halfstrip < 161);
247 if (doStripSwapping) {
249 if ((me1a || (me1b && (cfeb > 3))) &&
zplus) {
250 distrip = 7 - distrip;
252 bit2 = ((31 - (halfstrip % 32)) % 4) / 2;
253 bit3 = ((31 - (halfstrip % 32)) % 4) % 2;
255 if (me1b && !
zplus && (cfeb < 4)) {
256 distrip = 7 - distrip;
258 bit2 = ((31 - (halfstrip % 32)) % 4) / 2;
259 bit3 = ((31 - (halfstrip % 32)) % 4) % 2;
263 if ((me1a || (me1b && (cfeb > 3))) &&
zplus) {
264 distrip = 7 - distrip;
265 bit2 = ((31 - (halfstrip % 32)) % 4) / 2;
266 bit3 = ((31 - (halfstrip % 32)) % 4) % 2;
268 if (me1b && !
zplus && (cfeb < 4)) {
269 distrip = 7 - distrip;
271 bit2 = ((31 - (halfstrip % 32)) % 4) / 2;
272 bit3 = ((31 - (halfstrip % 32)) % 4) % 2;
278 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin(); tbinItr != timeBinsOn.end(); ++tbinItr) {
280 if (tbin >= 0 && tbin <
ntbins_ - 2) {
286 dataWord(cfeb, tbin + 1, layer).
set(distrip,
true);
291 dataWord(cfeb, tbin + 2, layer).
set(distrip,
true);
298 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb) {
299 for (
int tbin = 0; tbin <
ntbins_; ++tbin) {
300 for (
int layer = 1; layer <= 6; ++layer) {
303 bool wordIsGood = (
word.tbin_ == tbin) && (
word.cfeb_ == cfeb);
305 if (!wordIsGood &&
debug) {
306 LogTrace(
"CSCCLCTData|CSCRawToDigi")
307 <<
"Bad CLCT data in layer " << layer <<
" expect CFEB " << cfeb <<
" tbin " << tbin;
308 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
" See " <<
word.cfeb_ <<
" " <<
word.tbin_;
314 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"++ Bad CLCT Data ++ ";
334 clctData.
add(comparatorDigi1, 1);
335 clctData.
add(comparatorDigi2, 4);
336 clctData.
add(comparatorDigi3, 6);
346 assert(digis1.size() == 1);
347 assert(digis2.size() == 1);
348 assert(digis3.size() == 1);
350 assert(digis1[0].getStrip() == 1);
351 assert(digis1[0].getComparator() == 0);
352 assert(digis1[0].getTimeBin() == 4);
354 assert(digis2[0].getStrip() == 39);
355 assert(digis2[0].getComparator() == 1);
356 assert(digis2[0].getTimeBin() == 5);
358 assert(digis3[0].getStrip() == 80);
359 assert(digis3[0].getComparator() == 1);
360 assert(digis3[0].getTimeBin() == 6);