CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
l1t::stage2::BMTFPackerInputs Class Reference

#include <BMTFPackerInputs.h>

Inheritance diagram for l1t::stage2::BMTFPackerInputs:
l1t::Packer

Public Member Functions

Blocks pack (const edm::Event &, const PackerTokens *) override
 
- Public Member Functions inherited from l1t::Packer
unsigned board ()
 
void setBoard (unsigned board)
 
virtual ~Packer ()=default
 

Private Member Functions

uint32_t wordPhMaker (const L1MuDTChambPhDigi &phInput)
 
uint32_t wordThMaker (const L1MuDTChambThDigi &thInput, const bool &qualFlag)
 

Private Attributes

std::map< unsigned int, std::vector< uint32_t > > payloadMap_
 

Static Private Attributes

static const unsigned int bxCntMask = 0x3
 
static const unsigned int bxCntShift = 30
 
static const int ownLinks_ [] ={4,5,12,13,20,21,22,23,28,29}
 
static const unsigned int phiBMask = 0x3FF
 
static const unsigned int phiBShift = 12
 
static const unsigned int phiMask = 0xFFF
 
static const unsigned int phiShift = 0
 
static const unsigned int qualMask = 0x7
 
static const unsigned int qualShift = 22
 
static const unsigned int rpcMask = 0x1
 
static const unsigned int rpcShift = 26
 

Detailed Description

Definition at line 13 of file BMTFPackerInputs.h.

Member Function Documentation

Blocks l1t::stage2::BMTFPackerInputs::pack ( const edm::Event event,
const PackerTokens toks 
)
overridevirtual

Implements l1t::Packer.

Definition at line 14 of file BMTFPackerInputs.cc.

References funct::abs(), gather_cfg::blocks, l1t::Packer::board(), L1MuDTChambThContainer::getContainer(), L1MuDTChambPhContainer::getContainer(), mps_fire::i, createfilelist::int, ownLinks_, jets_cff::payload, wordPhMaker(), and wordThMaker().

Referenced by pyrootRender.interactiveRender::draw().

15  {
16  int board_id = (int)board();
17 
18  auto muonPhToken = static_cast<const BMTFTokens*>(toks)->getInputMuonTokenPh();
19  auto muonThToken = static_cast<const BMTFTokens*>(toks)->getInputMuonTokenTh();
20 
21  Blocks blocks;
22 
24  event.getByToken(muonPhToken, phInputs);
26  event.getByToken(muonThToken, thInputs);
27 
28  uint32_t qualEta_32bit = 0;
29  uint32_t posEta_0_32bit = 0;
30  uint32_t posEta_n2_32bit = 0, posEta_n1_32bit = 0;
31  uint32_t posEta_p2_32bit = 0, posEta_p1_32bit = 0;
32 
33  bool moreBXeta = false;
34  for (int link = 0; link <= 35; link++) {
35  // std::cout << "link : " << link << std::endl;
36 
37  if ( (link >= 6 && link < 8) ||
38  (link >= 14 && link < 16) ||
39  (link >= 30 && link < 32) )
40  continue;
41 
42  //initializing null block_payloads and block_id
43  std::vector<uint32_t> payload_0 (6,0);
44  std::vector<uint32_t> payload_p1(6,0);
45  std::vector<uint32_t> payload_n1(6,0);
46  std::vector<uint32_t> payload_p2(6,0);
47  std::vector<uint32_t> payload_n2(6,0);
48 
49  unsigned int block_id = 2*link;
50 
51  std::vector<bool> bxPresent(5,false);
52  bool moreBXphi = false;
53 
54  unsigned int BC = 0;
55 
56  //The first 4 phi words for the link's payload
57 
58  for (const auto & iphi : *(phInputs->getContainer()) )
59  {
60  // Only allow -2 <= bxNum <= 2, as in Stage2 data
61  if (std::abs(iphi.bxNum()) > 2) continue;
62 
63  if (iphi.bxNum() != 0)
64  moreBXphi = true;
65 
66  // std::cout << "scNum+1 = " << iphi->scNum()+1 << ", board_id = " << board_id << std::endl;
67  // std::cout << "bx, station = " << iphi->bxNum() << ", " << iphi->stNum() << std::endl;
68 
69  //BC = iphi->BxCnt();//this thing here is not completely functional
70 
71  if ( iphi.scNum()+1 != board_id )
72  continue;
73  // std::cout << "correct board" << std::endl;
74 
75  if (link != ownLinks_[4+2*(iphi.whNum())+iphi.Ts2Tag()])
76  continue;
77  // std::cout << "correct link" << std::endl;
78 
79  bxPresent[2+iphi.bxNum()] = true;
80 
81  //1 create 32word, 2 insert 32word in correct Block Slot
82  uint32_t word_32bit = wordPhMaker(iphi);//1
83  if (bxPresent[0]){
84  payload_n2[iphi.stNum()-1] = word_32bit;
85  }
86  else if (bxPresent[1]){
87  payload_n1[iphi.stNum()-1] = word_32bit;
88  }
89  else if (bxPresent[2])
90  payload_0[iphi.stNum()-1] = word_32bit;
91  else if (bxPresent[3]){
92  payload_p1[iphi.stNum()-1] = word_32bit;
93  }
94  else if (bxPresent[4]){
95  payload_p2[iphi.stNum()-1] = word_32bit;
96  }
97 
98  bxPresent.assign(5,false);
99 
100  }//phiCont_itr
101 
102 
103  //============================================================================================
104 
105 
106  //Create phiNull words (use the old format for null words because Packer gives fw_id=1)
107  //uint32_t phiNull_32bit = 0 | (BC & 0x3) << 30 | (7 & 0x7) << 22; //for the new fw
108  uint32_t phiNull_32bit = 0 | (BC & 0x3) << 30;//for the old fw
109  //phiNull = (BC)000001110000000000000000000000
110  uint32_t etaNull_32bit = 0 | (BC & 0x3) << 30;
111  //etaNull = (BC)000000000000000000000000000000
112 
113 
114  //============================================================================================
115 
116 
117  //The 5th & 6th words of the link's payload
118  // std::cout << "link%2 = " << link%2 << std::endl;
119  if (link%2 == 0) {
120 
121  //these Eta vars have to be declared out of link itr scope in order to maintain its information for the next link
122  //Using these as the basis for the pos and qual 32bit eta word
123  //in case there are les than 3 hits, the entries will be zero.
124  posEta_0_32bit = etaNull_32bit;
125  posEta_n2_32bit = etaNull_32bit;
126  posEta_n1_32bit = etaNull_32bit;
127  posEta_p2_32bit = etaNull_32bit;
128  posEta_p1_32bit = etaNull_32bit;
129 
130  qualEta_32bit = etaNull_32bit;
131 
132 
133  int theta_iterators = 0;//debug
134  for (const auto & ithe : *(thInputs->getContainer()) )
135  {
136  // Only allow -2 <= bxNum <= 2, as in Stage2 data
137  if (std::abs(ithe.bxNum()) > 2) continue;
138 
139  if (ithe.bxNum() != 0)
140  moreBXeta = true;
141 
142  theta_iterators++;//debug
143 
144  //debug
145  // std::cout << "scNum+1 = " << ithe.scNum()+1 << ", board_id = " << board_id << std::endl;
146  // std::cout << "bx, station = " << ithe.bxNum() << ", " << ithe.stNum() << std::endl;
147  // std::cout << "related link: " << ownLinks_[4+2*(ithe.whNum())] << std::endl;
148 
149  if ( ithe.scNum()+1 != board_id )
150  continue;
151 
152  if ( link != ownLinks_[4+2*(ithe.whNum())] )
153  continue;
154 
155  bxPresent[2+ithe.bxNum()] = true;
156 
157 
158  //positions for the next link
159  uint32_t posEta_7bit = wordThMaker(ithe, false);
160 
161  //qualities for this link
162  uint32_t qualEta_7bit = wordThMaker(ithe, true);
163  qualEta_32bit = qualEta_32bit | ( (qualEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
164 
165 
166  //write the eta-pos and eta-qual information at the correct payload per BX
167  if (bxPresent[0]){
168  payload_n2[4] = qualEta_32bit;
169  payload_n2[5] = etaNull_32bit | (2 & 0x2);
170  posEta_n2_32bit = posEta_n2_32bit | ( (posEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
171  }
172  else if (bxPresent[1]){
173  payload_n1[4] = qualEta_32bit;
174  payload_n1[5] = etaNull_32bit | (2 & 0x2);
175  posEta_n1_32bit = posEta_n1_32bit | ( (posEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
176  }
177  else if (bxPresent[2]){
178  payload_0[4] = qualEta_32bit;
179  payload_0[5] = etaNull_32bit | (2 & 0x2);
180  posEta_0_32bit = posEta_0_32bit | ( (posEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
181  }
182  else if (bxPresent[3]){
183  payload_p1[4] = qualEta_32bit;
184  payload_p1[5] = etaNull_32bit | (2 & 0x2);
185  posEta_p1_32bit = posEta_p1_32bit | ( (posEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
186  }
187  else if (bxPresent[4]){
188  payload_p2[4] = qualEta_32bit;
189  payload_p2[5] = etaNull_32bit | (2 & 0x2);
190  posEta_p2_32bit = posEta_p2_32bit | ( (posEta_7bit & 0x7F) << 7*(ithe.stNum()-1) );
191  }
192 
193  bxPresent.assign(5,false);
194 
195  }//theCont_itr
196 
197 
198  }
199  else {//now that we are in the next prime link #, write the buffered eta-qual
200 
201  if (moreBXeta) {
202  payload_n2[4] = posEta_n2_32bit;
203  payload_n2[5] = etaNull_32bit;
204 
205  payload_n1[4] = posEta_n1_32bit;
206  payload_n1[5] = etaNull_32bit;
207  }
208 
209  payload_0[4] = posEta_0_32bit;
210  payload_0[5] = etaNull_32bit;
211 
212  if (moreBXeta) {
213  payload_p1[4] = posEta_p1_32bit;
214  payload_p1[5] = etaNull_32bit;
215 
216  payload_p2[4] = posEta_p2_32bit;
217  payload_p2[5] = etaNull_32bit;
218  }
219 
220 
221  }
222 
223  //std::cout << "moreBXphi" << moreBXphi << std::endl;
224  //std::cout << "moreBXeta" << moreBXeta << std::endl;
225 
226 
227  bool moreBX = moreBXphi || moreBXeta;
228  //std::cout << "moreBX" << moreBX << std::endl;
229 
230  //case where phi words are notcreated
231  for (int iSt = 0; iSt <= 3; iSt++){
232 
233  if (moreBX && payload_n2[iSt]==0)
234  payload_n2[iSt] = phiNull_32bit;
235 
236  if (moreBX && payload_n1[iSt]==0)
237  payload_n1[iSt] = phiNull_32bit;
238 
239  if (payload_0[iSt]==0)
240  payload_0[iSt] = phiNull_32bit;
241 
242  if (moreBX && payload_p1[iSt]==0)
243  payload_p1[iSt] = phiNull_32bit;
244 
245  if (moreBX && payload_p2[iSt]==0)
246  payload_p2[iSt] = phiNull_32bit;
247  }
248 
249 
250  //case where eta words are notcreated
251  for (int word = 4; word <= 5; word++){
252 
253  if (moreBX && payload_n2[word]==0)
254  payload_n2[word] = etaNull_32bit;
255 
256  if (moreBX && payload_n1[word]==0)
257  payload_n1[word] = etaNull_32bit;
258 
259  if (payload_0[word]==0)
260  payload_0[word] = etaNull_32bit;
261 
262  if (moreBX && payload_p1[word]==0)
263  payload_p1[word] = etaNull_32bit;
264 
265  if (moreBX && payload_p2[word]==0)
266  payload_p2[word] = etaNull_32bit;
267  }
268 
269 
270  //============================================================================================
271 
272  /*
273 
274  //debug
275  std::cout << "payload created : " << std::endl;
276  if (moreBX){
277  for (auto &word : payload_n2) //
278  std::cout << std::bitset<32>(word).to_string() << std::endl;
279 
280  for (auto &word : payload_n1) //
281  std::cout << std::bitset<32>(word).to_string() << std::endl;
282  }
283 
284  for (auto &word : payload_0) //
285  std::cout << std::bitset<32>(word).to_string() << std::endl;
286 
287  if (moreBX){
288  for (auto &word : payload_p1) //
289  std::cout << std::bitset<32>(word).to_string() << std::endl;
290 
291  for (auto &word : payload_p2) //
292  std::cout << std::bitset<32>(word).to_string() << std::endl;
293  }
294  */
295  //============================================================================================
296 
297 
298  std::vector<uint32_t> payload;
299 
300  if (moreBX){//push -2,-1 bx payloads
301  for (int i=0; i<6; i++)
302  payload.push_back(payload_n2[i]);
303  for (int i=0; i<6; i++)
304  payload.push_back(payload_n1[i]);
305  }
306 
307  for (int i=0; i<6; i++)//zero bx payload
308  payload.push_back(payload_0[i]);
309 
310  if (moreBX){//push +1,+2 bx payloads
311  for (int i=0; i<6; i++)
312  payload.push_back(payload_p1[i]);
313  for (int i=0; i<6; i++)
314  payload.push_back(payload_p2[i]);
315  }
316 
317  //in format Block(id,payload)
318  blocks.push_back(Block(block_id, payload));
319 
320  if (link%2 != 0) {
321  moreBXphi = false;
322  moreBXeta = false;
323  }
324 
325  }//link_itr
326 
327 
328  return blocks;
329  }
The_Container const * getContainer() const
uint32_t wordPhMaker(const L1MuDTChambPhDigi &phInput)
uint32_t wordThMaker(const L1MuDTChambThDigi &thInput, const bool &qualFlag)
std::vector< Block > Blocks
Definition: Block.h:72
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Phi_Container const * getContainer() const
unsigned board()
Definition: Packer.h:18
uint32_t l1t::stage2::BMTFPackerInputs::wordPhMaker ( const L1MuDTChambPhDigi phInput)
private

Definition at line 333 of file BMTFPackerInputs.cc.

References L1MuDTChambPhDigi::BxCnt(), bxCntMask, bxCntShift, L1MuDTChambPhDigi::code(), L1MuDTChambPhDigi::phi(), L1MuDTChambPhDigi::phiB(), phiBMask, phiBShift, phiMask, phiShift, qualMask, qualShift, L1MuDTChambPhDigi::RpcBit(), rpcMask, rpcShift, and groupFilesInBlocks::temp.

Referenced by pack().

334  {
335  uint32_t temp(0);
336 
337  temp = (phInput.phi() & phiMask) << phiShift
338  |(phInput.phiB() & phiBMask) << phiBShift
339  |(phInput.code() & qualMask) << qualShift
340  |(phInput.RpcBit() & rpcMask) << rpcShift
341  |(0) << 29
342  |(phInput.BxCnt() & bxCntMask) << bxCntShift;
343 
344 
345  // std::cout<<"uint32_t temp is: "<<std::bitset<32>(temp).to_string()<<"---- phi="<<phInput.phi()<<", phiB()="<<phInput.phiB()<<", code(qual?)="<<phInput.code()<<", RPC="<<phInput.RpcBit()<<", BC="<<phInput.BxCnt()<<std::endl;
346  return temp;
347  }
static const unsigned int rpcShift
static const unsigned int bxCntShift
static const unsigned int phiShift
static const unsigned int phiMask
static const unsigned int phiBMask
static const unsigned int qualMask
static const unsigned int qualShift
static const unsigned int bxCntMask
static const unsigned int rpcMask
static const unsigned int phiBShift
uint32_t l1t::stage2::BMTFPackerInputs::wordThMaker ( const L1MuDTChambThDigi thInput,
const bool &  qualFlag 
)
private

Definition at line 350 of file BMTFPackerInputs.cc.

References DEFINE_L1T_PACKER, mps_fire::i, L1MuDTChambThDigi::position(), L1MuDTChambThDigi::quality(), and groupFilesInBlocks::temp.

Referenced by pack().

351  {
352  uint32_t temp(0);
353  if (!qualFlag)
354  {
355  for (int i=6; i>=0; i--) {
356  temp = temp << 1;
357  temp = temp | (thInput.position(i) & 0x1);
358  }
359  }
360  else
361  {
362  for (int i=6; i>=0; i--) {
363  temp = temp << 1;
364  temp = temp | (thInput.quality(i) & 0x1);
365  }
366  }
367 
368  return temp;
369  }
int quality(const int i) const
int position(const int i) const

Member Data Documentation

const unsigned int l1t::stage2::BMTFPackerInputs::bxCntMask = 0x3
staticprivate

Definition at line 31 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::bxCntShift = 30
staticprivate

Definition at line 32 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const int l1t::stage2::BMTFPackerInputs::ownLinks_ ={4,5,12,13,20,21,22,23,28,29}
staticprivate

Definition at line 34 of file BMTFPackerInputs.h.

Referenced by pack().

std::map<unsigned int, std::vector<uint32_t> > l1t::stage2::BMTFPackerInputs::payloadMap_
private

Definition at line 18 of file BMTFPackerInputs.h.

const unsigned int l1t::stage2::BMTFPackerInputs::phiBMask = 0x3FF
staticprivate

Definition at line 25 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::phiBShift = 12
staticprivate

Definition at line 26 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::phiMask = 0xFFF
staticprivate

Definition at line 23 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::phiShift = 0
staticprivate

Definition at line 24 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::qualMask = 0x7
staticprivate

Definition at line 27 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::qualShift = 22
staticprivate

Definition at line 28 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::rpcMask = 0x1
staticprivate

Definition at line 29 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().

const unsigned int l1t::stage2::BMTFPackerInputs::rpcShift = 26
staticprivate

Definition at line 30 of file BMTFPackerInputs.h.

Referenced by wordPhMaker().