11 #include <toolbox/string.h> 21 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh" 22 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplOracle.hh" 23 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplXMLFile.hh" 24 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationItemNotFoundException.hh" 63 if ( i!=std::string::npos )
65 database =
new ConfigurationDatabaseImplOracle();
66 database ->
connect( accessor );
70 database =
new ConfigurationDatabaseImplXMLFile();
71 database ->
connect( accessor );
82 accessor2 = _accessor2;
85 if ( i!=std::string::npos )
87 database2 =
new ConfigurationDatabaseImplOracle();
88 database2 ->
connect( accessor2 );
92 database2 =
new ConfigurationDatabaseImplXMLFile();
93 database2 ->
connect( accessor2 );
102 if ( database !=
NULL ) database -> disconnect();
103 if ( database2 !=
NULL ) database2 -> disconnect();
113 std::vector<unsigned int>
result;
115 hcal::ConfigurationDatabase::FPGASelection _fpga;
116 if ( topbottom == 0 ) _fpga = hcal::ConfigurationDatabase::Bottom;
120 std::cout <<
"topbottom out of range" << std::endl;
124 hcal::ConfigurationDatabase::LUTType _lt;
125 if ( luttype == 1 ) _lt = hcal::ConfigurationDatabase::LinearizerLUT;
126 else if ( luttype == 2 ) _lt = hcal::ConfigurationDatabase::CompressionLUT;
129 std::cout <<
"LUT type out of range" << std::endl;
133 hcal::ConfigurationDatabase::LUTId _lutid( crate, slot, _fpga, fiber, channel, _lt );
134 std::map<hcal::ConfigurationDatabase::LUTId, hcal::ConfigurationDatabase::LUT> testLUTs;
139 database -> getLUTs(tag, crate, slot, testLUTs);
140 }
catch (hcal::exception::ConfigurationItemNotFoundException&
e) {
141 std::cout <<
"Found nothing!" << std::endl;
143 std::cout <<
"Exception: " << e2.what() << std::endl;
146 result = testLUTs[_lutid];
155 std::vector<unsigned int>
result;
158 double _condition_data_set_id;
159 unsigned int _crate, _slot, _fiber, _channel;
160 hcal::ConfigurationDatabase::FPGASelection _fpga;
162 int side = _id .
zside();
163 int etaAbs = _id . ietaAbs();
164 int phi = _id . iphi();
167 if ( _id . subdet() ==
HcalBarrel) subdetector =
"HB";
168 else if ( _id . subdet() ==
HcalEndcap) subdetector =
"HE";
169 else if ( _id . subdet() ==
HcalOuter) subdetector =
"HO";
170 else if ( _id . subdet() ==
HcalForward) subdetector =
"HF";
172 oracle::occi::Connection * _connection = database -> getConnection();
175 Statement* stmt = _connection -> createStatement();
176 std::string query = (
"SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
177 query +=
" FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
178 query +=
toolbox::toString(
" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'", side, etaAbs, phi, depth, subdetector . c_str() );
181 ResultSet *rs = stmt->executeQuery(query.c_str());
183 _condition_data_set_id = 0.0;
186 double _cdsi = rs -> getDouble(1);
187 if ( _condition_data_set_id < _cdsi )
189 _condition_data_set_id = _cdsi;
194 else _fpga = hcal::ConfigurationDatabase::Bottom;
196 _channel = rs ->
getInt(6);
198 int topbottom, luttype;
201 if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
204 result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
208 _connection -> terminateStatement(stmt);
209 }
catch (SQLException&
e) {
210 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
218 std::vector<unsigned int>
result;
220 if ( database && database2 ){
224 double _condition_data_set_id;
225 unsigned int _crate, _slot, _fiber, _channel;
226 hcal::ConfigurationDatabase::FPGASelection _fpga;
228 int side = _id .
zside();
229 int etaAbs = _id . ietaAbs();
230 int phi = _id . iphi();
233 if ( _id . subdet() ==
HcalBarrel) subdetector =
"HB";
234 else if ( _id . subdet() ==
HcalEndcap) subdetector =
"HE";
235 else if ( _id . subdet() ==
HcalOuter) subdetector =
"HO";
236 else if ( _id . subdet() ==
HcalForward) subdetector =
"HF";
238 oracle::occi::Connection * _connection = database2 -> getConnection();
241 Statement* stmt = _connection -> createStatement();
242 std::string query = (
"SELECT RECORD_ID, CRATE, HTR_SLOT, HTR_FPGA, HTR_FIBER, FIBER_CHANNEL ");
243 query +=
" FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 ";
244 query +=
toolbox::toString(
" WHERE SIDE=%d AND ETA=%d AND PHI=%d AND DEPTH=%d AND SUBDETECTOR='%s'", side, etaAbs, phi, depth, subdetector . c_str() );
247 ResultSet *rs = stmt->executeQuery(query.c_str());
249 _condition_data_set_id = 0.0;
252 double _cdsi = rs -> getDouble(1);
253 if ( _condition_data_set_id < _cdsi )
255 _condition_data_set_id = _cdsi;
260 else _fpga = hcal::ConfigurationDatabase::Bottom;
262 _channel = rs ->
getInt(6);
265 int topbottom, luttype;
268 if ( _lt == hcal::ConfigurationDatabase::LinearizerLUT ) luttype = 1;
270 result = getOnlineLUT( tag, _crate, _slot, topbottom, _fiber, _channel, luttype );
274 _connection -> terminateStatement(stmt);
276 }
catch (SQLException&
e) {
277 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
281 std::cout <<
"Either the XML file with LUTs or the database with LMap are not defined" << std::endl;
289 return database -> getConnection();
293 return database -> getEnvironment();
300 oracle::occi::Clob clob = _clob;
301 Stream *instream = clob.getStream (1,0);
302 unsigned int size = clob.length();
303 char *cbuffer =
new char[
size];
304 memset (cbuffer, 0, size);
305 instream->readBuffer (cbuffer, size);
int getInt(ResultSet *rset, int ipar)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static const std::string Top
oracle::occi::Environment * getEnvironment(void)
oracle::occi::Connection * getConnection(void)
std::vector< unsigned int > getOnlineLUT(std::string tag, int crate, int slot, int topbottom, int fiber, int channel, int luttype)
void connect(std::string _accessor)
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
void setAccessor(std::string _accessor)
std::vector< unsigned int > getOnlineLUTFromXML(std::string tag, uint32_t _rawid, hcal::ConfigurationDatabase::LUTType _lt=hcal::ConfigurationDatabase::LinearizerLUT)
std::string clobToString(const oracle::occi::Clob &)
static XMLProcessor * getInstance()