CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
XMLRBXPedestalsLoader Class Reference

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

Inheritance diagram for XMLRBXPedestalsLoader:
XMLDOMBlock

Classes

struct  _datasetDBConfig
 
struct  _loaderBaseConfig
 

Public Types

typedef XMLRBXPedestalsLoader::_datasetDBConfig datasetDBConfig
 
typedef struct XMLRBXPedestalsLoader::_loaderBaseConfig loaderBaseConfig
 

Public Member Functions

int addRBXSlot (datasetDBConfig *config, std::string brickFileName, std::string rbx_config_type="pedestals", std::string templateFileName="HCAL_RBX_PEDESTALS_TYPE01.dataset.template")
 
 XMLRBXPedestalsLoader (loaderBaseConfig *config, std::string templateBase="HCAL_RBX_PEDESTALS_TYPE01.XMLloader.template")
 
virtual ~XMLRBXPedestalsLoader ()
 
- 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 ()
 

Protected Member Functions

int fixRbxName (std::string &)
 
int init (void)
 
- Protected Member Functions inherited from XMLDOMBlock
int init (std::string _root)
 

Protected Attributes

XERCES_CPP_NAMESPACE::MemBufInputSource * _data_gol
 
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_led
 
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_ped_delay
 
- 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
 

Private Member Functions

const XMLRBXPedestalsLoaderoperator= (const XMLRBXPedestalsLoader &)
 
 XMLRBXPedestalsLoader (const XMLRBXPedestalsLoader &)
 

Detailed Description

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

Usage: <usage>

Definition at line 29 of file XMLRBXPedestalsLoader.h.

Member Typedef Documentation

Constructor & Destructor Documentation

XMLRBXPedestalsLoader::XMLRBXPedestalsLoader ( loaderBaseConfig config,
std::string  templateBase = "HCAL_RBX_PEDESTALS_TYPE01.XMLloader.template" 
)

Definition at line 56 of file XMLRBXPedestalsLoader.cc.

References init(), dataset::name, XMLDOMBlock::setTagAttribute(), and XMLDOMBlock::setTagValue().

56  : XMLDOMBlock( templateBase )
57 {
58 
59  init();
60 
61  setTagValue( "EXTENSION_TABLE_NAME", config -> extention_table_name );
62  setTagValue( "NAME", config -> name );
63  setTagAttribute( "RUN", "mode", config -> run_mode );
64  setTagAttribute( "DATA_SET", "id", config -> data_set_id );
65  setTagAttribute( "IOV", "id", config -> iov_id );
66  setTagValue( "INTERVAL_OF_VALIDITY_BEGIN", config -> iov_begin );
67  setTagValue( "INTERVAL_OF_VALIDITY_END", config -> iov_end );
68  setTagAttribute( "TAG", "id", config -> tag_id );
69  setTagAttribute( "TAG", "mode", config -> tag_mode );
70  setTagValue( "TAG_NAME", config -> tag_name );
71  setTagValue( "DETECTOR_NAME", config -> detector_name );
72  setTagValue( "COMMENT_DESCRIPTION", config -> elements_comment_description );
73  setTagAttribute( "TAG", "idref", config -> tag_id, 1 );
74  setTagAttribute( "IOV", "idref", config -> iov_id, 1 );
75  setTagAttribute( "DATA_SET", "idref", config -> data_set_id, 1 );
76 }
Definition: config.py:1
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 * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
Definition: XMLDOMBlock.cc:408
XMLRBXPedestalsLoader::~XMLRBXPedestalsLoader ( )
virtual

Definition at line 79 of file XMLRBXPedestalsLoader.cc.

References _data_gol, _data_led, and _data_ped_delay.

80 {
81  if( _data_ped_delay ) delete _data_ped_delay;
82  if( _data_gol ) delete _data_gol;
83  if( _data_led ) delete _data_led;
84 }
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_ped_delay
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_gol
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_led
XMLRBXPedestalsLoader::XMLRBXPedestalsLoader ( const XMLRBXPedestalsLoader )
private

Member Function Documentation

int XMLRBXPedestalsLoader::addRBXSlot ( datasetDBConfig config,
std::string  brickFileName,
std::string  rbx_config_type = "pedestals",
std::string  templateFileName = "HCAL_RBX_PEDESTALS_TYPE01.dataset.template" 
)

Definition at line 87 of file XMLRBXPedestalsLoader.cc.

References _data_gol, _data_led, _data_ped_delay, XMLProcessor::_toXMLCh(), gather_cfg::cout, data, XMLDOMBlock::document, cmsRelvalreport::exit, XMLDOMBlock::getDocument(), XMLDOMBlock::getTagAttribute(), XMLDOMBlock::getTagValue(), XMLDOMBlock::setTagValue(), AlCaHLTBitMon_QueryRunRegistry::string, and jetIDSelector_cfi::version.

88 {
89  DOMElement * root = document -> getDocumentElement();
90 
91  XMLDOMBlock dataSetDoc( templateFileName );
92  DOMDocument * dataSet = dataSetDoc . getDocument();
93 
94  char timebuf[50];
95  strftime( timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime( &(config -> create_timestamp) ) );
96  setTagValue( "CREATE_TIMESTAMP", timebuf , 0, dataSet );
97  setTagValue( "CREATED_BY_USER", config -> created_by_user, 0, dataSet );
98  setTagValue( "VERSION", config -> version, 0, dataSet );
99  setTagValue( "SUBVERSION", config -> subversion, 0, dataSet );
100  setTagValue( "COMMENT_DESCRIPTION", config -> comment_description, 0, dataSet );
101  setTagValue( "NAME_LABEL", config -> name_label, 0, dataSet );
102  setTagValue( "KIND_OF_PART", config -> kind_of_part, 0, dataSet );
103 
104  // <DATA/>
105  //XMLDOMBlock rbxBrickDoc( "rbx_HBM01_PEDESTAL.xml" );
106  XMLDOMBlock rbxBrickDoc( brickFileName );
107  DOMDocument * rbxBrick = rbxBrickDoc . getDocument();
108  if ( rbx_config_type == "pedestals" || rbx_config_type == "delays" || rbx_config_type == "gols" ){
109  for ( unsigned int _item = 0; _item < rbxBrick -> getElementsByTagName( XMLProcessor::_toXMLCh( "Data" ) ) -> getLength(); _item++ ){
110  DOMElement * dataset_root = dataSet -> getDocumentElement();
111 
112  std::string _rm;
113  std::string _qie;
114  std::string _adc;
115  //string _led_item;
116 
117  MemBufInputSource * _data; // a container for the XML template for a data block
118  if ( rbx_config_type == "pedestals" || rbx_config_type == "delays" ){
119  _rm = rbxBrickDoc . getTagAttribute( "Data", "rm", _item );
120  _qie = rbxBrickDoc . getTagAttribute( "Data", "card", _item );
121  _adc = rbxBrickDoc . getTagAttribute( "Data", "qie", _item );
122  _data = _data_ped_delay;
123  }
124  else if ( rbx_config_type == "gols" ){
125  _rm = rbxBrickDoc . getTagAttribute( "Data", "rm", _item );
126  _qie = rbxBrickDoc . getTagAttribute( "Data", "card", _item );
127  _adc = rbxBrickDoc . getTagAttribute( "Data", "gol", _item );
128  _data = _data_gol;
129  }
130  //else if ( rbx_config_type == "leds" ){
131  //_led_item = rbxBrickDoc . getTagAttribute( "Data", "item", _item );
132  //_data = _data_led;
133  //}
134  else{
135  std::cout << "XMLRBXPedestalsLoader::addRBXSlot(): Unknown config type... exiting" << std::endl;
136  exit(1);
137  }
138  XMLDOMBlock dataDoc( *_data );
139  DOMDocument * data = dataDoc . getDocument();
140  std::string _value = rbxBrickDoc . getTagValue( "Data", _item );
141  if ( rbx_config_type == "pedestals" || rbx_config_type == "delays" ){
142  setTagValue( "MODULE_POSITION", _rm, 0, data );
143  setTagValue( "QIE_CARD_POSITION", _qie, 0, data );
144  setTagValue( "QIE_ADC_NUMBER", _adc, 0, data );
145  }
146  else if ( rbx_config_type == "gols" ){
147  setTagValue( "MODULE_POSITION", _rm, 0, data );
148  setTagValue( "QIE_CARD_POSITION", _qie, 0, data );
149  setTagValue( "FIBER_NUMBER", _adc, 0, data );
150  }
151  else if ( rbx_config_type == "gols" ){
152  setTagValue( "MODULE_POSITION", _rm, 0, data );
153  setTagValue( "QIE_CARD_POSITION", _qie, 0, data );
154  setTagValue( "FIBER_NUMBER", _adc, 0, data );
155  }
156  else if ( rbx_config_type == "leds" ){
157  setTagValue( "MODULE_POSITION", _rm, 0, data );
158  setTagValue( "QIE_CARD_POSITION", _qie, 0, data );
159  setTagValue( "FIBER_NUMBER", _adc, 0, data );
160  }
161  else{
162  std::cout << "XMLRBXPedestalsLoader::addRBXSlot(): Unknown config type... exiting" << std::endl;
163  exit(1);
164  }
165  setTagValue( "INTEGER_VALUE", _value, 0, data );
166  DOMNode * cloneData = dataSet -> importNode( data -> getDocumentElement(), true );
167  dataset_root -> appendChild( cloneData );
168  }
169  }
170  else if ( rbx_config_type == "leds" ){
171  DOMElement * dataset_root = dataSet -> getDocumentElement();
172 
173  std::string _led_item;
174 
175  MemBufInputSource * _data; // a container for the XML template for a data block
176  _data = _data_led;
177  std::string _value;
178 
179  XMLDOMBlock dataDoc( *_data );
180  DOMDocument * data = dataDoc . getDocument();
181 
182  int _item = 0;
183  _led_item = rbxBrickDoc . getTagAttribute( "Data", "item", _item );
184  // FIXME: need to check that the right data tag (_led_item) from the original brick is being processed
185  _value = rbxBrickDoc . getTagValue( "Data", _item );
186  setTagValue( "LED1_ON_IS_CHECKED", _value, 0, data );
187  setTagValue( "SET_LEDS_IS_CHECKED", _value, 0, data );
188  _item = 1;
189  _led_item = rbxBrickDoc . getTagAttribute( "Data", "item", _item );
190  _value = rbxBrickDoc . getTagValue( "Data", _item );
191  setTagValue( "LED2_ON_IS_CHECKED", _value, 0, data );
192  if (_value.find("0")==std::string::npos){
193  setTagValue( "SET_LEDS_IS_CHECKED", _value, 0, data );
194  }
195  _item = 2;
196  _led_item = rbxBrickDoc . getTagAttribute( "Data", "item", _item );
197  _value = rbxBrickDoc . getTagValue( "Data", _item );
198  setTagValue( "LED_AMPLITUDE", _value, 0, data );
199  _item = 3;
200  _led_item = rbxBrickDoc . getTagAttribute( "Data", "item", _item );
201  _value = rbxBrickDoc . getTagValue( "Data", _item );
202  setTagValue( "BUNCH_NUMBER", _value, 0, data );
203 
204  DOMNode * cloneData = dataSet -> importNode( data -> getDocumentElement(), true );
205  dataset_root -> appendChild( cloneData );
206  }
207 
208  // copy the <data_set> node into the final XML
209  DOMNode * cloneDataSet = document -> importNode( dataSet -> getDocumentElement(), true );
210  root -> appendChild( cloneDataSet );
211 
212  // update header from the brick
213  std::string _name;
214  int parameter_iter = -1;
215  do
216  {
217  parameter_iter++;
218  _name = rbxBrickDoc . getTagAttribute( "Parameter", "name", parameter_iter );
219  //std::cout << _name << std::endl;
220  } while( _name != "CREATIONTAG" );
221  std::string _creationtag = rbxBrickDoc . getTagValue( "Parameter", parameter_iter );
222  //std::cout << _creationtag << std::endl;
223  //setTagValue( "TAG_NAME", _creationtag ); // uncomment if want to pick up tag name from the brick set
224 
225  parameter_iter = -1;
226  do
227  {
228  parameter_iter++;
229  _name = rbxBrickDoc . getTagAttribute( "Parameter", "name", parameter_iter );
230  //std::cout << _name << std::endl;
231  } while( _name != "RBX" );
232  std::string _rbx = rbxBrickDoc . getTagValue( "Parameter", parameter_iter );
233 
234  // name_label fix - should be temporary
235  //fixRbxName( _rbx );
236  std::cout << _rbx << std::endl;
237  setTagValue( "NAME_LABEL", _rbx );
238 
239  // change kind of part name if this is ZDC (there is only one - ZDC01)
240  if (_rbx.find("ZDC01")!=std::string::npos){
241  setTagValue( "KIND_OF_PART", "HCAL ZDC RBX" );
242  std::cout << " --> ZDC RBX!" << std::endl;
243  }
244 
245  return 0;
246 }
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_ped_delay
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
Definition: config.py:1
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_gol
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_led
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const char * getTagValue(const std::string &tagName, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=NULL)
const char * getTagAttribute(const std::string &tagName, const std::string &attrName, int _item=0)
Definition: XMLDOMBlock.cc:400
int XMLRBXPedestalsLoader::fixRbxName ( std::string &  rbx)
protected

Definition at line 248 of file XMLRBXPedestalsLoader.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

249 {
250  std::string _fourth = rbx . substr(0,4);
251  if ( _fourth == "HBM0" || _fourth == "HBP0" || _fourth == "HEP0" || _fourth == "HFP0" || _fourth == "HOP0" || _fourth == "HOM0" ) rbx . erase( 3, 1 );
252 
253  if ( rbx == "HO0M02" ) rbx = "HO0M2";
254  if ( rbx == "HO0M04" ) rbx = "HO0M4";
255  if ( rbx == "HO0M06" ) rbx = "HO0M6";
256  if ( rbx == "HO0M08" ) rbx = "HO0M8";
257  if ( rbx == "HO0M10" ) rbx = "HO0M10";
258  if ( rbx == "HO0M12" ) rbx = "HO0M12";
259  if ( rbx == "HO0P02" ) rbx = "HO0P2";
260  if ( rbx == "HO0P04" ) rbx = "HO0P4";
261  if ( rbx == "HO0P06" ) rbx = "HO0P6";
262  if ( rbx == "HO0P08" ) rbx = "HO0P8";
263  if ( rbx == "HO0P10" ) rbx = "HO0P10";
264  if ( rbx == "HO0P12" ) rbx = "HO0P12";
265 
266  return 0;
267 }
int XMLRBXPedestalsLoader::init ( void  )
protected

Definition at line 269 of file XMLRBXPedestalsLoader.cc.

References _data_gol, _data_led, and _data_ped_delay.

Referenced by XMLRBXPedestalsLoader().

270 {
271  // define the <DATA/> template for pedestals and zero delays
272  static const char * _str = "\
273  <DATA>\n\
274  <MODULE_POSITION>2</MODULE_POSITION>\n\
275  <QIE_CARD_POSITION>1</QIE_CARD_POSITION>\n\
276  <QIE_ADC_NUMBER>0</QIE_ADC_NUMBER>\n\
277  <INTEGER_VALUE>4</INTEGER_VALUE>\n\
278  </DATA>\n\
279  ";
280  const XMLByte * _template = (const XMLByte *)_str;
281  _data_ped_delay = new MemBufInputSource( _template, strlen( (const char *)_template ), "_data_ped_delay", false );
282 
283  // define the <DATA/> template for gol currents
284  static const char * _str2 = "\
285  <DATA>\n\
286  <MODULE_POSITION>2</MODULE_POSITION>\n\
287  <QIE_CARD_POSITION>1</QIE_CARD_POSITION>\n\
288  <FIBER_NUMBER>0</FIBER_NUMBER>\n\
289  <INTEGER_VALUE>4</INTEGER_VALUE>\n\
290  </DATA>\n\
291  ";
292  const XMLByte * _template2 = (const XMLByte *)_str2;
293  _data_gol = new MemBufInputSource( _template2, strlen( (const char *)_template2 ), "_data_gol", false );
294 
295  // define the <DATA/> template for LED data
296  static const char * _str3 = "\
297  <DATA>\n\
298  <RM1_IS_CHECKED>1</RM1_IS_CHECKED>\n\
299  <RM2_IS_CHECKED>1</RM2_IS_CHECKED>\n\
300  <RM3_IS_CHECKED>1</RM3_IS_CHECKED>\n\
301  <RM4_IS_CHECKED>1</RM4_IS_CHECKED>\n\
302  <CALIB_IS_CHECKED>1</CALIB_IS_CHECKED>\n\
303  <RESET1_IS_CHECKED>1</RESET1_IS_CHECKED>\n\
304  <RESET1_VALUE>40</RESET1_VALUE>\n\
305  <RESET1_WAIT_CYCLES>3</RESET1_WAIT_CYCLES>\n\
306  <RESET2_IS_CHECKED>1</RESET2_IS_CHECKED>\n\
307  <RESET2_VALUE>40</RESET2_VALUE>\n\
308  <RESET2_WAIT_CYCLES>3</RESET2_WAIT_CYCLES>\n\
309  <SET_LEDS_IS_CHECKED>0</SET_LEDS_IS_CHECKED>\n\
310  <LED1_ON_IS_CHECKED>0</LED1_ON_IS_CHECKED>\n\
311  <LED2_ON_IS_CHECKED>0</LED2_ON_IS_CHECKED>\n\
312  <LED_AMPLITUDE>128</LED_AMPLITUDE>\n\
313  <LED_DELAY>1000</LED_DELAY>\n\
314  <TTCRX_PHASE>100</TTCRX_PHASE>\n\
315  <BROADCAST_SETTINGS>1</BROADCAST_SETTINGS>\n\
316  <QIE_RESET_DELAY>5</QIE_RESET_DELAY>\n\
317  <BUNCH_NUMBER>2000</BUNCH_NUMBER>\n\
318  </DATA>\n\
319  ";
320  const XMLByte * _template3 = (const XMLByte *)_str3;
321  _data_led = new MemBufInputSource( _template3, strlen( (const char *)_template3 ), "_data_led", false );
322 
323  return 0;
324 }
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_ped_delay
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_gol
XERCES_CPP_NAMESPACE::MemBufInputSource * _data_led
const XMLRBXPedestalsLoader& XMLRBXPedestalsLoader::operator= ( const XMLRBXPedestalsLoader )
private

Member Data Documentation

XERCES_CPP_NAMESPACE::MemBufInputSource* XMLRBXPedestalsLoader::_data_gol
protected

Definition at line 77 of file XMLRBXPedestalsLoader.h.

Referenced by addRBXSlot(), init(), and ~XMLRBXPedestalsLoader().

XERCES_CPP_NAMESPACE::MemBufInputSource* XMLRBXPedestalsLoader::_data_led
protected

Definition at line 78 of file XMLRBXPedestalsLoader.h.

Referenced by addRBXSlot(), init(), and ~XMLRBXPedestalsLoader().

XERCES_CPP_NAMESPACE::MemBufInputSource* XMLRBXPedestalsLoader::_data_ped_delay
protected

Definition at line 76 of file XMLRBXPedestalsLoader.h.

Referenced by addRBXSlot(), init(), and ~XMLRBXPedestalsLoader().