CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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),
55  m_MIP_PPUs(8), m_MIP_EPUs(8), m_ISO_PPUs(8), m_ISO_EPUs(8) {
56 
57  m_muons.reserve(8);
58  m_MIP.reserve(8);
59  m_ISO.reserve(8);
60 
61  // reserve MIP and ISO phi and eta projection units
62  m_MIP_PPUs.reserve(8);
63  m_MIP_EPUs.reserve(8);
64  m_ISO_PPUs.reserve(8);
65  m_ISO_EPUs.reserve(8);
66 
67  for (int i=0; i<8; i++) {
68  m_MIP_PPUs[i]=new L1MuGMTPhiProjectionUnit (*this, 16 * m_id + i) ;
69  m_MIP_EPUs[i]=new L1MuGMTEtaProjectionUnit (*this, 16 * m_id + i) ;
70 
71  m_ISO_PPUs[i]=new L1MuGMTPhiProjectionUnit (*this, 16 * m_id + 8 + i) ;
72  m_ISO_EPUs[i]=new L1MuGMTEtaProjectionUnit (*this, 16 * m_id + 8 + i) ;
73  }
74 
75 }
76 
77 //--------------
78 // Destructor --
79 //--------------
81 
82  reset();
83 
84  // delete MIP phi projection units
85  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
86  for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ )
87  delete *p_iter;
88  m_MIP_PPUs.clear();
89 
90  // delete ISO phi projection units
91  for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
92  delete *p_iter;
93  m_ISO_PPUs.clear();
94 
95  // delete MIP eta projection units
96  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
97  for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
98  delete *e_iter;
99  m_MIP_EPUs.clear();
100 
101  // delete ISO eta projection units
102  for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
103  delete *e_iter;
104  m_ISO_EPUs.clear();
105 }
106 
107 //--------------
108 // Operations --
109 //--------------
110 
111 //
112 // run MIP & ISO assignment unit
113 //
115 
116  load();
117 
118  // run MIP phi projection units
119  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
120  for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ )
121  (*p_iter)->run();
122 
123  // run ISO phi projection units
124  for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
125  (*p_iter)->run();
126 
127  // run MIP eta projection units
128  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
129  for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
130  (*e_iter)->run();
131 
132  // run ISO eta projection units
133  for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
134  (*e_iter)->run();
135 
136  assignMIP();
137  assignISO();
138 }
139 
140 
141 //
142 // reset MIP & ISO assignment unit
143 //
145 
146  for ( int i = 0; i < 8; i++ ) {
147  m_muons[i] = 0;
148  m_MIP[i] = false;
149  m_ISO[i] = false;
150  }
151 
152  // reset MIP phi projection units
153  std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
154  for ( p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++ ) {
155  (*p_iter)->reset();
156  }
157 
158  // reset ISO phi projection units
159  for ( p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++ )
160  (*p_iter)->reset();
161 
162  // reset MIP eta projection units
163  std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
164  for ( e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++ )
165  (*e_iter)->reset();
166 
167  // reset ISO eta projection units
168  for ( e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++ )
169  (*e_iter)->reset();
170 }
171 
172 
173 //
174 // print results of MIP & ISO assignment
175 //
177 
178  std::stringstream outmip;
179  outmip << "Assigned MIP bits : ";
180  std::vector<bool>::const_iterator iter;
181  for ( iter = m_MIP.begin(); iter != m_MIP.end(); iter++ ) {
182  outmip << (*iter) << " ";
183  }
184  edm::LogVerbatim("GMT_MipIso_info") << outmip.str();
185 
186  std::stringstream outiso;
187  outiso << "Assigned ISO bits : ";
188  for ( iter = m_ISO.begin(); iter != m_ISO.end(); iter++ ) {
189  outiso << (*iter) << " ";
190  }
191  edm::LogVerbatim("GMT_MipIso_info") << outiso.str();
192 }
193 
194 
195 //
196 // load MIP & ISO assignment unit (get data from PSB)
197 //
199 
200  // barrel MIP & ISO assignment unit gets DTBX and barrel RPC muons
201  if ( m_id == 0 ) {
202  for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
203  m_muons[idt] = m_gmt.Data()->DTBXMuon(idt);
204  }
205  for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++ ) {
206  m_muons[irpc+4] = m_gmt.Data()->RPCMuon(irpc);
207  }
208  }
209 
210  // endcap MIP & ISO assignment unit gets CSC and endcap RPC muons
211  if ( m_id == 1 ) {
212  for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
213  m_muons[icsc] = m_gmt.Data()->CSCMuon(icsc);
214  }
215  for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++ ) {
216  m_muons[irpc+4] = m_gmt.Data()->RPCMuon(irpc+4);
217  }
218  }
219 
220 }
221 
222 //
223 // run MIP assignment
224 //
226 
227  // get MIP bits from PSB
228  const L1MuGMTMatrix<bool>& mip = m_gmt.Data()->mipBits();
229 
230  for ( int imuon = 0; imuon < 8; imuon++ )
231  if (m_muons[imuon] && !m_muons[imuon]->empty() ) {
232  bool tmpMIP=false;
233 
234  for ( int iphi = 0; iphi < 18; iphi++ )
235  for ( int ieta = 0; ieta < 14; ieta++ ) {
236  if (m_MIP_PPUs[imuon]->isSelected(iphi) &&
237  m_MIP_EPUs[imuon]->isSelected(ieta) ) {
238  tmpMIP |= mip(ieta, iphi);
239  if ( L1MuGMTConfig::Debug(3) ) edm::LogVerbatim("GMT_MipIso_info") << "L1MuGMTMipIsoAU::assignMIP() checking calo region phi=" <<
240  iphi << ", eta=" << ieta;
241  }
242  }
243  m_MIP[imuon] = tmpMIP;
244  m_gmt.DebugBlockForFill()->SetIsMIPISO( m_MIP_PPUs[imuon]->id(), tmpMIP?1:0) ;
245  }
246 }
247 
248 
249 //
250 // run ISO assignment
251 //
253 
254  // get isolation bits from PSB
255  const L1MuGMTMatrix<bool>& isol = m_gmt.Data()->isolBits();
256 
257  for ( int imuon = 0; imuon < 8; imuon++ )
258  if (m_muons[imuon] && !m_muons[imuon]->empty() ) {
259  bool tmpISO=true;
260  bool any=false;
261 
262  for ( int iphi = 0; iphi < 18; iphi++ )
263  for ( int ieta = 0; ieta < 14; ieta++ ) {
264  if (m_ISO_PPUs[imuon]->isSelected(iphi) &&
265  m_ISO_EPUs[imuon]->isSelected(ieta) ) {
266  tmpISO &= isol(ieta, iphi);
267  any = true;
268  if ( L1MuGMTConfig::Debug(3) ) edm::LogVerbatim("GMT_MipIso_info") << "L1MuGMTMipIsoAU::assignISO() checking calo region phi=" <<
269  iphi << ", eta=" << ieta;
270  }
271  }
272  if (any) m_ISO[imuon] = tmpISO;
273  else edm::LogWarning("MipISOProblem") << "L1MuGMTMipIsoAU::assignISO(): no calo region was checked!!";
274 
275  m_gmt.DebugBlockForFill()->SetIsMIPISO( m_ISO_PPUs[imuon]->id(), m_ISO[imuon]?1:0) ;
276  }
277 
278 }
279 
280 
281 
282 
283 
284 
285 
int i
Definition: DBlmapReader.cc:9
std::vector< L1MuGMTPhiProjectionUnit * > m_ISO_PPUs
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
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:250
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:230
int irpc
static const unsigned int MAXCSC
Definition: L1MuGMTConfig.h:89
static const unsigned int MAXDTBX
Definition: L1MuGMTConfig.h:89
static const unsigned int MAXRPCendcap
Definition: L1MuGMTConfig.h:88
std::vector< const L1MuRegionalCand * > m_muons
std::vector< L1MuGMTPhiProjectionUnit * > m_MIP_PPUs
const L1MuRegionalCand * DTBXMuon(int index) const
get DTBX muon
Definition: L1MuGMTPSB.cc:240
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:88
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:89
virtual ~L1MuGMTMipIsoAU()
destructor
std::vector< L1MuGMTEtaProjectionUnit * > m_MIP_EPUs
const L1MuGMTMatrix< bool > & mipBits() const
return minimum ionizing bits
Definition: L1MuGMTPSB.h:92