File indexing completed on 2024-04-06 12:21:39
0001 #ifndef L1Trigger_RPCPacManager_h
0002 #define L1Trigger_RPCPacManager_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <string>
0020 #include <vector>
0021 #include "L1Trigger/RPCTrigger/interface/RPCConst.h"
0022 #include "L1Trigger/RPCTrigger/interface/RPCException.h"
0023
0024 #include "CondFormats/L1TObjects/interface/L1RPCConfig.h"
0025
0026 #include <cstdlib>
0027 #ifndef _STAND_ALONE
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #endif
0030
0031
0032
0033 enum L1RpcPACsCntEnum {
0034 ONE_PAC_PER_TOWER = 1,
0035 _12_PACS_PER_TOWER = 12,
0036 _144_PACS_PER_TOWER = 144,
0037 TB_TESTS
0038 };
0039
0040 template <class TPacType>
0041 class RPCPacManager {
0042 public:
0043 ~RPCPacManager() {
0044 for (unsigned int m_tower = 0; m_tower < m_PacTab.size(); m_tower++)
0045 for (unsigned int logSector = 0; logSector < m_PacTab[m_tower].size(); logSector++) {
0046 for (unsigned int logSegment = 0; logSegment < m_PacTab[m_tower][logSector].size(); logSegment++) {
0047 TPacType* pac = m_PacTab[m_tower][logSector][logSegment];
0048 delete pac;
0049 }
0050 }
0051 }
0052
0053
0054
0055
0056
0057
0058 void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt) {
0059 destroy();
0060 m_PACsCnt = _PACsCnt;
0061 if (m_PACsCnt == ONE_PAC_PER_TOWER) {
0062 m_SectorsCnt = 1;
0063 m_SegmentCnt = 1;
0064 } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
0065 m_SectorsCnt = 1;
0066 m_SegmentCnt = 12;
0067 } else if (m_PACsCnt == _144_PACS_PER_TOWER) {
0068 m_SectorsCnt = 12;
0069 m_SegmentCnt = 12;
0070 } else if (m_PACsCnt == TB_TESTS) {
0071 m_SectorsCnt = 1;
0072 m_SegmentCnt = 4;
0073 }
0074
0075 for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
0076 m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
0077 for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
0078 m_PacTab[m_tower].push_back(std::vector<TPacType*>());
0079 for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
0080 TPacType* pac = new TPacType(patFilesDirectory, m_tower, logSector, logSegment);
0081 m_PacTab[m_tower][logSector].push_back(pac);
0082 }
0083 }
0084 }
0085 };
0086
0087 void init(const L1RPCConfig* rpcconf) {
0088 destroy();
0089 switch (rpcconf->getPPT()) {
0090 case 1:
0091 m_PACsCnt = ONE_PAC_PER_TOWER;
0092 break;
0093 case 12:
0094 m_PACsCnt = _12_PACS_PER_TOWER;
0095 break;
0096 case 144:
0097 m_PACsCnt = _144_PACS_PER_TOWER;
0098 break;
0099 }
0100
0101 if (m_PACsCnt == ONE_PAC_PER_TOWER) {
0102 m_SectorsCnt = 1;
0103 m_SegmentCnt = 1;
0104 } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
0105 m_SectorsCnt = 1;
0106 m_SegmentCnt = 12;
0107 } else if (m_PACsCnt == _144_PACS_PER_TOWER) {
0108 m_SectorsCnt = 12;
0109 m_SegmentCnt = 12;
0110 } else if (m_PACsCnt == TB_TESTS) {
0111 m_SectorsCnt = 1;
0112 m_SegmentCnt = 4;
0113 }
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
0138 m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
0139 for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
0140 m_PacTab[tower].push_back(std::vector<TPacType*>());
0141 for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
0142
0143
0144
0145
0146
0147
0148
0149 TPacType* pac = new TPacType(rpcconf, tower, logSector, logSegment);
0150 m_PacTab[tower][logSector].push_back(pac);
0151 }
0152 }
0153 }
0154 };
0155
0156
0157
0158
0159
0160
0161 TPacType* getPac(int m_tower, int logSector, int logSegment) const {
0162 if (m_PacTab.size() <= (unsigned int)abs(m_tower))
0163 throw RPCException("RPCPacManager::getPac: given towerNum to big");
0164
0165
0166
0167
0168
0169 if (m_PACsCnt == ONE_PAC_PER_TOWER) {
0170 logSector = 0;
0171 logSegment = 0;
0172 } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
0173 logSector = 0;
0174 }
0175
0176
0177 return m_PacTab[std::abs(m_tower)][logSector][logSegment];
0178 };
0179
0180
0181 TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
0182 return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
0183 }
0184
0185 private:
0186 std::vector<std::vector<std::vector<TPacType*> > > m_PacTab;
0187
0188 int m_SectorsCnt;
0189
0190 int m_SegmentCnt;
0191
0192 L1RpcPACsCntEnum m_PACsCnt;
0193
0194 void destroy() {
0195 for (size_t tower = 0; tower < m_PacTab.size(); ++tower) {
0196 for (size_t logSector = 0; logSector < m_PacTab.at(tower).size(); logSector++) {
0197 for (size_t logSegment = 0; logSegment < m_PacTab.at(tower).at(logSector).size(); logSegment++) {
0198 TPacType* pac = m_PacTab.at(tower).at(logSector).at(logSegment);
0199 delete pac;
0200 }
0201 }
0202 }
0203 m_PacTab.clear();
0204 }
0205 };
0206
0207 #endif