CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/L1Trigger/GlobalMuonTrigger/src/L1MuGMTCancelOutUnit.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuGMTCancelOutUnit
00004 //
00005 //   Description: DT/CSC cancel-out unit
00006 //
00007 //
00008 //   $Date: 2007/04/10 09:59:19 $
00009 //   $Revision: 1.4 $
00010 //
00011 //   Author :
00012 //   H. Sakulin                CERN EP 
00013 //
00014 //   Migrated to CMSSW:
00015 //   I. Mikulec
00016 //
00017 //--------------------------------------------------
00018 
00019 //-----------------------
00020 // This Class's Header --
00021 //-----------------------
00022 
00023 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTCancelOutUnit.h"
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 
00029 #include <iostream>
00030 #include <iomanip>
00031 #include <cmath>
00032 #include <string>
00033 #include <sstream>
00034 
00035 //-------------------------------
00036 // Collaborating Class Headers --
00037 //-------------------------------
00038 
00039 #include "L1Trigger/GlobalMuonTrigger/interface/L1MuGlobalMuonTrigger.h"
00040 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
00041 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMatcher.h"
00042 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTMatrix.h"
00043 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTDebugBlock.h"
00044 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTReg.h"
00045 
00046 // --------------------------------
00047 //       class L1MuGMTCancelOutUnit
00048 //---------------------------------
00049 
00050 //----------------
00051 // Constructors --
00052 //----------------
00053 L1MuGMTCancelOutUnit::L1MuGMTCancelOutUnit(const L1MuGlobalMuonTrigger& gmt, int id) : 
00054                m_gmt(gmt), m_id(id), m_matcher(gmt, id+2), m_MyChipCancelbits(4), m_OtherChipCancelbits(4) {
00055 
00056 }
00057 
00058 //--------------
00059 // Destructor --
00060 //--------------
00061 L1MuGMTCancelOutUnit::~L1MuGMTCancelOutUnit() { 
00062 
00063   reset();
00064   
00065 }
00066 
00067 //--------------
00068 // Operations --
00069 //--------------
00070 
00071 //
00072 // run cancel-out unit
00073 //
00074 void L1MuGMTCancelOutUnit::run() {
00075 
00076   m_matcher.run();
00077   if (L1MuGMTConfig::Debug(3)) {
00078     edm::LogVerbatim("GMT_CancelOut_info") << "result of cancel-out matcher: ";
00079     m_matcher.print();
00080   }
00081   decide(); 
00082 }
00083 
00084 //
00085 // clear cancel-out unit
00086 //
00087 void L1MuGMTCancelOutUnit::reset() {
00088 
00089   m_matcher.reset();
00090   
00091   for ( int i = 0; i < 4; i++ ) {
00092     m_MyChipCancelbits[i] = false;
00093     m_OtherChipCancelbits[i] = false;
00094   }  
00095 }
00096 
00097 
00098 //
00099 // print cancel-out results
00100 //
00101 void L1MuGMTCancelOutUnit::print() {
00102 
00103   std::stringstream outmy;
00104   switch (m_id) {
00105     case 0 : outmy << "DT  " ; break;
00106     case 1 : outmy << "CSC " ; break;
00107     case 2 : outmy << "bRPC" ; break;
00108     case 3 : outmy << "fRPC" ; break;
00109   }
00110   outmy << "(my chip) cancel-bits : " ;
00111   for ( int i = 0; i < 4; i++ ) outmy << m_MyChipCancelbits[i] << "  ";
00112   edm::LogVerbatim("GMT_CancelOut_info") << outmy.str();
00113 
00114   std::stringstream outother;
00115   if (m_id==2 || m_id==3) {
00116     outother << (m_id==2 ? "CSC" : "DT" ) <<  "(other chip) cancel-bits : " ;
00117     for ( int i = 0; i < 4; i++ ) outother << m_OtherChipCancelbits[i] << "  ";
00118     outother << std::endl;
00119   }
00120   edm::LogVerbatim("GMT_CancelOut_info") << outother.str();
00121 }
00122 
00123 
00124 
00125 //
00126 // compute cancel decision
00127 //
00128 void L1MuGMTCancelOutUnit::decide() {
00129 
00130   // CancelDecisionLogic configuration register
00131   //
00132   unsigned CDL_config = L1MuGMTConfig::getRegCDLConfig()->getValue(m_id);
00133 
00134   // compute cancel decsion for my chip muons (mine)
00135 
00136   for(int imine=0; imine<4; imine++) {
00137     int idxother = m_matcher.pairM().rowAny(imine);
00138     if (idxother != -1) {
00139       int mine_is_matched = 0;
00140       switch(m_id) {
00141       case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(imine) != -1; break; //DT
00142       case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(imine) != -1; break; //CSC
00143       case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(imine) != -1; break; //bRPC
00144       case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(imine) != -1; break; //fRPC
00145       }
00146       int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(idxother) != -1;
00147 
00148       // calculate address of bit in CDL_config register
00149       unsigned addr = (unsigned) (2*mine_is_matched + other_is_matched);
00150       unsigned mask = (unsigned) 1 << addr;
00151       
00152       m_MyChipCancelbits[imine] = (CDL_config & mask) == mask;
00153     }
00154   }
00155 
00156   // compute cancel decsison for other chip muons (other)
00157 
00158   for(int iother=0; iother<4; iother++) {
00159     int idxmine = m_matcher.pairM().colAny(iother);
00160     if (idxmine != -1) {
00161       int mine_is_matched = 0;
00162       switch(m_id) {
00163       case 0: mine_is_matched = m_gmt.Matcher(0)->pairM().rowAny(idxmine) != -1; break; //DT
00164       case 1: mine_is_matched = m_gmt.Matcher(1)->pairM().rowAny(idxmine) != -1; break; //CSC
00165       case 2: mine_is_matched = m_gmt.Matcher(0)->pairM().colAny(idxmine) != -1; break; //bRPC
00166       case 3: mine_is_matched = m_gmt.Matcher(1)->pairM().colAny(idxmine) != -1; break; //fRPC
00167       }
00168       int other_is_matched = m_gmt.Matcher( 1-(m_id%2) )->pairM().rowAny(iother) != -1;
00169 
00170       // calculate address of bit in CDL_config register
00171       unsigned addr = (unsigned) (2*other_is_matched + mine_is_matched);
00172       unsigned mask = (unsigned)1 << (addr+4);
00173       
00174       m_OtherChipCancelbits[iother] = (CDL_config & mask) == mask;
00175     }
00176   }
00177 
00178   m_gmt.DebugBlockForFill()->SetCancelBits( m_id, m_MyChipCancelbits, m_OtherChipCancelbits) ; 
00179 }
00180 
00181   
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192