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 22 of file RPCPatternsParser.h.

Member Typedef Documentation

Definition at line 66 of file RPCPatternsParser.h.

Constructor & Destructor Documentation

RPCPatternsParser::RPCPatternsParser ( )

Definition at line 108 of file RPCPatternsParser.cc.

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

109 {
110  if(m_InstanceCount == 0) {
111  try {
113  //XPathEvaluator::initialize();
114  m_InstanceCount++;
115  }
116  catch(const XMLException &toCatch) {
117  throw RPCException("Error during Xerces-c Initialization: "
118  + xMLCh2String(toCatch.getMessage()));
119  //edm::LogError("RPCTrigger")<< "Error during Xerces-c Initialization: "
120  // + xMLCh2String(toCatch.getMessage());
121  }
122  }
123 }
string xMLCh2String(const XMLCh *ch)
void xercesInitialize()
Definition: Xerces.cc:18
static int m_InstanceCount
RPCPatternsParser::~RPCPatternsParser ( )
override

Definition at line 127 of file RPCPatternsParser.cc.

References cms::concurrency::xercesTerminate().

127  {
129 }
void xercesTerminate()
Definition: Xerces.cc:23

Member Function Documentation

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

Definition at line 210 of file RPCPatternsParser.cc.

References xMLCh2String().

210  {
211  string element = xMLCh2String(localname);
212  if(element == "pat") {
213  m_CurPacIt->second.push_back(m_CurPattern);
214  }
215 }
string xMLCh2String(const XMLCh *ch)
TPatternsVecsMap::iterator m_CurPacIt
const RPCPattern::RPCPatVec & RPCPatternsParser::getPatternsVec ( const RPCConst::l1RpcConeCrdnts coneCrds) const

Definition at line 43 of file RPCPatternsParser.cc.

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

Referenced by RPCPacData::init(), and RPCTriggerConfig::produce().

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

Definition at line 55 of file RPCPatternsParser.cc.

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

Definition at line 50 of file RPCPatternsParser.h.

References m_QualityVec.

Referenced by RPCPacData::init(), and RPCTriggerConfig::produce().

50  { //XXX - clean me!
51  return m_QualityVec;
52  };
RPCPattern::TQualityVec m_QualityVec
void RPCPatternsParser::parse ( std::string  fileName)

Definition at line 131 of file RPCPatternsParser.cc.

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

Referenced by RPCTriggerConfig::produce(), and RPCPacData::RPCPacData().

132 {
133  ifstream fin;
134  fin.open(fileName.c_str());
135  if(fin.fail()) {
136  throw RPCException("Cannot open the file" + fileName);
137  //edm::LogError("RPCTrigger") << "Cannot open the file" + fileName;
138  }
139  fin.close();
140 
141  SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
142  parser->setContentHandler(this);
143 
144  m_QualityVec.clear();
145  parser->parse(fileName.c_str());
146  delete parser;
147 }
RPCPattern::TQualityVec m_QualityVec
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 149 of file RPCPatternsParser.cc.

References Char2XMLCh, RPCPattern::TQuality::m_FiredPlanes, RPCConst::l1RpcConeCrdnts::m_LogSector, RPCConst::l1RpcConeCrdnts::m_LogSegment, RPCPattern::TQuality::m_QualityTabNumber, RPCPattern::TQuality::m_QualityValue, RPCConst::l1RpcConeCrdnts::m_Tower, RPCPattern::PAT_TYPE_E, RPCPattern::PAT_TYPE_T, EnergyCorrector::pt, jets_cff::quality, AlCaHLTBitMon_QueryRunRegistry::string, RPCConst::stringToInt(), and xMLCh2String().

152  {
153  RPCConst rpcconst;
154 
155  m_CurrElement = xMLCh2String(localname);
156  if(m_CurrElement == "quality") {
157  //<quality id = "0" planes = "011110" val = 1/>
159 
160 
161  quality.m_QualityTabNumber = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("id"))));
162  std::bitset<8> firedPl( xMLCh2String(attrs.getValue(Char2XMLCh("planes")) )) ;
163  unsigned long fpUL = firedPl.to_ulong();
164  quality.m_FiredPlanes = (unsigned char) (fpUL & 0xFF );
165  //quality.m_FiredPlanes = xMLCh2String(attrs.getValue(Char2XMLCh("planes")));
166  quality.m_QualityValue = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("val"))));
167 
168  m_QualityVec.push_back(quality);
169  }
170  else if(m_CurrElement == "pac") {
171  //<pac id ="0" m_tower = "0" logSector = "0" logSegment = "0" descr = "">
173  cone.m_Tower = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("tower"))));
174  cone.m_LogSector = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSector"))));
175  cone.m_LogSegment = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSegment"))));
176  pair <TPatternsVecsMap::iterator, bool> res = m_PatternsVecsMap.insert(TPatternsVecsMap::value_type(cone,
178  if(res.second == true)
179  m_CurPacIt = res.first;
180  else
181  throw RPCException( std::string("m_PatternsVecsMap insertion failed - cone already exixsts?"));
182  //edm::LogError("RPCTrigger") << "m_PatternsVecsMap insertion failed - cone already exixsts?";
183  }
184  else if(m_CurrElement == "pat") {
185  //<pat type="E" grp="0" qual="0" sign="0" code="31" num="0">
186  string pt = xMLCh2String(attrs.getValue(Char2XMLCh("type")));
187  if(pt == "E")
189  else if(pt == "T")
191  else
192  throw RPCException("unknown pattern type: " + pt);
193  //edm::LogError("RPCTrigger") << "unknown pattern type: " + pt;
194 
195  m_CurPattern.setRefGroup(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("grp")))));
196  m_CurPattern.setQualityTabNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("qual")))));
197 
198  m_CurPattern.setSign(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("sign")))));
199  m_CurPattern.setCode(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("code")))));
200  m_CurPattern.setNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("num")))));
201  }
202  else if(m_CurrElement == "str") {
203  //<logstrip plane="m_LOGPLANE1" from="32" to="32"/>
204  int logPlane = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("Pl"))));
205  m_CurPattern.setStripFrom(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("f")))));
206  m_CurPattern.setStripTo(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("t")))) + 1);
207  }
208 }
void setRefGroup(int refGroup)
Definition: RPCPattern.cc:91
string xMLCh2String(const XMLCh *ch)
void setStripTo(int logPlane, int stripTo)
Definition: RPCPattern.cc:49
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:119
void setPatternType(TPatternType patternType)
Definition: RPCPattern.cc:89
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:57
unsigned char m_FiredPlanes
Definition: RPCPattern.h:39
std::vector< RPCPattern > RPCPatVec
Definition: RPCPattern.h:36
TPatternsVecsMap m_PatternsVecsMap
void setNumber(int a)
Definition: RPCPattern.cc:87
void setQualityTabNumber(int qualityTabNumber)
Definition: RPCPattern.cc:93
std::string m_CurrElement
static const TPatternType PAT_TYPE_E
Definition: RPCPattern.h:58
void setSign(int a)
Definition: RPCPattern.cc:85
void setCode(int a)
Definition: RPCPattern.cc:83
int stringToInt(std::string str)
Converts string to inteager number. If string contains chars, that are not digits, throws RPCException.
Definition: RPCConst.cc:243

Member Data Documentation

TPatternsVecsMap::iterator RPCPatternsParser::m_CurPacIt
private

Definition at line 70 of file RPCPatternsParser.h.

RPCPattern RPCPatternsParser::m_CurPattern
private

Definition at line 72 of file RPCPatternsParser.h.

std::string RPCPatternsParser::m_CurrElement
private

Definition at line 62 of file RPCPatternsParser.h.

int RPCPatternsParser::m_InstanceCount = 0
staticprivate

Definition at line 52 of file RPCPatternsParser.h.

TPatternsVecsMap RPCPatternsParser::m_PatternsVecsMap
private

Definition at line 68 of file RPCPatternsParser.h.

RPCPattern::TQualityVec RPCPatternsParser::m_QualityVec
private

Definition at line 64 of file RPCPatternsParser.h.

Referenced by getQualityVec().