20 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
24 #include <toolbox/string.h>
30 using namespace oracle::occi;
36 comment =
"Comment has not been entered";
60 extension_table_name=
"HCAL_CHANNEL_QUALITY_V1";
61 type_name=
"HCAL Channel Quality [V1]";
63 channel_map =
"HCAL_CHANNELS";
70 tag_name =
"test_channel_quality_tag_name";
71 detector_name =
"HCAL";
72 comment = hcal_ass.getRandomQuote();
92 DOMElement * _data_elem = get_data_element(_dataset);
102 int _channel_status,
int _on_off,
std::string _comment ){
103 DOMNode * _dataset = add_dataset();
104 add_hcal_channel(_dataset, ieta, iphi, depth, subdetector);
105 add_data(_dataset, _channel_status, _on_off, _comment);
135 0, _onoff, _comment );
150 uint32_t _status = 0;
173 _status, _onoff, _comment );
181 return hcal_ass.getRandomQuote();
194 query +=
" sp.subdet as subdetector ";
195 query +=
" ,sp.ieta as IETA ";
196 query +=
" ,sp.iphi as IPHI ";
197 query +=
" ,sp.depth as DEPTH ";
198 query +=
" ,sp.channel_status_word as STATUS_WORD ";
199 query +=
" ,sp.channel_on_off_state as ON_OFF ";
200 query +=
" ,sp.commentdescription ";
206 query +=
" select MAX(cq.record_id) as record_id ";
207 query +=
" ,MAX(cq.interval_of_validity_begin) as iov_begin ";
208 query +=
" ,cq.channel_map_id ";
210 query +=
" cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
212 query +=
" tag_name=:1 ";
214 query +=
" cq.interval_of_validity_begin<=:2";
215 query +=
" group by ";
216 query +=
" cq.channel_map_id ";
217 query +=
" order by ";
218 query +=
" cq.channel_map_id ";
220 query +=
"inner join ";
221 query +=
" cms_hcl_hcal_cond.v_hcal_channel_quality sp ";
223 query +=
" fp.record_id=sp.record_id ";
226 oracle::occi::Statement* stmt = conn.
getStatement(query);
227 stmt->setString(1,_tag);
228 stmt->setInt(2,_iov_begin);
234 int _geomId = hAss.getGeomId(hAss.getSubdetector(rs->getString(1)),
240 _cq.
status = rs->getInt(5);
241 _cq.
onoff = rs->getInt(6);
242 _cq.
comment = rs->getString(7);
243 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId, _cq));
248 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
258 for (std::map<int,ChannelQuality>::const_iterator _chan=_cq.begin();
262 add_hcal_channel_dataset( hAss.getHcalIeta(_chan->first),
263 hAss.getHcalIphi(_chan->first),
264 hAss.getHcalDepth(_chan->first),
265 hAss.getSubdetectorString(hAss.getHcalSubdetector(_chan->first)),
266 _chan->second.status,
268 _chan->second.comment
277 int _channel_status,
int _on_off,
std::string _comment ){
278 int _geomId = hAss.getGeomId(hAss.getSubdetector(subdetector),
283 _cq.
status = _channel_status;
286 if (geomid_cq.find(_geomId)==geomid_cq.end()){
287 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId,_cq));
290 geomid_cq[_geomId]=_cq;
302 _cq.
comment =
"filled from an ASCII stream";
304 while ( getline( std::cin, _row ) > 0 ){
306 int _eta, _phi, _dep, _value;
309 if ( base.find(
"hex")!=std::string::npos ){
310 const char * _format =
"%d %d %d %s %X";
311 _read = sscanf( _row . c_str(), _format,
312 &_eta, &_phi, &_dep, _det, &_value
315 else if ( base.find(
"dec")!=std::string::npos ){
316 const char * _format =
"%d %d %d %s %d";
317 _read = sscanf( _row . c_str(), _format,
318 &_eta, &_phi, &_dep, _det, &_value
322 std::cerr <<
"Undefined or invalid base. Specify hex or dec. Exiting..." << std::endl;
328 int _geomId = hAss.getGeomId(hAss.getSubdetector(
std::string(_det))
331 _cq.
onoff = (_value & 65536)>>15;
332 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId, _cq));
344 sprintf(_buf,
"# eta phi dep det value DetId");
346 for (std::map<int,ChannelQuality>::const_iterator _cq = geomid_cq.begin();
347 _cq != geomid_cq.end();
350 _detId = hAss.getRawIdFromCmssw(_cq->first);
351 if ( base.find(
"hex")!=std::string::npos ){
352 sprintf(_buf,
" %16d%16d%16d%16s%16.8X%11.8X",
353 hAss.getHcalIeta(_cq->first),
354 hAss.getHcalIphi(_cq->first),
355 hAss.getHcalDepth(_cq->first),
356 hAss.getSubdetectorString(hAss.getHcalSubdetector(_cq->first)).c_str(),
361 else if ( base.find(
"dec")!=std::string::npos ){
362 sprintf(_buf,
" %16d%16d%16d%16s%16d%11.8d",
363 hAss.getHcalIeta(_cq->first),
364 hAss.getHcalIphi(_cq->first),
365 hAss.getHcalDepth(_cq->first),
366 hAss.getSubdetectorString(hAss.getHcalSubdetector(_cq->first)).c_str(),
372 std::cerr <<
"Undefined or invalid base. Specify hex or dec. Exiting..." << std::endl;
389 readStatusWordFromStdin(_base);
390 set_header_run_number(_runnumber);
391 set_elements_iov_begin(_iov_begin);
392 set_elements_iov_end(_iov_end);
393 set_elements_tag_name(_tag);
394 set_elements_comment(_elements_comment);
395 addChannelQualityGeom(geomid_cq);
402 getBaseLineFromOmds(_tag, _iov_begin);
403 writeStatusWordToStdout(base);
413 std::vector<std::string> _tags = getTagsFromOmds();
414 for (std::vector<std::string>::const_iterator
tag=_tags.begin();
tag!=_tags.end();
tag++){
424 std::vector<std::string> _tags;
429 query +=
"cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
430 query +=
"group by tag_name ";
431 query +=
"order by mrid desc ";
434 oracle::occi::Statement* stmt = conn.
getStatement(query);
438 _tags.push_back( rs->getString(1) );
443 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
455 std::vector<int> _iovs = getIovsFromOmds(tag);
456 for (std::vector<int>::const_iterator tag=_iovs.begin(); tag!=_iovs.end(); tag++){
466 std::vector<int> _iovs;
469 std::string query =
"select distinct cq.interval_of_validity_begin, min(record_id) as mrid ";
471 query +=
"cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
473 query +=
"tag_name=:1 ";
474 query +=
"group by cq.interval_of_validity_begin ";
475 query +=
"order by mrid desc ";
478 oracle::occi::Statement* stmt = conn.
getStatement(query);
479 stmt->setString(1,tag);
483 _iovs.push_back( rs->getInt(1) );
488 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
int initHBEFListFromLmapAscii(void)
int makeXmlFromAsciiStream(int _runnumber, int _iov_begin, int _iov_end, std::string _tag, std::string _elements_comment, std::string _base="hex")
std::string get_random_comment(void)
int set_all_channels_status(uint32_t _hb, uint32_t _he, uint32_t _hf, uint32_t _ho)
oracle::occi::Statement * getStatement(const std::string &query)
oracle::occi::SQLException SQLException
std::vector< std::string > getTagsFromOmds(void)
int writeBaseLineFromOmdsToStdout(std::string _tag, int _iov_begin, std::string base="hex")
DOMNode * add_hcal_channel_dataset(int ieta, int iphi, int depth, std::string subdetector, int _channel_status, int _on_off, std::string _comment)
virtual ~HcalChannelQualityXml()
int dumpIovsFromOmdsToStdout(std::string tag)
std::vector< int > getIovsFromOmds(std::string tag)
int addChannelToGeomIdMap(int ieta, int iphi, int depth, std::string subdetector, int _channel_status, int _on_off, std::string _comment)
DOMElement * add_data(DOMNode *_dataset, int _channel_status, int _on_off, std::string _comment)
int readStatusWordFromStdin(std::string base="hex")
int set_all_channels_on_off(int _hb, int _he, int _hf, int _ho)
oracle::occi::ResultSet ResultSet
static XMLCh * _toXMLCh(std::string temp)
int getBaseLineFromOmds(std::string _tag, int _iov_begin)
int dumpTagsFromOmdsToStdout(void)
int writeStatusWordToStdout(std::string base="hex")
HcalSubdetector getHcalSubdetector(void)
int addChannelQualityGeom(std::map< int, ChannelQuality > &_cq)