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 
17 XERCES_CPP_NAMESPACE_USE
18 
20 {
21  _root = 0;
22  _data = 0;
23  init();
24  parse(*_root);
25 }
26 
27 
29 {
30  if( _root ) delete _root;
31  if( _data ) delete _data;
32 }
33 
34 
36 {
37  static const char * _str = "\
38  <ROOT>\n\
39  <HEADER>\n\
40  <TYPE>\n\
41  <EXTENSION_TABLE_NAME>HCAL_TRIGGER_KEY</EXTENSION_TABLE_NAME>\n\
42  <NAME>HCAL trigger key</NAME>\n\
43  </TYPE>\n\
44  <RUN mode='no-run' />\n\
45  </HEADER>\n\
46  <DATA_SET>\n\
47  <VERSION>test_version</VERSION>\n\
48  <SUBVERSION>1</SUBVERSION>\n\
49  <CREATE_TIMESTAMP>2000-01-01 00:00:00.0</CREATE_TIMESTAMP>\n\
50  <CREATED_BY_USER>kukarzev</CREATED_BY_USER>\n\
51  <COMMENT_DESCRIPTION>test trigger key</COMMENT_DESCRIPTION>\n\
52  <PART>\n\
53  <NAME_LABEL>CMS-HCAL-ROOT</NAME_LABEL>\n\
54  </PART>\n\
55  </DATA_SET>\n\
56  <!-- Tags secton -->\n\
57  <ELEMENTS>\n\
58  <DATA_SET id='-1'/>\n\
59  <IOV id='1'>\n\
60  <INTERVAL_OF_VALIDITY_BEGIN>0</INTERVAL_OF_VALIDITY_BEGIN>\n\
61  <INTERVAL_OF_VALIDITY_END>1</INTERVAL_OF_VALIDITY_END>\n\
62  </IOV>\n\
63  <TAG id='2' mode='auto'>\n\
64  <TAG_NAME>trigger_key_tag</TAG_NAME>\n\
65  <DETECTOR_NAME>HCAL</DETECTOR_NAME>\n\
66  <COMMENT_DESCRIPTION>trigger_key_tag</COMMENT_DESCRIPTION>\n\
67  </TAG>\n\
68  </ELEMENTS>\n\
69  <MAPS>\n\
70  <TAG idref='2'>\n\
71  <IOV idref='1'>\n\
72  <DATA_SET idref='-1' />\n\
73  </IOV>\n\
74  </TAG>\n\
75  </MAPS>\n\
76  </ROOT>\n\
77  ";
78  const XMLByte * _template = (const XMLByte *)_str;
79  _root = new MemBufInputSource( _template, strlen( (const char *)_template ), "_root", false );
80 
81  static const char * _str2 = "\
82  <DATA>\n\
83  <TRIGGER_KEY_ID>TEST_trigger_key</TRIGGER_KEY_ID>\n\
84  <TRIGGER_KEY_CONFIG_TYPE>LUT_tag</TRIGGER_KEY_CONFIG_TYPE>\n\
85  <TRIGGER_KEY_CONFIG_VALUE>CRUZET_part4_physics_v3</TRIGGER_KEY_CONFIG_VALUE>\n\
86  </DATA>\n\
87  ";
88  const XMLByte * _template2 = (const XMLByte *)_str2;
89  _data = new MemBufInputSource( _template2, strlen( (const char *)_template2 ), "_data", false );
90 
91  return 0;
92 }
93 
94 
96  XMLDOMBlock data_block( *_data );
97  data_block.setTagValue("TRIGGER_KEY_ID",id);
98  data_block.setTagValue("TRIGGER_KEY_CONFIG_TYPE",type);
99  data_block.setTagValue("TRIGGER_KEY_CONFIG_VALUE",value);
100 
101  DOMDocument * data_doc = data_block . getDocument();
102 
103  DOMElement * data_set_elem = (DOMElement *)(document -> getElementsByTagName( XMLProcessor::_toXMLCh( "DATA_SET" ) ) -> item(0));
104 
105  DOMNode * clone_data = document -> importNode( data_doc -> getDocumentElement(), true );
106  data_set_elem -> appendChild( clone_data );
107 
108  //write("stdout");
109 
110  return 0;
111 }
112 
113 
114 int HcalTriggerKey::fill_key( std::string key_id, std::map<std::string, std::string> & key){
115  int _c=0;
116  for(std::map<std::string,std::string>::const_iterator key_pair=key.begin(); key_pair!=key.end(); key_pair++){
117  add_data(key_id, key_pair->first, key_pair->second);
118  _c++;
119  }
120 
121  return _c;
122 }
123 
125  std::map<std::string, std::string> _key;
126  std::string _id, _type, _value;
127 
128  std::cout << std::endl << "Creating the trigger key..." << std::endl;
129  std::cout << std::endl << "Enter the key ID (or tag if you would): " << std::endl;
130  std::getline(std::cin, _id);
131  while(1){
132  std::cout << "Enter the next config type (or type exit if the trigger key is complete): " << std::endl;
133  std::getline(std::cin, _type);
134  if (_type.find("exit") != std::string::npos) break;
135  std::cout << "Enter the config value: " << std::endl;
136  std::getline(std::cin, _value);
137  _key.insert(std::pair<std::string, std::string>(_type, _value));
138  }
139 
140  fill_key(_id, _key);
141 
142  std::cout << std::endl << "Creating the trigger key... done" << std::endl;
143  return 0;
144 }
type
Definition: HCALResponse.h:21
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:96
XERCES_CPP_NAMESPACE::MemBufInputSource * _data
XERCES_CPP_NAMESPACE::MemBufInputSource * _root
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)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
int fill_key(std::string key_id, std::map< std::string, std::string > &key)
static XMLCh * _toXMLCh(std::string temp)
Definition: XMLProcessor.h:183
tuple cout
Definition: gather_cfg.py:145
int add_data(std::string id, std::string type, std::string value)
virtual ~HcalTriggerKey()
void parse(XERCES_CPP_NAMESPACE::InputSource &_source)
Definition: XMLDOMBlock.cc:122
int compose_key_dialogue(void)