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
00054
00055
00061 void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt) {
00062 destroy();
00063 m_PACsCnt = _PACsCnt;
00064 if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00065 m_SectorsCnt = 1;
00066 m_SegmentCnt = 1;
00067 }
00068 else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00069 m_SectorsCnt = 1;
00070 m_SegmentCnt = 12;
00071 }
00072 else if(m_PACsCnt == _144_PACS_PER_TOWER) {
00073 m_SectorsCnt = 12;
00074 m_SegmentCnt = 12;
00075 }
00076 else if(m_PACsCnt == TB_TESTS) {
00077 m_SectorsCnt = 1;
00078 m_SegmentCnt = 4;
00079 }
00080
00081 for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
00082 m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
00083 for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
00084 m_PacTab[m_tower].push_back(std::vector<TPacType*>());
00085 for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
00086 TPacType* pac = new TPacType(patFilesDirectory, m_tower, logSector, logSegment);
00087 m_PacTab[m_tower][logSector].push_back(pac);
00088 }
00089 }
00090 }
00091 xercesc::XMLPlatformUtils::Terminate();
00092 };
00093
00094
00095 void init(const L1RPCConfig *rpcconf) {
00096 destroy();
00097 switch (rpcconf->getPPT()){
00098 case 1:
00099 m_PACsCnt = ONE_PAC_PER_TOWER;
00100 break;
00101 case 12:
00102 m_PACsCnt = _12_PACS_PER_TOWER;
00103 break;
00104 case 144:
00105 m_PACsCnt = _144_PACS_PER_TOWER;
00106 break;
00107
00108 }
00109
00110 if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00111 m_SectorsCnt = 1;
00112 m_SegmentCnt = 1;
00113 }
00114 else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00115 m_SectorsCnt = 1;
00116 m_SegmentCnt = 12;
00117 }
00118 else if(m_PACsCnt == _144_PACS_PER_TOWER) {
00119 m_SectorsCnt = 12;
00120 m_SegmentCnt = 12;
00121 }
00122 else if(m_PACsCnt == TB_TESTS) {
00123 m_SectorsCnt = 1;
00124 m_SegmentCnt = 4;
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
00151 m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
00152 for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
00153 m_PacTab[tower].push_back(std::vector<TPacType*>());
00154 for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
00155
00156
00157
00158
00159
00160
00161
00162 TPacType* pac = new TPacType(rpcconf, tower, logSector, logSegment);
00163 m_PacTab[tower][logSector].push_back(pac);
00164 }
00165 }
00166 }
00167 xercesc::XMLPlatformUtils::Terminate();
00168 };
00169
00174
00175 TPacType* getPac(int m_tower, int logSector, int logSegment) const {
00176 if (m_PacTab.size() <= (unsigned int) abs(m_tower))
00177 throw RPCException("RPCPacManager::getPac: given towerNum to big");
00178
00179
00180
00181
00182
00183 if(m_PACsCnt == ONE_PAC_PER_TOWER) {
00184 logSector = 0;
00185 logSegment = 0;
00186 }
00187 else if(m_PACsCnt == _12_PACS_PER_TOWER) {
00188 logSector = 0;
00189 }
00190
00191
00192 return m_PacTab[std::abs(m_tower)][logSector][logSegment];
00193 };
00194
00195
00196 TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
00197 return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
00198 }
00199
00200 private:
00201 std::vector<std::vector<std::vector<TPacType*> > > m_PacTab;
00202
00203 int m_SectorsCnt;
00204
00205 int m_SegmentCnt;
00206
00207 L1RpcPACsCntEnum m_PACsCnt;
00208
00209 void destroy(){
00210 for (size_t tower = 0; tower < m_PacTab.size() ; ++tower) {
00211 for (size_t logSector = 0; logSector < m_PacTab.at(tower).size(); logSector++) {
00212 for (size_t logSegment = 0; logSegment < m_PacTab.at(tower).at(logSector).size() ; logSegment++) {
00213 TPacType* pac = m_PacTab.at(tower).at(logSector).at(logSegment);
00214 delete pac;
00215 }
00216 }
00217 }
00218 m_PacTab.clear();
00219 }
00220 };
00221
00222 #endif