CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
XMLLUTLoader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: XMLTools
4 // Class : XMLLUTLoader
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Gena Kukartsev, kukarzev@fnal.gov
10 // Created: Tue Oct 23 14:30:20 CDT 2007
11 //
12 
13 // system include files
14 
15 // user include files
18 #include <cstdio>
19 XERCES_CPP_NAMESPACE_USE
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33  kind_of_part = "HCAL HTR Crate";
34  name_label = "CRATE17";
35  trig_prim_lookuptbl_data_file = "testLUT_17.xml";
36  crate = 17;
37 }
38 
40  comment_description = "checksum for all crates version test:2";
41  name_label = "CMS-HCAL-ROOT";
42  trig_prim_lookuptbl_data_file = "./testLUT_checksums.xml";
43  crate = -1;
44 }
45 
47 
49  : XMLDOMBlock(templateBase) {
50  setTagValue("EXTENSION_TABLE_NAME", config->extention_table_name);
51  setTagValue("NAME", config->name);
52  setTagAttribute("RUN", "mode", config->run_mode);
53  setTagAttribute("DATA_SET", "id", config->data_set_id);
54  setTagAttribute("IOV", "id", config->iov_id);
55  setTagValue("INTERVAL_OF_VALIDITY_BEGIN", config->iov_begin);
56  setTagValue("INTERVAL_OF_VALIDITY_END", config->iov_end);
57  setTagAttribute("TAG", "id", config->tag_id);
58  setTagAttribute("TAG", "mode", config->tag_mode);
59  setTagValue("TAG_NAME", config->tag_name);
60  setTagValue("DETECTOR_NAME", config->detector_name);
61  setTagValue("COMMENT_DESCRIPTION", config->comment_description);
62 
63  setTagAttribute("TAG", "idref", config->tag_id, 1);
64  setTagAttribute("IOV", "idref", config->iov_id, 1);
65  setTagAttribute("DATA_SET", "idref", config->data_set_id, 1);
66 }
67 
68 // XMLLUTLoader::XMLLUTLoader(const XMLLUTLoader& rhs)
69 // {
70 // // do actual copying here;
71 // }
72 
74 
75 //
76 // assignment operators
77 //
78 // const XMLLUTLoader& XMLLUTLoader::operator=(const XMLLUTLoader& rhs)
79 // {
80 // //An exception safe implementation is
81 // XMLLUTLoader temp(rhs);
82 // swap(rhs);
83 //
84 // return *this;
85 // }
86 
87 //
88 // member functions
89 //
91  DOMElement* root = document->getDocumentElement();
92 
93  XMLDOMBlock dataSetDoc(templateFileName);
94  DOMDocument* dataSet = dataSetDoc.getDocument();
95 
96  // changes to the LUT <data_set> node
97  setTagValue("VERSION", config->version, 0, dataSet);
98  setTagValue("SUBVERSION", config->subversion, 0, dataSet);
99  char timebuf[50];
100  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
101  strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime(&(config->create_timestamp)));
102  setTagValue("CREATE_TIMESTAMP", timebuf, 0, dataSet);
103  setTagValue("CREATED_BY_USER", config->created_by_user, 0, dataSet);
104  setTagValue("KIND_OF_PART", config->kind_of_part, 0, dataSet);
105  setTagValue("NAME_LABEL", config->name_label, 0, dataSet);
106  setTagValue("TRIG_PRIM_LOOKUPTBL_DATA_FILE", config->trig_prim_lookuptbl_data_file, 0, dataSet);
107  setTagValue("CRATE", config->crate, 0, dataSet);
108 
109  // copy the <data_set> node into the final XML
110  DOMNode* cloneDataSet = document->importNode(dataSet->getDocumentElement(), true);
111  root->appendChild(cloneDataSet);
112 
113  return 0;
114 }
115 
117  DOMElement* root = document->getDocumentElement();
118 
119  XMLDOMBlock dataSetDoc(templateFileName);
120  DOMDocument* dataSet = dataSetDoc.getDocument();
121 
122  // changes to the Checksums <data_set> node
123  setTagValue("VERSION", config->version, 0, dataSet);
124  setTagValue("SUBVERSION", config->subversion, 0, dataSet);
125  char timebuf[50];
126  //strftime( timebuf, 50, "%c", gmtime( &(config -> create_timestamp) ) );
127  strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime(&(config->create_timestamp)));
128  setTagValue("CREATE_TIMESTAMP", timebuf, 0, dataSet);
129  setTagValue("CREATED_BY_USER", config->created_by_user, 0, dataSet);
130  setTagValue("COMMENT_DESCRIPTION", config->comment_description, 0, dataSet);
131  setTagValue("NAME_LABEL", config->name_label, 0, dataSet);
132  setTagValue("TRIG_PRIM_LOOKUPTBL_DATA_FILE", config->trig_prim_lookuptbl_data_file, 0, dataSet);
133  setTagValue("CRATE", config->crate, 0, dataSet);
134 
135  // copy the <data_set> node into the final XML
136  DOMNode* cloneDataSet = document->importNode(dataSet->getDocumentElement(), true);
137  root->appendChild(cloneDataSet);
138 
139  return 0;
140 }
141 
142 int XMLLUTLoader::createLoader(const std::vector<int>& crate_number, const std::vector<std::string>& file_name) {
145 
146  for (std::vector<std::string>::const_iterator _file = file_name.begin(); _file != file_name.end(); _file++) {
147  conf.trig_prim_lookuptbl_data_file = *_file;
148  conf.trig_prim_lookuptbl_data_file += ".dat";
149  conf.crate = crate_number[_file - file_name.begin()];
150 
151  char _buf[128];
152  sprintf(_buf, "CRATE%.2d", conf.crate);
153  std::string _namelabel;
154  _namelabel.append(_buf);
155  conf.name_label = _namelabel;
156  addLUT(&conf);
157  }
158 
159  CSconf.trig_prim_lookuptbl_data_file += ".dat";
160  addChecksums(&CSconf);
161  write("LUTLoader.xml");
162 
163  return 0;
164 }
165 
166 //
167 // const member functions
168 //
169 
170 //
171 // static member functions
172 //
XERCES_CPP_NAMESPACE::DOMDocument * document
Definition: XMLDOMBlock.h:117
int addLUT(lutDBConfig *config, std::string templateFileName="HCAL_TRIG_PRIM_LOOKUP_TABLE.dataset.template")
Definition: XMLLUTLoader.cc:90
int write(std::string target="stdout")
Definition: XMLDOMBlock.cc:272
XERCES_CPP_NAMESPACE::DOMNode * setTagValue(const std::string &tagName, const std::string &tagValue, int _item=0, XERCES_CPP_NAMESPACE::DOMDocument *_document=nullptr)
XERCES_CPP_NAMESPACE::DOMDocument * getDocument(void)
Definition: XMLDOMBlock.cc:268
int createLoader(const std::vector< int > &crate_number, const std::vector< std::string > &file_name)
tuple config
parse the configuration file
int addChecksums(checksumsDBConfig *config, std::string templateFileName="HCAL_TRIG_PRIM_LOOKUP_TABLE.checksums.template")
~XMLLUTLoader() override
Definition: XMLLUTLoader.cc:73
std::string trig_prim_lookuptbl_data_file
Definition: XMLLUTLoader.h:38
XERCES_CPP_NAMESPACE::DOMNode * setTagAttribute(const std::string &tagName, const std::string &attrName, const std::string &attrValue, int _item=0)
Definition: XMLDOMBlock.cc:363
std::string created_by_user
Definition: XMLProcessor.h:122