CMS 3D CMS Logo

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 
29 RPCPacData::RPCPacData(std::string patFilesDir, int tower, int logSector, int logSegment) {
30  //: RPCPacBase(tower, logSector, logSegment) {
31  m_MaxQuality = 0;
32  std::string patFileName;
33 
34  RPCConst rpcconst;
35 
36  patFileName = patFilesDir + "pacPat_t" + rpcconst.intToString(tower) + "sc" + rpcconst.intToString(logSector) + "sg" +
37  rpcconst.intToString(logSegment) + ".xml";
38 
40  coneCrds.m_Tower = tower;
41  coneCrds.m_LogSector = logSector;
42  coneCrds.m_LogSegment = logSegment;
43 
45  parser.parse(patFileName);
46  init(parser, coneCrds);
47 
48  m_TrackPatternsGroup.setGroupDescription("Track PatternsGroup");
49 }
55 RPCPacData::RPCPacData(const RPCPattern::RPCPatVec& patVec, const RPCPattern::TQualityVec& qualVec) : m_MaxQuality(0) {
56  for (unsigned int i = 0; i < qualVec.size(); ++i) {
57  RPCPattern::TQuality quality = qualVec[i];
58  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
59  unsigned short firedPlanes = qualBits.to_ulong();
60 
61  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
62  }
63 
64  insertPatterns(patVec);
65 }
66 
67 RPCPacData::RPCPacData(const L1RPCConfig* rpcconf, const int tower, const int sector, const int segment)
68  : m_MaxQuality(0) {
69  for (unsigned int iqual = 0; iqual < rpcconf->m_quals.size(); iqual++) {
70  if (rpcconf->m_quals[iqual].m_tower != tower || rpcconf->m_quals[iqual].m_logsector != sector ||
71  rpcconf->m_quals[iqual].m_logsegment != segment)
72  continue;
73 
74  RPCPattern::TQuality quality = rpcconf->m_quals[iqual];
75  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
76  unsigned short firedPlanes = qualBits.to_ulong();
77  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
78  }
79 
80  insertPatterns(rpcconf->m_pats, tower, sector, segment);
81 }
82 
89  return (1 + m_EnergeticPatternsGroupList.size()); //1 = track pattrens group
90 }
98  if (m_PatternsVec.empty()) {
99  throw RPCException("GetPattren(): Patterns vec is empty, mayby it was not filled!");
100  //edm::LogError("RPCTrigger") << "GetPattren(): Patterns vec is empty, mayby it was not filled!";
101  }
102  return m_PatternsVec[patNum];
103 }
116 bool RPCPacData::getTPatternsGroupShape(int logPlane, int logStripNum) {
117  return m_TrackPatternsGroup.m_GroupShape.getLogStripState(logPlane, logStripNum);
118 }
125 bool RPCPacData::getEPatternsGroupShape(int groupNum, int logPlane, int bitNum) {
126  TEPatternsGroupList::const_iterator iEGroup = m_EnergeticPatternsGroupList.begin();
127  int i = 0;
128  for (; iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++, i++) {
129  if (i == groupNum)
130  return iEGroup->m_GroupShape.getLogStripState(logPlane, bitNum);
131  }
132  throw RPCException("getEPatternsGroupShape(): groupNum to big!");
133  //edm::LogError("RPCTrigger")<< "getEPatternsGroupShape(): groupNum to big!";
134  return false; // XXX - TMF
135 }
136 
138  RPCConst rpcconst;
139 
141  if (patternGroupNum == -1)
143  else {
144  TEPatternsGroupList::iterator iEGroup = m_EnergeticPatternsGroupList.begin();
145  int i = 0;
146  for (; iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++, i++) {
147  if (i == patternGroupNum)
148  ret = "EGroup #" + rpcconst.intToString(i) + iEGroup->getGroupDescription();
149  }
150  }
151 
152  if (ret.empty()) {
153  throw RPCException("getEPatternsGroupShape(): groupNum to big!");
154  //edm::LogError("RPCTrigger")<< "getEPatternsGroupShape(): groupNum to big!";
155  }
156 
157  return ret;
158 }
159 
160 void RPCPacData::insertQualityRecord(unsigned int qualityTabNumber, unsigned short firedPlanes, short quality) {
161  if (quality > m_MaxQuality)
163  if (qualityTabNumber < m_QualityTabsVec.size()) {
164  m_QualityTabsVec[qualityTabNumber][firedPlanes] = quality;
165  } else if (qualityTabNumber == m_QualityTabsVec.size()) {
166  // XXX - added cast(int)
167 
168  //= new TQualityTab();
170  m_QualityTabsVec.push_back(qualityTab);
171  m_QualityTabsVec[qualityTabNumber][firedPlanes] = quality;
172  } else
173  throw RPCException("insertQualityRecord(): wrong qualityTabNumber");
174  //edm::LogError("RPCTrigger") << "insertQualityRecord(): wrong qualityTabNumber";
175 }
176 
178  const int tower,
179  const int sector,
180  const int segment) {
181  bool ignorePos = false;
182  if (tower == 99 || sector == 99 || segment == 99)
183  ignorePos = true;
184 
185  RPCConst rpcconst;
186 
187  for (RPCPattern::RPCPatVec::const_iterator patIt = patternsVec.begin(); patIt != patternsVec.end(); patIt++) {
188  if (!ignorePos &&
189  (patIt->getTower() != tower || patIt->getLogSector() != sector || patIt->getLogSegment() != segment))
190  continue;
191 
192  if (patIt->getPatternType() == RPCPattern::PAT_TYPE_T)
194  else if (patIt->getPatternType() == RPCPattern::PAT_TYPE_E) {
195  TEPatternsGroupList::iterator iEGroup;
196  for (iEGroup = m_EnergeticPatternsGroupList.begin(); iEGroup != m_EnergeticPatternsGroupList.end(); iEGroup++)
197  if (iEGroup->check(patIt))
198  break;
199  if (iEGroup == m_EnergeticPatternsGroupList.end()) {
200  TEPatternsGroup newEGroup(patIt);
201  newEGroup.setGroupDescription(
202  //"EGroup #"+ rpcconst.intToString(m_EnergeticPatternsGroupList.size())+
203  ", code: " + rpcconst.intToString(patIt->getCode()) + ", dir: " + rpcconst.intToString(patIt->getSign()) +
204  ", refGroup: " + rpcconst.intToString(patIt->getRefGroup()) +
205  ", qualityTabNumber: " + rpcconst.intToString(patIt->getQualityTabNumber()));
206  m_EnergeticPatternsGroupList.push_back(newEGroup);
207  } else
208  iEGroup->addPattern(patIt);
209  } else
210  throw RPCException("InsertPattern(): unsupported pattern type");
211  //edm::LogError("RPCTrigger") << "InsertPattern(): unsupported pattern type";
212  }
213 
214  if (!m_EnergeticPatternsGroupList.empty()) {
215  m_EnergeticPatternsGroupList.sort(); //to jest potrzebne, bo w run() przechodzi
216  //pierwszy paettern, ktory ma Maxymalna quality, wiec
217  //grupy musza byc
219  }
220 }
221 
223  for (unsigned int i = 0; i < parser.getQualityVec().size(); i++) {
224  RPCPattern::TQuality quality = parser.getQualityVec()[i];
225  std::bitset<RPCConst::m_LOGPLANES_COUNT> qualBits(quality.m_FiredPlanes);
226  unsigned short firedPlanes = qualBits.to_ulong();
227 
228  insertQualityRecord(quality.m_QualityTabNumber, firedPlanes, quality.m_QualityValue);
229  }
230 
231  m_PatternsVec = parser.getPatternsVec(coneCrdnts);
233 }
std::string getPatternsGroupDescription(int patternGroupNum)
Definition: RPCPacData.cc:137
void insertPatterns(const RPCPattern::RPCPatVec &pattern, const int tower=99, const int sector=99, const int segment=99)
Definition: RPCPacData.cc:177
int getPatternsCount()
Definition: RPCPacData.cc:109
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
RPCLogCone m_GroupShape
ret
prodAgent to be discontinued
void addPattern(const RPCPattern::RPCPatVec::const_iterator &pattern)
constexpr int pow(int x)
Definition: conifer.h:24
TTPatternsGroup m_TrackPatternsGroup
Here patters used in "baseline" algorith are stored.
Definition: RPCPacData.h:91
void setGroupDescription(std::string groupDescription)
string quality
static const TPatternType PAT_TYPE_T
Definition: RPCPattern.h:55
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:184
void insertQualityRecord(unsigned int qualityTabNumber, unsigned short firedPlanes, short quality)
Definition: RPCPacData.cc:160
RPCConst::TQualityTabsVec m_QualityTabsVec
Definition: RPCPacData.h:84
std::string intToString(int number)
Converts inteager number to string.
Definition: RPCConst.cc:264
RPCPattern::RPCPatVec m_PatternsVec
Definition: RPCPacData.h:74
std::vector< TQuality > TQualityVec
Definition: RPCPattern.h:49
TEPatternsGroupList m_EnergeticPatternsGroupList
Definition: RPCPacData.h:88
static const TPatternType PAT_TYPE_E
Definition: RPCPattern.h:56
std::string getGroupDescription() const
bool getEPatternsGroupShape(int groupNum, int logPlane, int logStripNum)
Definition: RPCPacData.cc:125
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:45
std::vector< short > TQualityTab
Definition: RPCConst.h:113
int getPatternsGroupCount()
Definition: RPCPacData.cc:88
RPCPacData(std::string patFilesDir, int m_tower, int logSector, int logSegment)
Definition: RPCPacData.cc:29
short m_MaxQuality
Definition: RPCPacData.h:69
Group of paterns for "improved"("energetic") algorithm. In current implementation all patterns in giv...
bool getTPatternsGroupShape(int logPlane, int logStripNum)
Definition: RPCPacData.cc:116
RPCPattern getPattern(int patNum) const
Definition: RPCPacData.cc:97
void init(const RPCPatternsParser &parser, const RPCConst::l1RpcConeCrdnts &coneCrdnts)
Definition: RPCPacData.cc:222