CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCTMBHeader2020_TMB.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 = 0x001;
20  bits.nTBins = 12;
21  bits.nCFEBs = 5;
22 }
23 
24 CSCTMBHeader2020_TMB::CSCTMBHeader2020_TMB(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_TMB::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  unsigned cfeb = halfstrip / 32;
38  unsigned pattern = bits.clct0_shape;
39  unsigned bend = pattern & 0x1;
40 
41  CSCCLCTDigi digi0(
42  bits.clct0_valid, bits.clct0_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 1, bits.bxnPreTrigger);
43 
44  halfstrip = bits.clct1_key_low + (bits.clct1_key_high << 7);
45  strip = halfstrip % 32;
46  cfeb = halfstrip / 32;
47  pattern = bits.clct1_shape;
48  bend = pattern & 0x1;
49 
50  CSCCLCTDigi digi1(
51  bits.clct1_valid, bits.clct1_quality, pattern, 1, bend, strip, cfeb, bits.clct_bxn, 2, bits.bxnPreTrigger);
52  result.push_back(digi0);
53  result.push_back(digi1);
54  return result;
55 }
56 
58 std::vector<CSCCorrelatedLCTDigi> CSCTMBHeader2020_TMB::CorrelatedLCTDigis(uint32_t idlayer) const {
59  std::vector<CSCCorrelatedLCTDigi> result;
60  unsigned strip = bits.MPC_Muon0_clct_key_halfstrip; //this goes from 0-223
61  unsigned slope = (bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3);
62  unsigned hmt = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger
63  unsigned clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
64 
65  std::pair<unsigned, unsigned> run3_pattern_pair = run3_pattern_lookup_tbl[clct_pattern_id % 30];
66  unsigned run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon0_clct_LR][slope];
67  unsigned run3_pattern = run3_pattern_pair.second & 0x7;
68 
69  CSCCorrelatedLCTDigi digi(1,
70  bits.MPC_Muon0_lct_vpf,
71  bits.MPC_Muon0_lct_quality,
72  bits.MPC_Muon0_alct_key_wire,
73  strip,
74  run2_pattern,
75  bits.MPC_Muon0_clct_LR,
76  bits.MPC_Muon_alct_bxn,
77  0,
78  bits.MPC_Muon0_clct_bx0,
79  0,
80  0,
82  bits.MPC_Muon0_clct_QuarterStrip,
83  bits.MPC_Muon0_clct_EighthStrip,
84  run3_pattern,
85  slope);
86  digi.setHMT(hmt);
87  result.push_back(digi);
89  strip = bits.MPC_Muon1_clct_key_halfstrip; //this goes from 0-223
90  slope = (bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3);
91  run2_pattern = run2_pattern_lookup_tbl[bits.MPC_Muon1_clct_LR][slope];
92  run3_pattern = run3_pattern_pair.first & 0x7;
93  digi = CSCCorrelatedLCTDigi(2,
94  bits.MPC_Muon1_lct_vpf,
95  bits.MPC_Muon1_lct_quality,
96  bits.MPC_Muon1_alct_key_wire,
97  strip,
98  run2_pattern,
99  bits.MPC_Muon1_clct_LR,
100  bits.MPC_Muon_alct_bxn,
101  0,
102  bits.MPC_Muon1_clct_bx0,
103  0,
104  0,
106  bits.MPC_Muon1_clct_QuarterStrip,
107  bits.MPC_Muon1_clct_EighthStrip,
108  run3_pattern,
109  slope);
110  digi.setHMT(hmt);
111  result.push_back(digi);
112  return result;
113 }
114 
116  unsigned hmt_bits = bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1); // HighMultiplicityTrigger bits
117  uint16_t cscid = 0; // ??? What is 4-bits CSC Id in CSshowerDigi
118  CSCShowerDigi result(hmt_bits & 0x3, (hmt_bits >> 2) & 0x3, cscid); // 2-bits intime, 2-bits out of time
119  return result;
120 }
121 
123  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
124 }
125 
127  throw cms::Exception("In CSC TMBHeaderFormat 2007, ALCTs belong in ALCT header");
128 }
129 
131  unsigned halfStrip = digi.getKeyStrip();
132  unsigned pattern = digi.getPattern();
133  bits.clct0_valid = digi.isValid();
134  bits.clct0_quality = digi.getQuality();
135  bits.clct0_shape = pattern;
136  // first 7 bits of halfstrip
137  bits.clct0_key_low = halfStrip & (0x7F);
138  // most-significant (8th) bit
139  bits.clct0_key_high = (halfStrip >> 7) & (0x1);
140  bits.clct_bxn = digi.getBX();
141  bits.bxnPreTrigger = digi.getFullBX();
142 }
143 
145  unsigned halfStrip = digi.getKeyStrip();
146  unsigned pattern = digi.getPattern();
147  bits.clct1_valid = digi.isValid();
148  bits.clct1_quality = digi.getQuality();
149  bits.clct1_shape = pattern;
150  // first 7 bits of halfstrip
151  bits.clct1_key_low = halfStrip & (0x7F);
152  // most-significant (8th) bit
153  bits.clct1_key_high = (halfStrip >> 7) & (0x1);
154  // There is just one BX field common for CLCT0 and CLCT1 (since both
155  // are latched at the same BX); set it in addCLCT0().
156  bits.bxnPreTrigger = digi.getFullBX();
157 }
158 
160  bits.MPC_Muon0_lct_vpf = digi.isValid();
161  bits.MPC_Muon0_alct_key_wire = digi.getKeyWG();
162  bits.MPC_Muon0_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
163  bits.MPC_Muon0_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
164  bits.MPC_Muon0_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
165  bits.MPC_Muon0_lct_quality = digi.getQuality() & 0x7;
166 
167  // To restore 5-bits Run3 CLCT Pattern ID first assume and set pattern ID = LCT0 Run3 pattern
168  uint16_t run3_pattern = digi.getRun3Pattern();
169  bits.MPC_Muon_clct_pattern_low = run3_pattern & 0xF;
170  bits.MPC_Muon_clct_pattern_bit5 = (run3_pattern >> 4) & 0x1;
171  bits.MPC_Muon0_clct_bend_low = digi.getSlope() & 0x7;
172  bits.MPC_Muon0_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
173  bits.MPC_Muon0_clct_LR = digi.getBend() & 0x1;
174  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
175  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
176  bits.MPC_Muon_alct_bxn = digi.getBX();
177  bits.MPC_Muon0_clct_bx0 = digi.getBX0();
178 }
179 
181  bits.MPC_Muon1_lct_vpf = digi.isValid();
182  bits.MPC_Muon1_alct_key_wire = digi.getKeyWG();
183  bits.MPC_Muon1_clct_key_halfstrip = digi.getStrip(2) & 0xFF;
184  bits.MPC_Muon1_clct_QuarterStrip = digi.getQuartStripBit() & 0x1;
185  bits.MPC_Muon1_clct_EighthStrip = digi.getEighthStripBit() & 0x1;
186  bits.MPC_Muon1_lct_quality = digi.getQuality() & 0x7;
187 
188  // To restore 5-bits Run3 CLCT Pattern ID assume that LCT0 pattern ID is already processed
189  // and combine LCT1 Run3 pattern to set final 5-bit pattern ID
190  if (digi.isValid()) {
191  uint16_t clct_pattern_id = bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4);
192  uint16_t run3_pattern = digi.getRun3Pattern();
193  clct_pattern_id = (clct_pattern_id + (run3_pattern + 1) * 5) % 30;
194  bits.MPC_Muon_clct_pattern_low = clct_pattern_id & 0xF;
195  bits.MPC_Muon_clct_pattern_bit5 = (clct_pattern_id >> 4) & 0x1;
196  }
197  bits.MPC_Muon1_clct_bend_low = digi.getSlope() & 0x7;
198  bits.MPC_Muon1_clct_bend_bit4 = (digi.getSlope() >> 3) & 0x1;
199  bits.MPC_Muon1_clct_LR = digi.getBend() & 0x1;
200  bits.MPC_Muon_HMT_bit0 = digi.getHMT() & 0x1;
201  bits.MPC_Muon_HMT_high = (digi.getHMT() >> 1) & 0x7;
202  bits.MPC_Muon_alct_bxn = digi.getBX();
203  bits.MPC_Muon1_clct_bx0 = digi.getBX0();
204 }
205 
207  uint16_t hmt_bits = (digi.bitsInTime() & 0x3) + ((digi.bitsOutOfTime() & 0x3) << 2);
208  bits.MPC_Muon_HMT_bit0 = hmt_bits & 0x1;
209  bits.MPC_Muon_HMT_high = (hmt_bits >> 1) & 0x7;
210 }
211 
212 void CSCTMBHeader2020_TMB::print(std::ostream& os) const {
213  os << "...............(O)TMB2020 TMB Run3 Header.................."
214  << "\n";
215  os << std::hex << "BOC LINE " << bits.b0cline << " EOB " << bits.e0bline << "\n";
216  os << std::hex << "FW revision: 0x" << bits.firmRevCode << "\n";
217  os << std::dec << "fifoMode = " << bits.fifoMode << ", nTBins = " << bits.nTBins << "\n";
218  os << "boardID = " << bits.boardID << ", cscID = " << bits.cscID << "\n";
219  os << "l1aNumber = " << bits.l1aNumber << ", bxnCount = " << bits.bxnCount << "\n";
220  os << "trigSourceVect = " << bits.trigSourceVect << ", activeCFEBs = 0x" << std::hex
221  << (bits.activeCFEBs | (bits.activeCFEBs_2 << 5)) << ", readCFEBs = 0x" << std::hex
222  << (bits.readCFEBs | (bits.readCFEBs_2 << 5)) << std::dec << "\n";
223  os << "bxnPreTrigger = " << bits.bxnPreTrigger << "\n";
224  os << "tmbMatch = " << bits.tmbMatch << " alctOnly = " << bits.alctOnly << " clctOnly = " << bits.clctOnly << "\n";
225 
226  os << "CLCT Words:\n"
227  << " bits.clct0_valid = " << bits.clct0_valid << " bits.clct0_shape = " << bits.clct0_shape
228  << " bits.clct0_quality = " << bits.clct0_quality
229  << " halfstrip = " << (bits.clct0_key_low + (bits.clct0_key_high << 7)) << "\n";
230 
231  os << " bits.clct1_valid = " << bits.clct1_valid << " bits.clct1_shape = " << bits.clct1_shape
232  << " bits.clct1_quality = " << bits.clct1_quality
233  << " halfstrip = " << (bits.clct1_key_low + (bits.clct1_key_high << 7)) << "\n";
234 
235  os << "MPC Words:\n"
236  << " LCT0 valid = " << bits.MPC_Muon0_lct_vpf << " key WG = " << bits.MPC_Muon0_alct_key_wire
237  << " key halfstrip = " << bits.MPC_Muon0_clct_key_halfstrip
238  << " 1/4strip flag = " << bits.MPC_Muon0_clct_QuarterStrip
239  << " 1/8strip flag = " << bits.MPC_Muon0_clct_EighthStrip << "\n"
240  << " quality = " << bits.MPC_Muon0_lct_quality
241  << " slope/bend = " << ((bits.MPC_Muon0_clct_bend_low & 0x7) | (bits.MPC_Muon0_clct_bend_bit4 << 3))
242  << " L/R bend = " << bits.MPC_Muon0_clct_LR << "\n";
243 
244  os << " LCT1 valid = " << bits.MPC_Muon1_lct_vpf << " key WG = " << bits.MPC_Muon1_alct_key_wire
245  << " key halfstrip = " << bits.MPC_Muon1_clct_key_halfstrip
246  << " 1/4strip flag = " << bits.MPC_Muon1_clct_QuarterStrip
247  << " 1/8strip flag = " << bits.MPC_Muon1_clct_EighthStrip << "\n"
248  << " quality = " << bits.MPC_Muon1_lct_quality
249  << " slope/bend = " << ((bits.MPC_Muon1_clct_bend_low & 0x7) | (bits.MPC_Muon1_clct_bend_bit4 << 3))
250  << " L/R bend = " << bits.MPC_Muon1_clct_LR << "\n";
251 
252  os << " clct_5bit_pattern_id = " << (bits.MPC_Muon_clct_pattern_low | (bits.MPC_Muon_clct_pattern_bit5 << 4))
253  << " HMT = " << (bits.MPC_Muon_HMT_bit0 | (bits.MPC_Muon_HMT_high << 1)) << "\n";
254 }
uint16_t getSlope() const
return the slope
uint16_t getBend() const
void addShower(const CSCShowerDigi &digi) 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
void addALCT1(const CSCALCTDigi &digi) override
bool getQuartStripBit() const
get single quart strip bit
void setHMT(const uint16_t h)
set high-multiplicity bits
void addCLCT1(const CSCCLCTDigi &digi) override
static const double slope[3]
struct CSCTMBHeader2020_TMB::@491 bits
void addCorrelatedLCT1(const CSCCorrelatedLCTDigi &digi) override
void addALCT0(const CSCALCTDigi &digi) override
void print(std::ostream &os) const override
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
uint16_t getKeyWG() const
return the key wire group. counts from 0.
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
unsigned short * data() override
returns the first data word
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
unsigned bxn() const
Definition: CSCDMBHeader.h:37
const unsigned run2_pattern_lookup_tbl[2][16]
pattern IDs 30,31 are reserved
CSCShowerDigi showerDigi(uint32_t idlayer) const override
returns HMT Shower digi
uint16_t getPattern() const
return pattern
Definition: CSCCLCTDigi.h:62
uint16_t getQuality() const
return the Quality
bool isValid() const
return valid pattern bit
unsigned dmbID() const
Definition: CSCDMBHeader.h:36
unsigned short int sizeInWords() const override
void addCorrelatedLCT0(const CSCCorrelatedLCTDigi &digi) override
void setEventInformation(const CSCDMBHeader &dmbHeader) override
uint16_t getQuality() const
return quality of a pattern (number of layers hit!)
Definition: CSCCLCTDigi.h:56
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