Skip to content
Snippets Groups Projects
Commit fa744b66 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2: Committed by Tadej Novak
Browse files

MuonGeoModelR4 - Simplify way to retrieve the Alignable nodes

MuonGeoModelR4 - Simplify way to retrieve the Alignable nodes
parent 8f55c354
No related branches found
No related tags found
No related merge requests found
Showing
with 60 additions and 80 deletions
......@@ -23,19 +23,9 @@ class IMuonGeoUtilityTool : virtual public IAlgTool {
public:
/// Gaudi interface ID
DeclareInterfaceID(IMuonGeoUtilityTool, 1, 0);
/// Abbriviate the type definitions of the maps produced by the SqLite publisher
using alignNodeMap = std::map<std::string, GeoAlignableTransform*>;
using physNodeMap = std::map<std::string, GeoFullPhysVol*>;
using alignedPhysNodes = std::map<PVConstLink, const GeoAlignableTransform*>;
/// Loops over the publised alignable transforms and the published alignable nodes and produces a map
/// of full phys vols that have alignable transformations attached
virtual alignedPhysNodes selectAlignableVolumes(const physNodeMap& publishedPhysVols,
const alignNodeMap& publishedAlignNodes) const = 0;
/// Returns the next alignable transformation in the GeoModel tree hierachy upstream
virtual const GeoAlignableTransform* findAlignableTransform(const PVConstLink& physVol,
const alignedPhysNodes& alignNodes) const = 0;
/// Returns the next Geo alignable transform in the GeoModelTree upstream
virtual const GeoAlignableTransform* findAlignableTransform(const PVConstLink& physVol) const = 0;
/// Navigates throughs the volume to find a Box / Prd shape
......
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUONGEOMODELR4_IMUONREAOUDGEOMTOOL_H
......@@ -11,6 +11,9 @@
* create the ReadoutElements for each Muon Detector and append then to the
* MuonDetectorManager
* **/
#include <map>
class GeoFullPhysVol;
namespace MuonGMR4 {
class MuonDetectorManager;
......@@ -18,7 +21,8 @@ class IMuonReadoutGeomTool : virtual public IAlgTool {
public:
/// Gaudi interface ID
DeclareInterfaceID(IMuonReadoutGeomTool, 1, 0);
using physNodeMap = std::map<std::string, GeoFullPhysVol*>;
/// Retrieves the GeoModel from the GeoModelSvc and append the
/// ReadoutElements of the Given MuonDetectorTechnology to the
/// MuonDetectorManager
......
/*
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MUONGEOMODELR4_MUONGEOUTILITYTOOL_H
......@@ -28,11 +28,8 @@ class MuonGeoUtilityTool final : virtual public IMuonGeoUtilityTool, public AthA
// Destructor
virtual ~MuonGeoUtilityTool() override final;
alignedPhysNodes selectAlignableVolumes(const physNodeMap& publishedPhysVols,
const alignNodeMap& publishedAlignNodes) const override final;
const GeoAlignableTransform* findAlignableTransform(const PVConstLink& physVol) const override final;
const GeoAlignableTransform* findAlignableTransform(const PVConstLink& physVol,
const alignedPhysNodes& alignNodes) const override final;
const GeoShape* extractShape(const PVConstLink& physVol) const override final;
const GeoShape* extractShape(const GeoShape* inShape) const override final;
......
......@@ -111,15 +111,8 @@ StatusCode MdtReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
FactoryCache facCache{};
ATH_CHECK(readParameterBook(facCache));
const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
// Get the list of full phys volumes from SQLite, and create detector
// elements
using alignNodeMap = IMuonGeoUtilityTool::alignNodeMap;
using physNodeMap = IMuonGeoUtilityTool::physNodeMap;
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
// Get the list of full phys volumes from SQLite, and create detector elements
physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
alignNodeMap mapAlign = sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Muon");
alignedPhysNodes alignedNodes = m_geoUtilTool->selectAlignableVolumes(mapFPV, mapAlign);
#ifndef SIMULATIONBASE
SurfaceBoundSetPtr<Acts::LineBounds> tubeBounds = std::make_shared<SurfaceBoundSet<Acts::LineBounds>>();
SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
......@@ -150,7 +143,7 @@ StatusCode MdtReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
/// Skip the endcap chambers
define.physVol = pv;
define.chambDesign = key_tokens[1];
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol, alignedNodes);
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
/// Load first tube etc. from the parameter book table
ParamBookTable::const_iterator book_itr = facCache.parBook.find(define.chambDesign);
......
......@@ -175,15 +175,9 @@ StatusCode MmReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
// Get the list of full phys volumes from SQLite, and create detector
// elements
using alignNodeMap = IMuonGeoUtilityTool::alignNodeMap;
using physNodeMap = IMuonGeoUtilityTool::physNodeMap;
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
// Get the list of full phys volumes from SQLite, and create detector elements
/// Retrieve the list of full physical volumes & alignable nodes and connect them together afterwards
physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
alignNodeMap mapAlign = sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Muon");
alignedPhysNodes alignedNodes = m_geoUtilTool->selectAlignableVolumes(mapFPV, mapAlign);
#ifndef SIMULATIONBASE
SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds= std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
#endif
......@@ -217,7 +211,7 @@ StatusCode MmReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
ATH_MSG_DEBUG("Key "<<key<<" brought us "<<m_idHelperSvc->toStringDetEl(define.detElId));
define.physVol = pv;
define.chambDesign = key_tokens[0]+"_"+key_tokens[1]; // Recover the string denoted in WMM tables. e.g. chambDesign = "MM_SM1Q2"
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol, alignedNodes);
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
ATH_CHECK(loadDimensions(define, facCache));
#ifndef SIMULATIONBASE
define.layerBounds = layerBounds;
......
......@@ -21,7 +21,6 @@
using namespace ActsTrk;
namespace MuonGMR4{
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
using geoShapeWithShift = IMuonGeoUtilityTool::geoShapeWithShift;
MuonGeoUtilityTool::~MuonGeoUtilityTool() = default;
......@@ -166,23 +165,20 @@ std::string MuonGeoUtilityTool::dumpVolume(const PVConstLink& physVol, const std
return sstr.str();
}
alignedPhysNodes MuonGeoUtilityTool::selectAlignableVolumes(const physNodeMap& publishedPhysVols,
const alignNodeMap& publishedAlignNodes) const {
alignedPhysNodes result{};
for(const auto& [key, trans] : publishedAlignNodes) {
physNodeMap::const_iterator itr = publishedPhysVols.find(key);
if (itr == publishedPhysVols.end()) continue;
PVConstLink physVol{itr->second};
result[physVol] = trans;
const GeoAlignableTransform* MuonGeoUtilityTool::findAlignableTransform(const PVConstLink& physVol) const {
PVConstLink parent{physVol->getParent()}, child{physVol};
while (parent) {
const GeoGraphNode * const * node1 = parent->findChildNode(child);
const GeoGraphNode * const * fence = parent->getChildNode(0);
for(const GeoGraphNode * const * current = node1 - 1; current>=fence; current--) {
const GeoGraphNode* node{*current};
if (dynamic_cast<const GeoVPhysVol*>(node)) break;
const GeoAlignableTransform* alignTrans{dynamic_cast<const GeoAlignableTransform*>(node)};
if (alignTrans) return alignTrans;
}
child = parent;
parent = child->getParent();
}
return result;
}
const GeoAlignableTransform* MuonGeoUtilityTool::findAlignableTransform(const PVConstLink& physVol,
const alignedPhysNodes& alignNodes) const {
alignedPhysNodes::const_iterator itr = alignNodes.find(physVol);
if (itr != alignNodes.end()) return itr->second;
const PVConstLink parent = physVol->getParent();
if (parent) return findAlignableTransform(parent, alignNodes);
return nullptr;
}
......
......@@ -190,15 +190,10 @@ StatusCode RpcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
ATH_CHECK(readParameterBook(facCache));
const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
// Get the list of full phys volumes from SQLite, and create detector
// elements
using alignNodeMap = IMuonGeoUtilityTool::alignNodeMap;
using physNodeMap = IMuonGeoUtilityTool::physNodeMap;
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
// Get the list of full phys volumes from SQLite, and create detector elements
/// Retrieve the list of full physical volumes & alignable nodes and connect them together afterwards
physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
alignNodeMap mapAlign = sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Muon");
alignedPhysNodes alignedNodes = m_geoUtilTool->selectAlignableVolumes(mapFPV, mapAlign);
#ifndef SIMULATIONBASE
SurfaceBoundSetPtr<Acts::RectangleBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::RectangleBounds>>();
#endif
......@@ -231,7 +226,7 @@ StatusCode RpcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
defineArgs define{};
define.physVol = pv;
define.chambDesign = key_tokens[1];
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol, alignedNodes);
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
define.detElId = elementID;
ATH_MSG_VERBOSE("Key "<<key<<" lead to Identifier "<<m_idHelperSvc->toStringDetEl(elementID));
ATH_CHECK(loadDimensions(define, facCache));
......
......@@ -169,16 +169,9 @@ StatusCode TgcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
#endif
const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
// Get the list of full phys volumes from SQLite, and create detector
// elements
using alignNodeMap = IMuonGeoUtilityTool::alignNodeMap;
using physNodeMap = IMuonGeoUtilityTool::physNodeMap;
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
// Get the list of full phys volumes from SQLite, and create detector elements
/// Retrieve the list of full physical volumes & alignable nodes and connect them together afterwards
physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
alignNodeMap mapAlign = sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Muon");
alignedPhysNodes alignedNodes = m_geoUtilTool->selectAlignableVolumes(mapFPV, mapAlign);
for (auto& [key, pv] : mapFPV) {
/// The keys should be formatted like
/// <CHAMBERTYPE>_<STATIONNAME>_<STATIONETA>_<STATIONPHI>
......@@ -199,7 +192,7 @@ StatusCode TgcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
define.physVol = pv;
define.detElId = elementID;
define.chambDesign = key_tokens[0];
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol, alignedNodes);
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
#ifndef SIMULATIONBASE
define.layerBounds = layerBounds;
#endif
......
......@@ -165,16 +165,9 @@ StatusCode sTgcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
ATH_CHECK(readParameterBook(facCache));
const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
// Get the list of full phys volumes from SQLite, and create detector
// elements
// Get the list of full phys volumes from SQLite, and create detector elements
using alignNodeMap = IMuonGeoUtilityTool::alignNodeMap;
using physNodeMap = IMuonGeoUtilityTool::physNodeMap;
using alignedPhysNodes = IMuonGeoUtilityTool::alignedPhysNodes;
physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
alignNodeMap mapAlign = sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Muon");
alignedPhysNodes alignedNodes = m_geoUtilTool->selectAlignableVolumes(mapFPV, mapAlign);
#ifndef SIMULATIONBASE
SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
#endif
......@@ -210,7 +203,7 @@ StatusCode sTgcReadoutGeomTool::buildReadOutElements(MuonDetectorManager& mgr) {
/// Skip the endcap chambers
define.physVol = pv;
define.chambDesign = "sTGC_" + key_tokens[1];
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol, alignedNodes);
define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
ATH_MSG_VERBOSE("Key "<<key<<" lead to the identifier "<<m_idHelperSvc->toStringDetEl(define.detElId));
ATH_CHECK(loadDimensions(define, facCache));
std::unique_ptr<sTgcReadoutElement> readoutEle = std::make_unique<sTgcReadoutElement>(std::move(define));
......
......@@ -37,6 +37,11 @@ Identifier MdtReadoutElement::measurementId(const IdentifierHash& measHash) cons
tubeNumber(measHash) + 1);
}
StatusCode MdtReadoutElement::initElement() {
/// Check that the alignable node has been assigned
if(!alignableTransform()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
return StatusCode::FAILURE;
}
/// First check whether we're having tubes
if (!numLayers() || !numTubesInLay()) {
ATH_MSG_FATAL("The readout element "<< idHelperSvc()->toStringDetEl(identify())<<" has no tubes. Please check "<<std::endl<<m_pars);
......
......@@ -31,6 +31,10 @@ const parameterBook& MmReadoutElement::getParameters() const { return m_pars; }
StatusCode MmReadoutElement::initElement() {
ATH_MSG_DEBUG("Parameter book "<<parameterBook());
if(!alignableTransform()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
return StatusCode::FAILURE;
}
if (m_pars.layers.empty()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" doesn't have any layers defined");
return StatusCode::FAILURE;
......
......@@ -29,7 +29,12 @@ RpcReadoutElement::RpcReadoutElement(defineArgs&& args)
const parameterBook& RpcReadoutElement::getParameters() const { return m_pars; }
StatusCode RpcReadoutElement::initElement() {
StatusCode RpcReadoutElement::initElement() {
/// Check that the alignable node has been assigned
if(!alignableTransform()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Parameter book "<<parameterBook());
if (m_pars.layers.empty()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" doesn't have any layers defined");
......
......@@ -26,6 +26,12 @@ TgcReadoutElement::TgcReadoutElement(defineArgs&& args)
const parameterBook& TgcReadoutElement::getParameters() const { return m_pars; }
StatusCode TgcReadoutElement::initElement() {
if(!alignableTransform()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
return StatusCode::FAILURE;
}
/// Check that the readoutelement has sensor layouts
bool hasSensor{false};
for (size_t s = 0; s < m_pars.sensorLayouts.size(); ++s) {
......
......@@ -26,6 +26,11 @@ const parameterBook& sTgcReadoutElement::getParameters() const {return m_pars;}
StatusCode sTgcReadoutElement::initElement() {
ATH_MSG_DEBUG("Parameter book "<<parameterBook());
/// Check that the alignable node has been assigned
if(!alignableTransform()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" has no assigned alignable node");
return StatusCode::FAILURE;
}
if (m_pars.stripLayers.empty()) {
ATH_MSG_FATAL("The readout element "<<idHelperSvc()->toStringDetEl(identify())<<" doesn't have any layers defined");
return StatusCode::FAILURE;
......
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