450 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service(
"RndmGenSvc")};
481 const double maxRadius=51.4*CLHEP::cm;
482 const double minRadius=50.5*CLHEP::mm;
483 const double maxLength=158.*CLHEP::cm;
489 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
490 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
496 pixelElements = *pixelDetEleHandle;
497 if (not pixelDetEleHandle.
isValid() or pixelElements==
nullptr) {
499 return StatusCode::FAILURE;
505 sctElements = *sctDetEleHandle;
506 if (not sctDetEleHandle.
isValid() or sctElements==
nullptr) {
508 return StatusCode::FAILURE;
521 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
526 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
532 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
542 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
547 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
550 const HepGeom::Point3D<double> center = iter->second;
553 double r = center.rho();
554 double phi = center.phi();
555 double z = center.z();
557 HepGeom::Transform3D parameterizedTrafo;
558 HepGeom::Transform3D alignmentTrafo;
562 double ScaleFactor = 1.;
600 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
604 msg() <<
"radius " <<
r / CLHEP::cm <<
" centimeter" <<
endmsg;
606 msg() <<
"z " <<
z / CLHEP::cm <<
" centimeter" <<
endmsg;
607 if (
msgLvl(MSG::VERBOSE)) {
608 msg() <<
"localToGlobal transformation:" <<
endmsg;
609 msg() <<
"translation: " << localToGlobal.dx() / CLHEP::cm <<
";" << localToGlobal.dy() / CLHEP::cm <<
";" << localToGlobal.dz() / CLHEP::cm <<
endmsg;
611 msg() << localToGlobal.xx() <<
" " << localToGlobal.xy() <<
" " << localToGlobal.xz() <<
endmsg;
612 msg() << localToGlobal.yx() <<
" " << localToGlobal.yy() <<
" " << localToGlobal.yz() <<
endmsg;
613 msg() << localToGlobal.zx() <<
" " << localToGlobal.zy() <<
" " << localToGlobal.zz() <<
endmsg;
619 parameterizedTrafo = HepGeom::Transform3D();
626 CLHEP::HepRotation rot;
629 if (ScaleFactor == 0.0) {
630 parameterizedTrafo = HepGeom::Transform3D();
632 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
653 double randMisX = RandMisX();
654 double randMisY = RandMisY();
655 double randMisZ = RandMisZ();
657 double randMisaplha = RandMisalpha();
658 double randMisbeta = RandMisbeta();
659 double randMisgamma = RandMisgamma();
661 CLHEP::HepRotation rot;
662 HepGeom::Vector3D<double> shift;
665 if (ScaleFactor == 0.0) {
666 parameterizedTrafo = HepGeom::Transform3D();
668 shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
669 rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
670 parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
684 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
687 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
688 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
693 std::string module_str;
700 HepGeom::Vector3D<double> shift(0, 0, 0);
706 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
712 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
726 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
729 deltaR =
r/maxRadius * maxDeltaR;
736 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
739 deltaR = cos ( 2*
phi ) *
r/maxRadius * maxDeltaR;
746 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
749 deltaR = 2. *
z/maxLength * maxDeltaR;
752 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
765 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
772 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
787 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
795 deltaZ =
r/maxRadius * maxDeltaZ;
801 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
804 deltaZ = cos ( 2*
phi ) * maxDeltaZ;
809 deltaZ = 2. *
z/maxLength * maxDeltaZ;
815 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
816 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
823 parameterizedTrafo = HepGeom::Transform3D();
829 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
830 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
833 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
836 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
837 double deltaAlpha = (-2.) *
r * maxAngle/maxLength;
838 ATH_MSG_DEBUG(
"TRT barrel module alpha for twist: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
840 CLHEP::HepRotation twistForTRTRotation(HepGeom::Vector3D<double>(center.x(),center.y(),center.z()), deltaAlpha );
841 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
844 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
847 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
848 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
850 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
852 HepGeom::Vector3D<double> normalVector(center.x(),center.y(),center.z());
853 HepGeom::Vector3D<double> beamVector(0.,0.,1.);
854 HepGeom::Vector3D<double> rotationAxis = normalVector.cross(beamVector);
855 CLHEP::HepRotation twistForTRTRotation(rotationAxis, deltaAlpha );
856 HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
858 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
864 alignmentTrafo = parameterizedTrafo;
868 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
872 msg() <<
"Align Transformation x = (" << alignmentTrafo.getTranslation().x() / CLHEP::micrometer <<
" um)" <<
endmsg;
873 msg() <<
"Align Transformation y = (" << alignmentTrafo.getTranslation().y() / CLHEP::micrometer <<
" um)" <<
endmsg;
874 msg() <<
"Align Transformation z = (" << alignmentTrafo.getTranslation().z() / CLHEP::micrometer <<
" um)" <<
endmsg;
875 msg() <<
"Align Transformation x phi = (" << alignmentTrafo.getRotation().phiX() / CLHEP::deg <<
")" <<
endmsg;
876 msg() <<
"Align Transformation x Theta = (" << alignmentTrafo.getRotation().thetaX() / CLHEP::deg <<
")" <<
endmsg;
877 msg() <<
"Align Transformation y phi = (" << alignmentTrafo.getRotation().phiY() / CLHEP::deg <<
")" <<
endmsg;
878 msg() <<
"Align Transformation y Theta = (" << alignmentTrafo.getRotation().thetaY() / CLHEP::deg <<
")" <<
endmsg;
879 msg() <<
"Align Transformation z phi = (" << alignmentTrafo.getRotation().phiZ() / CLHEP::deg <<
")" <<
endmsg;
880 msg() <<
"Align Transformation z Theta = (" << alignmentTrafo.getRotation().thetaZ() / CLHEP::deg <<
")" <<
endmsg;
884 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
885 HepGeom::Vector3D<double>
886 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
887 getTranslation().
z());
889 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
891 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
892 HepGeom::Vector3D<double>
893 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
894 getTranslation().
z());
896 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
898 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
899 HepGeom::Vector3D<double>
900 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
902 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
904 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
905 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
906 zeroSuppressedRotation.setDelta(0.);
908 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
916 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
918 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
922 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
924 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
932 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
934 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
938 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
941 double alpha, beta, gamma;
942 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
952 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
963 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
971 double radialShift_x = SCT_Center[0];
972 double radialShift_y = SCT_Center[1];
973 HepGeom::Transform3D radial_shift = HepGeom::Translate3D(radialShift_x,radialShift_y,0);
974 HepGeom::Transform3D LocalaaGlobal = LocalaGlobal * radial_shift;
975 HepGeom::Point3D<double> SCT_endcap_alignedPosGlobal = LocalaaGlobal * alignedPosLocal;
1020 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1024 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1025 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1040 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1047 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1049 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1054 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1055 if ( StatusCode::SUCCESS
1062 return StatusCode::SUCCESS;