CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1Trigger/RPCTrigger/src/RPCTriggerBoard.cc

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