CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Date: 2007/03/23 18:51:35 $
9 // $Revision: 1.3 $
10 //
11 // Author :
12 // H. Sakulin CERN EP
13 //
14 // Migrated to CMSSW:
15 // I. Mikulec
16 //
17 //--------------------------------------------------
18 
19 //-----------------------
20 // This Class's Header --
21 //-----------------------
22 
24 
25 //---------------
26 // C++ Headers --
27 //---------------
28 
29 #include <iostream>
30 #include <iomanip>
31 #include <cmath>
32 #include <string>
33 #include <sstream>
34 
35 //-------------------------------
36 // Collaborating Class Headers --
37 //-------------------------------
38 
45 
46 // --------------------------------
47 // class L1MuGMTCancelOutUnit
48 //---------------------------------
49 
50 //----------------
51 // Constructors --
52 //----------------
54  m_gmt(gmt), m_id(id), m_matcher(gmt, id+2), m_MyChipCancelbits(4), m_OtherChipCancelbits(4) {
55 
56 }
57 
58 //--------------
59 // Destructor --
60 //--------------
62 
63  reset();
64 
65 }
66 
67 //--------------
68 // Operations --
69 //--------------
70 
71 //
72 // run cancel-out unit
73 //
75 
76  m_matcher.run();
77  if (L1MuGMTConfig::Debug(3)) {
78  edm::LogVerbatim("GMT_CancelOut_info") << "result of cancel-out matcher: ";
79  m_matcher.print();
80  }
81  decide();
82 }
83 
84 //
85 // clear cancel-out unit
86 //
88 
89  m_matcher.reset();
90 
91  for ( int i = 0; i < 4; i++ ) {
92  m_MyChipCancelbits[i] = false;
93  m_OtherChipCancelbits[i] = false;
94  }
95 }
96 
97 
98 //
99 // print cancel-out results
100 //
102 
103  std::stringstream outmy;
104  switch (m_id) {
105  case 0 : outmy << "DT " ; break;
106  case 1 : outmy << "CSC " ; break;
107  case 2 : outmy << "bRPC" ; break;
108  case 3 : outmy << "fRPC" ; break;
109  }
110  outmy << "(my chip) cancel-bits : " ;
111  for ( int i = 0; i < 4; i++ ) outmy << m_MyChipCancelbits[i] << " ";
112  edm::LogVerbatim("GMT_CancelOut_info") << outmy.str();
113 
114  std::stringstream outother;
115  if (m_id==2 || m_id==3) {
116  outother << (m_id==2 ? "CSC" : "DT" ) << "(other chip) cancel-bits : " ;
117  for ( int i = 0; i < 4; i++ ) outother << m_OtherChipCancelbits[i] << " ";
118  outother << std::endl;
119  }
120  edm::LogVerbatim("GMT_CancelOut_info") << outother.str();
121 }
122 
123 
124 
125 //
126 // compute cancel decision
127 //
129 
130  // CancelDecisionLogic configuration register
131  //
132  unsigned CDL_config = L1MuGMTConfig::getRegCDLConfig()->getValue(m_id);
133 
134  // compute cancel decsion for my chip muons (mine)
135 
136  for(int imine=0; imine<4; imine++) {
137  int idxother = m_matcher.pairM().rowAny(imine);
138  if (idxother != -1) {
139  int mine_is_matched = 0;
140  switch(m_id) {
141  case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(imine) != -1; break; //DT
142  case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(imine) != -1; break; //CSC
143  case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(imine) != -1; break; //bRPC
144  case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(imine) != -1; break; //fRPC
145  }
146  int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(idxother) != -1;
147 
148  // calculate address of bit in CDL_config register
149  unsigned addr = (unsigned) (2*mine_is_matched + other_is_matched);
150  unsigned mask = (unsigned) 1 << addr;
151 
152  m_MyChipCancelbits[imine] = (CDL_config & mask) == mask;
153  }
154  }
155 
156  // compute cancel decsison for other chip muons (other)
157 
158  for(int iother=0; iother<4; iother++) {
159  int idxmine = m_matcher.pairM().colAny(iother);
160  if (idxmine != -1) {
161  int mine_is_matched = 0;
162  switch(m_id) {
163  case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(idxmine) != -1; break; //DT
164  case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(idxmine) != -1; break; //CSC
165  case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(idxmine) != -1; break; //bRPC
166  case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(idxmine) != -1; break; //fRPC
167  }
168  int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(iother) != -1;
169 
170  // calculate address of bit in CDL_config register
171  unsigned addr = (unsigned) (2*other_is_matched + mine_is_matched);
172  unsigned mask = (unsigned)1 << (addr+4);
173 
174  m_OtherChipCancelbits[iother] = (CDL_config & mask) == mask;
175  }
176  }
177 
179 }
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
int i
Definition: DBlmapReader.cc:9
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:57
const L1MuGlobalMuonTrigger & m_gmt
int rowAny(int r) const
is any element in row r &gt; 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, std::vector< bool > mine, 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 &gt; 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)