CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCPacData.cc
Go to the documentation of this file.
1 /*******************************************************************************
2 * *
3 * Karol Bunkowski *
4 * Warsaw University 2002 *
5 * Porting to CMSSW - Tomasz Fruboes
6 * *
7 *******************************************************************************/
8 #include <cmath>
9 #include <bitset>
12 
14 
15 #include <iostream>
16 
17 //#include "FWCore/MessageLogger/interface/MessageLogger.h"
18 
19 
30 RPCPacData::RPCPacData(std::string patFilesDir, int tower, int logSector, int logSegment){
31 
32  //: RPCPacBase(tower, logSector, logSegment) {
33  m_MaxQuality=0;
34  std::string patFileName;
35 
36  RPCConst rpcconst;
37 
38 
39  patFileName = patFilesDir
40  + "pacPat_t" + rpcconst.intToString(tower)
41  + "sc" + rpcconst.intToString(logSector)
42  + "sg" + rpcconst.intToString(logSegment)
43  + ".xml";
44 
46  coneCrds.m_Tower=tower;
47  coneCrds.m_LogSector=logSector;
48  coneCrds.m_LogSegment=logSegment;
49 
51  parser.parse(patFileName);
52  init(parser, coneCrds);
53 
54  m_TrackPatternsGroup.setGroupDescription("Track PatternsGroup");
55 
56 }
63  const RPCPattern::TQualityVec &qualVec) :
64  m_MaxQuality(0)
65 {
66  for(unsigned int i = 0; i < qualVec.size(); ++i) {
67  RPCPattern::TQuality quality = qualVec[i];
68  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
69  unsigned short firedPlanes = qualBits.to_ulong();
70 
71  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
72  }
73 
74 
75  insertPatterns(patVec);
76 
77 
78 }
79 
80 
81 
82 RPCPacData::RPCPacData(const L1RPCConfig * rpcconf, const int tower, const int sector, const int segment):
83  m_MaxQuality(0)
84 {
85 
86  for (unsigned int iqual=0; iqual<rpcconf->m_quals.size(); iqual++){
87 
88  if (rpcconf->m_quals[iqual].m_tower != tower ||
89  rpcconf->m_quals[iqual].m_logsector != sector ||
90  rpcconf->m_quals[iqual].m_logsegment != segment ) continue;
91 
92  RPCPattern::TQuality quality =rpcconf->m_quals[iqual];
93  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
94  unsigned short firedPlanes = qualBits.to_ulong();
95  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
96 
97  }
98 
99  insertPatterns(rpcconf->m_pats,tower,sector,segment);
100 
101 }
102 
103 
104 
105 
106 
113  return(1 + m_EnergeticPatternsGroupList.size()); //1 = track pattrens group
114 }
122  if(m_PatternsVec.size() == 0) {
123 
124  throw RPCException("GetPattren(): Patterns vec is empty, mayby it was not filled!");
125  //edm::LogError("RPCTrigger") << "GetPattren(): Patterns vec is empty, mayby it was not filled!";
126 
127  }
128  return m_PatternsVec[patNum];
129 
130 }
137  return m_PatternsVec.size();
138 }
145 bool RPCPacData::getTPatternsGroupShape(int logPlane, int logStripNum) {
146  return m_TrackPatternsGroup.m_GroupShape.getLogStripState(logPlane, logStripNum);
147 }
154 bool RPCPacData::getEPatternsGroupShape(int groupNum, int logPlane, int bitNum) {
155  TEPatternsGroupList::const_iterator iEGroup = m_EnergeticPatternsGroupList.begin();
156  int i = 0;
157  for(; iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++, i++) {
158  if(i == groupNum)
159  return iEGroup->m_GroupShape.getLogStripState(logPlane, bitNum);
160  }
161  throw RPCException("getEPatternsGroupShape(): groupNum to big!");
162  //edm::LogError("RPCTrigger")<< "getEPatternsGroupShape(): groupNum to big!";
163  return false; // XXX - TMF
164 }
165 
167 
168  RPCConst rpcconst;
169 
171  if(patternGroupNum == -1)
173  else {
174  TEPatternsGroupList::iterator iEGroup = m_EnergeticPatternsGroupList.begin();
175  int i = 0;
176  for(; iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++, i++) {
177  if(i == patternGroupNum)
178  ret = "EGroup #"+ rpcconst.intToString(i)+iEGroup->getGroupDescription();
179  }
180 
181  }
182 
183  if(ret.empty()){
184  throw RPCException("getEPatternsGroupShape(): groupNum to big!");
185  //edm::LogError("RPCTrigger")<< "getEPatternsGroupShape(): groupNum to big!";
186  }
187 
188  return ret;
189 }
190 
191 void RPCPacData::insertQualityRecord(unsigned int qualityTabNumber,
192  unsigned short firedPlanes, short quality) {
193 
194  if(quality > m_MaxQuality)
195  m_MaxQuality = quality;
196  if(qualityTabNumber < m_QualityTabsVec.size()) {
197  m_QualityTabsVec[qualityTabNumber][firedPlanes] = quality;
198  }
199  else if(qualityTabNumber == m_QualityTabsVec.size()) {
200  // XXX - added cast(int)
201 
202  //= new TQualityTab();
204  m_QualityTabsVec.push_back(qualityTab);
205  m_QualityTabsVec[qualityTabNumber][firedPlanes] = quality;
206  }
207  else
208  throw RPCException("insertQualityRecord(): wrong qualityTabNumber");
209  //edm::LogError("RPCTrigger") << "insertQualityRecord(): wrong qualityTabNumber";
210 }
211 
212 
213 void RPCPacData::insertPatterns(const RPCPattern::RPCPatVec& patternsVec, const int tower, const int sector, const int segment) {
214 
215  bool ignorePos = false;
216  if ( tower == 99 || sector == 99 || segment == 99) ignorePos = true;
217 
218  RPCConst rpcconst;
219 
220  for(RPCPattern::RPCPatVec::const_iterator patIt = patternsVec.begin();
221  patIt != patternsVec.end();
222  patIt++)
223  {
224  if (!ignorePos &&
225  (patIt->getTower() != tower
226  || patIt->getLogSector() != sector
227  || patIt->getLogSegment() != segment) ) continue;
228 
229  if(patIt->getPatternType() == RPCPattern::PAT_TYPE_T)
231  else if(patIt->getPatternType() == RPCPattern::PAT_TYPE_E) {
232  TEPatternsGroupList::iterator iEGroup;
233  for(iEGroup = m_EnergeticPatternsGroupList.begin();
234  iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++)
235  if(iEGroup->check(patIt))
236  break;
237  if(iEGroup == m_EnergeticPatternsGroupList.end()) {
238  TEPatternsGroup newEGroup(patIt);
239  newEGroup.setGroupDescription(
240  //"EGroup #"+ rpcconst.intToString(m_EnergeticPatternsGroupList.size())+
241  ", code: " + rpcconst.intToString(patIt->getCode()) +
242  ", dir: " + rpcconst.intToString(patIt->getSign()) +
243  ", refGroup: " + rpcconst.intToString(patIt->getRefGroup()) +
244  ", qualityTabNumber: " + rpcconst.intToString(patIt->getQualityTabNumber()));
245  m_EnergeticPatternsGroupList.push_back(newEGroup);
246  }
247  else
248  iEGroup->addPattern(patIt);
249  }
250  else
251  throw RPCException("InsertPattern(): unsupported pattern type");
252  //edm::LogError("RPCTrigger") << "InsertPattern(): unsupported pattern type";
253  }
254 
255  if(m_EnergeticPatternsGroupList.size() != 0) {
256 
257  m_EnergeticPatternsGroupList.sort(); //to jest potrzebne, bo w run() przechodzi
258  //pierwszy paettern, ktory ma Maxymalna quality, wiec
259  //grupy musza byc
261  }
262 }
263 
265  for(unsigned int i = 0; i < parser.getQualityVec().size(); i++) {
266  RPCPattern::TQuality quality = parser.getQualityVec()[i];
267  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
268  unsigned short firedPlanes = qualBits.to_ulong();
269 
270  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
271  }
272 
273  m_PatternsVec = parser.getPatternsVec(coneCrdnts);
275 }
int i
Definition: DBlmapReader.cc:9
std::string getPatternsGroupDescription(int patternGroupNum)
Definition: RPCPacData.cc:166
void insertPatterns(const RPCPattern::RPCPatVec &pattern, const int tower=99, const int sector=99, const int segment=99)
Definition: RPCPacData.cc:213
std::string getGroupDescription() const
int getPatternsCount()
Definition: RPCPacData.cc:136
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:119
RPCLogCone m_GroupShape
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:211
void addPattern(const RPCPattern::RPCPatVec::const_iterator &pattern)
RPCPattern::TQualityVec m_quals
Definition: L1RPCConfig.h:44
TTPatternsGroup m_TrackPatternsGroup
Here patters used in &quot;baseline&quot; algorith are stored.
Definition: RPCPacData.h:91
void setGroupDescription(std::string groupDescription)
static const TPatternType PAT_TYPE_T
Definition: RPCPattern.h:57
unsigned char m_FiredPlanes
Definition: RPCPattern.h:39
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
void insertQualityRecord(unsigned int qualityTabNumber, unsigned short firedPlanes, short quality)
Definition: RPCPacData.cc:191
RPCConst::TQualityTabsVec m_QualityTabsVec
Definition: RPCPacData.h:84
std::string intToString(int number)
Converts inteager number to string.
Definition: RPCConst.cc:252
RPCPattern::RPCPatVec m_PatternsVec
Definition: RPCPacData.h:74
const RPCPattern::RPCPatVec & getPatternsVec(const RPCConst::l1RpcConeCrdnts &coneCrds) const
RPCPattern getPattern(int patNum) const
Definition: RPCPacData.cc:121
std::vector< TQuality > TQualityVec
Definition: RPCPattern.h:49
TEPatternsGroupList m_EnergeticPatternsGroupList
Definition: RPCPacData.h:88
static const TPatternType PAT_TYPE_E
Definition: RPCPattern.h:58
bool getEPatternsGroupShape(int groupNum, int logPlane, int logStripNum)
Definition: RPCPacData.cc:154
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:47
const RPCPattern::TQualityVec & getQualityVec() const
std::vector< short > TQualityTab
Definition: RPCConst.h:114
int getPatternsGroupCount()
Definition: RPCPacData.cc:112
RPCPacData(std::string patFilesDir, int m_tower, int logSector, int logSegment)
Definition: RPCPacData.cc:30
short m_MaxQuality
Definition: RPCPacData.h:69
Group of paterns for &quot;improved&quot;(&quot;energetic&quot;) algorithm. In current implementation all patterns in giv...
bool getTPatternsGroupShape(int logPlane, int logStripNum)
Definition: RPCPacData.cc:145
RPCPattern::RPCPatVec m_pats
Definition: L1RPCConfig.h:37
void parse(std::string fileName)
void init(const RPCPatternsParser &parser, const RPCConst::l1RpcConeCrdnts &coneCrdnts)
Definition: RPCPacData.cc:264
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40