451 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service(
"RndmGenSvc")};
482 const double maxRadius=51.4*CLHEP::cm;
483 const double minRadius=50.5*CLHEP::mm;
484 const double maxLength=158.*CLHEP::cm;
490 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
491 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
497 pixelElements = *pixelDetEleHandle;
498 if (not pixelDetEleHandle.
isValid() or pixelElements==
nullptr) {
500 return StatusCode::FAILURE;
506 sctElements = *sctDetEleHandle;
507 if (not sctDetEleHandle.
isValid() or sctElements==
nullptr) {
509 return StatusCode::FAILURE;
522 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
527 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
533 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
543 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
548 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
551 const HepGeom::Point3D<double> center = iter->second;
554 double r = center.rho();
555 double phi = center.phi();
556 double z = center.z();
558 HepGeom::Transform3D parameterizedTrafo;
559 HepGeom::Transform3D alignmentTrafo;
563 double ScaleFactor = 1.;
598 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
605 msg() <<
"radius " <<
r / CLHEP::cm <<
" centimeter" <<
endmsg;
607 msg() <<
"z " <<
z / CLHEP::cm <<
" centimeter" <<
endmsg;
608 if (
msgLvl(MSG::VERBOSE)) {
609 msg() <<
"localToGlobal transformation:" <<
endmsg;
610 msg() <<
"translation: " << localToGlobal.dx() / CLHEP::cm <<
";" << localToGlobal.dy() / CLHEP::cm <<
";" << localToGlobal.dz() / CLHEP::cm <<
endmsg;
612 msg() << localToGlobal.xx() <<
" " << localToGlobal.xy() <<
" " << localToGlobal.xz() <<
endmsg;
613 msg() << localToGlobal.yx() <<
" " << localToGlobal.yy() <<
" " << localToGlobal.yz() <<
endmsg;
614 msg() << localToGlobal.zx() <<
" " << localToGlobal.zy() <<
" " << localToGlobal.zz() <<
endmsg;
620 parameterizedTrafo = HepGeom::Transform3D();
627 CLHEP::HepRotation rot;
630 if (ScaleFactor == 0.0) {
631 parameterizedTrafo = HepGeom::Transform3D();
633 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
654 double randMisX = RandMisX();
655 double randMisY = RandMisY();
656 double randMisZ = RandMisZ();
658 double randMisaplha = RandMisalpha();
659 double randMisbeta = RandMisbeta();
660 double randMisgamma = RandMisgamma();
662 CLHEP::HepRotation rot;
663 HepGeom::Vector3D<double> shift;
666 if (ScaleFactor == 0.0) {
667 parameterizedTrafo = HepGeom::Transform3D();
669 shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
670 rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
671 parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
685 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
688 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
689 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
695 std::string module_str =
m_idHelper->show_to_string(ModuleID,
nullptr,
'/');
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_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
918 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
927 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
929 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
933 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
936 double alpha, beta, gamma;
937 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
947 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
958 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
966 double radialShift_x = SCT_Center[0];
967 double radialShift_y = SCT_Center[1];
968 HepGeom::Transform3D radial_shift = HepGeom::Translate3D(radialShift_x,radialShift_y,0);
969 HepGeom::Transform3D LocalaaGlobal = LocalaGlobal * radial_shift;
970 HepGeom::Point3D<double> SCT_endcap_alignedPosGlobal = LocalaaGlobal * alignedPosLocal;
1015 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1019 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1020 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1035 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1042 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1044 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1049 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1050 if ( StatusCode::SUCCESS
1057 return StatusCode::SUCCESS;