7 #include <GeoModelKernel/GeoVPhysVol.h>
11 #include <GeoModelKernel/GeoFullPhysVol.h>
37 #include <GaudiKernel/SystemOfUnits.h>
39 #include <GeoModelHelpers/defineWorld.h>
40 #include <GeoModelHelpers/cloneVolume.h>
41 #include <GeoModelHelpers/getChildNodesWithTrf.h>
42 #include <GeoModelHelpers/TransformToStringConverter.h>
43 #include <GeoModelHelpers/GeoShapeUtils.h>
47 #include <GaudiKernel/SystemOfUnits.h>
52 bool hasStationVolume(
const PVConstLink treeTop,
53 const std::set<PVConstLink>& translated) {
54 const unsigned int nCh = treeTop->getNChildVols();
55 for (
unsigned int ch = 0 ;
ch < nCh; ++
ch) {
56 PVConstLink child = treeTop->getChildVol(
ch);
57 if (translated.count(child) ||
58 hasStationVolume(child, translated)){
73 return StatusCode::SUCCESS;
79 if (writeHandle.isValid()) {
80 ATH_MSG_DEBUG(
"The current readout geometry is still valid.");
81 return StatusCode::SUCCESS;
89 if (!readHandle.isValid()) {
91 return StatusCode::FAILURE;
93 writeHandle.addDependency(readHandle);
94 auto alignStore = std::make_unique<ActsTrk::DetectorAlignStore>(**readHandle);
96 if (alignStore->geoModelAlignment) {
97 alignStore->geoModelAlignment->clearPosCache();
99 alignStore->trackingAlignment = std::make_unique<TrackingAlignment>(alignStore->detType);
100 geoContext.setStore(std::move(alignStore));
106 if (geoContext.getStore(detType)) {
110 geoContext.setStore(std::make_unique<ActsTrk::DetectorAlignStore>(detType));
114 cacheObj.
detMgr = std::make_unique<MuonGM::MuonDetectorManager>();
115 cacheObj.
world = createGeoWorld();
124 std::vector<GeoChildNodeWithTrf> treeTops = getChildrenWithRef(
m_detMgr->
getTreeTop(0),
false);
127 for (
const GeoChildNodeWithTrf& treeTop : treeTops) {
131 cacheObj.
world->add(const_pointer_cast(treeTop.volume));
143 return StatusCode::SUCCESS;
153 ATH_MSG_DEBUG(
"Station "<<
stName<<
", stEta: "<<stEta<<
", stPhi: "<<stPhi<<
" already exists.");
154 return StatusCode::SUCCESS;
160 const GeoVFullPhysVol* readOutVol = copyMe->getMaterialGeom();
161 PVConstLink parentVolume = readOutVol->getParent();
164 PVLink parentPhysVol{make_intrusive<GeoFullPhysVol>(parentVolume->getLogVol())};
168 const std::vector<GeoChildNodeWithTrf>
children = getChildrenWithRef(parentVolume,
false);
169 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};
170 for (
const GeoChildNodeWithTrf& child :
children) {
171 std::vector<Amg::Vector3D> edges = getPolyShapeEdges(child.volume->getLogVol()->getShape(),
172 readOutVol->getX().inverse() * child.transform);
189 const double shortS = (maxY1 - minY1);
190 const double longS = (maxY2 - minY2);
191 const double lengthR = (maxX - minX);
192 const double lengthZ = (maxZ - minZ);
196 const Amg::Transform3D stationTransform = alignTrf->getDefTransform().inverse()*parentVolume->getX();
198 for (
const GeoChildNodeWithTrf& child :
children) {
200 const GeoVPhysVol &childVolRef = *child.volume;
201 if (
typeid(childVolRef) ==
typeid(GeoFullPhysVol)) {
205 PVLink childVol = const_pointer_cast<GeoVPhysVol>(child.volume);
206 parentPhysVol->add(cacheObj.
newIdTag());
207 parentPhysVol->add(cacheObj.makeTransform(stationTransform*child.transform));
208 parentPhysVol->add(cloneVolume(childVol));
212 (stationTransform * readOutVol->getX()).inverse();
215 <<
" -- shortS: "<<shortS<<
", longS: "<<longS
216 <<
", lengthR: "<<lengthR<<
", lengthZ: "<<lengthZ
218 <<std::endl<<
"Station transform: "<<
GeoTrf::toString(stationTransform,
true)
219 <<std::endl<<
"Readout transform: "<<
GeoTrf::toString(readOutVol->getX(),
true));
220 auto newStation = std::make_unique<MuonGM::MuonStation>(
stName,
221 shortS, lengthR, lengthZ,
222 longS, lengthR, lengthZ,
223 stEta, stPhi,
false);
224 newStation->setPhysVol(parentPhysVol);
227 GeoIntrusivePtr<GeoAlignableTransform>
trf = make_intrusive<GeoAlignableTransform>(alignedTransform);
228 newStation->setTransform(
trf);
230 newStation->setNominalAmdbLRSToGlobal(
trf->getTransform());
232 cacheObj.
detMgr->addMuonStation(std::move(newStation));
235 cacheObj.
world->add(parentPhysVol);
237 return StatusCode::SUCCESS;
244 GeoIntrusivePtr<GeoVFullPhysVol>& physVol,
255 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
256 parentPhysVol->add(cacheObj.
newIdTag());
268 readOutVol->getParent()->getX() * readOutVol->getX()};
273 parentPhysVol->add(cacheObj.makeTransform(stationTrf*alignNodeToRE));
275 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
276 physVol = dynamic_pointer_cast<GeoVFullPhysVol>(clonedVol);
277 parentPhysVol->add(physVol);
278 return StatusCode::SUCCESS;
283 const std::vector<const MuonGMR4::RpcReadoutElement*> readoutEles =
m_detMgr->getAllRpcReadoutElements();
284 ATH_MSG_INFO(
"Copy "<<readoutEles.size()<<
" Rpc readout elements to the legacy system");
289 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
292 auto newElement = std::make_unique<MuonGM::RpcReadoutElement>(physVol,
294 1, 1,
false, cacheObj.
detMgr.get());
295 const bool aSide{copyMe->stationEta() > 0};
296 newElement->setDoubletPhi(copyMe->doubletPhi());
297 newElement->setDoubletR(copyMe->doubletR());
298 newElement->setDoubletZ(copyMe->doubletZ());
299 newElement->setIdentifier(reId);
300 newElement->setParentMuonStation(station);
301 station->addMuonReadoutElementWithAlTransf(newElement.get(),
nullptr, station->nMuonReadoutElements());
304 newElement->setLongZsize(2.*
pars.halfLength);
305 newElement->setLongSsize(2.*
pars.halfWidth);
306 newElement->setLongRsize(2.*
pars.halfThickness);
307 newElement->setZsize(2.*
pars.halfLength);
308 newElement->setSsize(2.*
pars.halfWidth);
309 newElement->setRsize(2.*
pars.halfThickness);
311 newElement->m_nlayers = copyMe->nGasGaps();
312 newElement->m_phistripwidth = copyMe->stripPhiWidth();
313 newElement->m_etastripwidth = copyMe->stripEtaWidth();
314 newElement->m_phistrippitch = copyMe->stripPhiPitch();
315 newElement->m_etastrippitch = (aSide > 0 ? 1. : -1.) *copyMe->stripEtaPitch();
316 newElement->m_phistriplength = copyMe->stripPhiLength();
317 newElement->m_etastriplength = copyMe->stripEtaLength();
319 newElement->m_nphistripsperpanel = copyMe->nPhiStrips();
320 newElement->m_netastripsperpanel = copyMe->nEtaStrips();
321 newElement->m_nphistrippanels = copyMe->nPhiPanels();
322 newElement->m_hasDEDontop =
true;
323 newElement->m_descratzneg =
false;
325 std::vector<Identifier> gapIds{};
327 for (
int doubPhi = copyMe->doubletPhiMax(); doubPhi >= copyMe->doubletPhi(); --doubPhi) {
328 for (
bool measPhi : {
false,
true}) {
329 if (measPhi && copyMe->nPhiStrips()==0)
continue;
331 const Identifier gapId = idHelper.channelID(copyMe->identify(),
336 gapIds.push_back(gapId);
337 const Amg::Vector3D locStripPos = copyMe->globalToLocalTrans(gctx) * copyMe->stripPosition(gctx, gapId);
339 newElement->m_gasGap_xPos[
gasGap -1] = locStripPos.x();
342 const int dbPIdx = copyMe->doubletPhi() == 2 ? 1 : doubPhi;
344 newElement->m_first_phistrip_s[dbPIdx -1] = locStripPos.y();
345 newElement->m_phistrip_z = locStripPos.z();
347 newElement->m_first_etastrip_z = locStripPos.z();
348 newElement->m_etastrip_s[dbPIdx-1] = locStripPos.y();
353 newElement->fillCache();
356 const int surfaceHash = newElement->surfaceHash(gapId);
357 const int layerHash = newElement->layerHash(gapId);
359 newElement->m_surfaceData->m_layerTransforms[surfaceHash] = refTrf;
360 newElement->m_surfaceData->m_layerCenters[layerHash] = refTrf.translation();
361 newElement->m_surfaceData->m_layerNormals[layerHash] = refTrf.linear() * Amg::Vector3D::UnitZ();
364 cacheObj.
detMgr->addRpcReadoutElement(std::move(newElement));
366 return StatusCode::SUCCESS;
372 std::vector<const MuonGMR4::TgcReadoutElement*> tgcReadouts{
m_detMgr->getAllTgcReadoutElements()};
374 return a->stationEta() >
b->stationEta();
376 ATH_MSG_INFO(
"Copy "<<tgcReadouts.size()<<
" Tgc readout elements to the legacy system");
380 std::map<std::string, std::shared_ptr<TgcReadoutParams>> readoutParMap{};
384 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
388 auto newRE = std::make_unique<MuonGM::TgcReadoutElement>(physVol,
m_idHelperSvc->stationNameString(reId),
390 newRE->setIdentifier(reId);
391 newRE->setParentMuonStation(station);
393 std::shared_ptr<TgcReadoutParams>& readOutPars = readoutParMap[
std::format(
"{:}_{:}", copyMe->chamberDesign(),
394 copyMe->stationEta()> 0?
'A' :
'C')];
400 std::array<WiregangArray, 3> wires{};
402 std::vector<StripArray> botMountings(copyMe->nGasGaps()),
403 topMountings(copyMe->nGasGaps());
405 double wirePitch{0.};
409 nWireGangs[
gasGap -1] = copyMe->numWireGangs(gangHash);
412 <<
" for gas gap "<<
gasGap);
414 if (nWireGangs[
gasGap -1]) {
418 for (
int gang = 1; gang <= design.numStrips(); ++gang) {
419 fillMe[gang -1] = design.numWiresInGroup(gang);
426 for (
int strip = 1; strip <= nCh; ++strip) {
427 botMountings[
gasGap-1][strip-1] = - design.stripLeftBottom(strip).x();
428 topMountings[
gasGap-1][strip-1] = - design.stripLeftTop(strip).x();
430 botMountings[
gasGap-1][nCh] = - design.stripRightBottom(nCh).x();
431 topMountings[
gasGap-1][nCh] = - design.stripRightTop(nCh).x();
432 ATH_MSG_VERBOSE(
"Strip layout\n bottom: "<<botMountings<<
"\n top: "<<topMountings);
435 readOutPars = std::make_unique<TgcReadoutParams>(copyMe->chamberDesign(),
437 idHelper.stationPhiMax(reId),
438 std::move(nWireGangs),
443 std::move(botMountings),
444 std::move(topMountings),
452 const Amg::Vector3D translation{copyMe->globalToLocalTrans(gctx) * copyMe->center(gctx, layHash)};
453 newRE->setPlaneZ(translation.x(),
gasGap);
455 newRE->setRsize(copyMe->moduleHeight());
456 newRE->setSsize(copyMe->moduleWidthS());
457 newRE->setZsize(copyMe->moduleThickness());
459 newRE->setLongRsize(copyMe->moduleHeight());
460 newRE->setLongSsize(copyMe->moduleWidthL());
461 newRE->setLongZsize(copyMe->moduleThickness());
463 newRE->setReadOutParams(readOutPars);
466 cacheObj.
detMgr->addTgcReadoutElement(std::move(newRE));
469 return StatusCode::SUCCESS;
472 GeoIntrusivePtr<GeoVFullPhysVol>
476 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
479 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
480 GeoIntrusivePtr<GeoFullPhysVol> physVol{dynamic_pointer_cast<GeoFullPhysVol>(clonedVol)};
483 cacheObj.
world->add(physVol);
489 const auto alignStore = alignItr ?
490 static_cast<const MmAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
493 cacheObj.
detMgr->setMMPassivation(alignStore->passivation);
495 const std::vector<const MuonGMR4::MmReadoutElement*> mmReadouts{
m_detMgr->getAllMmReadoutElements()};
496 ATH_MSG_INFO(
"Copy "<<mmReadouts.size()<<
" Mm readout elements to the legacy system");
500 GeoIntrusivePtr<GeoVFullPhysVol> physVol{
cloneNswWedge(gctx, copyMe, cacheObj)};
501 auto newRE = std::make_unique<MuonGM::MMReadoutElement>(physVol,
503 copyMe->stationEta(),
504 copyMe->stationPhi(),
505 copyMe->multilayer(), cacheObj.
detMgr.get());
511 newRE->m_Xlg[
gasGap] = stripLayer.toOrigin() *
518 designFrom.longHalfHeight(),
519 designFrom.halfWidth(),
520 designFrom.stereoAngle());
523 designTo.inputPitch = designFrom.stripPitch();
524 designTo.inputWidth = designTo.inputPitch *
std::cos(designTo.stereoAngle());
525 designTo.nMissedBottomEta = designTo.nMissedBottomStereo = designFrom.firstStripNumber() - 1;
526 designTo.totalStrips = designFrom.numStrips();
527 designTo.nch = designFrom.numStrips();
529 designTo.setFirstPos(designFrom.firstStripPos().x() + 0.5*designTo.inputPitch);
533 if (alignStore && alignStore->getBLine(reId)) {
534 newRE->setBLinePar(*alignStore->getBLine(reId));
537 cacheObj.
detMgr->addMMReadoutElement(std::move(newRE));
539 return StatusCode::SUCCESS;
544 auto alignStore = alignItr ?
static_cast<const sTgcAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
546 const std::vector<const MuonGMR4::sTgcReadoutElement*> sTgcReadOuts{
m_detMgr->getAllsTgcReadoutElements()};
547 ATH_MSG_INFO(
"Copy "<<sTgcReadOuts.size()<<
" sTgc readout elements to the legacy system");
552 GeoIntrusivePtr<GeoVFullPhysVol> physVol{
cloneNswWedge(gctx, copyMe, cacheObj)};
554 auto newRE = std::make_unique<MuonGM::sTgcReadoutElement>(physVol,
556 copyMe->stationEta(),
557 copyMe->stationPhi(),
558 copyMe->multilayer(),
561 if (alignStore && alignStore->getBLine(reId)) {
562 newRE->setBLinePar(*alignStore->getBLine(reId));
575 ChannelDesign& etaDesign{newRE->m_etaDesign[
layer-1]};
576 etaDesign.type = ChannelDesign::ChannelType::etaStrip;
578 if (copyEtaDesign.yCutout()) {
579 etaDesign.defineDiamond(copyEtaDesign.shortHalfHeight(),
580 copyEtaDesign.longHalfHeight(),
581 copyEtaDesign.halfWidth(),
582 copyEtaDesign.yCutout());
584 etaDesign.defineTrapezoid(copyEtaDesign.shortHalfHeight(),
585 copyEtaDesign.longHalfHeight(),
586 copyEtaDesign.halfWidth());
589 etaDesign.firstPitch = copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch() + copyEtaDesign.halfWidth();
590 etaDesign.inputPitch = copyEtaDesign.stripPitch();
591 etaDesign.inputWidth = copyEtaDesign.stripWidth();
592 etaDesign.nch = copyEtaDesign.numStrips();
594 etaDesign.setFirstPos(copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch());
599 ChannelDesign& phiDesign{newRE->m_phiDesign[
layer-1]};
600 phiDesign.type = ChannelDesign::ChannelType::phiStrip;
602 if (copyPhiDesign.yCutout() == 0.) {
603 phiDesign.defineTrapezoid(copyPhiDesign.shortHalfHeight(),
604 copyPhiDesign.longHalfHeight(),
605 copyPhiDesign.halfWidth());
607 phiDesign.defineDiamond(copyPhiDesign.shortHalfHeight(),
608 copyPhiDesign.longHalfHeight(),
609 copyPhiDesign.halfWidth(),
610 copyPhiDesign.yCutout());
612 phiDesign.inputPitch = copyPhiDesign.stripPitch();
613 phiDesign.inputWidth = copyPhiDesign.stripWidth();
615 phiDesign.setFirstPos(copyPhiDesign.firstStripPos().x());
616 phiDesign.firstPitch = copyPhiDesign.numWiresInGroup(1);
617 phiDesign.groupWidth = copyPhiDesign.numWiresInGroup(2);
618 phiDesign.nGroups = copyPhiDesign.numStrips();
619 phiDesign.wireCutout = copyPhiDesign.wireCutout();
620 phiDesign.nch = copyPhiDesign.nAllWires();
621 phiDesign.isConvertedFromPhaseII =
true;
625 padDesign.
Length = copyMe->chamberHeight();
626 padDesign.sWidth = copyMe->sChamberLength();
627 padDesign.lWidth = copyMe->lChamberLength();
628 padDesign.Size = 2.*copyPadDesign.halfWidth();
629 padDesign.ysFrame = copyMe->sFrameWidth();
630 padDesign.ylFrame = copyMe->lFrameWidth();
631 padDesign.thickness = copyMe->thickness();
633 if (copyPadDesign.yCutout()) {
634 padDesign.yCutout = copyPadDesign.halfWidth();
636 padDesign.setR(copyPadDesign.beamlineRadius());
637 padDesign.sPadWidth = 2.*copyPadDesign.shortHalfHeight();
638 padDesign.lPadWidth = 2.*copyPadDesign.longHalfHeight();
639 padDesign.nPadColumns = copyPadDesign.numPadPhi();
640 padDesign.firstPhiPos = copyPadDesign.firstPadPhiDiv();
641 padDesign.inputPhiPitch = copyPadDesign.anglePadPhi();
642 padDesign.PadPhiShift = copyPadDesign.padPhiShift();
643 padDesign.nPadH = copyPadDesign.numPadEta();
644 padDesign.padEtaMax = copyPadDesign.maxPadEta();
645 padDesign.firstRowPos = copyPadDesign.firstPadHeight();
646 padDesign.inputRowPitch = copyPadDesign.padHeight();
647 padDesign.sectorOpeningAngle = copyPadDesign.sectorAngle();
648 padDesign.isConvertedFromPhaseII =
true;
652 cacheObj.
detMgr->addsTgcReadoutElement(std::move(newRE));
655 return StatusCode::SUCCESS;
661 static_cast<const MdtAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
663 const std::vector<const MuonGMR4::MdtReadoutElement*> mdtReadOuts{
m_detMgr->getAllMdtReadoutElements()};
664 ATH_MSG_INFO(
"Copy "<<mdtReadOuts.size()<<
" Mdt readout elements to the legacy system");
669 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
672 if (copyMe->multilayer() == 1) {
675 (copyMe->tubePitch() - 2. * copyMe->tubeRadius());
678 modHalfThick{-0.5*copyMe->moduleThickness()};
680 const double thickness = ( (otherRE->
asBuiltRefFrame()*(modHalTHickO* Amg::Vector3D::UnitX())) -
681 (copyMe->asBuiltRefFrame()*(modHalfThick* Amg::Vector3D::UnitX()))).
z();
682 if (copyMe->isBarrel()) {
683 station->setMdtZsize(height);
684 station->setMdtRsize(thickness);
686 station->setMdtRsize(height);
687 station->setMdtZsize(thickness);
691 auto newElement = std::make_unique<MuonGM::MdtReadoutElement>(physVol,
694 newElement->setIdentifier(reId);
695 newElement->setMultilayer(copyMe->multilayer());
696 newElement->setNMdtInStation(
m_idHelperSvc->mdtIdHelper().multilayerMax(reId));
698 newElement->setParentMuonStation(station);
703 newElement->setLongRsize(2*
pars.halfY);
704 newElement->setRsize(2*
pars.halfY);
705 newElement->setZsize(2*
pars.halfHeight);
706 newElement->setLongZsize(2*
pars.halfHeight);
708 newElement->m_nlayers = copyMe->numLayers();
709 newElement->m_ntubesperlayer = copyMe->numTubesInLay();
710 newElement->m_deadlength =
pars.deadLength;
711 newElement->m_endpluglength =
pars.endPlugLength;
712 newElement->m_innerRadius =
pars.tubeInnerRad;
713 newElement->m_tubeWallThickness =
pars.tubeWall;
714 newElement->m_tubepitch =
pars.tubePitch;
720 unsigned int step{1};
721 double lastLength{2.*tubeLay.uncutHalfLength(1)};
722 for (
unsigned tube = 0;
tube < copyMe->numTubesInLay(); ++
tube) {
723 const double currLength = 2.*tubeLay.uncutHalfLength(
tube);
725 if (std::abs(lastLength - currLength) > std::numeric_limits<float>::epsilon() ||
726 tube == copyMe->numTubesInLay() -1) {
727 newElement->m_tubelength[
step-1] = lastLength;
728 newElement->m_tubelength[
step] = currLength;
730 newElement->m_ntubesinastep =
tube;
732 lastLength = currLength;
736 newElement->m_nsteps =
step;
739 double xOffSet{
pars.halfY}, yOffSet{
pars.halfHeight};
740 if (newElement->barrel())
std::swap(xOffSet, yOffSet);
741 for (
unsigned lay = 1; lay <= copyMe->numLayers(); ++lay) {
743 const Amg::Vector3D locTube = copyMe->localTubePos(tubeHash);
744 newElement->m_firstwire_x[lay-1] = locTube.z() + xOffSet;
745 newElement->m_firstwire_y[lay-1] = locTube.x() + yOffSet;
750 if (!station->hasMdtAsBuiltParams()){
751 station->setMdtAsBuiltParams(distort.
asBuilt);
753 if (!station->hasBLines()){
754 station->setBline(distort.
bLine);
756 const Amg::Vector3D refPoint = copyMe->bLineReferencePoint();
757 station->setBlineFixedPointInAmdbLRS(refPoint.x(), refPoint.y(), refPoint.z());
759 newElement->geoInitDone();
760 newElement->setBLinePar(distort.
bLine);
761 newElement->fillCache();
764 cacheObj.
detMgr->addMdtReadoutElement(std::move(newElement));
766 return StatusCode::SUCCESS;
776 return StatusCode::FAILURE;
781 return StatusCode::FAILURE;
783 return StatusCode::SUCCESS;
791 return StatusCode::SUCCESS;
807 return StatusCode::FAILURE;
811 for (
int strip = stripDesign.firstStripNumber(); strip <= stripDesign.numStrips(); ++strip) {
819 return StatusCode::FAILURE;
821 const double dist = refStripDir.dot(refStripPos - testStripPos);
826 return StatusCode::FAILURE;
831 return StatusCode::SUCCESS;
839 return StatusCode::SUCCESS;
845 <<std::endl<<
GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform())
849 for (
unsigned int lay = 1; lay <= refEle.
numLayers(); ++lay){
852 if (!refEle.
isValid(tubeHash)) {
866 <<
GeoTrf::toString(globToLocal*tubePos) <<
" delta: "<<(refPos - tubePos).mag()
867 <<
" Transforms "<<std::endl
870 return StatusCode::FAILURE;
880 std::numeric_limits<float>::epsilon() ) {
884 return StatusCode::FAILURE;
889 return StatusCode::SUCCESS;
896 return StatusCode::SUCCESS;
907 for (
bool measPhi : {
false,
true}) {
908 if (measPhi && !refEle.
nPhiStrips())
continue;
909 for (
int strip = 1; strip <= testEle.
Nstrips(measPhi); ++strip) {
912 doubPhi,
gasGap, measPhi, strip);
921 return StatusCode::FAILURE;
934 if ((refStripPos - testStripPos).
mag() > 2
e-4){
937 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refStripPos)
938 <<
" test: "<<
Amg::toString(refTrans.inverse()*testStripPos));
939 return StatusCode::FAILURE;
943 <<
", local: "<<
Amg::toString(refTrans.inverse()*refStripPos));
948 return StatusCode::SUCCESS;
955 return StatusCode::SUCCESS;
963 <<std::endl<<
GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform(),
true)
969 for (
bool isStrip : {
false,
true}) {
981 <<
" are not identical. ");
982 return StatusCode::FAILURE;
993 if ((refChannel - testChannel).
mag() < std::numeric_limits<float>::epsilon()){
996 std::stringstream
msg{};
998 <<
" is not at the same position "<<
Amg::toString(refChannel)
1000 <<(refChannel - testChannel).
mag();
1002 msg<<std::endl<<
"*** Test *** - wirePitch: "<<testEle.
wirePitch()
1007 msg<<std::endl<<
"*** Ref *** - wirePitch: "<<design.stripPitch()
1009 <<
", wires to reach "<<design.numPitchesToGroup(
ch)
1010 <<
", wires in gang "<<design.numWiresInGroup(
ch);
1012 const Amg::Vector3D locRefPos{refLayerTrf.inverse() * refChannel};
1013 const Amg::Vector3D locTestPos{refLayerTrf.inverse()* testChannel};
1018 return StatusCode::FAILURE;
1023 return StatusCode::SUCCESS;
1029 return StatusCode::SUCCESS;
1038 for (
int chType : {sTgcIdHelper::sTgcChannelTypes::Pad , sTgcIdHelper::sTgcChannelTypes::Strip, sTgcIdHelper::sTgcChannelTypes::Wire}) {
1042 const unsigned int numChannel = refEle.
numChannels(layID);
1043 constexpr
unsigned firstCh = 1;
1047 if(
chType == sTgcIdHelper::sTgcChannelTypes::Pad) {
1050 chID = idHelper.padID(refEle.
identify(),
1054 chID = idHelper.channelID(refEle.
identify(),
1066 || (testTrans.inverse()*refTrans).translation().perp() > std::numeric_limits<float>::epsilon() ) ) {
1070 return StatusCode::FAILURE;
1072 if (
chType == sTgcIdHelper::sTgcChannelTypes::Pad) {
1078 const std::array<Amg::Vector3D,4> refPadCorners = refEle.
globalPadCorners(gctx, chID);
1079 std::array<Amg::Vector3D,4> testPadCorners{make_array<Amg::Vector3D, 4>(
Amg::Vector3D::Zero())};
1081 for (
unsigned int cornerIdx = 0; cornerIdx < refPadCorners.size(); ++cornerIdx) {
1082 const double padCornerDiff = (refPadCorners[cornerIdx] - testPadCorners[cornerIdx]).
mag();
1086 <<
" difference: " << padCornerDiff
1087 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refPadCorners[cornerIdx])
1088 <<
" test: "<<
Amg::toString(testPadTrans.inverse()*testPadCorners[cornerIdx]));
1089 return StatusCode::FAILURE;
1092 const double padChannelDiff = (refChannelPos - testChannelPos).
mag();
1096 <<
" difference: " << padChannelDiff
1097 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refChannelPos)
1098 <<
" test: "<<
Amg::toString(testPadTrans.inverse()*testChannelPos));
1099 return StatusCode::FAILURE;
1104 else if (
chType == sTgcIdHelper::sTgcChannelTypes::Strip){
1111 <<
" local coordinates -- ref: "<<
Amg::toString(testTrans.inverse()*refChannelPos)
1112 <<
" test: "<<
Amg::toString(testTrans.inverse()*testChannelPos));
1113 return StatusCode::FAILURE;
1121 Amg::Vector3D localRefPos {testTrans.inverse()*refChannelPos};
1122 Amg::Vector3D localTestPos{testTrans.inverse()*testChannelPos};
1128 <<
" local coordinates -- ref: "<<
Amg::toString(testTrans.inverse()*refChannelPos)
1129 <<
" test: "<<
Amg::toString(testTrans.inverse()*testChannelPos)
1130 <<
"delta X: "<<std::abs(localRefPos.x() -localTestPos.x())
1131 <<
", delta Z: "<<std::abs(localRefPos.z() -localTestPos.z()));
1132 return StatusCode::FAILURE;
1138 return StatusCode::SUCCESS;