CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
DOMElement * add_element (DOMElement *parent, XMLCh *tagname, XMLCh *value)
 
DOMDocument * getDocument (void)
 
DOMDocument * getDocumentConst (void) const
 
DOMDocument * getNewDocument (std::string xmlFileName)
 
std::string & getString (void)
 
std::string & getString (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, DOMDocument *_document=NULL)
 
const char * getTagValue (const std::string &tagName, int _item, DOMElement *_document)
 
std::string getTimestamp (time_t _time)
 
XMLDOMBlockoperator+= (const XMLDOMBlock &other)
 
void parse (InputSource &_source)
 
DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
DOMNode * setTagAttribute (DOMElement *_elem, const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
 
DOMNode * setTagAttribute (const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
DOMNode * setTagAttribute (DOMElement *_elem, const std::string &tagName, const std::string &attrName, const int &attrValue, int _item=0)
 
DOMNode * setTagValue (const std::string &tagName, const std::string &tagValue, int _item=0, DOMDocument *_document=NULL)
 
DOMNode * setTagValue (DOMElement *_elem, const std::string &tagName, const std::string &tagValue, int _item=0)
 
DOMNode * setTagValue (const std::string &tagName, const int &tagValue, int _item=0, DOMDocument *_document=NULL)
 
DOMNode * setTagValue (DOMElement *_elem, const std::string &tagName, const int &tagValue, int _item=0)
 
int write (std::string target="stdout")
 
 XMLDOMBlock ()
 
 XMLDOMBlock (std::string xmlFileName)
 
 XMLDOMBlock (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

MemBufInputSource * _data_gol
 
MemBufInputSource * _data_led
 
MemBufInputSource * _data_ped_delay
 
- Protected Attributes inherited from XMLDOMBlock
DOMDocument * document
 
ErrorHandler * errHandler
 
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 55 of file XMLRBXPedestalsLoader.cc.

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

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

References _data_gol, _data_led, and _data_ped_delay.

79 {
80  if( _data_ped_delay ) delete _data_ped_delay;
81  if( _data_gol ) delete _data_gol;
82  if( _data_led ) delete _data_led;
83 }
MemBufInputSource * _data_led
MemBufInputSource * _data_ped_delay
MemBufInputSource * _data_gol
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 86 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(), dbtoconf::root, XMLDOMBlock::setTagValue(), AlCaHLTBitMon_QueryRunRegistry::string, and relval_steps::version.

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

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 268 of file XMLRBXPedestalsLoader.cc.

References _data_gol, _data_led, and _data_ped_delay.

Referenced by XMLRBXPedestalsLoader().

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

Member Data Documentation

MemBufInputSource* XMLRBXPedestalsLoader::_data_gol
protected

Definition at line 77 of file XMLRBXPedestalsLoader.h.

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

MemBufInputSource* XMLRBXPedestalsLoader::_data_led
protected

Definition at line 78 of file XMLRBXPedestalsLoader.h.

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

MemBufInputSource* XMLRBXPedestalsLoader::_data_ped_delay
protected

Definition at line 76 of file XMLRBXPedestalsLoader.h.

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