CMS 3D CMS Logo

SummaryPlotXmlParser Class Reference

Author:
P.Kalavase, R.Bainbridge
More...

#include <DQM/SiStripCommissioningClients/interface/SummaryPlotXmlParser.h>

Inheritance diagram for SummaryPlotXmlParser:

DQMParserBase

List of all members.

Public Member Functions

void parseXML (const std::string &xml_file)
 Fill the map with the required tag/names and values.
void print (std::stringstream &) const
 Debug print method.
std::vector< SummaryPlotsummaryPlots (const sistrip::RunType &)
 Returns SummaryPlot objects for given commissioning task.
 SummaryPlotXmlParser ()
 Default constructor.
virtual ~SummaryPlotXmlParser ()
 Default destructor.

Private Attributes

std::map< sistrip::RunType,
std::vector< SummaryPlot > > 
plots_
 Container holding the SummaryPlot objects.

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

Author:
P.Kalavase, R.Bainbridge

Parses the "summary plot" xml configuration file

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, and plots_.

00023                                            {
00024   plots_.clear();
00025   try { XMLPlatformUtils::Initialize(); }
00026   catch ( const XMLException &f ) {
00027     throw( std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog") );
00028   }
00029 }

virtual SummaryPlotXmlParser::~SummaryPlotXmlParser (  )  [inline, virtual]

Default destructor.

Definition at line 35 of file SummaryPlotXmlParser.h.

00035 {;}


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 attr, DQMParserBase::doc, e, element(), flush(), DQMParserBase::getDocument(), granularityAttr_, level, levelAttr_, sistrip::mlDqmClient_, LaserDQM_cfi::mon, monitorableAttr_, prof2calltree::node, root::plot(), plots_, presentationAttr_, release(), pydbsAccessor::root, rootTag_, run_type, SiStripEnumsAndStrings::runType(), runTypeAttr_, runTypeTag_, ss, summaryPlotTag_, and transcode().

Referenced by SiStripCommissioningOfflineClient::beginJob().

00048                                                         {
00049   
00050   plots_.clear();
00051   
00052   try {
00053 
00054     // Create parser and open XML document
00055     getDocument(f);
00056     
00057     // Retrieve root element
00058     DOMElement* root = this->doc->getDocumentElement();
00059     if( !root ) { 
00060       std::stringstream ss;
00061       ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00062          << " Unable to find any elements!"
00063          << " Empty xml document?...";
00064       throw( std::runtime_error( ss.str() ) ); 
00065     }
00066 
00067     // Check on "root" tag
00068     if( !XMLString::equals( root->getTagName(), XMLString::transcode(rootTag_.c_str()) ) ) {
00069       std::stringstream ss;
00070       ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00071          << " Did not find \"" << rootTag_ << "\" tag! " 
00072          << " Tag name is "
00073          << XMLString::transcode(root->getNodeName());
00074       edm::LogWarning(mlDqmClient_) << ss.str();
00075       return;
00076     }
00077         
00078     // Retrieve nodes in xml document
00079     DOMNodeList* nodes = root->getChildNodes();
00080     if ( nodes->getLength() == 0 ) { 
00081       std::stringstream ss;
00082       ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00083          << " Unable to find any children nodes!"
00084          << " Empty xml document?...";
00085       throw( std::runtime_error( ss.str() ) ); 
00086       return;
00087     }
00088 
00089 //     LogTrace(mlDqmClient_) 
00090 //       << "[SummaryPlotXmlParser::" << __func__ << "]"
00091 //       << " Found \"" << rootTag_ << "\" tag!";
00092     
00093 //     LogTrace(mlDqmClient_) 
00094 //       << "[SummaryPlotXmlParser::" << __func__ << "]"
00095 //       << " Found " << nodes->getLength()
00096 //       << " children nodes!";
00097     
00098     // Iterate through nodes
00099     for( XMLSize_t inode = 0; inode < nodes->getLength(); ++inode ) {
00100 
00101       // Check on whether node is element
00102       DOMNode* node = nodes->item(inode);
00103       if( node->getNodeType() &&
00104           node->getNodeType() == DOMNode::ELEMENT_NODE ) {
00105         
00106         DOMElement* element = dynamic_cast<DOMElement*>( node );
00107         if ( !element ) { continue; }
00108 
00109         if( XMLString::equals( element->getTagName(), 
00110                                XMLString::transcode(runTypeTag_.c_str()) ) ) {
00111           
00112           const XMLCh* attr = element->getAttribute( XMLString::transcode(runTypeAttr_.c_str()) );
00113           sistrip::RunType run_type = SiStripEnumsAndStrings::runType( XMLString::transcode(attr) );
00114           
00115 //        std::stringstream ss;
00116 //        ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00117 //           << " Found \"" << runTypeTag_ << "\" tag!" << std::endl
00118 //           << "  with tag name \"" << XMLString::transcode(element->getNodeName()) << "\"" << std::endl
00119 //           << "  and attr \"" << runTypeAttr_ << "\" with value \"" << XMLString::transcode(attr) << "\"";
00120 //        LogTrace(mlDqmClient_) << ss.str();
00121           
00122           // Retrieve nodes in xml document
00123           DOMNodeList* children = node->getChildNodes();
00124           if ( nodes->getLength() == 0 ) { 
00125             std::stringstream ss;
00126             ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00127                << " Unable to find any children nodes!"
00128                << " Empty xml document?...";
00129             throw( std::runtime_error( ss.str() ) ); 
00130             return;
00131           }
00132 
00133           // Iterate through nodes
00134           for( XMLSize_t jnode = 0; jnode < children->getLength(); ++jnode ) {
00135 
00136             // Check on whether node is element
00137             DOMNode* child = children->item(jnode);
00138             if( child->getNodeType() &&
00139                 child->getNodeType() == DOMNode::ELEMENT_NODE ) {
00140         
00141               DOMElement* elem = dynamic_cast<DOMElement*>( child );
00142               if ( !elem ) { continue; }
00143 
00144               if( XMLString::equals( elem->getTagName(), 
00145                                      XMLString::transcode(summaryPlotTag_.c_str()) ) ) {
00146                 
00147                 const XMLCh* mon = elem->getAttribute( XMLString::transcode(monitorableAttr_.c_str()) );
00148                 const XMLCh* pres = elem->getAttribute( XMLString::transcode(presentationAttr_.c_str()) );
00149                 const XMLCh* level = elem->getAttribute( XMLString::transcode(levelAttr_.c_str()) );
00150                 const XMLCh* gran = elem->getAttribute( XMLString::transcode(granularityAttr_.c_str()) );
00151   
00152                 SummaryPlot plot( XMLString::transcode(mon),
00153                                   XMLString::transcode(pres),
00154                                   XMLString::transcode(gran),
00155                                   XMLString::transcode(level) );
00156                 plots_[run_type].push_back( plot );
00157 
00158 //              std::stringstream ss;
00159 //              ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00160 //                 << " Found \"" << summaryPlotTag_ << "\" tag!" << std::endl
00161 //                 << "  with tag name \"" << XMLString::transcode(elem->getNodeName()) << "\"" << std::endl
00162 //                 << "  and attr \"" << monitorableAttr_ << "\" with value \"" << XMLString::transcode(mon) << "\"" << std::endl
00163 //                 << "  and attr \"" << presentationAttr_ << "\" with value \"" << XMLString::transcode(pres) << "\"" << std::endl
00164 //                //<< "  and attr \"" << viewAttr_ << "\" with value \"" << XMLString::transcode(view) << "\"" << std::endl
00165 //                 << "  and attr \"" << levelAttr_ << "\" with value \"" << XMLString::transcode(level) << "\"" << std::endl
00166 //                 << "  and attr \"" << granularityAttr_ << "\" with value \"" << XMLString::transcode(gran) << "\"";
00167 //              LogTrace(mlDqmClient_) << ss.str();
00168 
00169                 // Update SummaryPlot object and push back into map
00170                 
00171               }
00172             }
00173           }
00174           
00175         }
00176       }
00177     }
00178 
00179   }
00180   catch( XMLException& e ) {
00181     char* message = XMLString::transcode(e.getMessage());
00182     std::ostringstream ss;
00183     ss << "[SummaryPlotXmlParser::" << __func__ << "]"
00184        << " Error parsing file: " << message << std::flush;
00185     XMLString::release( &message );
00186   }
00187 
00188 }

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

Debug print method.

Definition at line 201 of file SummaryPlotXmlParser.cc.

References lat::endl(), plots_, and SiStripEnumsAndStrings::runType().

Referenced by operator<<().

00201                                                             {
00202   ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]" 
00203      << " Dumping contents of parsed XML file: " << std::endl;
00204   using namespace sistrip;
00205   typedef std::vector<SummaryPlot> Plots;
00206   std::map<RunType,Plots>::const_iterator irun = plots_.begin();
00207   for ( ; irun != plots_.end(); irun++ ) {
00208     ss << " RunType=\"" 
00209        << SiStripEnumsAndStrings::runType( irun->first )
00210        << "\"" << std::endl;
00211     if ( irun->second.empty() ) {
00212       ss << " No summary plots for this RunType!";
00213     } else {
00214       Plots::const_iterator iplot = irun->second.begin();
00215       for ( ; iplot != irun->second.end(); iplot++ ) {
00216         ss << *iplot << std::endl;
00217       }
00218     }
00219   }
00220 }

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 lat::endl(), sistrip::mlDqmClient_, and plots_.

Referenced by SiStripCommissioningOfflineClient::beginJob().

00033                                                                                           {
00034   if( plots_.empty() ) {
00035     edm::LogWarning(mlDqmClient_)
00036       << "[SummaryPlotXmlParser" << __func__ << "]"
00037       << " You have not called the parseXML function,"
00038       << " or your XML file is erronious" << std::endl;
00039   }
00040   if( plots_.find( run_type ) != plots_.end() ) {
00041     return plots_[run_type];
00042   } else { return std::vector<SummaryPlot>(); }
00043   
00044 }


Member Data Documentation

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

Definition at line 66 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 65 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 62 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Container holding the SummaryPlot objects.

Definition at line 53 of file SummaryPlotXmlParser.h.

Referenced by parseXML(), print(), summaryPlots(), and SummaryPlotXmlParser().

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

Definition at line 63 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 56 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 58 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 57 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 61 of file SummaryPlotXmlParser.h.

Referenced by parseXML().

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

Definition at line 64 of file SummaryPlotXmlParser.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:00 2009 for CMSSW by  doxygen 1.5.4