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 
41 template<class TPacType> class RPCPacManager {
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 
53 
54 
60  void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt) {
61  destroy();
62  m_PACsCnt = _PACsCnt;
64  m_SectorsCnt = 1;
65  m_SegmentCnt = 1;
66  }
67  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
68  m_SectorsCnt = 1;
69  m_SegmentCnt = 12;
70  }
71  else if(m_PACsCnt == _144_PACS_PER_TOWER) {
72  m_SectorsCnt = 12;
73  m_SegmentCnt = 12;
74  }
75  else if(m_PACsCnt == TB_TESTS) {
76  m_SectorsCnt = 1;
77  m_SegmentCnt = 4;
78  }
79 
80  for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
81  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
82  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
83  m_PacTab[m_tower].push_back(std::vector<TPacType*>());
84  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
85  TPacType* pac = new TPacType(patFilesDirectory, m_tower, logSector, logSegment);
86  m_PacTab[m_tower][logSector].push_back(pac);
87  }
88  }
89  }
90  };
91 
92 
93  void init(const L1RPCConfig *rpcconf) {
94  destroy();
95  switch (rpcconf->getPPT()){
96  case 1:
98  break;
99  case 12:
101  break;
102  case 144:
104  break;
105 
106  }
107 
109  m_SectorsCnt = 1;
110  m_SegmentCnt = 1;
111  }
112  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
113  m_SectorsCnt = 1;
114  m_SegmentCnt = 12;
115  }
116  else if(m_PACsCnt == _144_PACS_PER_TOWER) {
117  m_SectorsCnt = 12;
118  m_SegmentCnt = 12;
119  }
120  else if(m_PACsCnt == TB_TESTS) {
121  m_SectorsCnt = 1;
122  m_SegmentCnt = 4;
123  }
124 
125  /*
126  std::vector<std::vector<std::vector<RPCPattern::RPCPatVec> > > patvec;
127  std::vector<std::vector<std::vector<RPCPattern::TQualityVec> > > qualvec;
128  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
129  patvec.push_back(std::vector< std::vector< RPCPattern::RPCPatVec > >());
130  qualvec.push_back(std::vector< std::vector< RPCPattern::TQualityVec > >());
131  for (int logSector = 0; logSector < m_SectorsCnt; ++logSector) {
132  patvec[tower].push_back(std::vector< RPCPattern::RPCPatVec >());
133  qualvec[tower].push_back(std::vector< RPCPattern::TQualityVec >());
134  for (int logSegment = 0; logSegment < m_SegmentCnt; ++logSegment) {
135  patvec[tower][logSector].push_back(RPCPattern::RPCPatVec());
136  qualvec[tower][logSector].push_back(RPCPattern::TQualityVec());
137  }
138  }
139  }
140 
141  for (unsigned int ipat=0; ipat<rpcconf->m_pats.size(); ipat++)
142  patvec[rpcconf->m_pats[ipat].getTower()][rpcconf->m_pats[ipat].getLogSector()][rpcconf->m_pats[ipat].getLogSegment()].push_back(rpcconf->m_pats[ipat]);
143  for (unsigned int iqual=0; iqual<rpcconf->m_quals.size(); iqual++)
144  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]);
145  */
146 
147 
148  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
149  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
150  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
151  m_PacTab[tower].push_back(std::vector<TPacType*>());
152  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
153  /*L1RPCConfig* rpcconf1=new L1RPCConfig();
154  rpcconf1->setPPT(rpcconf->getPPT());
155  for (unsigned int ipat=0; ipat<patvec[tower][logSector][logSegment].size(); ipat++)
156  rpcconf1->m_pats.push_back(patvec[tower][logSector][logSegment][ipat]);
157  for (unsigned int iqual=0; iqual<qualvec[tower][logSector][logSegment].size(); iqual++)
158  rpcconf1->m_quals.push_back(qualvec[tower][logSector][logSegment][iqual]);
159  //TPacType* pac = new TPacType(rpcconf1->m_pats,rpcconf1->m_quals);*/
160  TPacType* pac = new TPacType(rpcconf, tower, logSector, logSegment);
161  m_PacTab[tower][logSector].push_back(pac);
162  }
163  }
164  }
165  };
166 
171  //const
172  TPacType* getPac(int m_tower, int logSector, int logSegment) const {
173  if (m_PacTab.size() <= (unsigned int) abs(m_tower))
174  throw RPCException("RPCPacManager::getPac: given towerNum to big");
175  // edm::LogError("RPCTrigger") << "RPCPacManager::getPac: given towerNum to big" << std::endl;
176 
177  //int curLogSector = logSector;
178  //int curlogSegment = logSegment;
179 
181  logSector = 0;
182  logSegment = 0;
183  }
184  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
185  logSector = 0;
186  }
187 
188  //XXXX//m_PacTab[abs(m_tower)][logSector][logSegment]->setCurrentPosition(m_tower, curLogSector, curlogSegment);
189  return m_PacTab[std::abs(m_tower)][logSector][logSegment];
190  };
191 
192  //const
193  TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
194  return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
195  }
196 
197  private:
198  std::vector<std::vector<std::vector<TPacType*> > > m_PacTab;
199 
201 
203 
204  L1RpcPACsCntEnum m_PACsCnt; //Used configuration version.
205 
206  void destroy(){
207  for (size_t tower = 0; tower < m_PacTab.size() ; ++tower) {
208  for (size_t logSector = 0; logSector < m_PacTab.at(tower).size(); logSector++) {
209  for (size_t logSegment = 0; logSegment < m_PacTab.at(tower).at(logSector).size() ; logSegment++) {
210  TPacType* pac = m_PacTab.at(tower).at(logSector).at(logSegment);
211  delete pac;
212  }
213  }
214  }
215  m_PacTab.clear();
216  }
217 };
218 
219 #endif
int m_SegmentCnt
Count of used differnt segments.
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:119
int getPPT() const
Definition: L1RPCConfig.h:37
TPacType * getPac(int m_tower, int logSector, int logSegment) const
L1RpcPACsCntEnum m_PACsCnt
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TPacType * getPac(const RPCConst::l1RpcConeCrdnts &coneCrdnts) const
static const int m_TOWER_COUNT
Only half of the detector.
Definition: RPCConst.h:43
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:93
void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt)
Definition: RPCPacManager.h:60