CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/L1Trigger/RPCTrigger/interface/RPCPacManager.h

Go to the documentation of this file.
00001 #ifndef L1Trigger_RPCPacManager_h
00002 #define L1Trigger_RPCPacManager_h
00003 
00018 //------------------------------------------------------------------------------
00019 #include <string>
00020 #include <vector>
00021 #include "L1Trigger/RPCTrigger/interface/RPCConst.h"
00022 #include "L1Trigger/RPCTrigger/interface/RPCException.h"
00023 
00024 #include "CondFormats/L1TObjects/interface/L1RPCConfig.h"
00025 
00026 #include <xercesc/util/PlatformUtils.hpp>
00027 #include <cstdlib>
00028 #ifndef _STAND_ALONE
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030 #endif // _STAND_ALONE
00031 
00033 // TODO: should be moved to L1RPConfig
00034 enum L1RpcPACsCntEnum {
00035   ONE_PAC_PER_TOWER = 1,
00036   _12_PACS_PER_TOWER = 12, //the same m_PAC in the same segment in every sector,
00037   _144_PACS_PER_TOWER =144,
00038   TB_TESTS
00039 };
00040 
00041 
00042 template<class TPacType> class RPCPacManager {
00043 public:
00044   ~RPCPacManager() {
00045     for (unsigned int m_tower = 0; m_tower < m_PacTab.size(); m_tower++)
00046       for (unsigned int logSector = 0; logSector < m_PacTab[m_tower].size(); logSector++) {
00047         for (unsigned int logSegment = 0; logSegment < m_PacTab[m_tower][logSector].size(); logSegment++) {
00048           TPacType* pac = m_PacTab[m_tower][logSector][logSegment];
00049           delete pac;
00050         }
00051       }
00052   }
00053 
00059   void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt)  {
00060     m_PACsCnt = _PACsCnt;
00061     if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00062       m_SectorsCnt = 1;
00063       m_SegmentCnt = 1;
00064     }
00065     else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00066       m_SectorsCnt = 1;
00067       m_SegmentCnt = 12;
00068     }
00069     else if(m_PACsCnt == _144_PACS_PER_TOWER) {
00070       m_SectorsCnt = 12;
00071       m_SegmentCnt = 12;
00072     }
00073     else if(m_PACsCnt == TB_TESTS) {
00074       m_SectorsCnt = 1;
00075       m_SegmentCnt = 4;
00076     }
00077 
00078     for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
00079       m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
00080       for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
00081         m_PacTab[m_tower].push_back(std::vector<TPacType*>());
00082         for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
00083           TPacType* pac  = new TPacType(patFilesDirectory, m_tower, logSector, logSegment); 
00084           m_PacTab[m_tower][logSector].push_back(pac);                   
00085         }
00086       } 
00087     } 
00088     xercesc::XMLPlatformUtils::Terminate();
00089   };
00090 
00091   
00092   void init(const L1RPCConfig *rpcconf)  {
00093   
00094     switch (rpcconf->getPPT()){
00095       case 1:
00096         m_PACsCnt = ONE_PAC_PER_TOWER;
00097         break;
00098       case 12:
00099         m_PACsCnt = _12_PACS_PER_TOWER;
00100         break;
00101       case 144:
00102         m_PACsCnt = _144_PACS_PER_TOWER;
00103         break;
00104     
00105     }
00106     
00107     if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00108       m_SectorsCnt = 1;
00109       m_SegmentCnt = 1;
00110     }
00111     else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00112       m_SectorsCnt = 1;
00113       m_SegmentCnt = 12;
00114     }
00115     else if(m_PACsCnt == _144_PACS_PER_TOWER) {
00116       m_SectorsCnt = 12;
00117       m_SegmentCnt = 12;
00118     }
00119     else if(m_PACsCnt == TB_TESTS) {
00120       m_SectorsCnt = 1;
00121       m_SegmentCnt = 4;
00122     }
00123 
00124     /*
00125     std::vector<std::vector<std::vector<RPCPattern::RPCPatVec> > > patvec;
00126     std::vector<std::vector<std::vector<RPCPattern::TQualityVec> > > qualvec;
00127     for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
00128       patvec.push_back(std::vector< std::vector< RPCPattern::RPCPatVec > >());
00129       qualvec.push_back(std::vector< std::vector< RPCPattern::TQualityVec > >());
00130       for (int logSector = 0; logSector < m_SectorsCnt; ++logSector) {
00131         patvec[tower].push_back(std::vector< RPCPattern::RPCPatVec >());
00132         qualvec[tower].push_back(std::vector< RPCPattern::TQualityVec >());
00133         for (int logSegment = 0; logSegment < m_SegmentCnt; ++logSegment) {
00134           patvec[tower][logSector].push_back(RPCPattern::RPCPatVec());
00135           qualvec[tower][logSector].push_back(RPCPattern::TQualityVec());
00136         }
00137       }
00138     }
00139 
00140     for (unsigned int ipat=0; ipat<rpcconf->m_pats.size(); ipat++)
00141       patvec[rpcconf->m_pats[ipat].getTower()][rpcconf->m_pats[ipat].getLogSector()][rpcconf->m_pats[ipat].getLogSegment()].push_back(rpcconf->m_pats[ipat]);
00142     for (unsigned int iqual=0; iqual<rpcconf->m_quals.size(); iqual++)
00143       qualvec[rpcconf->m_quals[iqual].m_tower][rpcconf->m_quals[iqual].m_logsector][rpcconf->m_quals[iqual].m_logsegment].push_back(rpcconf->m_quals[iqual]);
00144     */
00145 
00146 
00147     for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
00148       m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
00149       for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
00150         m_PacTab[tower].push_back(std::vector<TPacType*>());
00151         for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
00152           /*L1RPCConfig* rpcconf1=new L1RPCConfig();
00153           rpcconf1->setPPT(rpcconf->getPPT());
00154           for (unsigned int ipat=0; ipat<patvec[tower][logSector][logSegment].size(); ipat++)
00155             rpcconf1->m_pats.push_back(patvec[tower][logSector][logSegment][ipat]);
00156           for (unsigned int iqual=0; iqual<qualvec[tower][logSector][logSegment].size(); iqual++)
00157             rpcconf1->m_quals.push_back(qualvec[tower][logSector][logSegment][iqual]);
00158           //TPacType* pac  = new TPacType(rpcconf1->m_pats,rpcconf1->m_quals);*/
00159           TPacType* pac  = new TPacType(rpcconf, tower, logSector, logSegment);
00160           m_PacTab[tower][logSector].push_back(pac);
00161         }
00162       } 
00163     } 
00164     xercesc::XMLPlatformUtils::Terminate();
00165   };
00166   
00171   //const
00172   TPacType* getPac(int m_tower, int logSector, int logSegment) const {
00173     if (m_PacTab.size() <= (unsigned int) abs(m_tower))
00174      throw RPCException("RPCPacManager::getPac: given towerNum to big");
00175      // edm::LogError("RPCTrigger") << "RPCPacManager::getPac: given towerNum to big" << std::endl;
00176 
00177     //int curLogSector = logSector;
00178     //int curlogSegment = logSegment;
00179 
00180     if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00181       logSector = 0;
00182       logSegment = 0;
00183     }
00184     else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00185       logSector = 0;
00186     }
00187 
00188     //XXXX//m_PacTab[abs(m_tower)][logSector][logSegment]->setCurrentPosition(m_tower, curLogSector, curlogSegment);
00189     return  m_PacTab[std::abs(m_tower)][logSector][logSegment];
00190   };
00191   
00192   //const 
00193   TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
00194     return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
00195   }
00196   
00197   private:
00198     std::vector<std::vector<std::vector<TPacType*> > > m_PacTab; 
00199 
00200     int m_SectorsCnt; 
00201 
00202     int m_SegmentCnt; 
00203 
00204     L1RpcPACsCntEnum m_PACsCnt; //Used configuration version.
00205 };
00206 
00207 #endif