CMS 3D CMS Logo

RPCPacManager.h
Go to the documentation of this file.
1 #ifndef L1Trigger_RPCPacManager_h
2 #define L1Trigger_RPCPacManager_h
3 
18 //------------------------------------------------------------------------------
19 #include <string>
20 #include <vector>
23 
25 
26 #include <cstdlib>
27 #ifndef _STAND_ALONE
29 #endif // _STAND_ALONE
30 
32 // TODO: should be moved to L1RPConfig
35  _12_PACS_PER_TOWER = 12, //the same m_PAC in the same segment in every sector,
38 };
39 
40 template <class TPacType>
42 public:
44  for (unsigned int m_tower = 0; m_tower < m_PacTab.size(); m_tower++)
45  for (unsigned int logSector = 0; logSector < m_PacTab[m_tower].size(); logSector++) {
46  for (unsigned int logSegment = 0; logSegment < m_PacTab[m_tower][logSector].size(); logSegment++) {
47  TPacType* pac = m_PacTab[m_tower][logSector][logSegment];
48  delete pac;
49  }
50  }
51  }
52 
58  void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt) {
59  destroy();
60  m_PACsCnt = _PACsCnt;
62  m_SectorsCnt = 1;
63  m_SegmentCnt = 1;
64  } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
65  m_SectorsCnt = 1;
66  m_SegmentCnt = 12;
67  } else if (m_PACsCnt == _144_PACS_PER_TOWER) {
68  m_SectorsCnt = 12;
69  m_SegmentCnt = 12;
70  } else if (m_PACsCnt == TB_TESTS) {
71  m_SectorsCnt = 1;
72  m_SegmentCnt = 4;
73  }
74 
75  for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
76  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
77  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
78  m_PacTab[m_tower].push_back(std::vector<TPacType*>());
79  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
80  TPacType* pac = new TPacType(patFilesDirectory, m_tower, logSector, logSegment);
81  m_PacTab[m_tower][logSector].push_back(pac);
82  }
83  }
84  }
85  };
86 
87  void init(const L1RPCConfig* rpcconf) {
88  destroy();
89  switch (rpcconf->getPPT()) {
90  case 1:
92  break;
93  case 12:
95  break;
96  case 144:
98  break;
99  }
100 
101  if (m_PACsCnt == ONE_PAC_PER_TOWER) {
102  m_SectorsCnt = 1;
103  m_SegmentCnt = 1;
104  } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
105  m_SectorsCnt = 1;
106  m_SegmentCnt = 12;
107  } else if (m_PACsCnt == _144_PACS_PER_TOWER) {
108  m_SectorsCnt = 12;
109  m_SegmentCnt = 12;
110  } else if (m_PACsCnt == TB_TESTS) {
111  m_SectorsCnt = 1;
112  m_SegmentCnt = 4;
113  }
114 
115  /*
116  std::vector<std::vector<std::vector<RPCPattern::RPCPatVec> > > patvec;
117  std::vector<std::vector<std::vector<RPCPattern::TQualityVec> > > qualvec;
118  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
119  patvec.push_back(std::vector< std::vector< RPCPattern::RPCPatVec > >());
120  qualvec.push_back(std::vector< std::vector< RPCPattern::TQualityVec > >());
121  for (int logSector = 0; logSector < m_SectorsCnt; ++logSector) {
122  patvec[tower].push_back(std::vector< RPCPattern::RPCPatVec >());
123  qualvec[tower].push_back(std::vector< RPCPattern::TQualityVec >());
124  for (int logSegment = 0; logSegment < m_SegmentCnt; ++logSegment) {
125  patvec[tower][logSector].push_back(RPCPattern::RPCPatVec());
126  qualvec[tower][logSector].push_back(RPCPattern::TQualityVec());
127  }
128  }
129  }
130 
131  for (unsigned int ipat=0; ipat<rpcconf->m_pats.size(); ipat++)
132  patvec[rpcconf->m_pats[ipat].getTower()][rpcconf->m_pats[ipat].getLogSector()][rpcconf->m_pats[ipat].getLogSegment()].push_back(rpcconf->m_pats[ipat]);
133  for (unsigned int iqual=0; iqual<rpcconf->m_quals.size(); iqual++)
134  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]);
135  */
136 
137  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
138  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
139  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
140  m_PacTab[tower].push_back(std::vector<TPacType*>());
141  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
142  /*L1RPCConfig* rpcconf1=new L1RPCConfig();
143  rpcconf1->setPPT(rpcconf->getPPT());
144  for (unsigned int ipat=0; ipat<patvec[tower][logSector][logSegment].size(); ipat++)
145  rpcconf1->m_pats.push_back(patvec[tower][logSector][logSegment][ipat]);
146  for (unsigned int iqual=0; iqual<qualvec[tower][logSector][logSegment].size(); iqual++)
147  rpcconf1->m_quals.push_back(qualvec[tower][logSector][logSegment][iqual]);
148  //TPacType* pac = new TPacType(rpcconf1->m_pats,rpcconf1->m_quals);*/
149  TPacType* pac = new TPacType(rpcconf, tower, logSector, logSegment);
150  m_PacTab[tower][logSector].push_back(pac);
151  }
152  }
153  }
154  };
155 
160  //const
161  TPacType* getPac(int m_tower, int logSector, int logSegment) const {
162  if (m_PacTab.size() <= (unsigned int)abs(m_tower))
163  throw RPCException("RPCPacManager::getPac: given towerNum to big");
164  // edm::LogError("RPCTrigger") << "RPCPacManager::getPac: given towerNum to big" << std::endl;
165 
166  //int curLogSector = logSector;
167  //int curlogSegment = logSegment;
168 
169  if (m_PACsCnt == ONE_PAC_PER_TOWER) {
170  logSector = 0;
171  logSegment = 0;
172  } else if (m_PACsCnt == _12_PACS_PER_TOWER) {
173  logSector = 0;
174  }
175 
176  //XXXX//m_PacTab[abs(m_tower)][logSector][logSegment]->setCurrentPosition(m_tower, curLogSector, curlogSegment);
177  return m_PacTab[std::abs(m_tower)][logSector][logSegment];
178  };
179 
180  //const
181  TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
182  return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
183  }
184 
185 private:
186  std::vector<std::vector<std::vector<TPacType*> > > m_PacTab;
187 
189 
191 
192  L1RpcPACsCntEnum m_PACsCnt; //Used configuration version.
193 
194  void destroy() {
195  for (size_t tower = 0; tower < m_PacTab.size(); ++tower) {
196  for (size_t logSector = 0; logSector < m_PacTab.at(tower).size(); logSector++) {
197  for (size_t logSegment = 0; logSegment < m_PacTab.at(tower).at(logSector).size(); logSegment++) {
198  TPacType* pac = m_PacTab.at(tower).at(logSector).at(logSegment);
199  delete pac;
200  }
201  }
202  }
203  m_PacTab.clear();
204  }
205 };
206 
207 #endif
int m_SegmentCnt
Count of used differnt segments.
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
TPacType * getPac(const RPCConst::l1RpcConeCrdnts &coneCrdnts) const
TPacType * getPac(int m_tower, int logSector, int logSegment) const
L1RpcPACsCntEnum m_PACsCnt
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int m_TOWER_COUNT
Only half of the detector.
Definition: RPCConst.h:41
std::vector< std::vector< std::vector< TPacType * > > > m_PacTab
m_PacTab[m_tower][logSector][m_LogSegment]
int m_SectorsCnt
Count of used differnt sectors.
L1RpcPACsCntEnum
Suported configurations.
Definition: RPCPacManager.h:33
void init(const L1RPCConfig *rpcconf)
Definition: RPCPacManager.h:87
void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt)
Definition: RPCPacManager.h:58