CMS 3D CMS Logo

L1MuGMTMatcher.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTMatcher
4 //
5 // Description: Matcher
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister 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 
31 #include <fstream>
32 #include <sstream>
33 
34 //-------------------------------
35 // Collaborating Class Headers --
36 //-------------------------------
37 
50 
52 
53 // --------------------------------
54 // class L1MuGMTMatcher
55 //---------------------------------
56 
57 //----------------
58 // Constructors --
59 //----------------
61  : m_gmt(gmt),
62  m_id(id),
63  first(MaxMatch),
64  second(MaxMatch),
65  matchQuality(MaxMatch, MaxMatch, 0),
66  pairMatrix(MaxMatch, MaxMatch, false) {
67  first.reserve(MaxMatch);
68  second.reserve(MaxMatch);
69 }
70 
71 //--------------
72 // Destructor --
73 //--------------
75 
76 //--------------
77 // Operations --
78 //--------------
79 
80 //
81 // run Muon Matcher
82 //
84  load();
85  match();
86 }
87 
88 //
89 // clear Matcher
90 //
93  pairMatrix.reset(false);
94 
95  for (unsigned i = 0; i < MaxMatch; i++) {
96  first[i] = nullptr;
97  second[i] = nullptr;
98  }
99 }
100 
101 //
102 // print matching results
103 //
105  edm::LogVerbatim("GMT_Matcher_info");
106  if (L1MuGMTConfig::Debug(4)) {
107  edm::LogVerbatim("GMT_Matcher_info") << "MATCH Quality : ";
109  }
110 
111  edm::LogVerbatim("GMT_Matcher_info") << "PAIR Matrix : ";
112  pairMatrix.print();
113 
114  edm::LogVerbatim("GMT_Matcher_info");
115 }
116 
117 //
118 // load Matcher (get data from data buffer)
119 //
121  // barrel matcher gets DTBX and barrel RPC muons
122  if (m_id == 0) {
123  for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
124  first[idt] = m_gmt.Data()->DTBXMuon(idt);
125  }
126  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++) {
127  second[irpc] = m_gmt.Data()->RPCMuon(irpc);
128  }
129  }
130 
131  // endcap matcher gets CSC and endcap RPC muons
132  if (m_id == 1) {
133  for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
134  first[icsc] = m_gmt.Data()->CSCMuon(icsc);
135  }
136  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++) {
137  second[irpc] = m_gmt.Data()->RPCMuon(irpc + 4);
138  }
139  }
140 
141  // matcher in DT/CSC cancel-out unit gets DTBX and CSC muons
142  if (m_id == 2) {
143  for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
144  first[idt] = m_gmt.Data()->DTBXMuon(idt);
145  }
146  for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
147  second[icsc] = m_gmt.Data()->CSCMuon(icsc);
148  }
149  }
150 
151  // matcher in CSC/DT cancel-out unit gets CSC and DTBX muons
152  if (m_id == 3) {
153  for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
154  first[icsc] = m_gmt.Data()->CSCMuon(icsc);
155  }
156  for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
157  second[idt] = m_gmt.Data()->DTBXMuon(idt);
158  }
159  }
160 
161  // bRPC/CSC gets barrel RPC and CSC muons
162  if (m_id == 4) {
163  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++) {
164  first[irpc] = m_gmt.Data()->RPCMuon(irpc);
165  }
166  for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
167  second[icsc] = m_gmt.Data()->CSCMuon(icsc);
168  }
169  }
170 
171  // bRPC/DT matcher gets forward RPC and DTBX muons
172  if (m_id == 5) {
173  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++) {
174  first[irpc] = m_gmt.Data()->RPCMuon(irpc + 4);
175  }
176  for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
177  second[idt] = m_gmt.Data()->DTBXMuon(idt);
178  }
179  }
180 }
181 
182 //
183 // match muons
184 //
186  L1MuGMTMatrix<bool> maxMatrix(MaxMatch, MaxMatch, false);
187  L1MuGMTMatrix<bool> disableMatrix(MaxMatch, MaxMatch, false);
188 
189  // loop over all combinations
190 
191  unsigned i, j;
192  for (i = 0; i < MaxMatch; i++)
193  for (j = 0; j < MaxMatch; j++)
194  matchQuality(i, j) = lookup_mq(i, j);
195 
196  // store in debug block
198 
199  // fill MAX matrix
200 
201  for (i = 0; i < MaxMatch; i++)
202  for (j = 0; j < MaxMatch; j++)
203  maxMatrix(i, j) = matchQuality.isMax(i, j) && (matchQuality(i, j) != 0);
204 
205  // fill disable matrix
206 
207  for (i = 0; i < MaxMatch; i++)
208  for (j = 0; j < MaxMatch; j++) {
209  for (unsigned i1 = 0; i1 < MaxMatch; i1++)
210  if (i1 != i)
211  disableMatrix(i, j) = disableMatrix(i, j) || maxMatrix(i1, j);
212 
213  for (unsigned j1 = 0; j1 < MaxMatch; j1++)
214  if (j1 != j)
215  disableMatrix(i, j) = disableMatrix(i, j) || maxMatrix(i, j1);
216  }
217 
218  // fill pair matrix
219 
220  for (i = 0; i < MaxMatch; i++) {
221  for (j = 0; j < MaxMatch; j++) {
222  bool max = true;
223 
224  for (unsigned i1 = 0; i1 < i; i1++) {
225  max = max && ((matchQuality(i, j) > matchQuality(i1, j)) || disableMatrix(i1, j));
226  }
227 
228  for (unsigned i1 = i + 1; i1 < MaxMatch; i1++) {
229  max = max && ((matchQuality(i, j) >= matchQuality(i1, j)) || disableMatrix(i1, j));
230  }
231 
232  for (unsigned j1 = 0; j1 < j; j1++) {
233  max = max && ((matchQuality(i, j) > matchQuality(i, j1)) || disableMatrix(i, j1));
234  }
235 
236  for (unsigned j1 = j + 1; j1 < MaxMatch; j1++) {
237  max = max && ((matchQuality(i, j) >= matchQuality(i, j1)) || disableMatrix(i, j1));
238  }
239 
240  pairMatrix(i, j) = max && (matchQuality(i, j) != 0);
241  }
242  }
243 
244  // store in debug block
246 }
247 
248 //
249 // compare eta and phi of two muons
250 //
252  bool empty1 = (first[i] != nullptr) ? first[i]->empty() : true;
253  bool empty2 = (second[j] != nullptr) ? second[j]->empty() : true;
254  if (empty1 || empty2)
255  return 0;
256 
257  //
258  // (1) calculate delta-phi (integer version)
259  //
260  unsigned phi1 = first[i]->phi_packed();
261  unsigned phi2 = second[j]->phi_packed();
262 
263  int delta_phi = ((phi1 - phi2 + 3 * 72) % 144) - 72;
264 
265  if (delta_phi < -3 || delta_phi > 3)
266  delta_phi = -4;
267 
268  L1MuSignedPacking<3> DPhiPacking;
269  unsigned delta_phi_packed = DPhiPacking.packedFromIdx(delta_phi);
270 
271  //
272  // (2) look-up delta-eta
273  //
274  unsigned eta1 = first[i]->eta_packed();
275  unsigned eta2 = second[j]->eta_packed();
276 
277  unsigned delta_eta_packed = 0;
278 
279  if (m_id == 0 || m_id == 1) { // main matching units
280  // first is dt/csc, second is rpc
281 
282  bool disable1 = L1MuGMTSortRankUnit::isDisabled(first[i]);
283  bool disable2 = L1MuGMTSortRankUnit::isDisabled(second[j]);
284  ;
285 
286  if (disable1 || disable2)
287  return 0;
288 
290  delta_eta_packed = de_lut->SpecificLookup_delta_eta(m_id, eta1, eta2);
291  } else { // overlap cancel-out matching units
292  // first is own chip, second is other chip
293  int idx1 = first[i]->type_idx();
294  int idx1_dcrr = (idx1 == 1) ? 2 : (idx1 == 2) ? 1 : idx1;
295 
296  int idx2 = second[j]->type_idx();
297  int idx2_dcrr = (idx2 == 1) ? 2 : (idx2 == 2) ? 1 : idx2;
298 
299  bool disable1 = L1MuGMTSortRankUnit::isDisabled(first[i]);
300 
302  bool disable2 =
303  dishot_lut->SpecificLookup_disable_hot(idx2_dcrr, second[j]->eta_packed(), second[j]->phi_packed()) == 1;
304 
305  if (disable1 || disable2)
306  return 0;
307 
308  // convert eta to 4-bit, first
310 
311  unsigned eta1_4bit = econv_lut->SpecificLookup_eta_ovl(idx1_dcrr, eta1);
312  unsigned eta2_4bit = econv_lut->SpecificLookup_eta_ovl(idx2_dcrr, eta2);
313 
314  // look up delta eta
316  delta_eta_packed = cou_de_lut->SpecificLookup_delta_eta(m_id - 2, eta1_4bit, eta2_4bit);
317  }
318 
319  //
320  // (3) look up match quality
321  //
323 
324  unsigned mq = mq_lut->SpecificLookup_mq(m_id, delta_eta_packed, delta_phi_packed);
325 
326  return mq;
327 }
L1MuGMTLFDisableHotLUT::SpecificLookup_disable_hot
unsigned SpecificLookup_disable_hot(int idx, unsigned eta, unsigned phi) const
specific lookup function for disable_hot
Definition: L1MuGMTLFDisableHotLUT.h:51
L1MuGMTConfig::MAXCSC
static const unsigned int MAXCSC
Definition: L1MuGMTConfig.h:85
L1MuGMTConfig::MAXRPCendcap
static const unsigned int MAXRPCendcap
Definition: L1MuGMTConfig.h:85
mps_fire.i
i
Definition: mps_fire.py:428
L1MuGMTLFOvlEtaConvLUT::SpecificLookup_eta_ovl
unsigned SpecificLookup_eta_ovl(int idx, unsigned eta6) const
specific lookup function for eta_ovl
Definition: L1MuGMTLFOvlEtaConvLUT.h:52
MessageLogger.h
L1MuGMTLFMatchQualLUT
Definition: L1MuGMTLFMatchQualLUT.h:38
funct::false
false
Definition: Factorize.h:29
L1MuGMTMatcher::pairMatrix
L1MuGMTMatrix< bool > pairMatrix
Definition: L1MuGMTMatcher.h:85
L1MuGMTMatcher::MaxMatch
static const unsigned int MaxMatch
Definition: L1MuGMTMatcher.h:43
L1MuGMTMatcher.h
L1MuPacking.h
L1MuGMTLFDisableHotLUT.h
L1MuGMTLFDisableHotLUT
Definition: L1MuGMTLFDisableHotLUT.h:38
L1MuGMTMatcher::match
void match()
Definition: L1MuGMTMatcher.cc:185
L1MuGMTLFCOUDeltaEtaLUT.h
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
L1MuGlobalMuonTrigger::DebugBlockForFill
L1MuGMTDebugBlock * DebugBlockForFill() const
for debug: return the debug block (in order to fill it)
Definition: L1MuGlobalMuonTrigger.h:101
L1MuGMTConfig::MAXRPCbarrel
static const unsigned int MAXRPCbarrel
Definition: L1MuGMTConfig.h:85
L1MuGMTMatcher::L1MuGMTMatcher
L1MuGMTMatcher(const L1MuGlobalMuonTrigger &gmt, int id)
constructor
Definition: L1MuGMTMatcher.cc:60
L1MuGMTMatcher::~L1MuGMTMatcher
virtual ~L1MuGMTMatcher()
destructor
Definition: L1MuGMTMatcher.cc:74
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
L1MuGMTMatcher::matchQuality
L1MuGMTMatrix< int > matchQuality
Definition: L1MuGMTMatcher.h:84
L1MuGMTMatcher::second
std::vector< const L1MuRegionalCand * > second
Definition: L1MuGMTMatcher.h:82
L1MuGMTConfig::MAXDTBX
static const unsigned int MAXDTBX
Definition: L1MuGMTConfig.h:85
L1MuGMTConfig::getLFDisableHotLUT
static L1MuGMTLFDisableHotLUT * getLFDisableHotLUT()
Definition: L1MuGMTConfig.h:150
L1MuGMTMatcher::m_gmt
const L1MuGlobalMuonTrigger & m_gmt
Definition: L1MuGMTMatcher.h:78
dqmdumpme.first
first
Definition: dqmdumpme.py:55
L1MuGMTConfig::getLFCOUDeltaEtaLUT
static L1MuGMTLFCOUDeltaEtaLUT * getLFCOUDeltaEtaLUT()
Definition: L1MuGMTConfig.h:148
L1MuGMTDebugBlock::SetPairMatrix
void SetPairMatrix(int idx, L1MuGMTMatrix< bool > pm)
Set pair matrices.
Definition: L1MuGMTDebugBlock.h:84
irpc
int irpc
Definition: CascadeWrapper.h:67
L1MuGMTLFMatchQualLUT.h
L1MuGMTMatcher::load
void load()
Definition: L1MuGMTMatcher.cc:120
L1MuGMTMatrix.h
L1MuGMTLFDeltaEtaLUT::SpecificLookup_delta_eta
unsigned SpecificLookup_delta_eta(int idx, unsigned eta_dtcsc, unsigned eta_rpc) const
specific lookup function for delta_eta
Definition: L1MuGMTLFDeltaEtaLUT.h:52
L1MuGlobalMuonTrigger
Definition: L1MuGlobalMuonTrigger.h:64
L1MuGMTLFOvlEtaConvLUT
Definition: L1MuGMTLFOvlEtaConvLUT.h:38
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9542
L1MuGMTLFMatchQualLUT::SpecificLookup_mq
unsigned SpecificLookup_mq(int idx, unsigned delta_eta, unsigned delta_phi) const
specific lookup function for mq
Definition: L1MuGMTLFMatchQualLUT.h:53
L1MuGMTLFCOUDeltaEtaLUT
Definition: L1MuGMTLFCOUDeltaEtaLUT.h:38
L1MuGMTConfig.h
L1MuGMTMatcher::first
std::vector< const L1MuRegionalCand * > first
Definition: L1MuGMTMatcher.h:81
L1MuGlobalMuonTrigger::Data
const L1MuGMTPSB * Data() const
return pointer to PSB
Definition: L1MuGlobalMuonTrigger.h:75
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9541
L1MuGMTConfig::getLFMatchQualLUT
static L1MuGMTLFMatchQualLUT * getLFMatchQualLUT()
Definition: L1MuGMTConfig.h:152
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
L1MuGMTLFDeltaEtaLUT.h
L1MuGMTSortRankUnit::isDisabled
static bool isDisabled(const L1MuRegionalCand *)
Diable bit.
Definition: L1MuGMTSortRankUnit.cc:87
L1MuGMTLFOvlEtaConvLUT.h
L1MuGMTLFDeltaEtaLUT
Definition: L1MuGMTLFDeltaEtaLUT.h:38
L1MuGMTDebugBlock.h
L1MuGMTMatcher::run
void run()
run Matcher
Definition: L1MuGMTMatcher.cc:83
L1MuGMTDebugBlock::SetMQMatrix
void SetMQMatrix(int idx, L1MuGMTMatrix< int > mqm)
Set match quality matrices.
Definition: L1MuGMTDebugBlock.h:87
L1MuGMTMatcher::print
void print()
print matching results
Definition: L1MuGMTMatcher.cc:104
L1MuGMTPSB.h
L1MuGMTLFCOUDeltaEtaLUT::SpecificLookup_delta_eta
unsigned SpecificLookup_delta_eta(int idx, unsigned eta1, unsigned eta2) const
specific lookup function for delta_eta
Definition: L1MuGMTLFCOUDeltaEtaLUT.h:52
L1MuGMTMatcher::reset
void reset()
clear Matcher
Definition: L1MuGMTMatcher.cc:91
L1MuGMTPSB::RPCMuon
const L1MuRegionalCand * RPCMuon(int index) const
get RPC muon
Definition: L1MuGMTPSB.cc:224
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
L1MuGMTSortRankUnit.h
L1MuGMTConfig::getLFOvlEtaConvLUT
static L1MuGMTLFOvlEtaConvLUT * getLFOvlEtaConvLUT()
Definition: L1MuGMTConfig.h:157
L1MuGMTMatrix::isMax
bool isMax(int r, int c) const
is the element (r,c) the max. entry in its row and column?
Definition: L1MuGMTMatrix.h:222
L1MuGMTPSB::CSCMuon
const L1MuRegionalCand * CSCMuon(int index) const
get CSC muon
Definition: L1MuGMTPSB.cc:238
L1MuGMTMatrix::print
void print() const
print matrix
Definition: L1MuGMTMatrix.h:290
HLT_FULL_cff.delta_phi
delta_phi
Definition: HLT_FULL_cff.py:11672
L1MuGMTMatrix::reset
void reset(T v)
reset all elements
Definition: L1MuGMTMatrix.h:148
L1MuGlobalMuonTrigger.h
L1MuGMTConfig::getLFDeltaEtaLUT
static L1MuGMTLFDeltaEtaLUT * getLFDeltaEtaLUT()
Definition: L1MuGMTConfig.h:149
L1MuSignedPacking
Definition: L1MuPacking.h:94
L1MuGMTMatcher::lookup_mq
int lookup_mq(int i, int j)
Definition: L1MuGMTMatcher.cc:251
L1MuGMTMatcher::m_id
int m_id
Definition: L1MuGMTMatcher.h:79
L1MuGMTPSB::DTBXMuon
const L1MuRegionalCand * DTBXMuon(int index) const
get DTBX muon
Definition: L1MuGMTPSB.cc:231
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
L1MuGMTConfig::Debug
static bool Debug()
Definition: L1MuGMTConfig.h:101
L1MuGMTMatrix< bool >
L1MuSignedPacking::packedFromIdx
unsigned packedFromIdx(int idx) const override
get the packed notation of a value, check range
Definition: L1MuPacking.h:104