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>
23# include "Acts/Surfaces/TrapezoidBounds.hpp"
24# include "Acts/Surfaces/LineBounds.hpp"
42 return StatusCode::FAILURE;
46 if (shape->typeID() == GeoTrd::getClassTypeID()) {
48 const GeoTrd* trd =
static_cast<const GeoTrd*
>(shape);
49 define.
longHalfX = std::max(trd->getYHalfLength1(), trd->getYHalfLength2()) * Gaudi::Units::mm;
50 define.
shortHalfX = std::min(trd->getYHalfLength1(), trd->getYHalfLength2())* Gaudi::Units::mm;
51 define.
halfY = trd->getZHalfLength()* Gaudi::Units::mm;
52 define.
halfHeight = std::max(trd->getXHalfLength1(), trd->getXHalfLength2()) * Gaudi::Units::mm;
55 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;
83 bool chEndPlug{
false};
84 for (
unsigned int tube = 0 ; tube < lay.
nTubes(); ++tube) {
85 constexpr std::string_view airTubeName{
"airTube"};
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()){
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;
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)
146 ATH_MSG_FATAL(
"Failed to build a good identifier out of " << key);
147 return StatusCode::FAILURE;
157 if (book_itr == facCache.
parBook.end()) {
159 return StatusCode::FAILURE;
162#ifndef SIMULATIONBASE
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");
186 pars.tubeWall = record->getDouble(
"TUBWAL") * Gaudi::Units::cm;
187 pars.tubePitch = record->getDouble(
"TUBPIT") * Gaudi::Units::cm;
188 pars.tubeInnerRad = record->getDouble(
"TUBRAD") * Gaudi::Units::cm;
189 pars.endPlugLength = record->getDouble(
"TUBDEA") * Gaudi::Units::cm;
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);
194 cache.
parBook[key] = std::move(pars);
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;
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");
245 cache.
cutTubes[tubeId].insert(std::move(cutTubes));
248 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
virtual std::string tagName() const =0
virtual std::string nodeName() const =0
virtual unsigned int size() const =0
int multilayer(const Identifier &id) const
Access to components of the ID.
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
Helper struct to retrieve the tube lengths and the tube centers directly from the GeoModel tree.
PVConstLink getTubeNode(unsigned int tube) const
returns the PVConst link to the n-th tube [0 - nTubes() -1]
unsigned int nTubes() const
Returns the number of tubes in the layer.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
GeoModel::TransientConstSharedPtr< MdtTubeLayer > MdtTubeLayerPtr
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
double halfY
Length ~ number of tubes.
double endPlugLength
Depth of the endplug into the active tube volume.
double halfHeight
Height of the chamber ~ number of layers.
double shortHalfX
The chambers have either a rectangular or a trapezoidal shape to first approximation.
std::shared_ptr< Acts::SurfaceBoundFactory > boundFactory
Sets of surface bounds which is shared amongst all readout elements used to assign the same bound obj...
double readoutSide
Is the readout chip at positive or negative Z?
std::vector< MdtTubeLayerPtr > tubeLayers
Vector defining the position of all tubes in each tube layer.
std::set< IdentifierHash > removedTubes
List of tube places without tubes.
unsigned int firstTube
First tube of the cut.
double unCutHalfLength
Tube length before cut.
unsigned int lastTube
Last tube of the cut.
Identifier detElId
ATLAS identifier.
GeoIntrusivePtr< GeoVFullPhysVol > physVol
Pointer to the underlying physical volume in GeoModel.
const GeoAlignableTransform * alignTransform
Pointer to the alignable transformation.
std::string chambDesign
chamber design name as it's occuring in the parameter book tables E.g. BMS5, RPC10,...