CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes | Static Private Attributes
RPCPatternsParser Class Reference

#include <RPCPatternsParser.h>

Inheritance diagram for RPCPatternsParser:

Public Member Functions

void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) override
 
const RPCPattern::RPCPatVecgetPatternsVec (const RPCConst::l1RpcConeCrdnts &coneCrds) const
 
const RPCPattern::RPCPatVecgetPatternsVec (const int tower, const int sc, const int sg) const
 
const RPCPattern::TQualityVecgetQualityVec () const
 
void parse (std::string fileName)
 
 RPCPatternsParser ()
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attrs) override
 
 ~RPCPatternsParser () override
 

Private Types

typedef std::map< RPCConst::l1RpcConeCrdnts, RPCPattern::RPCPatVecTPatternsVecsMap
 

Private Attributes

TPatternsVecsMap::iterator m_CurPacIt
 
RPCPattern m_CurPattern
 
std::string m_CurrElement
 
TPatternsVecsMap m_PatternsVecsMap
 
RPCPattern::TQualityVec m_QualityVec
 

Static Private Attributes

static int m_InstanceCount = 0
 

Detailed Description

Definition at line 20 of file RPCPatternsParser.h.

Member Typedef Documentation

◆ TPatternsVecsMap

Definition at line 64 of file RPCPatternsParser.h.

Constructor & Destructor Documentation

◆ RPCPatternsParser()

RPCPatternsParser::RPCPatternsParser ( )

Definition at line 97 of file RPCPatternsParser.cc.

References cms::concurrency::xercesInitialize(), and xMLCh2String().

97  {
98  if (m_InstanceCount == 0) {
99  try {
101  //XPathEvaluator::initialize();
102  m_InstanceCount++;
103  } catch (const XMLException& toCatch) {
104  throw RPCException("Error during Xerces-c Initialization: " + xMLCh2String(toCatch.getMessage()));
105  //edm::LogError("RPCTrigger")<< "Error during Xerces-c Initialization: "
106  // + xMLCh2String(toCatch.getMessage());
107  }
108  }
109 }
string xMLCh2String(const XMLCh *ch)
void xercesInitialize()
Definition: Xerces.cc:18
static int m_InstanceCount

◆ ~RPCPatternsParser()

RPCPatternsParser::~RPCPatternsParser ( )
override

Definition at line 111 of file RPCPatternsParser.cc.

References cms::concurrency::xercesTerminate().

Member Function Documentation

◆ endElement()

void RPCPatternsParser::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)
override

Definition at line 187 of file RPCPatternsParser.cc.

References xMLCh2String().

187  {
188  string element = xMLCh2String(localname);
189  if (element == "pat") {
190  m_CurPacIt->second.push_back(m_CurPattern);
191  }
192 }
string xMLCh2String(const XMLCh *ch)
TPatternsVecsMap::iterator m_CurPacIt

◆ getPatternsVec() [1/2]

const RPCPattern::RPCPatVec & RPCPatternsParser::getPatternsVec ( const RPCConst::l1RpcConeCrdnts coneCrds) const

Definition at line 45 of file RPCPatternsParser.cc.

References RPCConst::l1RpcConeCrdnts::m_LogSector, RPCConst::l1RpcConeCrdnts::m_LogSegment, RPCConst::l1RpcConeCrdnts::m_Tower, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

45  {
46  TPatternsVecsMap::const_iterator patVecIt = m_PatternsVecsMap.find(coneCrds);
47  if (patVecIt == m_PatternsVecsMap.end()) {
48  std::stringstream ss;
49  ss << coneCrds.m_Tower << " " << coneCrds.m_LogSector << " " << coneCrds.m_LogSegment;
50  throw RPCException(std::string("no such a cone in m_PatternsVecsMap: ") + ss.str());
51  //edm::LogError("RPCTrigger")<< "no such a cone in m_PatternsVecsMap";
52  }
53  return patVecIt->second; // XXX - TMF - was in if{}, changed to avoid warning
54 }
TPatternsVecsMap m_PatternsVecsMap

◆ getPatternsVec() [2/2]

const RPCPattern::RPCPatVec & RPCPatternsParser::getPatternsVec ( const int  tower,
const int  sc,
const int  sg 
) const

Definition at line 56 of file RPCPatternsParser.cc.

References l1tHGCalTowerProducer_cfi::tower.

56  {
57  RPCConst::l1RpcConeCrdnts cords(tower, sc, sg);
58 
59  return getPatternsVec(cords);
60 }
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
const RPCPattern::RPCPatVec & getPatternsVec(const RPCConst::l1RpcConeCrdnts &coneCrds) const

◆ getQualityVec()

const RPCPattern::TQualityVec& RPCPatternsParser::getQualityVec ( ) const
inline

Definition at line 49 of file RPCPatternsParser.h.

References m_QualityVec.

49  { //XXX - clean me!
50  return m_QualityVec;
51  };
RPCPattern::TQualityVec m_QualityVec

◆ parse()

void RPCPatternsParser::parse ( std::string  fileName)

Definition at line 113 of file RPCPatternsParser.cc.

References MillePedeFileConverter_cfg::fileName, groupFilesInBlocks::fin, and writedatasetfile::parser.

113  {
114  ifstream fin;
115  fin.open(fileName.c_str());
116  if (fin.fail()) {
117  throw RPCException("Cannot open the file" + fileName);
118  //edm::LogError("RPCTrigger") << "Cannot open the file" + fileName;
119  }
120  fin.close();
121 
122  SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
123  parser->setContentHandler(this);
124 
125  m_QualityVec.clear();
126  parser->parse(fileName.c_str());
127  delete parser;
128 }
RPCPattern::TQualityVec m_QualityVec

◆ startElement()

void RPCPatternsParser::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
override

Definition at line 130 of file RPCPatternsParser.cc.

References Char2XMLCh, hltPFPuppi_cfi::cone, RPCPattern::PAT_TYPE_E, RPCPattern::PAT_TYPE_T, DiDispStaMuonMonitor_cfi::pt, quality, AlCaHLTBitMon_QueryRunRegistry::string, RPCConst::stringToInt(), and xMLCh2String().

133  {
134  RPCConst rpcconst;
135 
136  m_CurrElement = xMLCh2String(localname);
137  if (m_CurrElement == "quality") {
138  //<quality id = "0" planes = "011110" val = 1/>
140 
141  quality.m_QualityTabNumber = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("id"))));
142  std::bitset<8> firedPl(xMLCh2String(attrs.getValue(Char2XMLCh("planes"))));
143  unsigned long fpUL = firedPl.to_ulong();
144  quality.m_FiredPlanes = (unsigned char)(fpUL & 0xFF);
145  //quality.m_FiredPlanes = xMLCh2String(attrs.getValue(Char2XMLCh("planes")));
146  quality.m_QualityValue = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("val"))));
147 
148  m_QualityVec.push_back(quality);
149  } else if (m_CurrElement == "pac") {
150  //<pac id ="0" m_tower = "0" logSector = "0" logSegment = "0" descr = "">
152  cone.m_Tower = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("tower"))));
153  cone.m_LogSector = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSector"))));
154  cone.m_LogSegment = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSegment"))));
155  pair<TPatternsVecsMap::iterator, bool> res =
157  if (res.second == true)
158  m_CurPacIt = res.first;
159  else
160  throw RPCException(std::string("m_PatternsVecsMap insertion failed - cone already exixsts?"));
161  //edm::LogError("RPCTrigger") << "m_PatternsVecsMap insertion failed - cone already exixsts?";
162  } else if (m_CurrElement == "pat") {
163  //<pat type="E" grp="0" qual="0" sign="0" code="31" num="0">
164  string pt = xMLCh2String(attrs.getValue(Char2XMLCh("type")));
165  if (pt == "E")
167  else if (pt == "T")
169  else
170  throw RPCException("unknown pattern type: " + pt);
171  //edm::LogError("RPCTrigger") << "unknown pattern type: " + pt;
172 
173  m_CurPattern.setRefGroup(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("grp")))));
174  m_CurPattern.setQualityTabNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("qual")))));
175 
176  m_CurPattern.setSign(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("sign")))));
177  m_CurPattern.setCode(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("code")))));
178  m_CurPattern.setNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("num")))));
179  } else if (m_CurrElement == "str") {
180  //<logstrip plane="m_LOGPLANE1" from="32" to="32"/>
181  int logPlane = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("Pl"))));
182  m_CurPattern.setStripFrom(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("f")))));
183  m_CurPattern.setStripTo(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("t")))) + 1);
184  }
185 }
void setRefGroup(int refGroup)
Definition: RPCPattern.cc:89
string xMLCh2String(const XMLCh *ch)
void setStripTo(int logPlane, int stripTo)
Definition: RPCPattern.cc:47
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
void setPatternType(TPatternType patternType)
Definition: RPCPattern.cc:87
TPatternsVecsMap::iterator m_CurPacIt
Definition: Electron.h:6
void setStripFrom(int logPlane, int stripFrom)
Definition: RPCPattern.cc:45
RPCPattern::TQualityVec m_QualityVec
#define Char2XMLCh(str)
static const TPatternType PAT_TYPE_T
Definition: RPCPattern.h:55
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
TPatternsVecsMap m_PatternsVecsMap
void setNumber(int a)
Definition: RPCPattern.cc:85
void setQualityTabNumber(int qualityTabNumber)
Definition: RPCPattern.cc:91
std::string m_CurrElement
static const TPatternType PAT_TYPE_E
Definition: RPCPattern.h:56
void setSign(int a)
Definition: RPCPattern.cc:83
void setCode(int a)
Definition: RPCPattern.cc:81
string quality
int stringToInt(std::string str)
Converts string to inteager number. If string contains chars, that are not digits, throws RPCException.
Definition: RPCConst.cc:255

Member Data Documentation

◆ m_CurPacIt

TPatternsVecsMap::iterator RPCPatternsParser::m_CurPacIt
private

Definition at line 68 of file RPCPatternsParser.h.

◆ m_CurPattern

RPCPattern RPCPatternsParser::m_CurPattern
private

Definition at line 70 of file RPCPatternsParser.h.

◆ m_CurrElement

std::string RPCPatternsParser::m_CurrElement
private

Definition at line 60 of file RPCPatternsParser.h.

◆ m_InstanceCount

int RPCPatternsParser::m_InstanceCount = 0
staticprivate

Definition at line 51 of file RPCPatternsParser.h.

◆ m_PatternsVecsMap

TPatternsVecsMap RPCPatternsParser::m_PatternsVecsMap
private

Definition at line 66 of file RPCPatternsParser.h.

◆ m_QualityVec

RPCPattern::TQualityVec RPCPatternsParser::m_QualityVec
private

Definition at line 62 of file RPCPatternsParser.h.

Referenced by getQualityVec().