test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalHardwareXml Class Reference

#include <CaloOnlineTools/HcalOnlineDb/interface/HcalHardwareXml.h>

Inheritance diagram for HcalHardwareXml:
XMLDOMBlock

Public Member Functions

int addHardware (std::map< std::string, std::map< std::string, std::map< std::string, std::map< int, std::string > > > > &hw_map)
 
 HcalHardwareXml ()
 
 HcalHardwareXml (std::string _type)
 
virtual ~HcalHardwareXml ()
 
- Public Member Functions inherited from XMLDOMBlock
XERCES_CPP_NAMESPACE::DOMElement * add_element (XERCES_CPP_NAMESPACE::DOMElement *parent, XMLCh *tagname, XMLCh *value)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocument (void)
 
XERCES_CPP_NAMESPACE::DOMDocument * getDocumentConst (void) const
 
XERCES_CPP_NAMESPACE::DOMDocument * getNewDocument (std::string xmlFileName)
 
std::string & getString (void)
 
std::string & getString (XERCES_CPP_NAMESPACE::DOMNode *_node)
 
const char * getTagAttribute (const std::string &tagName, const std::string &attrName, int _item=0)
 
const char * getTagValue (const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
const char * getTagValue (const std::string &tagName, int _item, XERCES_CPP_NAMESPACE::DOMElement *_document)
 
std::string getTimestamp (time_t _time)
 
XMLDOMBlockoperator+= (const XMLDOMBlock &other)
 
void parse (XERCES_CPP_NAMESPACE::InputSource &_source)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
 
XERCES_CPP_NAMESPACE::DOMNode * setTagValue (XERCES_CPP_NAMESPACE::DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (XERCES_CPP_NAMESPACE::InputSource &_source)
 
 XMLDOMBlock (std::string _root, int rootElementName)
 
virtual ~XMLDOMBlock ()
 

Private Member Functions

XERCES_CPP_NAMESPACE::DOMElement * addPart (XERCES_CPP_NAMESPACE::DOMElement *parent, HcalPart &part)
 
 HcalHardwareXml (const HcalHardwareXml &)
 
const HcalHardwareXmloperator= (const HcalHardwareXml &)
 

Private Attributes

XERCES_CPP_NAMESPACE::DOMElement * partsElem
 

Additional Inherited Members

- Protected Member Functions inherited from XMLDOMBlock
int init (std::string _root)
 
- Protected Attributes inherited from XMLDOMBlock
XERCES_CPP_NAMESPACE::DOMDocument * document
 
XERCES_CPP_NAMESPACE::ErrorHandler * errHandler
 
XERCES_CPP_NAMESPACE::XercesDOMParser * parser
 
std::string * the_string
 
std::string theFileName
 
XMLProcessortheProcessor
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 37 of file HcalHardwareXml.h.

Constructor & Destructor Documentation

XERCES_CPP_NAMESPACE_USE HcalHardwareXml::HcalHardwareXml ( )

Definition at line 17 of file HcalHardwareXml.cc.

References XMLDOMBlock::document, partsElem, and XERCES_CPP_NAMESPACE_USE::transcode().

17  : XMLDOMBlock()
18 {
19 
20  DOMElement* rootElem = document -> getDocumentElement();
21 
22  partsElem = document->createElement( XMLString::transcode("PARTS") );
23  rootElem->appendChild(partsElem);
24 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLCh * transcode(const T &fInput)
XERCES_CPP_NAMESPACE::DOMElement * partsElem
HcalHardwareXml::HcalHardwareXml ( std::string  _type)

Definition at line 27 of file HcalHardwareXml.cc.

References XMLDOMBlock::document, partsElem, and XERCES_CPP_NAMESPACE_USE::transcode().

27  : XMLDOMBlock()
28 {
29 
30  DOMElement* rootElem = document -> getDocumentElement();
31 
32  partsElem = document->createElement( XMLString::transcode("PARTS") );
33  rootElem->appendChild(partsElem);
34 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XMLCh * transcode(const T &fInput)
XERCES_CPP_NAMESPACE::DOMElement * partsElem
HcalHardwareXml::~HcalHardwareXml ( )
virtual

Definition at line 155 of file HcalHardwareXml.cc.

156 {
157 }
HcalHardwareXml::HcalHardwareXml ( const HcalHardwareXml )
private

Member Function Documentation

int HcalHardwareXml::addHardware ( std::map< std::string, std::map< std::string, std::map< std::string, std::map< int, std::string > > > > &  hw_map)

Definition at line 39 of file HcalHardwareXml.cc.

References addPart(), _HcalPart::barcode, begin, comment, gather_cfg::cout, end, plotBeamSpotDB::first, universalConfigTemplate::mode, partsElem, submit::rm, edm::second(), and XERCES_CPP_NAMESPACE_USE::transcode().

40 {
41  //hw_map["HO001"]["HORBX09"]["200351"][2]="101295";
42 
43  std::map<std::string,int> double_entry; // to check for double entries
44 
45  std::map<std::string,std::map<std::string,std::map<std::string,std::map<int,std::string> > > >::const_iterator rbx_slot;
46  for (rbx_slot = hw_map . begin(); rbx_slot != hw_map . end(); rbx_slot++){
47 
48  HcalPart _p;
49  _p . mode = "find";
50  _p . kind_of_part = "HCAL RBX Slot";
51  _p . name_label = rbx_slot -> first;
52  DOMElement * rbx_slot_elem = addPart( partsElem, _p );
53  DOMElement * rbx_slot_children_elem = (DOMElement *)rbx_slot_elem -> getElementsByTagName(XMLString::transcode("CHILDREN"))->item(0);
54 
55  std::map<std::string,std::map<std::string,std::map<int,std::string> > >::const_iterator rbx;
56  for (rbx = rbx_slot->second . begin(); rbx != rbx_slot->second . end(); rbx++){
57  HcalPart _p2;
58  _p2 . mode = "find";
59  _p2 . kind_of_part = "HCAL RBX";
60  _p2 . name_label = rbx -> first;
61  DOMElement * rbx_elem = addPart( rbx_slot_children_elem, _p2 );
62  DOMElement * rbx_children_elem = (DOMElement *)rbx_elem -> getElementsByTagName(XMLString::transcode("CHILDREN"))->item(0);
63 
64  std::map<std::string,std::map<int,std::string> >::const_iterator rm;
65  for (rm = rbx->second . begin(); rm != rbx->second . end(); rm++){
66  HcalPart _p3;
67  _p3 . mode = "find";
68  _p3 . kind_of_part = "HCAL Readout Module";
69  _p3 . barcode = rm -> first;
70  DOMElement * rm_elem = addPart( rbx_children_elem, _p3 );
71  DOMElement * rm_children_elem = (DOMElement *)rm_elem -> getElementsByTagName(XMLString::transcode("CHILDREN"))->item(0);
72 
73  std::map<int,std::string>::const_iterator qie;
74  for (qie = rm->second . begin(); qie != rm->second . end(); qie++){
75  HcalPart _p4;
76  _p4 . mode = "find";
77  _p4 . kind_of_part = "HCAL QIE Card";
78  _p4 . barcode = qie -> second;
79  _p4 . comment = "HCAL hardware remapping by Gena Kukartsev";
80  _p4 . attr_name = "QIE Card Position";
81  std::stringstream _buffer;
82  _buffer . str("");
83  _buffer << qie->first;
84  _p4 . attr_value = _buffer . str();
85 
86  // check for multiple QIE entries
87  unsigned int _nqie = double_entry.size();
88  double_entry[_p4 . barcode]++;
89  if (double_entry.size() == _nqie){
90  std::cout << "QIE #" << _p4.barcode << " found " << double_entry[_p4 . barcode] << "times!" << std::endl;
91  }else{
92  addPart( rm_children_elem, _p4 );
93  }
94  }
95  }
96  }
97  }
98 
99  return 0;
100 }
std::string barcode
U second(std::pair< T, U > const &p)
string rm
Definition: submit.py:76
XMLCh * transcode(const T &fInput)
#define end
Definition: vmac.h:37
XERCES_CPP_NAMESPACE::DOMElement * partsElem
XERCES_CPP_NAMESPACE::DOMElement * addPart(XERCES_CPP_NAMESPACE::DOMElement *parent, HcalPart &part)
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:145
#define comment(par)
Definition: vmac.h:161
DOMElement * HcalHardwareXml::addPart ( XERCES_CPP_NAMESPACE::DOMElement *  parent,
HcalPart part 
)
private

Definition at line 102 of file HcalHardwareXml.cc.

References _HcalPart::attr_name, _HcalPart::attr_value, _HcalPart::barcode, class-composition::child, _HcalPart::comment, XMLDOMBlock::document, _HcalPart::kind_of_part, _HcalPart::mode, _HcalPart::name_label, findQualityFiles::size, and XERCES_CPP_NAMESPACE_USE::transcode().

Referenced by addHardware().

103 {
104 
105  DOMElement * child = document -> createElement( XMLString::transcode( "PART" ) );
106  child -> setAttribute( XMLString::transcode("mode"), XMLString::transcode(part.mode.c_str()) );
107 
108  DOMElement * kindElem = document -> createElement( XMLString::transcode( "KIND_OF_PART" ) );
109  DOMElement * nameElem = document -> createElement( XMLString::transcode( "NAME_LABEL" ) );
110  DOMElement * barElem = document -> createElement( XMLString::transcode( "BARCODE" ) );
111  DOMElement * childrenElem = document -> createElement( XMLString::transcode( "CHILDREN" ) );
112  DOMElement * commentElem = document -> createElement( XMLString::transcode( "COMMENT_DESCRIPTION" ) );
113 
114  child -> appendChild( kindElem );
115  DOMText * _kind = document -> createTextNode( XMLString::transcode(part.kind_of_part.c_str()));
116  kindElem -> appendChild( _kind );
117  if (part.name_label . size() > 0){
118  child -> appendChild( nameElem );
119  DOMText * _name = document -> createTextNode( XMLString::transcode(part.name_label.c_str()));
120  nameElem -> appendChild( _name );
121  }
122  if (part.barcode . size() > 0){
123  child -> appendChild( barElem );
124  DOMText * _code = document -> createTextNode( XMLString::transcode(part.barcode.c_str()));
125  barElem -> appendChild( _code );
126  }
127  if (part.comment . size() > 0){
128  child -> appendChild( commentElem );
129  DOMText * _comment = document -> createTextNode( XMLString::transcode(part.comment.c_str()));
130  commentElem -> appendChild( _comment );
131  }
132  if (part.attr_name . size() > 0 || part.attr_value . size() > 0){
133  DOMElement * predefined_attr_elem = document -> createElement( XMLString::transcode( "PREDEFINED_ATTRIBUTES" ) );
134  child -> appendChild( predefined_attr_elem );
135  DOMElement * attr_elem = document -> createElement( XMLString::transcode( "ATTRIBUTE" ) );
136  predefined_attr_elem -> appendChild( attr_elem );
137  DOMElement * attr_name_elem = document -> createElement( XMLString::transcode( "NAME" ) );
138  attr_elem -> appendChild( attr_name_elem );
139  DOMText * _name = document -> createTextNode( XMLString::transcode(part.attr_name.c_str()));
140  attr_name_elem -> appendChild( _name );
141  DOMElement * attr_value_elem = document -> createElement( XMLString::transcode( "VALUE" ) );
142  attr_elem -> appendChild( attr_value_elem );
143  DOMText * _value = document -> createTextNode( XMLString::transcode(part.attr_value.c_str()));
144  attr_value_elem -> appendChild( _value );
145  }
146  child -> appendChild( childrenElem );
147 
148  parent -> appendChild( child );
149 
150  return child;
151 }
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
std::string mode
std::string kind_of_part
std::string barcode
XMLCh * transcode(const T &fInput)
std::string name_label
std::string comment
std::string attr_value
std::string attr_name
tuple size
Write out results.
const HcalHardwareXml& HcalHardwareXml::operator= ( const HcalHardwareXml )
private

Member Data Documentation

XERCES_CPP_NAMESPACE::DOMElement* HcalHardwareXml::partsElem
private

Definition at line 55 of file HcalHardwareXml.h.

Referenced by addHardware(), and HcalHardwareXml().