the main function which calculates and applies a transformation to each detector element
464 {
465
466 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
469
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500 const double maxRadius=51.4*CLHEP::cm;
501 const double minRadius=50.5*CLHEP::mm;
502 const double maxLength=158.*CLHEP::cm;
503
508 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
509 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
510 const InDetDD::SiDetectorElementCollection* pixelElements=nullptr;
511 const InDetDD::SiDetectorElementCollection* sctElements=nullptr;
513
514 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(
m_pixelDetEleCollKey);
515 pixelElements = *pixelDetEleHandle;
516 if (not pixelDetEleHandle.isValid() or pixelElements==nullptr) {
518 return StatusCode::FAILURE;
519 }
520 }
522
523 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(
m_SCTDetEleCollKey);
524 sctElements = *sctDetEleHandle;
525 if (not sctDetEleHandle.isValid() or sctElements==nullptr) {
527 return StatusCode::FAILURE;
528 }
529 }
530
531 double mode42BowingAnchorAbsZ = 0.;
533 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator anchorIter =
m_ModuleList.begin();
535 const Identifier& anchorModuleID = anchorIter->first;
539 const double absZ = std::abs(anchorIter->second.z());
540 if (absZ > mode42BowingAnchorAbsZ) mode42BowingAnchorAbsZ = absZ;
541 }
542 }
544 << mode42BowingAnchorAbsZ / CLHEP::mm << " mm" );
545 }
546
547 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator iter =
m_ModuleList.begin(); iter !=
m_ModuleList.end(); ++iter) {
549 const Identifier& ModuleID =
iter->first;
550
551 const InDetDD::SiDetectorElement * SiModule = nullptr;
552
554 const IdentifierHash Pixel_ModuleHash =
m_pixelIdHelper->wafer_hash(ModuleID);
556 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
557
559 const IdentifierHash SCT_ModuleHash =
m_sctIdHelper->wafer_hash(ModuleID);
561 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
562
564
565
566 } else {
567 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
568 }
569
570
571
572
573
574
575
576
577 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
579 if (SiModule){
581 } else {
582 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
583 }
584 }
585 const HepGeom::Point3D<double> center =
iter->second;
586
587
588 double r = center.rho();
589 double phi = center.phi();
590 double z = center.z();
591
592 HepGeom::Transform3D parameterizedTrafo;
593 HepGeom::Transform3D alignmentTrafo;
594
595
596
597 double ScaleFactor = 1.;
598
600 {
604 }
605 else {
607 }
610 }
613 }
614
616 {
620 }
621 else {
623 }
624
626 {
630 }
631 else {
633 }
634 } else {
635 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
636 }
637
639 msg() <<
"radius " <<
r / CLHEP::cm <<
" centimeter" <<
endmsg;
641 msg() <<
"z " <<
z / CLHEP::cm <<
" centimeter" <<
endmsg;
642 if (
msgLvl(MSG::VERBOSE)) {
643 msg() <<
"localToGlobal transformation:" <<
endmsg;
644 msg() <<
"translation: " << localToGlobal.dx() / CLHEP::cm <<
";" << localToGlobal.dy() / CLHEP::cm <<
";" << localToGlobal.dz() / CLHEP::cm <<
endmsg;
646 msg() << localToGlobal.xx() <<
" " << localToGlobal.xy() <<
" " << localToGlobal.xz() <<
endmsg;
647 msg() << localToGlobal.yx() <<
" " << localToGlobal.yy() <<
" " << localToGlobal.yz() <<
endmsg;
648 msg() << localToGlobal.zx() <<
" " << localToGlobal.zy() <<
" " << localToGlobal.zz() <<
endmsg;
649 }
650 }
651
653
654 parameterizedTrafo = HepGeom::Transform3D();
655 }
656
658
660
661 CLHEP::HepRotation rot;
663
664 if (ScaleFactor == 0.0) {
665 parameterizedTrafo = HepGeom::Transform3D();
666 } else {
667 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
668 }
669
670 }
671
673
674
687
688 double randMisX = RandMisX();
689 double randMisY = RandMisY();
690 double randMisZ = RandMisZ();
691
692 double randMisaplha = RandMisalpha();
693 double randMisbeta = RandMisbeta();
694 double randMisgamma = RandMisgamma();
695
696 CLHEP::HepRotation rot;
697 HepGeom::Vector3D<double>
shift;
698
699
700 if (ScaleFactor == 0.0) {
701 parameterizedTrafo = HepGeom::Transform3D();
702 } else {
703 shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
704 rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
705 parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
706
707 }
708
710
713
715
716 } else {
717
719 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
720 }
721
722 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
723 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
724 }
725
727
728
729 int barrelEC = 0;
732
736 const double sideSign = barrelEC > 0 ? 1. : -1.;
737
739 deltaZ = sideSign * inputZ;
741 deltaZ = -sideSign * inputZ;
746 } else {
748 << "; using outward" );
749 deltaZ = sideSign * inputZ;
750 }
751 } else {
752 ATH_MSG_DEBUG(
"will not move this module for ITk endcap z shift " );
753 }
754
755 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ / CLHEP::micrometer <<
" um" );
756 parameterizedTrafo = HepGeom::Translate3D(0, 0, deltaZ);
757 }
758
760
762
768 const double anchorZ = (
z >= 0.) ? mode42BowingAnchorAbsZ : -mode42BowingAnchorAbsZ;
769 const double edgeDeltaX =
getBowingTx(bowingP1, anchorZ);
770 deltaX = rawDeltaX - edgeDeltaX;
771 } else {
772 ATH_MSG_DEBUG(
"will not move this module for ITk pixel barrel bowing " );
773 }
774
775 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX / CLHEP::micrometer <<
" um" );
776 parameterizedTrafo = HepGeom::Translate3D(deltaX, 0, 0);
777 }
778
780
781
784
789
793
794 const bool selectedSubdetector = (isPixelBarrel && selectPixel) || (isStripBarrel && selectStrip);
795
796 bool selectedLayer = false;
798
799 selectedLayer = true;
801
803 } else {
804
806 }
807
811
812 if (selectedSubdetector && selectedLayer &&
r > 0.) {
819 } else {
821 << "; using outward" );
823 }
824
827 } else {
828 ATH_MSG_DEBUG(
"will not move this module for ITk barrel radial shift " );
829 }
830
832 parameterizedTrafo = HepGeom::Translate3D(deltaX, deltaY, 0);
833 }
834
836
837 std::string module_str;
840
842
843
844 HepGeom::Vector3D<double>
shift(0, 0, 0);
847 }
848
849
850 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
853 }
854
855
856 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
857 }
858 }
859
860
861 else {
863
866
868
870 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
871 } else {
872
873 deltaR =
r/maxRadius * maxDeltaR;
874 }
876
878
880 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
881 } else {
882
884 }
886
888
890 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
891 } else {
892
893 deltaR = 2. *
z/maxLength * maxDeltaR;
894 }
895 } else {
896 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
898 }
899
902 }
903
905
908
909 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
911
912
914
916 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
917 } else {
918
920 }
922
924
925 } else {
928 }
929
931 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
932 }
933
935
938
939 deltaZ =
r/maxRadius * maxDeltaZ;
941
943
945 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
946 } else {
947
949 }
951
952
953 deltaZ = 2. *
z/maxLength * maxDeltaZ;
954 } else {
957 }
958
959 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
960 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
961 }
962
963 else {
964
966
967 parameterizedTrafo = HepGeom::Transform3D();
968 }
969 }
970
972
973 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
974 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
975
976
977 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
979
980 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
981 double deltaAlpha = (-2.) *
r * maxAngle/maxLength;
982 ATH_MSG_DEBUG(
"TRT barrel module alpha for twist: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
983
984 CLHEP::HepRotation twistForTRTRotation(HepGeom::Vector3D<double>(center.x(),center.y(),center.z()), deltaAlpha );
985 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
986
987
988 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
990
991 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
992 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
993
994 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
995
996 HepGeom::Vector3D<double> normalVector(center.x(),center.y(),center.z());
997 HepGeom::Vector3D<double> beamVector(0.,0.,1.);
998 HepGeom::Vector3D<double> rotationAxis = normalVector.cross(beamVector);
999 CLHEP::HepRotation twistForTRTRotation(rotationAxis, deltaAlpha );
1000 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
1001
1002 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
1003
1004
1005
1007 {
1008 alignmentTrafo = parameterizedTrafo;
1009 }
1010 else {
1011
1012 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
1013 }
1014
1016 msg() <<
"Align Transformation x = (" << alignmentTrafo.getTranslation().x() / CLHEP::micrometer <<
" um)" <<
endmsg;
1017 msg() <<
"Align Transformation y = (" << alignmentTrafo.getTranslation().y() / CLHEP::micrometer <<
" um)" <<
endmsg;
1018 msg() <<
"Align Transformation z = (" << alignmentTrafo.getTranslation().z() / CLHEP::micrometer <<
" um)" <<
endmsg;
1019 msg() <<
"Align Transformation x phi = (" << alignmentTrafo.getRotation().phiX() / CLHEP::deg <<
")" <<
endmsg;
1020 msg() <<
"Align Transformation x Theta = (" << alignmentTrafo.getRotation().thetaX() / CLHEP::deg <<
")" <<
endmsg;
1021 msg() <<
"Align Transformation y phi = (" << alignmentTrafo.getRotation().phiY() / CLHEP::deg <<
")" <<
endmsg;
1022 msg() <<
"Align Transformation y Theta = (" << alignmentTrafo.getRotation().thetaY() / CLHEP::deg <<
")" <<
endmsg;
1023 msg() <<
"Align Transformation z phi = (" << alignmentTrafo.getRotation().phiZ() / CLHEP::deg <<
")" <<
endmsg;
1024 msg() <<
"Align Transformation z Theta = (" << alignmentTrafo.getRotation().thetaZ() / CLHEP::deg <<
")" <<
endmsg;
1025 }
1026
1027
1028 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
1029 HepGeom::Vector3D<double>
1030 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
1031 getTranslation().
z());
1032 alignmentTrafo =
1033 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1034 }
1035 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
1036 HepGeom::Vector3D<double>
1037 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
1038 getTranslation().
z());
1039 alignmentTrafo =
1040 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1041 }
1042 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
1043 HepGeom::Vector3D<double>
1044 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
1045 alignmentTrafo =
1046 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1047 }
1048 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
1049 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
1050 zeroSuppressedRotation.setDelta(0.);
1051 alignmentTrafo =
1052 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
1053 }
1054
1055
1057
1060 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1061 } else {
1062 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1063 }
1066 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1067 } else {
1068 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1069 }
1072
1074 } else {
1076 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1077 } else {
1078 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1079 }
1080 }
1081 } else {
1082 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1083 }
1084
1086 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
1087
1094
1097 return StatusCode::FAILURE;
1098 }
1099 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
1102
1103
1104
1105
1109
1110 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
1111
1112
1114
1115 const InDetDD::StripStereoAnnulusDesign *p_design_check =
dynamic_cast<const InDetDD::StripStereoAnnulusDesign*
>(&(SiModule->
design()));
1116 if (p_design_check){
1118 double radialShift_x = SCT_Center[0];
1119 double radialShift_y = SCT_Center[1];
1120 HepGeom::Transform3D radial_shift = HepGeom::Translate3D(radialShift_x,radialShift_y,0);
1121 HepGeom::Transform3D LocalaaGlobal = LocalaGlobal * radial_shift;
1122 HepGeom::Point3D<double> SCT_endcap_alignedPosGlobal = LocalaaGlobal * alignedPosLocal;
1126 }
1127
1128 else {
1132
1133 }
1134
1135 }
1136
1137 else {
1141 }
1142
1143
1165
1166 } else {
1167 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1168 }
1169
1170
1171 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1172 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1173 }
1174
1175 }
1176
1177
1178
1179
1183 } else {
1187 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1189 }
1190 }
1191
1194 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1195 } else {
1196 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1200 }
1201 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1202 if ( StatusCode::SUCCESS
1205 }
1206 }
1207 }
1208
1209 return StatusCode::SUCCESS;
1210
1211 }
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar deltaR(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
bool msgLvl(const MSG::Level lvl) const
static constexpr uint32_t MAXRUN
static constexpr uint32_t MINEVENT
static constexpr uint32_t MAXEVENT
static constexpr uint32_t MINRUN
Gaudi::Property< double > m_RndmMisalignWidth_gamma
Gaudi::Property< double > m_RndmMisalignWidth_alpha
NTuple::Item< double > m_AlignResults_z
AP normal to module plane.
NTuple::Item< double > m_Initial_center_x
Initial global center of module.
double getBowingTx(double p1, double z)
NTuple::Item< long > m_AlignResults_Identifier_PixelSCT
ID information for this module.
Gaudi::Property< double > m_Misalign_x
Gaudi::Property< double > m_RndmMisalignWidth_z
NTuple::Item< double > m_Global_center_x
Misaligned global center of module.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Gaudi::Property< double > m_Misalign_z
Gaudi::Property< double > m_RndmMisalignWidth_beta
double getBowingMagParam(double temp_shift)
NTuple::Item< long > m_AlignResults_Identifier_BarrelEC
ID information for this module.
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
NTuple::Item< double > m_Initial_center_z
Initial global center of module.
NTuple::Item< long > m_AlignResults_Identifier_LayerDisc
ID information for this module.
Gaudi::Property< double > m_Misalign_y
NTuple::Item< double > m_AlignResults_x
Alignment parameter sensitive coordinate.
NTuple::Item< double > m_Global_center_y
Misaligned global center of module.
NTuple::Item< double > m_Initial_center_y
Initial global center of module.
NTuple::Item< long > m_AlignResults_Identifier_Eta
ID information for this module.
NTuple::Item< double > m_AlignResults_alpha
AP rotation around x-axis.
NTuple::Item< long > m_AlignResults_Identifier_Phi
ID information for this module.
Gaudi::Property< double > m_RndmMisalignWidth_y
Gaudi::Property< double > m_RndmMisalignWidth_x
NTuple::Item< long > m_AlignResults_Identifier_ID
ID information for this module.
Gaudi::Property< double > m_Misalign_beta
NTuple::Item< double > m_AlignResults_y
AP not-so-sensitive coordinate.
NTuple::Item< double > m_Global_center_z
Misaligned global center of module.
NTuple::Item< double > m_AlignResults_gamma
AP rotation around z-axis.
Gaudi::Property< double > m_Misalign_gamma
NTuple::Item< double > m_AlignResults_beta
AP rotation aorund y-axis.
Gaudi::Property< double > m_Misalign_alpha
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
const Amg::Transform3D & moduleTransform() const
Module to global frame transform.
virtual Amg::Vector3D sensorCenter() const override
Return the centre of a sensor in the local reference frame.
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.