22 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh" 26 #include <toolbox/string.h> 53 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
54 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
55 std::cout <<
"===> ERROR! Tag list is not available for V2 database."<<std::endl;
63 std::vector<std::string>
alltags;
88 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
89 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
128 std::vector<std::string>
alltags;
132 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
134 query +=
" cms_hcl_hcal_cond.hcal_channels ";
136 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
139 oracle::occi::Statement* stmt = conn.
getStatement(query);
148 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
165 query +=
" select iovs.interval_of_validity_begin as iov, ";
166 query +=
" min(iovs.record_insertion_time) time ";
167 query +=
" from cms_hcl_core_iov_mgmnt.cond_tags tags ";
168 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iov2tag_maps i2t ";
169 query +=
" on tags.cond_tag_id=i2t.cond_tag_id ";
170 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iovs iovs ";
171 query +=
" on i2t.cond_iov_record_id=iovs.cond_iov_record_id ";
173 query +=
" tags.tag_name=:1 ";
174 query +=
"group by iovs.interval_of_validity_begin ";
178 query +=
"order by time asc ";
181 oracle::occi::Statement* stmt = conn.
getStatement(query);
183 stmt->setString(1,tagname);
187 out.push_back(rs->getInt(1));
192 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
200 std::vector<uint32_t> omds, orcon,
out;
202 orcon.push_back(100);
219 if (getListOfNewIovs(out, omds, orcon) == -1){
220 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not possible" << std::endl;
222 else if (getListOfNewIovs(out, omds, orcon) == 0){
223 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not needed, the tag is up to date" << std::endl;
226 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is possible" << std::endl;
227 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): " << out.size() <<
" IOVs to be copied to ORCON" << std::endl;
230 std::ostream_iterator<uint32_t>(
std::cout,
"\n")
237 const std::vector<uint32_t> & omds_iovs,
238 const std::vector<uint32_t> & orcon_iovs){
243 int _orcon_index_offset = 0;
244 if (omds_iovs.size() > 0 &&
245 orcon_iovs.size() > 0 &&
246 orcon_iovs[0] == 1 &&
248 std::cout << std::endl <<
"HcalO2OManager: First IOV in the OMDS tag is not 1," << std::endl;
249 std::cout <<
"HcalO2OManager: while it must be 1 in the offline tag." << std::endl;
250 std::cout <<
"HcalO2OManager: O2O will assume that IOV=1 in the offline tag" << std::endl;
251 std::cout <<
"HcalO2OManager: is filled with some safe default." << std::endl;
252 std::cout <<
"HcalO2OManager: IOV=1 will be ignored, and O2O will proceeed" << std::endl;
253 std::cout <<
"HcalO2OManager: as long as other inconsistencies are not detected." << std::endl << std::endl;
254 _orcon_index_offset = 1;
257 if (omds_iovs.size()+_orcon_index_offset < orcon_iovs.size()){
258 std::cout <<
"HcalO2OManager: too many IOVs in the Pool tag, cannot sync, exiting..." << std::endl;
263 unsigned int _index = 0;
265 bool enforce_strict_matching =
false;
267 for (std::vector<uint32_t>::const_iterator _iov = orcon_iovs.begin();
268 _iov != orcon_iovs.end();
270 _index = (
int)(_iov - orcon_iovs.begin());
279 if (_orcon_index_offset == 1 && _index == 0)
continue;
292 if (omds_iovs[_index-_orcon_index_offset] != orcon_iovs[_index]){
295 std::cout <<
"HcalO2OManager: existing IOVs do not match, cannot sync in the strict sense." << std::endl;
296 std::cout <<
"HcalO2OManager: mismatched pair is (OMDS/offline): " << omds_iovs[_index-_orcon_index_offset] <<
"/" << orcon_iovs[_index] << std::endl;
297 std::cout <<
"HcalO2OManager: In the strict sense, the SYNCHRONIZATION OF THIS TAG HAS FAILED!" << std::endl;
298 std::cout <<
"HcalO2OManager: As an interim solution, I will still copy to the offline tag" << std::endl;
299 std::cout <<
"HcalO2OManager: those IOV from the OMDS tag that are newer than the last IOV" << std::endl;
300 std::cout <<
"HcalO2OManager: currently in the offline tag. " << std::endl;
304 if (enforce_strict_matching){
321 uint32_t _lastOrconIov = orcon_iovs[orcon_iovs.size()-1];
323 for (;_index < omds_iovs.size();++_index){
325 uint32_t _aIov = omds_iovs[_index];
327 if (_index == 0 && _aIov > _lastOrconIov){
328 iovs.push_back(_aIov);
331 else if (omds_iovs[_index]>omds_iovs[_index-1] &&
332 _aIov > _lastOrconIov){
333 iovs.push_back(omds_iovs[_index]);
337 if (enforce_strict_matching){
363 std::vector<uint32_t> omds_iovs;
364 std::vector<uint32_t> pool_iovs;
365 getListOfOmdsIovs(omds_iovs, _tag);
366 getListOfPoolIovs(pool_iovs, _tag, pool_connect_string, pool_auth_path);
367 int n_iovs = getListOfNewIovs(_iovs,
371 std::cout <<
"HcalO2OManager: O2O is not possible" << std::endl;
373 else if (n_iovs == 0){
374 std::cout <<
"HcalO2OManager: O2O is not needed, the tag is up to date" << std::endl;
377 edm::LogInfo(
"HcalO2OManager") <<
"These IOVs are to be updated:" << std::endl;
378 for (std::vector<uint32_t>::const_iterator iov = _iovs.begin();
381 std::cout <<
"O2O_IOV_LIST: " << *iov << std::endl;
static PluginManager & configure(const Config &)
virtual ~HcalO2OManager()
oracle::occi::Statement * getStatement(const std::string &query)
oracle::occi::SQLException SQLException
int getListOfNewIovs(std::vector< uint32_t > &iovs, const std::vector< uint32_t > &omds_iovs, const std::vector< uint32_t > &orcon_iovs)
PluginManager::Config config()
int getListOfUpdateIovs(std::vector< uint32_t > &_iovs, std::string _tag, std::string pool_connect_string, std::string pool_auth_path)
oracle::occi::ResultSet ResultSet
std::vector< std::string > getListOfOmdsTags()
int getListOfPoolIovs(std::vector< uint32_t > &out, std::string tagname, std::string connect, std::string auth_path)
int getListOfOmdsIovs(std::vector< uint32_t > &out, std::string tagname)
std::vector< std::string > getListOfPoolTags(std::string connect, std::string auth_path)
void getListOfNewIovs_test(void)