6 #include <GaudiKernel/SystemOfUnits.h>
12 #include <GeoModelKernel/GeoFullPhysVol.h>
13 #include <GeoModelKernel/GeoPhysVol.h>
14 #include <GeoModelKernel/GeoTrd.h>
15 #include <GeoModelKernel/GeoTube.h>
17 #include <GeoModelRead/ReadGeoModel.h>
28 MdtReadoutGeomTool::MdtReadoutGeomTool(
const std::string&
type,
29 const std::string&
name,
32 declareInterface<IMuonReadoutGeomTool>(
this);
43 return StatusCode::FAILURE;
47 if (shape->typeID() == GeoTrd::getClassTypeID()) {
49 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
56 return StatusCode::FAILURE;
61 for (
unsigned int ch = 1;
ch < define.
physVol->getNChildNodes(); ++
ch) {
62 const GeoGraphNode* childNode = (*define.
physVol->getChildNode(
ch));
63 const GeoVPhysVol* childVol =
dynamic_cast<const GeoVPhysVol*
>(childNode);
64 if (!childVol || childVol->getLogVol()->getName() !=
"TubeLayerLog") {
67 const GeoTransform* trfNode =
dynamic_cast<const GeoTransform*
>(*define.
physVol->getChildNode(
ch-1));
69 ATH_MSG_FATAL(
"Expect a GeoTransform node right before the tubelayer node");
70 return StatusCode::FAILURE;
75 MdtTubeLayerPtr newLay = std::make_unique<MdtTubeLayer>(childVol, trfNode);
81 bool chEndPlug{
false};
82 for (
unsigned int tube = 0 ;
tube < lay.nTubes(); ++
tube) {
83 constexpr std::string_view airTubeName{
"airTube"};
84 PVConstLink tubeVol{lay.getTubeNode(
tube)};
85 if (tubeVol->getLogVol()->getName() == airTubeName) {
87 }
else if (!chEndPlug) {
90 std::vector<physVolWithTrans> endPlugs =
m_geoUtilTool->findAllLeafNodesByName(tubeVol,
"Endplug");
91 if (endPlugs.empty()) {
95 const GeoShape* plugShape =
m_geoUtilTool->extractShape(endPlugs[0].volume);
96 if (plugShape->typeID() != GeoTube::getClassTypeID()){
98 return StatusCode::FAILURE;
100 const GeoTube* plugTube =
static_cast<const GeoTube*
>(plugShape);
106 return StatusCode::SUCCESS;
112 GeoModelIO::ReadGeoModel* sqliteReader =
m_geoDbTagSvc->getSqliteReader();
114 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
115 return StatusCode::FAILURE;
121 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
122 #ifndef SIMULATIONBASE
126 for (
auto& [
key,
pv] : mapFPV) {
133 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
134 if (key_tokens.size() != 5 ||
135 key_tokens[1].find(
"MDT") == std::string::npos)
140 define.detElId = idHelper.channelID(key_tokens[0].substr(0, 3),
146 return StatusCode::FAILURE;
151 define.chambDesign = key_tokens[1];
152 define.alignTransform =
m_geoUtilTool->findAlignableTransform(define.physVol);
155 ParamBookTable::const_iterator book_itr = facCache.parBook.find(define.chambDesign);
156 if (book_itr == facCache.parBook.end()) {
157 ATH_MSG_FATAL(
"There is no chamber called "<<define.chambDesign);
158 return StatusCode::FAILURE;
161 #ifndef SIMULATIONBASE
163 define.layerBounds = layerBounds;
167 std::unique_ptr<MdtReadoutElement> mdtDetectorElement = std::make_unique<MdtReadoutElement>(std::move(define));
168 ATH_CHECK(
mgr.addMdtReadoutElement(std::move(mdtDetectorElement)));
170 return StatusCode::SUCCESS;
177 if (paramTable->size() == 0) {
179 return StatusCode::FAILURE;
182 << paramTable->tagName() <<
"] table with "
183 << paramTable->size() <<
" records");
190 pars.radLengthX0 = record->getDouble(
"X0");
191 unsigned int nLay = record->getInt(
"LAYMDT");
192 const std::string
key {record->getString(
"WMDT_TYPE")};
193 ATH_MSG_DEBUG(
"Extracted parameters " <<
pars<<
" number of layers: "<<nLay<<
" will be safed under key "<<
key);
198 paramTable = accessSvc->getRecordsetPtr(
"MdtTubeROSides" ,
"");
199 if (paramTable->size() == 0) {
201 return StatusCode::FAILURE;
204 << paramTable->tagName() <<
"] table with "
205 << paramTable->size() <<
" records");
207 const std::string stName = record->getString(
"stationName");
208 const int stEta = record->getInt(
"stationEta");
209 const int stPhi = record->getInt(
"stationPhi");
210 const int side = record->getInt(
"side");
215 ATH_MSG_FATAL(
"station "<<stName<<
" eta: "<<stEta<<
" phi: "<<stPhi<<
" is unknown.");
216 return StatusCode::FAILURE;
220 return StatusCode::SUCCESS;