CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes | Static Private Attributes

RPCPatternsParser Class Reference

#include <RPCPatternsParser.h>

List of all members.

Public Member Functions

void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
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 Attributes &attrs)
 ~RPCPatternsParser ()

Private Types

typedef std::map
< RPCConst::l1RpcConeCrdnts,
RPCPattern::RPCPatVec
TPatternsVecsMap

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 xMLCh2String().

{
   if(m_InstanceCount == 0) { 
    try {
        XMLPlatformUtils::Initialize();
        //XPathEvaluator::initialize();
        m_InstanceCount++;
    }
    catch(const XMLException &toCatch)  {
      throw RPCException("Error during Xerces-c Initialization: "
           + xMLCh2String(toCatch.getMessage()));
      //edm::LogError("RPCTrigger")<< "Error during Xerces-c Initialization: " 
      //           + xMLCh2String(toCatch.getMessage());
    }
  }  
}
RPCPatternsParser::~RPCPatternsParser ( )

Definition at line 127 of file RPCPatternsParser.cc.

                                      {
}

Member Function Documentation

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

Definition at line 209 of file RPCPatternsParser.cc.

References xMLCh2String().

                                                                                                                 {
  string element = xMLCh2String(localname);
  if(element == "pat") {
    m_CurPacIt->second.push_back(m_CurPattern);
  }
}
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, and RPCConst::l1RpcConeCrdnts::m_Tower.

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

                                                                                                          {
  TPatternsVecsMap::const_iterator patVecIt  = m_PatternsVecsMap.find(coneCrds);
  if(patVecIt == m_PatternsVecsMap.end()){

    std::stringstream ss;
    ss << coneCrds.m_Tower << " " << coneCrds.m_LogSector << " " << coneCrds.m_LogSegment;
    throw RPCException( std::string("no such a cone in m_PatternsVecsMap: ")+ ss.str() );
    //edm::LogError("RPCTrigger")<< "no such a cone in m_PatternsVecsMap";
  }
  return patVecIt->second; // XXX - TMF - was in if{}, changed to avoid warning
}
const RPCPattern::RPCPatVec & RPCPatternsParser::getPatternsVec ( const int  tower,
const int  sc,
const int  sg 
) const

Definition at line 55 of file RPCPatternsParser.cc.

                                                                                                              {

    RPCConst::l1RpcConeCrdnts cords(tower,sc,sg);

    return getPatternsVec(cords);

}
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().

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

Definition at line 130 of file RPCPatternsParser.cc.

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

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

{
  ifstream fin;
  fin.open(fileName.c_str());
  if(fin.fail()) {
    throw RPCException("Cannot open the file" + fileName);
    //edm::LogError("RPCTrigger") << "Cannot open the file" + fileName;
  }
  fin.close();

  SAX2XMLReader* parser = XMLReaderFactory::createXMLReader();
  parser->setContentHandler(this);
  
  m_QualityVec.clear();
  parser->parse(fileName.c_str());
  delete parser;
}
void RPCPatternsParser::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const Attributes &  attrs 
)

Definition at line 148 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, RPCConst::stringToInt(), and xMLCh2String().

                                                                {
  RPCConst rpcconst;
  
  m_CurrElement = xMLCh2String(localname);
  if(m_CurrElement == "quality") {
    //<quality id = "0" planes = "011110" val = 1/>
    RPCPattern::TQuality quality;
    
    
    quality.m_QualityTabNumber = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("id"))));
    std::bitset<8> firedPl( xMLCh2String(attrs.getValue(Char2XMLCh("planes")) )) ;
    unsigned long fpUL = firedPl.to_ulong();
    quality.m_FiredPlanes = (unsigned char) (fpUL & 0xFF );
    //quality.m_FiredPlanes = xMLCh2String(attrs.getValue(Char2XMLCh("planes")));
    quality.m_QualityValue = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("val"))));

    m_QualityVec.push_back(quality);
  }
  else if(m_CurrElement == "pac") {
    //<pac id ="0" m_tower = "0" logSector = "0" logSegment = "0" descr = "">       
    RPCConst::l1RpcConeCrdnts cone;
    cone.m_Tower = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("tower"))));
    cone.m_LogSector = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSector"))));
    cone.m_LogSegment = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("logSegment"))));
    pair <TPatternsVecsMap::iterator, bool> res = m_PatternsVecsMap.insert(TPatternsVecsMap::value_type(cone,
                                                                                                RPCPattern::RPCPatVec()));
    if(res.second == true)
      m_CurPacIt = res.first;
    else
      throw RPCException( std::string("m_PatternsVecsMap insertion failed - cone already exixsts?"));
      //edm::LogError("RPCTrigger") << "m_PatternsVecsMap insertion failed - cone already exixsts?";
  }
  else if(m_CurrElement == "pat") {
    //<pat type="E" grp="0" qual="0" sign="0" code="31" num="0">
    string pt = xMLCh2String(attrs.getValue(Char2XMLCh("type")));
    if(pt == "E")
      m_CurPattern.setPatternType(RPCPattern::PAT_TYPE_E);
    else if(pt == "T")
      m_CurPattern.setPatternType(RPCPattern::PAT_TYPE_T);
    else
      throw RPCException("unknown pattern type: " + pt);
      //edm::LogError("RPCTrigger") << "unknown pattern type: " + pt;

    m_CurPattern.setRefGroup(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("grp")))));
    m_CurPattern.setQualityTabNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("qual")))));
    
    m_CurPattern.setSign(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("sign")))));
    m_CurPattern.setCode(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("code")))));
    m_CurPattern.setNumber(rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("num")))));
  }
  else if(m_CurrElement == "str") {
    //<logstrip plane="m_LOGPLANE1" from="32" to="32"/>
    int logPlane = rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("Pl"))));
    m_CurPattern.setStripFrom(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("f")))));
    m_CurPattern.setStripTo(logPlane, rpcconst.stringToInt(xMLCh2String(attrs.getValue(Char2XMLCh("t")))) + 1);
  }
}

Member Data Documentation

TPatternsVecsMap::iterator RPCPatternsParser::m_CurPacIt [private]

Definition at line 70 of file RPCPatternsParser.h.

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 [static, private]

Definition at line 52 of file RPCPatternsParser.h.

Definition at line 68 of file RPCPatternsParser.h.

Definition at line 64 of file RPCPatternsParser.h.

Referenced by getQualityVec().