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 = bits.cscID; // ??? What is 4-bits CSC Id in CSshowerDigi
135  //L1A_TMB_WINDOW is not included in below formula
136  //correct version: CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win + L1A_TMB_WINDOW/2;
137  // same for anode HMT and cathode HMT
138  uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win;
139  //LCTshower with showerType = 3. wireNHits is not avaiable
140  //TMB LCT shower is copied from ALCT shower
141  CSCShowerDigi result(hmt_bits & 0x3,
142  (hmt_bits >> 2) & 0x3,
143  cscid,
144  bx,
145  CSCShowerDigi::ShowerType::kLCTShower,
146  0,
147  0); // 2-bits intime, 2-bits out of time
148  return result;
149 }
150 
152  uint16_t cscid = bits.cscID;
153  uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win;
154  //ALCTshower with showerType = 1. wireNHits is not avaiable
156  bits.anode_hmt & 0x3, 0, cscid, bx, CSCShowerDigi::ShowerType::kALCTShower, 0, 0); // 2-bits intime, no out of time
157  return result;
158 }
159 
161  uint16_t cscid = bits.cscID;
162  uint16_t bx = CSCConstants::LCT_CENTRAL_BX - bits.pop_l1a_match_win;
163  //CLCTshower with showerType = 2. comparatorNhits is not avaiable for TMB yet
164  CSCShowerDigi result(bits.cathode_hmt & 0x3,
165  0,
166  cscid,
167  bx,
168  CSCShowerDigi::ShowerType::kCLCTShower,
169  0,
170  0); // 2-bits intime, no out of time
171  return result;
172 }
173 
175  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
176 }
177 
179  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
180 }
181 
183  unsigned halfStrip = digi.getKeyStrip();
184  unsigned pattern = digi.getPattern();
185  bits.clct0_valid = digi.isValid();
186  bits.clct0_quality = digi.getQuality();
187  bits.clct0_shape = pattern;
188  // first 7 bits of halfstrip
189  bits.clct0_key_low = halfStrip & (0x7F);
190  // most-significant (8th) bit
191  bits.clct0_key_high = (halfStrip >> 7) & (0x1);
192  bits.clct_bxn = digi.getBX();
193  bits.bxnPreTrigger = digi.getFullBX();
194 }
195 
197  unsigned halfStrip = digi.getKeyStrip();
198  unsigned pattern = digi.getPattern();
199  bits.clct1_valid = digi.isValid();
200  bits.clct1_quality = digi.getQuality();
201  bits.clct1_shape = pattern;
202  // first 7 bits of halfstrip
203  bits.clct1_key_low = halfStrip & (0x7F);
204  // most-significant (8th) bit
205  bits.clct1_key_high = (halfStrip >> 7) & (0x1);
206  // There is just one BX field common for CLCT0 and CLCT1 (since both
207  // are latched at the same BX); set it in addCLCT0().
208  bits.bxnPreTrigger = digi.getFullBX();
209 }
210 
212  bits.MPC_Muon0_lct_vpf = digi.isValid();
213  bits.MPC_Muon0_alct_key_wire = digi.getKeyWG();
214  bits.MPC_Muon0_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
216  /*
217  bits.MPC_Muon0_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
218  bits.MPC_Muon0_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
219  */
220  bits.MPC_Muon0_clct_QuarterStrip = 0;
221  bits.MPC_Muon0_clct_EighthStrip = 0;
222  bits.MPC_Muon0_lct_quality = digi.getQuality() & 0x7;
223 
225  /*
226  // To restore 5-bits Run3 CLCT Pattern ID first assume and set pattern ID = LCT0 Run3 pattern
227  uint16_t run3_pattern = digi.getRun3Pattern();
228  bits.MPC_Muon_clct_pattern_low = run3_pattern & 0xF;
229  bits.MPC_Muon_clct_pattern_bit5 = (run3_pattern >> 4) & 0x1;
230  */
231  bits.MPC_Muon_clct_pattern_low = 0;
232  bits.MPC_Muon_clct_pattern_bit5 = 0;
234  bits.MPC_Muon0_clct_bend_low = digi.getPattern() & 0x7;
235  bits.MPC_Muon0_clct_bend_bit4 = (digi.getPattern() >> 3) & 0x1;
236  bits.MPC_Muon0_clct_LR = digi.getBend() & 0x1;
237  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
238  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
239  bits.MPC_Muon_alct_bxn = digi.getBX();
240  bits.MPC_Muon0_clct_bx0 = digi.getBX0();
241 }
242 
244  bits.MPC_Muon1_lct_vpf = digi.isValid();
245  bits.MPC_Muon1_alct_key_wire = digi.getKeyWG();
246  bits.MPC_Muon1_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
248  /*
249  bits.MPC_Muon1_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
250  bits.MPC_Muon1_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
251  */
252  bits.MPC_Muon1_clct_QuarterStrip = 0;
253  bits.MPC_Muon1_clct_EighthStrip = 0;
254  bits.MPC_Muon1_lct_quality = digi.getQuality() & 0x7;
255 
257  /*
258  // To restore 5-bits Run3 CLCT Pattern ID assume that LCT0 pattern ID is already processed
259  // and combine LCT1 Run3 pattern to set final 5-bit pattern ID
260  if (digi.isValid()) {
261  uint16_t clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
262  uint16_t run3_pattern = digi.getRun3Pattern();
263  clct_pattern_id = (clct_pattern_id + (run3_pattern + 1) * 5) % 30;
264  bits.MPC_Muon_clct_pattern_low = clct_pattern_id & 0xF;
265  bits.MPC_Muon_clct_pattern_bit5 = (clct_pattern_id >> 4) & 0x1;
266  }
267  */
268  bits.MPC_Muon_clct_pattern_low = 0;
269  bits.MPC_Muon_clct_pattern_bit5 = 0;
271  bits.MPC_Muon1_clct_bend_low = digi.getPattern() & 0x7;
272  bits.MPC_Muon1_clct_bend_bit4 = (digi.getPattern() >> 3) & 0x1;
273  bits.MPC_Muon1_clct_LR = digi.getBend() & 0x1;
274  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
275  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
276  bits.MPC_Muon_alct_bxn = digi.getBX();
277  bits.MPC_Muon1_clct_bx0 = digi.getBX0();
278 }
279 
281  uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
282  //not valid LCT shower, then in-time bits must be 0
283  if (not digi.isValid())
284  hmt_bits = ((digi.bitsOutOfTime() & 0x3) << 2);
285  bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
286  bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
287  if (digi.isValid())
288  bits.pop_l1a_match_win = CSCConstants::LCT_CENTRAL_BX - digi.getBX();
289  else
290  bits.pop_l1a_match_win = 3; //default value
291 }
292 
294  uint16_t hmt_bits = digi.bitsInTime() & 0x3;
295  if (not digi.isValid())
296  hmt_bits = 0;
297  bits.anode_hmt = hmt_bits;
298  if (digi.isValid())
299  bits.pop_l1a_match_win = CSCConstants::LCT_CENTRAL_BX - digi.getBX();
300  else
301  bits.pop_l1a_match_win = 3; //default value
302 }
303 
306  /* uint16_t hmt_bits = digi.bitsInTime() & 0x3;
307  bits.cathode_hmt = hmt_bits;
308  */
309  bits.cathode_hmt = 0;
310 }
311 
312 void CSCTMBHeader2020_TMB::print(std::ostream& os) const {
313  os << "...............(O)TMB2020 TMB Run3 Header.................."
314  << "\n";
315  os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
316  os << std::hex << "FW revision: 0x" << bits.firmRevCode << "\n";
317  os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
318  os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
319  os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
320  os << "trigSourceVect = " << bits.trigSourceVect << ", activeCFEBs = 0x" << std::hex
321  << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x" << std::hex
322  << (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
323  os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
324  os << "ALCT location in CLCT window " << bits.matchWin << " L1A location in TMB window " << bits.pop_l1a_match_win
325  << "\n";
326  os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
327 
328  os << "CLCT Words:\n"
329  << " bits.clct0_valid = " << bits.clct0_valid << " bits.clct0_shape = " << bits.clct0_shape
330  << " bits.clct0_quality = " << bits.clct0_quality
331  << " halfstrip = " << (bits.clct0_key_low + (bits.clct0_key_high << 7)) << "\n";
332 
333  os << " bits.clct1_valid = " << bits.clct1_valid << " bits.clct1_shape = " << bits.clct1_shape
334  << " bits.clct1_quality = " << bits.clct1_quality
335  << " halfstrip = " << (bits.clct1_key_low + (bits.clct1_key_high << 7)) << "\n";
336 
337  os << "MPC Words:\n"
338  << " LCT0 valid = " << bits.MPC_Muon0_lct_vpf << " key WG = " << bits.MPC_Muon0_alct_key_wire
339  << " key halfstrip = " << bits.MPC_Muon0_clct_key_halfstrip
340  << " 1/4strip flag = " << bits.MPC_Muon0_clct_QuarterStrip
341  << " 1/8strip flag = " << bits.MPC_Muon0_clct_EighthStrip << "\n"
342  << " quality = " << bits.MPC_Muon0_lct_quality
343  << " slope/bend = " << ((bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3))
344  << " L/R bend = " << bits.MPC_Muon0_clct_LR << "\n";
345 
346  os << " LCT1 valid = " << bits.MPC_Muon1_lct_vpf << " key WG = " << bits.MPC_Muon1_alct_key_wire
347  << " key halfstrip = " << bits.MPC_Muon1_clct_key_halfstrip
348  << " 1/4strip flag = " << bits.MPC_Muon1_clct_QuarterStrip
349  << " 1/8strip flag = " << bits.MPC_Muon1_clct_EighthStrip << "\n"
350  << " quality = " << bits.MPC_Muon1_lct_quality
351  << " slope/bend = " << ((bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3))
352  << " L/R bend = " << bits.MPC_Muon1_clct_LR << "\n";
353 
354  os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
355  << " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << ", alctHMT = " << bits.anode_hmt
356  << ", clctHMT = " << bits.cathode_hmt << "\n";
357 }
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
bool isValid() const
data
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:49
void print(std::ostream &os) const override
uint16_t getFullBX() const
return 12-bit full BX.
Definition: CSCCLCTDigi.h:165
uint16_t getBX() const
Definition: CSCShowerDigi.h:51
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
struct CSCTMBHeader2020_TMB::@504 bits
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:48
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