13 : ncfebs_(tmbHeader->NCFEBs()), ntbins_(tmbHeader->NTBins())
21 : ncfebs_(ncfebs), ntbins_(ntbins)
31 : ncfebs_(ncfebs), ntbins_(ntbins)
44 for(
int ifeb = 0; ifeb <
ncfebs_; ++ifeb)
46 for(
int tbin = 0; tbin <
ntbins_; ++tbin)
48 for(
int layer = 1; layer <= 6; ++layer)
60 static const bool doStripSwapping =
true;
67 std::vector<CSCComparatorDigi>
result;
68 assert(layer>0 && layer<= 6);
72 for(
int distrip = 0; distrip < 8; ++distrip)
74 uint16_t tbinbitsS0HS0=0;
75 uint16_t tbinbitsS0HS1=0;
76 uint16_t tbinbitsS1HS0=0;
77 uint16_t tbinbitsS1HS1=0;
78 for(
int tbin = 0; tbin <
ntbins_-2; ++tbin)
80 if(
bitValue(cfeb, tbin, layer, distrip))
84 assert(word.
tbin_ == tbin);
85 assert(word.
cfeb_ == cfeb);
88 int bit2 =
bitValue(cfeb, tbin+1, layer, distrip);
89 int bit3 =
bitValue(cfeb, tbin+2, layer, distrip);
91 int chamberDistrip = distrip + cfeb*8;
92 int HalfStrip = 4*chamberDistrip + bit2*2 + bit3;
93 int output = 4 + bit2*2 + bit3;
105 LogTrace (
"CSCCLCTData|CSCRawToDigi")
106 <<
"fillComparatorOutputs: layer = "
107 << layer <<
" timebin = " << tbin
108 <<
" cfeb = " << cfeb <<
" distrip = " << chamberDistrip
109 <<
" HalfStrip = " << HalfStrip
110 <<
" Output " << output << std::endl;
114 if (output==4) tbinbitsS0HS0=tbinbitsS0HS0+(1<<tbin);
115 if (output==5) tbinbitsS0HS1=tbinbitsS0HS1+(1<<tbin);
116 if (output==6) tbinbitsS1HS0=tbinbitsS1HS0+(1<<tbin);
117 if (output==7) tbinbitsS1HS1=tbinbitsS1HS1+(1<<tbin);
126 if (tbinbitsS0HS0 || tbinbitsS0HS1 || tbinbitsS1HS0 || tbinbitsS1HS1) {
127 unsigned int cfeb_corr = cfeb;
128 unsigned int distrip_corr = distrip;
130 if (doStripSwapping) {
135 if ( me1a && zplus ) {distrip_corr = 7-distrip;}
136 if ( me1b && !zplus ) {distrip_corr = 7-distrip; cfeb_corr = 3-cfeb;}
139 int strip = 16*cfeb_corr + 2*distrip_corr + 1;
142 LogTrace (
"CSCCLCTData|CSCRawToDigi")
143 <<
"fillComparatorOutputs: cfeb_corr = " << cfeb_corr
144 <<
" distrip_corr = " << distrip_corr <<
" strip = " <<
strip;
146 if (doStripSwapping && (( me1a && zplus ) || ( me1b && !zplus ))) {
150 if (tbinbitsS0HS1) result.push_back(
CSCComparatorDigi(strip+1, 0, tbinbitsS0HS1));
151 if (tbinbitsS0HS0) result.push_back(
CSCComparatorDigi(strip+1, 1, tbinbitsS0HS0));
156 if (tbinbitsS1HS0) result.push_back(
CSCComparatorDigi(strip+1, 0, tbinbitsS1HS0));
157 if (tbinbitsS1HS1) result.push_back(
CSCComparatorDigi(strip+1, 1, tbinbitsS1HS1));
170 std::vector<CSCComparatorDigi>
result;
171 assert(layer>0 && layer<= 6);
173 for(
int cfeb = 0; cfeb <
ncfebs_; ++cfeb)
175 std::vector<CSCComparatorDigi> oneCfebDigi =
comparatorDigis(layer,cfeb);
176 result.insert(result.end(), oneCfebDigi.begin(), oneCfebDigi.end());
188 int cfeb = (strip-1)/16;
189 int distrip = ((strip-1)%16) / 2;
190 assert(distrip < 8 && cfeb < 6 && halfStrip < 161);
193 for(std::vector<int>::const_iterator tbinItr = timeBinsOn.begin();
194 tbinItr != timeBinsOn.end(); ++tbinItr)
197 if(tbin >= 0 && tbin <
ntbins_-2) {
215 for(
int cfeb = 0; cfeb <
ncfebs_; ++cfeb)
217 for(
int tbin = 0; tbin <
ntbins_; ++tbin)
219 for(
int layer = 1; layer <= 6; ++layer)
223 bool wordIsGood = (word.
tbin_ == tbin) && (word.
cfeb_ == cfeb);
224 result = result && wordIsGood;
225 if(!wordIsGood &&
debug)
227 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"Bad CLCT data in layer " << layer
228 <<
" expect CFEB " << cfeb <<
" tbin " << tbin;
229 LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
" See " << word.
cfeb_ <<
" "
235 if(!result)
LogTrace(
"CSCCLCTData|CSCRawToDigi") <<
"++ Bad CLCT Data ++ ";
258 clctData.
add(comparatorDigi1,1);
259 clctData.
add(comparatorDigi2,4);
260 clctData.
add(comparatorDigi3,6);
270 assert(digis1.size() == 1);
271 assert(digis2.size() == 1);
272 assert(digis3.size() == 1);
274 assert(digis1[0].getStrip() == 1);
275 assert(digis1[0].getComparator() == 0);
276 assert(digis1[0].getTimeBin() == 4);
278 assert(digis2[0].getStrip() == 39);
279 assert(digis2[0].getComparator() == 1);
280 assert(digis2[0].getTimeBin() == 5);
282 assert(digis3[0].getStrip() == 80);
283 assert(digis3[0].getComparator() == 1);
284 assert(digis3[0].getTimeBin() == 6);
int getStrip() const
Get the strip number.
void set(int distrip, bool value)
@ not right! doesn't set zero
CSCCLCTDataWord & dataWord(int iline) const
int getComparator() const
Get Comparator readings.
unsigned short theData[5 *6 *32]
bool bitValue(int cfeb, int tbin, int layer, int distrip)
std::vector< int > getTimeBinsOn() const
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.