5 #include <TGeoManager.h>
6 #include <TGeoPhysicalNode.h>
12 void FairAlignmentHandler::AlignGeometry()
const
14 if (fAlignmentMatrices.size() > 0) {
15 LOG(info) <<
"aligning the geometry...";
17 LOG(info) <<
"aligning in total " << fAlignmentMatrices.size() <<
" volumes.";
18 if (gGeoManager->GetNAlignable() > 0) {
19 AlignGeometryBySymlink();
21 AlignGeometryByFullPath();
24 LOG(info) <<
"alignment finished!";
28 void FairAlignmentHandler::AlignGeometryByFullPath()
const
32 LOG(info) <<
"aligning using full path.";
33 for (
auto const& alignment_entry : fAlignmentMatrices) {
34 volume_path = alignment_entry.first;
36 gGeoManager->cd(volume_path);
38 TGeoNode* volume_node = gGeoManager->GetCurrentNode();
39 TGeoMatrix* volume_matrix = volume_node->GetMatrix();
43 TGeoHMatrix local_volume_matrix = TGeoHMatrix(*volume_matrix);
45 TGeoHMatrix* new_volume_matrix =
new TGeoHMatrix(local_volume_matrix * alignment_entry.second);
48 TGeoPhysicalNode* pn = gGeoManager->MakePhysicalNode(volume_path);
50 pn->Align(new_volume_matrix);
52 LOG(info) <<
"alignments applied!";
55 void FairAlignmentHandler::AlignGeometryBySymlink()
const
59 LOG(info) <<
"aligning using symlinks";
60 for (
auto const& alignment_entry : fAlignmentMatrices) {
61 volume_path = alignment_entry.first;
63 TGeoPhysicalNode* node = NULL;
64 TGeoPNEntry* entry = gGeoManager->GetAlignableEntry(volume_path);
66 node = gGeoManager->MakeAlignablePN(entry);
69 TGeoMatrix* volume_matrix = NULL;
71 volume_matrix = node->GetMatrix();
77 TGeoHMatrix local_volume_matrix = TGeoHMatrix(*volume_matrix);
79 TGeoHMatrix* new_volume_matrix =
new TGeoHMatrix(local_volume_matrix * alignment_entry.second);
81 node->Align(new_volume_matrix);
85 void FairAlignmentHandler::AddAlignmentMatrices(
const std::map<std::string, TGeoHMatrix>& alignmentMatrices,
88 LOG(info) <<
"adding inverting matrices...";
89 for (
auto const& m : alignmentMatrices) {
91 fAlignmentMatrices[m.first] *= m.second.Inverse();
93 fAlignmentMatrices[m.first] *= m.second;
virtual ~FairAlignmentHandler()