CMS 3D CMS Logo

CSCTMBHeader2020_TMB.cc
Go to the documentation of this file.
4 
5 /* /// commented to prevent compilation warning
7 
8 const std::vector<std::pair<unsigned, unsigned> >
9  run3_pattern_lookup_tbl = {{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, /// Valid LCT0, invalid LCT1 combination. Check LCT1 vpf
10  {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {1, 0}, {1, 1}, {1, 2}, {1, 3},
11  {1, 4}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {3, 0}, {3, 1}, {3, 2},
12  {3, 3}, {3, 4}, {4, 0}, {4, 1}, {4, 2}, {4, 3}, {4, 4}}; /// pattern IDs 30,31 are reserved
13 
14 const unsigned run2_pattern_lookup_tbl[2][16] = {{10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 2},
15  {10, 10, 10, 9, 9, 9, 7, 7, 7, 5, 5, 5, 3, 3, 3, 3}};
16 */
17 
19  bzero(data(), sizeInWords() * 2);
20  bits.nHeaderFrames = 42;
21  bits.e0bline = 0x6E0B;
22  bits.b0cline = 0xDB0C;
23  bits.firmRevCode = 0x801;
24  bits.nTBins = 12;
25  bits.nCFEBs = 5;
26 }
27 
28 CSCTMBHeader2020_TMB::CSCTMBHeader2020_TMB(const unsigned short* buf) { memcpy(data(), buf, sizeInWords() * 2); }
29 
31  bits.cscID = dmbHeader.dmbID();
32  bits.l1aNumber = dmbHeader.l1a();
33  bits.bxnCount = dmbHeader.bxn();
34 }
35 
37 std::vector<CSCCLCTDigi> CSCTMBHeader2020_TMB::CLCTDigis(uint32_t idlayer) {
38  std::vector<CSCCLCTDigi> result;
39  unsigned halfstrip = bits.clct0_key_low + (bits.clct0_key_high << 7);
40  unsigned strip = halfstrip % 32;
41  unsigned cfeb = halfstrip / 32;
42  unsigned pattern = bits.clct0_shape;
43  unsigned bend = pattern & 0x1;
44 
45  CSCCLCTDigi digi0(
46  bits.clct0_valid, bits.clct0_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 1, bits.bxnPreTrigger);
47 
48  halfstrip = bits.clct1_key_low + (bits.clct1_key_high << 7);
49  strip = halfstrip % 32;
50  cfeb = halfstrip / 32;
51  pattern = bits.clct1_shape;
52  bend = pattern & 0x1;
53 
54  CSCCLCTDigi digi1(
55  bits.clct1_valid, bits.clct1_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 2, bits.bxnPreTrigger);
56  result.push_back(digi0);
57  result.push_back(digi1);
58  return result;
59 }
60 
62 std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2020_TMB::CorrelatedLCTDigis(uint32_t idlayer) const {
63  std::vector<CSCCorrelatedLCTDigi> result;
64  unsigned strip = bits.MPC_Muon0_clct_key_halfstrip; //this goes from 0-223
65 
68  unsigned slope = 0;
69  unsigned hmt = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger
70  /* /// Run3 format, when full-featured Run3 copper TMB firmware will be available
71  unsigned clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
72  std::pair<unsigned, unsigned> run3_pattern_pair = run3_pattern_lookup_tbl[clct_pattern_id % 30];
73  unsigned run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon0_clct_LR][slope];
74  unsigned run3_pattern = run3_pattern_pair.second & 0x7;
75  */
77  unsigned run3_pattern = 0;
79  unsigned run2_pattern = (bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3);
80 
81  CSCCorrelatedLCTDigi digi(1,
82  bits.MPC_Muon0_lct_vpf,
83  bits.MPC_Muon0_lct_quality,
84  bits.MPC_Muon0_alct_key_wire,
85  strip,
86  run2_pattern,
87  bits.MPC_Muon0_clct_LR,
88  bits.MPC_Muon_alct_bxn,
89  0,
90  bits.MPC_Muon0_clct_bx0,
91  0,
92  0,
94  false,
95  false,
96  run3_pattern,
97  slope);
98  digi.setHMT(hmt);
99  result.push_back(digi);
101  strip = bits.MPC_Muon1_clct_key_halfstrip; //this goes from 0-223
102  /* /// Run3 format, when full-featured Run3 copper TMB firmware will be available
103  slope = (bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3);
104  run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon1_clct_LR][slope];
105  run3_pattern = run3_pattern_pair.first & 0x7;
106  run2_pattern = (bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3);
107  */
109  run2_pattern = (bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3);
110  digi = CSCCorrelatedLCTDigi(2,
111  bits.MPC_Muon1_lct_vpf,
112  bits.MPC_Muon1_lct_quality,
113  bits.MPC_Muon1_alct_key_wire,
114  strip,
115  run2_pattern,
116  bits.MPC_Muon1_clct_LR,
117  bits.MPC_Muon_alct_bxn,
118  0,
119  bits.MPC_Muon1_clct_bx0,
120  0,
121  0,
123  false,
124  false,
125  run3_pattern,
126  slope);
127  digi.setHMT(hmt);
128  result.push_back(digi);
129  return result;
130 }
131 
133  unsigned hmt_bits = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger bits
134  uint16_t cscid = 0; // ??? What is 4-bits CSC Id in CSshowerDigi
135  CSCShowerDigi result(hmt_bits & 0x3, (hmt_bits >> 2) & 0x3, cscid); // 2-bits intime, 2-bits out of time
136  return result;
137 }
138 
140  uint16_t cscid = 0;
141  CSCShowerDigi result(bits.anode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
142  return result;
143 }
144 
146  uint16_t cscid = 0;
147  CSCShowerDigi result(bits.cathode_hmt & 0x3, 0, cscid); // 2-bits intime, no out of time
148  return result;
149 }
150 
152  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
153 }
154 
156  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
157 }
158 
160  unsigned halfStrip = digi.getKeyStrip();
161  unsigned pattern = digi.getPattern();
162  bits.clct0_valid = digi.isValid();
163  bits.clct0_quality = digi.getQuality();
164  bits.clct0_shape = pattern;
165  // first 7 bits of halfstrip
166  bits.clct0_key_low = halfStrip & (0x7F);
167  // most-significant (8th) bit
168  bits.clct0_key_high = (halfStrip >> 7) & (0x1);
169  bits.clct_bxn = digi.getBX();
170  bits.bxnPreTrigger = digi.getFullBX();
171 }
172 
174  unsigned halfStrip = digi.getKeyStrip();
175  unsigned pattern = digi.getPattern();
176  bits.clct1_valid = digi.isValid();
177  bits.clct1_quality = digi.getQuality();
178  bits.clct1_shape = pattern;
179  // first 7 bits of halfstrip
180  bits.clct1_key_low = halfStrip & (0x7F);
181  // most-significant (8th) bit
182  bits.clct1_key_high = (halfStrip >> 7) & (0x1);
183  // There is just one BX field common for CLCT0 and CLCT1 (since both
184  // are latched at the same BX); set it in addCLCT0().
185  bits.bxnPreTrigger = digi.getFullBX();
186 }
187 
189  bits.MPC_Muon0_lct_vpf = digi.isValid();
190  bits.MPC_Muon0_alct_key_wire = digi.getKeyWG();
191  bits.MPC_Muon0_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
193  /*
194  bits.MPC_Muon0_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
195  bits.MPC_Muon0_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
196  */
197  bits.MPC_Muon0_clct_QuarterStrip = 0;
198  bits.MPC_Muon0_clct_EighthStrip = 0;
199  bits.MPC_Muon0_lct_quality = digi.getQuality() & 0x7;
200 
202  /*
203  // To restore 5-bits Run3 CLCT Pattern ID first assume and set pattern ID = LCT0 Run3 pattern
204  uint16_t run3_pattern = digi.getRun3Pattern();
205  bits.MPC_Muon_clct_pattern_low = run3_pattern & 0xF;
206  bits.MPC_Muon_clct_pattern_bit5 = (run3_pattern >> 4) & 0x1;
207  */
208  bits.MPC_Muon_clct_pattern_low = 0;
209  bits.MPC_Muon_clct_pattern_bit5 = 0;
211  bits.MPC_Muon0_clct_bend_low = digi.getPattern() & 0x7;
212  bits.MPC_Muon0_clct_bend_bit4 = (digi.getPattern() >> 3) & 0x1;
213  bits.MPC_Muon0_clct_LR = digi.getBend() & 0x1;
214  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
215  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
216  bits.MPC_Muon_alct_bxn = digi.getBX();
217  bits.MPC_Muon0_clct_bx0 = digi.getBX0();
218 }
219 
221  bits.MPC_Muon1_lct_vpf = digi.isValid();
222  bits.MPC_Muon1_alct_key_wire = digi.getKeyWG();
223  bits.MPC_Muon1_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
225  /*
226  bits.MPC_Muon1_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
227  bits.MPC_Muon1_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
228  */
229  bits.MPC_Muon1_clct_QuarterStrip = 0;
230  bits.MPC_Muon1_clct_EighthStrip = 0;
231  bits.MPC_Muon1_lct_quality = digi.getQuality() & 0x7;
232 
234  /*
235  // To restore 5-bits Run3 CLCT Pattern ID assume that LCT0 pattern ID is already processed
236  // and combine LCT1 Run3 pattern to set final 5-bit pattern ID
237  if (digi.isValid()) {
238  uint16_t clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
239  uint16_t run3_pattern = digi.getRun3Pattern();
240  clct_pattern_id = (clct_pattern_id + (run3_pattern + 1) * 5) % 30;
241  bits.MPC_Muon_clct_pattern_low = clct_pattern_id & 0xF;
242  bits.MPC_Muon_clct_pattern_bit5 = (clct_pattern_id >> 4) & 0x1;
243  }
244  */
245  bits.MPC_Muon_clct_pattern_low = 0;
246  bits.MPC_Muon_clct_pattern_bit5 = 0;
248  bits.MPC_Muon1_clct_bend_low = digi.getPattern() & 0x7;
249  bits.MPC_Muon1_clct_bend_bit4 = (digi.getPattern() >> 3) & 0x1;
250  bits.MPC_Muon1_clct_LR = digi.getBend() & 0x1;
251  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
252  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
253  bits.MPC_Muon_alct_bxn = digi.getBX();
254  bits.MPC_Muon1_clct_bx0 = digi.getBX0();
255 }
256 
258  uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
259  bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
260  bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
261 }
262 
264  uint16_t hmt_bits = digi.bitsInTime() & 0x3;
265  bits.anode_hmt = hmt_bits;
266 }
267 
270  /* uint16_t hmt_bits = digi.bitsInTime() & 0x3;
271  bits.cathode_hmt = hmt_bits;
272  */
273  bits.cathode_hmt = 0;
274 }
275 
276 void CSCTMBHeader2020_TMB::print(std::ostream& os) const {
277  os << "...............(O)TMB2020 TMB Run3 Header.................."
278  << "\n";
279  os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
280  os << std::hex << "FW revision: 0x" << bits.firmRevCode << "\n";
281  os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
282  os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
283  os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
284  os << "trigSourceVect = " << bits.trigSourceVect << ", activeCFEBs = 0x" << std::hex
285  << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x" << std::hex
286  << (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
287  os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
288  os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
289 
290  os << "CLCT Words:\n"
291  << " bits.clct0_valid = " << bits.clct0_valid << " bits.clct0_shape = " << bits.clct0_shape
292  << " bits.clct0_quality = " << bits.clct0_quality
293  << " halfstrip = " << (bits.clct0_key_low + (bits.clct0_key_high << 7)) << "\n";
294 
295  os << " bits.clct1_valid = " << bits.clct1_valid << " bits.clct1_shape = " << bits.clct1_shape
296  << " bits.clct1_quality = " << bits.clct1_quality
297  << " halfstrip = " << (bits.clct1_key_low + (bits.clct1_key_high << 7)) << "\n";
298 
299  os << "MPC Words:\n"
300  << " LCT0 valid = " << bits.MPC_Muon0_lct_vpf << " key WG = " << bits.MPC_Muon0_alct_key_wire
301  << " key halfstrip = " << bits.MPC_Muon0_clct_key_halfstrip
302  << " 1/4strip flag = " << bits.MPC_Muon0_clct_QuarterStrip
303  << " 1/8strip flag = " << bits.MPC_Muon0_clct_EighthStrip << "\n"
304  << " quality = " << bits.MPC_Muon0_lct_quality
305  << " slope/bend = " << ((bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3))
306  << " L/R bend = " << bits.MPC_Muon0_clct_LR << "\n";
307 
308  os << " LCT1 valid = " << bits.MPC_Muon1_lct_vpf << " key WG = " << bits.MPC_Muon1_alct_key_wire
309  << " key halfstrip = " << bits.MPC_Muon1_clct_key_halfstrip
310  << " 1/4strip flag = " << bits.MPC_Muon1_clct_QuarterStrip
311  << " 1/8strip flag = " << bits.MPC_Muon1_clct_EighthStrip << "\n"
312  << " quality = " << bits.MPC_Muon1_lct_quality
313  << " slope/bend = " << ((bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3))
314  << " L/R bend = " << bits.MPC_Muon1_clct_LR << "\n";
315 
316  os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
317  << " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << ", alctHMT = " << bits.anode_hmt
318  << ", clctHMT = " << bits.cathode_hmt << "\n";
319 }
void addShower(const CSCShowerDigi &digi) override
unsigned bxn() const
Definition: CSCDMBHeader.h:37
CSCShowerDigi cathodeShowerDigi(uint32_t idlayer) const override
returns cathode HMT Shower digi
void addCathodeShower(const CSCShowerDigi &digi) override
void addALCT1(const CSCALCTDigi &digi) override
void setHMT(const uint16_t h)
set high-multiplicity bits
void addCLCT1(const CSCCLCTDigi &digi) override
uint16_t getPattern() const
return the Run-2 pattern ID
static const double slope[3]
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi) override
uint16_t getKeyStrip(const uint16_t n=2) const
Definition: CSCCLCTDigi.cc:107
void addALCT0(const CSCALCTDigi &digi) override
uint16_t bitsOutOfTime() const
Definition: CSCShowerDigi.h:33
void print(std::ostream &os) const override
struct CSCTMBHeader2020_TMB::@502 bits
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
uint16_t getBX() const
return BX
bool isValid() const
return valid pattern bit
bool isValid() const
check CLCT validity (1 - valid CLCT)
Definition: CSCCLCTDigi.h:50
unsigned l1a() const
Definition: CSCDMBHeader.h:39
unsigned short * data() override
returns the first data word
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 showerDigi(uint32_t idlayer) const override
returns lct HMT Shower digi
uint16_t getBX() const
return BX
Definition: CSCCLCTDigi.h:123
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
uint16_t getKeyWG() const
return the key wire group. counts from 0.
uint16_t bitsInTime() const
Definition: CSCShowerDigi.h:32
unsigned short int sizeInWords() const override
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi) override
CSCShowerDigi anodeShowerDigi(uint32_t idlayer) const override
returns anode HMT Shower digi
void setEventInformation(const CSCDMBHeader &dmbHeader) override
void addAnodeShower(const CSCShowerDigi &digi) override
void addCLCT0(const CSCCLCTDigi &digi) override
for data packing
std::vector< CSCCorrelatedLCTDigi > CorrelatedLCTDigis(uint32_t idlayer) const override
returns CorrelatedLCT digis
std::vector< CSCCLCTDigi > CLCTDigis(uint32_t idlayer) override
returns CLCT digis