From d6900c5a4675c26f53a1dc35e459fe35cdeca87c Mon Sep 17 00:00:00 2001 From: Atlas-Software Librarian <Atlas-Software.Librarian@cern.ch> Date: Fri, 8 Apr 2016 16:09:19 +0200 Subject: [PATCH] '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 2014-11-05 Elmar Ritsch < Elmar.Ritsch -at- cern.ch > * python/SubDetectorEnvelopesConfig.py: synching envelope definitions with G4AtlasApps-00-07-83 * tagging SubDetectorEnvelopes-00-03-02 --- .../SubDetectorEnvelopes/CMakeLists.txt | 32 +++++++ .../SubDetectorEnvelopes/cmt/requirements | 2 +- .../python/SubDetectorEnvelopesConfig.py | 12 ++- .../src/DetDescrDBEnvelopeSvc.cxx | 83 ++++++++++++------- .../DetDescrDBEnvelopeSvc.h | 14 ++-- .../SubDetectorEnvelopes_entries.cxx | 2 +- 6 files changed, 101 insertions(+), 44 deletions(-) create mode 100644 AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt rename AtlasGeometryCommon/SubDetectorEnvelopes/{SubDetectorEnvelopes => src}/DetDescrDBEnvelopeSvc.h (85%) diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt b/AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt new file mode 100644 index 00000000000..fe9ed7453dc --- /dev/null +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt @@ -0,0 +1,32 @@ +################################################################################ +# 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 ) + diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/cmt/requirements b/AtlasGeometryCommon/SubDetectorEnvelopes/cmt/requirements index f289d253777..c3a25edea12 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/cmt/requirements +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/cmt/requirements @@ -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 diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py index 5f5a45bcb5c..388ddf2d20c 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/python/SubDetectorEnvelopesConfig.py @@ -80,8 +80,8 @@ def getEnvelopeDefSvc(name="AtlasGeometry_EnvelopeDefSvc", **kwargs): Muon.addRZ( 70.0 , 12900.0 ) Muon.addRZ( 279.0 , 12900.0 ) Muon.addRZ( 279.0 , 18650.0 ) - Muon.addRZ( 436.0 , 18650.0 ) - Muon.addRZ( 436.0 , 22030.0 ) + Muon.addRZ( 436.7 , 18650.0 ) + Muon.addRZ( 436.7 , 22030.0 ) Muon.addRZ( 1050.0 , 22030.0 ) Muon.addRZ( 1050.0 , 26046.0 ) Muon.addRZ( 1500.0 , 26046.0 ) @@ -92,14 +92,18 @@ def getEnvelopeDefSvc(name="AtlasGeometry_EnvelopeDefSvc", **kwargs): Muon.addRZ( 12650.0 , 18650.0 ) Muon.addRZ( 13400.0 , 18650.0 ) Muon.addRZ( 13400.0 , 12900.0 ) - Muon.addRZ( 13000.0 , 12900.0 ) + Muon.addRZ( 13910.0 , 12900.0 ) + Muon.addRZ( 13910.0 , 6550.0 ) + Muon.addRZ( 13000.0 , 6550.0 ) kwargs.setdefault("FallbackMuonR" , Muon.getRs() ) kwargs.setdefault("FallbackMuonZ" , Muon.getZs() ) # setup fallback CavernEnvelope Cavern = Volume() - Cavern.addRZ( 13000.0 , 12900.0 ) # boundary with MS + Cavern.addRZ( 13000.0 , 6550.0 ) + Cavern.addRZ( 13910.0 , 6550.0 ) + Cavern.addRZ( 13910.0 , 12900.0 ) # boundary with MS Cavern.addRZ( 13400.0 , 12900.0 ) # boundary with MS Cavern.addRZ( 13400.0 , 18650.0 ) # boundary with MS Cavern.addRZ( 12650.0 , 18650.0 ) # boundary with MS diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.cxx b/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.cxx index 5ad06cf973f..53236cb38c5 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.cxx +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.cxx @@ -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; } diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h b/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.h similarity index 85% rename from AtlasGeometryCommon/SubDetectorEnvelopes/SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h rename to AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.h index 0596d68d1f5..67fa315e48e 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/src/DetDescrDBEnvelopeSvc.h @@ -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 */ diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/src/components/SubDetectorEnvelopes_entries.cxx b/AtlasGeometryCommon/SubDetectorEnvelopes/src/components/SubDetectorEnvelopes_entries.cxx index 8371730129b..e2ba66b4b9c 100644 --- a/AtlasGeometryCommon/SubDetectorEnvelopes/src/components/SubDetectorEnvelopes_entries.cxx +++ b/AtlasGeometryCommon/SubDetectorEnvelopes/src/components/SubDetectorEnvelopes_entries.cxx @@ -1,5 +1,5 @@ #include "GaudiKernel/DeclareFactoryEntries.h" -#include "SubDetectorEnvelopes/DetDescrDBEnvelopeSvc.h" +#include "src/DetDescrDBEnvelopeSvc.h" DECLARE_SERVICE_FACTORY( DetDescrDBEnvelopeSvc ) -- GitLab