466 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service(
"RndmGenSvc")};
500 const double maxRadius=51.4*CLHEP::cm;
501 const double minRadius=50.5*CLHEP::mm;
502 const double maxLength=158.*CLHEP::cm;
508 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
509 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
515 pixelElements = *pixelDetEleHandle;
516 if (not pixelDetEleHandle.
isValid() or pixelElements==
nullptr) {
518 return StatusCode::FAILURE;
524 sctElements = *sctDetEleHandle;
525 if (not sctDetEleHandle.
isValid() or sctElements==
nullptr) {
527 return StatusCode::FAILURE;
531 double mode42BowingAnchorAbsZ = 0.;
535 const Identifier& anchorModuleID = anchorIter->first;
539 const double absZ = std::abs(anchorIter->second.z());
540 if (absZ > mode42BowingAnchorAbsZ) mode42BowingAnchorAbsZ = absZ;
544 << mode42BowingAnchorAbsZ / CLHEP::mm <<
" mm" );
556 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
561 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
567 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
577 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
582 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
585 const HepGeom::Point3D<double> center = iter->second;
588 double r = center.rho();
589 double phi = center.phi();
590 double z = center.z();
592 HepGeom::Transform3D parameterizedTrafo;
593 HepGeom::Transform3D alignmentTrafo;
597 double ScaleFactor = 1.;
635 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
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;
654 parameterizedTrafo = HepGeom::Transform3D();
661 CLHEP::HepRotation rot;
664 if (ScaleFactor == 0.0) {
665 parameterizedTrafo = HepGeom::Transform3D();
667 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
688 double randMisX = RandMisX();
689 double randMisY = RandMisY();
690 double randMisZ = RandMisZ();
692 double randMisaplha = RandMisalpha();
693 double randMisbeta = RandMisbeta();
694 double randMisgamma = RandMisgamma();
696 CLHEP::HepRotation rot;
697 HepGeom::Vector3D<double> shift;
700 if (ScaleFactor == 0.0) {
701 parameterizedTrafo = HepGeom::Transform3D();
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);}
719 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
722 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
723 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
736 const double sideSign = barrelEC > 0 ? 1. : -1.;
739 deltaZ = sideSign * inputZ;
741 deltaZ = -sideSign * inputZ;
748 <<
"; using outward" );
749 deltaZ = sideSign * inputZ;
752 ATH_MSG_DEBUG(
"will not move this module for ITk endcap z shift " );
755 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ / CLHEP::micrometer <<
" um" );
756 parameterizedTrafo = HepGeom::Translate3D(0, 0, deltaZ);
768 const double anchorZ = (
z >= 0.) ? mode42BowingAnchorAbsZ : -mode42BowingAnchorAbsZ;
769 const double edgeDeltaX =
getBowingTx(bowingP1, anchorZ);
770 deltaX = rawDeltaX - edgeDeltaX;
772 ATH_MSG_DEBUG(
"will not move this module for ITk pixel barrel bowing " );
775 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX / CLHEP::micrometer <<
" um" );
776 parameterizedTrafo = HepGeom::Translate3D(deltaX, 0, 0);
792 if (isStripBarrel) layer =
m_sctIdHelper->layer_disk(ModuleID);
794 const bool selectedSubdetector = (isPixelBarrel && selectPixel) || (isStripBarrel && selectStrip);
796 bool selectedLayer =
false;
799 selectedLayer =
true;
812 if (selectedSubdetector && selectedLayer &&
r > 0.) {
821 <<
"; using outward" );
825 deltaX =
deltaR * center.x() /
r;
826 deltaY =
deltaR * center.y() /
r;
828 ATH_MSG_DEBUG(
"will not move this module for ITk barrel radial shift " );
832 parameterizedTrafo = HepGeom::Translate3D(deltaX, deltaY, 0);
837 std::string module_str;
844 HepGeom::Vector3D<double> shift(0, 0, 0);
850 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
856 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
870 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
873 deltaR =
r/maxRadius * maxDeltaR;
880 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
883 deltaR = cos ( 2*
phi ) *
r/maxRadius * maxDeltaR;
890 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
893 deltaR = 2. *
z/maxLength * maxDeltaR;
896 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
909 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
916 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
931 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
939 deltaZ =
r/maxRadius * maxDeltaZ;
945 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
948 deltaZ = cos ( 2*
phi ) * maxDeltaZ;
953 deltaZ = 2. *
z/maxLength * maxDeltaZ;
959 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
960 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
967 parameterizedTrafo = HepGeom::Transform3D();
973 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
974 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
977 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
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" );
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.));
988 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
991 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
992 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
994 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
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.));
1002 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
1008 alignmentTrafo = parameterizedTrafo;
1012 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
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;
1028 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
1029 HepGeom::Vector3D<double>
1030 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
1031 getTranslation().
z());
1033 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1035 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
1036 HepGeom::Vector3D<double>
1037 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
1038 getTranslation().
z());
1040 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1042 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
1043 HepGeom::Vector3D<double>
1044 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
1046 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1048 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
1049 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
1050 zeroSuppressedRotation.setDelta(0.);
1052 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
1060 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1062 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1066 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1068 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1076 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1078 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1082 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1085 double alpha, beta, gamma;
1086 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
1097 return StatusCode::FAILURE;
1099 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
1110 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
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;
1167 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1171 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1172 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1187 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1194 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1196 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1201 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1202 if ( StatusCode::SUCCESS
1209 return StatusCode::SUCCESS;