9 using namespace sistrip;
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 <<
"()!";
233 DbAccess::getDbConfiguration( user, passwd, path );
234 if ( user !=
"" && passwd !=
"" && path !=
"" ) {
236 std::stringstream
ss;
237 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
238 <<
" Setting \"user/passwd@path\" to \""
239 << user <<
"/" << passwd <<
"@" << path
240 <<
"\" using 'CONFDB' environmental variable";
244 ss <<
" (Overwriting existing value of \""
248 <<
"\" read from .cfg file)";
257 std::stringstream
ss;
258 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
259 <<
" Setting \"user/passwd@path\" to \""
263 <<
"\" using 'ConfDb' configurable read from .cfg file";
268 <<
"[SiStripConfigDb::" << __func__ <<
"]"
269 <<
" Unable to retrieve 'user/passwd@path' parameters"
270 <<
" from 'CONFDB' environmental variable or .cfg file"
271 <<
" (present value is \""
275 <<
"\"). Aborting connection to database...";
281 std::string tns_admin =
"/afs/cern.ch/project/oracle/admin";
282 if ( getenv( pattern.c_str() ) !=
NULL ) {
283 tns_admin = getenv( pattern.c_str() );
285 <<
"[SiStripConfigDb::" << __func__ <<
"]"
286 <<
" TNS_ADMIN is set to: \""
287 << tns_admin <<
"\"";
290 <<
"[SiStripConfigDb::" << __func__ <<
"]"
291 <<
" TNS_ADMIN is not set!"
292 <<
" Trying to use /afs and setting to: \""
293 << tns_admin <<
"\"";
298 std::stringstream
ss;
299 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
300 <<
" Overriding TNS_ADMIN value using cfg file!" << std::endl
301 <<
" Original value : \"" << tns_admin <<
"\"!" << std::endl
308 if ( tns_admin.empty() ) { tns_admin =
"."; }
310 if ( slash ==
sistrip::dir_ ) { tns_admin = tns_admin.substr( 0, tns_admin.size()-1 ); }
311 setenv( pattern.c_str(), tns_admin.c_str(), 1 );
315 std::ifstream tnsnames_ora( filename.c_str() );
317 if ( tnsnames_ora.is_open() ) {
319 while ( !tnsnames_ora.eof() ) {
320 getline( tnsnames_ora, line );
322 line.find(
dbParams_.
path() ) != std::string::npos ) { ok =
true; }
326 <<
"[SiStripConfigDb::" << __func__ <<
"]"
327 <<
" Cannot open file \""
333 <<
"[SiStripConfigDb::" << __func__ <<
"]"
334 <<
" Found database account \""
336 << filename <<
"\"!";
339 <<
"[SiStripConfigDb::" << __func__ <<
"]"
340 <<
" Cannot find database account \""
343 <<
" Aborting connection to database...";
350 <<
"[SiStripConfigDb::" << __func__ <<
"]"
351 <<
" Creating DeviceFactory object...";
356 <<
"[SiStripConfigDb::" << __func__ <<
"]"
357 <<
" Created DeviceFactory object!";
359 std::stringstream
ss;
360 ss <<
"Failed to connect to database using parameters '"
364 <<
"' and partitions '"
372 std::stringstream
ss;
373 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
374 <<
" DeviceFactory created at address 0x"
376 <<
", using database account with parameters '"
383 <<
"[SiStripConfigDb::" << __func__ <<
"]"
384 <<
" NULL pointer to DeviceFactory!"
385 <<
" Unable to connect to database using connection parameters '"
389 <<
"' and partitions '"
402 if ( getenv(partition.c_str()) !=
NULL ) {
404 std::stringstream
ss;
405 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
406 <<
" Setting \"partitions\" to \""
407 << getenv( partition.c_str() )
408 <<
"\" using 'ENV_CMS_TK_PARTITION' environmental variable";
410 ss <<
" (Overwriting existing value of \""
412 <<
"\" read from .cfg file)";
418 if ( !partitions.empty() ) {
420 std::vector<std::string>::iterator
ii = partitions.begin();
421 std::vector<std::string>::iterator
jj = partitions.end();
422 for ( ; ii !=
jj; ++
ii ) {
429 std::stringstream
ss;
430 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
431 <<
" Setting \"partitions\" to \""
433 <<
"\" using 'PartitionName' configurables read from .cfg file";
437 <<
"[SiStripConfigDb::" << __func__ <<
"]"
438 <<
" Unable to retrieve 'partition' parameter"
439 <<
" from 'CONFDB' environmental variable or .cfg file!"
440 <<
" Aborting connection to database...";
447 for ( ; ip != jp; ++ip ) { ip->second.update(
this ); }
468 std::stringstream
ss;
469 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
470 <<
" Empty string for shared memory name!"
471 <<
" Cannot accept shared memory!";
479 <<
"[SiStripConfigDb::" << __func__ <<
"]"
480 <<
" Creating DbClient object...";
483 <<
"[SiStripConfigDb::" << __func__ <<
"]"
484 <<
" Created DbClient object...";
486 std::stringstream
ss;
487 ss <<
"Failed to connect to database cache using shared memory name: '"
495 std::stringstream
ss;
496 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
497 <<
" DbClient object created at address 0x"
499 <<
" using shared memory name '"
504 <<
"[SiStripConfigDb::" << __func__ <<
"]"
505 <<
" NULL pointer to DbClient object!"
506 <<
" Unable to connect to database cache using shared memory name '"
515 handleException( __func__,
"Attempted to called DbClient::parse() method" );
524 <<
"[SiStripConfigDb::" << __func__ <<
"]"
525 <<
" Using XML description files...";
531 handleException( __func__,
"Attempting to create DeviceFactory for use with xml files" );
536 std::stringstream
ss;
537 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
538 <<
" DeviceFactory created at address 0x"
540 <<
", using XML description files";
544 <<
"[SiStripConfigDb::" << __func__ <<
"]"
545 <<
" NULL pointer to DeviceFactory!"
546 <<
" Unable to connect to database!";
559 for ( ; ip != jp; ++ip ) {
562 if ( ip->second.inputModuleXml() ==
"" ) {
564 <<
"[SiStripConfigDb::" << __func__ <<
"]"
565 <<
" NULL path to input 'module.xml' file!";
569 deviceFactory(__func__)->addConnectionFileName( ip->second.inputModuleXml() );
574 <<
"[SiStripConfigDb::" << __func__ <<
"]"
575 <<
" Added input 'module.xml' file: " << ip->second.inputModuleXml();
578 <<
"[SiStripConfigDb::" << __func__ <<
"]"
579 <<
" No 'module.xml' file found at " << ip->second.inputModuleXml();
580 ip->second.inputModuleXml() =
"";
585 if ( ip->second.inputDcuInfoXml() ==
"" ) {
587 <<
"[SiStripConfigDb::" << __func__ <<
"]"
588 <<
" NULL path to input 'dcuinfo.xml' file!";
592 deviceFactory(__func__)->addTkDcuInfoFileName( ip->second.inputDcuInfoXml() );
597 <<
"[SiStripConfigDb::" << __func__ <<
"]"
598 <<
" Added 'dcuinfo.xml' file: " << ip->second.inputDcuInfoXml();
601 <<
"[SiStripConfigDb::" << __func__ <<
"]"
602 <<
" No 'dcuinfo.xml' file found at " << ip->second.inputDcuInfoXml();
603 ip->second.inputDcuInfoXml() =
"";
608 if ( ip->second.inputFecXml().empty() ) {
610 <<
"[SiStripConfigDb::" << __func__ <<
"]"
611 <<
" NULL paths to input 'fec.xml' files!";
613 std::vector<std::string>::iterator iter = ip->second.inputFecXml().begin();
614 for ( ; iter != ip->second.inputFecXml().end(); iter++ ) {
617 <<
"[SiStripConfigDb::" << __func__ <<
"]"
618 <<
" NULL path to input 'fec.xml' file!";
625 <<
"[SiStripConfigDb::" << __func__ <<
"]"
626 <<
" Added 'fec.xml' file: " << *iter;
629 <<
"[SiStripConfigDb::" << __func__ <<
"]"
630 <<
" No 'fec.xml' file found at " << *iter;
638 if ( ip->second.inputFedXml().empty() ) {
640 <<
"[SiStripConfigDb::" << __func__ <<
"]"
641 <<
" NULL paths to input 'fed.xml' files!";
643 std::vector<std::string>::iterator iter = ip->second.inputFedXml().begin();
644 for ( ; iter != ip->second.inputFedXml().end(); iter++ ) {
647 <<
"[SiStripConfigDb::" << __func__ <<
"]"
648 <<
" NULL path to input 'fed.xml' file!";
657 <<
"[SiStripConfigDb::" << __func__ <<
"]"
658 <<
" Added 'fed.xml' file: " << *iter;
661 <<
"[SiStripConfigDb::" << __func__ <<
"]"
662 <<
" No 'fed.xml' file found at " << *iter;
674 <<
"[SiStripConfigDb::" << __func__ <<
"]"
675 <<
" NULL path to output 'module.xml' file!"
676 <<
" Setting to '/tmp/module.xml'...";
683 handleException( __func__,
"Problems setting output 'module.xml' file!" );
690 <<
"[SiStripConfigDb::" << __func__ <<
"]"
691 <<
" NULL path to output 'dcuinfo.xml' file!"
692 <<
" Setting to '/tmp/dcuinfo.xml'...";
699 handleException( __func__,
"Problems setting output 'dcuinfo.xml' file!" );
706 <<
"[SiStripConfigDb::" << __func__ <<
"]"
707 <<
" NULL path to output 'fec.xml' file!"
708 <<
" Setting to '/tmp/fec.xml'...";
715 handleException( __func__,
"Problems setting output 'fec.xml' file!" );
722 <<
"[SiStripConfigDb::" << __func__ <<
"]"
723 <<
" NULL path to output 'fed.xml' file!"
724 <<
" Setting to '/tmp/fed.xml'...";
728 Fed9U::Fed9UDeviceFactory* factory =
deviceFactory(__func__);
731 handleException( __func__,
"Problems setting output 'fed.xml' file!" );
742 std::stringstream
ss;
748 ss <<
" Caught cms::Exception in method "
749 << method_name <<
" with message: " << std::endl
751 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
756 ss <<
" Caught oracle::occi::SQLException in method "
757 << method_name <<
" with message: " << std::endl
759 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
763 catch (
const FecExceptionHandler& e ) {
764 ss <<
" Caught FecExceptionHandler exception in method "
765 << method_name <<
" with message: " << std::endl
766 <<
const_cast<FecExceptionHandler&
>(
e).what();
767 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
779 catch (
const ICUtils::ICException& e ) {
780 ss <<
" Caught ICUtils::ICException in method "
781 << method_name <<
" with message: " << std::endl
783 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
788 ss <<
" Caught std::exception in method "
789 << method_name <<
" with message: " << std::endl
791 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
796 ss <<
" Caught unknown exception in method "
797 << method_name <<
" (No message) " << std::endl;
798 if ( extra_info !=
"" ) { ss <<
"Additional info: " << extra_info << std::endl; }
811 fs.open( path.c_str(),
ios::in );
812 if( !fs.is_open() ) {
return false; }
827 <<
"[SiStripPartition::" << __func__ <<
"]"
828 <<
" NULL pointer to DeviceFactory object!";
834 all = df->getAllRuns();
837 tkRunVector::const_iterator
ii = all.begin();
838 tkRunVector::const_iterator
jj = all.end();
839 for ( ; ii !=
jj; ++
ii ) {
845 uint16_t
type = (*ii)->getModeId( (*ii)->getMode() );
874 r.
number_ = (*ii)->getRunNumber();
879 <<
"[SiStripPartition::" << __func__ <<
"]"
880 <<
" NULL pointer to TkRun object!";
896 if ( !optional_partition.empty() ) {
897 SiStripDbParams::SiStripPartitions::const_iterator iter =
dbParams_.
partition( optional_partition );
900 <<
"[SiStripPartition::" << __func__ <<
"]"
901 <<
" Partition name not found!";
907 Runs::const_iterator
ii = in.begin();
908 Runs::const_iterator
jj = in.end();
909 for ( ; ii !=
jj; ++
ii ) {
911 if ( ii->partition_ == optional_partition || optional_partition ==
"" ) {
918 if ( out.find( ii->type_ ) != out.end() ) {
919 Runs::const_iterator irun = out[ ii->type_ ].begin();
920 Runs::const_iterator jrun = out[ ii->type_ ].end();
921 while ( !found && irun != jrun ) {
922 if ( irun->number_ == ii->number_ ) { found =
true; }
928 out[ ii->type_ ].push_back( *ii );
963 Runs::const_iterator
ii = in.begin();
964 Runs::const_iterator
jj = in.end();
965 for ( ; ii !=
jj; ++
ii ) {
967 if ( ii->partition_ !=
"" ) {
973 if ( out.find( ii->partition_ ) != out.end() ) {
974 Runs::const_iterator irun = out[ ii->partition_ ].begin();
975 Runs::const_iterator jrun = out[ ii->partition_ ].end();
976 while ( !found && irun != jrun ) {
977 if ( irun->number_ == ii->number_ ) { found =
true; }
983 out[ ii->partition_ ].push_back( *ii );
1019 <<
"[SiStripPartition::" << __func__ <<
"]"
1020 <<
" NULL pointer to DeviceFactory object!";
1024 partitions = df->getAllPartitionNames();
virtual char const * what() const
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
void clearDeviceDescriptions(std::string partition="")
bool checkFileExists(const std::string &path)
oracle::occi::SQLException SQLException
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="")
volatile std::atomic< bool > shutdown_flag false
void clearFedDescriptions(std::string partition="")
void addPartition(const SiStripPartition &)
std::string outputFecXml() const
std::string outputDcuInfoXml() const
static const char null_[]