Skip to content
Snippets Groups Projects
Commit 732d4b7a authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (SubDetectorEnvelopes-00-03-05)

	* src/DetDescrDBEnvelopeSvc.cxx: allow empty envelope definitions in Python fallback mode
		(required for execution of Fatras in ATLFASTIIF)
	* tagging SubDetectorEnvelopes-00-03-05

2015-01-06  Elmar Ritsch  < Elmar.Ritsch -at- cern.ch >
	* moved non-public file 'DetDescrDBEnvelopeSvc.h' from 'SubDetectorEnvelopes' to 'src' directory
	* requirements and components files updated accordingly
	* tagging SubDetectorEnvelopes-00-03-04

2015-01-05  Elmar Ritsch  < Elmar.Ritsch -at- cern.ch >
	* src/DetDescrDBEnvelopeSvc.cxx: fixing coverity defects CID 17578 & 17576 (ATLASSIM-1711)
	* tagging SubDetectorEnvelopes-00-03-03
parent 161ecf45
No related branches found
No related tags found
No related merge requests found
################################################################################
# Package: SubDetectorEnvelopes
################################################################################
# Declare the package name:
atlas_subdir( SubDetectorEnvelopes )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
DetectorDescription/AtlasDetDescr
GaudiKernel
PRIVATE
Control/AthenaBaseComps
Database/AthenaPOOL/RDBAccessSvc
DetectorDescription/GeoModel/GeoModelInterfaces )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( CLHEP )
find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess )
# Component(s) in the package:
atlas_add_component( SubDetectorEnvelopes
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} AtlasDetDescr GaudiKernel AthenaBaseComps )
# Install files from the package:
atlas_install_headers( SubDetectorEnvelopes )
atlas_install_python_modules( python/*.py )
......@@ -6,12 +6,12 @@ manager Elmar Ritsch <Elmar.Ritsch@cern.ch>
# public use statements
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use AthenaBaseComps AthenaBaseComps-* Control
use AtlasDetDescr AtlasDetDescr-* DetectorDescription
#################################################################
# private use statements
private
use AthenaBaseComps AthenaBaseComps-* Control
use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL
use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel
use AtlasCLHEP AtlasCLHEP-* External
......
......@@ -7,7 +7,7 @@
///////////////////////////////////////////////////////////////////
// class header include
#include "SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h"
#include "DetDescrDBEnvelopeSvc.h"
// framework includes
#include "GaudiKernel/Bootstrap.h"
......@@ -123,13 +123,16 @@ StatusCode DetDescrDBEnvelopeSvc::initialize()
// cache the volume definitions locally
for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
RZPairVector *curRZ = retrieveRZBoundaryOptionalFallback( m_node[region] , m_fallbackR[region] , m_fallbackZ[region] );
if (!curRZ) {
StatusCode sc = retrieveRZBoundaryOptionalFallback( m_node[region],
m_fallbackR[region],
m_fallbackZ[region],
m_rposz[region] );
if (sc.isFailure()) {
ATH_MSG_ERROR("Unable to retrieve subdetector envelope for detector region '" <<
AtlasDetDescr::AtlasRegionHelper::getName(region) << "'");
return StatusCode::FAILURE;
}
m_rposz[region] = *curRZ;
}
// disconnect the DB access svc
......@@ -140,7 +143,13 @@ StatusCode DetDescrDBEnvelopeSvc::initialize()
else {
// cache the volume definitions locally
for ( int region = AtlasDetDescr::fFirstAtlasRegion; region < AtlasDetDescr::fNumAtlasRegions; region++) {
m_rposz[region] = *fallbackRZBoundary( m_fallbackR[region], m_fallbackZ[region] );
StatusCode sc = fallbackRZBoundary( m_fallbackR[region], m_fallbackZ[region], m_rposz[region] );
if (sc.isFailure()) {
ATH_MSG_ERROR("Unable to retrieve sub-detector envelope in (r,z)-space for detector region '" <<
AtlasDetDescr::AtlasRegionHelper::getName(region) << "'");
return StatusCode::FAILURE;
}
}
}
......@@ -177,34 +186,42 @@ StatusCode DetDescrDBEnvelopeSvc::finalize()
/** retrieve and store the (r,z) values locally for the given DB node.
if there are problems with retrieving this from DDDB,
try the fallback approach if allowed */
RZPairVector *DetDescrDBEnvelopeSvc::retrieveRZBoundaryOptionalFallback(
std::string &dbNode,
FallbackDoubleVector &r,
FallbackDoubleVector &z)
StatusCode DetDescrDBEnvelopeSvc::retrieveRZBoundaryOptionalFallback( std::string &dbNode,
FallbackDoubleVector &r,
FallbackDoubleVector &z,
RZPairVector &rzVec)
{
// clear the output RZPairVector
rzVec.clear();
// try the DB approach to retrieve the (r,z) values
RZPairVector *rz = retrieveRZBoundary(dbNode);
StatusCode sc = retrieveRZBoundary(dbNode, rzVec);
// if 0 return value -> unsuccessfully read DDDB
if (!rz) {
// if empty vector returned -> unsuccessfully read DDDB
if (sc.isFailure()) {
ATH_MSG_DEBUG("Will try reading Python-based envelope definition for '" << dbNode << "'.");
// try fallback approach
rz = enableFallback() ? fallbackRZBoundary(r, z) : 0;
if (rz) {
ATH_MSG_INFO("Sucessfully read Python-based envelope definition for '" << dbNode << "'.");
} else {
sc = enableFallback() ? fallbackRZBoundary(r, z, rzVec) : StatusCode::FAILURE;
if (sc.isFailure()) {
ATH_MSG_WARNING("Could not create envelope volume for '" << dbNode << "'.");
return StatusCode::FAILURE;
} else {
ATH_MSG_INFO("Sucessfully read Python-based envelope definition for '" << dbNode << "'.");
}
}
return rz;
return StatusCode::SUCCESS;
}
/** retrieve and store the (r,z) values locally for the given DB node */
RZPairVector *DetDescrDBEnvelopeSvc::retrieveRZBoundary( std::string &node)
StatusCode DetDescrDBEnvelopeSvc::retrieveRZBoundary( std::string &node,
RZPairVector &rzVec)
{
// clear the output RZPairVector
rzVec.clear();
// @TODO: implement checks and do output with the actual child tags taken
// some output about the used tags
//const std::string &detVersionTag = m_dbAccess->getChildTag( detNode /* child node */,
......@@ -237,12 +254,9 @@ RZPairVector *DetDescrDBEnvelopeSvc::retrieveRZBoundary( std::string &node)
size_t numEntries = envelopeRec ? envelopeRec->size() : 0;
if ( !numEntries) {
ATH_MSG_INFO("No entries for table '" << node << "' in Detector Description Database (DDDB). Maybe you are using Python-based envelope definitions...");
return 0;
return StatusCode::RECOVERABLE;
}
// the current RZPairVector (to be filled in the loop)
RZPairVector *rzVec = new RZPairVector();
// retrieve data from the DB
IRDBRecordset::const_iterator recIt = envelopeRec->begin();
IRDBRecordset::const_iterator recEnd = envelopeRec->end();
......@@ -252,33 +266,38 @@ RZPairVector *DetDescrDBEnvelopeSvc::retrieveRZBoundary( std::string &node)
double curR = (*recIt)->getDouble("R") * CLHEP::mm;
double curZ = (*recIt)->getDouble("Z") * CLHEP::mm;
// store (r,z) duplet locally
rzVec->push_back( RZPair(curR, curZ) );
rzVec.push_back( RZPair(curR, curZ) );
}
return rzVec;
return StatusCode::SUCCESS;
}
/** retrieve and store the (r,z) values locally for the given DB node */
RZPairVector *DetDescrDBEnvelopeSvc::fallbackRZBoundary( FallbackDoubleVector &r,
FallbackDoubleVector &z)
StatusCode DetDescrDBEnvelopeSvc::fallbackRZBoundary( FallbackDoubleVector &r,
FallbackDoubleVector &z,
RZPairVector &rzVec)
{
// TODO: check for same length of r and z vectors!
unsigned short len = r.size();
// the current RZPairVector (to be filled in the loop)
RZPairVector *rzVec = new RZPairVector();
// r and z vectors must have same length
if ( len != z.size() ) {
ATH_MSG_ERROR("Unable to construct fallback envelope definition in (r,z) space, as the provided r and z vectors have different length");
rzVec.clear();
return StatusCode::FAILURE;
}
// loop over the given pairs of (r,z) values
for ( unsigned short pos=0; pos<r.size(); ++pos) {
for ( unsigned short pos=0; pos<len; ++pos) {
// read-in (r,z) duplet
double curR = r[pos];
double curZ = z[pos];
// store (r,z) duplet locally
rzVec->push_back( RZPair(curR, curZ) );
rzVec.push_back( RZPair(curR, curZ) );
}
return rzVec;
return StatusCode::SUCCESS;
}
......
......@@ -56,16 +56,18 @@ class DetDescrDBEnvelopeSvc : public IEnvelopeDefSvc, virtual public AthService
/** retrieve and store the (r,z) values locally for the given DB node.
if there are problems with retrieving this from DDDB,
try the fallback approach if allowed */
RZPairVector *retrieveRZBoundaryOptionalFallback( std::string &dbNode,
FallbackDoubleVector &r,
FallbackDoubleVector &z);
StatusCode retrieveRZBoundaryOptionalFallback( std::string &dbNode,
FallbackDoubleVector &r,
FallbackDoubleVector &z,
RZPairVector &rzVec);
/** retrieve and store the (r,z) values locally for the given DB node */
RZPairVector *retrieveRZBoundary( std::string &node);
StatusCode retrieveRZBoundary( std::string &node, RZPairVector &rzVec);
/** use the fallback approach (python arguments) to set the (r,z) values */
RZPairVector *fallbackRZBoundary( FallbackDoubleVector &r,
FallbackDoubleVector &z);
StatusCode fallbackRZBoundary( FallbackDoubleVector &r,
FallbackDoubleVector &z,
RZPairVector &rzVec);
/** enable fallback solution:
* @return true if fallback mode is allowed, false if no fallback allowed */
......
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h"
#include "src/DetDescrDBEnvelopeSvc.h"
DECLARE_SERVICE_FACTORY( DetDescrDBEnvelopeSvc )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment