the main function which calculates and applies a transformation to each detector element
448 {
449
450 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
453
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481 const double maxRadius=51.4*CLHEP::cm;
482 const double minRadius=50.5*CLHEP::mm;
483 const double maxLength=158.*CLHEP::cm;
484
489 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
490 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
491 const InDetDD::SiDetectorElementCollection* pixelElements=nullptr;
492 const InDetDD::SiDetectorElementCollection* sctElements=nullptr;
494
495 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(
m_pixelDetEleCollKey);
496 pixelElements = *pixelDetEleHandle;
497 if (not pixelDetEleHandle.isValid() or pixelElements==nullptr) {
499 return StatusCode::FAILURE;
500 }
501 }
503
504 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(
m_SCTDetEleCollKey);
505 sctElements = *sctDetEleHandle;
506 if (not sctDetEleHandle.isValid() or sctElements==nullptr) {
508 return StatusCode::FAILURE;
509 }
510 }
511
512 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator iter =
m_ModuleList.begin(); iter !=
m_ModuleList.end(); ++iter) {
514 const Identifier& ModuleID =
iter->first;
515
516 const InDetDD::SiDetectorElement * SiModule = nullptr;
517
519 const IdentifierHash Pixel_ModuleHash =
m_pixelIdHelper->wafer_hash(ModuleID);
521 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
522
524 const IdentifierHash SCT_ModuleHash =
m_sctIdHelper->wafer_hash(ModuleID);
526 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
527
529
530
531 } else {
532 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
533 }
534
535
536
537
538
539
540
541
542 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
544 if (SiModule){
546 } else {
547 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
548 }
549 }
550 const HepGeom::Point3D<double> center =
iter->second;
551
552
553 double r = center.rho();
554 double phi = center.phi();
555 double z = center.z();
556
557 HepGeom::Transform3D parameterizedTrafo;
558 HepGeom::Transform3D alignmentTrafo;
559
560
561
562 double ScaleFactor = 1.;
563
565 {
569 }
570 else {
572 }
575 }
578 }
579
581 {
585 }
586 else {
588 }
589
591 {
595 }
596 else {
598 }
599 } else {
600 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
601 }
602
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;
614 }
615 }
616
618
619 parameterizedTrafo = HepGeom::Transform3D();
620 }
621
623
625
626 CLHEP::HepRotation rot;
628
629 if (ScaleFactor == 0.0) {
630 parameterizedTrafo = HepGeom::Transform3D();
631 } else {
632 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
633 }
634
635 }
636
638
639
652
653 double randMisX = RandMisX();
654 double randMisY = RandMisY();
655 double randMisZ = RandMisZ();
656
657 double randMisaplha = RandMisalpha();
658 double randMisbeta = RandMisbeta();
659 double randMisgamma = RandMisgamma();
660
661 CLHEP::HepRotation rot;
662 HepGeom::Vector3D<double> shift;
663
664
665 if (ScaleFactor == 0.0) {
666 parameterizedTrafo = HepGeom::Transform3D();
667 } else {
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);}
671
672 }
673
675
678
680
681 } else {
682
684 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
685 }
686
687 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
688 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
689 }
690
692
693 std::string module_str;
696
698
699
700 HepGeom::Vector3D<double> shift(0, 0, 0);
703 }
704
705
706 CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
709 }
710
711
712 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
713 }
714 }
715
716
717 else {
719
722
724
726 ATH_MSG_DEBUG(
"will not move TRT endcap for radial distortion " );
727 } else {
728
729 deltaR =
r/maxRadius * maxDeltaR;
730 }
732
734
736 ATH_MSG_DEBUG(
"will not move TRT endcap for elliptical distortion " );
737 } else {
738
740 }
742
744
746 ATH_MSG_DEBUG(
"will not move TRT endcap for funnel distortion " );
747 } else {
748
749 deltaR = 2. *
z/maxLength * maxDeltaR;
750 }
751 } else {
752 ATH_MSG_DEBUG(
"Wrong misalignment mode entered, doing nothing." );
754 }
755
758 }
759
761
764
765 deltaPhi =
r/maxRadius * maxAngle + minRadius/
r * maxAngleInner;
767
768
770
772 ATH_MSG_DEBUG(
"will not move TRT endcap for clamshell distortion " );
773 } else {
774
776 }
778
780
781 } else {
784 }
785
787 parameterizedTrafo = HepGeom::RotateZ3D(
deltaPhi);
788 }
789
791
794
795 deltaZ =
r/maxRadius * maxDeltaZ;
797
799
801 ATH_MSG_DEBUG(
"will not move TRT endcap for skew distortion " );
802 } else {
803
805 }
807
808
809 deltaZ = 2. *
z/maxLength * maxDeltaZ;
810 } else {
813 }
814
815 ATH_MSG_DEBUG(
"deltaZ for this module: " << deltaZ/CLHEP::micrometer <<
" um" );
816 parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ);
817 }
818
819 else {
820
822
823 parameterizedTrafo = HepGeom::Transform3D();
824 }
825 }
826
828
829 ATH_MSG_DEBUG(
"additional rotation for TRT barrel module!" );
830 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
831
832
833 alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
835
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" );
839
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.));
842
843
844 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
846
847 HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
848 double deltaAlpha = (-2.) * maxDeltaR/maxLength;
849
850 ATH_MSG_DEBUG(
"TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad <<
" mrad" );
851
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.));
857
858 alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
859
860
861
863 {
864 alignmentTrafo = parameterizedTrafo;
865 }
866 else {
867
868 alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
869 }
870
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;
881 }
882
883
884 if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
885 HepGeom::Vector3D<double>
886 zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
887 getTranslation().
z());
888 alignmentTrafo =
889 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
890 }
891 if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
892 HepGeom::Vector3D<double>
893 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
894 getTranslation().
z());
895 alignmentTrafo =
896 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
897 }
898 if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
899 HepGeom::Vector3D<double>
900 zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
901 alignmentTrafo =
902 HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
903 }
904 if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
905 CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
906 zeroSuppressedRotation.setDelta(0.);
907 alignmentTrafo =
908 HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
909 }
910
911
913
916 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
917 } else {
918 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_pixelIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
919 }
922 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
923 } else {
924 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_sctIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
925 }
928
930 } else {
932 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
933 } else {
934 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_trtIdHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
935 }
936 }
937 } else {
938 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
939 }
940
942 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
943
950
951
952 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
955
956
957
958
962
963 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
964
965
967
968 const InDetDD::StripStereoAnnulusDesign *p_design_check =
dynamic_cast<const InDetDD::StripStereoAnnulusDesign*
>(&(SiModule->
design()));
969 if (p_design_check){
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;
979 }
980
981 else {
985
986 }
987
988 }
989
990 else {
994 }
995
996
1018
1019 } else {
1020 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1021 }
1022
1023
1024 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1025 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1026 }
1027
1028 }
1029
1030
1031
1032
1036 } else {
1040 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1042 }
1043 }
1044
1047 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1048 } else {
1049 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1053 }
1054 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1055 if ( StatusCode::SUCCESS
1058 }
1059 }
1060 }
1061
1062 return StatusCode::SUCCESS;
1063
1064 }
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