11 #include <toolbox/string.h>
20 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh"
21 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplOracle.hh"
22 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplXMLFile.hh"
23 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationItemNotFoundException.hh"
52 if (
i != std::string::npos) {
53 database =
new ConfigurationDatabaseImplOracle();
54 database->connect(accessor);
56 database =
new ConfigurationDatabaseImplXMLFile();
57 database->connect(accessor);
64 accessor2 = _accessor2;
67 if (
i != std::string::npos) {
68 database2 =
new ConfigurationDatabaseImplOracle();
69 database2->connect(accessor2);
71 database2 =
new ConfigurationDatabaseImplXMLFile();
72 database2->connect(accessor2);
77 if (database !=
nullptr)
78 database->disconnect();
79 if (database2 !=
nullptr)
80 database2->disconnect();
84 std::string tag,
int crate,
int slot,
int topbottom,
int fiber,
int channel,
int luttype) {
87 std::vector<unsigned int>
result;
89 hcal::ConfigurationDatabase::FPGASelection _fpga;
91 _fpga = hcal::ConfigurationDatabase::Bottom;
92 else if (topbottom == 1)
95 std::cout <<
"topbottom out of range" << std::endl;
99 hcal::ConfigurationDatabase::LUTType _lt;
101 _lt = hcal::ConfigurationDatabase::LinearizerLUT;
102 else if (luttype == 2)
103 _lt = hcal::ConfigurationDatabase::CompressionLUT;
105 std::cout <<
"LUT type out of range" << std::endl;
109 hcal::ConfigurationDatabase::LUTId _lutid(crate, slot, _fpga, fiber, channel, _lt);
110 std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT> testLUTs;
115 database->getLUTs(
tag, crate, slot, testLUTs);
116 }
catch (hcal::exception::ConfigurationItemNotFoundException&
e) {
117 std::cout <<
"Found nothing!" << std::endl;
119 std::cout <<
"Exception: " << e2.what() << std::endl;
122 result = testLUTs[_lutid];
131 hcal::ConfigurationDatabase::LUTType _lt) {
132 std::vector<unsigned int>
result;
135 double _condition_data_set_id;
136 unsigned int _crate, _slot, _fiber, _channel;
137 hcal::ConfigurationDatabase::FPGASelection _fpga;
139 int side = _id.
zside();
153 oracle::occi::Connection* _connection = database->getConnection();
156 Statement* stmt = _connection->createStatement();
157 std::string query = (
"SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
158 query +=
" FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
167 ResultSet* rs = stmt->executeQuery(
query);
169 _condition_data_set_id = 0.0;
172 double _cdsi = rs->getDouble(1);
173 if (_condition_data_set_id < _cdsi) {
174 _condition_data_set_id = _cdsi;
175 _crate = rs->getInt(2);
176 _slot = rs->getInt(3);
181 _fpga = hcal::ConfigurationDatabase::Bottom;
182 _fiber = rs->getInt(5);
183 _channel = rs->getInt(6);
185 int topbottom, luttype;
190 if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
195 result = getOnlineLUT(
tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
199 _connection->terminateStatement(stmt);
200 }
catch (SQLException&
e) {
201 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
209 hcal::ConfigurationDatabase::LUTType _lt) {
210 std::vector<unsigned int>
result;
212 if (database && database2) {
215 double _condition_data_set_id;
216 unsigned int _crate, _slot, _fiber, _channel;
217 hcal::ConfigurationDatabase::FPGASelection _fpga;
219 int side = _id.
zside();
233 oracle::occi::Connection* _connection = database2->getConnection();
236 Statement* stmt = _connection->createStatement();
237 std::string query = (
"SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
238 query +=
" FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
247 ResultSet* rs = stmt->executeQuery(
query);
249 _condition_data_set_id = 0.0;
252 double _cdsi = rs->getDouble(1);
253 if (_condition_data_set_id < _cdsi) {
254 _condition_data_set_id = _cdsi;
255 _crate = rs->getInt(2);
256 _slot = rs->getInt(3);
261 _fpga = hcal::ConfigurationDatabase::Bottom;
262 _fiber = rs->getInt(5);
263 _channel = rs->getInt(6);
266 int topbottom, luttype;
271 if (_lt == hcal::ConfigurationDatabase::LinearizerLUT)
275 result = getOnlineLUT(
tag, _crate, _slot, topbottom, _fiber, _channel, luttype);
279 _connection->terminateStatement(stmt);
281 }
catch (SQLException&
e) {
282 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
286 std::cout <<
"Either the XML file with LUTs or the database with LMap are not defined" << std::endl;
298 oracle::occi::Clob clob = _clob;
299 Stream* instream = clob.getStream(1, 0);
300 unsigned int size = clob.length();
301 char* cbuffer =
new char[
size];
302 memset(cbuffer, 0,
size);
303 instream->readBuffer(cbuffer,
size);