ATLAS Offline Software
Loading...
Searching...
No Matches
ReadoutGeomCnvAlg.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5#include "ReadoutGeomCnvAlg.h"
6
7#include <GeoModelKernel/GeoVPhysVol.h>
11#include <GeoModelKernel/GeoFullPhysVol.h>
12#include <GeoModelKernel/GeoShapeShift.h>
13#include <GeoModelHelpers/printVolume.h>
14
20
21
23
27
28
35
37
39#include <GaudiKernel/SystemOfUnits.h>
40
41#include <GeoModelHelpers/defineWorld.h>
42#include <GeoModelHelpers/cloneVolume.h>
43#include <GeoModelHelpers/getChildNodesWithTrf.h>
44#include <GeoModelHelpers/TransformToStringConverter.h>
45#include <GeoModelHelpers/GeoShapeUtils.h>
46#include <GeoModelIOHelpers/GMIO.h>
47#include <map>
48#include <format>
49
50
51#include "Acts/Definitions/Units.hpp"
52using namespace Acts::UnitLiterals;
53
54namespace {
55 using SubDetAlignment = ActsTrk::GeometryContext::AlignmentStorePtr;
56 bool hasStationVolume(const PVConstLink treeTop,
57 const std::set<PVConstLink>& translated) {
58 const unsigned int nCh = treeTop->getNChildVols();
59 for (unsigned int ch = 0 ; ch < nCh; ++ch) {
60 PVConstLink child = treeTop->getChildVol(ch);
61 if (translated.count(child) ||
62 hasStationVolume(child, translated)){
63 return true;
64 }
65 }
66 return false;
67 };
68}
69
70namespace MuonGMR4{
71
73 ATH_CHECK(m_idHelperSvc.retrieve());
74 ATH_CHECK(m_writeKey.initialize());
75 ATH_CHECK(m_alignStoreKeys.initialize());
76 ATH_CHECK(detStore()->retrieve(m_detMgr));
77 return StatusCode::SUCCESS;
78}
79
80
81StatusCode ReadoutGeomCnvAlg::execute(const EventContext& ctx) const {
82 SG::WriteCondHandle writeHandle{m_writeKey, ctx};
83 if (writeHandle.isValid()) {
84 ATH_MSG_DEBUG("The current readout geometry is still valid.");
85 return StatusCode::SUCCESS;
86 }
89 ActsTrk::GeometryContext geoContext{};
93 if (!readHandle.isValid()) {
94 ATH_MSG_FATAL("Failed to retrieve alignment store "<<key.fullKey());
95 return StatusCode::FAILURE;
96 }
97 writeHandle.addDependency(readHandle);
98 auto alignStore = std::make_unique<ActsTrk::DetectorAlignStore>(**readHandle);
100 if (alignStore->geoModelAlignment) {
101 alignStore->geoModelAlignment->clearPosCache();
102 }
103 alignStore->trackingAlignment = std::make_unique<TrackingAlignment>(alignStore->detType);
104 geoContext.setStore(std::move(alignStore));
105 }
108 std::vector<ActsTrk::DetectorType> presentTechs = m_detMgr->getDetectorTypes();
109 for (const ActsTrk::DetectorType detType : presentTechs) {
110 if (geoContext.getStore(detType)) {
111 continue;
112 }
113 ATH_MSG_WARNING("No external detector alignment has been defined for technology "<<ActsTrk::to_string(detType));
114 geoContext.setStore(std::make_unique<ActsTrk::DetectorAlignStore>(detType));
115 }
117 ConstructionCache cacheObj;
118 cacheObj.detMgr = std::make_unique<MuonGM::MuonDetectorManager>();
119 cacheObj.world = createGeoWorld();
120 cacheObj.detMgr->addTreeTop(cacheObj.world);
122 ATH_CHECK(buildMdt(geoContext, cacheObj));
123 ATH_CHECK(buildTgc(geoContext, cacheObj));
124 ATH_CHECK(buildRpc(geoContext, cacheObj));
125 ATH_CHECK(buildSTGC(geoContext, cacheObj));
126 ATH_CHECK(buildMM(geoContext, cacheObj));
128 std::vector<GeoChildNodeWithTrf> treeTops = getChildrenWithRef(m_detMgr->getTreeTop(0), false);
129
131 for (const GeoChildNodeWithTrf& treeTop : treeTops) {
132 if (hasStationVolume(treeTop.volume, cacheObj.translatedStations)) continue;
133 ATH_MSG_VERBOSE("Detected passive volume "<<treeTop.nodeName);
134
135 cacheObj.world->add(const_pointer_cast(treeTop.volume));
136 }
137
139 if (m_checkGeo) {
140 const std::vector<const MuonGMR4::MuonReadoutElement*> refEles{m_detMgr->getAllReadoutElements()};
141 for (const MuonGMR4::MuonReadoutElement* refEle : refEles) {
142 ATH_CHECK(checkIdCompability(*refEle, *cacheObj.detMgr->getReadoutElement(refEle->identify())));
143 }
144 }
145 if (m_dumpGeo) {
146 ATH_MSG_DEBUG("Save geometry to SqLite file "<<m_geoDumpName);
147 GeoModelIO::IO::saveToDB(cacheObj.world, m_geoDumpName, 0 , true);
148 }
149
150 ATH_CHECK(writeHandle.record(std::move(cacheObj.detMgr)));
151 return StatusCode::SUCCESS;
152}
154 const Identifier& stationId,
155 ConstructionCache& cacheObj) const {
156 const std::string stName{m_idHelperSvc->stationNameString(stationId)};
157 const int stEta{m_idHelperSvc->stationEta(stationId)};
158 const int stPhi{m_idHelperSvc->stationPhi(stationId)};
159 MuonGM::MuonStation* station = cacheObj.detMgr->getMuonStation(stName, stEta, stPhi);
160 if (station) {
161 ATH_MSG_DEBUG("Station "<<stName<<", stEta: "<<stEta<<", stPhi: "<<stPhi<<" already exists.");
162 return StatusCode::SUCCESS;
163 }
165 const MuonGMR4::MuonReadoutElement* copyMe = m_detMgr->getReadoutElement(stationId);
166
168 const GeoVFullPhysVol* readOutVol = copyMe->getMaterialGeom();
169 // This is the physical volume that contains the readOutVol as a child.
170 PVConstLink parentVolume = readOutVol->getParent();
171
172 const GeoAlignableTransform* alignTrf{copyMe->alignableTransform()};
173
175 GeoIntrusivePtr<const GeoGraphNode> alignNode{*(parentVolume->getParent()->findChildNode(alignTrf) + 1)};
177 GeoIntrusivePtr<const GeoTransform> stationShiftNode{alignNode != parentVolume ?
178 dynamic_pointer_cast<const GeoTransform>(alignNode) : nullptr};
179
180 cacheObj.translatedStations.insert(parentVolume);
182 PVLink copiedStationVol{};
183 if (!stationShiftNode) {
184 copiedStationVol = make_intrusive<GeoFullPhysVol>(parentVolume->getLogVol());
185 } else {
186 auto volToCopy = parentVolume->getLogVol();
187 auto newShape = cacheObj.cacheShape(make_intrusive<GeoShapeShift>(volToCopy->getShape(),
188 stationShiftNode->getDefTransform()));
189 auto newLogVol = make_intrusive<GeoLogVol>(volToCopy->getName(), newShape, volToCopy->getMaterial());
190 copiedStationVol = make_intrusive<GeoFullPhysVol>(cacheObj.cacheVolume(newLogVol));
191 }
192
195 const std::vector<GeoChildNodeWithTrf> children = getChildrenWithRef(parentVolume, false); // we get the list of child nodes attached to the parent volume
196 double minX{1.e9}, maxX{-1.e9}, minY1{1.e9}, maxY1{-1.e9}, minY2{1.e9}, maxY2{-1.e9}, minZ{1.e9}, maxZ{-1.e9};
197 for (const GeoChildNodeWithTrf& child : children) {
198 std::vector<Amg::Vector3D> edges = getPolyShapeEdges(child.volume->getLogVol()->getShape(), //we are getting corner points of the edges
199 readOutVol->getX().inverse() * child.transform); //getX() returns the transformation from readout physical volume ref to parent physical volume ref. We take the inverse and we chain it with child.transform, which is from child ref to parent ref
200 for (const Amg::Vector3D& edge : edges) {
201 minX = std::min(minX, edge.x());
202 maxX = std::max(maxX, edge.x());
203 minZ = std::min(minZ, edge.z());
204 maxZ = std::max(maxZ, edge.z());
205 if (edge.z() < 0) {
206 minY1 = std::min(minY1, edge.y());
207 maxY1 = std::max(maxY1, edge.y());
208 } else {
209 minY2 = std::min(minY2, edge.y());
210 maxY2 = std::max(maxY2, edge.y());
211 }
212 }
214 const GeoVPhysVol &childVolRef = *child.volume;
215 if (typeid(childVolRef) == typeid(GeoFullPhysVol)) {
216 continue;
217 }
218 // Add the beam lines / foams inside the station volume
219 PVLink childVol = const_pointer_cast<GeoVPhysVol>(child.volume);
220 copiedStationVol->add(cacheObj.newIdTag());
221 if (stationShiftNode) {
222 copiedStationVol->add(const_pointer_cast(stationShiftNode));
223 }
224 copiedStationVol->add(cacheObj.makeTransform(child.transform));
225 copiedStationVol->add(cloneVolume(childVol));
226 }
227
230 const double shortS = (maxY1 - minY1);
231 const double longS = (maxY2 - minY2);
232 const double lengthR = (maxX - minX);
233 const double lengthZ = (maxZ - minZ);
234
236 const Amg::Transform3D alignedTransform = copyMe->localToGlobalTrans(gctx) *
237 ( ( stationShiftNode ? stationShiftNode->getDefTransform() : Amg::Transform3D::Identity())
238 * readOutVol->getDefX()).inverse();
239
240
241 auto newStation = std::make_unique<MuonGM::MuonStation>(stName,
242 shortS, lengthR, lengthZ,
243 longS, lengthR, lengthZ,
244 stEta, stPhi, false);
245 newStation->setPhysVol(copiedStationVol);
247 cacheObj.world->add(cacheObj.newIdTag());
248 auto copyAlignNode = make_intrusive<GeoAlignableTransform>(alignedTransform);
249 newStation->setTransform(copyAlignNode);
250 newStation->setNominalAmdbLRSToGlobal(copyAlignNode->getTransform());
251
252 ATH_MSG_VERBOSE("stName: "<<stName<<", stEta: "<<stEta<<", stPhi: "<<stPhi
253 <<" -- shortS: "<<shortS<<", longS: "<<longS
254 <<", lengthR: "<<lengthR<<", lengthZ: "<<lengthZ
255 <<std::endl<<"AlignableNode: "<<GeoTrf::toString(alignedTransform, true)
256 <<std::endl<<"Station shift: "<<GeoTrf::toString(stationShiftNode ? stationShiftNode->getDefTransform()
257 : Amg::Transform3D::Identity(), true)
258 <<std::endl<<"AmdLRSToGlobal: "<<GeoTrf::toString(newStation->getNominalAmdbLRSToGlobal(), true)
259 <<std::endl<<"Readout transform: "<<GeoTrf::toString(readOutVol->getX(), true));
260 cacheObj.detMgr->addMuonStation(std::move(newStation));
261 cacheObj.world->add(copyAlignNode);
262 cacheObj.world->add(copiedStationVol);
263 return StatusCode::SUCCESS;
264}
265
266
268 const Identifier& reId,
269 ConstructionCache& cacheObj,
270 GeoIntrusivePtr<GeoVFullPhysVol>& physVol,
271 MuonGM::MuonStation* & station) const {
272
273 ATH_CHECK(buildStation(gctx, reId, cacheObj));
274 const std::string stName{m_idHelperSvc->stationNameString(reId)};
275 station = cacheObj.detMgr->getMuonStation(stName,
276 m_idHelperSvc->stationEta(reId),
277 m_idHelperSvc->stationPhi(reId));
278
279 PVLink copiedStationVol{station->getPhysVol()};
280 const MuonGMR4::MuonReadoutElement* copyMe = m_detMgr->getReadoutElement(reId);
281 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
282 copiedStationVol->add(cacheObj.newIdTag());
293 const Amg::Transform3D alignNodeToRE{copyMe->alignableTransform()->getDefTransform().inverse() *
294 readOutVol->getParent()->getX() * readOutVol->getX()};
295 const Amg::Transform3D alignedNode{copyMe->localToGlobalTrans(gctx) * alignNodeToRE.inverse()};
296
297 const Amg::Transform3D stationTrf{copiedStationVol->getX().inverse() * alignedNode};
298
299 copiedStationVol->add(cacheObj.makeTransform(stationTrf*alignNodeToRE));
301 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
302 physVol = dynamic_pointer_cast<GeoVFullPhysVol>(clonedVol);
303 copiedStationVol->add(physVol);
304 return StatusCode::SUCCESS;
305}
306
308
309 const std::vector<const MuonGMR4::RpcReadoutElement*> readoutEles = m_detMgr->getAllRpcReadoutElements();
310 ATH_MSG_INFO("Copy "<<readoutEles.size()<<" Rpc readout elements to the legacy system");
311 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
312 for (const MuonGMR4::RpcReadoutElement* copyMe : readoutEles) {
313 const Identifier reId = copyMe->identify();
314 const MuonGMR4::RpcReadoutElement::parameterBook& pars{copyMe->getParameters()};
315 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
316 MuonGM::MuonStation* station{nullptr};
317 ATH_CHECK(cloneReadoutVolume(gctx, reId, cacheObj, physVol, station));
318 auto newElement = std::make_unique<MuonGM::RpcReadoutElement>(physVol,
319 m_idHelperSvc->stationNameString(reId),
320 1, 1, false, cacheObj.detMgr.get());
321 newElement->setDoubletPhi(copyMe->doubletPhi());
322 newElement->setDoubletR(copyMe->doubletR());
323 newElement->setDoubletZ(copyMe->doubletZ());
324 newElement->setIdentifier(reId);
325 newElement->setParentMuonStation(station);
326 station->addMuonReadoutElementWithAlTransf(newElement.get(), nullptr, station->nMuonReadoutElements());
327
329 newElement->setLongZsize(2.*pars.halfLength);
330 newElement->setLongSsize(2.*pars.halfWidth);
331 newElement->setLongRsize(2.*pars.halfThickness);
332 newElement->setZsize(2.*pars.halfLength);
333 newElement->setSsize(2.*pars.halfWidth);
334 newElement->setRsize(2.*pars.halfThickness);
335
336 newElement->m_nlayers = copyMe->nGasGaps();
337 newElement->m_phistripwidth = copyMe->stripPhiWidth();
338 newElement->m_etastripwidth = copyMe->stripEtaWidth();
339 newElement->m_phistrippitch = copyMe->stripPhiPitch();
340 newElement->m_etastrippitch = Acts::copySign(1., copyMe->stationEta() -
341 (copyMe->stationEta()==0))*copyMe->stripEtaPitch();
342 newElement->m_phistriplength = copyMe->stripPhiLength();
343 newElement->m_etastriplength = copyMe->stripEtaLength();
344
345 newElement->m_nphistripsperpanel = copyMe->nPhiStrips();
346 newElement->m_netastripsperpanel = copyMe->nEtaStrips();
347 newElement->m_nphistrippanels = copyMe->nPhiPanels();
348 newElement->m_hasDEDontop = true;
349 newElement->m_descratzneg = false;
350
351 std::vector<Identifier> gapIds{};
352 for (unsigned int gasGap = 1; gasGap <= copyMe->nGasGaps(); ++gasGap) {
353 for (int doubPhi = copyMe->doubletPhiMax(); doubPhi >= copyMe->doubletPhi(); --doubPhi) {
354 for (bool measPhi : {false, true}) {
355 if (measPhi && copyMe->nPhiStrips()==0) continue;
356 const int channel = 1;
357 const Identifier gapId = idHelper.channelID(copyMe->identify(),
358 copyMe->doubletZ(),
359 doubPhi, gasGap, measPhi,
360 channel);
361
362 gapIds.push_back(gapId);
363 const Amg::Vector3D locStripPos = copyMe->globalToLocalTrans(gctx) * copyMe->stripPosition(gctx, gapId);
364 ATH_MSG_VERBOSE("GasGap "<<m_idHelperSvc->toString(gapId)<<", local strip position: "<<Amg::toString(locStripPos));
365 newElement->m_gasGap_xPos[gasGap -1] = locStripPos.x();
368 const int dbPIdx = copyMe->doubletPhi() == 2 ? 1 : doubPhi;
369 if (measPhi) {
370 newElement->m_first_phistrip_s[dbPIdx -1] = locStripPos.y();
371 newElement->m_phistrip_z = locStripPos.z();
372 } else{
373 newElement->m_first_etastrip_z = locStripPos.z();
374 newElement->m_etastrip_s[dbPIdx-1] = locStripPos.y();
375 }
376 }
377 }
378 }
379 newElement->fillCache();
381 for (const Identifier& gapId : gapIds) {
382 const int surfaceHash = newElement->surfaceHash(gapId);
383 const int layerHash = newElement->layerHash(gapId);
384 const Amg::Transform3D refTrf{copyMe->localToGlobalTrans(gctx, gapId)*
385 (m_idHelperSvc->measuresPhi(gapId) ?
386 Amg::getRotateZ3D(90_degree) :
387 Amg::Transform3D::Identity())};
388 ATH_MSG_VERBOSE("Assign transform: "<<m_idHelperSvc->toString(gapId)<<", "<<Amg::toString(refTrf));
389 newElement->m_surfaceData->m_layerTransforms[surfaceHash] = refTrf;
390 newElement->m_surfaceData->m_layerCenters[layerHash] = refTrf.translation();
391 newElement->m_surfaceData->m_layerNormals[layerHash] = refTrf.linear() * Amg::Vector3D::UnitZ();
392 }
393 ATH_CHECK(dumpAndCompare(gctx, *copyMe, *newElement));
394 cacheObj.detMgr->addRpcReadoutElement(std::move(newElement));
395 }
396 return StatusCode::SUCCESS;
397}
398
399
401
402 std::vector<const MuonGMR4::TgcReadoutElement*> tgcReadouts{m_detMgr->getAllTgcReadoutElements()};
403 std::ranges::stable_sort(tgcReadouts,[](const MuonGMR4::TgcReadoutElement* a, const MuonGMR4::TgcReadoutElement* b){
404 return a->stationEta() > b->stationEta();
405 });
406 ATH_MSG_INFO("Copy "<<tgcReadouts.size()<<" Tgc readout elements to the legacy system");
407 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
408
409 using TgcReadoutParams = MuonGM::TgcReadoutParams;
410 std::map<std::string, std::shared_ptr<TgcReadoutParams>> readoutParMap{};
411
412 for (const MuonGMR4::TgcReadoutElement* copyMe: tgcReadouts) {
413 const Identifier reId = copyMe->identify();
414 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
415 MuonGM::MuonStation* station{nullptr};
416 ATH_CHECK(cloneReadoutVolume(gctx,reId, cacheObj, physVol, station));
417
418 auto newRE = std::make_unique<MuonGM::TgcReadoutElement>(physVol, m_idHelperSvc->stationNameString(reId),
419 cacheObj.detMgr.get());
420 newRE->setIdentifier(reId);
421 newRE->setParentMuonStation(station);
422 ATH_MSG_DEBUG("Readout element "<<m_idHelperSvc->toString(reId)<<", design: "<<copyMe->chamberDesign());
423 std::shared_ptr<TgcReadoutParams>& readOutPars = readoutParMap[std::format("{:}_{:}", copyMe->chamberDesign(),
424 copyMe->stationEta()> 0? 'A' : 'C')];
425 if (!readOutPars) {
426 using WiregangArray = TgcReadoutParams::WiregangArray;
427 using StripArray = TgcReadoutParams::StripArray;
428 using GasGapIntArray = TgcReadoutParams::GasGapIntArray;
429
430 std::array<WiregangArray, 3> wires{};
431 GasGapIntArray nWireGangs{}, nStrips{};
432 std::vector<StripArray> botMountings(copyMe->nGasGaps()),
433 topMountings(copyMe->nGasGaps());
434
435 double wirePitch{0.};
436 for (unsigned int gasGap =1; gasGap <= copyMe->nGasGaps(); ++gasGap) {
437 const IdentifierHash gangHash = copyMe->constructHash(0, gasGap, false);
438 const IdentifierHash stripHash = copyMe->constructHash(0, gasGap, true);
439 nWireGangs[gasGap -1] = copyMe->numWireGangs(gangHash);
440 nStrips[gasGap -1] = copyMe->numStrips(stripHash);
441 ATH_MSG_VERBOSE("Assigned wire gangs: "<<nWireGangs[gasGap-1]<<", strips: "<<nStrips[gasGap -1]
442 <<" for gas gap "<<gasGap);
443
444 if (nWireGangs[gasGap -1]) {
445 const MuonGMR4::WireGroupDesign& design{copyMe->wireGangLayout(gangHash)};
446 wirePitch = design.stripPitch();
447 WiregangArray& fillMe{wires[gasGap-1]};
448 for (int gang = 1; gang <= design.numStrips(); ++gang) {
449 fillMe[gang -1] = design.numWiresInGroup(gang);
450 }
451 ATH_MSG_VERBOSE("Gang layout: "<<fillMe);
452 }
453 if (nStrips[gasGap -1]) {
454 const MuonGMR4::RadialStripDesign& design{copyMe->stripLayout(stripHash)};
455 const int nCh = nStrips[gasGap -1];
456 for (int strip = 1; strip <= nCh; ++strip) {
457 botMountings[gasGap-1][strip-1] = - design.stripLeftBottom(strip).x();
458 topMountings[gasGap-1][strip-1] = - design.stripLeftTop(strip).x();
459 }
460 botMountings[gasGap-1][nCh] = - design.stripRightBottom(nCh).x();
461 topMountings[gasGap-1][nCh] = - design.stripRightTop(nCh).x();
462 ATH_MSG_VERBOSE("Strip layout\n bottom: "<<botMountings<<"\n top: "<<topMountings);
463 }
464 }
465 readOutPars = std::make_unique<TgcReadoutParams>(copyMe->chamberDesign(),
466 0, wirePitch,
467 idHelper.stationPhiMax(reId),
468 std::move(nWireGangs),
469 std::move(wires[0]),
470 std::move(wires[1]),
471 std::move(wires[2]),
472 0,
473 std::move(botMountings),
474 std::move(topMountings),
475 std::move(nStrips));
476 }
477
479 for (unsigned int gasGap = 1; gasGap <= copyMe->nGasGaps(); ++gasGap) {
480 const IdentifierHash layHash{copyMe->constructHash(0, gasGap, false)};
482 const Amg::Vector3D translation{copyMe->globalToLocalTrans(gctx) * copyMe->center(gctx, layHash)};
483 newRE->setPlaneZ(translation.x(), gasGap);
484 }
485 newRE->setRsize(copyMe->moduleHeight());
486 newRE->setSsize(copyMe->moduleWidthS());
487 newRE->setZsize(copyMe->moduleThickness());
488
489 newRE->setLongRsize(copyMe->moduleHeight());
490 newRE->setLongSsize(copyMe->moduleWidthL());
491 newRE->setLongZsize(copyMe->moduleThickness());
492
493 newRE->setReadOutParams(readOutPars);
494 newRE->fillCache();
495 ATH_CHECK(dumpAndCompare(gctx, *copyMe, *newRE));
496 cacheObj.detMgr->addTgcReadoutElement(std::move(newRE));
497
498 }
499 return StatusCode::SUCCESS;
500}
501
502GeoIntrusivePtr<GeoVFullPhysVol>
504 const MuonGMR4::MuonReadoutElement* copyMe,
505 ConstructionCache& cacheObj) const {
506 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
507 cacheObj.translatedStations.insert(readOutVol->getParent());
508
509 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
510 GeoIntrusivePtr<GeoFullPhysVol> physVol{dynamic_pointer_cast<GeoFullPhysVol>(clonedVol)};
511 cacheObj.world->add(cacheObj.newIdTag());
512 cacheObj.world->add(cacheObj.makeTransform(copyMe->localToGlobalTrans(gctx)));
513 cacheObj.world->add(physVol);
514 return physVol;
515}
517
518 SubDetAlignment alignItr = gctx.getStore(ActsTrk::DetectorType::Mm);
519 const auto alignStore = alignItr ?
520 static_cast<const MmAlignmentStore*>(alignItr->internalAlignment.get()) : nullptr;
521
522 if (alignStore) {
523 cacheObj.detMgr->setMMPassivation(alignStore->passivation);
524 }
525 const std::vector<const MuonGMR4::MmReadoutElement*> mmReadouts{m_detMgr->getAllMmReadoutElements()};
526 ATH_MSG_INFO("Copy "<<mmReadouts.size()<<" Mm readout elements to the legacy system");
527
528 for (const MuonGMR4::MmReadoutElement* copyMe : mmReadouts) {
529 const Identifier reId = copyMe->identify();
530 GeoIntrusivePtr<GeoVFullPhysVol> physVol{cloneNswWedge(gctx, copyMe, cacheObj)};
531 auto newRE = std::make_unique<MuonGM::MMReadoutElement>(physVol,
532 m_idHelperSvc->stationNameString(reId),
533 copyMe->stationEta(),
534 copyMe->stationPhi(),
535 copyMe->multilayer(), cacheObj.detMgr.get());
537 for (unsigned int gasGap = 0; gasGap < copyMe->nGasGaps(); ++gasGap) {
538 const MuonGMR4::StripLayer& stripLayer{copyMe->stripLayer(MuonGMR4::MmReadoutElement::createHash(gasGap +1, 0))};
539 const MuonGMR4::StripDesign& designFrom{stripLayer.design()};
540
541 newRE->m_Xlg[gasGap] = stripLayer.toOrigin() *
542 Amg::getRotateZ3D(-designFrom.stereoAngle()) *
543 Amg::getRotateY3D(90. * Gaudi::Units::deg);
544 ATH_MSG_VERBOSE("Layer transform "<<gasGap<<" "<<GeoTrf::toString(newRE->m_Xlg[gasGap], true));
545
546 MuonGM::MuonChannelDesign& designTo{newRE->m_etaDesign[gasGap]};
547 designTo.defineTrapezoid(designFrom.shortHalfHeight(),
548 designFrom.longHalfHeight(),
549 designFrom.halfWidth(),
550 designFrom.stereoAngle());
553 designTo.inputPitch = designFrom.stripPitch();
554 designTo.inputWidth = designTo.inputPitch * std::cos(designTo.stereoAngle());
555 designTo.nMissedBottomEta = designTo.nMissedBottomStereo = designFrom.firstStripNumber() - 1;
556 designTo.totalStrips = designFrom.numStrips();
557 designTo.nch = designFrom.numStrips();
558
559 designTo.setFirstPos(designFrom.firstStripPos().x() + 0.5*designTo.inputPitch);
560 }
561
562 newRE->fillCache();
563 if (alignStore && alignStore->getBLine(reId)) {
564 newRE->setBLinePar(*alignStore->getBLine(reId));
565 }
566 ATH_CHECK(dumpAndCompare(gctx, *copyMe, *newRE));
567 cacheObj.detMgr->addMMReadoutElement(std::move(newRE));
568 }
569 return StatusCode::SUCCESS;
570}
571
573 SubDetAlignment alignItr = gctx.getStore(ActsTrk::DetectorType::sTgc);
574 auto alignStore = alignItr ? static_cast<const sTgcAlignmentStore*>(alignItr->internalAlignment.get()) : nullptr;
575
576 const std::vector<const MuonGMR4::sTgcReadoutElement*> sTgcReadOuts{m_detMgr->getAllsTgcReadoutElements()};
577 ATH_MSG_INFO("Copy "<<sTgcReadOuts.size()<<" sTgc readout elements to the legacy system");
578
579 for (const MuonGMR4::sTgcReadoutElement* copyMe : sTgcReadOuts) {
580 const Identifier reId = copyMe->identify();
581 ATH_MSG_DEBUG("Translate readout element "<<m_idHelperSvc->toStringDetEl(reId)<<".");
582 GeoIntrusivePtr<GeoVFullPhysVol> physVol{cloneNswWedge(gctx, copyMe, cacheObj)};
583
584 auto newRE = std::make_unique<MuonGM::sTgcReadoutElement>(physVol,
585 m_idHelperSvc->stationNameString(reId).substr(1),
586 copyMe->stationEta(),
587 copyMe->stationPhi(),
588 copyMe->multilayer(),
589 cacheObj.detMgr.get());
590
591 if (alignStore && alignStore->getBLine(reId)) {
592 newRE->setBLinePar(*alignStore->getBLine(reId));
593 }
594 for (unsigned int layer = 1; layer <= copyMe->numLayers(); ++layer) {
596 using ChannelDesign = MuonGM::MuonChannelDesign;
597 const IdentifierHash layerHash = MuonGMR4::sTgcReadoutElement::createHash(layer,channelType::Strip,0);
598
599 const MuonGMR4::StripLayer& stripLayer{copyMe->stripLayer(layerHash)};
600 newRE->m_Xlg[layer -1] = stripLayer.toOrigin() *
601 Amg::getRotateY3D(90._degree) *
602 Amg::getTranslateX3D( layer%2 ? - 0.01 : 0.01 );
603
604 const MuonGMR4::StripDesign& copyEtaDesign{stripLayer.design()};
605 ATH_MSG_VERBOSE("Layer: "<<layer<<" "<<copyEtaDesign);
607 ChannelDesign& etaDesign{newRE->m_etaDesign[layer-1]};
608 etaDesign.type = ChannelDesign::ChannelType::etaStrip;
609 etaDesign.detType = ChannelDesign::DetType::STGC;
610 if (copyEtaDesign.yCutout()) {
611 etaDesign.defineDiamond(copyEtaDesign.shortHalfHeight(),
612 copyEtaDesign.longHalfHeight(),
613 copyEtaDesign.halfWidth(),
614 copyEtaDesign.yCutout());
615 } else {
616 etaDesign.defineTrapezoid(copyEtaDesign.shortHalfHeight(),
617 copyEtaDesign.longHalfHeight(),
618 copyEtaDesign.halfWidth());
619
620 }
621 etaDesign.firstPitch = copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch() + copyEtaDesign.halfWidth();
622 etaDesign.inputPitch = copyEtaDesign.stripPitch();
623 etaDesign.inputWidth = copyEtaDesign.stripWidth();
624 etaDesign.nch = copyEtaDesign.numStrips();
625 ATH_MSG_VERBOSE(m_idHelperSvc->toStringDetEl(copyMe->identify())<<", layer: "<<layer<<", eta-design: "<< copyEtaDesign);
626 etaDesign.setFirstPos(copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch());
628
629 const MuonGMR4::WireGroupDesign& copyPhiDesign{copyMe->wireDesign(layerHash)};
630
631 ChannelDesign& phiDesign{newRE->m_phiDesign[layer-1]};
632 phiDesign.type = ChannelDesign::ChannelType::phiStrip;
633 phiDesign.detType = ChannelDesign::DetType::STGC;
634 if (copyPhiDesign.yCutout() == 0.) {
635 phiDesign.defineTrapezoid(copyPhiDesign.shortHalfHeight(),
636 copyPhiDesign.longHalfHeight(),
637 copyPhiDesign.halfWidth());
638 } else {
639 phiDesign.defineDiamond(copyPhiDesign.shortHalfHeight(),
640 copyPhiDesign.longHalfHeight(),
641 copyPhiDesign.halfWidth(),
642 copyPhiDesign.yCutout());
643 }
644 phiDesign.inputPitch = copyPhiDesign.stripPitch();
645 phiDesign.inputWidth = copyPhiDesign.stripWidth();
646 ATH_MSG_VERBOSE(m_idHelperSvc->toStringDetEl(copyMe->identify())<<", layer: "<<layer<<", phi-design: "<< copyPhiDesign);
647 phiDesign.setFirstPos(copyPhiDesign.firstStripPos().x()); // Position of 1st wire, accounts for staggering
648 phiDesign.firstPitch = copyPhiDesign.numWiresInGroup(1); // Number of Wires in 1st group, group staggering
649 phiDesign.groupWidth = copyPhiDesign.numWiresInGroup(2); // Number of Wires normal group
650 phiDesign.nGroups = copyPhiDesign.numStrips(); // Number of Wire Groups
651 phiDesign.wireCutout = copyPhiDesign.wireCutout(); // Size of "active" wire region for digits
652 phiDesign.nch = copyPhiDesign.nAllWires();
653 phiDesign.isConvertedFromPhaseII = true;
654
655 const MuonGMR4::PadDesign& copyPadDesign{copyMe->padDesign(layerHash)};
656 MuonGM::MuonPadDesign& padDesign{newRE->m_padDesign[layer-1]};
657 padDesign.Length = copyMe->chamberHeight();
658 padDesign.sWidth = copyMe->sChamberLength();
659 padDesign.lWidth = copyMe->lChamberLength();
660 padDesign.Size = 2.*copyPadDesign.halfWidth();
661 padDesign.ysFrame = copyMe->sFrameWidth();
662 padDesign.ylFrame = copyMe->lFrameWidth();
663 padDesign.thickness = copyMe->thickness();
665 if (copyPadDesign.yCutout()) {
666 padDesign.yCutout = copyPadDesign.halfWidth();
667 }
668 padDesign.setR(copyPadDesign.beamlineRadius());
669 padDesign.sPadWidth = 2.*copyPadDesign.shortHalfHeight();
670 padDesign.lPadWidth = 2.*copyPadDesign.longHalfHeight();
671 padDesign.nPadColumns = copyPadDesign.numPadPhi();
672 padDesign.firstPhiPos = copyPadDesign.firstPadPhiDiv();
673 padDesign.inputPhiPitch = copyPadDesign.anglePadPhi();
674 padDesign.PadPhiShift = copyPadDesign.padPhiShift();
675 padDesign.nPadH = copyPadDesign.numPadEta();
676 padDesign.padEtaMax = copyPadDesign.maxPadEta();
677 padDesign.firstRowPos = copyPadDesign.firstPadHeight();
678 padDesign.inputRowPitch = copyPadDesign.padHeight();
679 padDesign.sectorOpeningAngle = copyPadDesign.sectorAngle();
680 padDesign.isConvertedFromPhaseII = true;
681 }
682 newRE->fillCache();
683 ATH_CHECK(dumpAndCompare(gctx, *copyMe, *newRE));
684 cacheObj.detMgr->addsTgcReadoutElement(std::move(newRE));
685
686 }
687 return StatusCode::SUCCESS;
688}
691 SubDetAlignment alignItr = gctx.getStore(ActsTrk::DetectorType::Mdt);
692 const MdtAlignmentStore* alignStore = alignItr ?
693 static_cast<const MdtAlignmentStore*>(alignItr->internalAlignment.get()) : nullptr;
694
695 const std::vector<const MuonGMR4::MdtReadoutElement*> mdtReadOuts{m_detMgr->getAllMdtReadoutElements()};
696 ATH_MSG_INFO("Copy "<<mdtReadOuts.size()<<" Mdt readout elements to the legacy system");
697 for (const MuonGMR4::MdtReadoutElement* copyMe : mdtReadOuts) {
698 const Identifier reId = copyMe->identify();
699 ATH_MSG_DEBUG("Translate "<<m_idHelperSvc->toStringDetEl(reId));
701 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
702 MuonGM::MuonStation* station{nullptr};
703 ATH_CHECK(cloneReadoutVolume(gctx,reId, cacheObj, physVol, station));
704 if (copyMe->multilayer() == 1) {
705 const MuonGMR4::MdtReadoutElement* otherRE = copyMe->complementaryRE();
706 const double height = std::max(copyMe->moduleHeight(), otherRE->moduleHeight()) -
707 (copyMe->tubePitch() - 2. * copyMe->tubeRadius());
708
709 const double modHalTHickO{0.5*otherRE->moduleThickness()},
710 modHalfThick{-0.5*copyMe->moduleThickness()};
711
712 const double thickness = ( (otherRE->asBuiltRefFrame()*(modHalTHickO* Amg::Vector3D::UnitX())) -
713 (copyMe->asBuiltRefFrame()*(modHalfThick* Amg::Vector3D::UnitX()))).z();
714 if (copyMe->isBarrel()) {
715 station->setMdtZsize(height);
716 station->setMdtRsize(thickness);
717 } else {
718 station->setMdtRsize(height);
719 station->setMdtZsize(thickness);
720 }
721 }
722 const MuonGMR4::MdtReadoutElement::parameterBook& pars{copyMe->getParameters()};
723 auto newElement = std::make_unique<MuonGM::MdtReadoutElement>(physVol,
724 m_idHelperSvc->stationNameString(reId),
725 cacheObj.detMgr.get());
726 newElement->setIdentifier(reId);
727 newElement->setMultilayer(copyMe->multilayer());
728 newElement->setNMdtInStation(m_idHelperSvc->mdtIdHelper().multilayerMax(reId));
729 // cppcheck-suppress invalidLifetime; ok: mgr took ownership.
730 newElement->setParentMuonStation(station);
731
733 newElement->setLongSsize(2*pars.longHalfX - 1._cm);
734 newElement->setSsize(2*pars.shortHalfX - 1._cm);
735 newElement->setLongRsize(2*pars.halfY);
736 newElement->setRsize(2*pars.halfY);
737 newElement->setZsize(2*pars.halfHeight);
738 newElement->setLongZsize(2*pars.halfHeight);
739
740 newElement->m_nlayers = copyMe->numLayers();
741 newElement->m_ntubesperlayer = copyMe->numTubesInLay();
742 newElement->m_deadlength = pars.deadLength;
743 newElement->m_endpluglength = pars.endPlugLength;
744 newElement->m_innerRadius = pars.tubeInnerRad;
745 newElement->m_tubeWallThickness = pars.tubeWall;
746 newElement->m_tubepitch = pars.tubePitch;
749
751 const MuonGMR4::MdtTubeLayer& tubeLay{*pars.tubeLayers[0]};
752 unsigned int step{1};
753 double lastLength{2.*tubeLay.uncutHalfLength(1)};
754 for (unsigned tube = 0; tube < copyMe->numTubesInLay(); ++tube) {
755 const double currLength = 2.*tubeLay.uncutHalfLength(tube);
756 ATH_MSG_VERBOSE(m_idHelperSvc->toString(copyMe->identify())<< ", tube "<<tube<<", length: "<<currLength);
757 if (std::abs(lastLength - currLength) > std::numeric_limits<float>::epsilon() ||
758 tube == copyMe->numTubesInLay() -1) {
759 newElement->m_tubelength[step-1] = lastLength;
760 newElement->m_tubelength[step] = currLength;
761 if (step == 1) {
762 newElement->m_ntubesinastep = tube;
763 }
764 lastLength = currLength;
765 ++step;
766 }
767 }
768 newElement->m_nsteps = step;
769
771 double xOffSet{pars.halfY}, yOffSet{pars.halfHeight};
772 if (newElement->barrel()) std::swap(xOffSet, yOffSet);
773 for (unsigned lay = 1; lay <= copyMe->numLayers(); ++lay) {
774 const IdentifierHash tubeHash{copyMe->measurementHash(lay, 1)};
775 const Amg::Vector3D locTube = copyMe->localTubePos(tubeHash);
776 newElement->m_firstwire_x[lay-1] = locTube.z() + xOffSet;
777 newElement->m_firstwire_y[lay-1] = locTube.x() + yOffSet;
778 }
779 MdtAlignmentStore::chamberDistortions distort = alignStore ? alignStore->getDistortion(reId) :
781
782 if (!station->hasMdtAsBuiltParams()){
783 station->setMdtAsBuiltParams(distort.asBuilt);
784 }
785 if (!station->hasBLines()){
786 station->setBline(distort.bLine);
787 }
788 const Amg::Vector3D refPoint = copyMe->bLineReferencePoint();
789 station->setBlineFixedPointInAmdbLRS(refPoint.x(), refPoint.y(), refPoint.z());
790
791 newElement->geoInitDone();
792 newElement->setBLinePar(distort.bLine);
793 newElement->fillCache();
794 ATH_CHECK(dumpAndCompare(gctx, *copyMe, *newElement));
796 cacheObj.detMgr->addMdtReadoutElement(std::move(newElement));
797 }
798 return StatusCode::SUCCESS;
799}
800
802 const MuonGM::MuonReadoutElement& testEle) const{
803
804 if (refEle.identify() != testEle.identify()) {
805 ATH_MSG_FATAL("Two different elements are compared "
806 <<m_idHelperSvc->toString(refEle.identify())<<" vs. "
807 <<m_idHelperSvc->toString(testEle.identify()));
808 return StatusCode::FAILURE;
809 }
810 if (refEle.identHash() != testEle.detectorElementHash()) {
811 ATH_MSG_FATAL("The hashes of the two detector elements "<<m_idHelperSvc->toString(refEle.identify())
812 <<" are completely different "<<refEle.identHash()<<" vs. "<<testEle.detectorElementHash());
813 return StatusCode::FAILURE;
814 }
815 return StatusCode::SUCCESS;
816}
817
819 const MuonGMR4::MmReadoutElement& refEle,
820 const MuonGM::MMReadoutElement& testEle) const {
821
822 if (!m_checkGeo) {
823 return StatusCode::SUCCESS;
824 }
825 ATH_CHECK(checkIdCompability(refEle, testEle));
826
827 ATH_MSG_VERBOSE("Compare basic readout transforms"<<std::endl
828 <<GeoTrf::toString(testEle.absTransform(),true)<<std::endl
829 <<GeoTrf::toString(refEle.localToGlobalTrans(gctx), true));
830 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
831 for (unsigned int gasGap = 1; gasGap <= refEle.nGasGaps(); ++ gasGap) {
832 const Identifier gapId = idHelper.channelID(refEle.identify(), refEle.multilayer(), gasGap, 1);
833
834 const Amg::Transform3D& refTrf{refEle.localToGlobalTrans(gctx, gapId)};
835 const Amg::Transform3D& testTrf{testEle.transform(gapId)};
836 if (!Amg::isIdentity(refTrf.inverse()*testTrf)) {
837 ATH_MSG_FATAL("The layer "<<m_idHelperSvc->toStringGasGap(gapId)<<" does not transform equally"
838 <<GeoTrf::toString(refTrf, true) <<" vs. "<<GeoTrf::toString(testTrf, true));
839 return StatusCode::FAILURE;
840 }
841 const MuonGMR4::StripDesign& stripDesign{refEle.stripLayer(gapId).design()};
842
843 for (int strip = stripDesign.firstStripNumber(); strip <= stripDesign.numStrips(); ++strip) {
844 const Identifier stripId = idHelper.channelID(refEle.identify(), refEle.multilayer(), gasGap, strip);
845 const Amg::Vector3D refStripPos{refEle.stripPosition(gctx, stripId)};
846 const Amg::Vector3D refStripDir{refEle.localToGlobalTrans(gctx, refEle.layerHash(stripId)).linear() * Amg::Vector3D::UnitX()};
847
848 Amg::Vector3D testStripPos{Amg::Vector3D::Zero()};
849 if (!testEle.stripGlobalPosition(stripId, testStripPos)) {
850 ATH_MSG_FATAL("Failed to retrieve strip position "<<m_idHelperSvc->toString(stripId));
851 return StatusCode::FAILURE;
852 }
853 const double dist = refStripDir.dot(refStripPos - testStripPos);
854 if (std::abs(dist) > 10. * Gaudi::Units::micrometer) {
855 ATH_MSG_FATAL("The strip "<<Amg::toString(testStripPos)<<" is not describing the same strip as "
856 <<Amg::toString(refStripPos)<<". Channel "<<m_idHelperSvc->toString(stripId)
857 <<" distance: "<<dist<<" "<<(dist / testEle.m_etaDesign[gasGap -1].inputWidth));
858 return StatusCode::FAILURE;
859 }
860 ATH_MSG_VERBOSE("Channel postion "<<m_idHelperSvc->toString(stripId)<<" match between legacy & new");
861 }
862 }
863 return StatusCode::SUCCESS;
864}
865
867 const MuonGMR4::MdtReadoutElement& refEle,
868 const MuonGM::MdtReadoutElement& testEle) const {
869
870 if (!m_checkGeo) {
871 return StatusCode::SUCCESS;
872 }
873 ATH_CHECK(checkIdCompability(refEle, testEle));
874
875 ATH_MSG_VERBOSE("Detector element "<<m_idHelperSvc->toString(refEle.identify())
876 <<std::endl<<GeoTrf::toString(refEle.localToGlobalTrans(gctx))
877 <<std::endl<<GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform())
878 <<std::endl<<"r-size: "<<testEle.getRsize()<<"/"<<testEle.getLongRsize()
879 <<" s-size: "<<testEle.getSsize()<<"/"<<testEle.getLongSsize()
880 <<" z-size: "<<testEle.getZsize()<<"/"<<testEle.getLongZsize());
881 for (unsigned int lay = 1; lay <= refEle.numLayers(); ++lay){
882 for (unsigned int tube = 1; tube <= refEle.numTubesInLay(); ++tube) {
883 const IdentifierHash tubeHash {refEle.measurementHash(lay,tube)};
884 if (!refEle.isValid(tubeHash)) {
885 ATH_MSG_VERBOSE("SKip layer / tube "<<lay <<","<<tube);
886 continue;
887 }
888 const Amg::Transform3D globToLocal = refEle.globalToLocalTrans(gctx, tubeHash);
889
890 const Amg::Vector3D refPos = refEle.globalTubePos(gctx, tubeHash);
891 const Amg::Vector3D tubePos = testEle.tubePos(lay, tube);
892
893
894 if ( (refPos - tubePos).mag() > Gaudi::Units::micrometer &&
895 (globToLocal*refPos - globToLocal * tubePos).perp() > Gaudi::Units::micrometer) {
896 ATH_MSG_ERROR("Tube positions differ for "<<m_idHelperSvc->toString(refEle.measurementId(tubeHash))
897 <<" reference: "<<GeoTrf::toString(globToLocal*refPos)<<" vs. test: "
898 <<GeoTrf::toString(globToLocal*tubePos) <<" delta: "<<(refPos - tubePos).mag()
899 <<" Transforms "<<std::endl
900 <<" **** "<< GeoTrf::toString(globToLocal.inverse())<<std::endl
901 <<" **** "<< GeoTrf::toString(testEle.transform(lay, tube)));
902 return StatusCode::FAILURE;
903 }
904 ATH_MSG_VERBOSE("Tube positions layer: "<<lay<<", tube: "<<tube
905 <<std::endl<<"reference: "<<GeoTrf::toString(refPos)
906 <<std::endl<<"test: "<<GeoTrf::toString(tubePos)
907 <<std::endl<<testEle.tubeLength(lay, tube)<<"/"<<testEle.getActiveTubeLength(lay, tube)<<"/"
908 <<testEle.getWireLength(lay,tube)<<" vs. "<<refEle.tubeLength(tubeHash)
909 <<"/"<<refEle.activeTubeLength(tubeHash)<<"/"<<refEle.wireLength(tubeHash)
910 <<"/"<<refEle.uncutTubeLength(tubeHash));
911 if (std::abs(testEle.getTubeLengthForCaching(lay,tube) - refEle.uncutTubeLength(tubeHash)) >
912 std::numeric_limits<float>::epsilon() ) {
913 ATH_MSG_FATAL("Different tube length's detected for "<<m_idHelperSvc->toStringDetEl(refEle.identify())
914 << " layer: "<<lay<<", tube: "<<tube<<" -- "<<testEle.getTubeLengthForCaching(lay,tube)<<" (new) vs. "
915 <<refEle.uncutTubeLength(tubeHash)<<" (ref)");
916 return StatusCode::FAILURE;
917 }
918 }
919 }
920
921 return StatusCode::SUCCESS;
922}
924 const MuonGMR4::RpcReadoutElement& refEle,
925 const MuonGM::RpcReadoutElement& testEle) const {
926
927 if (!m_checkGeo) {
928 return StatusCode::SUCCESS;
929 }
930 ATH_CHECK(checkIdCompability(refEle, testEle));
931
932 ATH_MSG_VERBOSE("Compare basic readout transforms"<<std::endl
933 <<" ref: "<<GeoTrf::toString(refEle.localToGlobalTrans(gctx), true)<<std::endl
934 <<" test: "<<GeoTrf::toString(testEle.absTransform(),true)<<std::endl
935 <<"delta: "<<GeoTrf::toString(testEle.absTransform().inverse()*refEle.localToGlobalTrans(gctx), true ));
936 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
937 for (unsigned int gasGap = 1; gasGap <= refEle.nGasGaps(); ++gasGap) {
938 for (int doubPhi = refEle.doubletPhi(); doubPhi <= refEle.doubletPhiMax(); ++doubPhi) {
939 for (bool measPhi : {false, true}) {
940 if (measPhi && !refEle.nPhiStrips()) continue;
941 for (int strip = 1; strip <= testEle.Nstrips(measPhi); ++strip) {
942 const Identifier stripId = idHelper.channelID(refEle.identify(),
943 refEle.doubletZ(),
944 doubPhi, gasGap, measPhi, strip);
945
946 const Amg::Transform3D refTrans{refEle.localToGlobalTrans(gctx, stripId) *
947 (measPhi ? Amg::getRotateZ3D(90_degree) :
948 Amg::Transform3D::Identity())};
949 const Amg::Transform3D& testTrans{testEle.transform(stripId)};
950 if (strip == 1 && !Amg::isIdentity(refTrans.inverse()*testTrans)) {
951 ATH_MSG_ERROR("Transformation for "<<m_idHelperSvc->toString(stripId)<<" - "<<refEle.identHash()<<std::endl
952 <<" *** ref: "<<GeoTrf::toString(refTrans)<<std::endl
953 <<" *** test: "<<GeoTrf::toString(testTrans)<<std::endl
954 <<" -> delta: "<<GeoTrf::toString(refTrans.inverse()*testTrans));
955 return StatusCode::FAILURE;
956 }
957
958 const Amg::Vector3D refStripPos = refEle.stripPosition(gctx, stripId);
959 const Amg::Vector3D testStripPos = testEle.stripPos(stripId);
960 // The threshold here used to be epsilon for a float.
961 // But this was then giving a failure in aarch64,
962 // with a difference of almost exactly 1e-4.
963 // It turned out that that was coming from GeoDeDuplicator,
964 // where to consider two transforms equivalent,
965 // the translations must match to 1e-4. But if the
966 // difference is almost exactly 1e-4, then small FP
967 // differences can be magnified to just about 1e-4.
968 if ((refStripPos - testStripPos).mag() > 2e-4){
969 ATH_MSG_ERROR("Mismatch in strip positions "<<m_idHelperSvc->toString(stripId)
970 <<" ref: "<<Amg::toString(refStripPos)<<" test: "<<Amg::toString(testStripPos)
971 <<" local coordinates -- ref: "<<Amg::toString(refTrans.inverse()*refStripPos)
972 <<" test: "<<Amg::toString(refTrans.inverse()*testStripPos));
973 return StatusCode::FAILURE;
974 }
975 ATH_MSG_VERBOSE("Agreement between new and old geometry for channel "<<m_idHelperSvc->toString(stripId)
976 <<" strip position "<<Amg::toString(refStripPos)
977 <<", local: "<<Amg::toString(refTrans.inverse()*refStripPos));
978 }
979 }
980 }
981 }
982 return StatusCode::SUCCESS;
983}
985 const MuonGMR4::TgcReadoutElement& refEle,
986 const MuonGM::TgcReadoutElement& testEle) const {
987
988 if (!m_checkGeo) {
989 return StatusCode::SUCCESS;
990 }
991 ATH_CHECK(checkIdCompability(refEle, testEle));
992
993 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
994
995 ATH_MSG_VERBOSE("Detector element "<<m_idHelperSvc->toString(refEle.identify())
996 <<std::endl<<GeoTrf::toString(refEle.localToGlobalTrans(gctx), true)
997 <<std::endl<<GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform(), true)
998 <<std::endl<<"r-size: "<<testEle.getRsize()<<"/"<<testEle.getLongRsize()
999 <<" s-size: "<<testEle.getSsize()<<"/"<<testEle.getLongSsize()
1000 <<" z-size: "<<testEle.getZsize()<<"/"<<testEle.getLongZsize());
1001
1002 for (unsigned int gasGap = 1; gasGap <= refEle.nGasGaps(); ++gasGap) {
1003 for (bool isStrip : {false, true}) {
1004 const IdentifierHash layHash = refEle.constructHash(0, gasGap, isStrip);
1005
1006 const Identifier layId = idHelper.channelID(refEle.identify(), gasGap, isStrip, 1);
1007 ATH_MSG_VERBOSE("Test layer "<<m_idHelperSvc->toString(layId)<<", nCh: "<<refEle.numChannels(layHash)<<", layHash: "<<layHash);
1008 if (!refEle.numChannels(layHash)) continue;
1009 const Amg::Transform3D refLayerTrf = refEle.localToGlobalTrans(gctx, refEle.constructHash(0, gasGap, false)) *
1010 (!isStrip ? Amg::Transform3D::Identity()
1011 : Amg::getRotateZ3D(-90._degree));
1012 const Amg::Transform3D& testLayerTrf = testEle.transform(layId);
1013 if (!Amg::isIdentity(refLayerTrf.inverse()* testLayerTrf)) {
1014 ATH_MSG_FATAL("The transformations in "<<m_idHelperSvc->toString(layId)
1015 <<std::endl<<"ref : "<<GeoTrf::toString(refLayerTrf,true)
1016 <<std::endl<<"test: "<<GeoTrf::toString(testLayerTrf,true)
1017 <<" are not identical. ");
1018 return StatusCode::FAILURE;
1019 }
1020 ATH_MSG_VERBOSE("Transformations in "<<m_idHelperSvc->toString(layId)
1021 <<std::endl<<"ref : "<<GeoTrf::toString(refLayerTrf,true)
1022 <<std::endl<<"test: "<<GeoTrf::toString(testLayerTrf,true));
1023
1024 for (unsigned int ch = 1; ch <= refEle.numChannels(layHash); ++ch) {
1025 const IdentifierHash measHash = refEle.constructHash(ch, gasGap, isStrip);
1026 const Identifier measId = refEle.measurementId(measHash);
1027 const Amg::Vector3D refChannel = refEle.channelPosition(gctx, measHash);
1028 const Amg::Vector3D testChannel = testEle.channelPos(measId);
1029 if ((refChannel - testChannel).mag() < std::numeric_limits<float>::epsilon()){
1030 continue;
1031 }
1032 std::stringstream msg{};
1033 msg<<"The channel "<<m_idHelperSvc->toString(measId)
1034 << " is not at the same position "<<Amg::toString(refChannel)
1035 <<" vs. "<<Amg::toString(testChannel)<<". Difference: "
1036 <<(refChannel - testChannel).mag();
1037 if (!isStrip) {
1038 msg<<std::endl<<"*** Test *** - wirePitch: "<<testEle.wirePitch()
1039 <<", tot wires "<<testEle.nWires(gasGap)
1040 <<", wires to reach "<<testEle.nPitchesToGang(gasGap, ch)
1041 <<", wires in gang "<<testEle.nWires(gasGap, ch);
1042 const MuonGMR4::WireGroupDesign& design{refEle.wireGangLayout(gasGap)};
1043 msg<<std::endl<<"*** Ref *** - wirePitch: "<<design.stripPitch()
1044 <<", tot wires "<<testEle.nWires(gasGap)
1045 <<", wires to reach "<<design.numPitchesToGroup(ch)
1046 <<", wires in gang "<<design.numWiresInGroup(ch);
1047 } else {
1048 const Amg::Vector3D locRefPos{refLayerTrf.inverse() * refChannel};
1049 const Amg::Vector3D locTestPos{refLayerTrf.inverse()* testChannel};
1050 msg<<std::endl<<"*** Ref **** - "<<Amg::toString(locRefPos)<<std::endl;
1051 msg<<std::endl<<"*** Test **** - "<<Amg::toString(locTestPos)<<std::endl;
1052 }
1053 ATH_MSG_FATAL(msg.str());
1054 return StatusCode::FAILURE;
1055 }
1056
1057 }
1058 }
1059 return StatusCode::SUCCESS;
1060}
1062 const MuonGMR4::sTgcReadoutElement& refEle,
1063 const MuonGM::sTgcReadoutElement& testEle) const {
1064 if (!m_checkGeo) {
1065 return StatusCode::SUCCESS;
1066 }
1067 ATH_CHECK(checkIdCompability(refEle, testEle));
1068
1069 ATH_MSG_VERBOSE("Compare basic readout transforms"<<std::endl
1070 <<GeoTrf::toString(testEle.absTransform(),true)<<std::endl
1071 <<GeoTrf::toString(refEle.localToGlobalTrans(gctx), true));
1072 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
1073 for (unsigned int gasGap = 1; gasGap <= refEle.numLayers(); ++gasGap) {
1077 const IdentifierHash layHash = refEle.createHash(gasGap, chType, 1);
1078 const unsigned int numChannel = refEle.numChannels(layHash);
1079 constexpr unsigned firstCh = 1;
1080 for (unsigned int channel = firstCh; channel < numChannel ; ++channel) {
1081 Identifier chID{};
1082 bool isValid = false;
1084 const int etaIndex = refEle.padDesign(layHash).padNumber(channel).first;
1085 const int phiIndex = refEle.padDesign(layHash).padNumber(channel).second;
1086 chID = idHelper.padID(refEle.identify(),
1087 refEle.multilayer(),
1088 gasGap, chType, etaIndex, phiIndex, isValid);
1089 } else {
1090 chID = idHelper.channelID(refEle.identify(),
1091 refEle.multilayer(),
1092 gasGap, chType, channel, isValid);
1093 }
1094
1095 if(!isValid) {
1096 ATH_MSG_WARNING("Invalid Identifier detected: " << m_idHelperSvc->toString(chID));
1097 return StatusCode::FAILURE;
1098 }
1099 const IdentifierHash measHash = refEle.measurementHash(chID);
1100 Amg::Transform3D refTrans{refEle.localToGlobalTrans(gctx, refEle.layerHash(measHash))*
1102 const Amg::Transform3D& testTrans{testEle.transform(chID)};
1103 if (channel == firstCh && (!Amg::doesNotDeform(testTrans.inverse()*refTrans)
1104 || (testTrans.inverse()*refTrans).translation().perp() >
1105 std::numeric_limits<float>::epsilon() ) ) {
1106 ATH_MSG_ERROR(__func__<<"() "<<__LINE__<<" - Transformation for "
1107 <<m_idHelperSvc->toString(chID)<<std::endl
1108 <<" *** ref: "<<GeoTrf::toString(refTrans, true)<<std::endl
1109 <<" *** test: "<<GeoTrf::toString(testTrans, true));
1110 return StatusCode::FAILURE;
1111 }
1112 const Amg::Vector3D refChannelPos = refEle.globalChannelPosition(gctx, measHash);
1113
1115 const Amg::Transform3D& testPadTrans{testEle.transform(chID)};
1116 Amg::Vector3D testChannelPos(Amg::Vector3D::Zero());
1117 testEle.stripGlobalPosition(chID, testChannelPos);
1118
1119 const std::array<Amg::Vector3D,4> refPadCorners = refEle.globalPadCorners(gctx, measHash);
1120 std::array<Amg::Vector3D,4> testPadCorners{make_array<Amg::Vector3D, 4>(Amg::Vector3D::Zero())};
1121 testEle.padGlobalCorners(chID, testPadCorners);
1122 for (unsigned int cornerIdx = 0; cornerIdx < refPadCorners.size(); ++cornerIdx) {
1123 const double padCornerDiff = (refPadCorners[cornerIdx] - testPadCorners[cornerIdx]).mag();
1124 if (padCornerDiff - 25. > 1. * Gaudi::Units::micrometer){
1125 ATH_MSG_ERROR("Mismatch in pad Corner " << cornerIdx << ": " <<m_idHelperSvc->toString(chID)
1126 <<" ref: "<<Amg::toString(refPadCorners[cornerIdx])<<" test: "<<Amg::toString(testPadCorners[cornerIdx])
1127 <<" difference: " << padCornerDiff
1128 <<" local coordinates -- ref: "<<Amg::toString(refTrans.inverse()*refPadCorners[cornerIdx])
1129 <<" test: "<<Amg::toString(testPadTrans.inverse()*testPadCorners[cornerIdx]));
1130 return StatusCode::FAILURE;
1131 }
1132 }
1133 const double padChannelDiff = (refChannelPos - testChannelPos).mag();
1134 if (padChannelDiff - 25. > 1. * Gaudi::Units::micrometer){
1135 ATH_MSG_ERROR("Mismatch in pad positions "<<m_idHelperSvc->toString(chID)
1136 <<" ref: "<<Amg::toString(refChannelPos)<<" test: "<<Amg::toString(testChannelPos)
1137 <<" difference: " << padChannelDiff
1138 <<" local coordinates -- ref: "<<Amg::toString(refTrans.inverse()*refChannelPos)
1139 <<" test: "<<Amg::toString(testPadTrans.inverse()*testChannelPos));
1140 return StatusCode::FAILURE;
1141 }
1142 ATH_MSG_VERBOSE("Agreement between new and old geometry for channel "<<m_idHelperSvc->toString(chID)
1143 <<" channel position "<<Amg::toString(refChannelPos));
1144 }
1146 Amg::Vector3D testChannelPos{Amg::Vector3D::Zero()};
1147 testEle.stripGlobalPosition(chID, testChannelPos);
1148 if ((refChannelPos - testChannelPos).mag() > 1. * Gaudi::Units::micrometer){
1149 ATH_MSG_ERROR("Mismatch in strip positions "<<m_idHelperSvc->toString(chID)
1150 <<" ref: "<<Amg::toString(refChannelPos)<<" test: "<<Amg::toString(testChannelPos)
1151 <<" local coordinates -- ref: "<<Amg::toString(testTrans.inverse()*refChannelPos)
1152 <<" test: "<<Amg::toString(testTrans.inverse()*testChannelPos));
1153 return StatusCode::FAILURE;
1154 }
1155 ATH_MSG_VERBOSE("Agreement between new and old geometry for channel "<<m_idHelperSvc->toString(chID)
1156 <<" channel position "<<Amg::toString(refChannelPos));
1157 } else { // wire
1158 Amg::Vector3D testChannelPos{Amg::Vector3D::Zero()};
1159 testEle.stripGlobalPosition(chID, testChannelPos);
1160 Amg::Vector3D localRefPos {testTrans.inverse()*refChannelPos};
1161 Amg::Vector3D localTestPos{testTrans.inverse()*testChannelPos};
1163 if((std::abs(localRefPos.x() -localTestPos.x()) > 1.* Gaudi::Units::micrometer)
1164 || (std::abs(refChannelPos.z() -testChannelPos.z()) > 15.* Gaudi::Units::micrometer)){
1165 ATH_MSG_ERROR("Mismatch in wire positions "<<m_idHelperSvc->toString(chID)
1166 <<" ref: "<<Amg::toString(refChannelPos)<<" test: "<<Amg::toString(testChannelPos)
1167 <<" local coordinates -- ref: "<<Amg::toString(testTrans.inverse()*refChannelPos)
1168 <<" test: "<<Amg::toString(testTrans.inverse()*testChannelPos)
1169 <<"delta X: "<<std::abs(localRefPos.x() -localTestPos.x())
1170 <<", delta Z: "<<std::abs(localRefPos.z() -localTestPos.z()));
1171 return StatusCode::FAILURE;
1172 }
1173 }
1174 }
1175 }
1176 }
1177 return StatusCode::SUCCESS;
1178}
1179}
Scalar perp() const
perp method - perpendicular length
Scalar mag() const
mag method
constexpr std::array< T, N > make_array(const T &def_val)
Helper function to initialize in-place arrays with non-zero values.
Definition ArrayHelper.h:10
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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
static Double_t a
Store holding the transfomations used by the Acts algorithms.
GeoModel::TransientConstSharedPtr< AlignmentStore > AlignmentStorePtr
AlignmentStorePtr & getStore(const DetectorType type)
Returns the mutable alignable store for the ATLAS detector type (Pixel, Mdt, etc.)
void setStore(AlignmentStorePtr store)
Adds the store to the Geometry context.
const ServiceHandle< StoreGateSvc > & detStore() const
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
This is a "hash" representation of an Identifier.
Helper struct to cache simulatenously the As-built and the BLine corrections of the Mdts for fast acc...
chamberDistortions getDistortion(const Identifier &detElId) const
Returns a chamber distortion that's cached for the corresponding Mdt chamber element.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
bool isValid(const IdentifierHash &measHash) const
double moduleHeight() const
Returns the height of the chamber (Distance bottom - topWidth)
Amg::Transform3D asBuiltRefFrame() const
Returns the transformation to go into the reference frame of the as-buit & b-line model starting from...
Amg::Vector3D globalTubePos(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the global position of the tube center.
unsigned int numTubesInLay() const
Returns the number of tubes per layer.
double moduleThickness() const
Returns the thickness of the chamber.
double uncutTubeLength(const IdentifierHash &tubeHash) const
Returns the uncut tube length.
const MdtReadoutElement * complementaryRE() const
Returns the pointer to the other readout element inside the muon station.
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
unsigned int numLayers() const
Returns the number of tube layer.
Helper struct to retrieve the tube lengths and the tube centers directly from the GeoModel tree.
double uncutHalfLength(const unsigned int tube) const
Returns the uncut-half length of the given tube.
const StripLayer & stripLayer(const Identifier &measId) const
unsigned int nGasGaps() const
Returns the number of gas gaps.
int multilayer() const
Returns the multi layer of the element [1-2].
IdentifierHash layerHash(const Identifier &measId) const override final
Amg::Vector3D stripPosition(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the position of the strip center.
static IdentifierHash createHash(const int gasGap, const int strip)
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
const Amg::Transform3D & localToGlobalTrans(const ActsTrk::GeometryContext &ctx) const
Returns the local to global transformation into the ATLAS coordinate system.
IdentifierHash identHash() const
Returns the Identifier has of the Element that is Identical to the detElHash from the id_helper class...
Identifier identify() const override final
Return the athena identifier.
const GeoAlignableTransform * alignableTransform() const
Returnsthe alignable transform of the readout element.
Amg::Transform3D globalToLocalTrans(const ActsTrk::GeometryContext &ctx) const
Transformations to translate between local <-> global coordinates.
double beamlineRadius() const
Returns the distance between the gasGap center and the beamline.
int numPadPhi() const
Returns the number of pads in the Phi direction in the given gasGap layer.
std::pair< int, int > padNumber(const int SeqChannel) const
Returns the pad (eta,phi) for a given pad number in sequence (1,2,3,...18,19,20......
int numPadEta() const
Returns the number of pads in the eta direction in the given layer.
double sectorAngle() const
Function gives the angular width of the sector.
double padPhiShift() const
Returns the staggering shift of inner pad edges in the phi direction.
int maxPadEta() const
Returns the maximum number of pads that can be contained in a column of a pad. Used to match the pad ...
double firstPadHeight() const
Returns the height of the pads that are adjacent to the bottom edge of the trapezoid active area.
double anglePadPhi() const
Returns the angular pitch of the pads in the phi direction.
double padHeight() const
Returns the height of all the pads that are not adjacent to the bottom edge of the trapezoid active a...
double firstPadPhiDiv() const
Returns the angle of the first pad outer edge w.r.t. the gasGap center from the beamline.
Amg::Vector2D stripLeftTop(int stripNumber) const
: Returns the intersection of the left strip edge at the top panel's edge
Amg::Vector2D stripRightTop(int stripNumber) const
: Returns the intersecetion fo the right strip edge at the top panel's edge
Amg::Vector2D stripRightBottom(int stripNumber) const
: Returns the intersecton of the strip right edge at the bottom panel's edge
Amg::Vector2D stripLeftBottom(int stripNumber) const
: Returns the intersection of the left strip edge at the bottom panel's edge
StatusCode buildStation(const ActsTrk::GeometryContext &gctx, const Identifier &stationId, ConstructionCache &cacheObj) const
builds a station object from readout element.
Gaudi::Property< std::string > m_geoDumpName
StatusCode buildMdt(const ActsTrk::GeometryContext &gctx, ConstructionCache &cacheObj) const
StatusCode initialize() override
StatusCode cloneReadoutVolume(const ActsTrk::GeometryContext &gctx, const Identifier &stationId, ConstructionCache &cacheObj, GeoIntrusivePtr< GeoVFullPhysVol > &clonedPhysVol, MuonGM::MuonStation *&station) const
Clones the fullPhysical volume of the readoutElement and embeds it into the associated station.
StatusCode execute(const EventContext &ctx) const override
SG::WriteCondHandleKey< MuonGM::MuonDetectorManager > m_writeKey
StatusCode buildRpc(const ActsTrk::GeometryContext &gctx, ConstructionCache &cacheObj) const
GeoIntrusivePtr< GeoVFullPhysVol > cloneNswWedge(const ActsTrk::GeometryContext &gctx, const MuonGMR4::MuonReadoutElement *nswRE, ConstructionCache &cacheObj) const
Clones the fullPhysicalVolume of the.
StatusCode buildTgc(const ActsTrk::GeometryContext &gctx, ConstructionCache &cacheObj) const
Gaudi::Property< bool > m_dumpGeo
StatusCode buildSTGC(const ActsTrk::GeometryContext &gctx, ConstructionCache &cacheObj) const
StatusCode dumpAndCompare(const ActsTrk::GeometryContext &gctx, const MuonGMR4::RpcReadoutElement &refEle, const MuonGM::RpcReadoutElement &testEle) const
StatusCode checkIdCompability(const MuonGMR4::MuonReadoutElement &refEle, const MuonGM::MuonReadoutElement &testEle) const
StatusCode buildMM(const ActsTrk::GeometryContext &gctx, ConstructionCache &cacheObj) const
SG::ReadCondHandleKeyArray< ActsTrk::DetectorAlignStore > m_alignStoreKeys
const MuonGMR4::MuonDetectorManager * m_detMgr
Gaudi::Property< bool > m_checkGeo
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
unsigned nPhiStrips() const
Number of strips measuring the phi coordinate.
int doubletZ() const
Returns the doublet Z field of the MuonReadoutElement identifier.
int doubletPhi() const
Returns the doublet Phi field of the MuonReadoutElement identifier.
int doubletPhiMax() const
Returns the maximum phi panel.
Amg::Vector3D stripPosition(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the position of the strip center.
unsigned nGasGaps() const
Returns the number of gasgaps described by this ReadOutElement (usally 2 or 3)
double halfWidth() const
Returns the half height of the strip panel.
double stereoAngle() const
Returns the value of the stereo angle.
int firstStripNumber() const
Returns the number of the first strip.
const Amg::Vector2D & firstStripPos() const
Vector indicating the first strip position.
double yCutout() const
Returns the cutout of the diamond.
double stripPitch() const
Distance between two adjacent strips.
double stripWidth() const
Width of a strip.
double shortHalfHeight() const
Returns the shorter half height of the panel.
double longHalfHeight() const
Returns the longer half height of the panel.
virtual int numStrips() const
Number of strips on the panel.
The StripLayer interfaces the 2D description of the strip plane layout with the 3D description of the...
Definition StripLayer.h:19
const StripDesign & design(bool phiView=false) const
Returns the underlying strip design.
const Amg::Transform3D & toOrigin() const
Returns the transformation to go from the strip layer center to the origin of the Strip chamber.
Amg::Vector3D channelPosition(const ActsTrk::GeometryContext &ctx, const Identifier &measId) const
Returns the center of the measurement channel eta measurement: wire gang center phi measurement: stri...
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
static IdentifierHash constructHash(unsigned measCh, unsigned gasGap, const bool isStrip)
Constructs the Hash out of the Identifier fields (channel, gasGap, isStrip)
const WireGroupDesign & wireGangLayout(const IdentifierHash &layHash) const
Returns access to the wire group design of the given gasGap [1-3] If the gap does not have a wires an...
unsigned numChannels(const IdentifierHash &measHash) const
Returns the number of readout channels.
unsigned nGasGaps() const
Returns the number of gasgaps described by this ReadOutElement (usally 2 or 3)
unsigned int numWiresInGroup(unsigned int groupNum) const
Returns the number of wires in a given group.
unsigned int numPitchesToGroup(unsigned int groupNum) const
Returns the number of wire pitches to reach the given group.
double wireCutout() const
Extract the wireCutout for a wireGroup layer.
unsigned int nAllWires() const
Returns the number of all wires.
unsigned numChannels(const IdentifierHash &measHash) const
Returns the number of strips / wires / pads in a given gasGap.
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
const PadDesign & padDesign(const IdentifierHash &measHash) const
Retrieves the readoutElement Layer given the Identifier/Hash.
int multilayer() const
Returns the multilayer of the sTgcReadoutElement.
globalCornerArray globalPadCorners(const ActsTrk::GeometryContext &ctx, const IdentifierHash &measHash) const
unsigned numLayers() const
Returns the number of gas gap layers.
IdentifierHash layerHash(const Identifier &measId) const override final
Transforms the Identifier into a layer hash.
ReadoutChannelType
ReadoutChannelType to distinguish the available readout channels Pad - pad readout channel Strip - et...
Amg::Vector3D globalChannelPosition(const ActsTrk::GeometryContext &ctx, const IdentifierHash &measHash) const
Returns the global pad/strip/wireGroup position.
static IdentifierHash createHash(const unsigned gasGap, const unsigned channelType, const unsigned channel, const unsigned wireInGrp=0)
Create a measurement hash from the Identifier fields.
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
bool stripGlobalPosition(const Identifier &id, Amg::Vector3D &gpos) const
std::array< MuonChannelDesign, 4 > m_etaDesign
double getTubeLengthForCaching(const int tubeLayer, const int tube) const
double getActiveTubeLength(const int tubeLayer, const int tube) const
Amg::Vector3D tubePos(const Identifier &id) const
Returns the global position of the given tube.
virtual const Amg::Transform3D & transform(const Identifier &id) const override final
Return local to global transform associated with this identifier.
double tubeLength(const int tubeLayer, const int tube) const
double getWireLength(const int tubeLayer, const int tube) const
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Get any read out element.
void addsTgcReadoutElement(std::unique_ptr< sTgcReadoutElement > &&reEle)
store the sTGCReadoutElement using as "key" the identifier
void addRpcReadoutElement(std::unique_ptr< RpcReadoutElement > &&reEle)
store the RpcReadoutElement using as "key" the identifier
const MuonStation * getMuonStation(const std::string &stName, int eta, int phi) const
void addMdtReadoutElement(std::unique_ptr< MdtReadoutElement > &&reEle)
store the MdtReadoutElement using as "key" the identifier
void addTgcReadoutElement(std::unique_ptr< TgcReadoutElement > &&reEle)
store the TgcReadoutElement using as "key" the identifier
void addMMReadoutElement(std::unique_ptr< MMReadoutElement > &&reEle)
store the MMReadoutElement using as "key" the identifier
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
IdentifierHash detectorElementHash() const
Returns the IdentifierHash of the detector element.
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
void setBlineFixedPointInAmdbLRS(double s0, double z0, double t0)
PVConstLink getPhysVol() const
bool hasBLines() const
void setMdtAsBuiltParams(const MdtAsBuiltPar *xtomo)
void setMdtRsize(const double rSize)
int nMuonReadoutElements() const
void addMuonReadoutElementWithAlTransf(MuonReadoutElement *a, GeoAlignableTransform *ptrsf, int jobIndex)
void setMdtZsize(const double zSize)
void setBline(const BLinePar *bline)
bool hasMdtAsBuiltParams() const
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
int Nstrips(bool measphi) const
returns the number of strips for the phi or eta plane
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
double nPitchesToGang(int gasGap, int gang) const
Returns the number of wire pitches that have to be travelled to reach gang i.
int nWires(int gasGap) const
Returns the total number of wires in a given gas gap.
double wirePitch() const
Returns the pitch of the wires.
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
bool stripGlobalPosition(const Identifier &id, Amg::Vector3D &gpos) const
bool padGlobalCorners(const Identifier &id, std::array< Amg::Vector3D, 4 > &gcorners) const
pad global corners
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
void addDependency(const EventIDRange &range)
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
static int stationPhiMax(bool endcap)
Identifier channelID(int stationName, int stationEta, int stationPhi, int gasGap, int isStrip, int channel) const
Identifier padID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int padEta, int padPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
std::string to_string(const DetectorType &type)
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ Mm
Maybe not needed in the migration.
@ sTgc
Micromegas (NSW)
@ Mdt
MuonSpectrometer.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
bool isIdentity(const Amg::Transform3D &trans)
Checks whether the transformation is the Identity transformation.
bool doesNotDeform(const Amg::Transform3D &trans)
Checks whether the linear part of the transformation rotates or stetches any of the basis vectors.
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Affine3d Transform3D
Amg::Transform3D getTranslateX3D(const double X)
: Returns a shift transformation along the x-axis
Eigen::Matrix< double, 3, 1 > Vector3D
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Helper struct to store the pointer to the Mdt distrotion parameters, namely the As-built and the BLin...
std::unique_ptr< MuonGM::MuonDetectorManager > detMgr
Pointer to the legacy MuonDetectorManager.
GeoIntrusivePtr< GeoIdentifierTag > newIdTag()
Returns an identifier tag.
std::set< PVConstLink > translatedStations
Set of all translated Physical volumes.
double stereoAngle() const
returns the stereo angle
void defineTrapezoid(double HalfShortY, double HalfLongY, double HalfHeight)
set the trapezoid dimensions
void setFirstPos(const double pos)
Set the position of the first strip along the x-axis.
Parameters defining the design of the readout sTGC pads.
void setR(double R)
access to cache