Skip to content

Commit

Permalink
fixed a typo in setting auxilary field, and added a macro to get
Browse files Browse the repository at this point in the history
translation matrix from two physical volumes
  • Loading branch information
liuk committed Apr 6, 2016
1 parent 4c0f521 commit 4f2eba8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Tracking/ITSTGeoImport/ITS.gdml
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@
<volume name="ITSUSensor0">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x3"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor0"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor0"/>
</volume>
<volume name="ITSUChip0">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -3910,7 +3910,7 @@
<volume name="ITSUSensor1">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x19"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor1"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor1"/>
</volume>
<volume name="ITSUChip1">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -4811,7 +4811,7 @@
<volume name="ITSUSensor2">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x35"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor2"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor2"/>
</volume>
<volume name="ITSUChip2">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -5760,7 +5760,7 @@
<volume name="ITSUSensor3">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x49"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor3"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor3"/>
</volume>
<volume name="ITSUChip3">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -6769,7 +6769,7 @@
<volume name="ITSUSensor4">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x51"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor4"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor4"/>
</volume>
<volume name="ITSUChip4">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -7342,7 +7342,7 @@
<volume name="ITSUSensor5">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x53"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor5"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor5"/>
</volume>
<volume name="ITSUChip5">
<materialref ref="ITS_SI"/>
Expand Down Expand Up @@ -8039,7 +8039,7 @@
<volume name="ITSUSensor6">
<materialref ref="ITS_SI"/>
<solidref ref="TGeoBBox0x55"/>
<auxiliary auxtype="SensDet" auxvlue="ITSUSensor6"/>
<auxiliary auxtype="SensDet" auxvalue="ITSUSensor6"/>
</volume>
<volume name="ITSUChip6">
<materialref ref="ITS_SI"/>
Expand Down
2 changes: 1 addition & 1 deletion Tracking/ITSTGeoImport/fixGDML.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

element = xml.etree.ElementTree.SubElement(lv, 'auxiliary')
element.set('auxtype', 'SensDet')
element.set('auxvlue', lv.attrib['name'])
element.set('auxvalue', lv.attrib['name'])

# reparse the xml to a string
rough_string = xml.etree.ElementTree.tostring(root, 'utf-8')
Expand Down
77 changes: 77 additions & 0 deletions Tracking/ITSTGeoImport/translation.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <vector>

void init()
{
gSystem->Load("libGeom");
TGeoManager::Import("ALICE_ITS_tgeo.root");
}

std::vector<TGeoNode*> path;
bool nodeFound = false;
void getNode(TString name)
{
nodeFound = false;
path.clear();

dfs(gGeoManager->GetTopNode(), name);

cout << "Node path: ";
for(int i = 0; i < path.size(); ++i)
{
cout << path[i]->GetName() << " ";
}
cout << endl;
}

void dfs(TGeoNode* node, TString name)
{
//if(nodeFound) return;

path.push_back(node);
if(node->GetName() == name)
{
nodeFound = true;
return;
}

for(int i = 0; i < node->GetNdaughters(); ++i)
{
dfs(node->GetDaughter(i), name);
if(nodeFound) return;
}
path.pop_back();
}

void translation(TString name, TString mothername = "")
{
//Get the node and path from world
getNode(name);

//Get mother node index
int idx_mother = -1;
if(mothername == "")
{
idx_mother = 0;
}
else
{
for(int i = 0; i < path.size(); ++i)
{
if(path[i]->GetName() == mothername)
{
idx_mother = i;
break;
}
}
}

//Get the transformation matrix level-by-level
TGeoHMatrix mat;
for(int i = idx_mother+1; i < path.size(); ++i)
{
mat *= (*path[i]->GetMatrix());
}

cout << "Translation from " << name << " to " << mothername << endl;
mat.Print();
}

0 comments on commit 4f2eba8

Please sign in to comment.