File indexing completed on 2024-04-06 12:00:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "CaloOnlineTools/HcalOnlineDb/interface/XMLLUTLoader.h"
0017 #include "CalibCalorimetry/HcalTPGAlgos/interface/XMLProcessor.h"
0018 #include <cstdio>
0019 XERCES_CPP_NAMESPACE_USE
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 XMLLUTLoader::lutDBConfig::_lutDBConfig() : XMLProcessor::DBConfig() {
0033 kind_of_part = "HCAL HTR Crate";
0034 name_label = "CRATE17";
0035 trig_prim_lookuptbl_data_file = "testLUT_17.xml";
0036 crate = 17;
0037 }
0038
0039 XMLLUTLoader::checksumsDBConfig::_checksumsDBConfig() : XMLProcessor::DBConfig() {
0040 comment_description = "checksum for all crates version test:2";
0041 name_label = "CMS-HCAL-ROOT";
0042 trig_prim_lookuptbl_data_file = "./testLUT_checksums.xml";
0043 crate = -1;
0044 }
0045
0046 XMLLUTLoader::XMLLUTLoader() {}
0047
0048 XMLLUTLoader::XMLLUTLoader(XMLProcessor::loaderBaseConfig* config, std::string templateBase)
0049 : XMLDOMBlock(templateBase) {
0050 setTagValue("EXTENSION_TABLE_NAME", config->extention_table_name);
0051 setTagValue("NAME", config->name);
0052 setTagAttribute("RUN", "mode", config->run_mode);
0053 setTagAttribute("DATA_SET", "id", config->data_set_id);
0054 setTagAttribute("IOV", "id", config->iov_id);
0055 setTagValue("INTERVAL_OF_VALIDITY_BEGIN", config->iov_begin);
0056 setTagValue("INTERVAL_OF_VALIDITY_END", config->iov_end);
0057 setTagAttribute("TAG", "id", config->tag_id);
0058 setTagAttribute("TAG", "mode", config->tag_mode);
0059 setTagValue("TAG_NAME", config->tag_name);
0060 setTagValue("DETECTOR_NAME", config->detector_name);
0061 setTagValue("COMMENT_DESCRIPTION", config->comment_description);
0062
0063 setTagAttribute("TAG", "idref", config->tag_id, 1);
0064 setTagAttribute("IOV", "idref", config->iov_id, 1);
0065 setTagAttribute("DATA_SET", "idref", config->data_set_id, 1);
0066 }
0067
0068
0069
0070
0071
0072
0073 XMLLUTLoader::~XMLLUTLoader() {}
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 int XMLLUTLoader::addLUT(lutDBConfig* config, std::string templateFileName) {
0091 DOMElement* root = document->getDocumentElement();
0092
0093 XMLDOMBlock dataSetDoc(templateFileName);
0094 DOMDocument* dataSet = dataSetDoc.getDocument();
0095
0096
0097 setTagValue("VERSION", config->version, 0, dataSet);
0098 setTagValue("SUBVERSION", config->subversion, 0, dataSet);
0099 char timebuf[50];
0100
0101 strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime(&(config->create_timestamp)));
0102 setTagValue("CREATE_TIMESTAMP", timebuf, 0, dataSet);
0103 setTagValue("CREATED_BY_USER", config->created_by_user, 0, dataSet);
0104 setTagValue("KIND_OF_PART", config->kind_of_part, 0, dataSet);
0105 setTagValue("NAME_LABEL", config->name_label, 0, dataSet);
0106 setTagValue("TRIG_PRIM_LOOKUPTBL_DATA_FILE", config->trig_prim_lookuptbl_data_file, 0, dataSet);
0107 setTagValue("CRATE", config->crate, 0, dataSet);
0108
0109
0110 DOMNode* cloneDataSet = document->importNode(dataSet->getDocumentElement(), true);
0111 root->appendChild(cloneDataSet);
0112
0113 return 0;
0114 }
0115
0116 int XMLLUTLoader::addChecksums(checksumsDBConfig* config, std::string templateFileName) {
0117 DOMElement* root = document->getDocumentElement();
0118
0119 XMLDOMBlock dataSetDoc(templateFileName);
0120 DOMDocument* dataSet = dataSetDoc.getDocument();
0121
0122
0123 setTagValue("VERSION", config->version, 0, dataSet);
0124 setTagValue("SUBVERSION", config->subversion, 0, dataSet);
0125 char timebuf[50];
0126
0127 strftime(timebuf, 50, "%Y-%m-%d %H:%M:%S.0", gmtime(&(config->create_timestamp)));
0128 setTagValue("CREATE_TIMESTAMP", timebuf, 0, dataSet);
0129 setTagValue("CREATED_BY_USER", config->created_by_user, 0, dataSet);
0130 setTagValue("COMMENT_DESCRIPTION", config->comment_description, 0, dataSet);
0131 setTagValue("NAME_LABEL", config->name_label, 0, dataSet);
0132 setTagValue("TRIG_PRIM_LOOKUPTBL_DATA_FILE", config->trig_prim_lookuptbl_data_file, 0, dataSet);
0133 setTagValue("CRATE", config->crate, 0, dataSet);
0134
0135
0136 DOMNode* cloneDataSet = document->importNode(dataSet->getDocumentElement(), true);
0137 root->appendChild(cloneDataSet);
0138
0139 return 0;
0140 }
0141
0142 int XMLLUTLoader::createLoader(const std::vector<int>& crate_number, const std::vector<std::string>& file_name) {
0143 XMLLUTLoader::lutDBConfig conf;
0144 XMLLUTLoader::checksumsDBConfig CSconf;
0145
0146 for (std::vector<std::string>::const_iterator _file = file_name.begin(); _file != file_name.end(); _file++) {
0147 conf.trig_prim_lookuptbl_data_file = *_file;
0148 conf.trig_prim_lookuptbl_data_file += ".dat";
0149 conf.crate = crate_number[_file - file_name.begin()];
0150
0151 char _buf[128];
0152 sprintf(_buf, "CRATE%.2d", conf.crate);
0153 std::string _namelabel;
0154 _namelabel.append(_buf);
0155 conf.name_label = _namelabel;
0156 addLUT(&conf);
0157 }
0158
0159 CSconf.trig_prim_lookuptbl_data_file += ".dat";
0160 addChecksums(&CSconf);
0161 write("LUTLoader.xml");
0162
0163 return 0;
0164 }
0165
0166
0167
0168
0169
0170
0171
0172