18 : ncfebs_(tmbHeader->NCFEBs()), ntbins_(tmbHeader->NTBins())
28 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version)
38 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version)
51 for (
int ifeb = 0; ifeb <
ncfebs_; ++ifeb)
53 for (
int tbin = 0; tbin <
ntbins_; ++tbin)
55 for (
int layer = 1; layer <= 6; ++layer)
67 static const bool doStripSwapping =
true;
77 std::vector<CSCComparatorDigi>
result;
78 assert(layer>0 && layer<= 6);
82 for (
int distrip = 0; distrip < 8; ++distrip)
84 uint16_t tbinbitsS0HS0=0;
85 uint16_t tbinbitsS0HS1=0;
86 uint16_t tbinbitsS1HS0=0;
87 uint16_t tbinbitsS1HS1=0;
88 for (
int tbin = 0; tbin <
ntbins_-2; ++tbin)
90 if (
bitValue(cfeb, tbin, layer, distrip))
98 int bit2 =
bitValue(cfeb, tbin+1, layer, distrip);
99 int bit3 =
bitValue(cfeb, tbin+2, layer, distrip);
101 int chamberDistrip = distrip + cfeb*8;
102 int HalfStrip = 4*chamberDistrip + bit2*2 + bit3;
103 int output = 4 + bit2*2 + bit3;
115 LogTrace (
"CSCCLCTData|CSCRawToDigi")
116 <<
"fillComparatorOutputs: layer = "
117 << layer <<
" timebin = " << tbin
118 <<
" cfeb = " << cfeb <<
" distrip = " << chamberDistrip
119 <<
" HalfStrip = " << HalfStrip
120 <<
" Output " << output << std::endl;
124 if (output==4) tbinbitsS0HS0=tbinbitsS0HS0+(1<<tbin);
125 if (output==5) tbinbitsS0HS1=tbinbitsS0HS1+(1<<tbin);
126 if (output==6) tbinbitsS1HS0=tbinbitsS1HS0+(1<<tbin);
127 if (output==7) tbinbitsS1HS1=tbinbitsS1HS1+(1<<tbin);
136 if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1)
138 unsigned int cfeb_corr = cfeb;
139 unsigned int distrip_corr = distrip;
151 distrip_corr = 7-distrip;
154 if ( me1b && !zplus )
156 distrip_corr = 7-distrip;
165 distrip_corr = 7-distrip;
167 if ( me1b && !zplus )
169 distrip_corr = 7-distrip;
176 int strip = 16*cfeb_corr + 2*distrip_corr + 1;
179 LogTrace (
"CSCCLCTData|CSCRawToDigi")
180 <<
"fillComparatorOutputs: cfeb_corr = " << cfeb_corr
181 <<
" distrip_corr = " << distrip_corr <<
" strip = " << strip;
183 if (doStripSwapping && (( me1a && zplus ) || ( me1b && !zplus )))
188 if (tbinbitsS0HS1) result.push_back(
CSCComparatorDigi(strip+1, 0, tbinbitsS0HS1));
189 if (tbinbitsS0HS0) result.push_back(
CSCComparatorDigi(strip+1, 1, tbinbitsS0HS0));
195 if (tbinbitsS1HS0) result.push_back(
CSCComparatorDigi(strip+1, 0, tbinbitsS1HS0));
196 if (tbinbitsS1HS1) result.push_back(
CSCComparatorDigi(strip+1, 1, tbinbitsS1HS1));
209 std::vector<CSCComparatorDigi>
result;
210 assert(layer>0 && layer<= 6);
212 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb)
214 std::vector<CSCComparatorDigi> oneCfebDigi =
comparatorDigis(layer,cfeb);
215 result.insert(result.end(), oneCfebDigi.begin(), oneCfebDigi.end());
227 int cfeb = (strip-1)/16;
228 int distrip = ((strip-1)%16) / 2;
233 assert(distrip < 8 && cfeb < 8 && halfStrip < 225);
236 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin();
237 tbinItr != timeBinsOn.end(); ++tbinItr)
240 if (tbin >= 0 && tbin <
ntbins_-2)
262 static const bool doStripSwapping =
true;
268 unsigned layer = cid.
layer();
273 int cfeb = (strip-1)/16;
274 int distrip = ((strip-1)%16) / 2;
275 int bit2 = (strip-1)%2;
283 assert(distrip < 8 && cfeb < 8 && halfstrip < 225);
285 assert(distrip < 8 && cfeb < 6 && halfstrip < 161);
294 if ( (me1a || (me1b && (cfeb > 3))) && zplus )
298 bit2 = ((31-(halfstrip%32))%4)/2;
299 bit3 = ((31-(halfstrip%32))%4)%2;
302 if ( me1b && !zplus && (cfeb<4))
306 bit2 = ((31-(halfstrip%32))%4)/2;
307 bit3 = ((31-(halfstrip%32))%4)%2;
315 if ( (me1a || (me1b && (cfeb > 3))) &&
zplus )
318 bit2 = ((31-(halfstrip%32))%4)/2;
319 bit3 = ((31-(halfstrip%32))%4)%2;
321 if ( me1b && !zplus && (cfeb<4))
325 bit2 = ((31-(halfstrip%32))%4)/2;
326 bit3 = ((31-(halfstrip%32))%4)%2;
335 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin();
336 tbinItr != timeBinsOn.end();
340 if (tbin >= 0 && tbin <
ntbins_-2)
362 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb)
364 for (
int tbin = 0; tbin <
ntbins_; ++tbin)
366 for (
int layer = 1; layer <= 6; ++layer)
370 bool wordIsGood = (word.
tbin_ == tbin) && (word.
cfeb_ == cfeb);
371 result = result && wordIsGood;
372 if (!wordIsGood &&
debug)
374 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"Bad CLCT data in layer " << layer
375 <<
" expect CFEB " << cfeb <<
" tbin " << tbin;
376 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
" See " << word.
cfeb_ <<
" "
382 if (!result)
LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"++ Bad CLCT Data ++ ";
407 clctData.
add(comparatorDigi1,1);
408 clctData.
add(comparatorDigi2,4);
409 clctData.
add(comparatorDigi3,6);
419 assert(digis1.size() == 1);
420 assert(digis2.size() == 1);
421 assert(digis3.size() == 1);
423 assert(digis1[0].getStrip() == 1);
424 assert(digis1[0].getComparator() == 0);
425 assert(digis1[0].getTimeBin() == 4);
427 assert(digis2[0].getStrip() == 39);
428 assert(digis2[0].getComparator() == 1);
429 assert(digis2[0].getTimeBin() == 5);
431 assert(digis3[0].getStrip() == 80);
432 assert(digis3[0].getComparator() == 1);
433 assert(digis3[0].getTimeBin() == 6);
int getStrip() const
Get the strip number. Counts from 1.
void set(int distrip, bool value)
@ not right! doesn't set zero
CSCCLCTDataWord & dataWord(int iline) const
unsigned short theData[7 *6 *32]
int getComparator() const
Get Comparator readings. Can be 0 or 1.
bool bitValue(int cfeb, int tbin, int layer, int distrip)
std::vector< int > getTimeBinsOn() const
static std::atomic< bool > debug
CSCCLCTData(const CSCTMBHeader *tmbHeader)
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn't do flipping yet.