42 openConnection_(
false)
46 <<
"[SiStripConfigDb::" << __func__ <<
"]" 47 <<
" Constructing database service..." 48 <<
" (Class instance: " <<
count <<
")";
65 <<
"[SiStripConfigDb::" << __func__ <<
"]" 66 <<
" Destructing object...";
105 <<
"[SiStripConfigDb::" << __func__ <<
"]" 106 <<
" Opening connection to database...";
111 <<
"[SiStripConfigDb::" << __func__ <<
"]" 112 <<
" Connection already open!";
123 std::stringstream ss;
124 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 125 <<
" Database connection parameters: " 133 <<
"[SiStripConfigDb::" << __func__ <<
"]" 134 <<
" Opened connection to database!";
143 <<
"[SiStripConfigDb::" << __func__ <<
"]" 144 <<
" Closing connection to database...";
149 <<
"[SiStripConfigDb::" << __func__ <<
"]" 150 <<
" No connection open!";
160 }
catch (...) {
handleException( __func__,
"Attempting to delete DeviceFactory object..." ); }
165 }
catch (...) {
handleException( __func__,
"Attempting to delete DbClient object..." ); }
169 <<
"[SiStripConfigDb::" << __func__ <<
"]" 170 <<
" Closed connection to database...";
179 <<
"[SiStripConfigDb::" << __func__ <<
"]" 180 <<
" Clearing local caches...";
198 if ( method_name !=
"" ) {
200 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 201 <<
" NULL pointer to DeviceFactory requested by" 202 <<
" method SiStripConfigDb::" << method_name <<
"()!";
214 if ( method_name !=
"" ) {
216 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 217 <<
" NULL pointer to DbClient requested by" 218 <<
" method SiStripConfigDb::" << method_name <<
"()!";
234 DbAccess::getDbConfiguration( user, passwd, path );
235 if ( user !=
"" && passwd !=
"" && path !=
"" ) {
237 std::stringstream ss;
238 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 239 <<
" Setting \"user/passwd@path\" to \"" 240 << user <<
"/" << pToPrint <<
"@" << path
241 <<
"\" using 'CONFDB' environmental variable";
245 ss <<
" (Overwriting existing value of \"" 249 <<
"\" read from .cfg file)";
258 std::stringstream ss;
259 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 260 <<
" Setting \"user/passwd@path\" to \"" 264 <<
"\" using 'ConfDb' configurable read from .cfg file";
269 <<
"[SiStripConfigDb::" << __func__ <<
"]" 270 <<
" Unable to retrieve 'user/passwd@path' parameters" 271 <<
" from 'CONFDB' environmental variable or .cfg file" 272 <<
" (present value is \"" 276 <<
"\"). Aborting connection to database...";
282 std::string tns_admin =
"/afs/cern.ch/project/oracle/admin";
283 if ( getenv( pattern.c_str() ) !=
nullptr ) {
284 tns_admin = getenv( pattern.c_str() );
286 <<
"[SiStripConfigDb::" << __func__ <<
"]" 287 <<
" TNS_ADMIN is set to: \"" 288 << tns_admin <<
"\"";
291 <<
"[SiStripConfigDb::" << __func__ <<
"]" 292 <<
" TNS_ADMIN is not set!" 293 <<
" Trying to use /afs and setting to: \"" 294 << tns_admin <<
"\"";
299 std::stringstream ss;
300 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 301 <<
" Overriding TNS_ADMIN value using cfg file!" << std::endl
302 <<
" Original value : \"" << tns_admin <<
"\"!" << std::endl
309 if ( tns_admin.empty() ) { tns_admin =
"."; }
311 if ( slash ==
sistrip::dir_ ) { tns_admin = tns_admin.substr( 0, tns_admin.size()-1 ); }
312 setenv( pattern.c_str(), tns_admin.c_str(), 1 );
316 std::ifstream tnsnames_ora( filename.c_str() );
318 if ( tnsnames_ora.is_open() ) {
320 while ( !tnsnames_ora.eof() ) {
321 getline( tnsnames_ora, line );
323 line.find(
dbParams_.
path() ) != std::string::npos ) { ok =
true; }
327 <<
"[SiStripConfigDb::" << __func__ <<
"]" 328 <<
" Cannot open file \"" 334 <<
"[SiStripConfigDb::" << __func__ <<
"]" 335 <<
" Found database account \"" 337 << filename <<
"\"!";
340 <<
"[SiStripConfigDb::" << __func__ <<
"]" 341 <<
" Cannot find database account \"" 344 <<
" Aborting connection to database...";
351 <<
"[SiStripConfigDb::" << __func__ <<
"]" 352 <<
" Creating DeviceFactory object...";
357 <<
"[SiStripConfigDb::" << __func__ <<
"]" 358 <<
" Created DeviceFactory object!";
360 std::stringstream ss;
361 ss <<
"Failed to connect to database using parameters '" 365 <<
"' and partitions '" 373 std::stringstream ss;
374 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 375 <<
" DeviceFactory created at address 0x" 377 <<
", using database account with parameters '" 384 <<
"[SiStripConfigDb::" << __func__ <<
"]" 385 <<
" NULL pointer to DeviceFactory!" 386 <<
" Unable to connect to database using connection parameters '" 390 <<
"' and partitions '" 403 if ( getenv(partition.c_str()) !=
nullptr ) {
405 std::stringstream ss;
406 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 407 <<
" Setting \"partitions\" to \"" 408 << getenv( partition.c_str() )
409 <<
"\" using 'ENV_CMS_TK_PARTITION' environmental variable";
411 ss <<
" (Overwriting existing value of \"" 413 <<
"\" read from .cfg file)";
419 if ( !partitions.empty() ) {
421 std::vector<std::string>::iterator
ii = partitions.begin();
422 std::vector<std::string>::iterator
jj = partitions.end();
423 for ( ; ii !=
jj; ++
ii ) {
430 std::stringstream ss;
431 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 432 <<
" Setting \"partitions\" to \"" 434 <<
"\" using 'PartitionName' configurables read from .cfg file";
438 <<
"[SiStripConfigDb::" << __func__ <<
"]" 439 <<
" Unable to retrieve 'partition' parameter" 440 <<
" from 'CONFDB' environmental variable or .cfg file!" 441 <<
" Aborting connection to database...";
448 for ( ; ip != jp; ++ip ) { ip->second.update(
this ); }
469 std::stringstream ss;
470 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 471 <<
" Empty string for shared memory name!" 472 <<
" Cannot accept shared memory!";
480 <<
"[SiStripConfigDb::" << __func__ <<
"]" 481 <<
" Creating DbClient object...";
484 <<
"[SiStripConfigDb::" << __func__ <<
"]" 485 <<
" Created DbClient object...";
487 std::stringstream ss;
488 ss <<
"Failed to connect to database cache using shared memory name: '" 496 std::stringstream ss;
497 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 498 <<
" DbClient object created at address 0x" 500 <<
" using shared memory name '" 505 <<
"[SiStripConfigDb::" << __func__ <<
"]" 506 <<
" NULL pointer to DbClient object!" 507 <<
" Unable to connect to database cache using shared memory name '" 516 handleException( __func__,
"Attempted to called DbClient::parse() method" );
525 <<
"[SiStripConfigDb::" << __func__ <<
"]" 526 <<
" Using XML description files...";
532 handleException( __func__,
"Attempting to create DeviceFactory for use with xml files" );
537 std::stringstream ss;
538 ss <<
"[SiStripConfigDb::" << __func__ <<
"]" 539 <<
" DeviceFactory created at address 0x" 541 <<
", using XML description files";
545 <<
"[SiStripConfigDb::" << __func__ <<
"]" 546 <<
" NULL pointer to DeviceFactory!" 547 <<
" Unable to connect to database!";
560 for ( ; ip != jp; ++ip ) {
563 if ( ip->second.inputModuleXml() ==
"" ) {
565 <<
"[SiStripConfigDb::" << __func__ <<
"]" 566 <<
" NULL path to input 'module.xml' file!";
570 deviceFactory(__func__)->addConnectionFileName( ip->second.inputModuleXml() );
575 <<
"[SiStripConfigDb::" << __func__ <<
"]" 576 <<
" Added input 'module.xml' file: " << ip->second.inputModuleXml();
579 <<
"[SiStripConfigDb::" << __func__ <<
"]" 580 <<
" No 'module.xml' file found at " << ip->second.inputModuleXml();
581 ip->second.inputModuleXml() =
"";
586 if ( ip->second.inputDcuInfoXml() ==
"" ) {
588 <<
"[SiStripConfigDb::" << __func__ <<
"]" 589 <<
" NULL path to input 'dcuinfo.xml' file!";
593 deviceFactory(__func__)->addTkDcuInfoFileName( ip->second.inputDcuInfoXml() );
598 <<
"[SiStripConfigDb::" << __func__ <<
"]" 599 <<
" Added 'dcuinfo.xml' file: " << ip->second.inputDcuInfoXml();
602 <<
"[SiStripConfigDb::" << __func__ <<
"]" 603 <<
" No 'dcuinfo.xml' file found at " << ip->second.inputDcuInfoXml();
604 ip->second.inputDcuInfoXml() =
"";
609 if ( ip->second.inputFecXml().empty() ) {
611 <<
"[SiStripConfigDb::" << __func__ <<
"]" 612 <<
" NULL paths to input 'fec.xml' files!";
614 std::vector<std::string>::iterator iter = ip->second.inputFecXml().begin();
615 for ( ; iter != ip->second.inputFecXml().end(); iter++ ) {
618 <<
"[SiStripConfigDb::" << __func__ <<
"]" 619 <<
" NULL path to input 'fec.xml' file!";
626 <<
"[SiStripConfigDb::" << __func__ <<
"]" 627 <<
" Added 'fec.xml' file: " << *iter;
630 <<
"[SiStripConfigDb::" << __func__ <<
"]" 631 <<
" No 'fec.xml' file found at " << *iter;
639 if ( ip->second.inputFedXml().empty() ) {
641 <<
"[SiStripConfigDb::" << __func__ <<
"]" 642 <<
" NULL paths to input 'fed.xml' files!";
644 std::vector<std::string>::iterator iter = ip->second.inputFedXml().begin();
645 for ( ; iter != ip->second.inputFedXml().end(); iter++ ) {
648 <<
"[SiStripConfigDb::" << __func__ <<
"]" 649 <<
" NULL path to input 'fed.xml' file!";
658 <<
"[SiStripConfigDb::" << __func__ <<
"]" 659 <<
" Added 'fed.xml' file: " << *iter;
662 <<
"[SiStripConfigDb::" << __func__ <<
"]" 663 <<
" No 'fed.xml' file found at " << *iter;
675 <<
"[SiStripConfigDb::" << __func__ <<
"]" 676 <<
" NULL path to output 'module.xml' file!" 677 <<
" Setting to '/tmp/module.xml'...";
684 handleException( __func__,
"Problems setting output 'module.xml' file!" );
691 <<
"[SiStripConfigDb::" << __func__ <<
"]" 692 <<
" NULL path to output 'dcuinfo.xml' file!" 693 <<
" Setting to '/tmp/dcuinfo.xml'...";
700 handleException( __func__,
"Problems setting output 'dcuinfo.xml' file!" );
707 <<
"[SiStripConfigDb::" << __func__ <<
"]" 708 <<
" NULL path to output 'fec.xml' file!" 709 <<
" Setting to '/tmp/fec.xml'...";
716 handleException( __func__,
"Problems setting output 'fec.xml' file!" );
723 <<
"[SiStripConfigDb::" << __func__ <<
"]" 724 <<
" NULL path to output 'fed.xml' file!" 725 <<
" Setting to '/tmp/fed.xml'...";
729 Fed9U::Fed9UDeviceFactory* factory =
deviceFactory(__func__);
732 handleException( __func__,
"Problems setting output 'fed.xml' file!" );
743 std::stringstream ss;
749 ss <<
" Caught cms::Exception in method " 750 << method_name <<
" with message: " << std::endl
752 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
756 catch (
const oracle::occi::SQLException& e ) {
757 ss <<
" Caught oracle::occi::SQLException in method " 758 << method_name <<
" with message: " << std::endl
760 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
764 catch (
const FecExceptionHandler& e ) {
765 ss <<
" Caught FecExceptionHandler exception in method " 766 << method_name <<
" with message: " << std::endl
767 <<
const_cast<FecExceptionHandler&
>(
e).what();
768 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
780 catch (
const ICUtils::ICException& e ) {
781 ss <<
" Caught ICUtils::ICException in method " 782 << method_name <<
" with message: " << std::endl
784 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
789 ss <<
" Caught std::exception in method " 790 << method_name <<
" with message: " << std::endl
792 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
797 ss <<
" Caught unknown exception in method " 798 << method_name <<
" (No message) " << std::endl;
799 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
812 fs.open( path.c_str(),
ios::in );
813 if( !fs.is_open() ) {
return false; }
828 <<
"[SiStripPartition::" << __func__ <<
"]" 829 <<
" NULL pointer to DeviceFactory object!";
835 all = df->getAllRuns();
838 tkRunVector::const_iterator
ii = all.begin();
839 tkRunVector::const_iterator
jj = all.end();
840 for ( ; ii !=
jj; ++
ii ) {
846 uint16_t
type = (*ii)->getModeId( (*ii)->getMode() );
875 r.
number_ = (*ii)->getRunNumber();
880 <<
"[SiStripPartition::" << __func__ <<
"]" 881 <<
" NULL pointer to TkRun object!";
897 if ( !optional_partition.empty() ) {
898 SiStripDbParams::SiStripPartitions::const_iterator iter =
dbParams_.
partition( optional_partition );
901 <<
"[SiStripPartition::" << __func__ <<
"]" 902 <<
" Partition name not found!";
908 Runs::const_iterator
ii = in.begin();
909 Runs::const_iterator
jj = in.end();
910 for ( ; ii !=
jj; ++
ii ) {
912 if ( ii->partition_ == optional_partition || optional_partition ==
"" ) {
919 if ( out.find( ii->type_ ) != out.end() ) {
920 Runs::const_iterator irun = out[ ii->type_ ].begin();
921 Runs::const_iterator jrun = out[ ii->type_ ].end();
922 while ( !found && irun != jrun ) {
923 if ( irun->number_ == ii->number_ ) { found =
true; }
929 out[ ii->type_ ].push_back( *ii );
964 Runs::const_iterator
ii = in.begin();
965 Runs::const_iterator
jj = in.end();
966 for ( ; ii !=
jj; ++
ii ) {
968 if ( ii->partition_ !=
"" ) {
974 if ( out.find( ii->partition_ ) != out.end() ) {
975 Runs::const_iterator irun = out[ ii->partition_ ].begin();
976 Runs::const_iterator jrun = out[ ii->partition_ ].end();
977 while ( !found && irun != jrun ) {
978 if ( irun->number_ == ii->number_ ) { found =
true; }
984 out[ ii->partition_ ].push_back( *ii );
1020 <<
"[SiStripPartition::" << __func__ <<
"]" 1021 <<
" NULL pointer to DeviceFactory object!";
1025 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 &)
std::map< std::string, Runs > RunsByPartition
char const * what() const override
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.
void clearFedConnections(std::string partition="")
DbClient *const databaseCache(std::string method_name="") const
std::string confdb() const
std::map< sistrip::RunType, Runs > RunsByType
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_[]