462 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service(
"RndmGenSvc")};
496 const double maxRadius=51.4*CLHEP::cm;
497 const double minRadius=50.5*CLHEP::mm;
498 const double maxLength=158.*CLHEP::cm;
504 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
505 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
511 pixelElements = *pixelDetEleHandle;
512 if (not pixelDetEleHandle.
isValid() or pixelElements==
nullptr) {
514 return StatusCode::FAILURE;
520 sctElements = *sctDetEleHandle;
521 if (not sctDetEleHandle.
isValid() or sctElements==
nullptr) {
523 return StatusCode::FAILURE;
527 double mode42BowingAnchorAbsZ = 0.;
531 const Identifier& anchorModuleID = anchorIter->first;
535 const double absZ = std::abs(anchorIter->second.z());
536 if (absZ > mode42BowingAnchorAbsZ) mode42BowingAnchorAbsZ = absZ;
540 << mode42BowingAnchorAbsZ / CLHEP::mm <<
" mm" );
552 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
557 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
563 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
573 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
578 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
581 const HepGeom::Point3D<double> center = iter->second;
584 double r = center.rho();
585 double phi = center.phi();
586 double z = center.z();
588 HepGeom::Transform3D parameterizedTrafo;
589 HepGeom::Transform3D alignmentTrafo;
593 double ScaleFactor = 1.;
631 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
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;
650 parameterizedTrafo = HepGeom::Transform3D();
657 CLHEP::HepRotation rot;
660 if (ScaleFactor == 0.0) {
661 parameterizedTrafo = HepGeom::Transform3D();
663 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
684 double randMisX = RandMisX();
685 double randMisY = RandMisY();
686 double randMisZ = RandMisZ();
688 double randMisaplha = RandMisalpha();
689 double randMisbeta = RandMisbeta();
690 double randMisgamma = RandMisgamma();
692 CLHEP::HepRotation rot;
693 HepGeom::Vector3D<double> shift;
696 if (ScaleFactor == 0.0) {
697 parameterizedTrafo = HepGeom::Transform3D();
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);}
715 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
718 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
719 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
732 const double sideSign = barrelEC > 0 ? 1. : -1.;
735 deltaZ = sideSign * inputZ;
737 deltaZ = -sideSign * inputZ;
744 <<
"; using outward" );
745 deltaZ = sideSign * inputZ;
748 ATH_MSG_DEBUG(
"will not move this module for ITk endcap z shift " );
751 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ / CLHEP::micrometer <<
" um" );
752 parameterizedTrafo = HepGeom::Translate3D(0, 0, deltaZ);
764 const double anchorZ = (
z >= 0.) ? mode42BowingAnchorAbsZ : -mode42BowingAnchorAbsZ;
765 const double edgeDeltaX =
getBowingTx(bowingP1, anchorZ);
766 deltaX = rawDeltaX - edgeDeltaX;
768 ATH_MSG_DEBUG(
"will not move this module for ITk pixel barrel bowing " );
771 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX / CLHEP::micrometer <<
" um" );
772 parameterizedTrafo = HepGeom::Translate3D(deltaX, 0, 0);
788 if (isStripBarrel) layer =
m_sctIdHelper->layer_disk(ModuleID);
790 const bool selectedSubdetector = (isPixelBarrel && selectPixel) || (isStripBarrel && selectStrip);
792 bool selectedLayer =
false;
795 selectedLayer =
true;
808 if (selectedSubdetector && selectedLayer &&
r > 0.) {
817 <<
"; using outward" );
821 deltaX =
deltaR * center.x() /
r;
822 deltaY =
deltaR * center.y() /
r;
824 ATH_MSG_DEBUG(
"will not move this module for ITk barrel radial shift " );
828 parameterizedTrafo = HepGeom::Translate3D(deltaX, deltaY, 0);
833 std::string module_str;
840 HepGeom::Vector3D<double> shift(0, 0, 0);
846 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
852 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
866 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
869 deltaR =
r/maxRadius * maxDeltaR;
876 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
879 deltaR = cos ( 2*
phi ) *
r/maxRadius * maxDeltaR;
886 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
889 deltaR = 2. *
z/maxLength * maxDeltaR;
892 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
905 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
912 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
927 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
935 deltaZ =
r/maxRadius * maxDeltaZ;
941 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
944 deltaZ = cos ( 2*
phi ) * maxDeltaZ;
949 deltaZ = 2. *
z/maxLength * maxDeltaZ;
955 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
956 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
963 parameterizedTrafo = HepGeom::Transform3D();
969 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
970 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
973 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
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" );
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.));
984 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
987 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
988 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
990 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
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.));
998 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
1004 alignmentTrafo = parameterizedTrafo;
1008 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
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;
1024 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
1025 HepGeom::Vector3D<double>
1026 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
1027 getTranslation().
z());
1029 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1031 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
1032 HepGeom::Vector3D<double>
1033 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
1034 getTranslation().
z());
1036 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1038 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
1039 HepGeom::Vector3D<double>
1040 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
1042 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
1044 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
1045 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
1046 zeroSuppressedRotation.setDelta(0.);
1048 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
1056 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1058 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1062 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1064 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1072 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
1074 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
1078 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1081 double alpha, beta, gamma;
1082 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
1092 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
1103 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
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;
1160 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1164 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1165 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1180 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1187 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1189 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1194 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1195 if ( StatusCode::SUCCESS
1202 return StatusCode::SUCCESS;