CMS 3D CMS Logo

List of all members | 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

Public Member Functions

void parseXML (const std::string &xml_file)
 
void print (std::stringstream &) const
 
std::vector< SummaryPlotsummaryPlots (const sistrip::RunType &)
 
 SummaryPlotXmlParser ()
 
virtual ~SummaryPlotXmlParser ()
 
- Public Member Functions inherited from DQMParserBase
int countNodes (std::string tagName)
 Returns the number of nodes with given name. More...
 
xercesc::DOMDocument * doc ()
 DOM Document. More...
 
 DQMParserBase ()
 Creator. More...
 
void getDocument (std::string configFile, bool UseDB=false)
 Methor that parses the xml file configFile. More...
 
void getNewDocument (std::string configFile, bool UseDB=false)
 Parses a new Document. More...
 
virtual ~DQMParserBase ()
 Destructor. More...
 

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"
 

Additional Inherited Members

- Protected Attributes inherited from DQMParserBase
xercesc::XercesDOMParser * parser
 

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, and cms::concurrency::xercesInitialize().

23  {
24  plots_.clear();
26  catch ( const XMLException &f ) {
27  throw( std::runtime_error("Standard pool exception : Fatal Error on pool::TrivialFileCatalog") );
28  }
29 }
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
void xercesInitialize()
Definition: Xerces.cc:18
double f[11][100]
virtual SummaryPlotXmlParser::~SummaryPlotXmlParser ( )
inlinevirtual

Default destructor.

Definition at line 35 of file SummaryPlotXmlParser.h.

References parseXML(), print(), AlCaHLTBitMon_QueryRunRegistry::string, and summaryPlots().

35 {;}

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 class-composition::child, class-composition::children, MillePedeFileConverter_cfg::e, HTMLExport::elem(), equals(), hcalDigis_cfi::level, python.rootplot.argparse::message, sistrip::mlDqmClient_, LaserDQM_cfi::mon, class-composition::nodes, plotFactory::plot, fetchall_from_DQM_v2::release, and SiStripEnumsAndStrings::runType().

Referenced by SiStripCommissioningOfflineClient::beginRun(), and ~SummaryPlotXmlParser().

48  {
49 
50  plots_.clear();
51 
52  try {
53 
54  // Create parser and open XML document
55  getDocument(f);
56 
57  // Retrieve root element
58  DOMElement* root = this->doc()->getDocumentElement();
59  if( !root ) {
60  std::stringstream ss;
61  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
62  << " Unable to find any elements!"
63  << " Empty xml document?...";
64  throw( std::runtime_error( ss.str() ) );
65  }
66 
67  // Check on "root" tag
68  if( !XMLString::equals( root->getTagName(), XMLString::transcode(rootTag_.c_str()) ) ) {
69  std::stringstream ss;
70  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
71  << " Did not find \"" << rootTag_ << "\" tag! "
72  << " Tag name is "
73  << XMLString::transcode(root->getNodeName());
74  edm::LogWarning(mlDqmClient_) << ss.str();
75  return;
76  }
77 
78  // Retrieve nodes in xml document
79  DOMNodeList* nodes = root->getChildNodes();
80  if ( nodes->getLength() == 0 ) {
81  std::stringstream ss;
82  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
83  << " Unable to find any children nodes!"
84  << " Empty xml document?...";
85  throw( std::runtime_error( ss.str() ) );
86  return;
87  }
88 
89 // LogTrace(mlDqmClient_)
90 // << "[SummaryPlotXmlParser::" << __func__ << "]"
91 // << " Found \"" << rootTag_ << "\" tag!";
92 
93 // LogTrace(mlDqmClient_)
94 // << "[SummaryPlotXmlParser::" << __func__ << "]"
95 // << " Found " << nodes->getLength()
96 // << " children nodes!";
97 
98  // Iterate through nodes
99  for( XMLSize_t inode = 0; inode < nodes->getLength(); ++inode ) {
100 
101  // Check on whether node is element
102  DOMNode* node = nodes->item(inode);
103  if( node->getNodeType() &&
104  node->getNodeType() == DOMNode::ELEMENT_NODE ) {
105 
106  DOMElement* element = dynamic_cast<DOMElement*>( node );
107  if ( !element ) { continue; }
108 
109  if( XMLString::equals( element->getTagName(),
110  XMLString::transcode(runTypeTag_.c_str()) ) ) {
111 
112  const XMLCh* attr = element->getAttribute( XMLString::transcode(runTypeAttr_.c_str()) );
113  sistrip::RunType run_type = SiStripEnumsAndStrings::runType( XMLString::transcode(attr) );
114 
115 // std::stringstream ss;
116 // ss << "[SummaryPlotXmlParser::" << __func__ << "]"
117 // << " Found \"" << runTypeTag_ << "\" tag!" << std::endl
118 // << " with tag name \"" << XMLString::transcode(element->getNodeName()) << "\"" << std::endl
119 // << " and attr \"" << runTypeAttr_ << "\" with value \"" << XMLString::transcode(attr) << "\"";
120 // LogTrace(mlDqmClient_) << ss.str();
121 
122  // Retrieve nodes in xml document
123  DOMNodeList* children = node->getChildNodes();
124  if ( nodes->getLength() == 0 ) {
125  std::stringstream ss;
126  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
127  << " Unable to find any children nodes!"
128  << " Empty xml document?...";
129  throw( std::runtime_error( ss.str() ) );
130  return;
131  }
132 
133  // Iterate through nodes
134  for( XMLSize_t jnode = 0; jnode < children->getLength(); ++jnode ) {
135 
136  // Check on whether node is element
137  DOMNode* child = children->item(jnode);
138  if( child->getNodeType() &&
139  child->getNodeType() == DOMNode::ELEMENT_NODE ) {
140 
141  DOMElement* elem = dynamic_cast<DOMElement*>( child );
142  if ( !elem ) { continue; }
143 
144  if( XMLString::equals( elem->getTagName(),
145  XMLString::transcode(summaryPlotTag_.c_str()) ) ) {
146 
147  const XMLCh* mon = elem->getAttribute( XMLString::transcode(monitorableAttr_.c_str()) );
148  const XMLCh* pres = elem->getAttribute( XMLString::transcode(presentationAttr_.c_str()) );
149  const XMLCh* level = elem->getAttribute( XMLString::transcode(levelAttr_.c_str()) );
150  const XMLCh* gran = elem->getAttribute( XMLString::transcode(granularityAttr_.c_str()) );
151 
152  SummaryPlot plot( XMLString::transcode(mon),
153  XMLString::transcode(pres),
154  XMLString::transcode(gran),
155  XMLString::transcode(level) );
156  plots_[run_type].push_back( plot );
157 
158 // std::stringstream ss;
159 // ss << "[SummaryPlotXmlParser::" << __func__ << "]"
160 // << " Found \"" << summaryPlotTag_ << "\" tag!" << std::endl
161 // << " with tag name \"" << XMLString::transcode(elem->getNodeName()) << "\"" << std::endl
162 // << " and attr \"" << monitorableAttr_ << "\" with value \"" << XMLString::transcode(mon) << "\"" << std::endl
163 // << " and attr \"" << presentationAttr_ << "\" with value \"" << XMLString::transcode(pres) << "\"" << std::endl
164 // //<< " and attr \"" << viewAttr_ << "\" with value \"" << XMLString::transcode(view) << "\"" << std::endl
165 // << " and attr \"" << levelAttr_ << "\" with value \"" << XMLString::transcode(level) << "\"" << std::endl
166 // << " and attr \"" << granularityAttr_ << "\" with value \"" << XMLString::transcode(gran) << "\"";
167 // LogTrace(mlDqmClient_) << ss.str();
168 
169  // Update SummaryPlot object and push back into map
170 
171  }
172  }
173  }
174 
175  }
176  }
177  }
178 
179  }
180  catch( XMLException& e ) {
181  char* message = XMLString::transcode(e.getMessage());
182  std::ostringstream ss;
183  ss << "[SummaryPlotXmlParser::" << __func__ << "]"
184  << " Error parsing file: " << message << std::flush;
185  XMLString::release( &message );
186  }
187 
188 }
static const std::string monitorableAttr_
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
void getDocument(std::string configFile, bool UseDB=false)
Methor that parses the xml file configFile.
static const std::string rootTag_
static const std::string runTypeTag_
static const std::string presentationAttr_
static const std::string runTypeAttr_
static const std::string granularityAttr_
static const char mlDqmClient_[]
static std::string runType(const sistrip::RunType &)
Class holding info that defines a summary plot.
Definition: SummaryPlot.h:19
double f[11][100]
static const std::string summaryPlotTag_
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:18
bool equals(const edm::RefToBase< Jet > &j1, const edm::RefToBase< Jet > &j2)
static const std::string levelAttr_
xercesc::DOMDocument * doc()
DOM Document.
Definition: DQMParserBase.h:45
void SummaryPlotXmlParser::print ( std::stringstream &  ss) const

Debug print method.

Definition at line 201 of file SummaryPlotXmlParser.cc.

References SiStripEnumsAndStrings::runType().

Referenced by operator<<(), and ~SummaryPlotXmlParser().

201  {
202  ss << "[SummaryPlotXmlParser::SummaryPlot::" << __func__ << "]"
203  << " Dumping contents of parsed XML file: " << std::endl;
204  using namespace sistrip;
205  typedef std::vector<SummaryPlot> Plots;
206  std::map<RunType,Plots>::const_iterator irun = plots_.begin();
207  for ( ; irun != plots_.end(); irun++ ) {
208  ss << " RunType=\""
209  << SiStripEnumsAndStrings::runType( irun->first )
210  << "\"" << std::endl;
211  if ( irun->second.empty() ) {
212  ss << " No summary plots for this RunType!";
213  } else {
214  Plots::const_iterator iplot = irun->second.begin();
215  for ( ; iplot != irun->second.end(); iplot++ ) {
216  ss << *iplot << std::endl;
217  }
218  }
219  }
220 }
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
sistrip classes
static std::string runType(const sistrip::RunType &)
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(), and ~SummaryPlotXmlParser().

33  {
34  if( plots_.empty() ) {
36  << "[SummaryPlotXmlParser" << __func__ << "]"
37  << " You have not called the parseXML function,"
38  << " or your XML file is erronious" << std::endl;
39  }
40  if( plots_.find( run_type ) != plots_.end() ) {
41  return plots_[run_type];
42  } else { return std::vector<SummaryPlot>(); }
43 
44 }
std::map< sistrip::RunType, std::vector< SummaryPlot > > plots_
static const char mlDqmClient_[]

Member Data Documentation

const std::string SummaryPlotXmlParser::granularityAttr_ = "granularity"
staticprivate

Definition at line 66 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::levelAttr_ = "level"
staticprivate

Definition at line 65 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::monitorableAttr_ = "monitorable"
staticprivate

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"
staticprivate

Definition at line 63 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::rootTag_ = "root"
staticprivate

Definition at line 56 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeAttr_ = "name"
staticprivate

Definition at line 58 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::runTypeTag_ = "RunType"
staticprivate

Definition at line 57 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::summaryPlotTag_ = "SummaryPlot"
staticprivate

Definition at line 61 of file SummaryPlotXmlParser.h.

const std::string SummaryPlotXmlParser::viewAttr_ = "view"
staticprivate

Definition at line 64 of file SummaryPlotXmlParser.h.