21 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
22 #include "xgi/Utils.h"
23 #include "toolbox/string.h"
27 using namespace oracle::occi;
33 comment =
"Comment has not been entered";
57 extension_table_name=
"HCAL_CHANNEL_QUALITY_V1";
58 type_name=
"HCAL Channel Quality [V1]";
60 channel_map =
"HCAL_CHANNELS";
67 tag_name =
"test_channel_quality_tag_name";
68 detector_name =
"HCAL";
69 comment = hcal_ass.getRandomQuote();
89 DOMElement * _data_elem = get_data_element(_dataset);
99 int _channel_status,
int _on_off, std::string _comment ){
100 DOMNode * _dataset = add_dataset();
101 add_hcal_channel(_dataset, ieta, iphi, depth, subdetector);
102 add_data(_dataset, _channel_status, _on_off, _comment);
110 std::string _subdetector =
"";
112 std::string _comment = get_random_comment();
132 0, _onoff, _comment );
146 std::string _subdetector =
"";
147 uint32_t _status = 0;
149 std::string _comment = get_random_comment();
170 _status, _onoff, _comment );
178 return hcal_ass.getRandomQuote();
189 std::string
query =
"select ";
191 query +=
" sp.subdet as subdetector ";
192 query +=
" ,sp.ieta as IETA ";
193 query +=
" ,sp.iphi as IPHI ";
194 query +=
" ,sp.depth as DEPTH ";
195 query +=
" ,sp.channel_status_word as STATUS_WORD ";
196 query +=
" ,sp.channel_on_off_state as ON_OFF ";
197 query +=
" ,sp.commentdescription ";
203 query +=
" select MAX(cq.record_id) as record_id ";
204 query +=
" ,MAX(cq.interval_of_validity_begin) as iov_begin ";
205 query +=
" ,cq.channel_map_id ";
207 query +=
" cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
209 query +=
" tag_name=:1 ";
211 query +=
" cq.interval_of_validity_begin<=:2";
212 query +=
" group by ";
213 query +=
" cq.channel_map_id ";
214 query +=
" order by ";
215 query +=
" cq.channel_map_id ";
217 query +=
"inner join ";
218 query +=
" cms_hcl_hcal_cond.v_hcal_channel_quality sp ";
220 query +=
" fp.record_id=sp.record_id ";
223 oracle::occi::Statement* stmt = conn.
getStatement(query);
224 stmt->setString(1,_tag);
225 stmt->setInt(2,_iov_begin);
231 int _geomId = hAss.getGeomId(hAss.getSubdetector(rs->getString(1)),
237 _cq.
status = rs->getInt(5);
238 _cq.
onoff = rs->getInt(6);
239 _cq.
comment = rs->getString(7);
240 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId, _cq));
245 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
255 for (std::map<int,ChannelQuality>::const_iterator _chan=_cq.begin();
259 add_hcal_channel_dataset( hAss.getHcalIeta(_chan->first),
260 hAss.getHcalIphi(_chan->first),
261 hAss.getHcalDepth(_chan->first),
262 hAss.getSubdetectorString(hAss.getHcalSubdetector(_chan->first)),
263 _chan->second.status,
265 _chan->second.comment
274 int _channel_status,
int _on_off, std::string _comment ){
275 int _geomId = hAss.getGeomId(hAss.getSubdetector(subdetector),
280 _cq.
status = _channel_status;
283 if (geomid_cq.find(_geomId)==geomid_cq.end()){
284 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId,_cq));
287 geomid_cq[_geomId]=_cq;
299 _cq.
comment =
"filled from an ASCII stream";
301 while ( getline( std::cin, _row ) > 0 ){
303 int _eta, _phi, _dep, _value;
306 if ( base.find(
"hex")!=std::string::npos ){
307 const char * _format =
"%d %d %d %s %X";
308 _read = sscanf( _row . c_str(), _format,
309 &_eta, &_phi, &_dep, _det, &_value
312 else if ( base.find(
"dec")!=std::string::npos ){
313 const char * _format =
"%d %d %d %s %d";
314 _read = sscanf( _row . c_str(), _format,
315 &_eta, &_phi, &_dep, _det, &_value
319 std::cerr <<
"Undefined or invalid base. Specify hex or dec. Exiting..." << std::endl;
325 int _geomId = hAss.getGeomId(hAss.getSubdetector(std::string(_det))
328 _cq.
onoff = (_value & 65536)>>15;
329 geomid_cq.insert(std::pair<int, HcalChannelQualityXml::ChannelQuality>(_geomId, _cq));
341 sprintf(_buf,
"# eta phi dep det value DetId");
343 for (std::map<int,ChannelQuality>::const_iterator _cq = geomid_cq.begin();
344 _cq != geomid_cq.end();
347 _detId = hAss.getRawIdFromCmssw(_cq->first);
348 if ( base.find(
"hex")!=std::string::npos ){
349 sprintf(_buf,
" %16d%16d%16d%16s%16.8X%11.8X",
350 hAss.getHcalIeta(_cq->first),
351 hAss.getHcalIphi(_cq->first),
352 hAss.getHcalDepth(_cq->first),
353 hAss.getSubdetectorString(hAss.getHcalSubdetector(_cq->first)).c_str(),
358 else if ( base.find(
"dec")!=std::string::npos ){
359 sprintf(_buf,
" %16d%16d%16d%16s%16d%11.8d",
360 hAss.getHcalIeta(_cq->first),
361 hAss.getHcalIphi(_cq->first),
362 hAss.getHcalDepth(_cq->first),
363 hAss.getSubdetectorString(hAss.getHcalSubdetector(_cq->first)).c_str(),
369 std::cerr <<
"Undefined or invalid base. Specify hex or dec. Exiting..." << std::endl;
382 std::string _elements_comment,
386 readStatusWordFromStdin(_base);
387 set_header_run_number(_runnumber);
388 set_elements_iov_begin(_iov_begin);
389 set_elements_iov_end(_iov_end);
390 set_elements_tag_name(_tag);
391 set_elements_comment(_elements_comment);
392 addChannelQualityGeom(geomid_cq);
399 getBaseLineFromOmds(_tag, _iov_begin);
400 writeStatusWordToStdout(base);
410 std::vector<std::string> _tags = getTagsFromOmds();
411 for (std::vector<std::string>::const_iterator
tag=_tags.begin();
tag!=_tags.end();
tag++){
421 std::vector<std::string> _tags;
424 std::string
query =
"select distinct tag_name, min(record_id) as mrid ";
426 query +=
"cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
427 query +=
"group by tag_name ";
428 query +=
"order by mrid desc ";
431 oracle::occi::Statement* stmt = conn.
getStatement(query);
435 _tags.push_back( rs->getString(1) );
440 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
452 std::vector<int> _iovs = getIovsFromOmds(tag);
453 for (std::vector<int>::const_iterator tag=_iovs.begin(); tag!=_iovs.end(); tag++){
463 std::vector<int> _iovs;
466 std::string
query =
"select distinct cq.interval_of_validity_begin, min(record_id) as mrid ";
468 query +=
"cms_hcl_hcal_cond.v_hcal_channel_quality cq ";
470 query +=
"tag_name=:1 ";
471 query +=
"group by cq.interval_of_validity_begin ";
472 query +=
"order by mrid desc ";
475 oracle::occi::Statement* stmt = conn.
getStatement(query);
476 stmt->setString(1,tag);
480 _iovs.push_back( rs->getInt(1) );
485 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)
std::string toString(const std::pair< T, T > &aT)
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)