ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGMR4::MdtReadoutGeomTool Class Reference

Implementation of the IMuonReadoutGeomTool to construct MdtReadoutElements from the list of published full physical volumes and the WMDT meta data table. More...

#include <MdtReadoutGeomTool.h>

Inheritance diagram for MuonGMR4::MdtReadoutGeomTool:
Collaboration diagram for MuonGMR4::MdtReadoutGeomTool:

Classes

struct  FactoryCache

Public Member Functions

StatusCode buildReadOutElements (MuonDetectorManager &mgr) override final

Private Types

using parameterBook = MdtReadoutElement::parameterBook
using ParamBookTable = std::map<std::string, parameterBook>

Private Member Functions

StatusCode readParameterBook (FactoryCache &facCache) const
 Retrieves the auxillary tables from the database.
StatusCode loadDimensions (FactoryCache &facCache, MdtReadoutElement::defineArgs &args) const
 Loads the chamber dimensions from GeoModel.

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ServiceHandle< IGeoDbTagSvcm_geoDbTagSvc
PublicToolHandle< IMuonGeoUtilityToolm_geoUtilTool {this,"GeoUtilTool", "" }

Detailed Description

Implementation of the IMuonReadoutGeomTool to construct MdtReadoutElements from the list of published full physical volumes and the WMDT meta data table.

Definition at line 19 of file MdtReadoutGeomTool.h.

Member Typedef Documentation

◆ ParamBookTable

using MuonGMR4::MdtReadoutGeomTool::ParamBookTable = std::map<std::string, parameterBook>
private

Definition at line 36 of file MdtReadoutGeomTool.h.

◆ parameterBook

Member Function Documentation

◆ buildReadOutElements()

StatusCode MuonGMR4::MdtReadoutGeomTool::buildReadOutElements ( MuonDetectorManager & mgr)
finaloverride

The keys should be formatted like <STATION_NAME>_<MUON_CHAMBERTYPE>etc. The <MUON_CHAMBERTYPE> also indicates whether we're dealing with a MDT / TGC / CSC / RPC chamber If we are dealing with a MDT chamber, then there are 3 additional properties encoded into the chamber <STATIONETA><STATIONPHI>_ML

Skip the endcap chambers

Load first tube etc. from the parameter book table

Chamber dimensions are given from the GeoShape

Definition at line 110 of file MdtReadoutGeomTool.cxx.

110 {
111 ATH_CHECK(m_geoDbTagSvc.retrieve());
112 ATH_CHECK(m_idHelperSvc.retrieve());
113 ATH_CHECK(m_geoUtilTool.retrieve());
114 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
115 if (!sqliteReader) {
116 ATH_MSG_FATAL("Error, the tool works exclusively from sqlite geometry inputs");
117 return StatusCode::FAILURE;
118 }
119 FactoryCache facCache{};
120 ATH_CHECK(readParameterBook(facCache));
121 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
122 // Get the list of full phys volumes from SQLite, and create detector elements
123 physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
124#ifndef SIMULATIONBASE
125 auto boundFactory = std::make_shared<Acts::SurfaceBoundFactory>();
126#endif
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)
137 continue;
138
139 MdtReadoutElement::defineArgs define{};
140 bool isValid{false};
141 define.detElId = idHelper.channelID(key_tokens[0].substr(0, 3),
142 atoi(key_tokens[2]),
143 atoi(key_tokens[3]),
144 atoi(key_tokens[4]), 1, 1, isValid);
145 if (!isValid) {
146 ATH_MSG_FATAL("Failed to build a good identifier out of " << key);
147 return StatusCode::FAILURE;
148 }
149 ATH_MSG_DEBUG("Key "<<key<<" brought us "<<m_idHelperSvc->toStringDetEl(define.detElId));
151 define.physVol = pv;
152 define.chambDesign = key_tokens[1];
153 define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
154
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;
160 }
161 static_cast<parameterBook&>(define) = book_itr->second;
162#ifndef SIMULATIONBASE
163 define.boundFactory = boundFactory;
164 #endif
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)));
169 }
170 return StatusCode::SUCCESS;
171}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
PublicToolHandle< IMuonGeoUtilityTool > m_geoUtilTool
StatusCode loadDimensions(FactoryCache &facCache, MdtReadoutElement::defineArgs &args) const
Loads the chamber dimensions from GeoModel.
StatusCode readParameterBook(FactoryCache &facCache) const
Retrieves the auxillary tables from the database.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
MdtReadoutElement::parameterBook parameterBook
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...

◆ loadDimensions()

StatusCode MuonGMR4::MdtReadoutGeomTool::loadDimensions ( FactoryCache & facCache,
MdtReadoutElement::defineArgs & args ) const
private

Loads the chamber dimensions from GeoModel.

The trapezoid defines the length of the chamber including the extra material stemming from the faraday cache etc.

Loop over the child nodes of the full mdt tube layer volume to pick the ones representing the tubeLayer – their logical volume is callded TubeLayerLog. The node right before the child volume is the associated transform node

Next check all tubes whether they're made up out of air or not. If yes, then there's no tube at this place and add the corresponding has hto the list.

Check for the endplug volumes

Either all tubes have an endplug or none

Definition at line 34 of file MdtReadoutGeomTool.cxx.

35 {
36
37 ATH_MSG_VERBOSE("Load dimensions of "<<m_idHelperSvc->toString(define.detElId)
38 <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.physVol));
39 const GeoShape* shape = m_geoUtilTool->extractShape(define.physVol);
40 if (!shape) {
41 ATH_MSG_FATAL("Failed to deduce a valid shape for "<<m_idHelperSvc->toString(define.detElId));
42 return StatusCode::FAILURE;
43 }
46 if (shape->typeID() == GeoTrd::getClassTypeID()) {
47 ATH_MSG_VERBOSE("Extracted shape "<<m_geoUtilTool->dumpShape(shape));
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;
53 } else {
54 ATH_MSG_FATAL("Unknown shape type "<<shape->type());
55 return StatusCode::FAILURE;
56 }
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") {
65 continue;
66 }
67 const GeoTransform* trfNode = dynamic_cast<const GeoTransform*>(*define.physVol->getChildNode(ch-1));
68 if (!trfNode) {
69 ATH_MSG_FATAL("Expect a GeoTransform node right before the tubelayer node");
70 return StatusCode::FAILURE;
71 }
72 ATH_MSG_VERBOSE("Add new tube layer "<<m_idHelperSvc->toStringDetEl(define.detElId)<<
73 std::endl<<std::endl<<m_geoUtilTool->dumpVolume(childVol));
74 const Identifier tubeLayId = idHelper.channelID(define.detElId,
75 idHelper.multilayer(define.detElId),
76 define.tubeLayers.size() +1, 1);
77 MdtTubeLayerPtr newLay = std::make_unique<MdtTubeLayer>(childVol, trfNode, facCache.cutTubes[tubeLayId]);
78 define.tubeLayers.emplace_back(*facCache.tubeLayers.insert(newLay).first);
79
80 const MdtTubeLayer& lay{*define.tubeLayers.back()};
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) {
88 define.removedTubes.insert(MdtReadoutElement::measurementHash(define.tubeLayers.size(), tube+1));
89 } else if (!chEndPlug) {
91 chEndPlug = true;
92 std::vector<physVolWithTrans> endPlugs = m_geoUtilTool->findAllLeafNodesByName(tubeVol, "Endplug");
93 if (endPlugs.empty()) {
95 continue;
96 }
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;
101 }
102 const GeoTube* plugTube = static_cast<const GeoTube*>(plugShape);
103 define.endPlugLength = plugTube->getZHalfLength();
104 }
105 }
106 }
107 define.readoutSide = facCache.readoutOnLeftSide.count(m_idHelperSvc->chamberId(define.detElId)) ? -1. : 1.;
108 return StatusCode::SUCCESS;
109}
#define ATH_MSG_VERBOSE(x)
int multilayer(const Identifier &id) const
Access to components of the ID.
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
GeoModel::TransientConstSharedPtr< MdtTubeLayer > MdtTubeLayerPtr

◆ readParameterBook()

StatusCode MuonGMR4::MdtReadoutGeomTool::readParameterBook ( FactoryCache & facCache) const
private

Retrieves the auxillary tables from the database.

Load the chamber that have their readout on the negative z-side

List of cut tubes

Definition at line 172 of file MdtReadoutGeomTool.cxx.

172 {
173 ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),
174 name());
175 ATH_CHECK(accessSvc.retrieve());
176 IRDBRecordset_ptr paramTable = accessSvc->getRecordsetPtr("WMDT", "");
177 if (paramTable->size() == 0) {
178 ATH_MSG_FATAL("Empty parameter book table found");
179 return StatusCode::FAILURE;
180 }
181 ATH_MSG_VERBOSE("Found the " << paramTable->nodeName() << " ["
182 << paramTable->tagName() << "] table with "
183 << paramTable->size() << " records");
184 for (const IRDBRecord_ptr& record : *paramTable) {
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);
195 }
197 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
198 paramTable = accessSvc->getRecordsetPtr("MdtTubeROSides" ,"");
199 if (paramTable->size() == 0) {
200 ATH_MSG_FATAL("Empty parameter book table found");
201 return StatusCode::FAILURE;
202 }
203 ATH_MSG_VERBOSE("Found the " << paramTable->nodeName() << " ["
204 << paramTable->tagName() << "] table with "
205 << paramTable->size() << " records");
206 for (const IRDBRecord_ptr& record : *paramTable) {
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");
211 if (side == -1) {
212 bool isValid{false};
213 cache.readoutOnLeftSide.insert(idHelper.elementID(stName,stEta,stPhi, isValid));
214 if (!isValid) {
215 ATH_MSG_FATAL("station "<<stName<<" eta: "<<stEta<<" phi: "<<stPhi<<" is unknown.");
216 return StatusCode::FAILURE;
217 }
218 }
219 }
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;
225 }
226 for (const IRDBRecord_ptr& record : *paramTable) {
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");
232 bool isValid{false};
233 const Identifier tubeId = idHelper.channelID(stName, stEta, stPhi, multiLay, tubeLay, 1 , isValid);
234 if (!isValid) {
235 ATH_MSG_FATAL("Failed to deduce valid Idnetifier "<<stName<<", "<<stEta<<", "<<stPhi<<","<<multiLay<<", "<<tubeLay);
236 return StatusCode::FAILURE;
237 }
238 FactoryCache::CutTubes cutTubes{};
239
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));
246
247 }
248 return StatusCode::SUCCESS;
249}
#define ATH_MSG_INFO(x)
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
virtual std::string tagName() const =0
virtual std::string nodeName() const =0
virtual unsigned int size() const =0
Identifier elementID(int stationName, int stationEta, int stationPhi) const
const std::string & stName(StIndex index)
convert StIndex into a string

Member Data Documentation

◆ m_geoDbTagSvc

ServiceHandle<IGeoDbTagSvc> MuonGMR4::MdtReadoutGeomTool::m_geoDbTagSvc
private
Initial value:
{this, "GeoDbTagSvc",
"GeoDbTagSvc"}

Definition at line 31 of file MdtReadoutGeomTool.h.

31 {this, "GeoDbTagSvc",
32 "GeoDbTagSvc"};

◆ m_geoUtilTool

PublicToolHandle<IMuonGeoUtilityTool> MuonGMR4::MdtReadoutGeomTool::m_geoUtilTool {this,"GeoUtilTool", "" }
private

Definition at line 34 of file MdtReadoutGeomTool.h.

34{this,"GeoUtilTool", "" };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonGMR4::MdtReadoutGeomTool::m_idHelperSvc
private
Initial value:
{
this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}

Definition at line 28 of file MdtReadoutGeomTool.h.

28 {
29 this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

The documentation for this class was generated from the following files: