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;
80static const double tenmu = 0.010;
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;
253 trtElements = trtDetEleHandle->getElements();
254 if (not trtDetEleHandle.
isValid() or trtElements==
nullptr) {
256 return StatusCode::FAILURE;
273 for(
int i=0; i<6; i++){
m_cog[i]=0.0;}
274 for(
int i=0; i<6; i++){
m_resglob[i]=0.0;}
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(
"+++++++++++++++++++++++++++++++++++++++++++++" );
317 bool success = solve(params.m_M1,params.m_A1, params.m_V1 );
320 m_CoG = makeAffine3d(params.m_A1);
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(
"+++++++++++++++++++++++++++++++++++++++++++++" );
370 bool success = solve(params.m_M2,params.m_A2, params.m_V2 );
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()) {
479 layer_disk =
m_pixid->layer_disk(
id);
480 phi_module =
m_pixid->phi_module(
id);
481 eta_module =
m_pixid->eta_module(
id);
486 layer_disk =
m_sctid->layer_disk(
id);
487 phi_module =
m_sctid->phi_module(
id);
488 eta_module =
m_sctid->eta_module(
id);
493 double sigmas[6]={0.1,0.1,0.1,1.,1.,1.};
515 if(element->isPixel())
526 ATH_MSG_VERBOSE(
"defTransform " << 2 <<
" " << det <<
" " << bec <<
" " << layer_disk <<
" "
527 << phi_module <<
" " << eta_module <<
" " << side <<
" "
532 ATH_MSG_VERBOSE(
"transform " << 2 <<
" " << det <<
" " << bec <<
" " << layer_disk <<
" "
533 << phi_module <<
" " << eta_module <<
" " << side <<
" "
539 ATH_MSG_VERBOSE(
"localDelta " << 2 <<
" " << det <<
" " << bec <<
" " << layer_disk <<
" "
540 << phi_module <<
" " << eta_module <<
" " << side <<
" "
545 if(!cog_already_calculated){
563 return StatusCode::SUCCESS;
591 int bec =
m_trtid->barrel_ec(
id);
592 int phi_module =
m_trtid->phi_module(
id);
593 int layer_wheel =
m_trtid->layer_or_wheel(
id);
594 int straw_layer =
m_trtid->straw_layer(
id);
601 if(bec == 1)
continue;
609 double sigmas[6]={0.1,0.1,0.1,1.,1.,1.};
619 ATH_MSG_VERBOSE(
"defTransform 2 3" <<
" " << bec <<
" " << phi_module <<
" "
620 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(defTransform));
627 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(t1));
633 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(t2));
637 ATH_MSG_VERBOSE(
"globalDelta 2 3" <<
" " << bec <<
" " << phi_module <<
" "
638 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(globalDelta));
641 const Amg::Transform3D localDelta = defTransform.inverse() * globalDelta * defTransform;
643 ATH_MSG_VERBOSE(
"localDelta 2 3" <<
" " << bec <<
" " << phi_module <<
" "
644 << layer_wheel <<
" " << straw_layer <<
" " <<
printTransform(localDelta));
648 if(!cog_already_calculated){
664 return StatusCode::SUCCESS;
687 double alpha[6], beta[6], gamma[6];
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;
721 val[1] += glob_x_trans[y_i]/
tenmu*
x + glob_y_trans[y_i]/
tenmu*
y + glob_z_trans[y_i]/
tenmu*
z;
724 val[2] += glob_x_trans[z_i]/
tenmu*
x + glob_y_trans[z_i]/
tenmu*
y + glob_z_trans[z_i]/
tenmu*
z;
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]);
778 double alpha[6], beta[6], gamma[6];
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(
"+++++++++++++++++++++++++++++++++++++++++++++" );
969 ATH_MSG_DEBUG(
"in normalizeTransform with factor " << norm );
973 return StatusCode::FAILURE;
977 vec /= (double) norm;
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;
1032 AmgMatrix(3,3) rotation( trans.rotation());
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 ";
1058 double alpha=0, beta=0, gamma=0;
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++){
1085 double diff = std::abs(t1(i,j) - t2(i,j));
1086 if (
diff > errRot) pass =
false;
1090 for (
int i=0; i<3; i++){
1091 double diff = std::abs(t1(i,3) - t2(i,3));
1092 if (
diff > errTrans) pass =
false;
1096 ATH_MSG_DEBUG(
"Remaining global transform within tolerances. Ok." );
1100 " No level 1 updates will be done" );
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
#define AmgSymMatrix(dim)
#define AmgMatrix(rows, cols)
Basic time unit for IOVSvc.
static const double onemrad
static const double tenmu
Algorithm for ID cog calculation.
This is an Identifier helper class for the Pixel subdetector.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
This is an Identifier helper class for the SCT subdetector.
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
This is an Identifier helper class for the TRT subdetector.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
static constexpr uint32_t MAXRUN
static constexpr uint32_t MINEVENT
static constexpr uint32_t MAXEVENT
static constexpr uint32_t MINRUN
int m_det
Pixel=1, SCT=2, Pixel+SCT=12, TRT=3, all (silicon and TRT)=99.
int m_TRT_layer
a particular TRT layer or all (TRT)=99
bool m_SiTxtOutput
output Si constants to txt file ?
StatusCode getTRT_Elements(const InDetDD::TRT_DetElementCollection *, const bool, InDetAlignCog::Params_t ¶ms)
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Amg::Transform3D m_glob_x
double m_errTrans
acceptable value for residual global translation
double m_traZ
translation/rotation values (CLHEP::mm, CLHEP::rad) for the arbitrary transformation
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
const Amg::Transform3D getL1Transform(int bec)
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleContKey
ServiceHandle< ITRT_AlignDbSvc > m_TRTAlignDbTool
Amg::Transform3D m_grot_z
Amg::Transform3D m_glob_z
double m_sigXsctB
assumed error for SCT barrel local X matchnig in the Xi2 method
bool m_TRT_TxtOutput
output TRT constants to txt file ?
void scaleTransform(Amg::Transform3D &, const float)
StatusCode normalizeTransform(Amg::Transform3D &, const int)
Amg::Transform3D m_ResGlob
Amg::Transform3D m_glob_y
std::string printTransform(const Amg::Transform3D &) const
double m_errRot
acceptable value for residual global rotation angles
double m_sigXpixB
assumed error for Pixel barrel local X matchnig in the Xi2 method
void prepareDerivative(const Amg::Transform3D &, const bool=false)
Amg::Transform3D sumTransforms(const Amg::Transform3D &, const Amg::Transform3D &) const
StatusCode getSiElements(const InDetDD::SiDetectorElementCollection *, const bool, InDetAlignCog::Params_t ¶ms)
bool m_doL1
enable/disable introducing the arbitrary L1 correction to the output objects
bool testIdentity(const Amg::Transform3D &, double, double) const
StatusCode shiftIDbyCog()
int m_TRT_bec
Barrel=-1, Endcaps=+-2, all (TRT)=99.
bool m_doCoG
enable/disable introducing the CoG correction to the output objects
void accumulate(const Amg::Transform3D &, double *)
double m_sigXtrtB
assumed error for TRT barrel local X matchnig in the Xi2 method
std::string m_SQLiteTag
SQLite tag name.
void accumulateChi2(const Amg::Transform3D &, AmgSymMatrix(6)&, AmgVector(6)&, const double *)
ToolHandle< IInDetAlignDBTool > m_IDAlignDBTool
Amg::Transform3D m_grot_x
std::string m_sitxtfile
text file with dump of Si alignment constants after cog shift
bool m_doTZ
enable/disable writing of indivitual DoF's to the db
std::string m_trt_txtfile
text file with dump of TRT alignment constants after cog shift
int m_Si_bec
Barrel=1, Endcaps=+-2, all (silicon)=99.
void enableCoG(Amg::Transform3D &, bool, bool, bool, bool, bool, bool)
InDetAlignCog(const std::string &name, ISvcLocator *pSvcLocator)
int m_counter
normalization factor
Amg::Transform3D m_grot_y
double m_sigXpixE
assumed error for Pixel endcap local X matchnig in the Xi2 method
int m_Si_layer
a particular silicon layer or all (silicon)=99
Class to hold the SiDetectorElement objects to be put in the detector store.
Class to hold geometrical description of a silicon detector element.
Virtual base class of TRT readout elements.
Class to hold collection of TRT detector elements.
Eigen::AngleAxisd AngleAxis3D
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
hold the test vectors and ease the comparison