File indexing completed on 2025-08-05 08:15:17
0001 #include <vector>
0002
0003 void init()
0004 {
0005 gSystem->Load("libGeom");
0006 TGeoManager::Import("ALICE_ITS_tgeo.root");
0007 }
0008
0009 std::vector<TGeoNode*> path;
0010 bool nodeFound = false;
0011 void getNode(TString name)
0012 {
0013 nodeFound = false;
0014 path.clear();
0015
0016 dfs(gGeoManager->GetTopNode(), name);
0017
0018 cout << "Node path: ";
0019 for(int i = 0; i < path.size(); ++i)
0020 {
0021 cout << path[i]->GetName() << " ";
0022 }
0023 cout << endl;
0024 }
0025
0026 void dfs(TGeoNode* node, TString name)
0027 {
0028
0029
0030 path.push_back(node);
0031 if(node->GetName() == name)
0032 {
0033 nodeFound = true;
0034 return;
0035 }
0036
0037 for(int i = 0; i < node->GetNdaughters(); ++i)
0038 {
0039 dfs(node->GetDaughter(i), name);
0040 if(nodeFound) return;
0041 }
0042 path.pop_back();
0043 }
0044
0045 void translation(TString name, TString mothername = "")
0046 {
0047
0048 getNode(name);
0049
0050
0051 int idx_mother = -1;
0052 if(mothername == "")
0053 {
0054 idx_mother = 0;
0055 }
0056 else
0057 {
0058 for(int i = 0; i < path.size(); ++i)
0059 {
0060 if(path[i]->GetName() == mothername)
0061 {
0062 idx_mother = i;
0063 break;
0064 }
0065 }
0066 }
0067
0068
0069 TGeoHMatrix mat;
0070 for(int i = idx_mother+1; i < path.size(); ++i)
0071 {
0072 mat *= (*path[i]->GetMatrix());
0073 }
0074
0075 cout << "Translation from " << name << " to " << mothername << endl;
0076 mat.Print();
0077 }