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 
56 //--------------
57 // Destructor --
58 //--------------
60 
61  reset();
62 
63 }
64 
65 //--------------
66 // Operations --
67 //--------------
68 
69 //
70 // run cancel-out unit
71 //
73 
74  m_matcher.run();
75  if (L1MuGMTConfig::Debug(3)) {
76  edm::LogVerbatim("GMT_CancelOut_info") << "result of cancel-out matcher: ";
77  m_matcher.print();
78  }
79  decide();
80 }
81 
82 //
83 // clear cancel-out unit
84 //
86 
87  m_matcher.reset();
88 
89  for ( int i = 0; i < 4; i++ ) {
90  m_MyChipCancelbits[i] = false;
91  m_OtherChipCancelbits[i] = false;
92  }
93 }
94 
95 
96 //
97 // print cancel-out results
98 //
100 
101  std::stringstream outmy;
102  switch (m_id) {
103  case 0 : outmy << "DT " ; break;
104  case 1 : outmy << "CSC " ; break;
105  case 2 : outmy << "bRPC" ; break;
106  case 3 : outmy << "fRPC" ; break;
107  }
108  outmy << "(my chip) cancel-bits : " ;
109  for ( int i = 0; i < 4; i++ ) outmy << m_MyChipCancelbits[i] << " ";
110  edm::LogVerbatim("GMT_CancelOut_info") << outmy.str();
111 
112  std::stringstream outother;
113  if (m_id==2 || m_id==3) {
114  outother << (m_id==2 ? "CSC" : "DT" ) << "(other chip) cancel-bits : " ;
115  for ( int i = 0; i < 4; i++ ) outother << m_OtherChipCancelbits[i] << " ";
116  outother << std::endl;
117  }
118  edm::LogVerbatim("GMT_CancelOut_info") << outother.str();
119 }
120 
121 
122 
123 //
124 // compute cancel decision
125 //
127 
128  // CancelDecisionLogic configuration register
129  //
130  unsigned CDL_config = L1MuGMTConfig::getRegCDLConfig()->getValue(m_id);
131 
132  // compute cancel decsion for my chip muons (mine)
133 
134  for(int imine=0; imine<4; imine++) {
135  int idxother = m_matcher.pairM().rowAny(imine);
136  if (idxother != -1) {
137  int mine_is_matched = 0;
138  switch(m_id) {
139  case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(imine) != -1; break; //DT
140  case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(imine) != -1; break; //CSC
141  case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(imine) != -1; break; //bRPC
142  case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(imine) != -1; break; //fRPC
143  }
144  int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(idxother) != -1;
145 
146  // calculate address of bit in CDL_config register
147  unsigned addr = (unsigned) (2*mine_is_matched + other_is_matched);
148  unsigned mask = (unsigned) 1 << addr;
149 
150  m_MyChipCancelbits[imine] = (CDL_config & mask) == mask;
151  }
152  }
153 
154  // compute cancel decsison for other chip muons (other)
155 
156  for(int iother=0; iother<4; iother++) {
157  int idxmine = m_matcher.pairM().colAny(iother);
158  if (idxmine != -1) {
159  int mine_is_matched = 0;
160  switch(m_id) {
161  case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(idxmine) != -1; break; //DT
162  case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(idxmine) != -1; break; //CSC
163  case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(idxmine) != -1; break; //bRPC
164  case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(idxmine) != -1; break; //fRPC
165  }
166  int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(iother) != -1;
167 
168  // calculate address of bit in CDL_config register
169  unsigned addr = (unsigned) (2*other_is_matched + mine_is_matched);
170  unsigned mask = (unsigned)1 << (addr+4);
171 
172  m_OtherChipCancelbits[iother] = (CDL_config & mask) == mask;
173  }
174  }
175 
177 }
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
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:55
const L1MuGlobalMuonTrigger & m_gmt
int rowAny(int r) const
is any element in row r > 0 ? return index or -1
void run()
run Matcher
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.
virtual ~L1MuGMTCancelOutUnit()
destructor
L1MuGMTCancelOutUnit(const L1MuGlobalMuonTrigger &gmt, int id)
constructor
void reset()
clear Matcher
const L1MuGMTMatrix< bool > & pairM() const
return pair matrix
std::vector< bool > m_OtherChipCancelbits
static L1MuGMTRegCDLConfig * getRegCDLConfig()
int colAny(int c) const
is any element in column c > 0 ? return index or -1
void run()
run cancel-out unit
L1MuGMTDebugBlock * DebugBlockForFill() const
for debug: return the debug block (in order to fill it)