the main function which calculates and applies a transformation to each detector element
449 {
450
451 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
454
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
482 const double maxRadius=51.4*CLHEP::cm;
483 const double minRadius=50.5*CLHEP::mm;
484 const double maxLength=158.*CLHEP::cm;
485
490 ATH_MSG_DEBUG(
"maximum deltaPhi = " << maxAngle/CLHEP::mrad <<
" mrad" );
491 ATH_MSG_DEBUG(
"maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad <<
" mrad" );
492 const InDetDD::SiDetectorElementCollection* pixelElements=nullptr;
493 const InDetDD::SiDetectorElementCollection* sctElements=nullptr;
495
496 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> pixelDetEleHandle(
m_pixelDetEleCollKey);
497 pixelElements = *pixelDetEleHandle;
498 if (not pixelDetEleHandle.isValid() or pixelElements==nullptr) {
500 return StatusCode::FAILURE;
501 }
502 }
504
505 SG::ReadCondHandle<InDetDD::SiDetectorElementCollection> sctDetEleHandle(
m_SCTDetEleCollKey);
506 sctElements = *sctDetEleHandle;
507 if (not sctDetEleHandle.isValid() or sctElements==nullptr) {
509 return StatusCode::FAILURE;
510 }
511 }
512
513 for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator iter =
m_ModuleList.begin(); iter !=
m_ModuleList.end(); ++iter) {
515 const Identifier& ModuleID =
iter->first;
516
517 const InDetDD::SiDetectorElement * SiModule = nullptr;
518
520 const IdentifierHash Pixel_ModuleHash =
m_pixelIdHelper->wafer_hash(ModuleID);
522 else ATH_MSG_WARNING(
"Trying to access a Pixel module when running with no Pixel!");
523
525 const IdentifierHash SCT_ModuleHash =
m_sctIdHelper->wafer_hash(ModuleID);
527 else ATH_MSG_WARNING(
"Trying to access an SCT/Strop module when running with no SCT/Strip!");
528
530
531
532 } else {
533 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
534 }
535
536
537
538
539
540
541
542
543 HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
545 if (SiModule){
547 } else {
548 ATH_MSG_WARNING(
"Apparently in a silicon detector, but SiModule is a null pointer");
549 }
550 }
551 const HepGeom::Point3D<double> center =
iter->second;
552
553
554 double r = center.rho();
555 double phi = center.phi();
556 double z = center.z();
557
558 HepGeom::Transform3D parameterizedTrafo;
559 HepGeom::Transform3D alignmentTrafo;
560
561
562
563 double ScaleFactor = 1.;
564
566 {
569 }
570 else {
572 }
575 }
578 }
579
581 {
584 }
585 else {
587 }
588
590 {
593 }
594 else {
596 }
597 } else {
598 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
599 }
600
601
602
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;
615 }
616 }
617
619
620 parameterizedTrafo = HepGeom::Transform3D();
621 }
622
624
626
627 CLHEP::HepRotation rot;
629
630 if (ScaleFactor == 0.0) {
631 parameterizedTrafo = HepGeom::Transform3D();
632 } else {
633 parameterizedTrafo = HepGeom::Transform3D(rot, shift);
634 }
635
636 }
637
639
640
653
654 double randMisX = RandMisX();
655 double randMisY = RandMisY();
656 double randMisZ = RandMisZ();
657
658 double randMisaplha = RandMisalpha();
659 double randMisbeta = RandMisbeta();
660 double randMisgamma = RandMisgamma();
661
662 CLHEP::HepRotation rot;
663 HepGeom::Vector3D<double> shift;
664
665
666 if (ScaleFactor == 0.0) {
667 parameterizedTrafo = HepGeom::Transform3D();
668 } else {
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);}
672
673 }
674
676
679
681
682 } else {
683
685 ATH_MSG_DEBUG(
"will not move this module for IBL temp distortion " );
686 }
687
688 ATH_MSG_DEBUG(
"deltaX for this module: " << deltaX/CLHEP::micrometer <<
" um" );
689 parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0);
690 }
691
693
694
695 std::string module_str =
m_idHelper->show_to_string(ModuleID,
nullptr,
'/');
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_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
917 } else {
918 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
919 }
922
924 } else {
925
927 ATH_MSG_ERROR(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" not successful" );
928 } else {
929 ATH_MSG_INFO(
"Update of alignment constants for module " <<
m_idHelper->show_to_string(ModuleID,
nullptr,
'/') <<
" successful" );
930 }
931 }
932 } else {
933 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
934 }
935
937 m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
938
945
946
947 HepGeom::Transform3D LocalaGlobal = HepGeom::Transform3D();
950
951
952
953
957
958 HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
959
960
962
963 const InDetDD::StripStereoAnnulusDesign *p_design_check =
dynamic_cast<const InDetDD::StripStereoAnnulusDesign*
>(&(SiModule->
design()));
964 if (p_design_check){
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;
974 }
975
976 else {
980
981 }
982
983 }
984
985 else {
989 }
990
991
1013
1014 } else {
1015 ATH_MSG_WARNING(
"Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1016 }
1017
1018
1019 if (StatusCode::SUCCESS!=
ntupleSvc()->writeRecord(
"NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1020 ATH_MSG_ERROR(
"Could not write InitialAlignment ntuple." );
1021 }
1022
1023 }
1024
1025
1026
1027
1031 } else {
1035 ATH_MSG_INFO(
"Writing IoV information to mysql file" );
1037 }
1038 }
1039
1042 ATH_MSG_ERROR(
"Write of AlignableTransforms (TRT) failed" );
1043 } else {
1044 ATH_MSG_INFO(
"AlignableTransforms for TRT were written" );
1048 }
1049 ATH_MSG_INFO(
"Writing IoV information for TRT to mysql file" );
1050 if ( StatusCode::SUCCESS
1053 }
1054 }
1055 }
1056
1057 return StatusCode::SUCCESS;
1058
1059 }
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