the main function which calculates and applies a transformation to each detector element
460 {
461
462 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
465
467
468
469
470
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 const double maxRadius=51.4*CLHEP::cm;
497 const double minRadius=50.5*CLHEP::mm;
498 const double maxLength=158.*CLHEP::cm;
499
504 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
505 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
506 const InDetDD::SiDetectorElementCollection* pixelElements=nullptr;
507 const InDetDD::SiDetectorElementCollection* sctElements=nullptr;
509
510 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(
m_pixelDetEleCollKey);
511 pixelElements = *pixelDetEleHandle;
512 if (not pixelDetEleHandle.isValid() or pixelElements==nullptr) {
514 return StatusCode::FAILURE;
515 }
516 }
518
519 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(
m_SCTDetEleCollKey);
520 sctElements = *sctDetEleHandle;
521 if (not sctDetEleHandle.isValid() or sctElements==nullptr) {
523 return StatusCode::FAILURE;
524 }
525 }
526
527 double mode42BowingAnchorAbsZ = 0.;
529 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator anchorIter =
m_ModuleList.begin();
531 const Identifier& anchorModuleID = anchorIter->first;
535 const double absZ = std::abs(anchorIter->second.z());
536 if (absZ > mode42BowingAnchorAbsZ) mode42BowingAnchorAbsZ = absZ;
537 }
538 }
540 << mode42BowingAnchorAbsZ / CLHEP::mm << " mm" );
541 }
542
543 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator iter =
m_ModuleList.begin(); iter !=
m_ModuleList.end(); ++iter) {
545 const Identifier& ModuleID =
iter->first;
546
547 const InDetDD::SiDetectorElement * SiModule = nullptr;
548
550 const IdentifierHash Pixel_ModuleHash =
m_pixelIdHelper->wafer_hash(ModuleID);
552 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
553
555 const IdentifierHash SCT_ModuleHash =
m_sctIdHelper->wafer_hash(ModuleID);
557 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
558
560
561
562 } else {
563 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
564 }
565
566
567
568
569
570
571
572
573 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
575 if (SiModule){
577 } else {
578 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
579 }
580 }
581 const HepGeom::Point3D<double> center =
iter->second;
582
583
584 double r = center.rho();
585 double phi = center.phi();
586 double z = center.z();
587
588 HepGeom::Transform3D parameterizedTrafo;
589 HepGeom::Transform3D alignmentTrafo;
590
591
592
593 double ScaleFactor = 1.;
594
596 {
600 }
601 else {
603 }
606 }
609 }
610
612 {
616 }
617 else {
619 }
620
622 {
626 }
627 else {
629 }
630 } else {
631 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
632 }
633
635 msg() <<
"radius " <<
r / CLHEP::cm <<
" centimeter" <<
endmsg;
637 msg() <<
"z " <<
z / CLHEP::cm <<
" centimeter" <<
endmsg;
638 if (
msgLvl(MSG::VERBOSE)) {
639 msg() <<
"localToGlobal transformation:" <<
endmsg;
640 msg() <<
"translation: " << localToGlobal.dx() / CLHEP::cm <<
";" << localToGlobal.dy() / CLHEP::cm <<
";" << localToGlobal.dz() / CLHEP::cm <<
endmsg;
642 msg() << localToGlobal.xx() <<
" " << localToGlobal.xy() <<
" " << localToGlobal.xz() <<
endmsg;
643 msg() << localToGlobal.yx() <<
" " << localToGlobal.yy() <<
" " << localToGlobal.yz() <<
endmsg;
644 msg() << localToGlobal.zx() <<
" " << localToGlobal.zy() <<
" " << localToGlobal.zz() <<
endmsg;
645 }
646 }
647
649
650 parameterizedTrafo = HepGeom::Transform3D();
651 }
652
654
656
657 CLHEP::HepRotation rot;
659
660 if (ScaleFactor == 0.0) {
661 parameterizedTrafo = HepGeom::Transform3D();
662 } else {
663 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
664 }
665
666 }
667
669
670
683
684 double randMisX = RandMisX();
685 double randMisY = RandMisY();
686 double randMisZ = RandMisZ();
687
688 double randMisaplha = RandMisalpha();
689 double randMisbeta = RandMisbeta();
690 double randMisgamma = RandMisgamma();
691
692 CLHEP::HepRotation rot;
693 HepGeom::Vector3D<double>
shift;
694
695
696 if (ScaleFactor == 0.0) {
697 parameterizedTrafo = HepGeom::Transform3D();
698 } else {
699 shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
700 rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
701 parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
702
703 }
704
706
709
711
712 } else {
713
715 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
716 }
717
718 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
719 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
720 }
721
723
724
725 int barrelEC = 0;
728
732 const double sideSign = barrelEC > 0 ? 1. : -1.;
733
735 deltaZ = sideSign * inputZ;
737 deltaZ = -sideSign * inputZ;
742 } else {
744 << "; using outward" );
745 deltaZ = sideSign * inputZ;
746 }
747 } else {
748 ATH_MSG_DEBUG(
"will not move this module for ITk endcap z shift " );
749 }
750
751 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ / CLHEP::micrometer <<
" um" );
752 parameterizedTrafo = HepGeom::Translate3D(0, 0, deltaZ);
753 }
754
756
758
764 const double anchorZ = (
z >= 0.) ? mode42BowingAnchorAbsZ : -mode42BowingAnchorAbsZ;
765 const double edgeDeltaX =
getBowingTx(bowingP1, anchorZ);
766 deltaX = rawDeltaX - edgeDeltaX;
767 } else {
768 ATH_MSG_DEBUG(
"will not move this module for ITk pixel barrel bowing " );
769 }
770
771 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX / CLHEP::micrometer <<
" um" );
772 parameterizedTrafo = HepGeom::Translate3D(deltaX, 0, 0);
773 }
774
776
777
780
785
789
790 const bool selectedSubdetector = (isPixelBarrel && selectPixel) || (isStripBarrel && selectStrip);
791
792 bool selectedLayer = false;
794
795 selectedLayer = true;
797
799 } else {
800
802 }
803
807
808 if (selectedSubdetector && selectedLayer &&
r > 0.) {
815 } else {
817 << "; using outward" );
819 }
820
823 } else {
824 ATH_MSG_DEBUG(
"will not move this module for ITk barrel radial shift " );
825 }
826
828 parameterizedTrafo = HepGeom::Translate3D(deltaX, deltaY, 0);
829 }
830
832
833 std::string module_str;
836
838
839
840 HepGeom::Vector3D<double>
shift(0, 0, 0);
843 }
844
845
846 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
849 }
850
851
852 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
853 }
854 }
855
856
857 else {
859
862
864
866 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
867 } else {
868
869 deltaR =
r/maxRadius * maxDeltaR;
870 }
872
874
876 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
877 } else {
878
880 }
882
884
886 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
887 } else {
888
889 deltaR = 2. *
z/maxLength * maxDeltaR;
890 }
891 } else {
892 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
894 }
895
898 }
899
901
904
905 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
907
908
910
912 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
913 } else {
914
916 }
918
920
921 } else {
924 }
925
927 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
928 }
929
931
934
935 deltaZ =
r/maxRadius * maxDeltaZ;
937
939
941 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
942 } else {
943
945 }
947
948
949 deltaZ = 2. *
z/maxLength * maxDeltaZ;
950 } else {
953 }
954
955 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
956 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
957 }
958
959 else {
960
962
963 parameterizedTrafo = HepGeom::Transform3D();
964 }
965 }
966
968
969 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
970 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
971
972
973 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
975
976 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
977 double deltaAlpha = (-2.) *
r * maxAngle/maxLength;
978 ATH_MSG_DEBUG(
"TRT barrel module alpha for twist: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
979
980 CLHEP::HepRotation twistForTRTRotation(HepGeom::Vector3D<double>(center.x(),center.y(),center.z()), deltaAlpha );
981 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
982
983
984 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
986
987 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
988 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
989
990 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
991
992 HepGeom::Vector3D<double> normalVector(center.x(),center.y(),center.z());
993 HepGeom::Vector3D<double> beamVector(0.,0.,1.);
994 HepGeom::Vector3D<double> rotationAxis = normalVector.cross(beamVector);
995 CLHEP::HepRotation twistForTRTRotation(rotationAxis, deltaAlpha );
996 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
997
998 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
999
1000
1001
1003 {
1004 alignmentTrafo = parameterizedTrafo;
1005 }
1006 else {
1007
1008 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
1009 }
1010
1012 msg() <<
"Align Transformation x = (" << alignmentTrafo.getTranslation().x() / CLHEP::micrometer <<
" um)" <<
endmsg;
1013 msg() <<
"Align Transformation y = (" << alignmentTrafo.getTranslation().y() / CLHEP::micrometer <<
" um)" <<
endmsg;
1014 msg() <<
"Align Transformation z = (" << alignmentTrafo.getTranslation().z() / CLHEP::micrometer <<
" um)" <<
endmsg;
1015 msg() <<
"Align Transformation x phi = (" << alignmentTrafo.getRotation().phiX() / CLHEP::deg <<
")" <<
endmsg;
1016 msg() <<
"Align Transformation x Theta = (" << alignmentTrafo.getRotation().thetaX() / CLHEP::deg <<
")" <<
endmsg;
1017 msg() <<
"Align Transformation y phi = (" << alignmentTrafo.getRotation().phiY() / CLHEP::deg <<
")" <<
endmsg;
1018 msg() <<
"Align Transformation y Theta = (" << alignmentTrafo.getRotation().thetaY() / CLHEP::deg <<
")" <<
endmsg;
1019 msg() <<
"Align Transformation z phi = (" << alignmentTrafo.getRotation().phiZ() / CLHEP::deg <<
")" <<
endmsg;
1020 msg() <<
"Align Transformation z Theta = (" << alignmentTrafo.getRotation().thetaZ() / CLHEP::deg <<
")" <<
endmsg;
1021 }
1022
1023
1024 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
1025 HepGeom::Vector3D<double>
1026 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
1027 getTranslation().
z());
1028 alignmentTrafo =
1029 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1030 }
1031 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
1032 HepGeom::Vector3D<double>
1033 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
1034 getTranslation().
z());
1035 alignmentTrafo =
1036 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1037 }
1038 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
1039 HepGeom::Vector3D<double>
1040 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
1041 alignmentTrafo =
1042 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1043 }
1044 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
1045 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
1046 zeroSuppressedRotation.setDelta(0.);
1047 alignmentTrafo =
1048 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
1049 }
1050
1051
1053
1056 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1057 } else {
1058 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1059 }
1062 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1063 } else {
1064 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1065 }
1068
1070 } else {
1072 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1073 } else {
1074 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1075 }
1076 }
1077 } else {
1078 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1079 }
1080
1082 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
1083
1090
1091
1092 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
1095
1096
1097
1098
1102
1103 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
1104
1105
1107
1108 const InDetDD::StripStereoAnnulusDesign *p_design_check =
dynamic_cast<const InDetDD::StripStereoAnnulusDesign*
>(&(SiModule->
design()));
1109 if (p_design_check){
1111 double radialShift_x = SCT_Center[0];
1112 double radialShift_y = SCT_Center[1];
1113 HepGeom::Transform3D radial_shift = HepGeom::Translate3D(radialShift_x,radialShift_y,0);
1114 HepGeom::Transform3D LocalaaGlobal = LocalaGlobal * radial_shift;
1115 HepGeom::Point3D<double> SCT_endcap_alignedPosGlobal = LocalaaGlobal * alignedPosLocal;
1119 }
1120
1121 else {
1125
1126 }
1127
1128 }
1129
1130 else {
1134 }
1135
1136
1158
1159 } else {
1160 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1161 }
1162
1163
1164 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1165 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1166 }
1167
1168 }
1169
1170
1171
1172
1176 } else {
1180 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1182 }
1183 }
1184
1187 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1188 } else {
1189 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1193 }
1194 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1195 if ( StatusCode::SUCCESS
1198 }
1199 }
1200 }
1201
1202 return StatusCode::SUCCESS;
1203
1204 }
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.