diff --git a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc index 0de45dc3597b610c80fe992adac1a02db4dd1f17..e691367ac68194cbf93b25c4bf6821eb6f84675e 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::EndcapCryostat::CalibrationMixedCalculator @@ -23,6 +23,7 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" @@ -75,12 +76,16 @@ namespace LArG4 { if (status != StatusCode::SUCCESS) { throw std::runtime_error ("Cannot locate GeoModelSvc!!"); } - + IGeoDbTagSvc *geoDbTagSvc(nullptr); + status = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); + if (status != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoDbTagSvc"); + } // Access the geometry database: IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); + status=svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } // Obtain the geometry version information: diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc index 9834c5c8594925953a881e1559801a24b55b7e08..2725ddf2302ab9de4e4bbc46ae462a614a649f0c 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::EMECSupportCalibrationCalculator @@ -23,6 +23,7 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" @@ -86,12 +87,16 @@ namespace LArG4 { if (status != StatusCode::SUCCESS) { throw std::runtime_error ("Cannot locate GeoModelSvc!!"); } - - // Access the geometry database: + IGeoDbTagSvc *geoDbTagSvc(nullptr); + status = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); + if (status != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoDbTagSvc"); + } + // Access the geometry database: IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); + status=svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } // Obtain the geometry version information: diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc index 591dd6675f1b3b7fbeb3622d0abd1ef79632bbe9..fc36c9af0c7edb042e7771594ea7676ad17c4886 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc @@ -44,6 +44,7 @@ #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GeoModelUtilities/DecodeVersionKey.h" #include "GaudiKernel/ISvcLocator.h" @@ -296,18 +297,26 @@ StatusCode EnergyCalculator::initialize() IGeoModelSvc *geoModel=0; ATH_CHECK(svcLocator->service ("GeoModelSvc",geoModel)); + IGeoDbTagSvc *geoDbTagSvc(nullptr); + ATH_CHECK(svcLocator->service ("GeoDbTagSvc",geoDbTagSvc)); + // Access the geometry database: IRDBAccessSvc *pAccessSvc=0; - ATH_CHECK(svcLocator->service("RDBAccessSvc",pAccessSvc)); + ATH_CHECK(svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc)); - DecodeVersionKey larVersionKey(geoModel, "LAr"); + std::string larKey, larNode; + if(geoDbTagSvc->getSqliteReader()==nullptr) { + DecodeVersionKey larVersionKey(geoModel, "LAr"); + larKey = larVersionKey.tag(); + larNode = larVersionKey.node(); + } - IRDBRecordset_ptr emecSamplingSep = pAccessSvc->getRecordsetPtr("EmecSamplingSep", larVersionKey.tag(), larVersionKey.node()); + IRDBRecordset_ptr emecSamplingSep = pAccessSvc->getRecordsetPtr("EmecSamplingSep", larKey, larNode); if (emecSamplingSep->size()==0) { throw std::runtime_error("Cannot find the EmecSamplingSep Table"); } - IRDBRecordset_ptr emecGeometry = pAccessSvc->getRecordsetPtr("EmecGeometry", larVersionKey.tag(), larVersionKey.node()); + IRDBRecordset_ptr emecGeometry = pAccessSvc->getRecordsetPtr("EmecGeometry", larKey, larNode); if (emecGeometry->size()==0) { throw std::runtime_error("Cannot find the EmecGeometry Table"); } diff --git a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc index c82c031180c2d9ffa1cb2c43d52e70254d4e2f3e..0a7be39443ffe6acb5eb70ea38e1e52441544ab9 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::EC::PresamplerGeometry @@ -26,6 +26,7 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" @@ -61,14 +62,13 @@ namespace LArG4 { ISvcLocator *svcLocator = Gaudi::svcLocator(); IGeoModelSvc *geoModel(nullptr); ATH_CHECK(svcLocator->service ("GeoModelSvc",geoModel)); + IGeoDbTagSvc *geoDbTagSvc(nullptr); + ATH_CHECK(svcLocator->service ("GeoDbTagSvc",geoDbTagSvc)); // Access the geometry database: IRDBAccessSvc *pAccessSvc(nullptr); - ATH_CHECK(svcLocator->service("RDBAccessSvc",pAccessSvc)); + ATH_CHECK(svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc)); // Obtain the geometry version information: const std::string AtlasVersion = geoModel->atlasVersion(); - const std::string LArVersion = geoModel->LAr_VersionOverride(); - const std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - const std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; // Note Presampler Lives In DB under "cryostats".. IRDBRecordset_ptr presamplerPosition = pAccessSvc->getRecordsetPtr("PresamplerPosition",AtlasVersion,"ATLAS"); diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc index bedd89822a825e433ca6cc216e362e71186cc568..040586b801e1430a47dd2c16390508f38e2646c2 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ //----------------------------------------------------------------------------- @@ -37,6 +37,7 @@ #include <algorithm> #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/ServiceHandle.h" @@ -92,16 +93,20 @@ namespace LArG4 { // get GeoModelSvc & RDBAccessSvc ISvcLocator *svcLocator = Gaudi::svcLocator(); - IGeoModelSvc *geoModel(0); + IGeoModelSvc *geoModel(nullptr); StatusCode status = svcLocator->service ("GeoModelSvc",geoModel); if (status != StatusCode::SUCCESS) throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate GeoModelSvc!"); + IGeoDbTagSvc *geoDbTagSvc(nullptr); + status=svcLocator->service("GeoDbTagSvc",geoDbTagSvc); + if (status != StatusCode::SUCCESS) + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate GeoDbTagSvc"); // Access the geometry database: - IRDBAccessSvc *pAccessSvc(0); - status=svcLocator->service("RDBAccessSvc",pAccessSvc); + IRDBAccessSvc *pAccessSvc(nullptr); + status=svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (status != StatusCode::SUCCESS) - throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate RDBAccessSvc!"); + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate " + geoDbTagSvc->getParamSvcName()); // Obtain the geometry version information: diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h index 092e8a24ee52485b21e178d1d006b4cad425d26e..55f326b148f0a26ba49a2d7515f9b74f7c34b5c5 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h +++ b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::HEC::LocalGeometry @@ -21,13 +21,10 @@ #include "AthenaBaseComps/AthService.h" #include "GeoModelInterfaces/IGeoModelSvc.h" -#include "RDBAccessSvc/IRDBAccessSvc.h" -//#include "globals.hh" -// Forward declarations. +#include "GeoModelInterfaces/IGeoDbTagSvc.h" + class LArG4Identifier; class G4Step; -// class IGeoModelSvc; -// class IRDBAccessSvc; namespace LArG4 { @@ -52,7 +49,7 @@ namespace LArG4 { int binSearchAll(double ly, int depth, bool regular=false) const; double deadZone(double locx, double locy) const; ServiceHandle<IGeoModelSvc> m_geoModel; - ServiceHandle<IRDBAccessSvc> m_AccessSvc; + ServiceHandle<IGeoDbTagSvc> m_geoDbTagSvc; bool m_isX; double m_depthSize[7] = {0.0}; diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc index dca57ab71839672618071ec183069ead4c498115..9816267fc05cfdcc44155f94d1b884f7093e9885 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc @@ -1,12 +1,11 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::HEC::LocalGeometry #include "LArG4HEC/LocalGeometry.h" #include "LArG4Code/LArG4Identifier.h" -//#include "LArG4HEC/Geometry.h" #include "G4ThreeVector.hh" #include "G4StepPoint.hh" @@ -19,7 +18,6 @@ #include "RDBAccessSvc/IRDBAccessSvc.h" #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" -#include "GeoModelInterfaces/IGeoModelSvc.h" #include "AthenaKernel/Units.h" #include "globals.hh" #include <cmath> @@ -100,11 +98,10 @@ namespace LArG4 { LocalGeometry::LocalGeometry(const std::string& name, ISvcLocator * pSvcLocator) : base_class(name, pSvcLocator) , m_geoModel("GeoModelSvc", name) - , m_AccessSvc("RDBAccessSvc", name) + , m_geoDbTagSvc("GeoDbTagSvc",name) , m_isX(false) { declareProperty("GeoModelSvc",m_geoModel); - declareProperty("RDBAccessSvc", m_AccessSvc); declareProperty("isX", m_isX); } @@ -115,7 +112,9 @@ namespace LArG4 { ATH_CHECK(m_geoModel.retrieve()); // Access the geometry database: - ATH_CHECK(m_AccessSvc.retrieve()); + ATH_CHECK(m_geoDbTagSvc.retrieve()); + ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(), name()); + ATH_CHECK(accessSvc.retrieve()); // Obtain the geometry version information: std::string AtlasVersion = m_geoModel->atlasVersion(); @@ -127,10 +126,10 @@ namespace LArG4 { ATH_MSG_INFO("Constructing local HEC geometry helper "); ATH_MSG_DEBUG(" detectorKey: "<<detectorKey<<" detectorNode: "<<detectorNode); - IRDBRecordset_ptr hecPad = m_AccessSvc->getRecordsetPtr("HecPad",detectorKey, detectorNode); + IRDBRecordset_ptr hecPad = accessSvc->getRecordsetPtr("HecPad",detectorKey, detectorNode); if (hecPad->size()==0) { - hecPad = m_AccessSvc->getRecordsetPtr("HecPad","HecPad-00", "HecPad"); + hecPad = accessSvc->getRecordsetPtr("HecPad","HecPad-00", "HecPad"); } if (hecPad->size()==0) { @@ -147,7 +146,7 @@ namespace LArG4 { } } - IRDBRecordset_ptr hecLongitudinalBlock = m_AccessSvc->getRecordsetPtr("HecLongitudinalBlock",detectorKey,detectorNode); + IRDBRecordset_ptr hecLongitudinalBlock = accessSvc->getRecordsetPtr("HecLongitudinalBlock",detectorKey,detectorNode); if (hecLongitudinalBlock->size()==0) { ATH_MSG_ERROR("Cannot find the HecLongitinalBlock Table"); @@ -159,7 +158,7 @@ namespace LArG4 { m_firstAbsorber[indexloop]= (*hecLongitudinalBlock)[indexloop]->getDouble("PLATE0")*Units::cm; } - IRDBRecordset_ptr hadronicEndcap = m_AccessSvc->getRecordsetPtr("HadronicEndcap",detectorKey,detectorNode); + IRDBRecordset_ptr hadronicEndcap = accessSvc->getRecordsetPtr("HadronicEndcap",detectorKey,detectorNode); if (hadronicEndcap->size()==0) { ATH_MSG_ERROR("Cannot find the HadronicEndcap Table"); diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc index fa30f43e1b3259f93aa208e069a558903e7e5b63..df2e5ebaa72d55b01728b42f6adedd7d62b08bc1 100644 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // LArG4::MiniFCAL::MiniFCALAssignIdentifier @@ -28,11 +28,11 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include "GaudiKernel/IService.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/IMessageSvc.h" #include "GaudiKernel/Bootstrap.h" -//#include "AthenaKernel/getMessageSvc.h" #include "G4ios.hh" #include <string> @@ -71,18 +71,23 @@ namespace LArG4 { MsgStream log(m_msgsvc, "LArG4::MiniFcalAssignIdentifier"); log << MSG::DEBUG << "In MiniFcalAssignIdentifier - constructor; access database" << endmsg; - IRDBAccessSvc* pAccessSvc(0); - sc=svcLocator->service("RDBAccessSvc",pAccessSvc); - if(sc != StatusCode::SUCCESS) { - log << MSG::ERROR <<"Cannot locate RDBAccessSvc!!" << endmsg; - } - - IGeoModelSvc* geoModelSvc(0); + IGeoModelSvc* geoModelSvc(nullptr); sc = svcLocator->service ("GeoModelSvc",geoModelSvc); if (sc != StatusCode::SUCCESS) { log << MSG::ERROR <<"Cannot locate GeoModelSvc!!" << endmsg; } + IGeoDbTagSvc *geoDbTagSvc(nullptr); + sc=svcLocator->service("GeoDbTagSvc",geoDbTagSvc); + if(sc != StatusCode::SUCCESS) { + log << MSG::ERROR <<"Cannot locate GeoDbTagSvc!!" << endmsg; + } + + IRDBAccessSvc* pAccessSvc(nullptr); + sc=svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); + if(sc != StatusCode::SUCCESS) { + log << MSG::ERROR <<"Cannot locate RDBAccessSvc!!" << endmsg; + } std::string AtlasVersion = geoModelSvc->atlasVersion(); std::string LArVersion = geoModelSvc->LAr_VersionOverride(); diff --git a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.cxx b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.cxx index 18efcaa06eb1a60a272c7c161d1c6060447cb061..1d3dcf1be62383daf2d6c52e6887eb8c013780b7 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoAlgsNV/src/LArDetectorFactoryLite.cxx @@ -8,6 +8,8 @@ #include "LArGeoFcal/FCALChannelMapBuilder.h" #include "LArHV/LArHVManager.h" #include "LArGeoEndcap/MbtsReadoutBuilder.h" +#include "LArGeoCode/VDetectorParameters.h" +#include "LArGeoRAL/RAL.h" #include "LArReadoutGeometry/HECDetectorManager.h" #include "LArReadoutGeometry/FCALDetectorManager.h" @@ -51,9 +53,14 @@ LArGeo::LArDetectorFactoryLite::~LArDetectorFactoryLite() void LArGeo::LArDetectorFactoryLite::create(GeoPhysVol* world) { + ATH_MSG_INFO("LArDetectorFactoryLite::create()"); + std::string errorMessage{""}; - ATH_MSG_INFO("LArDetectorFactoryLite::create()"); + // Instantiate VDetectorParameters (needed for some clients) + VDetectorParameters* parameters = new LArGeo::RAL(); + VDetectorParameters::SetInstance(parameters); + if(LArGeo::buildFcalChannelMap(m_detStore,m_paramSvc,Athena::getMessageSvc()).isFailure()) { errorMessage="Failed to build FCAL Channel Map"; ATH_MSG_FATAL(errorMessage); diff --git a/LArCalorimeter/LArGeoModel/LArGeoRAL/LArGeoRAL/RALEmb.h b/LArCalorimeter/LArGeoModel/LArGeoRAL/LArGeoRAL/RALEmb.h index 16e4211748aa3be1a158312ddd5af92783bb3269..efb8dab64d10ad96abc8d02c5140e9b8b75ad218 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoRAL/LArGeoRAL/RALEmb.h +++ b/LArCalorimeter/LArGeoModel/LArGeoRAL/LArGeoRAL/RALEmb.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // RALEmb.h @@ -36,9 +36,9 @@ namespace LArGeo { class Clockwork; Clockwork *m_c; - bool m_oldDB; - bool m_oldSagging; - bool m_oldContract; + bool m_oldDB{false}; + bool m_oldSagging{false}; + bool m_oldContract{false}; RALEmb (const RALEmb&); RALEmb& operator= (const RALEmb&); diff --git a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmb.cxx b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmb.cxx index b44021388c9383548930bf1d984cec7cd1d4e41e..1c7d4e81228507caea3d06dc83c10af2d5961eaa 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmb.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmb.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // RALEmb @@ -21,6 +21,7 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include <iostream> #include <string> @@ -50,72 +51,78 @@ LArGeo::RALEmb::RALEmb(): m_c(new Clockwork()) { // First, fetch the Athena services. - ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap.h + ISvcLocator* svcLocator = Gaudi::svcLocator(); - - StatusCode sc; - IRDBAccessSvc *pAccessSvc; - sc = svcLocator->service("RDBAccessSvc",pAccessSvc); + IGeoDbTagSvc* geoDbTagSvc{nullptr}; + StatusCode sc = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); + if (sc != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoDBTagSvc"); + } + + IRDBAccessSvc* pAccessSvc{nullptr}; + sc = svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } + std::string detectorKey; + std::string detectorNode; + if(geoDbTagSvc->getSqliteReader()==nullptr) { + // The geometry DB is used + IGeoModelSvc* geoModel{nullptr}; + sc = svcLocator->service ("GeoModelSvc",geoModel); + if (sc != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoModelSvc"); + } - IGeoModelSvc *geoModel; - sc = svcLocator->service ("GeoModelSvc",geoModel); - if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } + std::string AtlasVersion = geoModel->atlasVersion(); + std::string LArVersion = geoModel->LAr_VersionOverride(); - - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); + detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; + detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; - std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; + + if ( LArVersion.empty()) { + LArVersion=pAccessSvc->getChildTag("LAr",AtlasVersion,"ATLAS"); + } + if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || + LArVersion == "LAr-Rome-Initial-00" || + LArVersion == "LAr-H6-00" || + LArVersion == "LAr-Commissioning-00" || + LArVersion == "LAr-G3-00") { + m_oldDB=true; + std::cout << " in RALEmb: old database tag used, some values are hard coded" << std::endl; + std::cout << " Non projectivity of lead transition will not be simulated " << std::endl; + } + + if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" || + LArVersion == "LAr-Rome-Initial-00" || + LArVersion == "LAr-H8-00" || + LArVersion == "LAr-H6-00" || + LArVersion == "LAr-Commissioning-00" || + LArVersion == "LAr-G3-00") { + m_oldSagging=true; + std::cout << " in RALEmb: only old sagging values available" << std::endl; + } - if ( LArVersion.empty()) { - LArVersion=pAccessSvc->getChildTag("LAr",AtlasVersion,"ATLAS"); - } - m_oldDB=false; - if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || - LArVersion == "LAr-Rome-Initial-00" || - LArVersion == "LAr-H6-00" || - LArVersion == "LAr-Commissioning-00" || - LArVersion == "LAr-G3-00") { - m_oldDB=true; - std::cout << " in RALEmb: old database tag used, some values are hard coded" << std::endl; - std::cout << " Non projectivity of lead transition will not be simulated " << std::endl; - } - m_oldSagging=false; - if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" || - LArVersion == "LAr-Rome-Initial-00" || - LArVersion == "LAr-H8-00" || - LArVersion == "LAr-H6-00" || - LArVersion == "LAr-Commissioning-00" || - LArVersion == "LAr-G3-00") { - m_oldSagging=true; - std::cout << " in RALEmb: only old sagging values available" << std::endl; - } - m_oldContract=false; - if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" || - LArVersion == "LAr-03" || LArVersion == "LAr-04" || - LArVersion == "LAr-Rome-Initial-00" || - LArVersion == "LAr-H8-00" || - LArVersion == "LAr-H6-00" || - LArVersion == "LAr-Commissioning-00" || - LArVersion == "LAr-Commissioning-01" || - LArVersion == "LAr-G3-00" || - LArVersion == "LAr-02-Align-00" || - LArVersion == "LAr-02-Align-01" || - LArVersion == "LAr-H6-2002-00" || - LArVersion == "LAr-H6-2003-00" || + if (LArVersion == "LAr-00" || LArVersion == "LAr-01" || LArVersion == "LAr-02" || + LArVersion == "LAr-03" || LArVersion == "LAr-04" || + LArVersion == "LAr-Rome-Initial-00" || + LArVersion == "LAr-H8-00" || + LArVersion == "LAr-H6-00" || + LArVersion == "LAr-Commissioning-00" || + LArVersion == "LAr-Commissioning-01" || + LArVersion == "LAr-G3-00" || + LArVersion == "LAr-02-Align-00" || + LArVersion == "LAr-02-Align-01" || + LArVersion == "LAr-H6-2002-00" || + LArVersion == "LAr-H6-2003-00" || LArVersion == "LAr-TBEC-00" ) { m_oldContract=true; - } - + } + } m_c->barrelGeometry = pAccessSvc->getRecordsetPtr("BarrelGeometry",detectorKey, detectorNode); diff --git a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmec.cxx b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmec.cxx index 1bcf54e29a22e6d897c0cdc8f2d1bb88572f367f..f4ef558cbf5f9eecc227f9eb0bc63e66dae8a4b0 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmec.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALEmec.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // RALEmec @@ -21,6 +21,8 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" + #include <iostream> #include <string> #include <stdlib.h> @@ -48,33 +50,38 @@ LArGeo::RALEmec::RALEmec(): m_c(new Clockwork()) { // First, fetch the Athena services. - ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap.h - + ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode sc; - IRDBAccessSvc *pAccessSvc; - sc = svcLocator->service("RDBAccessSvc",pAccessSvc); + IGeoDbTagSvc* geoDbTagSvc{nullptr}; + StatusCode sc = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate GeoDBTagSvc"); } - - - - - IGeoModelSvc *geoModel; - sc = svcLocator->service ("GeoModelSvc",geoModel); + + IRDBAccessSvc* pAccessSvc{nullptr}; + sc = svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } - - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); + std::string detectorKey; + std::string detectorNode; + std::string AtlasVersion; - std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; + if(geoDbTagSvc->getSqliteReader()==nullptr) { + // The geometry DB is used + IGeoModelSvc* geoModel{nullptr}; + sc = svcLocator->service ("GeoModelSvc",geoModel); + if (sc != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoModelSvc"); + } + AtlasVersion = geoModel->atlasVersion(); + std::string LArVersion = geoModel->LAr_VersionOverride(); + detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; + detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; + } m_c->emecCylLayer = pAccessSvc->getRecordsetPtr("EmecCylLayer",detectorKey, detectorNode); m_c->emecGeometry = pAccessSvc->getRecordsetPtr("EmecGeometry",detectorKey, detectorNode); diff --git a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALExperimentalHall.cxx b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALExperimentalHall.cxx index 9e99b370ea7ec727d55049d9787d08cb892af27f..22dee3412cac43d47f0b332a491fe892d756aa70 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALExperimentalHall.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALExperimentalHall.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // RALExperimentalHall @@ -21,6 +21,8 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" + #include <iostream> #include <string> #include <stdlib.h> @@ -42,22 +44,33 @@ LArGeo::RALExperimentalHall::RALExperimentalHall(): m_c(new Clockwork()) { // First, fetch the Athena services. - ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap.h + ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode sc; - IRDBAccessSvc *pAccessSvc; - sc = svcLocator->service("RDBAccessSvc",pAccessSvc); + IGeoDbTagSvc* geoDbTagSvc{nullptr}; + StatusCode sc = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate GeoDBTagSvc"); } - - IGeoModelSvc *geoModel; - sc = svcLocator->service ("GeoModelSvc",geoModel); + + IRDBAccessSvc* pAccessSvc{nullptr}; + sc = svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } + + std::string AtlasVersion; + + if(geoDbTagSvc->getSqliteReader()==nullptr) { + // The geometry DB is used + IGeoModelSvc* geoModel{nullptr}; + sc = svcLocator->service ("GeoModelSvc",geoModel); + if (sc != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoModelSvc"); + } - std::string AtlasVersion = geoModel->atlasVersion(); + AtlasVersion = geoModel->atlasVersion(); + } + m_c->atlasMother = pAccessSvc->getRecordsetPtr("AtlasMother",AtlasVersion, "ATLAS"); } diff --git a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALHec.cxx b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALHec.cxx index f5f217d67541c4c84e79a30230c5e4321fa03ed6..4cff7fded2722d81b094e427b292169c2b17c296 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALHec.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoRAL/src/RALHec.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ // RALHec @@ -22,6 +22,7 @@ #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" +#include "GeoModelInterfaces/IGeoDbTagSvc.h" #include <iostream> #include <string> @@ -45,29 +46,37 @@ LArGeo::RALHec::RALHec(): m_c(new Clockwork()) { // First, fetch the Athena services. - ISvcLocator* svcLocator = Gaudi::svcLocator(); // from Bootstrap.h + ISvcLocator* svcLocator = Gaudi::svcLocator(); - - StatusCode sc; - IRDBAccessSvc *pAccessSvc; - sc=svcLocator->service("RDBAccessSvc",pAccessSvc); + IGeoDbTagSvc* geoDbTagSvc{nullptr}; + StatusCode sc = svcLocator->service("GeoDbTagSvc",geoDbTagSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); + throw std::runtime_error ("Cannot locate GeoDBTagSvc"); } - - - IGeoModelSvc *geoModel; - sc = svcLocator->service ("GeoModelSvc",geoModel); + + IRDBAccessSvc* pAccessSvc{nullptr}; + sc = svcLocator->service(geoDbTagSvc->getParamSvcName(),pAccessSvc); if (sc != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); + throw std::runtime_error ("Cannot locate " + geoDbTagSvc->getParamSvcName()); } - - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); - std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; + std::string detectorKey; + std::string detectorNode; + + if(geoDbTagSvc->getSqliteReader()==nullptr) { + // The geometry DB is used + IGeoModelSvc* geoModel{nullptr}; + sc = svcLocator->service ("GeoModelSvc",geoModel); + if (sc != StatusCode::SUCCESS) { + throw std::runtime_error ("Cannot locate GeoModelSvc"); + } + std::string AtlasVersion = geoModel->atlasVersion(); + std::string LArVersion = geoModel->LAr_VersionOverride(); + + detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; + detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; + } m_c->hadronicEndcap = pAccessSvc->getRecordsetPtr("HadronicEndcap",detectorKey, detectorNode); diff --git a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx index 0c7e5dfd21314b5d04116327a62fc04b46ec8cd0..050becc6b33e8ca830a364590241a860e076feb4 100644 --- a/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/ExtParameterisedVolumeBuilder.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "ExtParameterisedVolumeBuilder.h" @@ -32,8 +32,8 @@ ExtParameterisedVolumeBuilder::ExtParameterisedVolumeBuilder(const std::string& n, Geo2G4AssemblyFactory* G4AssemblyFactory): VolumeBuilder(n), m_getMatEther(true), - m_matEther(0), - m_matHypUr(0), + m_matEther(nullptr), + m_matHypUr(nullptr), m_msg(n), m_G4AssemblyFactory(G4AssemblyFactory) { @@ -42,8 +42,8 @@ ExtParameterisedVolumeBuilder::ExtParameterisedVolumeBuilder(const std::string& G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPhysVolume, OpticalVolumesMap* optical_volumes) const { PVConstLink theGeoPhysChild; - const GeoSerialTransformer* serialTransformerChild=0; - G4LogicalVolume* theG4LogChild; + const GeoSerialTransformer* serialTransformerChild{nullptr}; + G4LogicalVolume* theG4LogChild{nullptr}; unsigned int numChildNodes; // number of child nodes (PV and ST) bool descend; // flag to continue geo tree navigation bool serialExists = false; // flag for existence of ST among childs @@ -96,7 +96,7 @@ G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPh theGeoPhysChild = serialTransformerChild->getVolume(); // Build the child - if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return 0; + if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return nullptr; if (nameChild == "ANON") nameChild=theG4LogChild->GetName(); nameChild += "_Param"; @@ -132,49 +132,57 @@ G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPh Query<int> Qint = av.getId(); if(Qint.isValid()) id = Qint; - if(m_matEther == theGeoPhysChild->getLogVol()->getMaterial()) - { - Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild); - - if(Qint.isValid()) - assembly->MakeImprint(theG4LogVolume,theG4Position,id); - else - assembly->MakeImprint(theG4LogVolume,theG4Position); - } - else if(m_matHypUr == theGeoPhysChild->getLogVol()->getMaterial()) - { - Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild); - - if(Qint.isValid()) - assembly->MakeImprint(theG4LogVolume,theG4Position,id,true); - else - assembly->MakeImprint(theG4LogVolume,theG4Position,0,true); - } - else - { - nameChild = av.getName(); - - // Build the child - if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return 0; - - if (nameChild == "ANON") nameChild=theG4LogChild->GetName(); - - G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position, - nameChild, - theG4LogChild, - theG4LogVolume, - false, - id); - - // if GeoModel volume is optical store it in the map - if(optical_volumes!=0) - { - const GeoOpticalPhysVol* opticalGeoPhysChild = - dynamic_cast < const GeoOpticalPhysVol* >(theGeoPhysChild.operator->()); - if(opticalGeoPhysChild) - (*optical_volumes)[opticalGeoPhysChild] = pvPair.first; - } - } + bool isEther = m_matEther + ? m_matEther == theGeoPhysChild->getLogVol()->getMaterial() + : theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::Ether")==0; + + bool isHypUr = m_matHypUr + ? m_matHypUr == theGeoPhysChild->getLogVol()->getMaterial() + : theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::HyperUranium")==0; + + if(isEther) { + Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild); + + if(Qint.isValid()) { + assembly->MakeImprint(theG4LogVolume,theG4Position,id); + } + else { + assembly->MakeImprint(theG4LogVolume,theG4Position); + } + } + else if(isHypUr) { + Geo2G4AssemblyVolume* assembly = BuildAssembly(theGeoPhysChild); + + if(Qint.isValid()) { + assembly->MakeImprint(theG4LogVolume,theG4Position,id,true); + } + else { + assembly->MakeImprint(theG4LogVolume,theG4Position,0,true); + } + } + else { + nameChild = av.getName(); + + // Build the child + if(!(theG4LogChild = Build(theGeoPhysChild,optical_volumes))) return nullptr; + + if (nameChild == "ANON") nameChild=theG4LogChild->GetName(); + + G4PhysicalVolumesPair pvPair = G4ReflectionFactory::Instance()->Place(theG4Position + , nameChild + , theG4LogChild + , theG4LogVolume + , false + , id); + + // if GeoModel volume is optical store it in the map + if(optical_volumes!=0) { + const GeoOpticalPhysVol* opticalGeoPhysChild = + dynamic_cast < const GeoOpticalPhysVol* >(theGeoPhysChild.operator->()); + if(opticalGeoPhysChild) + (*optical_volumes)[opticalGeoPhysChild] = pvPair.first; + } + } av.next(); } @@ -186,8 +194,8 @@ G4LogicalVolume* ExtParameterisedVolumeBuilder::Build(const PVConstLink theGeoPh Geo2G4AssemblyVolume* ExtParameterisedVolumeBuilder::BuildAssembly(const PVConstLink& pv) const { PVConstLink theGeoPhysChild; - G4LogicalVolume* theG4LogChild = 0; - Geo2G4AssemblyVolume* theG4AssemblyChild = 0; + G4LogicalVolume* theG4LogChild{nullptr}; + Geo2G4AssemblyVolume* theG4AssemblyChild{nullptr}; bool descend; // flag to continue geo tree navigation if(m_getMatEther) getMatEther(); @@ -207,35 +215,39 @@ Geo2G4AssemblyVolume* ExtParameterisedVolumeBuilder::BuildAssembly(const PVConst + theGeoPhysChild->getLogVol()->getName() + ")"; // Check if it is an assembly - if(m_matEther == theGeoPhysChild->getLogVol()->getMaterial() || - m_matHypUr == theGeoPhysChild->getLogVol()->getMaterial() ) - { - // Build the child assembly - if(!(theG4AssemblyChild = BuildAssembly(theGeoPhysChild))) return 0; - - // Get its transform - G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform())); - - assemblyVolume->AddPlacedAssembly(theG4AssemblyChild,theG4Position); - } - else - { - Query<int> Qint = av.getId(); - - // Build the child - if(!(theG4LogChild = Build(theGeoPhysChild))) return 0; - - // Get its transform - G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform())); - - int placedID = 0; - if(Qint.isValid()) placedID = Qint; + bool isEther = m_matEther + ? m_matEther == theGeoPhysChild->getLogVol()->getMaterial() + : theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::Ether")==0; + + bool isHypUr = m_matHypUr + ? m_matHypUr == theGeoPhysChild->getLogVol()->getMaterial() + : theGeoPhysChild->getLogVol()->getMaterial()->getName().compare("special::HyperUranium")==0; + + if(isEther || isHypUr) { + // Build the child assembly + if(!(theG4AssemblyChild = BuildAssembly(theGeoPhysChild))) return nullptr; + + // Get its transform + G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform())); + + assemblyVolume->AddPlacedAssembly(theG4AssemblyChild,theG4Position); + } + else { + Query<int> Qint = av.getId(); - std::string placedName = nameChild=="ANON" ? "" : nameChild; + // Build the child + if(!(theG4LogChild = Build(theGeoPhysChild))) return nullptr; + // Get its transform + G4Transform3D theG4Position(Amg::EigenTransformToCLHEP(av.getTransform())); + + int placedID = 0; + if(Qint.isValid()) placedID = Qint; + + std::string placedName = nameChild=="ANON" ? "" : nameChild; - assemblyVolume->AddPlacedVolume(theG4LogChild,theG4Position,placedID,placedName); - } + assemblyVolume->AddPlacedVolume(theG4LogChild,theG4Position,placedID,placedName); + } av.next(); } @@ -259,21 +271,17 @@ void ExtParameterisedVolumeBuilder::PrintSTInfo(const std::string& volume) const void ExtParameterisedVolumeBuilder::getMatEther() const { - StoreGateSvc* pDetStore=0; + StoreGateSvc* pDetStore{nullptr}; ISvcLocator* svcLocator = Gaudi::svcLocator(); if(svcLocator->service("DetectorStore",pDetStore).isFailure()) { ATH_MSG_ERROR ( "ExtParameterisedVolumeBuilder: Unable to access Detector Store" ); } - else - { - const StoredMaterialManager* theMaterialManager = nullptr; - if(pDetStore->retrieve(theMaterialManager, "MATERIALS").isFailure()) { - ATH_MSG_ERROR ( "ExtParameterisedVolumeBuilder: Unable to access Material Manager" ); - } - else { - m_matEther = theMaterialManager->getMaterial("special::Ether"); - m_matHypUr = theMaterialManager->getMaterial("special::HyperUranium"); - } + else { + const StoredMaterialManager* theMaterialManager = pDetStore->tryConstRetrieve<StoredMaterialManager>("MATERIALS"); + if(theMaterialManager) { + m_matEther = theMaterialManager->getMaterial("special::Ether"); + m_matHypUr = theMaterialManager->getMaterial("special::HyperUranium"); } + } m_getMatEther = false; } diff --git a/Simulation/G4Utilities/Geo2G4/src/Geo2G4Builder.cxx b/Simulation/G4Utilities/Geo2G4/src/Geo2G4Builder.cxx index 3e41b9eaeb9f6ded8c8ccbde93875f71ce1eedb2..f1b2f093624c53e6e6135ad282e783810ea7be4b 100644 --- a/Simulation/G4Utilities/Geo2G4/src/Geo2G4Builder.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/Geo2G4Builder.cxx @@ -60,16 +60,16 @@ Geo2G4Builder::Geo2G4Builder(const std::string& detectorName) for(unsigned int i=0; i<m_treeTops.size();i++) ATH_MSG_INFO( " Tree Top " << i << " " << m_treeTops[i]->getLogVol()->getName() ); - if(m_treeTops.size()>1) - { + if(m_treeTops.size()>1) { // -------- -------- MATERIAL MANAGER -------- ---------- - const StoredMaterialManager* theMaterialManager = nullptr; - sc = m_pDetStore->retrieve(theMaterialManager, "MATERIALS"); - if(sc.isFailure()) - ATH_MSG_ERROR("Detector "<< detectorName << "could not retrieve Material Manager when number of tree tops > 1"); - else + const StoredMaterialManager* theMaterialManager = m_pDetStore->tryConstRetrieve<StoredMaterialManager>("MATERIALS"); + if(theMaterialManager) { m_matAir = theMaterialManager->getMaterial("std::Air"); - } + } + else { + m_matAir = m_treeTops[0]->getLogVol()->getMaterial(); + } + } Geo2G4SvcAccessor accessor; Geo2G4SvcBase *g=accessor.GetGeo2G4Svc();