Skip to content

Commit bae8e1d

Browse files
committed
Port missing getMatrix method from aliroot
1 parent 525ccd4 commit bae8e1d

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

Detectors/Base/include/DetectorsBase/GeometryManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class GeometryManager : public TObject
5757
///< performed before alignment.
5858
static Bool_t getOriginalMatrix(o2::detectors::DetID detid, int sensid, TGeoHMatrix& m);
5959
static Bool_t getOriginalMatrix(const char* symname, TGeoHMatrix& m);
60+
static TGeoHMatrix* getMatrix(const char* symname);
6061
static const char* getSymbolicName(o2::detectors::DetID detid, int sensid);
6162
static TGeoPNEntry* getPNEntry(o2::detectors::DetID detid, Int_t sensid);
6263
static TGeoHMatrix* getMatrix(o2::detectors::DetID detid, Int_t sensid);
@@ -114,7 +115,7 @@ class GeometryManager : public TObject
114115
private:
115116
/// Default constructor
116117
GeometryManager() = default;
117-
118+
static TGeoHMatrix* getMatrix(TGeoPNEntry* pne);
118119
static void accountMaterial(const TGeoMaterial* material, MatBudgetExt& bd);
119120
static void accountMaterial(const TGeoMaterial* material, o2::base::MatBudget& bd)
120121
{

Detectors/Base/src/GeometryManager.cxx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,47 @@ Bool_t GeometryManager::getOriginalMatrixFromPath(const char* path, TGeoHMatrix&
118118
return kTRUE;
119119
}
120120

121+
//______________________________________________________________________
122+
TGeoHMatrix* GeometryManager::getMatrix(TGeoPNEntry* pne)
123+
{
124+
// Get the global transformation matrix for a given PNEntry
125+
// by quering the TGeoManager
126+
127+
if (!gGeoManager || !gGeoManager->IsClosed()) {
128+
LOG(ERROR) << "Can't get the global matrix! gGeoManager doesn't exist or it is still opened!";
129+
return nullptr;
130+
}
131+
132+
// if matrix already known --> return it
133+
TGeoPhysicalNode* pnode = pne->GetPhysicalNode();
134+
if (pnode) {
135+
return pnode->GetMatrix();
136+
}
137+
138+
// otherwise calculate it from title and attach via TGeoPhysicalNode
139+
pne->SetPhysicalNode(new TGeoPhysicalNode(pne->GetTitle()));
140+
return pne->GetPhysicalNode()->GetMatrix();
141+
}
142+
143+
//______________________________________________________________________
144+
TGeoHMatrix* GeometryManager::getMatrix(const char* symname)
145+
{
146+
// Get the global transformation matrix for a given alignable volume
147+
// identified by its symbolic name 'symname' by quering the TGeoManager
148+
149+
if (!gGeoManager || !gGeoManager->IsClosed()) {
150+
LOG(ERROR) << "No active geometry or geometry not yet closed!";
151+
return nullptr;
152+
}
153+
154+
TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
155+
if (!pne) {
156+
return nullptr;
157+
}
158+
159+
return getMatrix(pne);
160+
}
161+
121162
//______________________________________________________________________
122163
const char* GeometryManager::getSymbolicName(DetID detid, int sensid)
123164
{

0 commit comments

Comments
 (0)