From 4fbb979824a540ba3740e407dc331f4e2397608f Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Wed, 1 Oct 2003 17:53:12 +0000 Subject: [PATCH] From Andrei Gheata: several bug fixes. git-svn-id: http://root.cern.ch/svn/root/trunk@7390 27541ba8-7e3a-0410-8455-c3a389f83636 --- geom/inc/TGeoCache.h | 6 +++++- geom/src/TGeoCache.cxx | 27 ++++++++++++++++++--------- geom/src/TGeoManager.cxx | 7 ++----- geom/src/TGeoMatrix.cxx | 4 +++- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/geom/inc/TGeoCache.h b/geom/inc/TGeoCache.h index 32ce4f6ddca..8d9fad96e75 100644 --- a/geom/inc/TGeoCache.h +++ b/geom/inc/TGeoCache.h @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: $:$Id: TGeoCache.h,v 1.15 2003/03/14 11:49:02 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoCache.h,v 1.16 2003/06/17 09:13:55 brun Exp $ // Author: Andrei Gheata 18/03/02 /************************************************************************* @@ -43,6 +43,7 @@ class TGeoCacheState : public TObject { protected: Int_t fLevel; // level in the current branch + Int_t fIdBranch[30]; // ID branch Double_t *fPoint; // last point in master frame Bool_t fOverlapping; // overlap flag public: @@ -145,6 +146,8 @@ public: virtual void ClearDaughter(Int_t index); virtual void ClearNode(Int_t nindex); virtual void Compact(); + void FillIdBranch(const Int_t *br) {memcpy(fIdBranch,br,(fLevel+1)*sizeof(Int_t)); fIndex=fIdBranch[fLevel];} + const Int_t *GetIdBranch() const {return fIdBranch;} virtual void DeleteCaches(); virtual Bool_t DumpNodes(); virtual void *GetBranch() const {return fBranch;} @@ -168,6 +171,7 @@ public: virtual Int_t GetNodeId() const; Int_t GetSize() const {return fSize;} virtual Int_t GetUsageCount() const; + Bool_t HasIdArray() const {return (fNodeIdArray)?kTRUE:kFALSE;} virtual void IncreasePool(Int_t size) {fSize+=size;} virtual void IncrementUsageCount(); Int_t Index(Int_t nindex) const {return (nindex & 0xFFFFFF);} diff --git a/geom/src/TGeoCache.cxx b/geom/src/TGeoCache.cxx index 9be8dd28105..8c82bb010e0 100644 --- a/geom/src/TGeoCache.cxx +++ b/geom/src/TGeoCache.cxx @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: $:$Id: TGeoCache.cxx,v 1.20 2003/06/24 12:37:39 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoCache.cxx,v 1.21 2003/08/08 09:22:18 brun Exp $ // Author: Andrei Gheata 18/03/02 /************************************************************************* @@ -154,6 +154,7 @@ void TGeoNodeCache::BuildIdArray() Int_t ifree = 1; Int_t nodeid = 0; gGeoManager->GetTopNode()->FillIdArray(ifree, nodeid, fNodeIdArray); + fIdBranch[0] = 0; } //_____________________________________________________________________________ @@ -1462,8 +1463,10 @@ void TGeoCacheState::SetState(Int_t level, Bool_t ovlp, Double_t *point) fLevel = -1; return; } - memcpy(fBranch, (Int_t*)gGeoManager->GetCache()->GetBranch(), (level+1)*sizeof(Int_t)); - memcpy(fMatrices, (Int_t*)gGeoManager->GetCache()->GetMatrices(), (level+1)*sizeof(Int_t)); + TGeoNodeCache *cache = gGeoManager->GetCache(); + if (cache->HasIdArray()) memcpy(fIdBranch, cache->GetIdBranch(), (level+1)*sizeof(Int_t)); + memcpy(fBranch, (Int_t*)cache->GetBranch(), (level+1)*sizeof(Int_t)); + memcpy(fMatrices, (Int_t*)cache->GetMatrices(), (level+1)*sizeof(Int_t)); fOverlapping = ovlp; if (point) memcpy(fPoint, point, 3*sizeof(Double_t)); } @@ -1476,8 +1479,10 @@ Bool_t TGeoCacheState::GetState(Int_t &level, Double_t *point) const level = 0; return kFALSE; } - memcpy((Int_t*)gGeoManager->GetCache()->GetBranch(), fBranch, (level+1)*sizeof(Int_t)); - memcpy((Int_t*)gGeoManager->GetCache()->GetMatrices(), fMatrices, (level+1)*sizeof(Int_t)); + TGeoNodeCache *cache = gGeoManager->GetCache(); + if (cache->HasIdArray()) cache->FillIdBranch(fIdBranch); + memcpy((Int_t*)cache->GetBranch(), fBranch, (level+1)*sizeof(Int_t)); + memcpy((Int_t*)cache->GetMatrices(), fMatrices, (level+1)*sizeof(Int_t)); if (point) memcpy(point, fPoint, 3*sizeof(Double_t)); return fOverlapping; } @@ -1528,8 +1533,10 @@ TGeoCacheStateDummy::~TGeoCacheStateDummy() void TGeoCacheStateDummy::SetState(Int_t level, Bool_t ovlp, Double_t *point) { fLevel = level; - TGeoNode **node_branch = (TGeoNode **) gGeoManager->GetCache()->GetBranch(); - TGeoHMatrix **mat_branch = (TGeoHMatrix **) gGeoManager->GetCache()->GetMatrices(); + TGeoNodeCache *cache = gGeoManager->GetCache(); + if (cache->HasIdArray()) memcpy(fIdBranch, cache->GetIdBranch(), (level+1)*sizeof(Int_t)); + TGeoNode **node_branch = (TGeoNode **) cache->GetBranch(); + TGeoHMatrix **mat_branch = (TGeoHMatrix **) cache->GetMatrices(); memcpy(fNodeBranch, node_branch, (level+1)*sizeof(TGeoNode *)); for (Int_t i=0; i<level+1; i++) @@ -1542,8 +1549,10 @@ void TGeoCacheStateDummy::SetState(Int_t level, Bool_t ovlp, Double_t *point) Bool_t TGeoCacheStateDummy::GetState(Int_t &level, Double_t *point) const { level = fLevel; - TGeoNode **node_branch = (TGeoNode **) gGeoManager->GetCache()->GetBranch(); - TGeoHMatrix **mat_branch = (TGeoHMatrix **) gGeoManager->GetCache()->GetMatrices(); + TGeoNodeCache *cache = gGeoManager->GetCache(); + if (cache->HasIdArray()) cache->FillIdBranch(fIdBranch); + TGeoNode **node_branch = (TGeoNode **) cache->GetBranch(); + TGeoHMatrix **mat_branch = (TGeoHMatrix **) cache->GetMatrices(); memcpy(node_branch, fNodeBranch, (level+1)*sizeof(TGeoNode *)); for (Int_t i=0; i<level+1; i++) diff --git a/geom/src/TGeoManager.cxx b/geom/src/TGeoManager.cxx index 3dce81717e6..3d0fca1b0be 100644 --- a/geom/src/TGeoManager.cxx +++ b/geom/src/TGeoManager.cxx @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: $:$Id: TGeoManager.cxx,v 1.60 2003/08/21 10:17:16 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoManager.cxx,v 1.61 2003/09/23 10:33:15 brun Exp $ // Author: Andrei Gheata 25/10/01 /************************************************************************* @@ -777,10 +777,7 @@ void TGeoManager::Matrix(Int_t index, Double_t theta1, Double_t phi1, // theta3 polar angle for axis Z // phi3 azimuthal angle for axis Z // - - char name[50]; - sprintf(name,"rot%d",index); - TGeoRotation * rot = new TGeoRotation(name,theta1,phi1,theta2,phi2,theta3,phi3); + TGeoRotation * rot = new TGeoRotation("",theta1,phi1,theta2,phi2,theta3,phi3); rot->SetUniqueID(index); rot->RegisterYourself(); } diff --git a/geom/src/TGeoMatrix.cxx b/geom/src/TGeoMatrix.cxx index 9eebce4fcf0..3fa160a5e08 100644 --- a/geom/src/TGeoMatrix.cxx +++ b/geom/src/TGeoMatrix.cxx @@ -1,4 +1,4 @@ -// @(#)root/geom:$Name: $:$Id: TGeoMatrix.cxx,v 1.11 2003/07/31 20:19:32 brun Exp $ +// @(#)root/geom:$Name: $:$Id: TGeoMatrix.cxx,v 1.12 2003/09/25 14:50:40 brun Exp $ // Author: Andrei Gheata 25/10/01 /************************************************************************* @@ -956,6 +956,7 @@ TGeoCombiTrans::TGeoCombiTrans(Double_t dx, Double_t dy, Double_t dz, TGeoRotati SetBit(kGeoCombiTrans); SetDefaultName(); SetTranslation(dx, dy, dz); + fRotation = 0; SetRotation(rot); } //----------------------------------------------------------------------------- @@ -965,6 +966,7 @@ TGeoCombiTrans::TGeoCombiTrans(const char *name, Double_t dx, Double_t dy, Doubl // ctor SetBit(kGeoCombiTrans); SetTranslation(dx, dy, dz); + fRotation = 0; SetRotation(rot); } //----------------------------------------------------------------------------- -- GitLab