CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

SummaryPlotXmlParser Class Reference

Parses the "summary plot" xml configuration file. More...

#include <SummaryPlotXmlParser.h>

Inheritance diagram for SummaryPlotXmlParser:
DQMParserBase

List of all members.

Public Member Functions

void parseXML (const std::string &xml_file)
void print (std::stringstream &) const
std::vector< SummaryPlotsummaryPlots (const sistrip::RunType &)
 SummaryPlotXmlParser ()
virtual ~SummaryPlotXmlParser ()

Private Attributes

std::map< sistrip::RunType,
std::vector< SummaryPlot > > 
plots_

Static Private Attributes

static const std::string granularityAttr_ = "granularity"
static const std::string levelAttr_ = "level"
static const std::string monitorableAttr_ = "monitorable"
static const std::string presentationAttr_ = "presentation"
static const std::string rootTag_ = "root"
static const std::string runTypeAttr_ = "name"
static const std::string runTypeTag_ = "RunType"
static const std::string summaryPlotTag_ = "SummaryPlot"
static const std::string viewAttr_ = "view"

Detailed Description

Parses the "summary plot" xml configuration file.

Author:
P.Kalavase, R.Bainbridge

Definition at line 25 of file SummaryPlotXmlParser.h.


Constructor & Destructor Documentation

SummaryPlotXmlParser::SummaryPlotXmlParser ( )

Default constructor.

Definition at line 23 of file SummaryPlotXmlParser.cc.

References f.

                                           {
  plots_.clear();
  try { XMLPlatformUtils::Initialize(); }
  catch ( const XMLException &f ) {
    throw( std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog") );
  }
}
virtual SummaryPlotXmlParser::~SummaryPlotXmlParser ( ) [inline, virtual]

Default destructor.

Definition at line 35 of file SummaryPlotXmlParser.h.

{;}

Member Function Documentation

void SummaryPlotXmlParser::parseXML ( const std::string &  xml_file)

Fill the map with the required tag/names and values

Definition at line 48 of file SummaryPlotXmlParser.cc.

References asciidump::attr, asciidump::doc, ExpressReco_HICollisions_FallBack::e, testEve_cfg::level, argparse::message, sistrip::mlDqmClient_, LaserDQM_cfi::mon, python::Node::node, EcalCondTools::plot(), cmsPerfSuiteHarvest::release, dbtoconf::root, and ExpressReco_HICollisions_FallBack::runType.

Referenced by SiStripCommissioningOfflineClient::beginRun().

                                                        {
  
  plots_.clear();
  
  try {

    // Create parser and open XML document
    getDocument(f);
    
    // Retrieve root element
    DOMElement* root = this->doc->getDocumentElement();
    if( !root ) { 
      std::stringstream ss;
      ss << "[SummaryPlotXmlParser::" << __func__ << "]"
         << " Unable to find any elements!"
         << " Empty xml document?...";
      throw( std::runtime_error( ss.str() ) ); 
    }

    // Check on "root" tag
    if( !XMLString::equals( root->getTagName(), XMLString::transcode(rootTag_.c_str()) ) ) {
      std::stringstream ss;
      ss << "[SummaryPlotXmlParser::" << __func__ << "]"
         << " Did not find \"" << rootTag_ << "\" tag! " 
         << " Tag name is "
         << XMLString::transcode(root->getNodeName());
      edm::LogWarning(mlDqmClient_) << ss.str();
      return;
    }
        
    // Retrieve nodes in xml document
    DOMNodeList* nodes = root->getChildNodes();
    if ( nodes->getLength() == 0 ) { 
      std::stringstream ss;
      ss << "[SummaryPlotXmlParser::" << __func__ << "]"
         << " Unable to find any children nodes!"
         << " Empty xml document?...";
      throw( std::runtime_error( ss.str() ) ); 
      return;
    }

//     LogTrace(mlDqmClient_) 
//       << "[SummaryPlotXmlParser::" << __func__ << "]"
//       << " Found \"" << rootTag_ << "\" tag!";
    
//     LogTrace(mlDqmClient_) 
//       << "[SummaryPlotXmlParser::" << __func__ << "]"
//       << " Found " << nodes->getLength()
//       << " children nodes!";
    
    // Iterate through nodes
    for( XMLSize_t inode = 0; inode < nodes->getLength(); ++inode ) {

      // Check on whether node is element
      DOMNode* node = nodes->item(inode);
      if( node->getNodeType() &&
          node->getNodeType() == DOMNode::ELEMENT_NODE ) {
        
        DOMElement* element = dynamic_cast<DOMElement*>( node );
        if ( !element ) { continue; }

        if( XMLString::equals( element->getTagName(), 
                               XMLString::transcode(runTypeTag_.c_str()) ) ) {
          
          const XMLCh* attr = element->getAttribute( XMLString::transcode(runTypeAttr_.c_str()) );
          sistrip::RunType run_type = SiStripEnumsAndStrings::runType( XMLString::transcode(attr) );
          
//        std::stringstream ss;
//        ss << "[SummaryPlotXmlParser::" << __func__ << "]"
//           << " Found \"" << runTypeTag_ << "\" tag!" << std::endl
//           << "  with tag name \"" << XMLString::transcode(element->getNodeName()) << "\"" << std::endl
//           << "  and attr \"" << runTypeAttr_ << "\" with value \"" << XMLString::transcode(attr) << "\"";
//        LogTrace(mlDqmClient_) << ss.str();
          
          // Retrieve nodes in xml document
          DOMNodeList* children = node->getChildNodes();
          if ( nodes->getLength() == 0 ) { 
            std::stringstream ss;
            ss << "[SummaryPlotXmlParser::" << __func__ << "]"
               << " Unable to find any children nodes!"
               << " Empty xml document?...";
            throw( std::runtime_error( ss.str() ) ); 
            return;
          }

          // Iterate through nodes
          for( XMLSize_t jnode = 0; jnode < children->getLength(); ++jnode ) {

            // Check on whether node is element
            DOMNode* child = children->item(jnode);
            if( child->getNodeType() &&
                child->getNodeType() == DOMNode::ELEMENT_NODE ) {
        
              DOMElement* elem = dynamic_cast<DOMElement*>( child );
              if ( !elem ) { continue; }

              if( XMLString::equals( elem->getTagName(), 
                                     XMLString::transcode(summaryPlotTag_.c_str()) ) ) {
                
                const XMLCh* mon = elem->getAttribute( XMLString::transcode(monitorableAttr_.c_str()) );
                const XMLCh* pres = elem->getAttribute( XMLString::transcode(presentationAttr_.c_str()) );
                const XMLCh* level = elem->getAttribute( XMLString::transcode(levelAttr_.c_str()) );
                const XMLCh* gran = elem->getAttribute( XMLString::transcode(granularityAttr_.c_str()) );
  
                SummaryPlot plot( XMLString::transcode(mon),
                                  XMLString::transcode(pres),
                                  XMLString::transcode(gran),
                                  XMLString::transcode(level) );
                plots_[run_type].push_back( plot );

//              std::stringstream ss;
//              ss << "[SummaryPlotXmlParser::" << __func__ << "]"
//                 << " Found \"" << summaryPlotTag_ << "\" tag!" << std::endl
//                 << "  with tag name \"" << XMLString::transcode(elem->getNodeName()) << "\"" << std::endl
//                 << "  and attr \"" << monitorableAttr_ << "\" with value \"" << XMLString::transcode(mon) << "\"" << std::endl
//                 << "  and attr \"" << presentationAttr_ << "\" with value \"" << XMLString::transcode(pres) << "\"" << std::endl
//                //<< "  and attr \"" << viewAttr_ << "\" with value \"" << XMLString::transcode(view) << "\"" << std::endl
//                 << "  and attr \"" << levelAttr_ << "\" with value \"" << XMLString::transcode(level) << "\"" << std::endl
//                 << "  and attr \"" << granularityAttr_ << "\" with value \"" << XMLString::transcode(gran) << "\"";
//              LogTrace(mlDqmClient_) << ss.str();

                // Update SummaryPlot object and push back into map
                
              }
            }
          }
          
        }
      }
    }

  }
  catch( XMLException& e ) {
    char* message = XMLString::transcode(e.getMessage());
    std::ostringstream ss;
    ss << "[SummaryPlotXmlParser::" << __func__ << "]"
       << " Error parsing file: " << message << std::flush;
    XMLString::release( &message );
  }

}
void SummaryPlotXmlParser::print ( std::stringstream &  ss) const

Debug print method.

Definition at line 201 of file SummaryPlotXmlParser.cc.

References ExpressReco_HICollisions_FallBack::runType.

Referenced by operator<<().

                                                            {
  ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]" 
     << " Dumping contents of parsed XML file: " << std::endl;
  using namespace sistrip;
  typedef std::vector<SummaryPlot> Plots;
  std::map<RunType,Plots>::const_iterator irun = plots_.begin();
  for ( ; irun != plots_.end(); irun++ ) {
    ss << " RunType=\"" 
       << SiStripEnumsAndStrings::runType( irun->first )
       << "\"" << std::endl;
    if ( irun->second.empty() ) {
      ss << " No summary plots for this RunType!";
    } else {
      Plots::const_iterator iplot = irun->second.begin();
      for ( ; iplot != irun->second.end(); iplot++ ) {
        ss << *iplot << std::endl;
      }
    }
  }
}
std::vector< SummaryPlot > SummaryPlotXmlParser::summaryPlots ( const sistrip::RunType run_type)

Returns SummaryPlot objects for given commissioning task.

Definition at line 33 of file SummaryPlotXmlParser.cc.

References sistrip::mlDqmClient_.

Referenced by SiStripCommissioningOfflineClient::beginRun().

                                                                                          {
  if( plots_.empty() ) {
    edm::LogWarning(mlDqmClient_)
      << "[SummaryPlotXmlParser" << __func__ << "]"
      << " You have not called the parseXML function,"
      << " or your XML file is erronious" << std::endl;
  }
  if( plots_.find( run_type ) != plots_.end() ) {
    return plots_[run_type];
  } else { return std::vector<SummaryPlot>(); }
  
}

Member Data Documentation

const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity" [static, private]

Definition at line 66 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::levelAttr_ = "level" [static, private]

Definition at line 65 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable" [static, private]

Definition at line 62 of file SummaryPlotXmlParser.h.

std::map< sistrip::RunType, std::vector<SummaryPlot> > SummaryPlotXmlParser::plots_ [private]

Container holding the SummaryPlot objects.

Definition at line 53 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::presentationAttr_ = "presentation" [static, private]

Definition at line 63 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::rootTag_ = "root" [static, private]

Definition at line 56 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeAttr_ = "name" [static, private]

Definition at line 58 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType" [static, private]

Definition at line 57 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot" [static, private]

Definition at line 61 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::viewAttr_ = "view" [static, private]

Definition at line 64 of file SummaryPlotXmlParser.h.