Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:57

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuGMTMipIsoAU
0004 //
0005 //   Description:  GMT MIP & ISO bit assignment unit
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   H. Sakulin                CERN EP
0011 //
0012 //   Migrated to CMSSW:
0013 //   I. Mikulec
0014 //
0015 //--------------------------------------------------
0016 
0017 //-----------------------
0018 // This Class's Header --
0019 //-----------------------
0020 
0021 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMipIsoAU.h"
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <iostream>
0028 #include <vector>
0029 #include <cmath>
0030 #include <string>
0031 #include <sstream>
0032 
0033 //-------------------------------
0034 // Collaborating Class Headers --
0035 //-------------------------------
0036 
0037 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
0038 #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h"
0039 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPSB.h"
0040 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTPhiProjectionUnit.h"
0041 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTEtaProjectionUnit.h"
0042 
0043 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTDebugBlock.h"
0044 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0045 
0046 // --------------------------------
0047 //       class L1MuGMTMipIsoAU
0048 //---------------------------------
0049 
0050 //----------------
0051 // Constructors --
0052 //----------------
0053 L1MuGMTMipIsoAU::L1MuGMTMipIsoAU(const L1MuGlobalMuonTrigger& gmt, int id)
0054     : 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) {
0055   m_muons.reserve(8);
0056   m_MIP.reserve(8);
0057   m_ISO.reserve(8);
0058 
0059   // reserve MIP and ISO phi and eta projection units
0060   m_MIP_PPUs.reserve(8);
0061   m_MIP_EPUs.reserve(8);
0062   m_ISO_PPUs.reserve(8);
0063   m_ISO_EPUs.reserve(8);
0064 
0065   for (int i = 0; i < 8; i++) {
0066     m_MIP_PPUs[i] = new L1MuGMTPhiProjectionUnit(*this, 16 * m_id + i);
0067     m_MIP_EPUs[i] = new L1MuGMTEtaProjectionUnit(*this, 16 * m_id + i);
0068 
0069     m_ISO_PPUs[i] = new L1MuGMTPhiProjectionUnit(*this, 16 * m_id + 8 + i);
0070     m_ISO_EPUs[i] = new L1MuGMTEtaProjectionUnit(*this, 16 * m_id + 8 + i);
0071   }
0072 }
0073 
0074 //--------------
0075 // Destructor --
0076 //--------------
0077 L1MuGMTMipIsoAU::~L1MuGMTMipIsoAU() {
0078   reset();
0079 
0080   // delete MIP phi projection units
0081   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
0082   for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++)
0083     delete *p_iter;
0084   m_MIP_PPUs.clear();
0085 
0086   // delete ISO phi projection units
0087   for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
0088     delete *p_iter;
0089   m_ISO_PPUs.clear();
0090 
0091   // delete MIP eta projection units
0092   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
0093   for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
0094     delete *e_iter;
0095   m_MIP_EPUs.clear();
0096 
0097   // delete ISO eta projection units
0098   for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
0099     delete *e_iter;
0100   m_ISO_EPUs.clear();
0101 }
0102 
0103 //--------------
0104 // Operations --
0105 //--------------
0106 
0107 //
0108 // run MIP & ISO assignment unit
0109 //
0110 void L1MuGMTMipIsoAU::run() {
0111   load();
0112 
0113   // run MIP phi projection units
0114   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
0115   for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++)
0116     (*p_iter)->run();
0117 
0118   // run ISO phi projection units
0119   for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
0120     (*p_iter)->run();
0121 
0122   // run MIP eta projection units
0123   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
0124   for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
0125     (*e_iter)->run();
0126 
0127   // run ISO eta projection units
0128   for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
0129     (*e_iter)->run();
0130 
0131   assignMIP();
0132   assignISO();
0133 }
0134 
0135 //
0136 // reset MIP & ISO assignment unit
0137 //
0138 void L1MuGMTMipIsoAU::reset() {
0139   for (int i = 0; i < 8; i++) {
0140     m_muons[i] = nullptr;
0141     m_MIP[i] = false;
0142     m_ISO[i] = false;
0143   }
0144 
0145   // reset MIP phi projection units
0146   std::vector<L1MuGMTPhiProjectionUnit*>::iterator p_iter;
0147   for (p_iter = m_MIP_PPUs.begin(); p_iter != m_MIP_PPUs.end(); p_iter++) {
0148     (*p_iter)->reset();
0149   }
0150 
0151   // reset ISO phi projection units
0152   for (p_iter = m_ISO_PPUs.begin(); p_iter != m_ISO_PPUs.end(); p_iter++)
0153     (*p_iter)->reset();
0154 
0155   // reset MIP eta projection units
0156   std::vector<L1MuGMTEtaProjectionUnit*>::iterator e_iter;
0157   for (e_iter = m_MIP_EPUs.begin(); e_iter != m_MIP_EPUs.end(); e_iter++)
0158     (*e_iter)->reset();
0159 
0160   // reset ISO eta projection units
0161   for (e_iter = m_ISO_EPUs.begin(); e_iter != m_ISO_EPUs.end(); e_iter++)
0162     (*e_iter)->reset();
0163 }
0164 
0165 //
0166 // print results of MIP & ISO assignment
0167 //
0168 void L1MuGMTMipIsoAU::print() const {
0169   std::stringstream outmip;
0170   outmip << "Assigned MIP bits : ";
0171   std::vector<bool>::const_iterator iter;
0172   for (iter = m_MIP.begin(); iter != m_MIP.end(); iter++) {
0173     outmip << (*iter) << "  ";
0174   }
0175   edm::LogVerbatim("GMT_MipIso_info") << outmip.str();
0176 
0177   std::stringstream outiso;
0178   outiso << "Assigned ISO bits : ";
0179   for (iter = m_ISO.begin(); iter != m_ISO.end(); iter++) {
0180     outiso << (*iter) << "  ";
0181   }
0182   edm::LogVerbatim("GMT_MipIso_info") << outiso.str();
0183 }
0184 
0185 //
0186 // load MIP & ISO assignment unit (get data from PSB)
0187 //
0188 void L1MuGMTMipIsoAU::load() {
0189   // barrel MIP & ISO assignment unit gets DTBX and barrel RPC muons
0190   if (m_id == 0) {
0191     for (unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++) {
0192       m_muons[idt] = m_gmt.Data()->DTBXMuon(idt);
0193     }
0194     for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++) {
0195       m_muons[irpc + 4] = m_gmt.Data()->RPCMuon(irpc);
0196     }
0197   }
0198 
0199   // endcap MIP & ISO assignment unit gets CSC and endcap RPC muons
0200   if (m_id == 1) {
0201     for (unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++) {
0202       m_muons[icsc] = m_gmt.Data()->CSCMuon(icsc);
0203     }
0204     for (unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++) {
0205       m_muons[irpc + 4] = m_gmt.Data()->RPCMuon(irpc + 4);
0206     }
0207   }
0208 }
0209 
0210 //
0211 // run MIP assignment
0212 //
0213 void L1MuGMTMipIsoAU::assignMIP() {
0214   // get MIP bits from PSB
0215   const L1MuGMTMatrix<bool>& mip = m_gmt.Data()->mipBits();
0216 
0217   for (int imuon = 0; imuon < 8; imuon++)
0218     if (m_muons[imuon] && !m_muons[imuon]->empty()) {
0219       bool tmpMIP = false;
0220 
0221       for (int iphi = 0; iphi < 18; iphi++)
0222         for (int ieta = 0; ieta < 14; ieta++) {
0223           if (m_MIP_PPUs[imuon]->isSelected(iphi) && m_MIP_EPUs[imuon]->isSelected(ieta)) {
0224             tmpMIP |= mip(ieta, iphi);
0225             if (L1MuGMTConfig::Debug(3))
0226               edm::LogVerbatim("GMT_MipIso_info")
0227                   << "L1MuGMTMipIsoAU::assignMIP() checking calo region phi=" << iphi << ", eta=" << ieta;
0228           }
0229         }
0230       m_MIP[imuon] = tmpMIP;
0231       m_gmt.DebugBlockForFill()->SetIsMIPISO(m_MIP_PPUs[imuon]->id(), tmpMIP ? 1 : 0);
0232     }
0233 }
0234 
0235 //
0236 // run ISO assignment
0237 //
0238 void L1MuGMTMipIsoAU::assignISO() {
0239   // get isolation bits from PSB
0240   const L1MuGMTMatrix<bool>& isol = m_gmt.Data()->isolBits();
0241 
0242   for (int imuon = 0; imuon < 8; imuon++)
0243     if (m_muons[imuon] && !m_muons[imuon]->empty()) {
0244       bool tmpISO = true;
0245       bool any = false;
0246 
0247       for (int iphi = 0; iphi < 18; iphi++)
0248         for (int ieta = 0; ieta < 14; ieta++) {
0249           if (m_ISO_PPUs[imuon]->isSelected(iphi) && m_ISO_EPUs[imuon]->isSelected(ieta)) {
0250             tmpISO &= isol(ieta, iphi);
0251             any = true;
0252             if (L1MuGMTConfig::Debug(3))
0253               edm::LogVerbatim("GMT_MipIso_info")
0254                   << "L1MuGMTMipIsoAU::assignISO() checking calo region phi=" << iphi << ", eta=" << ieta;
0255           }
0256         }
0257       if (any)
0258         m_ISO[imuon] = tmpISO;
0259       else
0260         edm::LogWarning("MipISOProblem") << "L1MuGMTMipIsoAU::assignISO(): no calo region was checked!!";
0261 
0262       m_gmt.DebugBlockForFill()->SetIsMIPISO(m_ISO_PPUs[imuon]->id(), m_ISO[imuon] ? 1 : 0);
0263     }
0264 }