CMS 3D CMS Logo

Public Member Functions

RPCTBGhostBuster Class Reference

#include <RPCTBGhostBuster.h>

List of all members.

Public Member Functions

L1RpcTBMuonsVec gBEta (L1RpcTBMuonsVec2 &gbPhiMuonsVec2) const
L1RpcTBMuonsVec gBPhi (L1RpcTBMuonsVec &pacMuonsVec) const
L1RpcTBMuonsVec run (L1RpcTBMuonsVec2 &pacMuonsVec2) const

Detailed Description

Peformes the Trigger Board Ghost Buster and sorter algorithms. Because the class does not keep any data and GB is the same for every TB, there might be one and the same object of this class for all TBs.

Author:
Karol Bunkowski (Warsaw)

Definition at line 13 of file RPCTBGhostBuster.h.


Member Function Documentation

L1RpcTBMuonsVec RPCTBGhostBuster::gBEta ( L1RpcTBMuonsVec2 gbPhiMuonsVec2) const
Parameters:
gbPhiMuonsVec2size() should be equal to 4 (max number of m_tower in TB). Performs the Eta Goustbuster - between muons from diferent towers. Calls RPCTBMuon::setPhiAddr() for each alive muon.
Returns:
always 4 muons.

Definition at line 126 of file RPCTBGhostBuster.cc.

References abs, RPCConst::m_GBETA_OUT_MUONS_CNT, and python::multivaluedict::sort().

                                                                              {
//-----  killing ghosts ---------------------------------------
  for(unsigned int iMuVec = 0; iMuVec < gbPhiMuonsVec2.size() -1; iMuVec++) {
    for(unsigned int iMu = 0; iMu < gbPhiMuonsVec2[iMuVec].size(); iMu++) {
      if(gbPhiMuonsVec2[iMuVec][iMu].getCode() == 0)
        break; //because muons are sorted

      for(unsigned int iMuNext = 0; iMuNext < gbPhiMuonsVec2[iMuVec+1].size(); iMuNext++) {
        if(abs(gbPhiMuonsVec2[iMuVec][iMu].getPhiAddr()-gbPhiMuonsVec2[iMuVec+1][iMuNext].getPhiAddr())<=1)
        {
          //comparing with next:
          if(gbPhiMuonsVec2[iMuVec][iMu].getCode() < gbPhiMuonsVec2[iMuVec+1][iMuNext].getCode()) 
          { 
            gbPhiMuonsVec2[iMuVec][iMu].kill();
          }
          else 
          {
            gbPhiMuonsVec2[iMuVec+1][iMuNext].kill();
          }
        }
      }
    }
  }

//---------sorting-----------------------------------------
/*  multiset<RPCTBMuon, RPCTBMuon::TMuonMore> liveMuonsSet;
  for(unsigned int iMuVec = 0; iMuVec < gbPhiMuonsVec2.size(); iMuVec++)
  for(unsigned int iMu = 0; iMu < gbPhiMuonsVec2[iMuVec].size(); iMu++)
      if(gbPhiMuonsVec2[iMuVec][iMu].isLive()) {
        gbPhiMuonsVec2[iMuVec][iMu].setEtaAddr(iMuVec);
        liveMuonsSet.insert(gbPhiMuonsVec2[iMuVec][iMu]);
      }
  L1RpcTBMuonsVec outputMuons(liveMuonsSet.begin(), liveMuonsSet.end()); */

  L1RpcTBMuonsVec outputMuons;
  for(unsigned int iMuVec = 0; iMuVec < gbPhiMuonsVec2.size(); iMuVec++)
    for(unsigned int iMu = 0; iMu < gbPhiMuonsVec2[iMuVec].size(); iMu++)
      if(gbPhiMuonsVec2[iMuVec][iMu].isLive()) {
        gbPhiMuonsVec2[iMuVec][iMu].setEtaAddr(iMuVec);
        outputMuons.push_back(gbPhiMuonsVec2[iMuVec][iMu]);
      }
  sort(outputMuons.begin(), outputMuons.end(), RPCTBMuon::TMuonMore());
  
//-------setting size to m_GBETA_OUT_MUONS_CNT----------------
  while(outputMuons.size() < RPCConst::m_GBETA_OUT_MUONS_CNT)
    outputMuons.push_back(RPCTBMuon());
  while(outputMuons.size() > RPCConst::m_GBETA_OUT_MUONS_CNT)
    outputMuons.pop_back();

  return outputMuons;
}
L1RpcTBMuonsVec RPCTBGhostBuster::gBPhi ( L1RpcTBMuonsVec pacMuonsVec) const
Parameters:
pacMuonsVecpacMuonsVec.size() should be equal to 12 (Segment in given TB count) or 0, Performs Phi Goustbuster - between muons in one sector of the same m_tower.
Returns:
if pacMuonsVec has size = 0, returns L1RpcTBMuonsVec with size 0, otherwise returns vector of size = 4. Calls RPCTBMuon::setPhiAddr() for each alive muon.

Definition at line 52 of file RPCTBGhostBuster.cc.

References RPCConst::m_GBPHI_OUT_MUONS_CNT, RPCConst::m_SEGMENTS_IN_SECTOR_CNT, and python::multivaluedict::sort().

                                                                          {
  if(pacMuonsVec.size() == 0)
    return L1RpcTBMuonsVec(); //empty vector;
//--------- killing ghosts ---------------------------------------
  pacMuonsVec.push_back(RPCTBMuon()); //adding  empty muon to the end,

  for(unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
    if(pacMuonsVec[iMu].getCode() == 0)
      ;
    else if(pacMuonsVec[iMu].getCode() < pacMuonsVec[iMu + 1].getCode())
      pacMuonsVec[iMu].kill();
    else if(pacMuonsVec[iMu].getCode() == pacMuonsVec[iMu + 1].getCode()) {
      if(pacMuonsVec[iMu].wasKilled())
        pacMuonsVec[iMu+1].kill();
      else
        pacMuonsVec[iMu].kill();
    }
    else  //>
      pacMuonsVec[iMu+1].kill();
  }

  pacMuonsVec.pop_back();  //removing empty muon from the end,

//-------setting the m_GBData ----------------------------------
  if(pacMuonsVec[0].isLive())
    pacMuonsVec[0].setGBDataKilledFirst();
  else if(pacMuonsVec[0].wasKilled())
    for(unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
      if(pacMuonsVec[iMu].isLive()) {
        pacMuonsVec[iMu].setGBDataKilledFirst();
        break;
      }
    }

    if(pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT-1].isLive()) 
      pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT-1].setGBDataKilledLast();
    else if(pacMuonsVec[RPCConst::m_SEGMENTS_IN_SECTOR_CNT-1].wasKilled())
      for(int iMu = RPCConst::m_SEGMENTS_IN_SECTOR_CNT -1; iMu >= 0 ; iMu--) {
        if(pacMuonsVec[iMu].isLive()) {
          pacMuonsVec[iMu].setGBDataKilledLast();
          break;
      }
    }
//-------------sorting ------------------------------------------
  /*
  multiset<RPCTBMuon, RPCTBMuon::TMuonMore> liveMuonsSet;
  for(int iMu = 0; iMu < m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
    if(pacMuonsVec[iMu].isLive()) {
      pacMuonsVec[iMu].setPhiAddr(iMu);
      liveMuonsSet.insert(pacMuonsVec[iMu]);
    }
  }
  L1RpcTBMuonsVec outputMuons(liveMuonsSet.begin(), liveMuonsSet.end());*/

  L1RpcTBMuonsVec outputMuons;
  for(unsigned int iMu = 0; iMu < RPCConst::m_SEGMENTS_IN_SECTOR_CNT; iMu++) {
    if(pacMuonsVec[iMu].isLive()) {
      pacMuonsVec[iMu].setPhiAddr(iMu);
      outputMuons.push_back(pacMuonsVec[iMu]);
    }
  }
  sort(outputMuons.begin(), outputMuons.end(), RPCTBMuon::TMuonMore());

//-------setting size to m_GBPHI_OUT_MUONS_CNT----------------
  while (outputMuons.size() < RPCConst::m_GBPHI_OUT_MUONS_CNT)
    outputMuons.push_back(RPCTBMuon());
  while(outputMuons.size() > RPCConst::m_GBPHI_OUT_MUONS_CNT)
    outputMuons.pop_back();

  return outputMuons;
}
L1RpcTBMuonsVec RPCTBGhostBuster::run ( L1RpcTBMuonsVec2 pacMuonsVec2) const

Calls gBPhi and gBEta.

Parameters:
pacMuonsVec2pacMuonsVec2[0..3][0..11] (4 Towers x 12 Segments (PACs) ), if pacMuonsVec2[i].size() == 0, means no nonempty muon.
Returns:
always 4 muons.

Definition at line 15 of file RPCTBGhostBuster.cc.

Referenced by RPCTriggerBoard::runTBGB().

                                                                          {
  L1RpcTBMuonsVec2 gbPhiMuonsVec2;
  for(unsigned int iTow = 0; iTow < pacMuonsVec2.size(); iTow++) {
    gbPhiMuonsVec2.push_back(gBPhi(pacMuonsVec2[iTow]));
  }

  return gBEta(gbPhiMuonsVec2);
}