10 using namespace sistrip;
43 openConnection_(
false)
47 <<
"[SiStripConfigDb::" << __func__ <<
"]"
48 <<
" Constructing database service..."
49 <<
" (Class instance: " <<
cntr_ <<
")";
66 <<
"[SiStripConfigDb::" << __func__ <<
"]"
67 <<
" Destructing object...";
106 <<
"[SiStripConfigDb::" << __func__ <<
"]"
107 <<
" Opening connection to database...";
112 <<
"[SiStripConfigDb::" << __func__ <<
"]"
113 <<
" Connection already open!";
124 std::stringstream ss;
125 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
126 <<
" Database connection parameters: "
134 <<
"[SiStripConfigDb::" << __func__ <<
"]"
135 <<
" Opened connection to database!";
144 <<
"[SiStripConfigDb::" << __func__ <<
"]"
145 <<
" Closing connection to database...";
150 <<
"[SiStripConfigDb::" << __func__ <<
"]"
151 <<
" No connection open!";
161 }
catch (...) {
handleException( __func__,
"Attempting to delete DeviceFactory object..." ); }
166 }
catch (...) {
handleException( __func__,
"Attempting to delete DbClient object..." ); }
170 <<
"[SiStripConfigDb::" << __func__ <<
"]"
171 <<
" Closed connection to database...";
180 <<
"[SiStripConfigDb::" << __func__ <<
"]"
181 <<
" Clearing local caches...";
199 if ( method_name !=
"" ) {
201 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
202 <<
" NULL pointer to DeviceFactory requested by"
203 <<
" method SiStripConfigDb::" << method_name <<
"()!";
215 if ( method_name !=
"" ) {
217 ss <<
"[SiStripConfigDb::" << __func__ <<
"]"
218 <<
" NULL pointer to DbClient requested by"
219 <<
" method SiStripConfigDb::" << method_name <<
"()!";
231 std::string
user =
"";
232 std::string passwd =
"";
233 std::string
path =
"";
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 <<
"/" << passwd <<
"@" << 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...";
281 std::string
pattern =
"TNS_ADMIN";
282 std::string tns_admin =
"/afs/cern.ch/project/oracle/admin";
283 if ( getenv( pattern.c_str() ) !=
NULL ) {
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 =
"."; }
310 std::string
slash = tns_admin.substr( tns_admin.size()-1, 1 );
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 );
315 std::string
filename( tns_admin +
"/tnsnames.ora" );
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"
376 << std::hex << std::setw(8) << std::setfill(
'0') <<
factory_ << std::dec
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 '"
402 std::string partition =
"ENV_CMS_TK_PARTITION";
403 if ( getenv(partition.c_str()) !=
NULL ) {
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"
499 << std::hex << std::setw(8) << std::setfill(
'0') <<
dbCache_ << std::dec
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"
540 << std::hex << std::setw(8) << std::setfill(
'0') <<
factory_ << std::dec
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!" );
741 const std::string& extra_info )
const {
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; }
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!";
892 std::string optional_partition )
const {
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();
static std::string defaultPartitionName_
virtual char const * what() const
DeviceDescriptionsV typedDevices_
std::string passwd() const
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 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()
static bool allowCalibUpload_
void pset(const edm::ParameterSet &)
SiStripDbParams dbParams_
bool usingDbCache() const
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_[]