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>
46 #include <GaudiKernel/SystemOfUnits.h>
51 bool hasStationVolume(
const PVConstLink treeTop,
52 const std::set<PVConstLink>& translated) {
53 const unsigned int nCh = treeTop->getNChildVols();
54 for (
unsigned int ch = 0 ;
ch < nCh; ++
ch) {
55 PVConstLink child = treeTop->getChildVol(
ch);
56 if (translated.count(child) ||
57 hasStationVolume(child, translated)){
72 return StatusCode::SUCCESS;
78 if (writeHandle.isValid()) {
79 ATH_MSG_DEBUG(
"The current readout geometry is still valid.");
80 return StatusCode::SUCCESS;
88 if (!readHandle.isValid()) {
90 return StatusCode::FAILURE;
92 writeHandle.addDependency(readHandle);
93 auto alignStore = std::make_unique<ActsTrk::DetectorAlignStore>(**readHandle);
95 if (alignStore->geoModelAlignment) {
96 alignStore->geoModelAlignment->clearPosCache();
98 alignStore->trackingAlignment = std::make_unique<TrackingAlignment>(alignStore->detType);
99 geoContext.setStore(std::move(alignStore));
105 if (geoContext.getStore(detType)) {
109 geoContext.setStore(std::make_unique<ActsTrk::DetectorAlignStore>(detType));
113 cacheObj.
detMgr = std::make_unique<MuonGM::MuonDetectorManager>();
114 cacheObj.
world = createGeoWorld();
123 std::vector<GeoChildNodeWithTrf> treeTops = getChildrenWithRef(
m_detMgr->
getTreeTop(0),
false);
126 for (
const GeoChildNodeWithTrf& treeTop : treeTops) {
130 cacheObj.
world->add(const_pointer_cast(treeTop.volume));
142 return StatusCode::SUCCESS;
153 return StatusCode::SUCCESS;
159 const GeoVFullPhysVol* readOutVol = copyMe->getMaterialGeom();
160 PVConstLink parentVolume = readOutVol->getParent();
163 PVLink parentPhysVol{make_intrusive<GeoFullPhysVol>(parentVolume->getLogVol())};
167 const std::vector<GeoChildNodeWithTrf>
children = getChildrenWithRef(parentVolume,
false);
168 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};
169 for (
const GeoChildNodeWithTrf& child :
children) {
170 std::vector<Amg::Vector3D> edges = getPolyShapeEdges(child.volume->getLogVol()->getShape(),
171 readOutVol->getX().inverse() * child.transform);
188 const double shortS = (maxY1 - minY1);
189 const double longS = (maxY2 - minY2);
190 const double lengthR = (maxX - minX);
191 const double lengthZ = (maxZ - minZ);
195 const Amg::Transform3D stationTransform = alignTrf->getDefTransform().inverse()*parentVolume->getX();
197 for (
const GeoChildNodeWithTrf& child :
children) {
199 const GeoVPhysVol &childVolRef = *child.volume;
200 if (
typeid(childVolRef) ==
typeid(GeoFullPhysVol)) {
204 PVLink childVol = const_pointer_cast<GeoVPhysVol>(child.volume);
205 parentPhysVol->add(cacheObj.
newIdTag());
206 parentPhysVol->add(cacheObj.makeTransform(stationTransform*child.transform));
207 parentPhysVol->add(cloneVolume(childVol));
211 (stationTransform * readOutVol->getX()).
inverse();
213 ATH_MSG_VERBOSE(
"stName "<<
stName<<
","<<stEta<<
","<<stPhi<<
" -- shortS: "<<shortS<<
", longS: "<<longS
214 <<
", lengthR: "<<lengthR<<
", lengthZ "<<lengthZ
216 <<std::endl<<
"Station transform: "<<
GeoTrf::toString(stationTransform,
true)
217 <<std::endl<<
"Readout transform: "<<
GeoTrf::toString(readOutVol->getX(),
true));
218 auto newStation = std::make_unique<MuonGM::MuonStation>(
stName,
219 shortS, lengthR, lengthZ,
220 longS, lengthR, lengthZ,
221 stEta, stPhi,
false);
222 newStation->setPhysVol(parentPhysVol);
225 GeoIntrusivePtr<GeoAlignableTransform>
trf = make_intrusive<GeoAlignableTransform>(alignedTransform);
226 newStation->setTransform(
trf);
228 newStation->setNominalAmdbLRSToGlobal(
trf->getTransform());
230 cacheObj.
detMgr->addMuonStation(std::move(newStation));
233 cacheObj.
world->add(parentPhysVol);
235 return StatusCode::SUCCESS;
242 GeoIntrusivePtr<GeoVFullPhysVol>& physVol,
253 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
254 parentPhysVol->add(cacheObj.
newIdTag());
266 readOutVol->getParent()->getX() * readOutVol->getX()};
271 parentPhysVol->add(cacheObj.makeTransform(stationTrf*alignNodeToRE));
273 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
274 physVol = dynamic_pointer_cast<GeoVFullPhysVol>(clonedVol);
275 parentPhysVol->add(physVol);
276 return StatusCode::SUCCESS;
281 const std::vector<const MuonGMR4::RpcReadoutElement*> readoutEles =
m_detMgr->getAllRpcReadoutElements();
282 ATH_MSG_INFO(
"Copy "<<readoutEles.size()<<
" Rpc readout elements to the legacy system");
287 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
290 auto newElement = std::make_unique<MuonGM::RpcReadoutElement>(physVol,
292 1, 1,
false, cacheObj.
detMgr.get());
293 const bool aSide{copyMe->stationEta() > 0};
294 newElement->setDoubletPhi(copyMe->doubletPhi());
295 newElement->setDoubletR(copyMe->doubletR());
296 newElement->setDoubletZ(copyMe->doubletZ());
297 newElement->setIdentifier(reId);
298 newElement->setParentMuonStation(station);
299 station->addMuonReadoutElementWithAlTransf(newElement.get(),
nullptr, station->nMuonReadoutElements());
302 newElement->setLongZsize(2.*
pars.halfLength);
303 newElement->setLongSsize(2.*
pars.halfWidth);
304 newElement->setLongRsize(2.*
pars.halfThickness);
305 newElement->setZsize(2.*
pars.halfLength);
306 newElement->setSsize(2.*
pars.halfWidth);
307 newElement->setRsize(2.*
pars.halfThickness);
309 newElement->m_nlayers = copyMe->nGasGaps();
310 newElement->m_phistripwidth = copyMe->stripPhiWidth();
311 newElement->m_etastripwidth = copyMe->stripEtaWidth();
312 newElement->m_phistrippitch = copyMe->stripPhiPitch();
313 newElement->m_etastrippitch = (aSide > 0 ? 1. : -1.) *copyMe->stripEtaPitch();
314 newElement->m_phistriplength = copyMe->stripPhiLength();
315 newElement->m_etastriplength = copyMe->stripEtaLength();
317 newElement->m_nphistripsperpanel = copyMe->nPhiStrips();
318 newElement->m_netastripsperpanel = copyMe->nEtaStrips();
319 newElement->m_nphistrippanels = copyMe->nPhiPanels();
320 newElement->m_hasDEDontop =
true;
321 newElement->m_descratzneg =
false;
323 std::vector<Identifier> gapIds{};
325 for (
int doubPhi = copyMe->doubletPhiMax(); doubPhi >= copyMe->doubletPhi(); --doubPhi) {
326 for (
bool measPhi : {
false,
true}) {
327 if (measPhi && copyMe->nPhiStrips()==0)
continue;
329 const Identifier gapId = idHelper.channelID(copyMe->identify(),
334 gapIds.push_back(gapId);
335 const Amg::Vector3D locStripPos = copyMe->globalToLocalTrans(gctx) * copyMe->stripPosition(gctx, gapId);
337 newElement->m_gasGap_xPos[
gasGap -1] = locStripPos.x();
340 const int dbPIdx = copyMe->doubletPhi() == 2 ? 1 : doubPhi;
342 newElement->m_first_phistrip_s[dbPIdx -1] = locStripPos.y();
343 newElement->m_phistrip_z = locStripPos.z();
345 newElement->m_first_etastrip_z = locStripPos.z();
346 newElement->m_etastrip_s[dbPIdx-1] = locStripPos.y();
351 newElement->fillCache();
354 const int surfaceHash = newElement->surfaceHash(gapId);
355 const int layerHash = newElement->layerHash(gapId);
357 newElement->m_surfaceData->m_layerTransforms[surfaceHash] = refTrf;
358 newElement->m_surfaceData->m_layerCenters[layerHash] = refTrf.translation();
359 newElement->m_surfaceData->m_layerNormals[layerHash] = refTrf.linear() * Amg::Vector3D::UnitZ();
362 cacheObj.
detMgr->addRpcReadoutElement(std::move(newElement));
364 return StatusCode::SUCCESS;
370 std::vector<const MuonGMR4::TgcReadoutElement*> tgcReadouts{
m_detMgr->getAllTgcReadoutElements()};
371 std::stable_sort(tgcReadouts.begin(), tgcReadouts.end(),
373 return a->stationEta() > b->stationEta();
375 ATH_MSG_INFO(
"Copy "<<tgcReadouts.size()<<
" Tgc readout elements to the legacy system");
379 std::map<std::string, std::shared_ptr<TgcReadoutParams>> readoutParMap{};
383 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
387 auto newRE = std::make_unique<MuonGM::TgcReadoutElement>(physVol,
m_idHelperSvc->stationNameString(reId),
389 newRE->setIdentifier(reId);
390 newRE->setParentMuonStation(station);
392 std::shared_ptr<TgcReadoutParams>& readOutPars = readoutParMap[copyMe->chamberDesign()];
398 std::array<WiregangArray, 3> wires{};
401 bool stripSet{
false};
402 double wirePitch{0.};
407 nWireGangs[
gasGap -1] = copyMe->numWireGangs(gangHash);
409 if (nWireGangs[
gasGap -1]) {
413 for (
int gang = 1; gang <= design.numStrips(); ++gang) {
414 fillMe[gang -1] = design.numWiresInGroup(gang);
420 for (
int strip = 1; strip <= nCh; ++strip) {
421 botMountings[strip-1] = - design.stripLeftBottom(strip).x();
422 topMountings[strip-1] = - design.stripLeftTop(strip).x();
424 botMountings[nCh] = - design.stripRightBottom(nCh).x();
425 topMountings[nCh] = - design.stripRightTop(nCh).x();
430 readOutPars = std::make_unique<TgcReadoutParams>(copyMe->chamberDesign(),
432 idHelper.stationPhiMax(reId),
433 std::move(nWireGangs),
438 std::move(botMountings),
439 std::move(topMountings),
447 const Amg::Vector3D translation{copyMe->globalToLocalTrans(gctx) * copyMe->center(gctx, layHash)};
448 newRE->setPlaneZ(translation.x(),
gasGap);
450 newRE->setRsize(copyMe->moduleHeight());
451 newRE->setSsize(copyMe->moduleWidthS());
452 newRE->setZsize(copyMe->moduleThickness());
454 newRE->setLongRsize(copyMe->moduleHeight());
455 newRE->setLongSsize(copyMe->moduleWidthL());
456 newRE->setLongZsize(copyMe->moduleThickness());
458 newRE->setReadOutParams(readOutPars);
461 cacheObj.
detMgr->addTgcReadoutElement(std::move(newRE));
464 return StatusCode::SUCCESS;
467 GeoIntrusivePtr<GeoVFullPhysVol>
471 GeoIntrusivePtr<const GeoVFullPhysVol> readOutVol{copyMe->getMaterialGeom()};
474 PVLink clonedVol{cloneVolume(const_pointer_cast<GeoVFullPhysVol>(readOutVol))};
475 GeoIntrusivePtr<GeoFullPhysVol> physVol{dynamic_pointer_cast<GeoFullPhysVol>(clonedVol)};
478 cacheObj.
world->add(physVol);
484 const auto alignStore = alignItr ?
485 static_cast<const MmAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
488 cacheObj.
detMgr->setMMPassivation(alignStore->passivation);
490 const std::vector<const MuonGMR4::MmReadoutElement*> mmReadouts{
m_detMgr->getAllMmReadoutElements()};
491 ATH_MSG_INFO(
"Copy "<<mmReadouts.size()<<
" Mm readout elements to the legacy system");
495 GeoIntrusivePtr<GeoVFullPhysVol> physVol{
cloneNswWedge(gctx, copyMe, cacheObj)};
496 auto newRE = std::make_unique<MuonGM::MMReadoutElement>(physVol,
498 copyMe->stationEta(),
499 copyMe->stationPhi(),
500 copyMe->multilayer(), cacheObj.
detMgr.get());
506 newRE->m_Xlg[
gasGap] = stripLayer.toOrigin() *
513 designFrom.longHalfHeight(),
514 designFrom.halfWidth(),
515 designFrom.stereoAngle());
518 designTo.inputPitch = designFrom.stripPitch();
519 designTo.inputWidth = designTo.inputPitch *
std::cos(designTo.stereoAngle());
520 designTo.nMissedBottomEta = designTo.nMissedBottomStereo = designFrom.firstStripNumber() - 1;
521 designTo.totalStrips = designFrom.numStrips();
522 designTo.nch = designFrom.numStrips();
524 designTo.setFirstPos(designFrom.firstStripPos().x() + 0.5*designTo.inputPitch);
528 if (alignStore && alignStore->getBLine(reId)) {
529 newRE->setBLinePar(*alignStore->getBLine(reId));
532 cacheObj.
detMgr->addMMReadoutElement(std::move(newRE));
534 return StatusCode::SUCCESS;
539 auto alignStore = alignItr ?
static_cast<const sTgcAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
541 const std::vector<const MuonGMR4::sTgcReadoutElement*> sTgcReadOuts{
m_detMgr->getAllsTgcReadoutElements()};
542 ATH_MSG_INFO(
"Copy "<<sTgcReadOuts.size()<<
" sTgc readout elements to the legacy system");
547 GeoIntrusivePtr<GeoVFullPhysVol> physVol{
cloneNswWedge(gctx, copyMe, cacheObj)};
549 auto newRE = std::make_unique<MuonGM::sTgcReadoutElement>(physVol,
551 copyMe->stationEta(),
552 copyMe->stationPhi(),
553 copyMe->multilayer(),
556 if (alignStore && alignStore->getBLine(reId)) {
557 newRE->setBLinePar(*alignStore->getBLine(reId));
570 ChannelDesign& etaDesign{newRE->m_etaDesign[
layer-1]};
571 etaDesign.type = ChannelDesign::ChannelType::etaStrip;
573 if (copyEtaDesign.yCutout()) {
574 etaDesign.defineDiamond(copyEtaDesign.shortHalfHeight(),
575 copyEtaDesign.longHalfHeight(),
576 copyEtaDesign.halfWidth(),
577 copyEtaDesign.yCutout());
579 etaDesign.defineTrapezoid(copyEtaDesign.shortHalfHeight(),
580 copyEtaDesign.longHalfHeight(),
581 copyEtaDesign.halfWidth());
584 etaDesign.firstPitch = copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch() + copyEtaDesign.halfWidth();
585 etaDesign.inputPitch = copyEtaDesign.stripPitch();
586 etaDesign.inputWidth = copyEtaDesign.stripWidth();
587 etaDesign.nch = copyEtaDesign.numStrips();
589 etaDesign.setFirstPos(copyEtaDesign.firstStripPos().x() + 0.5*copyEtaDesign.stripPitch());
594 ChannelDesign& phiDesign{newRE->m_phiDesign[
layer-1]};
595 phiDesign.type = ChannelDesign::ChannelType::phiStrip;
597 if (copyPhiDesign.yCutout() == 0.) {
598 phiDesign.defineTrapezoid(copyPhiDesign.shortHalfHeight(),
599 copyPhiDesign.longHalfHeight(),
600 copyPhiDesign.halfWidth());
602 phiDesign.defineDiamond(copyPhiDesign.shortHalfHeight(),
603 copyPhiDesign.longHalfHeight(),
604 copyPhiDesign.halfWidth(),
605 copyPhiDesign.yCutout());
607 phiDesign.inputPitch = copyPhiDesign.stripPitch();
608 phiDesign.inputWidth = copyPhiDesign.stripWidth();
610 phiDesign.setFirstPos(copyPhiDesign.firstStripPos().x());
611 phiDesign.firstPitch = copyPhiDesign.numWiresInGroup(1);
612 phiDesign.groupWidth = copyPhiDesign.numWiresInGroup(2);
613 phiDesign.nGroups = copyPhiDesign.numStrips();
614 phiDesign.wireCutout = copyPhiDesign.wireCutout();
615 phiDesign.nch = copyPhiDesign.nAllWires();
616 phiDesign.isConvertedFromPhaseII =
true;
620 padDesign.
Length = copyMe->chamberHeight();
621 padDesign.sWidth = copyMe->sChamberLength();
622 padDesign.lWidth = copyMe->lChamberLength();
623 padDesign.Size = 2.*copyPadDesign.halfWidth();
624 padDesign.ysFrame = copyMe->sFrameWidth();
625 padDesign.ylFrame = copyMe->lFrameWidth();
626 padDesign.thickness = copyMe->thickness();
628 if (copyPadDesign.yCutout()) {
629 padDesign.yCutout = copyPadDesign.halfWidth();
631 padDesign.setR(copyPadDesign.beamlineRadius());
632 padDesign.sPadWidth = 2.*copyPadDesign.shortHalfHeight();
633 padDesign.lPadWidth = 2.*copyPadDesign.longHalfHeight();
634 padDesign.nPadColumns = copyPadDesign.numPadPhi();
635 padDesign.firstPhiPos = copyPadDesign.firstPadPhiDiv();
636 padDesign.inputPhiPitch = copyPadDesign.anglePadPhi();
637 padDesign.PadPhiShift = copyPadDesign.padPhiShift();
638 padDesign.nPadH = copyPadDesign.numPadEta();
639 padDesign.padEtaMax = copyPadDesign.maxPadEta();
640 padDesign.firstRowPos = copyPadDesign.firstPadHeight();
641 padDesign.inputRowPitch = copyPadDesign.padHeight();
642 padDesign.sectorOpeningAngle = copyPadDesign.sectorAngle();
643 padDesign.isConvertedFromPhaseII =
true;
647 cacheObj.
detMgr->addsTgcReadoutElement(std::move(newRE));
650 return StatusCode::SUCCESS;
656 static_cast<const MdtAlignmentStore*
>(alignItr->internalAlignment.get()) :
nullptr;
658 const std::vector<const MuonGMR4::MdtReadoutElement*> mdtReadOuts{
m_detMgr->getAllMdtReadoutElements()};
659 ATH_MSG_INFO(
"Copy "<<mdtReadOuts.size()<<
" Mdt readout elements to the legacy system");
664 GeoIntrusivePtr<GeoVFullPhysVol> physVol{};
667 if (copyMe->multilayer() == 1) {
670 (copyMe->tubePitch() - 2. * copyMe->tubeRadius());
673 modHalfThick{-0.5*copyMe->moduleThickness()};
675 const double thickness = ( (otherRE->
asBuiltRefFrame()*(modHalTHickO* Amg::Vector3D::UnitX())) -
676 (copyMe->asBuiltRefFrame()*(modHalfThick* Amg::Vector3D::UnitX()))).
z();
677 if (copyMe->isBarrel()) {
678 station->setMdtZsize(height);
679 station->setMdtRsize(thickness);
681 station->setMdtRsize(height);
682 station->setMdtZsize(thickness);
686 auto newElement = std::make_unique<MuonGM::MdtReadoutElement>(physVol,
689 newElement->setIdentifier(reId);
690 newElement->setMultilayer(copyMe->multilayer());
691 newElement->setNMdtInStation(
m_idHelperSvc->mdtIdHelper().multilayerMax(reId));
693 newElement->setParentMuonStation(station);
698 newElement->setLongRsize(2*
pars.halfY);
699 newElement->setRsize(2*
pars.halfY);
700 newElement->setZsize(2*
pars.halfHeight);
701 newElement->setLongZsize(2*
pars.halfHeight);
703 newElement->m_nlayers = copyMe->numLayers();
704 newElement->m_ntubesperlayer = copyMe->numTubesInLay();
705 newElement->m_deadlength =
pars.deadLength;
706 newElement->m_endpluglength =
pars.endPlugLength;
707 newElement->m_innerRadius =
pars.tubeInnerRad;
708 newElement->m_tubeWallThickness =
pars.tubeWall;
709 newElement->m_tubepitch =
pars.tubePitch;
715 unsigned int step{1};
716 double lastLength{2.*tubeLay.uncutHalfLength(1)};
717 for (
unsigned tube = 0;
tube < copyMe->numTubesInLay(); ++
tube) {
718 const double currLength = 2.*tubeLay.uncutHalfLength(
tube);
720 if (std::abs(lastLength - currLength) > std::numeric_limits<float>::epsilon() ||
721 tube == copyMe->numTubesInLay() -1) {
722 newElement->m_tubelength[
step-1] = lastLength;
723 newElement->m_tubelength[
step] = currLength;
725 newElement->m_ntubesinastep =
tube;
727 lastLength = currLength;
731 newElement->m_nsteps =
step;
734 double xOffSet{
pars.halfY}, yOffSet{
pars.halfHeight};
735 if (newElement->barrel())
std::swap(xOffSet, yOffSet);
736 for (
unsigned lay = 1; lay <= copyMe->numLayers(); ++lay) {
738 const Amg::Vector3D locTube = copyMe->localTubePos(tubeHash);
739 newElement->m_firstwire_x[lay-1] = locTube.z() + xOffSet;
740 newElement->m_firstwire_y[lay-1] = locTube.x() + yOffSet;
745 if (!station->hasMdtAsBuiltParams()){
746 station->setMdtAsBuiltParams(distort.
asBuilt);
748 if (!station->hasBLines()){
749 station->setBline(distort.
bLine);
751 const Amg::Vector3D refPoint = copyMe->bLineReferencePoint();
752 station->setBlineFixedPointInAmdbLRS(refPoint.x(), refPoint.y(), refPoint.z());
754 newElement->geoInitDone();
755 newElement->setBLinePar(distort.
bLine);
756 newElement->fillCache();
759 cacheObj.
detMgr->addMdtReadoutElement(std::move(newElement));
761 return StatusCode::SUCCESS;
771 return StatusCode::FAILURE;
776 return StatusCode::FAILURE;
778 return StatusCode::SUCCESS;
786 return StatusCode::SUCCESS;
802 return StatusCode::FAILURE;
806 for (
int strip = stripDesign.firstStripNumber(); strip <= stripDesign.numStrips(); ++strip) {
814 return StatusCode::FAILURE;
816 const double dist = refStripDir.dot(refStripPos - testStripPos);
821 return StatusCode::FAILURE;
826 return StatusCode::SUCCESS;
834 return StatusCode::SUCCESS;
840 <<std::endl<<
GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform())
844 for (
unsigned int lay = 1; lay <= refEle.
numLayers(); ++lay){
847 if (!refEle.
isValid(tubeHash)) {
861 <<
GeoTrf::toString(globToLocal*tubePos) <<
" delta: "<<(refPos - tubePos).mag()
862 <<
" Transforms "<<std::endl
865 return StatusCode::FAILURE;
875 std::numeric_limits<float>::epsilon() ) {
879 return StatusCode::FAILURE;
884 return StatusCode::SUCCESS;
891 return StatusCode::SUCCESS;
902 for (
bool measPhi : {
false,
true}) {
903 if (measPhi && !refEle.
nPhiStrips())
continue;
904 for (
int strip = 1; strip <= testEle.
Nstrips(measPhi); ++strip) {
907 doubPhi,
gasGap, measPhi, strip);
916 return StatusCode::FAILURE;
929 if ((refStripPos - testStripPos).
mag() > 2
e-4){
932 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refStripPos)
933 <<
" test: "<<
Amg::toString(refTrans.inverse()*testStripPos));
934 return StatusCode::FAILURE;
938 <<
", local: "<<
Amg::toString(refTrans.inverse()*refStripPos));
943 return StatusCode::SUCCESS;
950 return StatusCode::SUCCESS;
958 <<std::endl<<
GeoTrf::toString(testEle.getMaterialGeom()->getAbsoluteTransform(),
true)
964 for (
bool isStrip : {
false,
true}) {
976 <<
" are not identical. ");
977 return StatusCode::FAILURE;
988 if ((refChannel - testChannel).
mag() < std::numeric_limits<float>::epsilon()){
991 std::stringstream
msg{};
993 <<
" is not at the same position "<<
Amg::toString(refChannel)
995 <<(refChannel - testChannel).
mag();
997 msg<<std::endl<<
"*** Test *** - wirePitch: "<<testEle.
wirePitch()
1002 msg<<std::endl<<
"*** Ref *** - wirePitch: "<<design.stripPitch()
1004 <<
", wires to reach "<<design.numPitchesToGroup(
ch)
1005 <<
", wires in gang "<<design.numWiresInGroup(
ch);
1007 const Amg::Vector3D locRefPos{refLayerTrf.inverse() * refChannel};
1008 const Amg::Vector3D locTestPos{refLayerTrf.inverse()* testChannel};
1013 return StatusCode::FAILURE;
1018 return StatusCode::SUCCESS;
1024 return StatusCode::SUCCESS;
1033 for (
int chType : {sTgcIdHelper::sTgcChannelTypes::Pad , sTgcIdHelper::sTgcChannelTypes::Strip, sTgcIdHelper::sTgcChannelTypes::Wire}) {
1037 const unsigned int numChannel = refEle.
numChannels(layID);
1038 constexpr
unsigned firstCh = 1;
1042 if(
chType == sTgcIdHelper::sTgcChannelTypes::Pad) {
1045 chID = idHelper.padID(refEle.
identify(),
1049 chID = idHelper.channelID(refEle.
identify(),
1061 || (testTrans.inverse()*refTrans).translation().perp() > std::numeric_limits<float>::epsilon() ) ) {
1065 return StatusCode::FAILURE;
1067 if (
chType == sTgcIdHelper::sTgcChannelTypes::Pad) {
1073 const std::array<Amg::Vector3D,4> refPadCorners = refEle.
globalPadCorners(gctx, chID);
1074 std::array<Amg::Vector3D,4> testPadCorners{make_array<Amg::Vector3D, 4>(
Amg::Vector3D::Zero())};
1076 for (
unsigned int cornerIdx = 0; cornerIdx < refPadCorners.size(); ++cornerIdx) {
1077 const double padCornerDiff = (refPadCorners[cornerIdx] - testPadCorners[cornerIdx]).
mag();
1081 <<
" difference: " << padCornerDiff
1082 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refPadCorners[cornerIdx])
1083 <<
" test: "<<
Amg::toString(testPadTrans.inverse()*testPadCorners[cornerIdx]));
1084 return StatusCode::FAILURE;
1087 const double padChannelDiff = (refChannelPos - testChannelPos).
mag();
1091 <<
" difference: " << padChannelDiff
1092 <<
" local coordinates -- ref: "<<
Amg::toString(refTrans.inverse()*refChannelPos)
1093 <<
" test: "<<
Amg::toString(testPadTrans.inverse()*testChannelPos));
1094 return StatusCode::FAILURE;
1099 else if (
chType == sTgcIdHelper::sTgcChannelTypes::Strip){
1106 <<
" local coordinates -- ref: "<<
Amg::toString(testTrans.inverse()*refChannelPos)
1107 <<
" test: "<<
Amg::toString(testTrans.inverse()*testChannelPos));
1108 return StatusCode::FAILURE;
1116 Amg::Vector3D localRefPos {testTrans.inverse()*refChannelPos};
1117 Amg::Vector3D localTestPos{testTrans.inverse()*testChannelPos};
1123 <<
" local coordinates -- ref: "<<
Amg::toString(testTrans.inverse()*refChannelPos)
1124 <<
" test: "<<
Amg::toString(testTrans.inverse()*testChannelPos)
1125 <<
"delta X: "<<std::abs(localRefPos.x() -localTestPos.x())
1126 <<
", delta Z: "<<std::abs(localRefPos.z() -localTestPos.z()));
1127 return StatusCode::FAILURE;
1133 return StatusCode::SUCCESS;