Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:13

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuGMTCancelOutUnit
0004 //
0005 //   Description: DT/CSC cancel-out 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/L1MuGMTCancelOutUnit.h"
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <iostream>
0028 #include <iomanip>
0029 #include <cmath>
0030 #include <string>
0031 #include <sstream>
0032 
0033 //-------------------------------
0034 // Collaborating Class Headers --
0035 //-------------------------------
0036 
0037 #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h"
0038 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
0039 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMatcher.h"
0040 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMatrix.h"
0041 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTDebugBlock.h"
0042 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTReg.h"
0043 
0044 // --------------------------------
0045 //       class L1MuGMTCancelOutUnit
0046 //---------------------------------
0047 
0048 //----------------
0049 // Constructors --
0050 //----------------
0051 L1MuGMTCancelOutUnit::L1MuGMTCancelOutUnit(const L1MuGlobalMuonTrigger& gmt, int id)
0052     : m_gmt(gmt), m_id(id), m_matcher(gmt, id + 2), m_MyChipCancelbits(4), m_OtherChipCancelbits(4) {}
0053 
0054 //--------------
0055 // Destructor --
0056 //--------------
0057 L1MuGMTCancelOutUnit::~L1MuGMTCancelOutUnit() { reset(); }
0058 
0059 //--------------
0060 // Operations --
0061 //--------------
0062 
0063 //
0064 // run cancel-out unit
0065 //
0066 void L1MuGMTCancelOutUnit::run() {
0067   m_matcher.run();
0068   if (L1MuGMTConfig::Debug(3)) {
0069     edm::LogVerbatim("GMT_CancelOut_info") << "result of cancel-out matcher: ";
0070     m_matcher.print();
0071   }
0072   decide();
0073 }
0074 
0075 //
0076 // clear cancel-out unit
0077 //
0078 void L1MuGMTCancelOutUnit::reset() {
0079   m_matcher.reset();
0080 
0081   for (int i = 0; i < 4; i++) {
0082     m_MyChipCancelbits[i] = false;
0083     m_OtherChipCancelbits[i] = false;
0084   }
0085 }
0086 
0087 //
0088 // print cancel-out results
0089 //
0090 void L1MuGMTCancelOutUnit::print() {
0091   std::stringstream outmy;
0092   switch (m_id) {
0093     case 0:
0094       outmy << "DT  ";
0095       break;
0096     case 1:
0097       outmy << "CSC ";
0098       break;
0099     case 2:
0100       outmy << "bRPC";
0101       break;
0102     case 3:
0103       outmy << "fRPC";
0104       break;
0105   }
0106   outmy << "(my chip) cancel-bits : ";
0107   for (int i = 0; i < 4; i++)
0108     outmy << m_MyChipCancelbits[i] << "  ";
0109   edm::LogVerbatim("GMT_CancelOut_info") << outmy.str();
0110 
0111   std::stringstream outother;
0112   if (m_id == 2 || m_id == 3) {
0113     outother << (m_id == 2 ? "CSC" : "DT") << "(other chip) cancel-bits : ";
0114     for (int i = 0; i < 4; i++)
0115       outother << m_OtherChipCancelbits[i] << "  ";
0116     outother << std::endl;
0117   }
0118   edm::LogVerbatim("GMT_CancelOut_info") << outother.str();
0119 }
0120 
0121 //
0122 // compute cancel decision
0123 //
0124 void L1MuGMTCancelOutUnit::decide() {
0125   // CancelDecisionLogic configuration register
0126   //
0127   unsigned CDL_config = L1MuGMTConfig::getRegCDLConfig()->getValue(m_id);
0128 
0129   // compute cancel decsion for my chip muons (mine)
0130 
0131   for (int imine = 0; imine < 4; imine++) {
0132     int idxother = m_matcher.pairM().rowAny(imine);
0133     if (idxother != -1) {
0134       int mine_is_matched = 0;
0135       switch (m_id) {
0136         case 0:
0137           mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(imine) != -1;
0138           break;  //DT
0139         case 1:
0140           mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(imine) != -1;
0141           break;  //CSC
0142         case 2:
0143           mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(imine) != -1;
0144           break;  //bRPC
0145         case 3:
0146           mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(imine) != -1;
0147           break;  //fRPC
0148       }
0149       int other_is_matched = m_gmt.Matcher(1 - (m_id % 2))->pairM().rowAny(idxother) != -1;
0150 
0151       // calculate address of bit in CDL_config register
0152       unsigned addr = (unsigned)(2 * mine_is_matched + other_is_matched);
0153       unsigned mask = (unsigned)1 << addr;
0154 
0155       m_MyChipCancelbits[imine] = (CDL_config & mask) == mask;
0156     }
0157   }
0158 
0159   // compute cancel decsison for other chip muons (other)
0160 
0161   for (int iother = 0; iother < 4; iother++) {
0162     int idxmine = m_matcher.pairM().colAny(iother);
0163     if (idxmine != -1) {
0164       int mine_is_matched = 0;
0165       switch (m_id) {
0166         case 0:
0167           mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(idxmine) != -1;
0168           break;  //DT
0169         case 1:
0170           mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(idxmine) != -1;
0171           break;  //CSC
0172         case 2:
0173           mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(idxmine) != -1;
0174           break;  //bRPC
0175         case 3:
0176           mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(idxmine) != -1;
0177           break;  //fRPC
0178       }
0179       int other_is_matched = m_gmt.Matcher(1 - (m_id % 2))->pairM().rowAny(iother) != -1;
0180 
0181       // calculate address of bit in CDL_config register
0182       unsigned addr = (unsigned)(2 * other_is_matched + mine_is_matched);
0183       unsigned mask = (unsigned)1 << (addr + 4);
0184 
0185       m_OtherChipCancelbits[iother] = (CDL_config & mask) == mask;
0186     }
0187   }
0188 
0189   m_gmt.DebugBlockForFill()->SetCancelBits(m_id, m_MyChipCancelbits, m_OtherChipCancelbits);
0190 }