24 #include <Eigen/Dense>
25 #include <Eigen/Geometry>
46 float alpha = 0.0, beta = 0.0, gamma = 0.0, dx = 0.0,
dy = 0.0,
dz = 0.0;
49 std::ifstream datafile;
51 if(datafile.is_open())
53 std::cout <<
"AlignmentTransformation: Reading alignment parameters from disk file: "
61 std::cout <<
"AlignmentTransformation: Reading alignment parameters from database file: " <<
alignmentParamsFile << std::endl;
69 for (
int i=0;
i<fileLines;
i++)
71 datafile >> hitsetkey >> alpha >> beta >> gamma >> dx >>
dy >>
dz;
74 Eigen::Vector3d sensorAngles(alpha,beta,gamma);
75 Eigen::Vector3d millepedeTranslation(dx,
dy,dz);
94 transform =
newMakeTransform(surf, millepedeTranslation, sensorAngles,
false);
101 std::cout <<
" Add transform for MVTX with surface GeometryIdentifier " <<
id <<
" trkrid " << trkrId << std::endl;
102 std::cout <<
" final mvtx transform:" << std::endl << transform.matrix() << std::endl;
126 std::cout <<
" Add transform for INTT with surface GeometryIdentifier " <<
id <<
" trkrid " << trkrId << std::endl;
144 int subsurfkey_min = (1-side)*144 + (144-sector*12) - 12 - 6;
145 int subsurfkey_max = subsurfkey_min + 12;
151 if(sskey < 0) { sskey += 288; }
153 surf = surfMaps.
getTpcSurface(hitsetkey,(
unsigned int) sskey);
156 transform =
newMakeTransform(surf, millepedeTranslation, sensorAngles,
false);
162 std::cout <<
" Add transform for TPC with surface GeometryIdentifier " <<
id << std::endl
163 <<
" trkrid " << trkrId <<
" hitsetkey " << hitsetkey <<
" layer " << layer <<
" sector " << sector <<
" side " << side
166 std::cout <<
"Ideal surface center: " << std::endl <<center << std::endl;
167 std::cout <<
"transform matrix: " << std::endl << transform.matrix() << std::endl;
185 transform =
newMakeTransform(surf, millepedeTranslation, sensorAngles,
false);
190 std::cout <<
" Add transform for Micromegas with surface GeometryIdentifier " <<
id <<
" trkrid " << trkrId << std::endl;
199 std::cout<<
"Error: Invalid Hitsetkey" << std::endl;
216 Eigen::Vector3d nullTranslation(0,0,0);
217 Eigen::AngleAxisd
a(0, Eigen::Vector3d::UnitX());
218 Eigen::AngleAxisd
b(0, Eigen::Vector3d::UnitY());
219 Eigen::AngleAxisd
g(0, Eigen::Vector3d::UnitZ());
220 Eigen::Quaternion<double> qnull = g*b*
a;
221 Eigen::Matrix3d nullRotation = qnull.matrix();
232 Eigen::AngleAxisd
alpha(sensorAngles(0), Eigen::Vector3d::UnitX());
233 Eigen::AngleAxisd beta(sensorAngles(1), Eigen::Vector3d::UnitY());
234 Eigen::AngleAxisd gamma(sensorAngles(2), Eigen::Vector3d::UnitZ());
236 Eigen::Quaternion<double> q = gamma*beta*
alpha;
238 Eigen::Matrix3d millepedeRotation = q.matrix();
241 mpRotationAffine.linear() = millepedeRotation;
242 mpRotationAffine.translation() = nullTranslation;
246 mpTranslationAffine.linear() = nullRotation;
249 mpTranslationAffine.translation() = millepedeTranslation;
254 Eigen::Vector3d millepedeTranslationxzy(millepedeTranslation(0), millepedeTranslation(2), millepedeTranslation(1));
255 mpTranslationAffine.translation() = millepedeTranslationxzy;
260 Eigen::Matrix3d actsRotationPart = actsTransform.rotation();
261 Eigen::Vector3d actsTranslationPart = actsTransform.translation();
265 actsRotationAffine.linear() = actsRotationPart;
266 actsRotationAffine.translation() = nullTranslation;
268 actsTranslationAffine.linear() = nullRotation;
269 actsTranslationAffine.translation() = actsTranslationPart;
279 transform = mpTranslationAffine * mpRotationAffine;
287 transform = mpTranslationAffine * actsTranslationAffine * mpRotationAffine * actsRotationAffine;
292 transform = actsTranslationAffine * actsRotationAffine * mpTranslationAffine * mpRotationAffine;
298 Acts::Transform3 actstransform = actsTranslationAffine * actsRotationAffine;
301 std::cout <<
"newMakeTransform" << std::endl;
303 std::cout <<
"mpRotationAffine: "<< std::endl<< mpRotationAffine.matrix() <<std::endl;
306 std::cout <<
"mpTranslationAffine: " << std::endl << mpTranslationAffine.matrix() <<std::endl;
307 std::cout <<
" mptranslationAffine * mpRotationAffine " << std::endl
308 << (mpTranslationAffine * mpRotationAffine).matrix() << std::endl;
310 std::cout <<
"millepederotation * acts " << std::endl << millepedeRotation * actsRotationPart << std::endl;
311 std::cout <<
"actsRotationAffine: "<< std::endl<< actsRotationAffine.matrix() <<std::endl;
312 std::cout <<
"actsTranslationAffine: "<< std::endl<< actsTranslationAffine.matrix() <<std::endl;
313 std::cout <<
"full acts transform " << std::endl << actstransform.matrix() << std::endl <<
"full mp transform " << std::endl << mptransform.matrix() << std::endl;
316 std::cout <<
"mpTranslationAffine: " << std::endl << mpTranslationAffine.matrix() <<std::endl;
318 std::cout <<
"Overall transform: " << std::endl << transform.matrix() <<std::endl;
319 std::cout <<
"overall * idealinv " << std::endl << (transform * actstransform.inverse()).matrix() << std::endl;
320 std::cout <<
"overall - ideal " << std::endl;
321 for(
int test = 0;
test < transform.matrix().rows();
test++)
323 for(
int test2 = 0; test2 < transform.matrix().cols(); test2++)
327 std::cout << std::endl;
337 m_tGeometry = findNode::getClass<ActsGeometry>(topNode,
"ActsGeometry");
340 std::cout <<
"ActsGeometry not on node tree. Exiting."
361 std::cerr <<
"DST node is missing, quitting" << std::endl;
362 throw std::runtime_error(
"Failed to find DST node in AlignmentTransformation::createNodes");
365 transformMap = findNode::getClass<alignmentTransformationContainer>(topNode,
"alignmentTransformationContainer");
373 transformMapTransient = findNode::getClass<alignmentTransformationContainer>(topNode,
"alignmentTransformationContainerTransient");
387 std::cout <<
"Generating Random Perturbations..."<<std::endl;
391 std::normal_distribution<double> distribution(0,angleDev(0));
396 std::normal_distribution<double> distribution(0,angleDev(1));
401 std::normal_distribution<double> distribution(0,angleDev(2));
404 if(transformDev(0)!=0)
406 std::normal_distribution<double> distribution(0,transformDev(0));
409 if(transformDev(1)!=0)
411 std::normal_distribution<double> distribution(0,transformDev(1));
414 if(transformDev(2)!=0)
416 std::normal_distribution<double> distribution(0,transformDev(2));