CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCTMBHeader2020_GEM.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 = 0x601;
20  bits.nTBins = 12;
21  bits.nCFEBs = 7;
22 }
23 
24 CSCTMBHeader2020_GEM::CSCTMBHeader2020_GEM(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_GEM::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_GEM::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  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
171 }
172 
174  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
175 }
176 
178  unsigned halfStrip = digi.getKeyStrip();
179  unsigned pattern = digi.getRun3Pattern();
180  bits.clct0_valid = digi.isValid();
181  bits.clct0_quality = digi.getQuality();
182  bits.clct0_shape = pattern;
183  // first 7 bits of halfstrip
184  bits.clct0_key_low = halfStrip & (0x7F);
185  // most-significant (8th) bit
186  bits.clct0_key_high = (halfStrip >> 7) & (0x1);
187  bits.clct_bxn = digi.getBX();
188  bits.bxnPreTrigger = digi.getFullBX();
189  bits.clct0_comparator_code = digi.getCompCode();
190  bits.clct0_xky = (digi.getEighthStripBit() & 0x1) + ((digi.getQuartStripBit() & 0x1) << 1);
191  bits.clct0_LR_bend = digi.getBend();
192  bits.clct0_slope = digi.getSlope();
193 }
194 
196  unsigned halfStrip = digi.getKeyStrip();
197  unsigned pattern = digi.getRun3Pattern();
198  bits.clct1_valid = digi.isValid();
199  bits.clct1_quality = digi.getQuality();
200  bits.clct1_shape = pattern;
201  // first 7 bits of halfstrip
202  bits.clct1_key_low = halfStrip & (0x7F);
203  // most-significant (8th) bit
204  bits.clct1_key_high = (halfStrip >> 7) & (0x1);
205  // There is just one BX field common for CLCT0 and CLCT1 (since both
206  // are latched at the same BX); set it in addCLCT0().
207  bits.bxnPreTrigger = digi.getFullBX();
208  bits.clct1_comparator_code = digi.getCompCode();
209  bits.clct1_xky = (digi.getEighthStripBit() & 0x1) + ((digi.getQuartStripBit() & 0x1) << 1);
210  bits.clct1_LR_bend = digi.getBend();
211  bits.clct1_slope = digi.getSlope();
212 }
213 
215  bits.MPC_Muon0_lct_vpf = digi.isValid();
216  bits.MPC_Muon0_alct_key_wire = digi.getKeyWG();
217  bits.MPC_Muon0_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
218  bits.MPC_Muon0_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
219  bits.MPC_Muon0_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
220  bits.MPC_Muon0_lct_quality = digi.getQuality() & 0x7;
221 
222  // To restore 5-bits Run3 CLCT Pattern ID first assume and set pattern ID = LCT0 Run3 pattern
223  uint16_t run3_pattern = digi.getRun3Pattern();
224  bits.MPC_Muon_clct_pattern_low = run3_pattern & 0xF;
225  bits.MPC_Muon_clct_pattern_bit5 = (run3_pattern >> 4) & 0x1;
226  bits.MPC_Muon0_clct_bend_low = digi.getSlope() & 0x7;
227  bits.MPC_Muon0_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
228  bits.MPC_Muon0_clct_LR = digi.getBend() & 0x1;
229  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
230  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
231  bits.MPC_Muon_alct_bxn = digi.getBX();
232  bits.MPC_Muon0_clct_bx0 = digi.getBX0();
233 }
234 
236  bits.MPC_Muon1_lct_vpf = digi.isValid();
237  bits.MPC_Muon1_alct_key_wire = digi.getKeyWG();
238  bits.MPC_Muon1_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
239  bits.MPC_Muon1_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
240  bits.MPC_Muon1_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
241  bits.MPC_Muon1_lct_quality = digi.getQuality() & 0x7;
242 
243  // To restore 5-bits Run3 CLCT Pattern ID assume that LCT0 pattern ID is already processed
244  // and combine LCT1 Run3 pattern to set final 5-bit pattern ID
245  if (digi.isValid()) {
246  uint16_t clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
247  uint16_t run3_pattern = digi.getRun3Pattern();
248  clct_pattern_id = (clct_pattern_id + (run3_pattern + 1) * 5) % 30;
249  bits.MPC_Muon_clct_pattern_low = clct_pattern_id & 0xF;
250  bits.MPC_Muon_clct_pattern_bit5 = (clct_pattern_id >> 4) & 0x1;
251  }
252  bits.MPC_Muon1_clct_bend_low = digi.getSlope() & 0x7;
253  bits.MPC_Muon1_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
254  bits.MPC_Muon1_clct_LR = digi.getBend() & 0x1;
255  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
256  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
257  bits.MPC_Muon_alct_bxn = digi.getBX();
258  bits.MPC_Muon1_clct_bx0 = digi.getBX0();
259 }
260 
262  uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
263  bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
264  bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
265 }
266 
267 void CSCTMBHeader2020_GEM::print(std::ostream& os) const {
268  os << "...............(O)TMB2020 ME11 GEM/CCLUT/HMT Header.................."
269  << "\n";
270  os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
271  os << std::hex << "FW revision: 0x" << bits.firmRevCode << "\n";
272  os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
273  os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
274  os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
275  os << "trigSourceVect = " << bits.trigSourceVect << ", run3_trig_df = " << bits.run3_trig_df
276  << ", gem_enable = " << bits.gem_enable << ", gem_csc_bend_enable = " << bits.gem_csc_bend_enable
277  << ", activeCFEBs = 0x" << std::hex << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x"
278  << std::hex << (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
279  os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
280  os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
281 
282  os << "readoutCounter: " << std::dec << bits.readoutCounter << ", buf_q_ovf: " << bits.stackOvf
283  << ", sync_err: " << bits.syncError << ", has_buf: " << bits.hasBuf << ", buf_stalled: " << bits.bufFull << "\n";
284  os << "r_wr_buf_adr: 0x" << std::hex << bits.r_wr_buf_adr << ", r_wr_buf_ready: " << bits.r_wr_buf_ready
285  << ", wr_buf_ready: " << bits.wr_buf_ready << ", buf_q_full: " << bits.buf_q_full
286  << ", buf_q_empty: " << bits.buf_q_empty << ",\nr_buf_fence_dist: 0x" << bits.r_buf_fence_dist
287  << ", buf_q_ovf_err: " << bits.buf_q_ovf_err << ", buf_q_udf_err: " << bits.buf_q_udf_err
288  << ", buf_q_adr_err: " << bits.buf_q_adr_err << ", buf_stalled: " << bits.buf_stalled << ",\nbuf_fence_cnt: 0x"
289  << bits.buf_fence_cnt << ", reverse_hs_csc: " << bits.reverse_hs_csc
290  << ", reverse_hs_me1a: " << bits.reverse_hs_me1a << ", reverse_hs_me1b: " << bits.reverse_hs_me1b << std::dec
291  << "\n";
292  os << "CLCT Words:\n"
293  << " bits.clct0_valid = " << bits.clct0_valid << " bits.clct0_shape = " << bits.clct0_shape
294  << " bits.clct0_quality = " << bits.clct0_quality
295  << " halfstrip = " << (bits.clct0_key_low + (bits.clct0_key_high << 7)) << "\n";
296  os << " bits.clct0_xky = " << bits.clct0_xky << " bits.clct0_comparator_code = " << bits.clct0_comparator_code
297  << " bits.clct0_LR_bend = " << bits.clct0_LR_bend << " bits.clct0_slope = " << bits.clct0_slope << "\n";
298 
299  os << " bits.clct1_valid = " << bits.clct1_valid << " bits.clct1_shape = " << bits.clct1_shape
300  << " bits.clct1_quality = " << bits.clct1_quality
301  << " halfstrip = " << (bits.clct1_key_low + (bits.clct1_key_high << 7)) << "\n";
302  os << " bits.clct1_xky = " << bits.clct1_xky << " bits.clct1_comparator_code = " << bits.clct1_comparator_code
303  << " bits.clct1_LR_bend = " << bits.clct1_LR_bend << " bits.clct1_slope = " << bits.clct1_slope << "\n";
304 
305  os << "MPC Words:\n"
306  << " LCT0 valid = " << bits.MPC_Muon0_lct_vpf << " key WG = " << bits.MPC_Muon0_alct_key_wire
307  << " key halfstrip = " << bits.MPC_Muon0_clct_key_halfstrip
308  << " 1/4strip flag = " << bits.MPC_Muon0_clct_QuarterStrip
309  << " 1/8strip flag = " << bits.MPC_Muon0_clct_EighthStrip << "\n"
310  << " quality = " << bits.MPC_Muon0_lct_quality
311  << " slope/bend = " << ((bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3))
312  << " L/R bend = " << bits.MPC_Muon0_clct_LR << "\n";
313 
314  os << " LCT1 valid = " << bits.MPC_Muon1_lct_vpf << " key WG = " << bits.MPC_Muon1_alct_key_wire
315  << " key halfstrip = " << bits.MPC_Muon1_clct_key_halfstrip
316  << " 1/4strip flag = " << bits.MPC_Muon1_clct_QuarterStrip
317  << " 1/8strip flag = " << bits.MPC_Muon1_clct_EighthStrip << "\n"
318  << " quality = " << bits.MPC_Muon1_lct_quality
319  << " slope/bend = " << ((bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3))
320  << " L/R bend = " << bits.MPC_Muon1_clct_LR << "\n";
321 
322  os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
323  << " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << "\n";
324 
325  // os << "..................CLCT....................." << "\n";
326  os << "GEM Data:\n"
327  << " gem_enabled_fibers = 0x" << std::hex << gem_enabled_fibers() << std::dec
328  << " gem_fifo_tbins = " << gem_fifo_tbins() << " gem_fifo_pretrig = " << gem_fifo_pretrig()
329  << " gem_zero_suppress = " << gem_zero_suppress() << " gem_csc_bend_enable = " << bits.gem_csc_bend_enable
330  << " gem_sync_dataword = 0x" << std::hex << gem_sync_dataword() << " gem_timing_dataword = 0x" << std::hex
331  << gem_timing_dataword() << std::dec << "\n";
332  os << " gem num_copad: " << bits.num_copad << ", gem_delay: " << bits.gem_delay
333  << ", gem_clct_win: " << bits.gem_clct_win << ", alct_gem_win: " << bits.alct_gem_win << "\n";
334 }
uint16_t getRun3Pattern() const
return pattern
Definition: CSCCLCTDigi.h:68
uint16_t getSlope() const
return the slope
uint16_t getBend() const
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const override
returns CorrelatedLCT digis
uint16_t gem_enabled_fibers() const override
unsigned short int sizeInWords() const override
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
unsigned l1a() const
Definition: CSCDMBHeader.h:39
uint16_t getBX() const
return BX
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:123
uint16_t gem_sync_dataword() const override
bool getQuartStripBit() const
get single quart strip bit
void setHMT(const uint16_t h)
set high-multiplicity bits
uint16_t getBend() const
Definition: CSCCLCTDigi.h:93
void addALCT1(const CSCALCTDigi &digi) override
CSCShowerDigi showerDigi(uint32_t idlayer) const override
returns HMT Shower digi
static const double slope[3]
void addALCT0(const CSCALCTDigi &digi) override
struct CSCTMBHeader2020_GEM::@487 bits
tuple result
Definition: mps_fire.py:311
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:107
uint16_t bitsInTime() const
Definition: CSCShowerDigi.h:32
void setEventInformation(const CSCDMBHeader &dmbHeader) override
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi) override
uint16_t getKeyWG() const
return the key wire group. counts from 0.
void addCLCT0(const CSCCLCTDigi &digi) override
for data packing
void addCLCT1(const CSCCLCTDigi &digi) override
bool getEighthStripBit() const
get single eighth strip bit
Definition: CSCCLCTDigi.h:114
uint16_t gem_zero_suppress() const override
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
uint16_t bitsOutOfTime() const
Definition: CSCShowerDigi.h:33
bool getEighthStripBit() const
get single eighth strip bit
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi) override
uint16_t getBX0() const
uint16_t getStrip(uint16_t n=2) const
return the key halfstrip from 0,159
const std::vector< std::pair< unsigned, unsigned > > run3_pattern_lookup_tbl
uint16_t getRun3Pattern() const
return the Run-3 pattern ID
void print(std::ostream &os) const override
unsigned bxn() const
Definition: CSCDMBHeader.h:37
const unsigned run2_pattern_lookup_tbl[2][16]
pattern IDs 30,31 are reserved
uint16_t getSlope() const
return the slope
Definition: CSCCLCTDigi.h:74
uint16_t getQuality() const
return the Quality
bool isValid() const
return valid pattern bit
unsigned dmbID() const
Definition: CSCDMBHeader.h:36
uint16_t gem_fifo_tbins() const override
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer) override
returns CLCT digis
uint16_t gem_fifo_pretrig() const override
uint16_t gem_timing_dataword() const override
unsigned short * data() override
returns the first data word
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
void addShower(const CSCShowerDigi &digi) override
int16_t getCompCode() const
Definition: CSCCLCTDigi.h:171
bool getQuartStripBit() const
get single quart strip bit
Definition: CSCCLCTDigi.h:108