CMS 3D CMS Logo

CSCTMBHeader2020_CCLUT.cc
Go to the documentation of this file.
4 
5 const std::vector<std::pair<unsigned, unsigned> >
6  run3_pattern_lookup_tbl = {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4},
7  {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 0}, {1, 1}, {1, 2}, {1, 3},
8  {1, 4}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {3, 0}, {3, 1}, {3, 2},
9  {3, 3}, {3, 4}, {4, 0}, {4, 1}, {4, 2}, {4, 3}, {4, 4}};
10 
11 const unsigned run2_pattern_lookup_tbl[2][16] = {{10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2},
12  {10, 10, 10, 9, 9, 9, 7, 7, 7, 5, 5, 5, 3, 3, 3, 3}};
13 
15  bzero(data(), sizeInWords() * 2);
16  bits.nHeaderFrames = 42;
17  bits.e0bline = 0x6E0B;
18  bits.b0cline = 0xDB0C;
19  bits.firmRevCode = 0x401;
20  bits.nTBins = 12;
21  bits.nCFEBs = 7;
22 }
23 
24 CSCTMBHeader2020_CCLUT::CSCTMBHeader2020_CCLUT(const unsigned short* buf) { memcpy(data(), buf, sizeInWords() * 2); }
25 
27  bits.cscID = dmbHeader.dmbID();
28  bits.l1aNumber = dmbHeader.l1a();
29  bits.bxnCount = dmbHeader.bxn();
30 }
31 
33 std::vector<CSCCLCTDigi> CSCTMBHeader2020_CCLUT::CLCTDigis(uint32_t idlayer) {
34  std::vector<CSCCLCTDigi> result;
35  unsigned halfstrip = bits.clct0_key_low + (bits.clct0_key_high << 7);
36  unsigned strip = halfstrip % 32;
37  // CLCT0 1/4 strip bit
38  bool quartstrip = (bits.clct0_xky >> 1) & 0x1;
39  // CLCT1 1/8 strip bit
40  bool eighthstrip = bits.clct0_xky & 0x1;
41  unsigned cfeb = halfstrip / 32;
42 
44  unsigned run3_pattern = bits.clct0_shape & 0x7; // 3-bit Run3 CLCT PatternID
45  unsigned bend = bits.clct0_LR_bend;
46  unsigned slope = bits.clct0_slope;
47  unsigned run2_pattern = run2_pattern_lookup_tbl[bend][slope];
48 
49  CSCCLCTDigi digi0(bits.clct0_valid,
50  bits.clct0_quality,
51  run2_pattern,
52  1,
53  bend,
54  strip,
55  cfeb,
56  bits.clct_bxn,
57  1,
58  bits.bxnPreTrigger,
59  bits.clct0_comparator_code,
61  quartstrip,
62  eighthstrip,
63  run3_pattern,
64  slope);
65 
66  halfstrip = bits.clct1_key_low + (bits.clct1_key_high << 7);
67  strip = halfstrip % 32;
68  // CLCT0 1/4 strip bit
69  quartstrip = (bits.clct1_xky >> 1) & 0x1;
70  // CLCT1 1/8 strip bit
71  eighthstrip = bits.clct1_xky & 0x1;
72  cfeb = halfstrip / 32;
73 
74  // CLCT LR bend and slope are from dedicated header fields
75  run3_pattern = bits.clct1_shape & 0x7; // 3-bit Run3 CLCT PatternID
76  bend = bits.clct1_LR_bend;
77  slope = bits.clct1_slope;
78  run2_pattern = run2_pattern_lookup_tbl[bend][slope];
79 
80  CSCCLCTDigi digi1(bits.clct1_valid,
81  bits.clct1_quality,
82  run2_pattern,
83  1,
84  bend,
85  strip,
86  cfeb,
87  bits.clct_bxn,
88  2,
89  bits.bxnPreTrigger,
90  bits.clct1_comparator_code,
92  quartstrip,
93  eighthstrip,
94  run3_pattern,
95  slope);
96 
97  result.push_back(digi0);
98  result.push_back(digi1);
99  return result;
100 }
101 
103 std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2020_CCLUT::CorrelatedLCTDigis(uint32_t idlayer) const {
104  std::vector<CSCCorrelatedLCTDigi> result;
106  unsigned strip = bits.MPC_Muon0_clct_key_halfstrip; //this goes from 0-223
107  unsigned slope = (bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3);
108  unsigned hmt = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger
109  unsigned clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
110 
111  std::pair<unsigned, unsigned> run3_pattern_pair = run3_pattern_lookup_tbl[clct_pattern_id % 30];
112  unsigned run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon0_clct_LR][slope];
113  unsigned run3_pattern = run3_pattern_pair.second & 0x7;
114 
115  CSCCorrelatedLCTDigi digi(1,
116  bits.MPC_Muon0_lct_vpf,
117  bits.MPC_Muon0_lct_quality,
118  bits.MPC_Muon0_alct_key_wire,
119  strip,
120  run2_pattern,
121  bits.MPC_Muon0_clct_LR,
122  bits.MPC_Muon_alct_bxn,
123  0,
124  bits.MPC_Muon0_clct_bx0,
125  0,
126  0,
128  bits.MPC_Muon0_clct_QuarterStrip,
129  bits.MPC_Muon0_clct_EighthStrip,
130  run3_pattern,
131  slope);
132  digi.setHMT(hmt);
133  result.push_back(digi);
135  strip = bits.MPC_Muon1_clct_key_halfstrip; //this goes from 0-223
136  slope = (bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3);
137  run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon1_clct_LR][slope];
138  run3_pattern = run3_pattern_pair.first & 0x7;
139 
140  digi = CSCCorrelatedLCTDigi(2,
141  bits.MPC_Muon1_lct_vpf,
142  bits.MPC_Muon1_lct_quality,
143  bits.MPC_Muon1_alct_key_wire,
144  strip,
145  run2_pattern,
146  bits.MPC_Muon1_clct_LR,
147  bits.MPC_Muon_alct_bxn,
148  0,
149  bits.MPC_Muon1_clct_bx0,
150  0,
151  0,
153  bits.MPC_Muon1_clct_QuarterStrip,
154  bits.MPC_Muon1_clct_EighthStrip,
155  run3_pattern,
156  slope);
157  digi.setHMT(hmt);
158  result.push_back(digi);
159  return result;
160 }
161 
163  unsigned hmt_bits = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger bits
164  uint16_t cscid = 0; // ??? What is 4-bits CSC Id in CSshowerDigi
165  CSCShowerDigi result(hmt_bits & 0x3, (hmt_bits >> 2) & 0x3, cscid); // 2-bits intime, 2-bits out of time
166  return result;
167 }
168 
170  uint16_t cscid = 0;
171  CSCShowerDigi result(bits.anode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
172  return result;
173 }
174 
176  uint16_t cscid = 0;
177  CSCShowerDigi result(bits.cathode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
178  return result;
179 }
180 
182  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
183 }
184 
186  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
187 }
188 
190  unsigned halfStrip = digi.getKeyStrip();
191  unsigned pattern = digi.getRun3Pattern();
192  bits.clct0_valid = digi.isValid();
193  bits.clct0_quality = digi.getQuality();
194  bits.clct0_shape = pattern;
195  // first 7 bits of halfstrip
196  bits.clct0_key_low = halfStrip & (0x7F);
197  // most-significant (8th) bit
198  bits.clct0_key_high = (halfStrip >> 7) & (0x1);
199  bits.clct_bxn = digi.getBX();
200  bits.bxnPreTrigger = digi.getFullBX();
201  bits.clct0_comparator_code = digi.getCompCode();
202  bits.clct0_xky = (digi.getEighthStripBit() & 0x1) + ((digi.getQuartStripBit() & 0x1) << 1);
203  bits.clct0_LR_bend = digi.getBend();
204  bits.clct0_slope = digi.getSlope();
205 }
206 
208  unsigned halfStrip = digi.getKeyStrip();
209  unsigned pattern = digi.getRun3Pattern();
210  bits.clct1_valid = digi.isValid();
211  bits.clct1_quality = digi.getQuality();
212  bits.clct1_shape = pattern;
213  // first 7 bits of halfstrip
214  bits.clct1_key_low = halfStrip & (0x7F);
215  // most-significant (8th) bit
216  bits.clct1_key_high = (halfStrip >> 7) & (0x1);
217  // There is just one BX field common for CLCT0 and CLCT1 (since both
218  // are latched at the same BX); set it in addCLCT0().
219  bits.bxnPreTrigger = digi.getFullBX();
220  bits.clct1_comparator_code = digi.getCompCode();
221  bits.clct1_xky = (digi.getEighthStripBit() & 0x1) + ((digi.getQuartStripBit() & 0x1) << 1);
222  bits.clct1_LR_bend = digi.getBend();
223  bits.clct1_slope = digi.getSlope();
224 }
225 
227  bits.MPC_Muon0_lct_vpf = digi.isValid();
228  bits.MPC_Muon0_alct_key_wire = digi.getKeyWG();
229  bits.MPC_Muon0_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
230  bits.MPC_Muon0_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
231  bits.MPC_Muon0_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
232  bits.MPC_Muon0_lct_quality = digi.getQuality() & 0x7;
233 
234  // To restore 5-bits Run3 CLCT Pattern ID first assume and set pattern ID = LCT0 Run3 pattern
235  uint16_t run3_pattern = digi.getRun3Pattern();
236  bits.MPC_Muon_clct_pattern_low = run3_pattern & 0xF;
237  bits.MPC_Muon_clct_pattern_bit5 = (run3_pattern >> 4) & 0x1;
238  bits.MPC_Muon0_clct_bend_low = digi.getSlope() & 0x7;
239  bits.MPC_Muon0_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
240  bits.MPC_Muon0_clct_LR = digi.getBend() & 0x1;
241  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
242  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
243  bits.MPC_Muon_alct_bxn = digi.getBX();
244  bits.MPC_Muon0_clct_bx0 = digi.getBX0();
245 }
246 
248  bits.MPC_Muon1_lct_vpf = digi.isValid();
249  bits.MPC_Muon1_alct_key_wire = digi.getKeyWG();
250  bits.MPC_Muon1_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
251  bits.MPC_Muon1_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
252  bits.MPC_Muon1_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
253  bits.MPC_Muon1_lct_quality = digi.getQuality() & 0x7;
254 
255  // To restore 5-bits Run3 CLCT Pattern ID assume that LCT0 pattern ID is already processed
256  // and combine LCT1 Run3 pattern to set final 5-bit pattern ID
257  if (digi.isValid()) {
258  uint16_t clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
259  uint16_t run3_pattern = digi.getRun3Pattern();
260  clct_pattern_id = (clct_pattern_id + (run3_pattern + 1) * 5) % 30;
261  bits.MPC_Muon_clct_pattern_low = clct_pattern_id & 0xF;
262  bits.MPC_Muon_clct_pattern_bit5 = (clct_pattern_id >> 4) & 0x1;
263  }
264  bits.MPC_Muon1_clct_bend_low = digi.getSlope() & 0x7;
265  bits.MPC_Muon1_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
266  bits.MPC_Muon1_clct_LR = digi.getBend() & 0x1;
267  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
268  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
269  bits.MPC_Muon_alct_bxn = digi.getBX();
270  bits.MPC_Muon1_clct_bx0 = digi.getBX0();
271 }
272 
274  uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
275  bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
276  bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
277 }
278 
280  uint16_t hmt_bits = digi.bitsInTime() & 0x3;
281  bits.anode_hmt = hmt_bits;
282 }
283 
285  uint16_t hmt_bits = digi.bitsInTime() & 0x3;
286  bits.cathode_hmt = hmt_bits;
287 }
288 
289 void CSCTMBHeader2020_CCLUT::print(std::ostream& os) const {
290  os << "...............(O)TMB2020 CCLUT/HMT Header.................."
291  << "\n";
292  os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
293  os << std::hex << "FW revision: 0x" << bits.firmRevCode << "\n";
294  os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
295  os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
296  os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
297  os << "trigSourceVect = " << bits.trigSourceVect << ", run3_trig_df = " << bits.run3_trig_df << ", activeCFEBs = 0x"
298  << std::hex << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x" << std::hex
299  << (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
300  os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
301  os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
302 
303  os << "readoutCounter: " << std::dec << bits.readoutCounter << ", buf_q_ovf: " << bits.stackOvf
304  << ", sync_err: " << bits.syncError << ", has_buf: " << bits.hasBuf << ", buf_stalled: " << bits.bufFull << "\n";
305  os << "r_wr_buf_adr: 0x" << std::hex << bits.r_wr_buf_adr << ", r_wr_buf_ready: " << bits.r_wr_buf_ready
306  << ", wr_buf_ready: " << bits.wr_buf_ready << ", buf_q_full: " << bits.buf_q_full
307  << ", buf_q_empty: " << bits.buf_q_empty << ",\nr_buf_fence_dist: 0x" << bits.r_buf_fence_dist
308  << ", buf_q_ovf_err: " << bits.buf_q_ovf_err << ", buf_q_udf_err: " << bits.buf_q_udf_err
309  << ", buf_q_adr_err: " << bits.buf_q_adr_err << ", buf_stalled: " << bits.buf_stalled << ",\nbuf_fence_cnt: 0x"
310  << bits.buf_fence_cnt << ", reverse_hs_csc: " << bits.reverse_hs_csc
311  << ", reverse_hs_me1a: " << bits.reverse_hs_me1a << ", reverse_hs_me1b: " << bits.reverse_hs_me1b << "\n";
312  os << "CLCT Words:\n"
313  << " bits.clct0_valid = " << bits.clct0_valid << " bits.clct0_shape = " << bits.clct0_shape
314  << " bits.clct0_quality = " << bits.clct0_quality
315  << " halfstrip = " << (bits.clct0_key_low + (bits.clct0_key_high << 7)) << "\n";
316  os << " bits.clct0_xky = " << bits.clct0_xky << " bits.clct0_comparator_code = " << bits.clct0_comparator_code
317  << " bits.clct0_LR_bend = " << bits.clct0_LR_bend << " bits.clct0_slope = " << bits.clct0_slope << "\n";
318 
319  os << " bits.clct1_valid = " << bits.clct1_valid << " bits.clct1_shape = " << bits.clct1_shape
320  << " bits.clct1_quality = " << bits.clct1_quality
321  << " halfstrip = " << (bits.clct1_key_low + (bits.clct1_key_high << 7)) << "\n";
322  os << " bits.clct1_xky = " << bits.clct1_xky << " bits.clct1_comparator_code = " << bits.clct1_comparator_code
323  << " bits.clct1_LR_bend = " << bits.clct1_LR_bend << " bits.clct1_slope = " << bits.clct1_slope << "\n";
324 
325  os << "MPC Words:\n"
326  << " LCT0 valid = " << bits.MPC_Muon0_lct_vpf << " key WG = " << bits.MPC_Muon0_alct_key_wire
327  << " key halfstrip = " << bits.MPC_Muon0_clct_key_halfstrip
328  << " 1/4strip flag = " << bits.MPC_Muon0_clct_QuarterStrip
329  << " 1/8strip flag = " << bits.MPC_Muon0_clct_EighthStrip << "\n"
330  << " quality = " << bits.MPC_Muon0_lct_quality
331  << " slope/bend = " << ((bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3))
332  << " L/R bend = " << bits.MPC_Muon0_clct_LR << "\n";
333 
334  os << " LCT1 valid = " << bits.MPC_Muon1_lct_vpf << " key WG = " << bits.MPC_Muon1_alct_key_wire
335  << " key halfstrip = " << bits.MPC_Muon1_clct_key_halfstrip
336  << " 1/4strip flag = " << bits.MPC_Muon1_clct_QuarterStrip
337  << " 1/8strip flag = " << bits.MPC_Muon1_clct_EighthStrip << "\n"
338  << " quality = " << bits.MPC_Muon1_lct_quality
339  << " slope/bend = " << ((bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3))
340  << " L/R bend = " << bits.MPC_Muon1_clct_LR << "\n";
341 
342  os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
343  << " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << ", alctHMT = " << bits.anode_hmt
344  << ", clctHMT = " << bits.cathode_hmt << "\n";
345 }
unsigned bxn() const
Definition: CSCDMBHeader.h:37
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi) override
void setHMT(const uint16_t h)
set high-multiplicity bits
uint16_t getSlope() const
return the slope
static const double slope[3]
void addShower(const CSCShowerDigi &digi) override
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:107
bool getEighthStripBit() const
get single eighth strip bit
Definition: CSCCLCTDigi.h:114
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer) override
returns CLCT digis
uint16_t bitsOutOfTime() const
Definition: CSCShowerDigi.h:33
int16_t getCompCode() const
Definition: CSCCLCTDigi.h:171
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const override
returns CorrelatedLCT digis
void addCathodeShower(const CSCShowerDigi &digi) override
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi) override
void setEventInformation(const CSCDMBHeader &dmbHeader) override
void print(std::ostream &os) const override
void addALCT0(const CSCALCTDigi &digi) override
uint16_t getBX() const
return BX
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
bool isValid() const
return valid pattern bit
unsigned short int sizeInWords() const override
void addALCT1(const CSCALCTDigi &digi) override
bool getEighthStripBit() const
get single eighth strip bit
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
unsigned l1a() const
Definition: CSCDMBHeader.h:39
const std::vector< std::pair< unsigned, unsigned > > run3_pattern_lookup_tbl
uint16_t getQuality() const
return the Quality
unsigned dmbID() const
Definition: CSCDMBHeader.h:36
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
CSCShowerDigi anodeShowerDigi(uint32_t idlayer) const override
returns anode HMT Shower digi
const unsigned run2_pattern_lookup_tbl[2][16]
pattern IDs 30,31 are reserved
bool getQuartStripBit() const
get single quart strip bit
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:123
uint16_t getKeyWG() const
return the key wire group. counts from 0.
void addAnodeShower(const CSCShowerDigi &digi) override
uint16_t bitsInTime() const
Definition: CSCShowerDigi.h:32
struct CSCTMBHeader2020_CCLUT::@496 bits
CSCShowerDigi cathodeShowerDigi(uint32_t idlayer) const override
returns cathode HMT Shower digi
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68
void addCLCT0(const CSCCLCTDigi &digi) override
for data packing
void addCLCT1(const CSCCLCTDigi &digi) override
uint16_t getRun3Pattern() const
return the Run-3 pattern ID
unsigned short * data() override
returns the first data word
CSCShowerDigi showerDigi(uint32_t idlayer) const override
returns lct HMT Shower digi