15 #include "Identifier/Identifier.h"
50 affine *= _rotationY(angle_y);
51 affine *= _rotationZ(angle_z);
55 return makeAffine3d(trans[3],trans[4],trans[5],
Amg::Vector3D(trans[0],trans[1],trans[2]));
57 typedef double DoubleArray6_t[6];
59 return makeAffine3d(trans[3],trans[4],trans[5],
Amg::Vector3D(trans[0],trans[1],trans[2]));
63 template <
class T_Matrix,
class T_Vector>
64 bool solve(T_Matrix &
A, T_Vector &
x,
const T_Vector &
b) {
65 Eigen::LDLT< T_Matrix > llt;
68 if (llt.info() != Eigen::Success)
return false;
80 static const double tenmu = 0.010;
81 static const double onemrad = 0.001;
88 m_IDAlignDBTool(
"InDetAlignDBTool"),
89 m_TRTAlignDbTool(
"TRT_AlignDbSvc",
name),
129 declareProperty(
"Det",m_det=99);
130 declareProperty(
"SiBec",m_Si_bec=99);
131 declareProperty(
"TRT_Bec",m_TRT_bec=99);
132 declareProperty(
"SiLayer",m_Si_layer=99);
133 declareProperty(
"TRT_Layer",m_TRT_layer=99);
135 declareProperty(
"PrintFullMatrix", m_fullMatrix=
false);
136 declareProperty(
"PrintDB", m_printDB=
false);
137 declareProperty(
"ErrorTranslation",m_errTrans=1
e-3);
138 declareProperty(
"ErrorRotation",m_errRot=1
e-6);
139 declareProperty(
"InDetAlignDBTool",m_IDAlignDBTool);
140 declareProperty(
"TRTAlignDbTool",m_TRTAlignDbTool);
142 declareProperty(
"SiTextOutput",m_SiTxtOutput=
false);
143 declareProperty(
"TRT_TextOutput",m_TRT_TxtOutput=
false);
144 declareProperty(
"SiTextFile",m_sitxtfile=
"cog_si_file.txt");
145 declareProperty(
"TRT_TextFile",m_trt_txtfile=
"cog_trt_file.txt");
147 declareProperty(
"SQLiteTag",m_SQLiteTag=
"cog_tag");
149 declareProperty(
"UseChi2",m_useChi2=
true);
150 declareProperty(
"SXpixBarrel",m_sigXpixB=0.1);
151 declareProperty(
"SYpixBarrel",m_sigYpixB=0.1);
152 declareProperty(
"SZpixBarrel",m_sigZpixB=0.1);
153 declareProperty(
"SXpixEndcap",m_sigXpixE=0.1);
154 declareProperty(
"SYpixEndcap",m_sigYpixE=0.1);
155 declareProperty(
"SZpixEndcap",m_sigZpixE=0.1);
156 declareProperty(
"SXsctBarrel",m_sigXsctB=0.1);
157 declareProperty(
"SYsctBarrel",m_sigYsctB=0.1);
158 declareProperty(
"SZsctBarrel",m_sigZsctB=0.1);
159 declareProperty(
"SXsctEndcap",m_sigXsctE=0.1);
160 declareProperty(
"SYsctEndcap",m_sigYsctE=0.1);
161 declareProperty(
"SZsctEndcap",m_sigZsctE=0.1);
162 declareProperty(
"SXtrtBarrel",m_sigXtrtB=0.1);
163 declareProperty(
"SYtrtBarrel",m_sigYtrtB=0.1);
164 declareProperty(
"SZtrtBarrel",m_sigZtrtB=0.1);
165 declareProperty(
"SXtrtEndcap",m_sigXtrtE=0.1);
166 declareProperty(
"SYtrtEndcap",m_sigYtrtE=0.1);
167 declareProperty(
"SZtrtEndcap",m_sigZtrtE=0.1);
169 declareProperty(
"DoTX",m_doTX=
true);
170 declareProperty(
"DoTY",m_doTY=
true);
171 declareProperty(
"DoTZ",m_doTZ=
true);
172 declareProperty(
"DoRX",m_doRX=
true);
173 declareProperty(
"DoRY",m_doRY=
true);
174 declareProperty(
"DoRZ",m_doRZ=
true);
176 declareProperty(
"DoCoG",m_doCoG=
true);
177 declareProperty(
"DoL1",m_doL1=
false);
178 declareProperty(
"TraX",m_traX=0.0);
179 declareProperty(
"TraY",m_traY=0.0);
180 declareProperty(
"TraZ",m_traZ=0.0);
181 declareProperty(
"RotX",m_rotX=0.0);
182 declareProperty(
"RotY",m_rotY=0.0);
183 declareProperty(
"RotZ",m_rotZ=0.0);
220 return StatusCode::SUCCESS;
233 pixelElements = *pixelDetEleHandle;
234 if (not pixelDetEleHandle.
isValid() or pixelElements==
nullptr) {
236 return StatusCode::FAILURE;
243 sctElements = *sctDetEleHandle;
244 if (not sctDetEleHandle.
isValid() or sctElements==
nullptr) {
246 return StatusCode::FAILURE;
254 if (not trtDetEleHandle.
isValid() or trtElements==
nullptr) {
256 return StatusCode::FAILURE;
293 for(
int i=0;
i<6;
i++){
m_cog[
i]=std::numeric_limits<double>::infinity();}
304 ATH_MSG_DEBUG(
"+++++++++++++++++++++++++++++++++++++++++++++" );
307 ATH_MSG_DEBUG(
"+++++++++++++++++++++++++++++++++++++++++++++" );
311 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
313 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
322 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
325 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
327 ATH_MSG_ERROR(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
329 ATH_MSG_ERROR(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
348 if (
m_counter==0)
throw std::logic_error(
"No Si-elements.");
357 ATH_MSG_DEBUG(
"+++++++++++++++++++++++++++++++++++++++++++++" );
360 ATH_MSG_DEBUG(
"+++++++++++++++++++++++++++++++++++++++++++++" );
364 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
366 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
373 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
376 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
378 ATH_MSG_ERROR(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
380 ATH_MSG_ERROR(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
392 ATH_MSG_INFO(
"<<< CoG correction will be applied. >>>" );
395 ATH_MSG_INFO(
"<<< CoG correction will be skipped. >>>" );
400 ATH_MSG_INFO(
"<<< Predefined L1 transformation will be added. >>>" );
405 ATH_MSG_ERROR(
"Problem updating ID level 1 constants !!!" );
406 return StatusCode::FAILURE;
411 return StatusCode::SUCCESS;
422 ATH_MSG_ERROR(
"Write of silicon alignableTransforms fails" );
423 return StatusCode::FAILURE;
439 return StatusCode::FAILURE;
445 ATH_MSG_ERROR(
"Write of TRT new constants txt file fails" );
454 return StatusCode::SUCCESS;
461 bool cog_already_calculated,
476 if(element->isPixel()) {
493 double sigmas[6]={0.1,0.1,0.1,1.,1.,1.};
515 if(element->isPixel())
527 << phi_module <<
" " << eta_module <<
" " <<
side <<
" "
533 << phi_module <<
" " << eta_module <<
" " <<
side <<
" "
540 << phi_module <<
" " << eta_module <<
" " <<
side <<
" "
545 if(!cog_already_calculated){
563 return StatusCode::SUCCESS;
601 if(
bec == 1)
continue;
609 double sigmas[6]={0.1,0.1,0.1,1.,1.,1.};
620 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(defTransform));
638 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(globalDelta));
641 const Amg::Transform3D localDelta = defTransform.inverse() * globalDelta * defTransform;
644 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(localDelta));
648 if(!cog_already_calculated){
664 return StatusCode::SUCCESS;
688 for(
int i=0;
i<6;
i++){
702 x = translation_part[x_i];
703 y = translation_part[y_i];
704 z = translation_part[z_i];
718 val[0] += glob_x_trans[x_i]/tenmu*
x + glob_y_trans[x_i]/tenmu*
y + glob_z_trans[x_i]/tenmu*
z;
719 val[0] += grot_x_trans[x_i]/onemrad*
a + grot_y_trans[x_i]/onemrad*
b + grot_z_trans[x_i]/onemrad*
g;
721 val[1] += glob_x_trans[y_i]/tenmu*
x + glob_y_trans[y_i]/tenmu*
y + glob_z_trans[y_i]/tenmu*
z;
722 val[1] += grot_x_trans[y_i]/onemrad*
a + grot_y_trans[y_i]/onemrad*
b + grot_z_trans[y_i]/onemrad*
g;
724 val[2] += glob_x_trans[z_i]/tenmu*
x + glob_y_trans[z_i]/tenmu*
y + glob_z_trans[z_i]/tenmu*
z;
725 val[2] += grot_x_trans[z_i]/onemrad*
a + grot_y_trans[z_i]/onemrad*
b + grot_z_trans[z_i]/onemrad*
g;
735 val[3] += alpha[0]/tenmu*
x + alpha[1]/tenmu*
y + alpha[2]/tenmu*
z;
736 val[3] += alpha[3]/onemrad*
a + alpha[4]/onemrad*
b + alpha[5]/onemrad*
g;
758 delta[0] = translation_part[0];
759 delta[1] = translation_part[1];
760 delta[2] = translation_part[2];
761 m_IDAlignDBTool->extractAlphaBetaGamma(trans ,delta[3],delta[4],delta[5]);
787 jacobian(0,0) = glob_x_trans[0]/tenmu;
788 jacobian(0,1) = glob_y_trans[0]/tenmu;
789 jacobian(0,2) = glob_z_trans[0]/tenmu;
790 jacobian(0,3) = grot_x_trans[0]/onemrad;
791 jacobian(0,4) = grot_y_trans[0]/onemrad;
792 jacobian(0,5) = grot_z_trans[0]/onemrad;
793 jacobian(1,0) = glob_x_trans[1]/tenmu;
794 jacobian(1,1) = glob_y_trans[1]/tenmu;
795 jacobian(1,2) = glob_z_trans[1]/tenmu;
796 jacobian(1,3) = grot_x_trans[1]/onemrad;
797 jacobian(1,4) = grot_y_trans[1]/onemrad;
798 jacobian(1,5) = grot_z_trans[1]/onemrad;
799 jacobian(2,0) = glob_x_trans[2]/tenmu;
800 jacobian(2,1) = glob_y_trans[2]/tenmu;
801 jacobian(2,2) = glob_z_trans[2]/tenmu;
802 jacobian(2,3) = grot_x_trans[2]/onemrad;
803 jacobian(2,4) = grot_y_trans[2]/onemrad;
804 jacobian(2,5) = grot_z_trans[2]/onemrad;
807 for (
unsigned int i=3;
i<6; ++
i) {
808 for (
unsigned int j=0; j<3; ++j) {
812 jacobian(3,3) = alpha[3]/onemrad;
813 jacobian(3,4) = alpha[4]/onemrad;
814 jacobian(3,5) = alpha[5]/onemrad;
815 jacobian(4,3) =
beta[3]/onemrad;
816 jacobian(4,4) =
beta[4]/onemrad;
817 jacobian(4,5) =
beta[5]/onemrad;
818 jacobian(5,3) =
gamma[3]/onemrad;
819 jacobian(5,4) =
gamma[4]/onemrad;
820 jacobian(5,5) =
gamma[5]/onemrad;
826 for (
int i=0;
i<6;
i++) {
827 for (
int k=0;
k<3;
k++) {
828 V[
i] -= 2./(sigmas[
k]*sigmas[
k])*jacobian(
k,
i)*delta[
k];
829 for (
int j=0; j<=
i; j++) {
830 M(
i,j) += 2./(sigmas[
k]*sigmas[
k])*jacobian(
k,
i)*jacobian(
k,j);
857 m_glob_x = trans * epsilon_x * inv_trans;
858 m_glob_y = trans * epsilon_y * inv_trans;
859 m_glob_z = trans * epsilon_z * inv_trans;
860 m_grot_x = trans * epsilon_a * inv_trans;
861 m_grot_y = trans * epsilon_b * inv_trans;
862 m_grot_z = trans * epsilon_g * inv_trans;
865 m_glob_x = inv_trans * epsilon_x * trans;
866 m_glob_y = inv_trans * epsilon_y * trans;
867 m_glob_z = inv_trans * epsilon_z * trans;
868 m_grot_x = inv_trans * epsilon_a * trans;
869 m_grot_y = inv_trans * epsilon_b * trans;
870 m_grot_z = inv_trans * epsilon_g * trans;
886 ATH_MSG_DEBUG(
"Will try to update Pixel and SCT level 1 constants...");
893 ATH_MSG_ERROR(
"Could not update level 1 silicon constants !!" );
894 return StatusCode::FAILURE;
897 ATH_MSG_DEBUG(
"Successful update of level 1 silicon constants " );
903 ATH_MSG_DEBUG(
"Will try to update TRT level 1 constants...");
912 return StatusCode::FAILURE;
915 ATH_MSG_DEBUG(
"Successful update of level 1 TRT constants " );
918 return StatusCode::SUCCESS;
925 bool dotx,
bool doty,
bool dotz,
bool dorx,
bool dory,
bool dorz){
926 ATH_MSG_DEBUG(
"in enableCoG with decisions " << dotx << doty << dotz << dorx << dory << dorz );
930 if( !dotx )
vec[0]=0.0;
931 if( !doty )
vec[1]=0.0;
932 if( !dotz )
vec[2]=0.0;
940 trans = makeAffine3d(
a,
b,
g,
vec);
952 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
955 ATH_MSG_INFO(
"+++++++++++++++++++++++++++++++++++++++++++++" );
973 return StatusCode::FAILURE;
985 trans = makeAffine3d(
a,
b,
g,
vec);
987 return StatusCode::SUCCESS;
1005 trans = makeAffine3d(
a,
b,
g,
vec);
1023 return makeAffine3d(a1+a2,b1+b2,
g1+
g2,sumvec);
1030 std::ostringstream ostr;
1035 ostr.setf(std::ios::fixed);
1036 ostr.setf(std::ios::showpoint);
1038 ostr << std::endl << std::endl;
1039 ostr << std::setw(10) << std::setprecision(6) <<
rotation(0,0)
1040 << std::setw(12) << std::setprecision(6) <<
rotation(0,1)
1041 << std::setw(12) << std::setprecision(6) <<
rotation(0,2)
1042 <<
" Tx = " << std::setw(10) << std::setprecision(6) << translation[0] << std::endl;
1044 ostr << std::setw(10) << std::setprecision(6) <<
rotation(1,0)
1045 << std::setw(12) << std::setprecision(6) <<
rotation(1,1)
1046 << std::setw(12) << std::setprecision(6) <<
rotation(1,2)
1047 <<
" Ty = " << std::setw(10) << std::setprecision(6) << translation[1] << std::endl;
1049 ostr << std::setw(10) << std::setprecision(6) <<
rotation(2,0)
1050 << std::setw(12) << std::setprecision(6) <<
rotation(2,1)
1051 << std::setw(12) << std::setprecision(6) <<
rotation(2,2)
1052 <<
" Tz = " << std::setw(10) << std::setprecision(6) << translation[2];
1057 ostr <<
"(" << translation[0] <<
"," << translation[1] <<
"," << translation[2] <<
")mm ";
1060 ostr <<
"( A=" << 1000*alpha <<
", B=" << 1000*
beta <<
", G=" << 1000*
gamma <<
")mrad";
1073 double errTrans)
const {
1083 for (
int i=0;
i<3;
i++){
1084 for (
int j=0; j<3; j++){
1086 if (
diff > errRot) pass =
false;
1090 for (
int i=0;
i<3;
i++){
1092 if (
diff > errTrans) pass =
false;
1096 ATH_MSG_DEBUG(
"Remaining global transform within tolerances. Ok." );
1100 " No level 1 updates will be done" );