7 #include <GaudiKernel/SystemOfUnits.h>
13 #include <GeoModelKernel/GeoFullPhysVol.h>
14 #include <GeoModelKernel/GeoPhysVol.h>
15 #include <GeoModelKernel/GeoTrd.h>
16 #include <GeoModelKernel/GeoTube.h>
18 #include <GeoModelRead/ReadGeoModel.h>
22 #ifndef SIMULATIONBASE
23 # include "Acts/Surfaces/TrapezoidBounds.hpp"
24 # include "Acts/Surfaces/LineBounds.hpp"
38 <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.
physVol));
39 const GeoShape* shape = m_geoUtilTool->extractShape(define.
physVol);
42 return StatusCode::FAILURE;
46 if (shape->typeID() == GeoTrd::getClassTypeID()) {
48 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
55 return StatusCode::FAILURE;
60 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
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;
73 std::endl<<std::endl<<m_geoUtilTool->dumpVolume(childVol));
75 idHelper.multilayer(define.
detElId),
83 bool chEndPlug{
false};
84 for (
unsigned int tube = 0 ;
tube < lay.nTubes(); ++
tube) {
85 constexpr std::string_view airTubeName{
"airTube"};
86 PVConstLink tubeVol{lay.getTubeNode(
tube)};
87 if (tubeVol->getLogVol()->getName() == airTubeName) {
89 }
else if (!chEndPlug) {
92 std::vector<physVolWithTrans> endPlugs = m_geoUtilTool->findAllLeafNodesByName(tubeVol,
"Endplug");
93 if (endPlugs.empty()) {
97 const GeoShape* plugShape = m_geoUtilTool->extractShape(endPlugs[0].volume);
98 if (plugShape->typeID() != GeoTube::getClassTypeID()){
99 ATH_MSG_FATAL(
"The shape "<<m_geoUtilTool->dumpShape(plugShape)<<
" is not a tube");
100 return StatusCode::FAILURE;
102 const GeoTube* plugTube =
static_cast<const GeoTube*
>(plugShape);
108 return StatusCode::SUCCESS;
114 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
116 ATH_MSG_FATAL(
"Error, the tool works exclusively from sqlite geometry inputs");
117 return StatusCode::FAILURE;
121 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
123 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>(
"Muon");
124 #ifndef SIMULATIONBASE
125 auto boundFactory = std::make_shared<Acts::SurfaceBoundFactory>();
127 for (
auto& [
key,
pv] : mapFPV) {
134 std::vector<std::string> key_tokens =
tokenize(
key,
"_");
135 if (key_tokens.size() != 5 ||
136 key_tokens[1].find(
"MDT") == std::string::npos)
141 define.detElId = idHelper.channelID(key_tokens[0].substr(0, 3),
147 return StatusCode::FAILURE;
149 ATH_MSG_DEBUG(
"Key "<<
key<<
" brought us "<<m_idHelperSvc->toStringDetEl(define.detElId));
152 define.chambDesign = key_tokens[1];
153 define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
156 ParamBookTable::const_iterator book_itr = facCache.parBook.find(define.chambDesign);
157 if (book_itr == facCache.parBook.end()) {
158 ATH_MSG_FATAL(
"There is no chamber called "<<define.chambDesign);
159 return StatusCode::FAILURE;
162 #ifndef SIMULATIONBASE
166 ATH_CHECK(loadDimensions(facCache, define));
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);
197 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
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");
216 return StatusCode::FAILURE;
221 paramTable = accessSvc->getRecordsetPtr(
"MdtCutTubes" ,
"");
222 if (paramTable->size() == 0) {
223 ATH_MSG_INFO(
"No information about cut mdt tubes has been found. Skipping.");
224 return StatusCode::SUCCESS;
227 const std::string
stName = record->getString(
"stationName");
228 const int stEta = record->getInt(
"stationEta");
229 const int stPhi = record->getInt(
"stationPhi");
230 const int multiLay = record->getInt(
"multiLayer");
231 const int tubeLay = record->getInt(
"tubeLayer");
235 ATH_MSG_FATAL(
"Failed to deduce valid Idnetifier "<<
stName<<
", "<<stEta<<
", "<<stPhi<<
","<<multiLay<<
", "<<tubeLay);
236 return StatusCode::FAILURE;
240 cutTubes.
firstTube = record->getInt(
"firstTube");
241 cutTubes.lastTube = record->getInt(
"lastTube");
242 cutTubes.unCutHalfLength = record->getDouble(
"uncutHalfLength");
243 ATH_MSG_VERBOSE(
"Found new uncut tube set in "<<m_idHelperSvc->toString(tubeId)<<
" tubes: ["
244 <<cutTubes.firstTube<<
"-"<<cutTubes.lastTube<<
"], length: "<< 2.*cutTubes.unCutHalfLength );
245 cache.
cutTubes[tubeId].insert(std::move(cutTubes));
248 return StatusCode::SUCCESS;