CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes

L1MuGMTMatcher Class Reference

#include <L1MuGMTMatcher.h>

List of all members.

Public Member Functions

int id () const
 return identifier
 L1MuGMTMatcher (const L1MuGlobalMuonTrigger &gmt, int id)
 constructor
bool pairM (int i, int j) const
 return pair matrix
const L1MuGMTMatrix< bool > & pairM () const
 return pair matrix
void print ()
 print matching results
void reset ()
 clear Matcher
void run ()
 run Matcher
virtual ~L1MuGMTMatcher ()
 destructor

Static Public Attributes

static const unsigned int MaxMatch = 4

Private Member Functions

void load ()
int lookup_mq (int i, int j)
void match ()

Private Attributes

std::vector< const
L1MuRegionalCand * > 
first
const L1MuGlobalMuonTriggerm_gmt
int m_id
L1MuGMTMatrix< int > matchQuality
L1MuGMTMatrix< bool > pairMatrix
std::vector< const
L1MuRegionalCand * > 
second

Detailed Description

Matching Unit in the L1 Global Muon Trigger.

Definition at line 43 of file L1MuGMTMatcher.h.


Constructor & Destructor Documentation

L1MuGMTMatcher::L1MuGMTMatcher ( const L1MuGlobalMuonTrigger gmt,
int  id 
)

constructor

Definition at line 62 of file L1MuGMTMatcher.cc.

References first, MaxMatch, and second.

L1MuGMTMatcher::~L1MuGMTMatcher ( ) [virtual]

destructor

Definition at line 74 of file L1MuGMTMatcher.cc.

References reset().

                                { 

  reset();
  
}

Member Function Documentation

int L1MuGMTMatcher::id ( void  ) const [inline]

return identifier

Definition at line 65 of file L1MuGMTMatcher.h.

References m_id.

{ return m_id; } 
void L1MuGMTMatcher::load ( ) [private]

Definition at line 132 of file L1MuGMTMatcher.cc.

References L1MuGMTPSB::CSCMuon(), L1MuGlobalMuonTrigger::Data(), L1MuGMTPSB::DTBXMuon(), first, irpc, m_gmt, m_id, MAXCSC, MAXDTBX, L1MuGMTConfig::MAXRPCbarrel, L1MuGMTConfig::MAXRPCendcap, L1MuGMTPSB::RPCMuon(), and second.

Referenced by run().

                          {

  // barrel matcher gets DTBX and barrel RPC muons
  if ( m_id == 0 ) {
    for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
      first[idt] = m_gmt.Data()->DTBXMuon(idt);
    }
    for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++ ) {
      second[irpc] = m_gmt.Data()->RPCMuon(irpc);
    }
  }
  
  // endcap matcher gets CSC and endcap RPC muons
  if ( m_id == 1 ) {  
    for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
      first[icsc] = m_gmt.Data()->CSCMuon(icsc);
    }
    for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++ ) {
      second[irpc] = m_gmt.Data()->RPCMuon(irpc+4);
    }
  }

  // matcher in DT/CSC cancel-out unit gets DTBX and CSC muons
  if ( m_id == 2 ) {
    for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
      first[idt] = m_gmt.Data()->DTBXMuon(idt);
    }
    for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
      second[icsc] = m_gmt.Data()->CSCMuon(icsc);
    }
  }

  // matcher in CSC/DT cancel-out unit gets CSC and DTBX muons
  if ( m_id==3 ) {
    for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
      first[icsc] = m_gmt.Data()->CSCMuon(icsc);
    }
    for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
      second[idt] = m_gmt.Data()->DTBXMuon(idt);
    }
  }

  // bRPC/CSC gets barrel RPC and CSC muons
  if ( m_id == 4 ) {  
    for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCbarrel; irpc++ ) {
      first[irpc] = m_gmt.Data()->RPCMuon(irpc);
    }
    for ( unsigned icsc = 0; icsc < L1MuGMTConfig::MAXCSC; icsc++ ) {
      second[icsc] = m_gmt.Data()->CSCMuon(icsc);
    }
  }

  // bRPC/DT matcher gets forward RPC and DTBX muons
  if ( m_id == 5 ) {
    for ( unsigned irpc = 0; irpc < L1MuGMTConfig::MAXRPCendcap; irpc++ ) {
      first[irpc] = m_gmt.Data()->RPCMuon(irpc+4);
    }
    for ( unsigned idt = 0; idt < L1MuGMTConfig::MAXDTBX; idt++ ) {
      second[idt] = m_gmt.Data()->DTBXMuon(idt);
    }
  }
}
int L1MuGMTMatcher::lookup_mq ( int  i,
int  j 
) [private]

Definition at line 273 of file L1MuGMTMatcher.cc.

References kinem::delta_phi(), relativeConstraints::empty, first, L1MuGMTConfig::getLFCOUDeltaEtaLUT(), L1MuGMTConfig::getLFDeltaEtaLUT(), L1MuGMTConfig::getLFDisableHotLUT(), L1MuGMTConfig::getLFMatchQualLUT(), L1MuGMTConfig::getLFOvlEtaConvLUT(), i, L1MuGMTSortRankUnit::isDisabled(), j, m_id, L1MuSignedPacking< Bits >::packedFromIdx(), second, L1MuGMTLFCOUDeltaEtaLUT::SpecificLookup_delta_eta(), L1MuGMTLFDeltaEtaLUT::SpecificLookup_delta_eta(), L1MuGMTLFDisableHotLUT::SpecificLookup_disable_hot(), L1MuGMTLFOvlEtaConvLUT::SpecificLookup_eta_ovl(), and L1MuGMTLFMatchQualLUT::SpecificLookup_mq().

Referenced by match().

                                          {

  bool empty1 = ( first[i] != 0 ) ? first[i]->empty() : true;
  bool empty2 = ( second[j] != 0 ) ? second[j]->empty() : true;
  if ( empty1 || empty2) return 0; 

  //
  // (1) calculate delta-phi (integer version)
  //
  unsigned phi1 = first[i]->phi_packed();
  unsigned phi2 = second[j]->phi_packed();
  
  int delta_phi = ( ( phi1 - phi2 + 3*72  ) % 144  ) - 72;
  
  if (delta_phi < -3 || delta_phi >3) 
    delta_phi = -4;
  
  L1MuSignedPacking<3> DPhiPacking;
  unsigned delta_phi_packed = DPhiPacking.packedFromIdx (delta_phi);
  
  //
  // (2) look-up delta-eta
  //
  unsigned eta1 = first[i]->eta_packed();
  unsigned eta2 = second[j]->eta_packed();

  unsigned delta_eta_packed = 0;
  
  if (m_id == 0 || m_id == 1) { // main matching units
    // first is dt/csc, second is rpc

    bool disable1 = L1MuGMTSortRankUnit::isDisabled(first[i]);
    bool disable2 = L1MuGMTSortRankUnit::isDisabled(second[j]);;

    if (disable1 || disable2) return 0;
 
    L1MuGMTLFDeltaEtaLUT* de_lut = L1MuGMTConfig::getLFDeltaEtaLUT(); 
    delta_eta_packed = de_lut->SpecificLookup_delta_eta (m_id, eta1, eta2);
  }
  else { // overlap cancel-out matching units
    // first is own chip, second is other chip
    int idx1 = first[i]->type_idx(); 
    int idx1_dcrr = (idx1==1)?2:(idx1==2)?1:idx1;

    int idx2 = second[j]->type_idx(); 
    int idx2_dcrr = (idx2==1)?2:(idx2==2)?1:idx2;

    bool disable1 = L1MuGMTSortRankUnit::isDisabled(first[i]);
    
    L1MuGMTLFDisableHotLUT* dishot_lut = L1MuGMTConfig::getLFDisableHotLUT(); 
    bool disable2 = dishot_lut->SpecificLookup_disable_hot (idx2_dcrr, 
                                                            second[j]->eta_packed(), 
                                                            second[j]->phi_packed()) == 1;

    if (disable1 || disable2) return 0;
    
    // convert eta to 4-bit, first
    L1MuGMTLFOvlEtaConvLUT* econv_lut = L1MuGMTConfig::getLFOvlEtaConvLUT(); 


    unsigned eta1_4bit = econv_lut->SpecificLookup_eta_ovl (idx1_dcrr, eta1);
    unsigned eta2_4bit = econv_lut->SpecificLookup_eta_ovl (idx2_dcrr, eta2);

    // look up delta eta
    L1MuGMTLFCOUDeltaEtaLUT* cou_de_lut = L1MuGMTConfig::getLFCOUDeltaEtaLUT(); 
    delta_eta_packed = cou_de_lut->SpecificLookup_delta_eta (m_id-2, eta1_4bit, eta2_4bit);
  }

  //
  // (3) look up match quality
  //
  L1MuGMTLFMatchQualLUT* mq_lut = L1MuGMTConfig::getLFMatchQualLUT(); 
    
  unsigned mq = mq_lut->SpecificLookup_mq(m_id, delta_eta_packed, delta_phi_packed);

  return mq;
}
void L1MuGMTMatcher::match ( ) [private]

Definition at line 199 of file L1MuGMTMatcher.cc.

References L1MuGlobalMuonTrigger::DebugBlockForFill(), i, L1MuGMTMatrix< T >::init(), L1MuGMTMatrix< T >::isMax(), j, lookup_mq(), m_gmt, m_id, matchQuality, max(), MaxMatch, pairMatrix, L1MuGMTDebugBlock::SetMQMatrix(), and L1MuGMTDebugBlock::SetPairMatrix().

Referenced by run().

                           {

  L1MuGMTMatrix<bool> maxMatrix(MaxMatch,MaxMatch);
  L1MuGMTMatrix<bool> disableMatrix(MaxMatch,MaxMatch);
  maxMatrix.init(false);
  disableMatrix.init(false);

  // loop over all combinations

  unsigned i,j;
  for ( i = 0; i < MaxMatch; i++ ) 
    for ( j = 0; j < MaxMatch; j++ ) 
      matchQuality(i,j) = lookup_mq(i,j);

  // store in debug block
  m_gmt.DebugBlockForFill()->SetMQMatrix( m_id, matchQuality) ;

  // fill MAX matrix

  for ( i = 0; i < MaxMatch; i++ )
    for ( j = 0; j < MaxMatch; j++ ) 
      maxMatrix(i,j) = matchQuality.isMax(i,j) && (matchQuality(i,j) != 0);
  
  // fill disable matrix
 
  for ( i = 0; i < MaxMatch; i++ )  
    for ( j = 0; j < MaxMatch; j++ ) {

      for ( unsigned i1 = 0; i1 < MaxMatch; i1++ ) 
        if ( i1 != i ) disableMatrix(i,j) = disableMatrix(i,j) || maxMatrix(i1,j);
      
      for ( unsigned j1 = 0; j1 < MaxMatch; j1++ ) 
        if ( j1 != j ) disableMatrix(i,j) = disableMatrix(i,j) || maxMatrix(i,j1);
  }

  // fill pair matrix

  for ( i = 0; i < MaxMatch; i++ ) {  
    for ( j = 0; j < MaxMatch; j++ ) {

      bool max = true;

      for ( unsigned i1 = 0; i1 < i; i1++ ) {
          max = max && ((matchQuality(i,j) > matchQuality(i1,j)) ||
                         disableMatrix(i1,j));
      }

      for ( unsigned i1 = i+1; i1 < MaxMatch; i1++ ) {
          max = max && ((matchQuality(i,j) >= matchQuality(i1,j)) ||
                         disableMatrix(i1,j));
      }

      for ( unsigned j1 = 0; j1 < j; j1++ ) {
          max = max && ((matchQuality(i,j) > matchQuality(i,j1)) ||
                         disableMatrix(i,j1));
      }

      for ( unsigned j1 = j+1; j1 < MaxMatch; j1++ ) {
          max = max && ((matchQuality(i,j) >= matchQuality(i,j1)) ||
                         disableMatrix(i,j1));
      }
 
      pairMatrix(i,j) = max && (matchQuality(i,j) != 0);

    }
  }  

  // store in debug block
  m_gmt.DebugBlockForFill()->SetPairMatrix( m_id, pairMatrix) ;
}
bool L1MuGMTMatcher::pairM ( int  i,
int  j 
) const [inline]

return pair matrix

Definition at line 71 of file L1MuGMTMatcher.h.

References pairMatrix.

{ return pairMatrix(i,j); }
const L1MuGMTMatrix<bool>& L1MuGMTMatcher::pairM ( ) const [inline]

return pair matrix

Definition at line 68 of file L1MuGMTMatcher.h.

References pairMatrix.

Referenced by L1MuGMTCancelOutUnit::decide(), and L1MuGMTMerger::merge().

{ return pairMatrix; }
void L1MuGMTMatcher::print ( void  )

print matching results

Definition at line 113 of file L1MuGMTMatcher.cc.

References L1MuGMTConfig::Debug(), matchQuality, pairMatrix, and L1MuGMTMatrix< T >::print().

Referenced by L1MuGlobalMuonTrigger::produce(), and L1MuGMTCancelOutUnit::run().

                           {

  edm::LogVerbatim("GMT_Matcher_info");
  if ( L1MuGMTConfig::Debug(4) ) {
    edm::LogVerbatim("GMT_Matcher_info") << "MATCH Quality : ";
    matchQuality.print();
  }

  edm::LogVerbatim("GMT_Matcher_info") << "PAIR Matrix : ";
  pairMatrix.print();

  edm::LogVerbatim("GMT_Matcher_info");

}
void L1MuGMTMatcher::reset ( void  )

clear Matcher

Definition at line 97 of file L1MuGMTMatcher.cc.

References first, i, L1MuGMTMatrix< T >::init(), matchQuality, MaxMatch, pairMatrix, and second.

Referenced by L1MuGlobalMuonTrigger::reset(), L1MuGMTCancelOutUnit::reset(), and ~L1MuGMTMatcher().

                           {

  matchQuality.init(0);
  pairMatrix.init(false);
  
  for ( unsigned i = 0; i < MaxMatch; i++ ) {
    first[i] = 0;
    second[i] = 0;
  }  

}
void L1MuGMTMatcher::run ( void  )

run Matcher

Definition at line 87 of file L1MuGMTMatcher.cc.

References load(), and match().

Referenced by L1MuGlobalMuonTrigger::produce(), and L1MuGMTCancelOutUnit::run().

                         {

  load();
  match();
  
}

Member Data Documentation

std::vector<const L1MuRegionalCand*> L1MuGMTMatcher::first [private]

Definition at line 87 of file L1MuGMTMatcher.h.

Referenced by L1MuGMTMatcher(), load(), lookup_mq(), and reset().

Definition at line 84 of file L1MuGMTMatcher.h.

Referenced by load(), and match().

int L1MuGMTMatcher::m_id [private]

Definition at line 85 of file L1MuGMTMatcher.h.

Referenced by id(), load(), lookup_mq(), and match().

Definition at line 90 of file L1MuGMTMatcher.h.

Referenced by match(), print(), and reset().

const unsigned int L1MuGMTMatcher::MaxMatch = 4 [static]

Definition at line 47 of file L1MuGMTMatcher.h.

Referenced by L1MuGMTMatcher(), match(), and reset().

Definition at line 91 of file L1MuGMTMatcher.h.

Referenced by match(), pairM(), print(), and reset().

std::vector<const L1MuRegionalCand*> L1MuGMTMatcher::second [private]

Definition at line 88 of file L1MuGMTMatcher.h.

Referenced by L1MuGMTMatcher(), load(), lookup_mq(), and reset().