18 : ncfebs_(tmbHeader->NCFEBs()), ntbins_(tmbHeader->NTBins()) {
19 if (tmbHeader !=
nullptr)
28 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version) {
34 : ncfebs_(ncfebs), ntbins_(ntbins), theFirmwareVersion(firmware_version) {
43 for (
int ifeb = 0; ifeb <
ncfebs_; ++ifeb) {
44 for (
int tbin = 0; tbin <
ntbins_; ++tbin) {
53 static const bool doStripSwapping =
true;
63 std::vector<CSCComparatorDigi>
result;
69 uint16_t tbinbitsS0HS0 = 0;
70 uint16_t tbinbitsS0HS1 = 0;
71 uint16_t tbinbitsS1HS0 = 0;
72 uint16_t tbinbitsS1HS1 = 0;
73 for (
int tbin = 0; tbin <
ntbins_ - 2; ++tbin) {
85 int HalfStrip = 4 * chamberDistrip + bit2 * 2 + bit3;
86 int output = 4 + bit2 * 2 + bit3;
98 LogTrace(
"CSCComparatorData|CSCRawToDigi")
99 <<
"fillComparatorOutputs: layer = " <<
layer <<
" timebin = " << tbin <<
" cfeb = " << cfeb
100 <<
" distrip = " << chamberDistrip <<
" HalfStrip = " << HalfStrip <<
" Output " <<
output << std::endl;
105 tbinbitsS0HS0 = tbinbitsS0HS0 + (1 << tbin);
107 tbinbitsS0HS1 = tbinbitsS0HS1 + (1 << tbin);
109 tbinbitsS1HS0 = tbinbitsS1HS0 + (1 << tbin);
111 tbinbitsS1HS1 = tbinbitsS1HS1 + (1 << tbin);
120 if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1) {
121 unsigned int cfeb_corr = cfeb;
122 unsigned int distrip_corr = distrip;
124 if (doStripSwapping) {
131 distrip_corr = 7 - distrip;
132 cfeb_corr = 10 - cfeb;
134 if (me1b && !
zplus) {
135 distrip_corr = 7 - distrip;
136 cfeb_corr = 3 - cfeb;
141 distrip_corr = 7 - distrip;
143 if (me1b && !
zplus) {
144 distrip_corr = 7 - distrip;
145 cfeb_corr = 3 - cfeb;
150 int strip = 16 * cfeb_corr + 2 * distrip_corr + 1;
153 LogTrace(
"CSCComparatorData|CSCRawToDigi") <<
"fillComparatorOutputs: cfeb_corr = " << cfeb_corr
154 <<
" distrip_corr = " << distrip_corr <<
" strip = " <<
strip;
156 if (doStripSwapping && ((me1a &&
zplus) || (me1b && !
zplus))) {
186 std::vector<CSCComparatorDigi>
result;
187 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb) {
189 result.insert(
result.end(), oneCfebDigi.begin(), oneCfebDigi.end());
208 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin(); tbinItr != timeBinsOn.end(); ++tbinItr) {
210 if (tbin >= 0 && tbin <
ntbins_ - 2) {
228 static const bool doStripSwapping =
true;
229 bool me1a = (cid.
station() == 1) && (cid.
ring() == 4);
231 bool me1b = (cid.
station() == 1) && (cid.
ring() == 1);
239 int bit2 = (
strip - 1) % 2;
256 if (doStripSwapping) {
259 distrip = 7 - distrip;
265 distrip = 7 - distrip;
272 distrip = 7 - distrip;
277 distrip = 7 - distrip;
286 for (std::vector<int>::const_iterator tbinItr = timeBinsOn.begin(); tbinItr != timeBinsOn.end(); ++tbinItr) {
288 if (tbin >= 0 && tbin <
ntbins_ - 2) {
306 for (
int cfeb = 0; cfeb <
ncfebs_; ++cfeb) {
307 for (
int tbin = 0; tbin <
ntbins_; ++tbin) {
311 bool wordIsGood = (
word.tbin_ == tbin) && (
word.cfeb_ == cfeb);
313 if (!wordIsGood &&
debug) {
314 LogTrace(
"CSCComparatorData|CSCRawToDigi")
315 <<
"Bad CLCT data in layer " <<
layer <<
" expect CFEB " << cfeb <<
" tbin " << tbin;
316 LogTrace(
"CSCComparatorData|CSCRawToDigi") <<
" See " <<
word.cfeb_ <<
" " <<
word.tbin_;
322 LogTrace(
"CSCComparatorData|CSCRawToDigi") <<
"++ Bad CLCT Data ++ ";
342 comparatorData.
add(comparatorDigi1, 1);
343 comparatorData.
add(comparatorDigi2, 4);
344 comparatorData.
add(comparatorDigi3, 6);
350 std::vector<CSCComparatorDigi> digis1 = comparatorData.
comparatorDigis(1);
351 std::vector<CSCComparatorDigi> digis2 = comparatorData.
comparatorDigis(4);
352 std::vector<CSCComparatorDigi> digis3 = comparatorData.
comparatorDigis(6);
354 assert(digis1.size() == 1);
355 assert(digis2.size() == 1);
356 assert(digis3.size() == 1);
358 assert(digis1[0].getStrip() == 1);
359 assert(digis1[0].getComparator() == 0);
360 assert(digis1[0].getTimeBin() == 4);
362 assert(digis2[0].getStrip() == 39);
363 assert(digis2[0].getComparator() == 1);
364 assert(digis2[0].getTimeBin() == 5);
366 assert(digis3[0].getStrip() == 80);
367 assert(digis3[0].getComparator() == 1);
368 assert(digis3[0].getTimeBin() == 6);
int getComparator() const
Get Comparator readings. Can be 0 or 1.
void set(int distrip, bool value)
@ not right! doesn't set zero
bool bitValue(int cfeb, int tbin, int layer, int distrip)
int getCFEB() const
Get the CFEB number. Counts from 0.
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
CSCComparatorDataWord & dataWord(int iline) const
std::vector< int > getTimeBinsOn() const
int getHalfStrip() const
Get the associated halfstrip number for this comparator digi. Counts from 0.
void add(const CSCComparatorDigi &digi, int layer)
TODO for packing. Doesn't do flipping yet.
CSCComparatorData(const CSCTMBHeader *tmbHeader)
int getStrip() const
Get the strip number. Counts from 1.
static std::atomic< bool > debug
int getDiStrip() const
Get the distrip number. Counts from 0.
std::vector< CSCComparatorDigi > comparatorDigis(int layer)
layers count from one
unsigned short theData[7 *6 *32]