ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
MuonGMR4::MdtReadoutGeomTool Class Reference

#include <MdtReadoutGeomTool.h>

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

Classes

struct  FactoryCache
 

Public Member Functions

 MdtReadoutGeomTool (const std::string &type, const std::string &name, const IInterface *parent)
 
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. More...
 
StatusCode loadDimensions (FactoryCache &facCache, MdtReadoutElement::defineArgs &args) const
 Loads the chamber dimensions from GeoModel. More...
 

Private Attributes

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

Detailed Description

Definition at line 18 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

Definition at line 35 of file MdtReadoutGeomTool.h.

Constructor & Destructor Documentation

◆ MdtReadoutGeomTool()

MuonGMR4::MdtReadoutGeomTool::MdtReadoutGeomTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 36 of file MdtReadoutGeomTool.cxx.

39  : base_class{type, name, parent} {}

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 117 of file MdtReadoutGeomTool.cxx.

117  {
118  ATH_CHECK(m_geoDbTagSvc.retrieve());
119  ATH_CHECK(m_idHelperSvc.retrieve());
120  ATH_CHECK(m_geoUtilTool.retrieve());
121  GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
122  if (!sqliteReader) {
123  ATH_MSG_FATAL("Error, the tool works exclusively from sqlite geometry inputs");
124  return StatusCode::FAILURE;
125  }
126  FactoryCache facCache{};
127  ATH_CHECK(readParameterBook(facCache));
128  const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
129  // Get the list of full phys volumes from SQLite, and create detector elements
130  physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
131 #ifndef SIMULATIONBASE
132  SurfaceBoundSetPtr<Acts::LineBounds> tubeBounds = std::make_shared<SurfaceBoundSet<Acts::LineBounds>>();
133  SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
134 #endif
135  for (auto& [key, pv] : mapFPV) {
142  std::vector<std::string> key_tokens = tokenize(key, "_");
143  if (key_tokens.size() != 5 ||
144  key_tokens[1].find("MDT") == std::string::npos)
145  continue;
146 
148  bool isValid{false};
149  define.detElId = idHelper.channelID(key_tokens[0].substr(0, 3),
150  atoi(key_tokens[2]),
151  atoi(key_tokens[3]),
152  atoi(key_tokens[4]), 1, 1, isValid);
153  if (!isValid) {
154  ATH_MSG_FATAL("Failed to build a good identifier out of " << key);
155  return StatusCode::FAILURE;
156  }
157  ATH_MSG_DEBUG("Key "<<key<<" brought us "<<m_idHelperSvc->toStringDetEl(define.detElId));
159  define.physVol = pv;
160  define.chambDesign = key_tokens[1];
161  define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
162 
164  ParamBookTable::const_iterator book_itr = facCache.parBook.find(define.chambDesign);
165  if (book_itr == facCache.parBook.end()) {
166  ATH_MSG_FATAL("There is no chamber called "<<define.chambDesign);
167  return StatusCode::FAILURE;
168  }
169  static_cast<parameterBook&>(define) = book_itr->second;
170 #ifndef SIMULATIONBASE
171  define.tubeBounds = tubeBounds;
172  define.layerBounds = layerBounds;
173  #endif
175  ATH_CHECK(loadDimensions(facCache, define));
176  std::unique_ptr<MdtReadoutElement> mdtDetectorElement = std::make_unique<MdtReadoutElement>(std::move(define));
177  ATH_CHECK(mgr.addMdtReadoutElement(std::move(mdtDetectorElement)));
178  }
179  return StatusCode::SUCCESS;
180 }

◆ 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 41 of file MdtReadoutGeomTool.cxx.

42  {
43 
44  ATH_MSG_VERBOSE("Load dimensions of "<<m_idHelperSvc->toString(define.detElId)
45  <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.physVol));
46  const GeoShape* shape = m_geoUtilTool->extractShape(define.physVol);
47  if (!shape) {
48  ATH_MSG_FATAL("Failed to deduce a valid shape for "<<m_idHelperSvc->toString(define.detElId));
49  return StatusCode::FAILURE;
50  }
53  if (shape->typeID() == GeoTrd::getClassTypeID()) {
54  ATH_MSG_VERBOSE("Extracted shape "<<m_geoUtilTool->dumpShape(shape));
55  const GeoTrd* trd = static_cast<const GeoTrd*>(shape);
56  define.longHalfX = std::max(trd->getYHalfLength1(), trd->getYHalfLength2()) * Gaudi::Units::mm;
57  define.shortHalfX = std::min(trd->getYHalfLength1(), trd->getYHalfLength2())* Gaudi::Units::mm;
58  define.halfY = trd->getZHalfLength()* Gaudi::Units::mm;
59  define.halfHeight = std::max(trd->getXHalfLength1(), trd->getXHalfLength2()) * Gaudi::Units::mm;
60  } else {
61  ATH_MSG_FATAL("Unknown shape type "<<shape->type());
62  return StatusCode::FAILURE;
63  }
67  const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
68  for (unsigned int ch = 1; ch < define.physVol->getNChildNodes(); ++ch) {
69  const GeoGraphNode* childNode = (*define.physVol->getChildNode(ch));
70  const GeoVPhysVol* childVol = dynamic_cast<const GeoVPhysVol*>(childNode);
71  if (!childVol || childVol->getLogVol()->getName() != "TubeLayerLog") {
72  continue;
73  }
74  const GeoTransform* trfNode = dynamic_cast<const GeoTransform*>(*define.physVol->getChildNode(ch-1));
75  if (!trfNode) {
76  ATH_MSG_FATAL("Expect a GeoTransform node right before the tubelayer node");
77  return StatusCode::FAILURE;
78  }
79  ATH_MSG_VERBOSE("Add new tube layer "<<m_idHelperSvc->toStringDetEl(define.detElId)<<
80  std::endl<<std::endl<<m_geoUtilTool->dumpVolume(childVol));
81  const Identifier tubeLayId = idHelper.channelID(define.detElId,
82  idHelper.multilayer(define.detElId),
83  define.tubeLayers.size() +1, 1);
84  MdtTubeLayerPtr newLay = std::make_unique<MdtTubeLayer>(childVol, trfNode, facCache.cutTubes[tubeLayId]);
85  define.tubeLayers.emplace_back(*facCache.tubeLayers.insert(newLay).first);
86 
87  const MdtTubeLayer& lay{*define.tubeLayers.back()};
90  bool chEndPlug{false};
91  for (unsigned int tube = 0 ; tube < lay.nTubes(); ++tube) {
92  constexpr std::string_view airTubeName{"airTube"};
93  PVConstLink tubeVol{lay.getTubeNode(tube)};
94  if (tubeVol->getLogVol()->getName() == airTubeName) {
95  define.removedTubes.insert(MdtReadoutElement::measurementHash(define.tubeLayers.size(), tube+1));
96  } else if (!chEndPlug) {
98  chEndPlug = true;
99  std::vector<physVolWithTrans> endPlugs = m_geoUtilTool->findAllLeafNodesByName(tubeVol, "Endplug");
100  if (endPlugs.empty()) {
102  continue;
103  }
104  const GeoShape* plugShape = m_geoUtilTool->extractShape(endPlugs[0].volume);
105  if (plugShape->typeID() != GeoTube::getClassTypeID()){
106  ATH_MSG_FATAL("The shape "<<m_geoUtilTool->dumpShape(plugShape)<<" is not a tube");
107  return StatusCode::FAILURE;
108  }
109  const GeoTube* plugTube = static_cast<const GeoTube*>(plugShape);
110  define.endPlugLength = plugTube->getZHalfLength();
111  }
112  }
113  }
114  define.readoutSide = facCache.readoutOnLeftSide.count(m_idHelperSvc->chamberId(define.detElId)) ? -1. : 1.;
115  return StatusCode::SUCCESS;
116 }

◆ 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 181 of file MdtReadoutGeomTool.cxx.

181  {
182  ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),
183  name());
184  ATH_CHECK(accessSvc.retrieve());
185  IRDBRecordset_ptr paramTable = accessSvc->getRecordsetPtr("WMDT", "");
186  if (paramTable->size() == 0) {
187  ATH_MSG_FATAL("Empty parameter book table found");
188  return StatusCode::FAILURE;
189  }
190  ATH_MSG_VERBOSE("Found the " << paramTable->nodeName() << " ["
191  << paramTable->tagName() << "] table with "
192  << paramTable->size() << " records");
193  for (const IRDBRecord_ptr& record : *paramTable) {
195  pars.tubeWall = record->getDouble("TUBWAL") * Gaudi::Units::cm;
196  pars.tubePitch = record->getDouble("TUBPIT") * Gaudi::Units::cm;
197  pars.tubeInnerRad = record->getDouble("TUBRAD") * Gaudi::Units::cm;
198  pars.endPlugLength = record->getDouble("TUBDEA") * Gaudi::Units::cm;
199  pars.radLengthX0 = record->getDouble("X0");
200  unsigned int nLay = record->getInt("LAYMDT");
201  const std::string key {record->getString("WMDT_TYPE")};
202  ATH_MSG_DEBUG("Extracted parameters " <<pars<<" number of layers: "<<nLay<<" will be safed under key "<<key);
203  cache.parBook[key] = std::move(pars);
204  }
206  const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
207  paramTable = accessSvc->getRecordsetPtr("MdtTubeROSides" ,"");
208  if (paramTable->size() == 0) {
209  ATH_MSG_FATAL("Empty parameter book table found");
210  return StatusCode::FAILURE;
211  }
212  ATH_MSG_VERBOSE("Found the " << paramTable->nodeName() << " ["
213  << paramTable->tagName() << "] table with "
214  << paramTable->size() << " records");
215  for (const IRDBRecord_ptr& record : *paramTable) {
216  const std::string stName = record->getString("stationName");
217  const int stEta = record->getInt("stationEta");
218  const int stPhi = record->getInt("stationPhi");
219  const int side = record->getInt("side");
220  if (side == -1) {
221  bool isValid{false};
222  cache.readoutOnLeftSide.insert(idHelper.elementID(stName,stEta,stPhi, isValid));
223  if (!isValid) {
224  ATH_MSG_FATAL("station "<<stName<<" eta: "<<stEta<<" phi: "<<stPhi<<" is unknown.");
225  return StatusCode::FAILURE;
226  }
227  }
228  }
230  paramTable = accessSvc->getRecordsetPtr("MdtCutTubes" ,"");
231  if (paramTable->size() == 0) {
232  ATH_MSG_INFO("No information about cut mdt tubes has been found. Skipping.");
233  return StatusCode::SUCCESS;
234  }
235  for (const IRDBRecord_ptr& record : *paramTable) {
236  const std::string stName = record->getString("stationName");
237  const int stEta = record->getInt("stationEta");
238  const int stPhi = record->getInt("stationPhi");
239  const int multiLay = record->getInt("multiLayer");
240  const int tubeLay = record->getInt("tubeLayer");
241  bool isValid{false};
242  const Identifier tubeId = idHelper.channelID(stName, stEta, stPhi, multiLay, tubeLay, 1 , isValid);
243  if (!isValid) {
244  ATH_MSG_FATAL("Failed to deduce valid Idnetifier "<<stName<<", "<<stEta<<", "<<stPhi<<","<<multiLay<<", "<<tubeLay);
245  return StatusCode::FAILURE;
246  }
247  FactoryCache::CutTubes cutTubes{};
248 
249  cutTubes.firstTube = record->getInt("firstTube");
250  cutTubes.lastTube = record->getInt("lastTube");
251  cutTubes.unCutHalfLength = record->getDouble("uncutHalfLength");
252  ATH_MSG_VERBOSE("Found new uncut tube set in "<<m_idHelperSvc->toString(tubeId)<<" tubes: ["
253  <<cutTubes.firstTube<<"-"<<cutTubes.lastTube<<"], length: "<< 2.*cutTubes.unCutHalfLength );
254  cache.cutTubes[tubeId].insert(std::move(cutTubes));
255 
256  }
257  return StatusCode::SUCCESS;
258 }

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.

◆ m_geoUtilTool

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

Definition at line 34 of file MdtReadoutGeomTool.h.

◆ 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.


The documentation for this class was generated from the following files:
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
MuonGMR4::MdtReadoutElement::parameterBook::tubeBounds
ActsTrk::SurfaceBoundSetPtr< Acts::LineBounds > tubeBounds
Sets of surface bounds which is shared amongst all readout elements used to assign the same bound obj...
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.h:69
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonGMR4::MdtTubeLayerPtr
GeoModel::TransientConstSharedPtr< MdtTubeLayer > MdtTubeLayerPtr
Definition: MdtTubeLayer.h:17
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CxxUtils::tokenize
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition: Control/CxxUtils/Root/StringUtils.cxx:15
MuonGMR4::MdtReadoutElement::measurementHash
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:225
MuonGMR4::MdtReadoutGeomTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: MdtReadoutGeomTool.h:31
MuonGMR4::MdtReadoutGeomTool::readParameterBook
StatusCode readParameterBook(FactoryCache &facCache) const
Retrieves the auxillary tables from the database.
Definition: MdtReadoutGeomTool.cxx:181
MuonGMR4::MdtReadoutGeomTool::m_geoUtilTool
PublicToolHandle< IMuonGeoUtilityTool > m_geoUtilTool
Definition: MdtReadoutGeomTool.h:34
TRT::Hit::side
@ side
Definition: HitInfo.h:83
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGMR4::MdtTubeLayer::CutTubes::firstTube
unsigned int firstTube
First tube of the cut.
Definition: MdtTubeLayer.h:38
MuonGMR4::MdtReadoutGeomTool::parameterBook
MdtReadoutElement::parameterBook parameterBook
Definition: MdtReadoutGeomTool.h:35
MdtIdHelper
Definition: MdtIdHelper.h:61
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
min
#define min(a, b)
Definition: cfImp.cxx:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonGMR4::MdtReadoutGeomTool::loadDimensions
StatusCode loadDimensions(FactoryCache &facCache, MdtReadoutElement::defineArgs &args) const
Loads the chamber dimensions from GeoModel.
Definition: MdtReadoutGeomTool.cxx:41
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IRDBRecord_ptr
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
Definition: IRDBRecordset.h:23
MuonGMR4::MdtReadoutGeomTool::FactoryCache::CutTubes
MdtTubeLayer::CutTubes CutTubes
Definition: MdtReadoutGeomTool.h:43
python.changerun.pv
pv
Definition: changerun.py:81
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
ActsTrk::SurfaceBoundSetPtr
std::shared_ptr< SurfaceBoundSet< BoundType > > SurfaceBoundSetPtr
Aberivation to create a new SurfaceBoundSetPtr.
Definition: Tracking/Acts/ActsGeoUtils/ActsGeoUtils/Defs.h:19
calibdata.tube
tube
Definition: calibdata.py:31
MuonGMR4::defineArgs
RpcReadoutElement::defineArgs defineArgs
Definition: RpcReadoutGeomTool.cxx:37
MuonGMR4::MdtReadoutGeomTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtReadoutGeomTool.h:28
ServiceHandle< IRDBAccessSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14