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 }
97 RPCPattern RPCPacData::getPattern(int patNum) const {
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 }
109 int RPCPacData::getPatternsCount() { return m_PatternsVec.size(); }
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 
177 void RPCPacData::insertPatterns(const RPCPattern::RPCPatVec& patternsVec,
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 
222 void RPCPacData::init(const RPCPatternsParser& parser, const RPCConst::l1RpcConeCrdnts& coneCrdnts) {
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 }
RPCPattern::TQualityVec
std::vector< TQuality > TQualityVec
Definition: RPCPattern.h:49
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
RPCLogCone::getLogStripState
bool getLogStripState(int logPlane, unsigned int logStripNum) const
Definition: RPCLogCone.cc:183
L1RPCConfig_cff.rpcconf
rpcconf
Definition: L1RPCConfig_cff.py:3
RPCConst::intToString
std::string intToString(int number)
Converts inteager number to string.
Definition: RPCConst.cc:264
RPCPacData::insertQualityRecord
void insertQualityRecord(unsigned int qualityTabNumber, unsigned short firedPlanes, short quality)
Definition: RPCPacData.cc:159
mps_fire.i
i
Definition: mps_fire.py:428
RPCPacData::getEPatternsGroupShape
bool getEPatternsGroupShape(int groupNum, int logPlane, int logStripNum)
Definition: RPCPacData.cc:124
RPCException.h
RPCPacData::m_EnergeticPatternsGroupList
TEPatternsGroupList m_EnergeticPatternsGroupList
Definition: RPCPacData.h:88
RPCConst::l1RpcConeCrdnts::m_Tower
int m_Tower
Definition: RPCConst.h:119
TPatternsGroup::addPattern
void addPattern(const RPCPattern::RPCPatVec::const_iterator &pattern)
Definition: TPatternsGroup.cc:19
RPCPacData::RPCPacData
RPCPacData(std::string patFilesDir, int m_tower, int logSector, int logSegment)
Definition: RPCPacData.cc:28
RPCPacData::m_MaxQuality
short m_MaxQuality
Definition: RPCPacData.h:69
hgcalTowerProducer_cfi.tower
tower
Definition: hgcalTowerProducer_cfi.py:4
RPCPacData::getTPatternsGroupShape
bool getTPatternsGroupShape(int logPlane, int logStripNum)
Definition: RPCPacData.cc:115
RPCPattern::PAT_TYPE_E
static const TPatternType PAT_TYPE_E
Definition: RPCPattern.h:56
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
TPatternsGroup::setGroupDescription
void setGroupDescription(std::string groupDescription)
Definition: TPatternsGroup.cc:29
RPCConst.h
L1RPCConfig
Definition: L1RPCConfig.h:29
RPCPacData::getPatternsGroupCount
int getPatternsGroupCount()
Definition: RPCPacData.cc:87
quality
const uint32_t *__restrict__ Quality * quality
Definition: CAHitNtupletGeneratorKernelsImpl.h:109
RPCPattern::TQuality
Definition: RPCPattern.h:38
TPatternsGroup::getGroupDescription
std::string getGroupDescription() const
Definition: TPatternsGroup.cc:31
RPCConst::l1RpcConeCrdnts
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
RPCPacData::insertPatterns
void insertPatterns(const RPCPattern::RPCPatVec &pattern, const int tower=99, const int sector=99, const int segment=99)
Definition: RPCPacData.cc:176
RPCConst::TQualityTab
std::vector< short > TQualityTab
Definition: RPCConst.h:113
TPatternsGroup::m_GroupShape
RPCLogCone m_GroupShape
Definition: TPatternsGroup.h:48
RPCPacData::getPatternsGroupDescription
std::string getPatternsGroupDescription(int patternGroupNum)
Definition: RPCPacData.cc:136
RPCPacData::getPattern
RPCPattern getPattern(int patNum) const
Definition: RPCPacData.cc:96
RPCPatternsParser
Definition: RPCPatternsParser.h:19
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCPacData::getPatternsCount
int getPatternsCount()
Definition: RPCPacData.cc:108
RPCConst::l1RpcConeCrdnts::m_LogSegment
int m_LogSegment
Definition: RPCConst.h:121
RPCPacData.h
RPCPattern
Definition: RPCPattern.h:16
RPCException
Definition: RPCException.h:21
RPCPacData::init
void init(const RPCPatternsParser &parser, const RPCConst::l1RpcConeCrdnts &coneCrdnts)
Definition: RPCPacData.cc:221
RPCPacData::m_TrackPatternsGroup
TTPatternsGroup m_TrackPatternsGroup
Here patters used in "baseline" algorith are stored.
Definition: RPCPacData.h:91
RPCPattern::RPCPatVec
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
RPCPacData::m_QualityTabsVec
RPCConst::TQualityTabsVec m_QualityTabsVec
Definition: RPCPacData.h:84
RPCPattern::PAT_TYPE_T
static const TPatternType PAT_TYPE_T
Definition: RPCPattern.h:55
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
RPCConst::m_LOGPLANES_COUNT
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:45
RPCConst::l1RpcConeCrdnts::m_LogSector
int m_LogSector
Definition: RPCConst.h:120
RPCConst
Definition: RPCConst.h:23
TEPatternsGroup
Group of paterns for "improved"("energetic") algorithm. In current implementation all patterns in giv...
Definition: TEPatternsGroup.h:23
RPCPacData::m_PatternsVec
RPCPattern::RPCPatVec m_PatternsVec
Definition: RPCPacData.h:74