File indexing completed on 2024-04-06 12:22:14
0001 #include "L1TriggerConfig/CSCTFConfigProducers/interface/CSCTFConfigOnlineProd.h"
0002 #include <cstdio>
0003 #include <string>
0004
0005 std::unique_ptr<L1MuCSCTFConfiguration> CSCTFConfigOnlineProd::newObject(const std::string& objectKey) {
0006 edm::LogInfo("L1-O2O: CSCTFConfigOnlineProd") << "Producing "
0007 << "L1MuCSCTFConfiguration "
0008 << "with key CSCTF_KEY=" << objectKey;
0009
0010 std::string csctfreg[12];
0011
0012
0013 for (int iSP = 1; iSP < 13; iSP++) {
0014 std::string spkey = objectKey + "00";
0015 if (iSP < 10)
0016 spkey += "0";
0017 spkey += std::to_string(iSP);
0018
0019
0020 std::vector<std::string> columns;
0021 columns.push_back("STATIC_CONFIG");
0022 columns.push_back("ETA_CONFIG");
0023 columns.push_back("FIRMWARE");
0024
0025
0026 l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0027 columns, "CMS_CSC_TF", "CSCTF_SP_CONF", "CSCTF_SP_CONF.SP_KEY", m_omdsReader.singleAttribute(spkey));
0028
0029 if (results.queryFailed())
0030 {
0031 edm::LogError("L1-O2O") << "Problem with L1CSCTFParameters key.";
0032
0033 return std::make_unique<L1MuCSCTFConfiguration>();
0034 }
0035
0036 std::string conf_stat, conf_eta, conf_firmware;
0037 results.fillVariable("STATIC_CONFIG", conf_stat);
0038 results.fillVariable("ETA_CONFIG", conf_eta);
0039 results.fillVariable("FIRMWARE", conf_firmware);
0040
0041 LogDebug("L1-O2O: CSCTFConfigOnlineProd:") << "conf_stat queried: " << conf_stat << "conf_eta queried:" << conf_eta
0042 << "conf_firmware queried:" << conf_firmware;
0043
0044 for (size_t pos = conf_stat.find("\\n"); pos != std::string::npos; pos = conf_stat.find("\\n", pos)) {
0045 conf_stat[pos] = ' ';
0046 conf_stat[pos + 1] = '\n';
0047 }
0048
0049 for (size_t pos = conf_eta.find("\\n"); pos != std::string::npos; pos = conf_eta.find("\\n", pos)) {
0050 conf_eta[pos] = ' ';
0051 conf_eta[pos + 1] = '\n';
0052 }
0053
0054 for (size_t pos = conf_firmware.find("\\n"); pos != std::string::npos; pos = conf_firmware.find("\\n", pos)) {
0055 conf_firmware[pos] = ' ';
0056 conf_firmware[pos + 1] = '\n';
0057 }
0058
0059 LogDebug("L1-O2O: CSCTFConfigOnlineProd") << "\nSP KEY: " << spkey << "\n\nSTATIC CONFIGURATION:\n"
0060 << conf_stat << "\nDAT_ETA CONFIGURATION:\n"
0061 << conf_eta << "\nFIRMWARE VERSIONS:\n"
0062 << conf_firmware;
0063
0064
0065
0066
0067
0068
0069
0070 std::string conf_firmware_sp;
0071
0072 std::stringstream conf(conf_firmware);
0073 while (!conf.eof()) {
0074 char buff[1024];
0075 conf.getline(buff, 1024);
0076 std::stringstream line(buff);
0077
0078 std::string register_ = "FIRMWARE";
0079 std::string chip_;
0080 line >> chip_;
0081 std::string muon_;
0082 line >> muon_;
0083 std::string writeValue_;
0084 line >> writeValue_;
0085
0086 size_t pos;
0087 pos = writeValue_.find('/');
0088
0089 std::string day;
0090 day.push_back(writeValue_[pos - 2]);
0091 day.push_back(writeValue_[pos - 1]);
0092
0093 std::string month;
0094 month.push_back(writeValue_[pos + 1]);
0095 month.push_back(writeValue_[pos + 2]);
0096
0097 std::string year("20");
0098 year.push_back(writeValue_[pos + 4]);
0099 year.push_back(writeValue_[pos + 5]);
0100
0101
0102
0103
0104
0105 std::string date = year + month + day;
0106
0107
0108
0109
0110
0111
0112
0113 if (chip_ == "SP")
0114 conf_firmware_sp += register_ + " " + chip_ + " " + muon_ + " " + date + "\n";
0115 }
0116
0117 edm::LogInfo("L1-O2O: CSCTFConfigOnlineProd") << "\nSP KEY: " << spkey << "\n\nSTATIC CONFIGURATION:\n"
0118 << conf_stat << "\nDAT_ETA CONFIGURATION:\n"
0119 << conf_eta << "\nFIRMWARE VERSIONS:\n"
0120 << conf_firmware_sp;
0121
0122 std::string conf_read = conf_eta + conf_stat + conf_firmware_sp;
0123
0124 csctfreg[iSP - 1] = conf_read;
0125 }
0126
0127
0128 return std::make_unique<L1MuCSCTFConfiguration>(csctfreg);
0129 }