test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
27 #include <cstdlib>
28 #ifndef _STAND_ALONE
30 #endif // _STAND_ALONE
31 
33 // TODO: should be moved to L1RPConfig
36  _12_PACS_PER_TOWER = 12, //the same m_PAC in the same segment in every sector,
39 };
40 
41 
42 template<class TPacType> class RPCPacManager {
43 public:
45  for (unsigned int m_tower = 0; m_tower < m_PacTab.size(); m_tower++)
46  for (unsigned int logSector = 0; logSector < m_PacTab[m_tower].size(); logSector++) {
47  for (unsigned int logSegment = 0; logSegment < m_PacTab[m_tower][logSector].size(); logSegment++) {
48  TPacType* pac = m_PacTab[m_tower][logSector][logSegment];
49  delete pac;
50  }
51  }
52  }
53 
54 
55 
61  void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt) {
62  destroy();
63  m_PACsCnt = _PACsCnt;
65  m_SectorsCnt = 1;
66  m_SegmentCnt = 1;
67  }
68  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
69  m_SectorsCnt = 1;
70  m_SegmentCnt = 12;
71  }
72  else if(m_PACsCnt == _144_PACS_PER_TOWER) {
73  m_SectorsCnt = 12;
74  m_SegmentCnt = 12;
75  }
76  else if(m_PACsCnt == TB_TESTS) {
77  m_SectorsCnt = 1;
78  m_SegmentCnt = 4;
79  }
80 
81  for (int m_tower = 0; m_tower < RPCConst::m_TOWER_COUNT; m_tower++) {
82  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
83  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
84  m_PacTab[m_tower].push_back(std::vector<TPacType*>());
85  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
86  TPacType* pac = new TPacType(patFilesDirectory, m_tower, logSector, logSegment);
87  m_PacTab[m_tower][logSector].push_back(pac);
88  }
89  }
90  }
92  };
93 
94 
95  void init(const L1RPCConfig *rpcconf) {
96  destroy();
97  switch (rpcconf->getPPT()){
98  case 1:
100  break;
101  case 12:
103  break;
104  case 144:
106  break;
107 
108  }
109 
111  m_SectorsCnt = 1;
112  m_SegmentCnt = 1;
113  }
114  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
115  m_SectorsCnt = 1;
116  m_SegmentCnt = 12;
117  }
118  else if(m_PACsCnt == _144_PACS_PER_TOWER) {
119  m_SectorsCnt = 12;
120  m_SegmentCnt = 12;
121  }
122  else if(m_PACsCnt == TB_TESTS) {
123  m_SectorsCnt = 1;
124  m_SegmentCnt = 4;
125  }
126 
127  /*
128  std::vector<std::vector<std::vector<RPCPattern::RPCPatVec> > > patvec;
129  std::vector<std::vector<std::vector<RPCPattern::TQualityVec> > > qualvec;
130  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; ++tower) {
131  patvec.push_back(std::vector< std::vector< RPCPattern::RPCPatVec > >());
132  qualvec.push_back(std::vector< std::vector< RPCPattern::TQualityVec > >());
133  for (int logSector = 0; logSector < m_SectorsCnt; ++logSector) {
134  patvec[tower].push_back(std::vector< RPCPattern::RPCPatVec >());
135  qualvec[tower].push_back(std::vector< RPCPattern::TQualityVec >());
136  for (int logSegment = 0; logSegment < m_SegmentCnt; ++logSegment) {
137  patvec[tower][logSector].push_back(RPCPattern::RPCPatVec());
138  qualvec[tower][logSector].push_back(RPCPattern::TQualityVec());
139  }
140  }
141  }
142 
143  for (unsigned int ipat=0; ipat<rpcconf->m_pats.size(); ipat++)
144  patvec[rpcconf->m_pats[ipat].getTower()][rpcconf->m_pats[ipat].getLogSector()][rpcconf->m_pats[ipat].getLogSegment()].push_back(rpcconf->m_pats[ipat]);
145  for (unsigned int iqual=0; iqual<rpcconf->m_quals.size(); iqual++)
146  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]);
147  */
148 
149 
150  for (int tower = 0; tower < RPCConst::m_TOWER_COUNT; tower++) {
151  m_PacTab.push_back(std::vector<std::vector<TPacType*> >());
152  for (int logSector = 0; logSector < m_SectorsCnt; logSector++) {
153  m_PacTab[tower].push_back(std::vector<TPacType*>());
154  for (int logSegment = 0; logSegment < m_SegmentCnt; logSegment++) {
155  /*L1RPCConfig* rpcconf1=new L1RPCConfig();
156  rpcconf1->setPPT(rpcconf->getPPT());
157  for (unsigned int ipat=0; ipat<patvec[tower][logSector][logSegment].size(); ipat++)
158  rpcconf1->m_pats.push_back(patvec[tower][logSector][logSegment][ipat]);
159  for (unsigned int iqual=0; iqual<qualvec[tower][logSector][logSegment].size(); iqual++)
160  rpcconf1->m_quals.push_back(qualvec[tower][logSector][logSegment][iqual]);
161  //TPacType* pac = new TPacType(rpcconf1->m_pats,rpcconf1->m_quals);*/
162  TPacType* pac = new TPacType(rpcconf, tower, logSector, logSegment);
163  m_PacTab[tower][logSector].push_back(pac);
164  }
165  }
166  }
168  };
169 
174  //const
175  TPacType* getPac(int m_tower, int logSector, int logSegment) const {
176  if (m_PacTab.size() <= (unsigned int) abs(m_tower))
177  throw RPCException("RPCPacManager::getPac: given towerNum to big");
178  // edm::LogError("RPCTrigger") << "RPCPacManager::getPac: given towerNum to big" << std::endl;
179 
180  //int curLogSector = logSector;
181  //int curlogSegment = logSegment;
182 
184  logSector = 0;
185  logSegment = 0;
186  }
187  else if(m_PACsCnt == _12_PACS_PER_TOWER) {
188  logSector = 0;
189  }
190 
191  //XXXX//m_PacTab[abs(m_tower)][logSector][logSegment]->setCurrentPosition(m_tower, curLogSector, curlogSegment);
192  return m_PacTab[std::abs(m_tower)][logSector][logSegment];
193  };
194 
195  //const
196  TPacType* getPac(const RPCConst::l1RpcConeCrdnts& coneCrdnts) const {
197  return getPac(coneCrdnts.m_Tower, coneCrdnts.m_LogSector, coneCrdnts.m_LogSegment);
198  }
199 
200  private:
201  std::vector<std::vector<std::vector<TPacType*> > > m_PacTab;
202 
204 
206 
207  L1RpcPACsCntEnum m_PACsCnt; //Used configuration version.
208 
209  void destroy(){
210  for (size_t tower = 0; tower < m_PacTab.size() ; ++tower) {
211  for (size_t logSector = 0; logSector < m_PacTab.at(tower).size(); logSector++) {
212  for (size_t logSegment = 0; logSegment < m_PacTab.at(tower).at(logSector).size() ; logSegment++) {
213  TPacType* pac = m_PacTab.at(tower).at(logSector).at(logSegment);
214  delete pac;
215  }
216  }
217  }
218  m_PacTab.clear();
219  }
220 };
221 
222 #endif
int m_SegmentCnt
Count of used differnt segments.
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:119
void xercesTerminate()
Definition: Xerces.cc:23
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:34
void init(const L1RPCConfig *rpcconf)
Definition: RPCPacManager.h:95
void init(std::string patFilesDirectory, L1RpcPACsCntEnum _PACsCnt)
Definition: RPCPacManager.h:61