Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonGMR4::TgcReadoutGeomTool Class Reference

#include <TgcReadoutGeomTool.h>

Inheritance diagram for MuonGMR4::TgcReadoutGeomTool:
Collaboration diagram for MuonGMR4::TgcReadoutGeomTool:

Classes

struct  FactoryCache
 
struct  wTgcTable
 Helper struct to cache the essential readout parameters from the WTGC tables. More...
 

Public Member Functions

 TgcReadoutGeomTool (const std::string &type, const std::string &name, const IInterface *parent)
 
StatusCode buildReadOutElements (MuonDetectorManager &mgr) override final
 

Private Member Functions

StatusCode writeSectorMapping (const MuonDetectorManager &mgr) const
 Map the Tgc sectors to the classical Muon System sectors. More...
 
StatusCode readParameterBook (FactoryCache &cache)
 Retrieves the auxillary tables from the database. More...
 
StatusCode loadDimensions (TgcReadoutElement::defineArgs &args, FactoryCache &factory)
 Loads the chamber dimensions from GeoModel. More...
 
IdentifierHash layerHash (const TgcReadoutElement::defineArgs &args, const int gasGap, const int doubPhi, const bool measPhi) const
 

Private Attributes

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

Detailed Description

Definition at line 19 of file TgcReadoutGeomTool.h.

Constructor & Destructor Documentation

◆ TgcReadoutGeomTool()

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

Definition at line 39 of file TgcReadoutGeomTool.cxx.

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

Member Function Documentation

◆ buildReadOutElements()

StatusCode MuonGMR4::TgcReadoutGeomTool::buildReadOutElements ( MuonDetectorManager mgr)
finaloverride

Retrieve the list of full physical volumes & alignable nodes and connect them together afterwards

The keys should be formatted like <CHAMBERTYPE>_<STATIONNAME>_<STATIONETA>_<STATIONPHI> where CHAMBERTYPE has to start with TGC

Retrieve first the station Identifier

Definition at line 155 of file TgcReadoutGeomTool.cxx.

155  {
156  ATH_CHECK(m_geoDbTagSvc.retrieve());
157  ATH_CHECK(m_idHelperSvc.retrieve());
158  ATH_CHECK(m_geoUtilTool.retrieve());
159  GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
160  if (!sqliteReader) {
161  ATH_MSG_FATAL("Error, the tool works exclusively from sqlite geometry inputs");
162  return StatusCode::FAILURE;
163  }
164 
165  FactoryCache facCache{};
166  ATH_CHECK(readParameterBook(facCache));
167 
168 #ifndef SIMULATIONBASE
169  SurfaceBoundSetPtr<Acts::TrapezoidBounds> layerBounds = std::make_shared<SurfaceBoundSet<Acts::TrapezoidBounds>>();
170 #endif
171  const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
172  // Get the list of full phys volumes from SQLite, and create detector elements
174  physNodeMap mapFPV = sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Muon");
175  for (auto& [key, pv] : mapFPV) {
179  std::vector<std::string> key_tokens = tokenize(key, "_");
180  if (key_tokens.size() < 4 ||
181  !key_tokens[0].starts_with( "TGC"))
182  continue;
183 
184  bool isValid{false};
185  const Identifier elementID = idHelper.elementID(key_tokens[1].substr(0,3), atoi(key_tokens[2]), atoi(key_tokens[3]), isValid);
187  if (!isValid){
188  ATH_MSG_FATAL("Failed to construct the station Identifier from "<<key);
189  return StatusCode::FAILURE;
190  }
191  defineArgs define{};
192  define.physVol = pv;
193  define.detElId = elementID;
194  define.chambDesign = key_tokens[0];
195  define.alignTransform = m_geoUtilTool->findAlignableTransform(define.physVol);
196 #ifndef SIMULATIONBASE
197  define.layerBounds = layerBounds;
198 #endif
199  ATH_MSG_DEBUG("Key "<<key<<" lead to Identifier "<<m_idHelperSvc->toStringDetEl(define.detElId));
200  ATH_CHECK(loadDimensions(define, facCache));
201  std::unique_ptr<TgcReadoutElement> readoutEle = std::make_unique<TgcReadoutElement>(std::move(define));
202  ATH_CHECK(mgr.addTgcReadoutElement(std::move(readoutEle)));
203  }
205  return StatusCode::SUCCESS;
206 }

◆ layerHash()

IdentifierHash MuonGMR4::TgcReadoutGeomTool::layerHash ( const TgcReadoutElement::defineArgs args,
const int  gasGap,
const int  doubPhi,
const bool  measPhi 
) const
private

◆ loadDimensions()

StatusCode MuonGMR4::TgcReadoutGeomTool::loadDimensions ( TgcReadoutElement::defineArgs args,
FactoryCache factory 
)
private

Loads the chamber dimensions from GeoModel.

Navigate through the GeoModel tree to find all gas volume leaves

Reserve the first bit for the isStrip property

The extra 1 to account for the is Strip true

Definition at line 43 of file TgcReadoutGeomTool.cxx.

44  {
45  ATH_MSG_VERBOSE("Load dimensions of "<<m_idHelperSvc->toString(define.detElId)
46  <<std::endl<<std::endl<<m_geoUtilTool->dumpVolume(define.physVol));
47  const GeoShape* shape = m_geoUtilTool->extractShape(define.physVol);
48  if (!shape) {
49  ATH_MSG_FATAL("Failed to deduce a valid shape for "<<m_idHelperSvc->toString(define.detElId));
50  return StatusCode::FAILURE;
51  }
52 
53  if (shape->typeID() != GeoTrd::getClassTypeID()) {
54  ATH_MSG_FATAL("The shape of "<<m_idHelperSvc->toStringDetEl(define.detElId)
55  <<" is expected to be a trapezoid "<<m_geoUtilTool->dumpShape(shape));
56  return StatusCode::FAILURE;
57  }
58  const GeoTrd* chambTrd = static_cast<const GeoTrd*>(shape);
59  define.halfWidthShort = std::min(chambTrd->getYHalfLength1(), chambTrd->getYHalfLength2());
60  define.halfWidthLong = std::max(chambTrd->getYHalfLength1(), chambTrd->getYHalfLength2());
61  define.halfHeight = chambTrd->getZHalfLength();
62  define.halfThickness = chambTrd->getXHalfLength1();
64  std::vector<physVolWithTrans> allGasGaps = m_geoUtilTool->findAllLeafNodesByName(define.physVol, "TgcGas");
65  if (allGasGaps.empty()) {
66  ATH_MSG_FATAL("The volume "<<m_idHelperSvc->toStringDetEl(define.detElId)<<" does not have any childern TgcGas"
67  <<std::endl<<m_geoUtilTool->dumpVolume(define.physVol));
68  return StatusCode::FAILURE;
69  }
70  unsigned int gasGap{0};
71  for (const physVolWithTrans& pVolTrans : allGasGaps) {
72  std::stringstream key{};
73  key<<define.chambDesign<<"_"<<(gasGap+1)
74  <<(m_idHelperSvc->stationEta(define.detElId) > 0 ? "A" : "C");
75 
76  StripLayerPtr& stripLayout{factoryCache.stripDesigns[key.str()]};
77  StripLayerPtr& wireLayout{factoryCache.wireDesigns[key.str()]};
78 
79  if (!stripLayout || !wireLayout) {
80  const wTgcTable& table{factoryCache.parameterBook[key.str()]};
81  if (!table.gasGap) {
82  ATH_MSG_FATAL("No wTGC table could be found for "
83  <<m_idHelperSvc->toStringDetEl(define.detElId)
84  <<" "<<define.chambDesign<<", gasGap "<<(gasGap+1));
85  return StatusCode::FAILURE;
86  }
87  const GeoShape* gapShape = m_geoUtilTool->extractShape(pVolTrans.volume);
88  if (gapShape->typeID() != GeoTrd::getClassTypeID()) {
89  ATH_MSG_FATAL("Expected shape "<<m_geoUtilTool->dumpShape(gapShape)
90  <<" to be a trapezoid");
91  return StatusCode::FAILURE;
92  }
93  const GeoTrd* gapTrd = static_cast<const GeoTrd*>(gapShape);
94 
95  const double halfMinX = std::min(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
96  const double halfMaxX = std::max(gapTrd->getYHalfLength1(), gapTrd->getYHalfLength2());
97  const double halfY = gapTrd->getZHalfLength();
98 
99  if (!wireLayout && table.wireGangs.size()) {
100  WireDesignPtr wireGrp = std::make_unique<WireGroupDesign>();
101  wireGrp->defineTrapezoid(halfMinX, halfMaxX, halfY);
102  for (unsigned int gang : table.wireGangs) {
103  wireGrp->declareGroup(gang);
104  }
105  const double wireOffSet = -0.5*table.wirePitch * wireGrp->nAllWires();
106  wireGrp->defineStripLayout(Amg::Vector2D{wireOffSet, 0.},
107  table.wirePitch, 0., table.wireGangs.size());
108 
109  const Amg::Transform3D trans{pVolTrans.transform
113  const IdentifierHash hash{gasGap << 1};
114  wireLayout = std::make_unique<StripLayer>(trans, (*factoryCache.wireLayouts.insert(std::move(wireGrp)).first), hash);
115  }
116  if (!stripLayout && table.bottomStripPos.size()) {
117  RadialStripDesignPtr radDesign = std::make_unique<RadialStripDesign>();
118  radDesign->defineTrapezoid(halfMinX, halfMaxX, halfY);
119  radDesign->defineStripLayout(Amg::Vector2D{-halfY,0.},
120  0.,0.,table.bottomStripPos.size());
121  radDesign->flipTrapezoid();
122  for (size_t s = 0; s < table.bottomStripPos.size(); ++s) {
123  radDesign->addStrip(table.bottomStripPos.at(s),
124  table.topStripPos.at(s));
125  }
127  const IdentifierHash hash{gasGap<< 1 | 1};
128  const Amg::Transform3D trans{pVolTrans.transform
131  stripLayout = std::make_unique<StripLayer>(trans, (*factoryCache.stripLayouts.insert(std::move(radDesign)).first), hash);
132  }
133  }
134  ++gasGap;
135  if (stripLayout) {
136  unsigned int stripIdx = static_cast<unsigned>(stripLayout->hash());
137  if (stripIdx >= define.sensorLayouts.size()) {
138  ATH_MSG_FATAL("The strip index "<<stripIdx<<" is out of range for gasGap "<<gasGap);
139  return StatusCode::FAILURE;
140  }
141  define.sensorLayouts[stripIdx] = stripLayout;
142  }
143  if (wireLayout) {
144  unsigned int wireIdx = static_cast<unsigned>(wireLayout->hash());
145  if (wireIdx >= define.sensorLayouts.size()) {
146  ATH_MSG_FATAL("The wire index "<<wireIdx<<" is out of range for gasGap "<<gasGap);
147  return StatusCode::FAILURE;
148  }
149  define.sensorLayouts[wireIdx] = wireLayout;
150  }
151  }
152  define.nGasGaps = gasGap;
153  return StatusCode::SUCCESS;
154 }

◆ readParameterBook()

StatusCode MuonGMR4::TgcReadoutGeomTool::readParameterBook ( FactoryCache cache)
private

Retrieves the auxillary tables from the database.

Definition at line 221 of file TgcReadoutGeomTool.cxx.

221  {
222  ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(), name());
223  ATH_CHECK(accessSvc.retrieve());
224  IRDBRecordset_ptr paramTable = accessSvc->getRecordsetPtr("TgcSensorLayout", "");
225  if (paramTable->size() == 0) {
226  ATH_MSG_FATAL("Empty parameter book table found");
227  return StatusCode::FAILURE;
228  }
229  for (const IRDBRecord_ptr& record : *paramTable) {
230  const std::string chambType = record->getString("technology");
231  const int gasGap = record->getInt("gasGap");
232  const std::vector<int> wireGangs{tokenizeInt(record->getString("wireGangs"),",")};
233  const std::vector<double> botStrips = tokenizeDouble(record->getString("bottomStrips"), ",");
234  const std::vector<double> topStrips = tokenizeDouble(record->getString("topStrips"), ",");
235  const std::vector<std::string> sides = tokenize(record->getString("side"), ";");
236  const double wirePitch = record->getDouble("wirePitch");
237  for (const std::string& side : sides) {
238  std::stringstream key{};
239  key<<chambType<<"_"<<gasGap<<side;
240  wTgcTable& parBook{cache.parameterBook[key.str()]};
241  parBook.wireGangs.insert(parBook.wireGangs.end(), wireGangs.begin(), wireGangs.end());
242  parBook.bottomStripPos = botStrips;
243  parBook.topStripPos = topStrips;
244  parBook.wirePitch = wirePitch;
245  parBook.gasGap = gasGap;
246  }
247 
248  }
249  ATH_MSG_DEBUG("Read in total "<<cache.parameterBook.size()<<" chamber layouts");
250  return StatusCode::SUCCESS;
251 }

◆ writeSectorMapping()

StatusCode MuonGMR4::TgcReadoutGeomTool::writeSectorMapping ( const MuonDetectorManager mgr) const
private

Map the Tgc sectors to the classical Muon System sectors.

Map the Tgc sectors to the classic muon sectors

Definition at line 207 of file TgcReadoutGeomTool.cxx.

207  {
209  std::vector<const TgcReadoutElement*> tgcReadOutEles = mgr.getAllTgcReadoutElements();
210  std::unique_ptr<std::vector<int>> tgcSectorMapping = std::make_unique<std::vector<int>>();
211  tgcSectorMapping->resize(m_idHelperSvc->tgcIdHelper().module_hash_max());
212  Muon::MuonSectorMapping sectorMapping{};
213  const ActsGeometryContext gctx{};
214  for (const TgcReadoutElement* readoutEle : tgcReadOutEles) {
215  int& sectNumb = (*tgcSectorMapping)[m_idHelperSvc->moduleHash(readoutEle->identify())];
216  sectNumb = sectorMapping.getSector(readoutEle->center(gctx).phi());
217  }
218  ATH_CHECK(detStore()->record(std::move(tgcSectorMapping), "TGC_SectorMapping"));
219  return StatusCode::SUCCESS;
220 }

Member Data Documentation

◆ m_geoDbTagSvc

ServiceHandle<IGeoDbTagSvc> MuonGMR4::TgcReadoutGeomTool::m_geoDbTagSvc {this, "GeoDbTagSvc", "GeoDbTagSvc"}
private

Definition at line 34 of file TgcReadoutGeomTool.h.

◆ m_geoUtilTool

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

Definition at line 36 of file TgcReadoutGeomTool.h.

◆ m_idHelperSvc

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

Definition at line 31 of file TgcReadoutGeomTool.h.


The documentation for this class was generated from the following files:
GeoModel::TransientConstSharedPtr
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
Definition: TransientConstSharedPtr.h:13
dumpTgcDigiDeadChambers.gasGap
list gasGap
Definition: dumpTgcDigiDeadChambers.py:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CxxUtils::tokenizeDouble
std::vector< double > tokenizeDouble(const std::string &the_str, std::string_view delimiter)
Definition: Control/CxxUtils/Root/StringUtils.cxx:34
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TgcIdHelper
Definition: TgcIdHelper.h:50
RPDUtils::sides
constexpr std::initializer_list< unsigned int > sides
Definition: RPDUtils.h:17
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
CxxUtils::tokenizeInt
std::vector< int > tokenizeInt(const std::string &the_str, std::string_view delimiter)
Definition: Control/CxxUtils/Root/StringUtils.cxx:55
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
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
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
deg
#define deg
Definition: SbPolyhedron.cxx:17
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:620
Amg::getRotateZ3D
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Definition: GeoPrimitivesHelpers.h:270
TRT::Hit::side
@ side
Definition: HitInfo.h:83
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
MuonGMR4::TgcReadoutGeomTool::writeSectorMapping
StatusCode writeSectorMapping(const MuonDetectorManager &mgr) const
Map the Tgc sectors to the classical Muon System sectors.
Definition: TgcReadoutGeomTool.cxx:207
Amg::getRotateX3D
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
Definition: GeoPrimitivesHelpers.h:252
MuonGMR4::WireDesignPtr
GeoModel::TransientConstSharedPtr< WireGroupDesign > WireDesignPtr
Definition: WireGroupDesign.h:21
MuonGMR4::TgcReadoutGeomTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TgcReadoutGeomTool.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGMR4::TgcReadoutGeomTool::readParameterBook
StatusCode readParameterBook(FactoryCache &cache)
Retrieves the auxillary tables from the database.
Definition: TgcReadoutGeomTool.cxx:221
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonGMR4::TgcReadoutGeomTool::loadDimensions
StatusCode loadDimensions(TgcReadoutElement::defineArgs &args, FactoryCache &factory)
Loads the chamber dimensions from GeoModel.
Definition: TgcReadoutGeomTool.cxx:43
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.ext.table_printer.table
list table
Definition: table_printer.py:81
MuonGMR4::physVolWithTrans
IMuonGeoUtilityTool::physVolWithTrans physVolWithTrans
Definition: MdtReadoutGeomTool.cxx:33
Amg::getRotateY3D
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
Definition: GeoPrimitivesHelpers.h:261
MuonGMR4::RadialStripDesignPtr
GeoModel::TransientConstSharedPtr< RadialStripDesign > RadialStripDesignPtr
Definition: RadialStripDesign.h:21
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IRDBRecord_ptr
std::unique_ptr< IRDBRecord > IRDBRecord_ptr
Definition: IRDBRecordset.h:23
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
Muon::MuonSectorMapping
Definition: MuonSectorMapping.h:20
ActsTrk::SurfaceBoundSetPtr
std::shared_ptr< SurfaceBoundSet< BoundType > > SurfaceBoundSetPtr
Aberivation to create a new SurfaceBoundSetPtr.
Definition: Tracking/Acts/ActsGeoUtils/ActsGeoUtils/Defs.h:19
MuonGMR4::MuonReadoutElement::defineArgs::physVol
GeoIntrusivePtr< GeoVFullPhysVol > physVol
Pointer to the underlying physical volume in GeoModel.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonReadoutElement.h:45
MuonGMR4::TgcReadoutGeomTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: TgcReadoutGeomTool.h:34
MuonGMR4::TgcReadoutGeomTool::m_geoUtilTool
PublicToolHandle< IMuonGeoUtilityTool > m_geoUtilTool
Definition: TgcReadoutGeomTool.h:36
MuonGMR4::defineArgs
RpcReadoutElement::defineArgs defineArgs
Definition: RpcReadoutGeomTool.cxx:37
ServiceHandle< IRDBAccessSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Identifier
Definition: IdentifierFieldParser.cxx:14