CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1MuGMTMipIsoAU.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTMipIsoAU
4 //
5 // Description: GMT MIP & ISO bit assignment 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 <vector>
29 #include <cmath>
30 #include <string>
31 #include <sstream>
32 
33 //-------------------------------
34 // Collaborating Class Headers --
35 //-------------------------------
36 
42 
45 
46 // --------------------------------
47 // class L1MuGMTMipIsoAU
48 //---------------------------------
49 
50 //----------------
51 // Constructors --
52 //----------------
54  : m_gmt(gmt), m_id(id), m_muons(8), m_MIP(8), m_ISO(8), m_MIP_PPUs(8), m_MIP_EPUs(8), m_ISO_PPUs(8), m_ISO_EPUs(8) {
55  m_muons.reserve(8);
56  m_MIP.reserve(8);
57  m_ISO.reserve(8);
58 
59  // reserve MIP and ISO phi and eta projection units
60  m_MIP_PPUs.reserve(8);
61  m_MIP_EPUs.reserve(8);
62  m_ISO_PPUs.reserve(8);
63  m_ISO_EPUs.reserve(8);
64 
65  for (int i = 0; i < 8; i++) {
66  m_MIP_PPUs[i] = new L1MuGMTPhiProjectionUnit(*this, 16 * m_id + i);
67  m_MIP_EPUs[i] = new L1MuGMTEtaProjectionUnit(*this, 16 * m_id + i);
68 
69  m_ISO_PPUs[i] = new L1MuGMTPhiProjectionUnit(*this, 16 * m_id + 8 + i);
70  m_ISO_EPUs[i] = new L1MuGMTEtaProjectionUnit(*this, 16 * m_id + 8 + i);
71  }
72 }
73 
74 //--------------
75 // Destructor --
76 //--------------
78  reset();
79 
80  // delete MIP phi projection units
81  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
82  for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++)
83  delete *p_iter;
84  m_MIP_PPUs.clear();
85 
86  // delete ISO phi projection units
87  for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
88  delete *p_iter;
89  m_ISO_PPUs.clear();
90 
91  // delete MIP eta projection units
92  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
93  for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
94  delete *e_iter;
95  m_MIP_EPUs.clear();
96 
97  // delete ISO eta projection units
98  for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
99  delete *e_iter;
100  m_ISO_EPUs.clear();
101 }
102 
103 //--------------
104 // Operations --
105 //--------------
106 
107 //
108 // run MIP & ISO assignment unit
109 //
111  load();
112 
113  // run MIP phi projection units
114  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
115  for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++)
116  (*p_iter)->run();
117 
118  // run ISO phi projection units
119  for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
120  (*p_iter)->run();
121 
122  // run MIP eta projection units
123  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
124  for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
125  (*e_iter)->run();
126 
127  // run ISO eta projection units
128  for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
129  (*e_iter)->run();
130 
131  assignMIP();
132  assignISO();
133 }
134 
135 //
136 // reset MIP & ISO assignment unit
137 //
139  for (int i = 0; i < 8; i++) {
140  m_muons[i] = nullptr;
141  m_MIP[i] = false;
142  m_ISO[i] = false;
143  }
144 
145  // reset MIP phi projection units
146  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
147  for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++) {
148  (*p_iter)->reset();
149  }
150 
151  // reset ISO phi projection units
152  for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
153  (*p_iter)->reset();
154 
155  // reset MIP eta projection units
156  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
157  for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
158  (*e_iter)->reset();
159 
160  // reset ISO eta projection units
161  for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
162  (*e_iter)->reset();
163 }
164 
165 //
166 // print results of MIP & ISO assignment
167 //
169  std::stringstream outmip;
170  outmip << "Assigned MIP bits : ";
171  std::vector<bool>::const_iterator iter;
172  for (iter = m_MIP.begin(); iter != m_MIP.end(); iter++) {
173  outmip << (*iter) << " ";
174  }
175  edm::LogVerbatim("GMT_MipIso_info") << outmip.str();
176 
177  std::stringstream outiso;
178  outiso << "Assigned ISO bits : ";
179  for (iter = m_ISO.begin(); iter != m_ISO.end(); iter++) {
180  outiso << (*iter) << " ";
181  }
182  edm::LogVerbatim("GMT_MipIso_info") << outiso.str();
183 }
184 
185 //
186 // load MIP & ISO assignment unit (get data from PSB)
187 //
189  // barrel MIP & ISO assignment unit gets DTBX and barrel RPC muons
190  if (m_id == 0) {
191  for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
192  m_muons[idt] = m_gmt.Data()->DTBXMuon(idt);
193  }
194  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++) {
195  m_muons[irpc + 4] = m_gmt.Data()->RPCMuon(irpc);
196  }
197  }
198 
199  // endcap MIP & ISO assignment unit gets CSC and endcap RPC muons
200  if (m_id == 1) {
201  for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
202  m_muons[icsc] = m_gmt.Data()->CSCMuon(icsc);
203  }
204  for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++) {
205  m_muons[irpc + 4] = m_gmt.Data()->RPCMuon(irpc + 4);
206  }
207  }
208 }
209 
210 //
211 // run MIP assignment
212 //
214  // get MIP bits from PSB
215  const L1MuGMTMatrix<bool>& mip = m_gmt.Data()->mipBits();
216 
217  for (int imuon = 0; imuon < 8; imuon++)
218  if (m_muons[imuon] && !m_muons[imuon]->empty()) {
219  bool tmpMIP = false;
220 
221  for (int iphi = 0; iphi < 18; iphi++)
222  for (int ieta = 0; ieta < 14; ieta++) {
223  if (m_MIP_PPUs[imuon]->isSelected(iphi) && m_MIP_EPUs[imuon]->isSelected(ieta)) {
224  tmpMIP |= mip(ieta, iphi);
225  if (L1MuGMTConfig::Debug(3))
226  edm::LogVerbatim("GMT_MipIso_info")
227  << "L1MuGMTMipIsoAU::assignMIP() checking calo region phi=" << iphi << ", eta=" << ieta;
228  }
229  }
230  m_MIP[imuon] = tmpMIP;
231  m_gmt.DebugBlockForFill()->SetIsMIPISO(m_MIP_PPUs[imuon]->id(), tmpMIP ? 1 : 0);
232  }
233 }
234 
235 //
236 // run ISO assignment
237 //
239  // get isolation bits from PSB
240  const L1MuGMTMatrix<bool>& isol = m_gmt.Data()->isolBits();
241 
242  for (int imuon = 0; imuon < 8; imuon++)
243  if (m_muons[imuon] && !m_muons[imuon]->empty()) {
244  bool tmpISO = true;
245  bool any = false;
246 
247  for (int iphi = 0; iphi < 18; iphi++)
248  for (int ieta = 0; ieta < 14; ieta++) {
249  if (m_ISO_PPUs[imuon]->isSelected(iphi) && m_ISO_EPUs[imuon]->isSelected(ieta)) {
250  tmpISO &= isol(ieta, iphi);
251  any = true;
252  if (L1MuGMTConfig::Debug(3))
253  edm::LogVerbatim("GMT_MipIso_info")
254  << "L1MuGMTMipIsoAU::assignISO() checking calo region phi=" << iphi << ", eta=" << ieta;
255  }
256  }
257  if (any)
258  m_ISO[imuon] = tmpISO;
259  else
260  edm::LogWarning("MipISOProblem") << "L1MuGMTMipIsoAU::assignISO(): no calo region was checked!!";
261 
262  m_gmt.DebugBlockForFill()->SetIsMIPISO(m_ISO_PPUs[imuon]->id(), m_ISO[imuon] ? 1 : 0);
263  }
264 }
Log< level::Info, true > LogVerbatim
std::vector< L1MuGMTPhiProjectionUnit * > m_ISO_PPUs
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
void print() const
print results after MIP &amp; ISO bit assignment
std::vector< bool > m_ISO
void reset()
clear MIP &amp; ISO bit assignment unit
const L1MuRegionalCand * CSCMuon(int index) const
get CSC muon
Definition: L1MuGMTPSB.cc:238
void run()
run GMT MIP &amp; ISO bit assignment unit
L1MuGMTMipIsoAU(const L1MuGlobalMuonTrigger &gmt, int id)
constructor
static bool Debug()
std::vector< bool > m_MIP
const L1MuGMTPSB * Data() const
return pointer to PSB
const L1MuRegionalCand * RPCMuon(int index) const
get RPC muon
Definition: L1MuGMTPSB.cc:224
int irpc
static const unsigned int MAXCSC
Definition: L1MuGMTConfig.h:85
static const unsigned int MAXDTBX
Definition: L1MuGMTConfig.h:85
static const unsigned int MAXRPCendcap
Definition: L1MuGMTConfig.h:85
m_id("(unknown)")
std::vector< const L1MuRegionalCand * > m_muons
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
std::vector< L1MuGMTPhiProjectionUnit * > m_MIP_PPUs
const L1MuRegionalCand * DTBXMuon(int index) const
get DTBX muon
Definition: L1MuGMTPSB.cc:231
const L1MuGlobalMuonTrigger & m_gmt
void SetIsMIPISO(int idx, unsigned ismipiso)
Set MIP/ISO bits for current bx.
static const unsigned int MAXRPCbarrel
Definition: L1MuGMTConfig.h:85
Log< level::Warning, false > LogWarning
std::vector< L1MuGMTEtaProjectionUnit * > m_ISO_EPUs
L1MuGMTDebugBlock * DebugBlockForFill() const
for debug: return the debug block (in order to fill it)
const L1MuGMTMatrix< bool > & isolBits() const
return isolation bits
Definition: L1MuGMTPSB.h:88
virtual ~L1MuGMTMipIsoAU()
destructor
std::vector< L1MuGMTEtaProjectionUnit * > m_MIP_EPUs
const L1MuGMTMatrix< bool > & mipBits() const
return minimum ionizing bits
Definition: L1MuGMTPSB.h:91