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
00034 enum L1RpcPACsCntEnum {
00035 ONE_PAC_PER_TOWER = 1,
00036 _12_PACS_PER_TOWER = 12,
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
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
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
00153
00154
00155
00156
00157
00158
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
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
00176
00177
00178
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
00189 return m_PacTab[std::abs(m_tower)][logSector][logSegment];
00190 };
00191
00192
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;
00205 };
00206
00207 #endif