From 2dbcd1eef696275c924e77d9605dd1fedc83c5ee Mon Sep 17 00:00:00 2001
From: Rene Brun <Rene.Brun@cern.ch>
Date: Wed, 5 Dec 2007 16:00:57 +0000
Subject: [PATCH] From Andrei: adds a global matrix pointer to TGeoPNEntry
 objects - needed by the alignment framework in ALICE.

git-svn-id: http://root.cern.ch/svn/root/trunk@21211 27541ba8-7e3a-0410-8455-c3a389f83636
---
 geom/inc/TGeoPhysicalNode.h   | 9 +++++----
 geom/src/TGeoManager.cxx      | 1 -
 geom/src/TGeoPhysicalNode.cxx | 7 +++++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/geom/inc/TGeoPhysicalNode.h b/geom/inc/TGeoPhysicalNode.h
index a12457ae6d3..d5ba015ce68 100644
--- a/geom/inc/TGeoPhysicalNode.h
+++ b/geom/inc/TGeoPhysicalNode.h
@@ -111,7 +111,7 @@ private:
    };   
    TGeoPhysicalNode   *fNode;        // Physical node to which this applies
    const TGeoHMatrix  *fMatrix;      // Additional matrix
-   const TGeoMatrix   *fMatrixOrig;  // Original local matrix of the last TGeoNode in the branch
+   TGeoHMatrix        *fGlobalOrig;  // Original global matrix for the linked physical node
 
 protected:
    TGeoPNEntry(const TGeoPNEntry& pne) 
@@ -126,13 +126,14 @@ public:
    virtual ~TGeoPNEntry();
    
    inline const char   *GetPath() const {return GetTitle();}
-   const TGeoHMatrix   *GetMatrix()  const {return fMatrix;}
-   const TGeoMatrix    *GetMatrixOrig() const {return fMatrixOrig;}
+   const TGeoHMatrix   *GetMatrix() const {return fMatrix;}
+   TGeoHMatrix      *GetMatrixOrig() const {if (fNode) return fNode->GetOriginalMatrix(); else return NULL;};
+   TGeoHMatrix      *GetGlobalOrig() const {return fGlobalOrig;}
    TGeoPhysicalNode *GetPhysicalNode() const {return fNode;}
    void              SetMatrix(const TGeoHMatrix *matrix);
    void              SetPhysicalNode(TGeoPhysicalNode *node);
    
-   ClassDef(TGeoPNEntry, 3)                  // a physical node entry with unique name
+   ClassDef(TGeoPNEntry, 4)                  // a physical node entry with unique name
 };
 
 #endif
diff --git a/geom/src/TGeoManager.cxx b/geom/src/TGeoManager.cxx
index ed903b649f5..eeee1fda9db 100644
--- a/geom/src/TGeoManager.cxx
+++ b/geom/src/TGeoManager.cxx
@@ -2939,7 +2939,6 @@ TGeoPhysicalNode *TGeoManager::MakeAlignablePN(TGeoPNEntry *entry)
    }
    TGeoPhysicalNode *node = MakePhysicalNode(path);
    entry->SetPhysicalNode(node);
-   node->SetMatrixOrig(entry->GetMatrixOrig());
    return node;
 }
 
diff --git a/geom/src/TGeoPhysicalNode.cxx b/geom/src/TGeoPhysicalNode.cxx
index 3ddd2f98bd9..7cf9acc5b90 100644
--- a/geom/src/TGeoPhysicalNode.cxx
+++ b/geom/src/TGeoPhysicalNode.cxx
@@ -358,7 +358,7 @@ TGeoPNEntry::TGeoPNEntry()
    else SetBit(kPNEntryOwnMatrix,kFALSE);
    fNode = 0;
    fMatrix = 0;
-   fMatrixOrig = 0;
+   fGlobalOrig = 0;
 }
 
 //_____________________________________________________________________________
@@ -374,7 +374,8 @@ TGeoPNEntry::TGeoPNEntry(const char *name, const char *path)
    }   
    gGeoManager->PushPath();
    gGeoManager->cd(path);
-   fMatrixOrig = gGeoManager->GetCurrentNode()->GetMatrix();
+   fGlobalOrig = new TGeoHMatrix();
+   *fGlobalOrig = gGeoManager->GetCurrentMatrix();
    gGeoManager->PopPath();
    SetBit(kPNEntryOwnMatrix,kFALSE);
    fNode = 0;
@@ -386,6 +387,7 @@ TGeoPNEntry::~TGeoPNEntry()
 {
 // Destructor
    if (fMatrix && TestBit(kPNEntryOwnMatrix)) delete fMatrix;
+   delete fGlobalOrig;
 }
    
 //_____________________________________________________________________________
@@ -405,3 +407,4 @@ void TGeoPNEntry::SetMatrix(const TGeoHMatrix *mat)
 // Set the additional matrix for this node entry. The matrix is owned by user.
    fMatrix = mat;
 }
+
-- 
GitLab