00001 /******************************************************************************* 00002 * * 00003 * Karol Bunkowski * 00004 * Warsaw University 2004 * 00005 * * 00006 *******************************************************************************/ 00007 #include "L1Trigger/RPCTrigger/interface/RPCTriggerBoard.h" 00008 #include "L1Trigger/RPCTrigger/interface/RPCException.h" 00009 00010 #include<sstream> 00011 //--------------------------------------------------------------------------- 00012 RPCTriggerBoard::RPCTriggerBoard( RPCTriggerConfiguration* triggerConfig, 00013 int tbNum, int tcNum) 00014 { 00015 00016 m_TriggerConfig = triggerConfig; 00017 m_TBNumber = tbNum; 00018 00019 int towerMin=-16; 00020 int towerMax=-16; 00021 00022 // Calculate tower boundaries for this TB 00023 for (int i=0;i <= tbNum; i++){ // Trigger Boards are numbered from 0 to 8 00024 towerMin=towerMax; 00025 towerMax+=m_TriggerConfig->getTowsCntOnTB(i); 00026 } 00027 towerMax--; 00028 00029 for (int tower = towerMin; tower <= towerMax; tower++){ 00030 for (int logSegment = 0; logSegment < 12; logSegment++){ // One logSegment = one PAC 00031 //m_pacs[cone.getTower()][cone.getLogSegment()] 00032 RPCConst::l1RpcConeCrdnts coneCrds; 00033 coneCrds.m_Tower=tower; 00034 coneCrds.m_LogSector=tcNum; 00035 coneCrds.m_LogSegment=logSegment; 00036 00037 const RPCPacData *pacData = m_TriggerConfig->getPac(coneCrds); 00038 00039 // one trigger crate covers one logsector: 00040 //RPCPac *pac = new RPCPac(pacData, tower, tcNum, logSegment); 00041 boost::shared_ptr< RPCPac > pac (new RPCPac(pacData, tower, tcNum, logSegment) ); 00042 00043 m_pacs[tower].push_back(pac); 00044 00045 } 00046 } 00047 00048 00049 } 00050 //--------------------------------------------------------------------------- 00051 bool RPCTriggerBoard::runCone(const RPCLogCone& cone) { 00052 00053 //RPCTBMuon tbMuon(m_TriggerConfig->getPac(cone.getConeCrdnts())->run(cone) ); 00054 if(m_pacs.find(cone.getTower())==m_pacs.end()){ 00055 std::stringstream s; 00056 s << "RPCTriggerBoard::runCone() wrong tower: " << cone.getTower() << " in TB=" << m_TBNumber; 00057 throw RPCException(s.str()); 00058 } 00059 00060 RPCTBMuon tbMuon(m_pacs[cone.getTower()][cone.getLogSegment()]->run(cone)); 00061 //Reference: RPCTBMuon(int ptCode, int quality, int sign, int patternNum, unsigned short firedPlanes); 00062 00063 //RPCPacMuon pmuon = m_pacs[cone.getTower()][cone.getLogSegment()]->run(cone); 00064 //RPCTBMuon tbMuon(pmuon.getPtCode(), pmuon.getQuality(), pmuon.getSign(), pmuon.getPatternNum(), pmuon.getFiredPlanes()); 00065 00066 00067 if(tbMuon.getCode() > 0) { 00068 m_PacsMuonsVec.push_back(tbMuon); 00069 if (m_TriggerConfig->getDebugLevel()!=0){ 00070 #ifndef _STAND_ALONE 00071 LogDebug("RPCHwDebug") << "GB 0 -1 " 00072 << tbMuon.printDebugInfo(m_TriggerConfig->getDebugLevel()); 00073 #else 00074 std::cout << "GB 0 -1 " 00075 << tbMuon.printDebugInfo(m_TriggerConfig->getDebugLevel()) 00076 << std::endl; 00077 #endif //_STAND_ALONE 00078 } 00079 return true; 00080 } 00081 else 00082 return false; 00083 00084 } 00085 //--------------------------------------------------------------------------- 00086 L1RpcTBMuonsVec RPCTriggerBoard::runTBGB() { //4 muons or empty vector 00087 if(m_PacsMuonsVec.size() == 0) 00088 return L1RpcTBMuonsVec(); 00089 00090 L1RpcTBMuonsVec2 gbMuons(RPCConst::m_TOWERS_ON_TB_CNT, L1RpcTBMuonsVec()); 00091 for(unsigned int iMu = 0; iMu < m_PacsMuonsVec.size(); iMu++) { 00092 int tbTower = m_TriggerConfig->getTowerNumOnTb(m_PacsMuonsVec[iMu].getConeCrdnts()); 00093 00094 if(gbMuons[tbTower].size() == 0) 00095 gbMuons[tbTower].assign(RPCConst::m_SEGMENTS_IN_SECTOR_CNT, RPCTBMuon()); 00096 00097 gbMuons[tbTower][m_PacsMuonsVec[iMu].getLogSegment()] = m_PacsMuonsVec[iMu]; 00098 } 00099 00100 m_PacsMuonsVec.clear(); 00101 return m_TBGhostBuster.run(gbMuons); 00102 } 00103