test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTriggerKey.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: XMLTools
4 // Class : HcalTriggerKey
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Gena Kukartsev, kukarzev@fnal.gov
10 // Created: August 27, 2008
11 //
12 
16 
18 {
19  _root = 0;
20  _data = 0;
21  init();
22  parse(*_root);
23 }
24 
25 
27 {
28  if( _root ) delete _root;
29  if( _data ) delete _data;
30 }
31 
32 
34 {
35  static const char * _str = "\
36  <ROOT>\n\
37  <HEADER>\n\
38  <TYPE>\n\
39  <EXTENSION_TABLE_NAME>HCAL_TRIGGER_KEY</EXTENSION_TABLE_NAME>\n\
40  <NAME>HCAL trigger key</NAME>\n\
41  </TYPE>\n\
42  <RUN mode='no-run' />\n\
43  </HEADER>\n\
44  <DATA_SET>\n\
45  <VERSION>test_version</VERSION>\n\
46  <SUBVERSION>1</SUBVERSION>\n\
47  <CREATE_TIMESTAMP>2000-01-01 00:00:00.0</CREATE_TIMESTAMP>\n\
48  <CREATED_BY_USER>kukarzev</CREATED_BY_USER>\n\
49  <COMMENT_DESCRIPTION>test trigger key</COMMENT_DESCRIPTION>\n\
50  <PART>\n\
51  <NAME_LABEL>CMS-HCAL-ROOT</NAME_LABEL>\n\
52  </PART>\n\
53  </DATA_SET>\n\
54  <!-- Tags secton -->\n\
55  <ELEMENTS>\n\
56  <DATA_SET id='-1'/>\n\
57  <IOV id='1'>\n\
58  <INTERVAL_OF_VALIDITY_BEGIN>0</INTERVAL_OF_VALIDITY_BEGIN>\n\
59  <INTERVAL_OF_VALIDITY_END>1</INTERVAL_OF_VALIDITY_END>\n\
60  </IOV>\n\
61  <TAG id='2' mode='auto'>\n\
62  <TAG_NAME>trigger_key_tag</TAG_NAME>\n\
63  <DETECTOR_NAME>HCAL</DETECTOR_NAME>\n\
64  <COMMENT_DESCRIPTION>trigger_key_tag</COMMENT_DESCRIPTION>\n\
65  </TAG>\n\
66  </ELEMENTS>\n\
67  <MAPS>\n\
68  <TAG idref='2'>\n\
69  <IOV idref='1'>\n\
70  <DATA_SET idref='-1' />\n\
71  </IOV>\n\
72  </TAG>\n\
73  </MAPS>\n\
74  </ROOT>\n\
75  ";
76  const XMLByte * _template = (const XMLByte *)_str;
77  _root = new MemBufInputSource( _template, strlen( (const char *)_template ), "_root", false );
78 
79  static const char * _str2 = "\
80  <DATA>\n\
81  <TRIGGER_KEY_ID>TEST_trigger_key</TRIGGER_KEY_ID>\n\
82  <TRIGGER_KEY_CONFIG_TYPE>LUT_tag</TRIGGER_KEY_CONFIG_TYPE>\n\
83  <TRIGGER_KEY_CONFIG_VALUE>CRUZET_part4_physics_v3</TRIGGER_KEY_CONFIG_VALUE>\n\
84  </DATA>\n\
85  ";
86  const XMLByte * _template2 = (const XMLByte *)_str2;
87  _data = new MemBufInputSource( _template2, strlen( (const char *)_template2 ), "_data", false );
88 
89  return 0;
90 }
91 
92 
94  XMLDOMBlock data_block( *_data );
95  data_block.setTagValue("TRIGGER_KEY_ID",id);
96  data_block.setTagValue("TRIGGER_KEY_CONFIG_TYPE",type);
97  data_block.setTagValue("TRIGGER_KEY_CONFIG_VALUE",value);
98 
99  DOMDocument * data_doc = data_block . getDocument();
100 
101  DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
102 
103  DOMNode * clone_data = document -> importNode( data_doc -> getDocumentElement(), true );
104  data_set_elem -> appendChild( clone_data );
105 
106  //write("stdout");
107 
108  return 0;
109 }
110 
111 
112 int HcalTriggerKey::fill_key( std::string key_id, std::map<std::string, std::string> & key){
113  int _c=0;
114  for(std::map<std::string,std::string>::const_iterator key_pair=key.begin(); key_pair!=key.end(); key_pair++){
115  add_data(key_id, key_pair->first, key_pair->second);
116  _c++;
117  }
118 
119  return _c;
120 }
121 
123  std::map<std::string, std::string> _key;
124  std::string _id, _type, _value;
125 
126  std::cout << std::endl << "Creating the trigger key..." << std::endl;
127  std::cout << std::endl << "Enter the key ID (or tag if you would): " << std::endl;
128  std::getline(std::cin, _id);
129  while(1){
130  std::cout << "Enter the next config type (or type exit if the trigger key is complete): " << std::endl;
131  std::getline(std::cin, _type);
132  if (_type.find("exit") != std::string::npos) break;
133  std::cout << "Enter the config value: " << std::endl;
134  std::getline(std::cin, _value);
135  _key.insert(std::pair<std::string, std::string>(_type, _value));
136  }
137 
138  fill_key(_id, _key);
139 
140  std::cout << std::endl << "Creating the trigger key... done" << std::endl;
141  return 0;
142 }
type
Definition: HCALResponse.h:21
DOMDocument * document
Definition: XMLDOMBlock.h:97
DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:312
int fill_key(std::string key_id, std::map< std::string, std::string > &key)
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:184
void parse(InputSource &_source)
Definition: XMLDOMBlock.cc:122
list key
Definition: combine.py:13
MemBufInputSource * _data
tuple cout
Definition: gather_cfg.py:121
int add_data(std::string id, std::string type, std::string value)
virtual ~HcalTriggerKey()
MemBufInputSource * _root
DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, DOMDocument *_document=NULL)
Definition: XMLDOMBlock.cc:364
int compose_key_dialogue(void)