41 openConnection_(
false) {
44 <<
" Constructing database service..." 45 <<
" (Class instance: " <<
count <<
")";
61 <<
" Destructing object...";
100 <<
" Opening connection to database...";
105 <<
" Connection already open!";
121 std::stringstream
ss;
122 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 123 <<
" Database connection parameters: " << std::endl
131 <<
" Opened connection to database!";
138 <<
" Closing connection to database...";
143 <<
" No connection open!";
156 handleException(__func__,
"Attempting to delete DeviceFactory object...");
170 <<
" Closed connection to database...";
177 <<
" Clearing local caches...";
195 if (!method_name.empty()) {
197 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 198 <<
" NULL pointer to DeviceFactory requested by" 199 <<
" method SiStripConfigDb::" << method_name <<
"()!";
212 if (!method_name.empty()) {
214 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 215 <<
" NULL pointer to DbClient requested by" 216 <<
" method SiStripConfigDb::" << method_name <<
"()!";
230 DbAccess::getDbConfiguration(user, passwd, path);
231 if (!user.empty() && !passwd.empty() && !path.empty()) {
232 std::stringstream
ss;
233 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 234 <<
" Setting \"user/passwd@path\" to \"" << user <<
"/" << passwd <<
"@" << path
235 <<
"\" using 'CONFDB' environmental variable";
244 std::stringstream
ss;
245 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 247 <<
dbParams_.
path() <<
"\" using 'ConfDb' configurable read from .cfg file";
252 <<
" Unable to retrieve 'user/passwd@path' parameters" 253 <<
" from 'CONFDB' environmental variable or .cfg file" 254 <<
" (present value is \"" << user <<
"/" << passwd <<
"@" << path
255 <<
"\"). Aborting connection to database...";
261 std::string tns_admin =
"/afs/cern.ch/project/oracle/admin";
262 if (std::getenv(pattern.c_str()) !=
nullptr) {
263 tns_admin = std::getenv(pattern.c_str());
265 <<
" TNS_ADMIN is set to: \"" << tns_admin <<
"\"";
268 <<
" TNS_ADMIN is not set!" 269 <<
" Trying to use /afs and setting to: \"" << tns_admin <<
"\"";
274 std::stringstream
ss;
275 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 276 <<
" Overriding TNS_ADMIN value using cfg file!" << std::endl
277 <<
" Original value : \"" << tns_admin <<
"\"!" << std::endl
284 if (tns_admin.empty()) {
289 tns_admin = tns_admin.substr(0, tns_admin.size() - 1);
291 setenv(pattern.c_str(), tns_admin.c_str(), 1);
295 std::ifstream tnsnames_ora(filename.c_str());
297 if (tnsnames_ora.is_open()) {
299 while (!tnsnames_ora.eof()) {
300 getline(tnsnames_ora, line);
307 <<
" Cannot open file \"" << filename <<
"\"";
312 <<
" Found database account \"" <<
dbParams_.
path() <<
"\" in file \"" << filename <<
"\"!";
315 <<
" Cannot find database account \"" <<
dbParams_.
path() <<
"\" in file \"" 317 <<
" Aborting connection to database...";
324 <<
" Creating DeviceFactory object...";
327 <<
" Created DeviceFactory object!";
329 std::stringstream
ss;
338 std::stringstream
ss;
339 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 340 <<
" DeviceFactory created at address 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
factory_ 346 <<
" NULL pointer to DeviceFactory!" 347 <<
" Unable to connect to database using connection parameters '" <<
dbParams_.
user()
361 if (std::getenv(partition.c_str()) !=
nullptr) {
362 std::stringstream
ss;
363 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 364 <<
" Setting \"partitions\" to \"" << std::getenv(partition.c_str())
365 <<
"\" using 'ENV_CMS_TK_PARTITION' environmental variable";
368 <<
"\" read from .cfg file)";
374 if (!partitions.empty()) {
376 std::vector<std::string>::iterator
ii = partitions.begin();
377 std::vector<std::string>::iterator
jj = partitions.end();
378 for (; ii !=
jj; ++
ii) {
385 std::stringstream
ss;
386 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 388 <<
"\" using 'PartitionName' configurables read from .cfg file";
392 <<
" Unable to retrieve 'partition' parameter" 393 <<
" from 'CONFDB' environmental variable or .cfg file!" 394 <<
" Aborting connection to database...";
401 for (; ip != jp; ++ip) {
402 ip->second.update(
this);
422 std::stringstream
ss;
423 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 424 <<
" Empty string for shared memory name!" 425 <<
" Cannot accept shared memory!";
433 <<
" Creating DbClient object...";
436 <<
" Created DbClient object...";
438 std::stringstream
ss;
439 ss <<
"Failed to connect to database cache using shared memory name: '" <<
dbParams_.
sharedMemory() <<
"'!";
446 std::stringstream
ss;
447 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 448 <<
" DbClient object created at address 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
dbCache_ 453 <<
" NULL pointer to DbClient object!" 454 <<
" Unable to connect to database cache using shared memory name '" 463 handleException(__func__,
"Attempted to called DbClient::parse() method");
471 <<
" Using XML description files...";
477 handleException(__func__,
"Attempting to create DeviceFactory for use with xml files");
482 std::stringstream
ss;
483 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 484 <<
" DeviceFactory created at address 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
factory_ 485 <<
std::dec <<
", using XML description files";
489 <<
" NULL pointer to DeviceFactory!" 490 <<
" Unable to connect to database!";
503 for (; ip != jp; ++ip) {
505 if (ip->second.inputModuleXml().empty()) {
507 <<
" NULL path to input 'module.xml' file!";
511 deviceFactory(__func__)->addConnectionFileName(ip->second.inputModuleXml());
516 <<
" Added input 'module.xml' file: " << ip->second.inputModuleXml();
519 <<
" No 'module.xml' file found at " << ip->second.inputModuleXml();
520 ip->second.inputModuleXml() =
"";
525 if (ip->second.inputDcuInfoXml().empty()) {
527 <<
" NULL path to input 'dcuinfo.xml' file!";
531 deviceFactory(__func__)->addTkDcuInfoFileName(ip->second.inputDcuInfoXml());
536 <<
" Added 'dcuinfo.xml' file: " << ip->second.inputDcuInfoXml();
539 <<
" No 'dcuinfo.xml' file found at " << ip->second.inputDcuInfoXml();
540 ip->second.inputDcuInfoXml() =
"";
545 if (ip->second.inputFecXml().empty()) {
547 <<
" NULL paths to input 'fec.xml' files!";
549 std::vector<std::string>::iterator iter = ip->second.inputFecXml().begin();
550 for (; iter != ip->second.inputFecXml().end(); iter++) {
551 if ((*iter).empty()) {
553 <<
" NULL path to input 'fec.xml' file!";
562 <<
" Added 'fec.xml' file: " << *iter;
565 <<
" No 'fec.xml' file found at " << *iter;
573 if (ip->second.inputFedXml().empty()) {
575 <<
" NULL paths to input 'fed.xml' files!";
577 std::vector<std::string>::iterator iter = ip->second.inputFedXml().begin();
578 for (; iter != ip->second.inputFedXml().end(); iter++) {
579 if ((*iter).empty()) {
581 <<
" NULL path to input 'fed.xml' file!";
590 <<
" Added 'fed.xml' file: " << *iter;
593 <<
" No 'fed.xml' file found at " << *iter;
604 <<
" NULL path to output 'module.xml' file!" 605 <<
" Setting to '/tmp/module.xml'...";
612 handleException(__func__,
"Problems setting output 'module.xml' file!");
619 <<
" NULL path to output 'dcuinfo.xml' file!" 620 <<
" Setting to '/tmp/dcuinfo.xml'...";
627 handleException(__func__,
"Problems setting output 'dcuinfo.xml' file!");
634 <<
" NULL path to output 'fec.xml' file!" 635 <<
" Setting to '/tmp/fec.xml'...";
649 <<
" NULL path to output 'fed.xml' file!" 650 <<
" Setting to '/tmp/fed.xml'...";
654 Fed9U::Fed9UDeviceFactory* factory =
deviceFactory(__func__);
665 std::stringstream
ss;
671 ss <<
" Caught cms::Exception in method " << method_name <<
" with message: " << std::endl << e.
what();
672 if (!extra_info.empty()) {
673 ss <<
"Additional info: " << extra_info << std::endl;
678 catch (
const oracle::occi::SQLException& e) {
679 ss <<
" Caught oracle::occi::SQLException in method " << method_name <<
" with message: " << std::endl
681 if (!extra_info.empty()) {
682 ss <<
"Additional info: " << extra_info << std::endl;
687 catch (
const FecExceptionHandler& e) {
688 ss <<
" Caught FecExceptionHandler exception in method " << method_name <<
" with message: " << std::endl
689 <<
const_cast<FecExceptionHandler&
>(
e).what();
690 if (!extra_info.empty()) {
691 ss <<
"Additional info: " << extra_info << std::endl;
704 catch (
const ICUtils::ICException& e) {
705 ss <<
" Caught ICUtils::ICException in method " << method_name <<
" with message: " << std::endl << e.what();
706 if (!extra_info.empty()) {
707 ss <<
"Additional info: " << extra_info << std::endl;
713 ss <<
" Caught std::exception in method " << method_name <<
" with message: " << std::endl << e.what();
714 if (!extra_info.empty()) {
715 ss <<
"Additional info: " << extra_info << std::endl;
721 ss <<
" Caught unknown exception in method " << method_name <<
" (No message) " << std::endl;
722 if (!extra_info.empty()) {
723 ss <<
"Additional info: " << extra_info << std::endl;
736 fs.open(path.c_str(),
ios::in);
753 <<
" NULL pointer to DeviceFactory object!";
759 all = df->getAllRuns();
762 tkRunVector::const_iterator
ii = all.begin();
763 tkRunVector::const_iterator
jj = all.end();
764 for (; ii !=
jj; ++
ii) {
768 uint16_t
type = (*ii)->getModeId((*ii)->getMode());
772 }
else if (type == 2) {
774 }
else if (type == 3) {
776 }
else if (type == 33) {
778 }
else if (type == 4) {
780 }
else if (type == 5) {
782 }
else if (type == 6) {
784 }
else if (type == 7) {
786 }
else if (type == 10) {
788 }
else if (type == 8) {
790 }
else if (type == 12) {
792 }
else if (type == 13) {
794 }
else if (type == 14) {
796 }
else if (type == 15) {
798 }
else if (type == 16) {
800 }
else if (type == 17) {
802 }
else if (type == 18) {
804 }
else if (type == 19) {
806 }
else if (type == 20) {
808 }
else if (type == 21) {
810 }
else if (type == 0) {
820 r.
number_ = (*ii)->getRunNumber();
825 <<
" NULL pointer to TkRun object!";
838 if (!optional_partition.empty()) {
839 SiStripDbParams::SiStripPartitions::const_iterator iter =
dbParams_.
partition(optional_partition);
842 <<
" Partition name not found!";
848 Runs::const_iterator
ii = in.begin();
849 Runs::const_iterator
jj = in.end();
850 for (; ii !=
jj; ++
ii) {
852 if (ii->partition_ == optional_partition || optional_partition.empty()) {
858 if (out.find(ii->type_) != out.end()) {
859 Runs::const_iterator irun = out[ii->type_].begin();
860 Runs::const_iterator jrun = out[ii->type_].end();
861 while (!found && irun != jrun) {
862 if (irun->number_ == ii->number_) {
870 out[ii->type_].push_back(*ii);
902 Runs::const_iterator
ii = in.begin();
903 Runs::const_iterator
jj = in.end();
904 for (; ii !=
jj; ++
ii) {
906 if (!ii->partition_.empty()) {
912 if (out.find(ii->partition_) != out.end()) {
913 Runs::const_iterator irun = out[ii->partition_].begin();
914 Runs::const_iterator jrun = out[ii->partition_].end();
915 while (!found && irun != jrun) {
916 if (irun->number_ == ii->number_) {
924 out[ii->partition_].push_back(*ii);
957 <<
" NULL pointer to DeviceFactory object!";
961 partitions = df->getAllPartitionNames();
DeviceDescriptionsV typedDevices_
std::string passwd() const
static const std::string defaultPartitionName_
void partitions(std::list< std::string > &) const
DeviceFactory *const deviceFactory(std::string method_name="") const
void handleException(const std::string &method_name, const std::string &extra_info="") const
SiStripConfigDb(const edm::ParameterSet &, const edm::ActivityRegistry &)
char const * what() const override
std::map< std::string, Runs > RunsByPartition
void clearDeviceDescriptions(std::string partition="")
bool checkFileExists(const std::string &path)
static const char fecSlot_[]
static const char mlConfigDb_[]
static const char ccuChan_[]
static const char ccuAddr_[]
const_iterator_range partitions() const
static const char lldChan_[]
std::vector< std::string > partitionNames() const
std::string outputModuleXml() const
std::string tnsAdmin() const
void clearAnalysisDescriptions(std::string partition="")
static std::atomic< uint32_t > cntr_
static const char fecCrate_[]
std::string sharedMemory() const
Container class for database partition parameters.
std::map< sistrip::RunType, Runs > RunsByType
void clearFedConnections(std::string partition="")
DbClient *const databaseCache(std::string method_name="") const
std::string confdb() const
static const char feChan_[]
Container class for database connection parameters.
static const char fecRing_[]
static const uint16_t invalid_
std::string outputFedXml() const
SiStripPartitions::const_iterator partition(std::string partition_name) const
void usingDatabaseCache()
void pset(const edm::ParameterSet &)
SiStripDbParams dbParams_
bool usingDbCache() const
static std::atomic< bool > allowCalibUpload_
static const char feUnit_[]
friend class SiStripPartition
void clearDcuDetIds(std::string partition="")
void clearFedDescriptions(std::string partition="")
void addPartition(const SiStripPartition &)
std::string outputFecXml() const
std::string outputDcuInfoXml() const
static const char null_[]