diff --git a/AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt b/AtlasGeometryCommon/SubDetectorEnvelopes/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fe9ed7453dc9044f5880c5e50e596f09439bd806 --- /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 f289d2537771b94724e129174a2891112fd6c4eb..c3a25edea120fa2cbacebb940f551cd4b9c5a520 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 5f5a45bcb5c38657840f5526b898490ca1a9513d..388ddf2d20c4a4611dc5b5e6f5cc0d9a31666a23 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 5ad06cf973f1ab381d0634097a00ca9597057c03..53236cb38c5688284ed788aecd49cca4ee48faf0 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 0596d68d1f5ebb7e8a7004fe15c5db79e50a4f2c..67fa315e48ed35df1c95f99f48c9d430192b7036 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 8371730129b72aaab0b9928b51a9a7116fad01b9..e2ba66b4b9c76b88531fdfc05e6b0d48a9446eb1 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 )