CMS 3D CMS Logo

L1MuGMTCancelOutUnit.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTCancelOutUnit
4 //
5 // Description: DT/CSC cancel-out unit
6 //
7 //
8 //
9 // Author :
10 // H. Sakulin CERN EP
11 //
12 // Migrated to CMSSW:
13 // I. Mikulec
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <iomanip>
29 #include <cmath>
30 #include <string>
31 #include <sstream>
32 
33 //-------------------------------
34 // Collaborating Class Headers --
35 //-------------------------------
36 
43 
44 // --------------------------------
45 // class L1MuGMTCancelOutUnit
46 //---------------------------------
47 
48 //----------------
49 // Constructors --
50 //----------------
52  : m_gmt(gmt), m_id(id), m_matcher(gmt, id + 2), m_MyChipCancelbits(4), m_OtherChipCancelbits(4) {}
53 
54 //--------------
55 // Destructor --
56 //--------------
58 
59 //--------------
60 // Operations --
61 //--------------
62 
63 //
64 // run cancel-out unit
65 //
67  m_matcher.run();
68  if (L1MuGMTConfig::Debug(3)) {
69  edm::LogVerbatim("GMT_CancelOut_info") << "result of cancel-out matcher: ";
70  m_matcher.print();
71  }
72  decide();
73 }
74 
75 //
76 // clear cancel-out unit
77 //
79  m_matcher.reset();
80 
81  for (int i = 0; i < 4; i++) {
82  m_MyChipCancelbits[i] = false;
83  m_OtherChipCancelbits[i] = false;
84  }
85 }
86 
87 //
88 // print cancel-out results
89 //
91  std::stringstream outmy;
92  switch (m_id) {
93  case 0:
94  outmy << "DT ";
95  break;
96  case 1:
97  outmy << "CSC ";
98  break;
99  case 2:
100  outmy << "bRPC";
101  break;
102  case 3:
103  outmy << "fRPC";
104  break;
105  }
106  outmy << "(my chip) cancel-bits : ";
107  for (int i = 0; i < 4; i++)
108  outmy << m_MyChipCancelbits[i] << " ";
109  edm::LogVerbatim("GMT_CancelOut_info") << outmy.str();
110 
111  std::stringstream outother;
112  if (m_id == 2 || m_id == 3) {
113  outother << (m_id == 2 ? "CSC" : "DT") << "(other chip) cancel-bits : ";
114  for (int i = 0; i < 4; i++)
115  outother << m_OtherChipCancelbits[i] << " ";
116  outother << std::endl;
117  }
118  edm::LogVerbatim("GMT_CancelOut_info") << outother.str();
119 }
120 
121 //
122 // compute cancel decision
123 //
125  // CancelDecisionLogic configuration register
126  //
127  unsigned CDL_config = L1MuGMTConfig::getRegCDLConfig()->getValue(m_id);
128 
129  // compute cancel decsion for my chip muons (mine)
130 
131  for (int imine = 0; imine < 4; imine++) {
132  int idxother = m_matcher.pairM().rowAny(imine);
133  if (idxother != -1) {
134  int mine_is_matched = 0;
135  switch (m_id) {
136  case 0:
137  mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(imine) != -1;
138  break; //DT
139  case 1:
140  mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(imine) != -1;
141  break; //CSC
142  case 2:
143  mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(imine) != -1;
144  break; //bRPC
145  case 3:
146  mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(imine) != -1;
147  break; //fRPC
148  }
149  int other_is_matched = m_gmt.Matcher(1 - (m_id % 2))->pairM().rowAny(idxother) != -1;
150 
151  // calculate address of bit in CDL_config register
152  unsigned addr = (unsigned)(2 * mine_is_matched + other_is_matched);
153  unsigned mask = (unsigned)1 << addr;
154 
155  m_MyChipCancelbits[imine] = (CDL_config & mask) == mask;
156  }
157  }
158 
159  // compute cancel decsison for other chip muons (other)
160 
161  for (int iother = 0; iother < 4; iother++) {
162  int idxmine = m_matcher.pairM().colAny(iother);
163  if (idxmine != -1) {
164  int mine_is_matched = 0;
165  switch (m_id) {
166  case 0:
167  mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(idxmine) != -1;
168  break; //DT
169  case 1:
170  mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(idxmine) != -1;
171  break; //CSC
172  case 2:
173  mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(idxmine) != -1;
174  break; //bRPC
175  case 3:
176  mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(idxmine) != -1;
177  break; //fRPC
178  }
179  int other_is_matched = m_gmt.Matcher(1 - (m_id % 2))->pairM().rowAny(iother) != -1;
180 
181  // calculate address of bit in CDL_config register
182  unsigned addr = (unsigned)(2 * other_is_matched + mine_is_matched);
183  unsigned mask = (unsigned)1 << (addr + 4);
184 
185  m_OtherChipCancelbits[iother] = (CDL_config & mask) == mask;
186  }
187  }
188 
190 }
Log< level::Info, true > LogVerbatim
const L1MuGMTMatcher * Matcher(int id) const
return pointer to Matcher
void reset()
clear cancel-out unit
void print()
print cancel-out bits
unsigned getValue(int idx)
get Value
Definition: L1MuGMTReg.h:53
const L1MuGlobalMuonTrigger & m_gmt
void run()
run Matcher
L1MuGMTDebugBlock * DebugBlockForFill() const
for debug: return the debug block (in order to fill it)
std::vector< bool > m_MyChipCancelbits
void print()
print matching results
static bool Debug()
void SetCancelBits(int idx, const std::vector< bool > &mine, const std::vector< bool > &others)
Set cancel bits.
const L1MuGMTMatrix< bool > & pairM() const
return pair matrix
virtual ~L1MuGMTCancelOutUnit()
destructor
L1MuGMTCancelOutUnit(const L1MuGlobalMuonTrigger &gmt, int id)
constructor
void reset()
clear Matcher
int rowAny(int r) const
is any element in row r > 0 ? return index or -1
int colAny(int c) const
is any element in column c > 0 ? return index or -1
std::vector< bool > m_OtherChipCancelbits
static L1MuGMTRegCDLConfig * getRegCDLConfig()
void run()
run cancel-out unit